xref: /haiku/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.h (revision 2db0fbd87ec3eeed8ab9b08ecfd1c41891c7e3a6)
1 /*
2  * Copyright 2018-2020, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 
7 #ifndef LOCAL_REPOSITORY_UPDATE_PROCESS__H
8 #define LOCAL_REPOSITORY_UPDATE_PROCESS__H
9 
10 
11 #include "AbstractProcess.h"
12 
13 #include <File.h>
14 #include <Path.h>
15 #include <String.h>
16 #include <Url.h>
17 
18 #include <package/Context.h>
19 #include <package/PackageRoster.h>
20 #include <package/RepositoryCache.h>
21 
22 #include "Model.h"
23 #include "PackageInfo.h"
24 
25 
26 /*! This process is intended to, for each repository configured on the host,
27     retrieve an updated set of data for the repository from the remote
28     repository site.  This is typically HPKR data copied over to the local
29     machine.  From there, a latter process will process this data by using the
30     facilities of the Package Kit.
31 */
32 
33 class LocalRepositoryUpdateProcess : public AbstractProcess {
34 public:
35 								LocalRepositoryUpdateProcess(
36 									Model *model, bool force = false);
37 	virtual						~LocalRepositoryUpdateProcess();
38 
39 			const char*			Name() const;
40 			const char*			Description() const;
41 
42 protected:
43 	virtual status_t			RunInternal();
44 
45 private:
46 			bool				_ShouldRunForRepositoryName(
47 									const BString& repoName,
48 									BPackageKit::BPackageRoster& roster,
49 									BPackageKit::BRepositoryCache* cache);
50 
51 			status_t			_RunForRepositoryName(const BString& repoName,
52 									BPackageKit::BContext& context,
53 									BPackageKit::BPackageRoster& roster,
54 									BPackageKit::BRepositoryCache* cache);
55 
56 			void				_NotifyError(const BString& error) const;
57 			void				_NotifyError(const BString& error,
58 									const BString& details) const;
59 
60 private:
61 			Model*				fModel;
62 			bool				fForce;
63 };
64 
65 #endif // LOCAL_REPOSITORY_UPDATE_PROCESS__H
66