repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / server / AbstractServerProcess.h
blobde8c0d0229027ba9ddd9bf4122e0fdefb15053b5
1 /*
2 * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #ifndef ABSTRACT_SERVER_PROCESS_H
7 #define ABSTRACT_SERVER_PROCESS_H
9 #include <Json.h>
10 #include <String.h>
11 #include <Url.h>
13 #include "StandardMetaData.h"
16 #define APP_ERR_NOT_MODIFIED (B_APP_ERROR_BASE + 452)
19 class AbstractServerProcess {
20 public:
21 virtual status_t Run() = 0;
23 protected:
24 virtual void GetStandardMetaDataPath(
25 BPath& path) const = 0;
26 virtual void GetStandardMetaDataJsonPath(
27 BString& jsonPath) const = 0;
28 virtual const char* LoggingName() const = 0;
30 status_t IfModifiedSinceHeaderValue(
31 BString& headerValue) const;
32 status_t IfModifiedSinceHeaderValue(
33 BString& headerValue,
34 const BPath& metaDataPath,
35 const BString& jsonPath) const;
37 status_t PopulateMetaData(
38 StandardMetaData& metaData,
39 const BPath& path,
40 const BString& jsonPath) const;
42 status_t ParseJsonFromFileWithListener(
43 BJsonEventListener *listener,
44 const BPath& path) const;
46 status_t DownloadToLocalFile(
47 const BPath& targetFilePath,
48 const BUrl& url,
49 uint32 redirects, uint32 failures);
51 status_t MoveDamagedFileAside(
52 const BPath& currentFilePath);
54 private:
55 bool LooksLikeGzip(const char *pathStr) const;
59 #endif // ABSTRACT_SERVER_PROCESS_H