1 /* 2 * Copyright (c) 2007, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * Łukasz 'Sil2100' Zemczak <sil2100@vexillium.org> 7 */ 8 #ifndef INSTALLEDPACKAGEINFO_H 9 #define INSTALLEDPACKAGEINFO_H 10 11 #include <File.h> 12 #include <String.h> 13 #include <List.h> 14 #include <Path.h> 15 16 17 #define P_BUSY_TRIES 10 18 19 enum { 20 P_PACKAGE_INFO = 'ppki' 21 }; 22 23 extern const char * kPackagesDir; 24 25 26 // Useful function for fetching the package name and version without parsing all 27 // other data 28 status_t info_get_package_name(const char *filename, BString &name); 29 status_t info_get_package_version(const char *filename, BString &name); 30 31 32 class InstalledPackageInfo { 33 public: 34 InstalledPackageInfo(); 35 InstalledPackageInfo(const char *packageName, const char *version = NULL, 36 bool create = false); 37 ~InstalledPackageInfo(); 38 39 status_t InitCheck(); 40 status_t SetTo(const char *packageName, const char *version = NULL, 41 bool create = false); 42 43 void SetName(const char *name) { fName = name; } 44 const char *GetName() { return fName.String(); } 45 void SetDescription(const char *description) { fDescription = description; } 46 const char *GetDescription() { return fDescription.String(); } 47 //void SetVersion(const char *version) { fVersion = version; } 48 const char *GetVersion() { return fVersion.String(); } 49 void SetSpaceNeeded(uint64 size) { fSpaceNeeded = size; } 50 uint64 GetSpaceNeeded() { return fSpaceNeeded; } 51 52 status_t AddItem(const char *itemName); 53 54 status_t Uninstall(); 55 status_t Save(); 56 57 private: 58 void _ClearItemList(); 59 60 status_t fStatus; 61 bool fIsUpToDate; 62 bool fCreate; 63 64 BString fName; 65 BString fDescription; 66 BString fVersion; 67 uint64 fSpaceNeeded; 68 BList fInstalledItems; 69 70 BPath fPathToInfo; 71 }; 72 73 74 #endif 75 76