-
Notifications
You must be signed in to change notification settings - Fork 1
/
ManifestService.h
99 lines (81 loc) · 2.07 KB
/
ManifestService.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
#ifndef __MANIFESTSERVICE_H
#define __MANIFESTSERVICE_H
#include <wx/wx.h>
#include <wx/filename.h>
#include <wx/file.h>
#include <wx/ffile.h>
#include <vector>
#include <algorithm>
#include "Message.h"
namespace RAIN
{
namespace BEnc
{
class Dictionary;
};
/** an interface to a single manifest entry, stored in the manifest cache */
class ManifestEntry
{
public:
// benc constructor
ManifestEntry(BEnc::Value *v);
// load constructor
ManifestEntry(wxFileName& filename);
~ManifestEntry();
void Load(wxFileName& filename);
bool Verify();
void Save();
BEnc::Value * getBenc();
time_t getTimestamp();
BEnc::Dictionary * getMeta();
BEnc::Dictionary * getFiles();
BEnc::Dictionary * getPieces();
BEnc::Dictionary *v;
};
/** possible errors returned by Create() */
enum ManifestCreationError
{
MCE_ERROR_OK,
MCE_ERROR_MISSING_FILE,
MCE_ERROR_BAD_PERMISSIONS,
};
enum ManifestSignatureResult
{
MSR_ERROR_OK,
MSR_ERROR_UNSIGNED,
MSR_ERROR_BADSIGNATURE,
MSR_ERROR_ALREADYSIGNED,
MSR_ERROR_BADCREDENTIALS,
};
/** returned by Create() */
class ManifestCreationResult
{
public:
ManifestCreationError errorCode;
wxString error;
ManifestEntry *manifest;
};
/** a single file given to Create() */
class ManifestCreationFile
{
public:
ManifestCreationFile(const wxString& filename);
ManifestCreationFile(const wxArrayString& base, const wxFileName& filename);
wxString GetTranslatedPath(const wxString& meshbase);
wxFileName filename;
wxArrayString prepend;
unsigned long long fileSize;
private:
void UpdateFileSize();
};
/** the actual manifestservice class, a few static methods for usage by GUI or CLI
* clients */
class ManifestService
{
public:
static ManifestCreationResult Create(std::vector<ManifestCreationFile*> *files, const wxString& base);
static ManifestSignatureResult Sign(ManifestEntry& m);
static ManifestSignatureResult VerifySignature(ManifestEntry& m);
};
}
#endif //__MANIFESTSERVICE_H