xref: /haiku/headers/os/package/PackageRoster.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2011-2014, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__PACKAGE_ROSTER_H_
6 #define _PACKAGE__PACKAGE_ROSTER_H_
7 
8 
9 #include <Entry.h>
10 #include <FindDirectory.h>
11 #include <Path.h>
12 
13 #include <package/PackageDefs.h>
14 
15 
16 class BStringList;
17 
18 
19 namespace BPackageKit {
20 
21 
22 struct BRepositoryConfigVisitor {
23 	virtual ~BRepositoryConfigVisitor()
24 	{
25 	}
26 
27 	virtual status_t operator()(const BEntry& entry) = 0;
28 };
29 
30 
31 class BInstallationLocationInfo;
32 class BPackageInfoSet;
33 class BRepositoryCache;
34 class BRepositoryConfig;
35 
36 
37 // watchable events
38 enum {
39 	B_WATCH_PACKAGE_INSTALLATION_LOCATIONS	= 0x0001,
40 		// de-/activation of packages in standard installation locations
41 };
42 
43 // notification message "event" field values
44 enum {
45 	B_INSTALLATION_LOCATION_PACKAGES_CHANGED,
46 		// "location": int32
47 		//		the installation location
48 		//		(B_PACKAGE_INSTALLATION_LOCATION_{SYSTEM,HOME}
49 		// "change count": int64
50 		//		the installation location change count
51 };
52 
53 
54 class BPackageRoster {
55 public:
56 								BPackageRoster();
57 								~BPackageRoster();
58 
59 			status_t			GetCommonRepositoryCachePath(BPath* path,
60 									bool create = false) const;
61 			status_t			GetUserRepositoryCachePath(BPath* path,
62 									bool create = false) const;
63 
64 			status_t			GetCommonRepositoryConfigPath(BPath* path,
65 									bool create = false) const;
66 			status_t			GetUserRepositoryConfigPath(BPath* path,
67 									bool create = false) const;
68 
69 			status_t			GetRepositoryNames(BStringList& names);
70 
71 			status_t			VisitCommonRepositoryConfigs(
72 									BRepositoryConfigVisitor& visitor);
73 			status_t			VisitUserRepositoryConfigs(
74 									BRepositoryConfigVisitor& visitor);
75 
76 			status_t			GetRepositoryCache(const BString& name,
77 									BRepositoryCache* repositoryCache);
78 			status_t			GetRepositoryConfig(const BString& name,
79 									BRepositoryConfig* repositoryConfig);
80 
81 			status_t			GetInstallationLocationInfo(
82 									BPackageInstallationLocation location,
83 									BInstallationLocationInfo& _info);
84 			status_t			GetActivePackages(
85 									BPackageInstallationLocation location,
86 									BPackageInfoSet& packageInfos);
87 
88 			status_t			StartWatching(const BMessenger& target,
89 									uint32 eventMask);
90 			status_t			StopWatching(const BMessenger& target);
91 
92 private:
93 			status_t			_GetRepositoryPath(BPath* path, bool create,
94 									directory_which whichDir) const;
95 			status_t			_VisitRepositoryConfigs(const BPath& path,
96 									BRepositoryConfigVisitor& visitor);
97 };
98 
99 
100 }	// namespace BPackageKit
101 
102 
103 #endif // _PACKAGE__PACKAGE_ROSTER_H_
104