MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / fetchTrialState

Method fetchTrialState

app/src/Licensing/Trial.cpp:213–237  ·  view source on GitHub ↗

* @brief Sends a trial activation or validation request to the backend. */

Source from the content-addressed store, hash-verified

211 * @brief Sends a trial activation or validation request to the backend.
212 */
213void Licensing::Trial::fetchTrialState()
214{
215 if (m_busy)
216 return;
217
218 m_busy = true;
219 Q_EMIT busyChanged();
220
221 const qint64 timestamp = QDateTime::currentSecsSinceEpoch();
222 const QString nonce = QUuid::createUuid().toString(QUuid::WithoutBraces);
223
224 QJsonObject payload;
225 payload["machine_id"] = MachineID::instance().appVerMachineId();
226 payload["timestamp"] = QString::number(timestamp);
227 payload["nonce"] = nonce;
228
229 const auto payloadData = QJsonDocument(payload).toJson(QJsonDocument::Compact);
230
231 const QUrl url(QStringLiteral("https://cloud.serial-studio.com/trial"));
232 QNetworkRequest request(url);
233 request.setTransferTimeout(15 * 1000);
234 request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
235
236 (void)m_manager.post(request, payloadData);
237}
238
239/**
240 * @brief Handles the server response for trial activation; the returned expiry

Callers

nothing calls this directly

Calls 2

toJsonMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected