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 bool IsRebootNeeded(); 60 61 status_t GetCommonRepositoryCachePath(BPath* path, 62 bool create = false) const; 63 status_t GetUserRepositoryCachePath(BPath* path, 64 bool create = false) const; 65 66 status_t GetCommonRepositoryConfigPath(BPath* path, 67 bool create = false) const; 68 status_t GetUserRepositoryConfigPath(BPath* path, 69 bool create = false) const; 70 71 status_t GetRepositoryNames(BStringList& names); 72 73 status_t VisitCommonRepositoryConfigs( 74 BRepositoryConfigVisitor& visitor); 75 status_t VisitUserRepositoryConfigs( 76 BRepositoryConfigVisitor& visitor); 77 78 status_t GetRepositoryCache(const BString& name, 79 BRepositoryCache* repositoryCache); 80 status_t GetRepositoryConfig(const BString& name, 81 BRepositoryConfig* repositoryConfig); 82 83 status_t GetInstallationLocationInfo( 84 BPackageInstallationLocation location, 85 BInstallationLocationInfo& _info); 86 status_t GetActivePackages( 87 BPackageInstallationLocation location, 88 BPackageInfoSet& packageInfos); 89 90 status_t StartWatching(const BMessenger& target, 91 uint32 eventMask); 92 status_t StopWatching(const BMessenger& target); 93 94 private: 95 status_t _GetRepositoryPath(BPath* path, bool create, 96 directory_which whichDir) const; 97 status_t _VisitRepositoryConfigs(const BPath& path, 98 BRepositoryConfigVisitor& visitor); 99 }; 100 101 102 } // namespace BPackageKit 103 104 105 #endif // _PACKAGE__PACKAGE_ROSTER_H_ 106