MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / on_queryMessageVersion_finished

Method on_queryMessageVersion_finished

src/share/WizGroupMessage.cpp:153–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void WizGroupMessage::on_queryMessageVersion_finished()
154{
155 QNetworkReply* reply = qobject_cast<QNetworkReply *>(sender());
156
157 if (reply->error()) {
158 reply->deleteLater();
159 syncEnd();
160 return;
161 }
162
163 // return: "{"result": version,"return_code":200,"return_message":"success"}"
164 QString strReply = reply->readAll();
165 reply->deleteLater();
166
167 qDebug() << "[Message Sync]query version finished, reply: " << strReply;
168
169 rapidjson::Document document;
170 document.Parse<0>(strReply.toUtf8().constData());
171
172 if (!document.IsObject()) {
173 TOLOG("Error occured when try to parse json of message version");
174 syncEnd();
175 return;
176 }
177
178 QString nCode;
179 if (document["return_code"].IsString()) {
180 nCode = document["return_code"].getString();
181 } else {
182 nCode = QString::number(document["return_code"].getInt());
183 }
184
185 QString strMsg = document["return_message"].getString();
186 if (nCode != WIZAPI_RETURN_SUCCESS) {
187 TOLOG2("Error occured when get message version, code: %1, message: %2",
188 nCode, strMsg);
189 syncEnd();
190 return;
191 }
192
193 qint64 nVersionRemote = document["result"].getInt64();
194 qint64 nVersionLocal = m_db.getObjectVersion(WIZMESSAGEDATA::objectName());
195
196 qDebug() << "[Message Sync]local message version: " << nVersionLocal;
197
198 // 3. compare version, determine fetch needed or not
199 if (nVersionLocal < nVersionRemote) {
200 callGetMessages(nVersionLocal);
201 } else {
202 syncEnd();
203 }
204}
205
206void WizGroupMessage::onGetMessages(const CWizMessageDataArray& messages)
207{

Callers

nothing calls this directly

Calls 5

TOLOGFunction · 0.85
errorMethod · 0.80
getIntMethod · 0.80
getObjectVersionMethod · 0.80
getStringMethod · 0.45

Tested by

no test coverage detected