2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
3 * Copyright 2016-2017, Andrew Lindesay <apl@lindesay.co.nz>.
4 * All rights reserved. Distributed under the terms of the MIT License.
12 #include <Referenceable.h>
13 #include <package/PackageInfo.h>
16 #include "PackageInfoListener.h"
17 #include "SharedBitmap.h"
26 UserInfo(const BString
& nickName
);
27 UserInfo(const BitmapRef
& avatar
,
28 const BString
& nickName
);
29 UserInfo(const UserInfo
& other
);
31 UserInfo
& operator=(const UserInfo
& other
);
32 bool operator==(const UserInfo
& other
) const;
33 bool operator!=(const UserInfo
& other
) const;
35 const BitmapRef
& Avatar() const
37 const BString
& NickName() const
49 UserRating(const UserInfo
& userInfo
,
51 const BString
& comment
,
52 const BString
& language
,
53 const BString
& packageVersion
,
54 int32 upVotes
, int32 downVotes
);
55 UserRating(const UserRating
& other
);
57 UserRating
& operator=(const UserRating
& other
);
58 bool operator==(const UserRating
& other
) const;
59 bool operator!=(const UserRating
& other
) const;
61 const UserInfo
& User() const
63 const BString
& Comment() const
65 const BString
& Language() const
67 const float Rating() const
69 const BString
& PackageVersion() const
70 { return fPackageVersion
; }
74 int32
DownVotes() const
75 { return fDownVotes
; }
81 BString fPackageVersion
;
87 typedef List
<UserRating
, false> UserRatingList
;
93 RatingSummary(const RatingSummary
& other
);
95 RatingSummary
& operator=(const RatingSummary
& other
);
96 bool operator==(const RatingSummary
& other
) const;
97 bool operator!=(const RatingSummary
& other
) const;
103 int ratingCountByStar
[5];
107 class StabilityRating
{
111 const BString
& label
,
112 const BString
& name
);
113 StabilityRating(const StabilityRating
& other
);
115 StabilityRating
& operator=(const StabilityRating
& other
);
116 bool operator==(const StabilityRating
& other
) const;
117 bool operator!=(const StabilityRating
& other
) const;
119 const BString
& Label() const
121 const BString
& Name() const
129 typedef List
<StabilityRating
, false> StabilityRatingList
;
132 class PublisherInfo
{
135 PublisherInfo(const BitmapRef
& logo
,
137 const BString
& email
,
138 const BString
& website
);
139 PublisherInfo(const PublisherInfo
& other
);
141 PublisherInfo
& operator=(const PublisherInfo
& other
);
142 bool operator==(const PublisherInfo
& other
) const;
143 bool operator!=(const PublisherInfo
& other
) const;
145 const BitmapRef
& Logo() const
147 const BString
& Name() const
149 const BString
& Email() const
151 const BString
& Website() const
162 class PackageCategory
: public BReferenceable
{
165 PackageCategory(const BitmapRef
& icon
,
166 const BString
& label
,
167 const BString
& name
);
168 PackageCategory(const PackageCategory
& other
);
170 PackageCategory
& operator=(const PackageCategory
& other
);
171 bool operator==(const PackageCategory
& other
) const;
172 bool operator!=(const PackageCategory
& other
) const;
174 const BitmapRef
& Icon() const
176 const BString
& Label() const
178 const BString
& Name() const
187 typedef BReference
<PackageCategory
> CategoryRef
;
188 typedef List
<CategoryRef
, false> CategoryList
;
191 class ScreenshotInfo
{
194 ScreenshotInfo(const BString
& code
,
195 int32 width
, int32 height
, int32 dataSize
);
196 ScreenshotInfo(const ScreenshotInfo
& other
);
198 ScreenshotInfo
& operator=(const ScreenshotInfo
& other
);
199 bool operator==(const ScreenshotInfo
& other
) const;
200 bool operator!=(const ScreenshotInfo
& other
) const;
202 const BString
& Code() const
208 int32
DataSize() const
209 { return fDataSize
; }
219 typedef List
<ScreenshotInfo
, false, 2> ScreenshotInfoList
;
222 typedef List
<PackageInfoListenerRef
, false, 2> PackageListenerList
;
223 typedef std::set
<int32
> PackageInstallationLocationSet
;
236 using BPackageKit::BPackageInfo
;
237 using BPackageKit::BPackageVersion
;
240 class PackageInfo
: public BReferenceable
{
243 PackageInfo(const BPackageInfo
& info
);
246 const BPackageVersion
& version
,
247 const PublisherInfo
& publisher
,
248 const BString
& shortDescription
,
249 const BString
& fullDescription
,
251 const char* architecture
);
252 PackageInfo(const PackageInfo
& other
);
254 PackageInfo
& operator=(const PackageInfo
& other
);
255 bool operator==(const PackageInfo
& other
) const;
256 bool operator!=(const PackageInfo
& other
) const;
258 const BString
& Name() const
260 void SetTitle(const BString
& title
);
261 const BString
& Title() const;
262 const BPackageVersion
& Version() const
264 void SetShortDescription(const BString
& description
);
265 const BString
& ShortDescription() const
266 { return fShortDescription
; }
267 void SetFullDescription(const BString
& description
);
268 const BString
& FullDescription() const
269 { return fFullDescription
; }
270 const PublisherInfo
& Publisher() const
271 { return fPublisher
; }
273 void SetIcon(const BitmapRef
& icon
);
274 const BitmapRef
& Icon() const
276 void SetChangelog(const BString
& changelog
);
277 const BString
& Changelog() const
278 { return fChangelog
; }
282 bool IsSystemPackage() const;
284 bool IsSystemDependency() const
285 { return fSystemDependency
; }
286 void SetSystemDependency(bool isDependency
);
288 const BString
Architecture() const
289 { return fArchitecture
; }
291 PackageState
State() const
293 void SetState(PackageState state
);
295 const PackageInstallationLocationSet
&
296 InstallationLocations() const
297 { return fInstallationLocations
; }
298 void AddInstallationLocation(int32 location
);
300 float DownloadProgress() const
301 { return fDownloadProgress
; }
302 void SetDownloadProgress(float progress
);
304 void SetLocalFilePath(const char* path
);
305 const BString
& LocalFilePath() const
306 { return fLocalFilePath
; }
307 bool IsLocalFile() const;
308 const BString
& FileName() const
309 { return fFileName
; }
311 void ClearCategories();
312 bool AddCategory(const CategoryRef
& category
);
313 const CategoryList
& Categories() const
314 { return fCategories
; }
316 void ClearUserRatings();
317 bool AddUserRating(const UserRating
& rating
);
318 const UserRatingList
& UserRatings() const
319 { return fUserRatings
; }
320 void SetRatingSummary(const RatingSummary
& summary
);
321 RatingSummary
CalculateRatingSummary() const;
323 void SetProminence(float prominence
);
324 float Prominence() const
325 { return fProminence
; }
326 bool HasProminence() const
327 { return fProminence
!= 0.0f
; }
328 bool IsProminent() const;
330 void ClearScreenshotInfos();
331 bool AddScreenshotInfo(const ScreenshotInfo
& info
);
332 const ScreenshotInfoList
& ScreenshotInfos() const
333 { return fScreenshotInfos
; }
335 void ClearScreenshots();
336 bool AddScreenshot(const BitmapRef
& screenshot
);
337 const BitmapList
& Screenshots() const
338 { return fScreenshots
; }
340 void SetSize(int64 size
);
344 void SetDepotName(const BString
& depotName
);
345 const BString
& DepotName() const
346 { return fDepotName
; }
349 const PackageInfoListenerRef
& listener
);
351 const PackageInfoListenerRef
& listener
);
353 static void CleanupDefaultIcon();
356 void _NotifyListeners(uint32 changes
);
362 BPackageVersion fVersion
;
363 PublisherInfo fPublisher
;
364 BString fShortDescription
;
365 BString fFullDescription
;
367 CategoryList fCategories
;
368 UserRatingList fUserRatings
;
369 RatingSummary fCachedRatingSummary
;
371 ScreenshotInfoList fScreenshotInfos
;
372 BitmapList fScreenshots
;
374 PackageInstallationLocationSet
375 fInstallationLocations
;
376 float fDownloadProgress
;
377 PackageListenerList fListeners
;
379 bool fSystemDependency
;
380 BString fArchitecture
;
381 BString fLocalFilePath
;
386 static BitmapRef sDefaultIcon
;
390 typedef BReference
<PackageInfo
> PackageInfoRef
;
393 typedef List
<PackageInfoRef
, false> PackageList
;
399 DepotInfo(const BString
& name
);
400 DepotInfo(const DepotInfo
& other
);
402 DepotInfo
& operator=(const DepotInfo
& other
);
403 bool operator==(const DepotInfo
& other
) const;
404 bool operator!=(const DepotInfo
& other
) const;
406 const BString
& Name() const
409 const PackageList
& Packages() const
410 { return fPackages
; }
412 bool AddPackage(const PackageInfoRef
& package
);
414 int32
PackageIndexByName(const BString
& packageName
);
416 void SyncPackages(const PackageList
& packages
);
418 void SetBaseURL(const BString
& baseURL
);
419 const BString
& BaseURL() const
422 void SetWebAppRepositoryCode(const BString
& code
);
423 const BString
& WebAppRepositoryCode() const
424 { return fWebAppRepositoryCode
; }
426 void SetWebAppRepositorySourceCode(
427 const BString
& code
);
428 const BString
& WebAppRepositorySourceCode() const
429 { return fWebAppRepositorySourceCode
; }
433 PackageList fPackages
;
434 BString fWebAppRepositoryCode
;
435 BString fWebAppRepositorySourceCode
;
440 typedef List
<DepotInfo
, false> DepotList
;
443 typedef List
<BString
, false> StringList
;
446 #endif // PACKAGE_INFO_H