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
16class BStringList;
17
18
19namespace BPackageKit {
20
21
22struct BRepositoryConfigVisitor {
23	virtual ~BRepositoryConfigVisitor()
24	{
25	}
26
27	virtual status_t operator()(const BEntry& entry) = 0;
28};
29
30
31class BInstallationLocationInfo;
32class BPackageInfoSet;
33class BRepositoryCache;
34class BRepositoryConfig;
35class BPackageInfo;
36
37
38// watchable events
39enum {
40	B_WATCH_PACKAGE_INSTALLATION_LOCATIONS	= 0x0001,
41		// de-/activation of packages in standard installation locations
42};
43
44// notification message "event" field values
45enum {
46	B_INSTALLATION_LOCATION_PACKAGES_CHANGED,
47		// "location": int32
48		//		the installation location
49		//		(B_PACKAGE_INSTALLATION_LOCATION_{SYSTEM,HOME}
50		// "change count": int64
51		//		the installation location change count
52};
53
54
55class BPackageRoster {
56public:
57								BPackageRoster();
58								~BPackageRoster();
59
60			bool				IsRebootNeeded();
61
62			status_t			GetCommonRepositoryCachePath(BPath* path,
63									bool create = false) const;
64			status_t			GetUserRepositoryCachePath(BPath* path,
65									bool create = false) const;
66
67			status_t			GetCommonRepositoryConfigPath(BPath* path,
68									bool create = false) const;
69			status_t			GetUserRepositoryConfigPath(BPath* path,
70									bool create = false) const;
71
72			status_t			GetRepositoryNames(BStringList& names);
73
74			status_t			VisitCommonRepositoryConfigs(
75									BRepositoryConfigVisitor& visitor);
76			status_t			VisitUserRepositoryConfigs(
77									BRepositoryConfigVisitor& visitor);
78
79			status_t			GetRepositoryCache(const BString& name,
80									BRepositoryCache* repositoryCache);
81			status_t			GetRepositoryConfig(const BString& name,
82									BRepositoryConfig* repositoryConfig);
83
84			status_t			GetInstallationLocationInfo(
85									BPackageInstallationLocation location,
86									BInstallationLocationInfo& _info);
87			status_t			GetActivePackages(
88									BPackageInstallationLocation location,
89									BPackageInfoSet& packageInfos);
90
91			status_t			IsPackageActive(
92									BPackageInstallationLocation location,
93									const BPackageInfo info, bool* active);
94
95			status_t			StartWatching(const BMessenger& target,
96									uint32 eventMask);
97			status_t			StopWatching(const BMessenger& target);
98
99private:
100			status_t			_GetRepositoryPath(BPath* path, bool create,
101									directory_which whichDir) const;
102			status_t			_VisitRepositoryConfigs(const BPath& path,
103									BRepositoryConfigVisitor& visitor);
104};
105
106
107}	// namespace BPackageKit
108
109
110#endif // _PACKAGE__PACKAGE_ROSTER_H_
111