/
PackageInfo.h
212 lines (163 loc) · 4.99 KB
/
PackageInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef PACKAGE_INFO_H
#define PACKAGE_INFO_H
#include <Referenceable.h>
#include <String.h>
#include "List.h"
class BBitmap;
class SharedBitmap : public BReferenceable {
public:
enum Size {
SIZE_16 = 0,
SIZE_32 = 1,
SIZE_64 = 2
};
SharedBitmap(BBitmap* bitmap);
SharedBitmap(int32 resourceID);
SharedBitmap(const char* mimeType);
~SharedBitmap();
const BBitmap* Bitmap(Size which);
private:
BBitmap* _CreateBitmapFromResource(int32 size) const;
BBitmap* _CreateBitmapFromMimeType(int32 size) const;
private:
int32 fResourceID;
BString fMimeType;
BBitmap* fBitmap[3];
};
typedef BReference<SharedBitmap> BitmapRef;
class UserInfo {
public:
UserInfo();
UserInfo(const BString& nickName);
UserInfo(const BitmapRef& avatar,
const BString& nickName);
UserInfo(const UserInfo& other);
UserInfo& operator=(const UserInfo& other);
bool operator==(const UserInfo& other) const;
bool operator!=(const UserInfo& other) const;
const BitmapRef& Avatar() const
{ return fAvatar; }
const BString& NickName() const
{ return fNickName; }
private:
BitmapRef fAvatar;
BString fNickName;
};
class UserRating {
public:
UserRating();
UserRating(const UserInfo& userInfo,
float rating,
const BString& comment,
const BString& language,
const BString& packageVersion);
UserRating(const UserRating& other);
UserRating& operator=(const UserRating& other);
bool operator==(const UserRating& other) const;
bool operator!=(const UserRating& other) const;
const UserInfo& User() const
{ return fUserInfo; }
const BString& Comment() const
{ return fComment; }
const BString& Language() const
{ return fLanguage; }
const float Rating() const
{ return fRating; }
const BString& PackageVersion() const
{ return fPackageVersion; }
private:
UserInfo fUserInfo;
float fRating;
BString fComment;
BString fLanguage;
BString fPackageVersion;
};
typedef List<UserRating, false> UserRatingList;
class PublisherInfo {
public:
PublisherInfo();
PublisherInfo(const BitmapRef& logo,
const BString& name,
const BString& email,
const BString& website);
PublisherInfo(const PublisherInfo& other);
PublisherInfo& operator=(const PublisherInfo& other);
bool operator==(const PublisherInfo& other) const;
bool operator!=(const PublisherInfo& other) const;
const BitmapRef& Logo() const
{ return fLogo; }
const BString& Name() const
{ return fName; }
const BString& Email() const
{ return fEmail; }
const BString& Website() const
{ return fWebsite; }
private:
BitmapRef fLogo;
BString fName;
BString fEmail;
BString fWebsite;
};
class PackageInfo {
public:
PackageInfo();
PackageInfo(const BitmapRef& icon,
const BString& title,
const BString& version,
const PublisherInfo& publisher,
const BString& shortDescription,
const BString& fullDescription,
const BString& changelog);
PackageInfo(const PackageInfo& other);
PackageInfo& operator=(const PackageInfo& other);
bool operator==(const PackageInfo& other) const;
bool operator!=(const PackageInfo& other) const;
const BitmapRef& Icon() const
{ return fIcon; }
const BString& Title() const
{ return fTitle; }
const BString& Version() const
{ return fVersion; }
const BString& ShortDescription() const
{ return fShortDescription; }
const BString& FullDescription() const
{ return fFullDescription; }
const PublisherInfo& Publisher() const
{ return fPublisher; }
const BString& Changelog() const
{ return fChangelog; }
bool AddUserRating(const UserRating& rating);
private:
BitmapRef fIcon;
BString fTitle;
BString fVersion;
PublisherInfo fPublisher;
BString fShortDescription;
BString fFullDescription;
BString fChangelog;
UserRatingList fUserRatings;
};
typedef List<PackageInfo, false> PackageInfoList;
class DepotInfo {
public:
DepotInfo();
DepotInfo(const BString& title);
DepotInfo(const DepotInfo& other);
DepotInfo& operator=(const DepotInfo& other);
bool operator==(const DepotInfo& other) const;
bool operator!=(const DepotInfo& other) const;
const BString& Title() const
{ return fTitle; }
const PackageInfoList& PackageList() const
{ return fPackages; }
bool AddPackage(const PackageInfo& package);
private:
BString fTitle;
PackageInfoList fPackages;
};
typedef List<DepotInfo, false> DepotInfoList;
#endif // PACKAGE_INFO_H