-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathStory.cpp
149 lines (122 loc) · 4.24 KB
/
Story.cpp
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "Story.h"
//Shared key
const QString Story::STORY_KEY = "story";
const QString Story::ID_KEY = "id";
const QString Story::USERNAME_KEY = "username";
const QString Story::MATURE_CONTENT_KEY = "mature_content";
const QString Story::CLIENT_ID_KEY = "client_id";
const QString Story::TIMESTAMP_KEY = "timestamp";
const QString Story::MEDIA_ID_KEY = "media_id";
const QString Story::MEDIA_KEY_KEY = "media_key";
const QString Story::MEDIA_IV_KEY = "media_iv";
const QString Story::THUMBNAIL_IV_KEY = "thumbnail_iv";
const QString Story::MEDIA_TYPE_KEY = "media_type";
const QString Story::TIME_KEY = "time";
const QString Story::CAPTION_TEXT_DISPLAY_KEY = "caption_text_display";
const QString Story::ZIPPED_KEY = "zipped";
const QString Story::TIME_LEFT_KEY = "time_left";
const QString Story::MEDIA_URL_KEY = "media_url";
const QString Story::THUMBNAIL_URL_KEY = "thumbnail_url";
//Other's story key
const QString Story::VIEWED_KEY = "viewed";
//Own story key
const QString Story::STORY_NOTES_KEY = "story_notes";
const QString Story::STORY_EXTRAS_KEY = "story_extras";
const QString Story::VIEW_COUNT_KEY = "view_count";
const QString Story::SCREENSHOT_COUNT_KEY = "screenshot_count";
Story::Story(QJsonObject fullStoryObj, bool isMyStory)
{
this->isMyStory = isMyStory;
QJsonObject storyObj = fullStoryObj[STORY_KEY].toObject();
if(isMyStory){
//Parse story notes
QJsonArray storyNotesArray = fullStoryObj[STORY_NOTES_KEY].toArray();
for(int i = 0; i < storyNotesArray.size(); i++){
viewers.append(Viewer(storyNotesArray.at(i).toObject()));
}
//Parse story extras
QJsonObject storyExtrasObj = fullStoryObj[STORY_EXTRAS_KEY].toObject();
this->viewCount = storyExtrasObj[VIEW_COUNT_KEY].toInt();
this->screenshotCount = storyExtrasObj[SCREENSHOT_COUNT_KEY].toInt();
}else{
this->viewed = fullStoryObj[VIEWED_KEY].toBool();
}
this->id = storyObj[ID_KEY].toString();
this->author = storyObj[USERNAME_KEY].toString();
this->matureContent = storyObj[MATURE_CONTENT_KEY].toBool();
this->clientID = storyObj[CLIENT_ID_KEY].toString();
this->timestamp = storyObj[TIMESTAMP_KEY].toString().toLongLong();
this->media_id = storyObj[MEDIA_ID_KEY].toString();
this->media_key = storyObj[MEDIA_KEY_KEY].toString();
this->media_iv = storyObj[MEDIA_IV_KEY].toString();
this->thumbnail_iv = storyObj[THUMBNAIL_IV_KEY].toString();
this->mediaType = storyObj[MEDIA_TYPE_KEY].toInt();
this->time = storyObj[TIME_KEY].toString().toFloat();
this->text = storyObj[CAPTION_TEXT_DISPLAY_KEY].toString();
this->zipped = storyObj[ZIPPED_KEY].toBool();
this->timeLeft = storyObj[TIME_LEFT_KEY].toString().toLongLong();
this->media_url = storyObj[MEDIA_URL_KEY].toString();
this->thumbnail_url = storyObj[THUMBNAIL_URL_KEY].toString();
}
const QString Story::getID() const {
return this->id;
}
const QString Story::getAuthor() const {
return this->author;
}
bool Story::hasMatureContent() const {
return this->matureContent;
}
const QString Story::getClientID() const {
return this->clientID;
}
qint64 Story::getSentTime() const {
return this->timestamp;
}
const QString Story::getMediaID() const {
return this->media_id;
}
const QString Story::getMediaKey() const {
return this->media_key;
}
const QString Story::getMediaIV() const {
return this->media_iv;
}
const QString Story::getThumbnailIV() const {
return this->thumbnail_iv;
}
bool Story::isVideo() const {
return this->mediaType == 1;
}
float Story::getDuration() const {
return this->time;
}
const QString Story::getCaptionText() const {
return this->text;
}
bool Story::isZipped() const {
return this->zipped;
}
qint64 Story::getTimeLeft() const {
return this->timeLeft;
}
const QString Story::getMediaURL() const {
return this->media_url;
}
const QString Story::getThumbnailURL() const {
return this->thumbnail_url;
}
//Only for other's story
bool Story::isViewed() const {
return this->viewed;
}
//Only for our story
int Story::getViewCount() const {
return this->viewCount;
}
int Story::getScreenshotCount() const {
return this->screenshotCount;
}
const QList<Viewer> Story::getViewers() const {
return this->viewers;
}