xref: /haiku/src/apps/haikudepot/server/ServerIconExportUpdateProcess.h (revision 19c15fec85fa585951ea15260aea52c9327171cb)
1 /*
2  * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef SERVER_ICON_PROCESS_H
7 #define SERVER_ICON_PROCESS_H
8 
9 
10 #include "AbstractServerProcess.h"
11 
12 #include <File.h>
13 #include <Path.h>
14 #include <String.h>
15 #include <Url.h>
16 
17 #include "IconMetaData.h"
18 
19 
20 class ServerIconExportUpdateProcess : public AbstractServerProcess {
21 public:
22 
23 								ServerIconExportUpdateProcess(
24 									const BPath& localStorageDirectoryPath);
25 
26 			status_t			Run();
27 
28 private:
29 			status_t			_Download(BPath& tarGzFilePath);
30 			status_t			_Download(BPath& tarGzFilePath, const BUrl& url,
31 									uint32 redirects, uint32 failures);
32 			BString				_FormFullUrl(const BString& suffix) const;
33 			status_t			_IfModifiedSinceHeaderValue(
34 									BString& headerValue) const;
35 			status_t			_IfModifiedSinceHeaderValue(
36 									BString& headerValue,
37 									BPath& iconMetaDataPath) const;
38 
39 			status_t			_PopulateIconMetaData(
40 									IconMetaData& iconMetaData, BPath& path)
41 									const;
42 			status_t			_PopulateIconMetaData(
43 									IconMetaData& iconMetaData,
44 									BString& jsonString) const;
45 			status_t			_PopulateIconMetaData(
46 									IconMetaData& iconMetaData,
47 									BMessage& message) const;
48 
49 			void				_TimestampToRfc2822String(
50 									uint64_t timestampMillis,
51 									BString& rfc2822String) const;
52 
53 			BString				fBaseUrl;
54 			BPath				fLocalStorageDirectoryPath;
55 
56 };
57 
58 #endif // SERVER_ICON_PROCESS_H
59