Loading client/localapi.cpp +16 −1 Changes for client/localapi.cpp: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -187,9 +187,17 @@ void LocalApi::connectToServer(const QString &url, const QString &user, const QS _pub->setServerUrl(url); if (user.isEmpty()) { /* No credentials — just set the URL and mark connected */ /* No credentials — verify server is reachable */ emit statusMessage("Testing connection..."); _pub->testConnection([this, url](bool ok, const QString &msg) { if (ok) { emit connectionStatusChanged(true, "Connected to " + url); emit statusMessage("Connected to " + url); } else { emit connectionStatusChanged(false, msg); emit statusMessage("Connection failed: " + msg); } }); return; } Loading @@ -206,12 +214,19 @@ void LocalApi::connectToServer(const QString &url, const QString &user, const QS } void LocalApi::disconnectServer() { _pub->abort(); _pub->setServerUrl(""); _pub->setAuthToken(""); emit connectionStatusChanged(false, "Disconnected"); emit statusMessage("Disconnected from server"); } void LocalApi::abortConnection() { _pub->abort(); emit connectionStatusChanged(false, "Aborted"); emit statusMessage("Connection aborted"); } void LocalApi::setIgnoreSslErrors(bool ignore) { _pub->setIgnoreSslErrors(ignore); } Loading client/localapi.h +1 −0 Changes for client/localapi.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public: /* Connection management */ Q_INVOKABLE void connectToServer(const QString &url, const QString &user, const QString &password); Q_INVOKABLE void disconnectServer(); Q_INVOKABLE void abortConnection(); Q_INVOKABLE void setIgnoreSslErrors(bool ignore); /* Initial load */ Loading client/publishclient.cpp +38 −1 Changes for client/publishclient.cpp: 38 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -57,6 +57,39 @@ void PublishClient::setIgnoreSslErrors(bool ignore) { _ignoreSsl = ignore; } void PublishClient::abort() { if (_activeReply && _activeReply->isRunning()) { _activeReply->abort(); } } void PublishClient::testConnection(Callback cb) { if (_serverUrl.isEmpty()) { cb(false, "Server URL not set"); return; } QUrl url(_serverUrl); QNetworkRequest req(url); QNetworkReply *reply = _nam->get(req); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (reply->error() == QNetworkReply::OperationCanceledError) { cb(false, "Aborted"); } else if (reply->error() != QNetworkReply::NoError && status == 0) { cb(false, reply->errorString()); } else { cb(true, "Server reachable"); } }); } void PublishClient::login(const QString &user, const QString &password, Callback cb) { QUrl url(_serverUrl + "/api"); QNetworkRequest req(url); Loading @@ -72,9 +105,11 @@ void PublishClient::login(const QString &user, const QString &password, Callback QJsonDocument doc(commands); QNetworkReply *reply = _nam->post(req, doc.toJson(QJsonDocument::Compact)); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { cb(false, reply->errorString()); Loading Loading @@ -119,9 +154,11 @@ void PublishClient::publish(const QString &html, Callback cb) { QJsonDocument doc(commands); QNetworkReply *reply = _nam->post(req, doc.toJson(QJsonDocument::Compact)); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [reply, cb]() { connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { cb(false, reply->errorString()); Loading client/publishclient.h +3 −0 Changes for client/publishclient.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -45,10 +45,13 @@ public: void publish(const QString &html, Callback cb); void login(const QString &user, const QString &password, Callback cb); void testConnection(Callback cb); void setIgnoreSslErrors(bool ignore); void abort(); private: QNetworkAccessManager *_nam; QNetworkReply *_activeReply = nullptr; QString _serverUrl; QString _authToken; bool _ignoreSsl = false; Loading client/qml/ConnectionPanel.qml +1 −0 Changes for client/qml/ConnectionPanel.qml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ ColumnLayout { spacing: 8 property bool connected: false property bool connecting: false property string serverUrl: "" property string statusText: "Not connected" property color statusColor: Theme.textMuted Loading Loading
client/localapi.cpp +16 −1 Changes for client/localapi.cpp: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -187,9 +187,17 @@ void LocalApi::connectToServer(const QString &url, const QString &user, const QS _pub->setServerUrl(url); if (user.isEmpty()) { /* No credentials — just set the URL and mark connected */ /* No credentials — verify server is reachable */ emit statusMessage("Testing connection..."); _pub->testConnection([this, url](bool ok, const QString &msg) { if (ok) { emit connectionStatusChanged(true, "Connected to " + url); emit statusMessage("Connected to " + url); } else { emit connectionStatusChanged(false, msg); emit statusMessage("Connection failed: " + msg); } }); return; } Loading @@ -206,12 +214,19 @@ void LocalApi::connectToServer(const QString &url, const QString &user, const QS } void LocalApi::disconnectServer() { _pub->abort(); _pub->setServerUrl(""); _pub->setAuthToken(""); emit connectionStatusChanged(false, "Disconnected"); emit statusMessage("Disconnected from server"); } void LocalApi::abortConnection() { _pub->abort(); emit connectionStatusChanged(false, "Aborted"); emit statusMessage("Connection aborted"); } void LocalApi::setIgnoreSslErrors(bool ignore) { _pub->setIgnoreSslErrors(ignore); } Loading
client/localapi.h +1 −0 Changes for client/localapi.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public: /* Connection management */ Q_INVOKABLE void connectToServer(const QString &url, const QString &user, const QString &password); Q_INVOKABLE void disconnectServer(); Q_INVOKABLE void abortConnection(); Q_INVOKABLE void setIgnoreSslErrors(bool ignore); /* Initial load */ Loading
client/publishclient.cpp +38 −1 Changes for client/publishclient.cpp: 38 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -57,6 +57,39 @@ void PublishClient::setIgnoreSslErrors(bool ignore) { _ignoreSsl = ignore; } void PublishClient::abort() { if (_activeReply && _activeReply->isRunning()) { _activeReply->abort(); } } void PublishClient::testConnection(Callback cb) { if (_serverUrl.isEmpty()) { cb(false, "Server URL not set"); return; } QUrl url(_serverUrl); QNetworkRequest req(url); QNetworkReply *reply = _nam->get(req); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (reply->error() == QNetworkReply::OperationCanceledError) { cb(false, "Aborted"); } else if (reply->error() != QNetworkReply::NoError && status == 0) { cb(false, reply->errorString()); } else { cb(true, "Server reachable"); } }); } void PublishClient::login(const QString &user, const QString &password, Callback cb) { QUrl url(_serverUrl + "/api"); QNetworkRequest req(url); Loading @@ -72,9 +105,11 @@ void PublishClient::login(const QString &user, const QString &password, Callback QJsonDocument doc(commands); QNetworkReply *reply = _nam->post(req, doc.toJson(QJsonDocument::Compact)); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { cb(false, reply->errorString()); Loading Loading @@ -119,9 +154,11 @@ void PublishClient::publish(const QString &html, Callback cb) { QJsonDocument doc(commands); QNetworkReply *reply = _nam->post(req, doc.toJson(QJsonDocument::Compact)); _activeReply = reply; if (_ignoreSsl) connect(reply, &QNetworkReply::sslErrors, reply, qOverload<>(&QNetworkReply::ignoreSslErrors)); connect(reply, &QNetworkReply::finished, this, [reply, cb]() { connect(reply, &QNetworkReply::finished, this, [this, reply, cb]() { if (_activeReply == reply) _activeReply = nullptr; reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { cb(false, reply->errorString()); Loading
client/publishclient.h +3 −0 Changes for client/publishclient.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -45,10 +45,13 @@ public: void publish(const QString &html, Callback cb); void login(const QString &user, const QString &password, Callback cb); void testConnection(Callback cb); void setIgnoreSslErrors(bool ignore); void abort(); private: QNetworkAccessManager *_nam; QNetworkReply *_activeReply = nullptr; QString _serverUrl; QString _authToken; bool _ignoreSsl = false; Loading
client/qml/ConnectionPanel.qml +1 −0 Changes for client/qml/ConnectionPanel.qml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ ColumnLayout { spacing: 8 property bool connected: false property bool connecting: false property string serverUrl: "" property string statusText: "Not connected" property color statusColor: Theme.textMuted Loading