1 /* 2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>. 3 * Copyright 2016-2024, Andrew Lindesay <apl@lindesay.co.nz>. 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 #ifndef PACKAGE_INFO_H 7 #define PACKAGE_INFO_H 8 9 10 #include <Referenceable.h> 11 #include <package/PackageInfo.h> 12 13 #include "Language.h" 14 #include "List.h" 15 #include "PackageClassificationInfo.h" 16 #include "PackageInfoListener.h" 17 #include "PackageLocalInfo.h" 18 #include "PackageLocalizedText.h" 19 #include "PackageScreenshotInfo.h" 20 #include "PublisherInfo.h" 21 #include "ScreenshotInfo.h" 22 #include "UserRatingInfo.h" 23 24 25 using BPackageKit::BPackageInfo; 26 using BPackageKit::BPackageVersion; 27 28 29 class PackageInfo : public BReferenceable { 30 public: 31 PackageInfo(); 32 PackageInfo(const BPackageInfo& info); 33 PackageInfo(const PackageInfo& other); 34 35 PackageInfo& operator=(const PackageInfo& other); 36 bool operator==(const PackageInfo& other) const; 37 bool operator!=(const PackageInfo& other) const; 38 39 uint32 DiffMask(const PackageInfo& other) const; 40 41 const BString& Name() const 42 { return fName; } 43 44 PackageLocalizedTextRef 45 LocalizedText() const; 46 void SetLocalizedText(PackageLocalizedTextRef value); 47 48 const BPackageVersion& 49 Version() const 50 { return fVersion; } 51 const PublisherInfo& Publisher() const 52 { return fPublisher; } 53 54 const BString Architecture() const 55 { return fArchitecture; } 56 57 void SetPackageClassificationInfo( 58 PackageClassificationInfoRef value); 59 PackageClassificationInfoRef 60 PackageClassificationInfo() const 61 { return fClassificationInfo; } 62 63 UserRatingInfoRef UserRatingInfo() const; 64 void SetUserRatingInfo(UserRatingInfoRef userRatingInfo); 65 66 PackageLocalInfoRef LocalInfo() const; 67 void SetLocalInfo(PackageLocalInfoRef& localInfo); 68 69 PackageScreenshotInfoRef 70 ScreenshotInfo() const 71 { return fScreenshotInfo; } 72 void SetScreenshotInfo(PackageScreenshotInfoRef value); 73 74 void SetVersionCreateTimestamp(uint64 value); 75 uint64 VersionCreateTimestamp() const 76 { return fVersionCreateTimestamp; } 77 78 void SetDepotName(const BString& depotName); 79 const BString& DepotName() const 80 { return fDepotName; } 81 82 bool AddListener( 83 const PackageInfoListenerRef& listener); 84 void RemoveListener( 85 const PackageInfoListenerRef& listener); 86 87 void StartCollatingChanges(); 88 void EndCollatingChanges(); 89 void NotifyChangedIcon(); 90 91 private: 92 void _NotifyListeners(uint32 changes); 93 void _NotifyListenersImmediate(uint32 changes); 94 95 private: 96 BString fName; 97 BPackageVersion fVersion; 98 // milliseconds since epoch 99 uint64 fVersionCreateTimestamp; 100 PublisherInfo fPublisher; 101 BString fArchitecture; 102 BString fDepotName; 103 104 PackageLocalizedTextRef 105 fLocalizedText; 106 PackageClassificationInfoRef 107 fClassificationInfo; 108 PackageScreenshotInfoRef 109 fScreenshotInfo; 110 UserRatingInfoRef fUserRatingInfo; 111 PackageLocalInfoRef fLocalInfo; 112 113 std::vector<PackageInfoListenerRef> 114 fListeners; 115 bool fIsCollatingChanges; 116 uint32 fCollatedChanges; 117 118 119 }; 120 121 122 typedef BReference<PackageInfo> PackageInfoRef; 123 124 125 #endif // PACKAGE_INFO_H 126