Checks if the report stored in the database can be updated with missing data from the local report
| 159 | |
| 160 | // Checks if the report stored in the database can be updated with missing data from the local report |
| 161 | bool VulkanDatabase::checkCanUpdateReport(VulkanDeviceInfo& device, int reportId) |
| 162 | { |
| 163 | manager = new QNetworkAccessManager(nullptr); |
| 164 | QHttpMultiPart* multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); |
| 165 | QHttpPart jsonPart; |
| 166 | jsonPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"data\"; filename=\"update_check_report.json\"")); |
| 167 | QJsonDocument doc(device.toJson("", "")); |
| 168 | jsonPart.setBody(doc.toJson()); |
| 169 | multiPart->append(jsonPart); |
| 170 | QUrl qurl(databaseUrl + "api/v4/checkcanupdatereport.php?reportid=" + QString::number(reportId)); |
| 171 | QNetworkRequest request(qurl); |
| 172 | QNetworkReply* reply = manager->post(request, multiPart); |
| 173 | multiPart->setParent(reply); |
| 174 | QEventLoop loop; |
| 175 | connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); |
| 176 | loop.exec(QEventLoop::ExcludeUserInputEvents); |
| 177 | bool result = false; |
| 178 | if (reply->error() == QNetworkReply::NoError) |
| 179 | { |
| 180 | QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); |
| 181 | bool canUpdate = response.isObject() ? response.object()["canupdate"].toBool() : false; |
| 182 | result = canUpdate; |
| 183 | } |
| 184 | else |
| 185 | { |
| 186 | QString err(reply->errorString()); |
| 187 | result = false; |
| 188 | } |
| 189 | delete(manager); |
| 190 | return result; |
| 191 | } |
| 192 | |
| 193 | // Upload the current report for updating an existing report |
| 194 | bool VulkanDatabase::postReportForUpdate(VulkanDeviceInfo &device, int reportId, QString &updateLog) |
no test coverage detected