-
Notifications
You must be signed in to change notification settings - Fork 0
/
safetypes.h
121 lines (108 loc) · 3.2 KB
/
safetypes.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
#include <QObject>
#include <QJsonObject>
#include <QDebug>
#ifndef SAFETYPES_H
#define SAFETYPES_H
struct SafeCaptcha {
QByteArray picture;
QString id;
};
struct SafeApiState {
QString token;
QString userId;
ulong tokenTimestamp;
void clear() {
token.clear();
userId.clear();
tokenTimestamp = 0;
}
};
struct SafeDir {
QString id;
QString name;
QString special_dir;
QString tree;
QString creator;
QString owner;
QString c_type;
QJsonObject props;
ulong ctime;
ulong mtime;
ulong uptime;
bool is_trash;
bool shared;
bool versioned;
SafeDir(QJsonObject obj) {
fromJsonObject(obj);
}
void fromJsonObject(QJsonObject obj) {
id = obj.value("id").toString();
name = obj.value("name").toString();
special_dir = obj.value("special_dir").toString();
creator = obj.value("creator").toString();
tree = obj.value("tree").toString();
owner = obj.value("owner").toString();
c_type = obj.value("c_type").toString();
props = obj.value("props").toObject();
ctime = obj.value("ctime").toDouble();
mtime = obj.value("mtime").toDouble();
uptime = obj.value("uptime").toDouble();
is_trash = (obj.value("is_trash").toDouble() == 1) ? true : false;
shared = (obj.value("shared").toDouble() == 1) ? true : false;
versioned = (obj.value("versioned").toDouble() == 1) ? true : false;
}
QString toString() const {
return this->name;
}
};
struct SafeFile {
QString id;
QString name;
QString creator;
QString tree;
QString owner;
QString c_type;
QJsonObject props;
QString current_version;
QString chksum;
QString sha256;
QString thumbnail;
ulong size;
ulong uptime;
ulong ctime;
ulong mtime;
ulong total_size;
ulong version_count;
bool is_trash;
bool shared;
bool versioned;
SafeFile(QJsonObject obj) {
fromJsonObject(obj);
}
void fromJsonObject(QJsonObject obj) {
id = obj.value("id").toString();
name = obj.value("name").toString();
creator = obj.value("creator").toString();
tree = obj.value("tree").toString();
owner = obj.value("owner").toString();
c_type = obj.value("c_type").toString();
props = obj.value("props").toObject();
current_version = obj.value("current_version").toString();
chksum = obj.value("chksum").toString();
sha256 = obj.value("sha256").toString();
thumbnail = obj.value("thumbnail").toString();
size = obj.value("size").toDouble();
uptime = obj.value("uptime").toDouble();
ctime = obj.value("ctime").toDouble();
mtime = obj.value("mtime").toDouble();
total_size = obj.value("total_size").toDouble();
version_count = obj.value("version_count").toDouble();
is_trash = (obj.value("is_trash").toDouble() == 1) ? true : false;
shared = (obj.value("shared").toDouble() == 1) ? true : false;
versioned = (obj.value("versioned").toDouble() == 1) ? true : false;
}
QString toString() const {
return this->name;
}
};
#endif // SAFETYPES_H