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.
9 #include <FindDirectory.h>
12 #include "AbstractServerProcess.h"
13 #include "LocalIconStore.h"
14 #include "BulkLoadContext.h"
15 #include "PackageInfo.h"
16 #include "WebAppInterface.h"
24 class PackageFilter
: public BReferenceable
{
26 virtual ~PackageFilter();
28 virtual bool AcceptsPackage(
29 const PackageInfoRef
& package
) const = 0;
32 typedef BReference
<PackageFilter
> PackageFilterRef
;
35 class ModelListener
: public BReferenceable
{
37 virtual ~ModelListener();
39 virtual void AuthorizationChanged() = 0;
45 virtual DepotInfo
MapDepot(const DepotInfo
& depot
,
50 class PackageConsumer
{
52 virtual bool ConsumePackage(
53 const PackageInfoRef
& packageInfoRef
,
58 typedef BReference
<ModelListener
> ModelListenerRef
;
59 typedef List
<ModelListenerRef
, false> ModelListenerList
;
70 bool AddListener(const ModelListenerRef
& listener
);
72 // !Returns new PackageInfoList from current parameters
73 PackageList
CreatePackageList() const;
76 const PackageInfoRef
& package
) const;
78 bool AddDepot(const DepotInfo
& depot
);
79 bool HasDepot(const BString
& name
) const;
80 const DepotList
& Depots() const
82 const DepotInfo
* DepotForName(const BString
& name
) const;
83 bool SyncDepot(const DepotInfo
& depot
);
87 // Access to global categories
88 const CategoryRef
& CategoryAudio() const
89 { return fCategoryAudio
; }
90 const CategoryRef
& CategoryBusiness() const
91 { return fCategoryBusiness
; }
92 const CategoryRef
& CategoryDevelopment() const
93 { return fCategoryDevelopment
; }
94 const CategoryRef
& CategoryEducation() const
95 { return fCategoryEducation
; }
96 const CategoryRef
& CategoryInternetAndNetwork() const
97 { return fCategoryInternetAndNetwork
; }
98 const CategoryRef
& CategoryGames() const
99 { return fCategoryGames
; }
100 const CategoryRef
& CategoryGraphics() const
101 { return fCategoryGraphics
; }
102 const CategoryRef
& CategoryProductivity() const
103 { return fCategoryProductivity
; }
104 const CategoryRef
& CategoryScienceAndMathematics() const
105 { return fCategoryScienceAndMathematics
; }
106 const CategoryRef
& CategorySystemAndUtilities() const
107 { return fCategorySystemAndUtilities
; }
108 const CategoryRef
& CategoryVideo() const
109 { return fCategoryVideo
; }
111 const CategoryList
& Categories() const
112 { return fCategories
; }
114 void SetPackageState(
115 const PackageInfoRef
& package
,
118 // Configure PackageFilters
119 void SetCategory(const BString
& category
);
120 BString
Category() const;
121 void SetDepot(const BString
& depot
);
122 BString
Depot() const;
123 void SetSearchTerms(const BString
& searchTerms
);
124 BString
SearchTerms() const;
126 void SetShowFeaturedPackages(bool show
);
127 bool ShowFeaturedPackages() const
128 { return fShowFeaturedPackages
; }
129 void SetShowAvailablePackages(bool show
);
130 bool ShowAvailablePackages() const
131 { return fShowAvailablePackages
; }
132 void SetShowInstalledPackages(bool show
);
133 bool ShowInstalledPackages() const
134 { return fShowInstalledPackages
; }
135 void SetShowSourcePackages(bool show
);
136 bool ShowSourcePackages() const
137 { return fShowSourcePackages
; }
138 void SetShowDevelopPackages(bool show
);
139 bool ShowDevelopPackages() const
140 { return fShowDevelopPackages
; }
142 // Retrieve package information
143 static const uint32 POPULATE_CACHED_RATING
= 1 << 0;
144 static const uint32 POPULATE_CACHED_ICON
= 1 << 1;
145 static const uint32 POPULATE_USER_RATINGS
= 1 << 2;
146 static const uint32 POPULATE_SCREEN_SHOTS
= 1 << 3;
147 static const uint32 POPULATE_CHANGELOG
= 1 << 4;
148 static const uint32 POPULATE_CATEGORIES
= 1 << 5;
149 static const uint32 POPULATE_FORCE
= 1 << 6;
151 void PopulatePackage(const PackageInfoRef
& package
,
154 const StringList
& SupportedLanguages() const
155 { return fSupportedLanguages
; }
157 const BString
& PreferredLanguage() const
158 { return fPreferredLanguage
; }
160 void SetUsername(BString username
);
161 const BString
& Username() const;
162 void SetAuthorization(const BString
& username
,
163 const BString
& password
,
166 const WebAppInterface
& GetWebAppInterface() const
167 { return fWebAppInterface
; }
169 void ReplaceDepotByUrl(
171 DepotMapper
* depotMapper
,
175 void (*func
)(const DepotInfo
& depot
,
179 void ForAllPackages(PackageConsumer
* packageConsumer
,
182 void ForPackageByNameInDepot(
183 const BString
& depotName
,
184 const BString
& packageName
,
185 PackageConsumer
* packageConsumer
,
188 status_t
IconStoragePath(BPath
& path
) const;
189 status_t
DumpExportRepositoryDataPath(BPath
& path
) const;
190 status_t
DumpExportPkgDataPath(BPath
& path
,
191 const BString
& repositorySourceCode
) const;
193 void LogDepotsWithNoWebAppRepositoryCode() const;
196 void _UpdateIsFeaturedFilter();
198 static int32
_PopulateAllPackagesEntry(void* cookie
);
200 void _PopulatePackageScreenshot(
201 const PackageInfoRef
& package
,
202 const ScreenshotInfo
& info
,
203 int32 scaledWidth
, bool fromCacheOnly
);
205 bool _GetCacheFile(BPath
& path
, BFile
& file
,
206 directory_which directory
,
207 const char* relativeLocation
,
208 const char* fileName
,
209 uint32 openMode
) const;
210 bool _GetCacheFile(BPath
& path
, BFile
& file
,
211 directory_which directory
,
212 const char* relativeLocation
,
213 const char* fileName
,
214 bool ignoreAge
, time_t maxAge
) const;
216 void _NotifyAuthorizationChanged();
223 CategoryRef fCategoryAudio
;
224 CategoryRef fCategoryBusiness
;
225 CategoryRef fCategoryDevelopment
;
226 CategoryRef fCategoryEducation
;
227 CategoryRef fCategoryGames
;
228 CategoryRef fCategoryGraphics
;
229 CategoryRef fCategoryInternetAndNetwork
;
230 CategoryRef fCategoryProductivity
;
231 CategoryRef fCategoryScienceAndMathematics
;
232 CategoryRef fCategorySystemAndUtilities
;
233 CategoryRef fCategoryVideo
;
234 // TODO: Dynamic categories retrieved from web-app
236 CategoryList fCategories
;
238 PackageList fInstalledPackages
;
239 PackageList fActivatedPackages
;
240 PackageList fUninstalledPackages
;
241 PackageList fDownloadingPackages
;
242 PackageList fUpdateablePackages
;
243 PackageList fPopulatedPackages
;
245 PackageFilterRef fCategoryFilter
;
246 BString fDepotFilter
;
247 PackageFilterRef fSearchTermsFilter
;
248 PackageFilterRef fIsFeaturedFilter
;
250 bool fShowFeaturedPackages
;
251 bool fShowAvailablePackages
;
252 bool fShowInstalledPackages
;
253 bool fShowSourcePackages
;
254 bool fShowDevelopPackages
;
256 StringList fSupportedLanguages
;
257 BString fPreferredLanguage
;
259 WebAppInterface fWebAppInterface
;
261 ModelListenerList fListeners
;
265 #endif // PACKAGE_INFO_H