diff --git a/src/o2.cpp b/src/o2.cpp index 5f6b092..c610624 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -162,7 +162,10 @@ QString O2::grantType() void O2::setGrantType(const QString &value) { + if (grantType_ == value) + return; grantType_ = value; + Q_EMIT grantTypeChanged(grantType_); } void O2::link() { @@ -697,7 +700,11 @@ QString O2::localhostPolicy() const { } void O2::setLocalhostPolicy(const QString &value) { + if (localhostPolicy_ == value) + return; + localhostPolicy_ = value; + Q_EMIT localHostPolicyChanged(localhostPolicy_); } QString O2::apiKey() { @@ -705,7 +712,11 @@ QString O2::apiKey() { } void O2::setApiKey(const QString &value) { + if (apiKey_ == value) + return; + apiKey_ = value; + Q_EMIT apiKeyChanged(apiKey_); } bool O2::ignoreSslErrors() { @@ -714,4 +725,5 @@ bool O2::ignoreSslErrors() { void O2::setIgnoreSslErrors(bool ignoreSslErrors) { timedReplies_.setIgnoreSslErrors(ignoreSslErrors); + Q_EMIT ignoreSslErrorsChanged(ignoreSslErrors); } diff --git a/src/o2.h b/src/o2.h index 4764912..00e2fbe 100644 --- a/src/o2.h +++ b/src/o2.h @@ -51,18 +51,18 @@ class O0_EXPORT O2: public O0BaseAuth /// Localhost policy. By default it's value is http://127.0.0.1:%1/, however some services may /// require the use of http://localhost:%1/ or any other value. - Q_PROPERTY(QString localhostPolicy READ localhostPolicy WRITE setLocalhostPolicy) + Q_PROPERTY(QString localhostPolicy READ localhostPolicy WRITE setLocalhostPolicy NOTIFY localHostPolicyChanged) QString localhostPolicy() const; void setLocalhostPolicy(const QString &value); /// API key. - Q_PROPERTY(QString apiKey READ apiKey WRITE setApiKey) + Q_PROPERTY(QString apiKey READ apiKey WRITE setApiKey NOTIFY apiKeyChanged) QString apiKey(); void setApiKey(const QString &value); /// Allow ignoring SSL errors? /// E.g. SurveyMonkey fails on Mac due to SSL error. Ignoring the error circumvents the problem - Q_PROPERTY(bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors) + Q_PROPERTY(bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors NOTIFY ignoreSslErrorsChanged) bool ignoreSslErrors(); void setIgnoreSslErrors(bool ignoreSslErrors); @@ -87,7 +87,7 @@ class O0_EXPORT O2: public O0BaseAuth void setRefreshTokenUrl(const QString &value); /// Grant type (if non-standard) - Q_PROPERTY(QString grantType READ grantType WRITE setGrantType) + Q_PROPERTY(QString grantType READ grantType WRITE setGrantType NOTIFY grantTypeChanged) QString grantType(); void setGrantType(const QString &value); @@ -131,6 +131,10 @@ public Q_SLOTS: void extraRequestParamsChanged(); void refreshTokenUrlChanged(); void tokenUrlChanged(); + void localHostPolicyChanged(const QString& policy); + void apiKeyChanged(const QString& key); + void ignoreSslErrorsChanged(bool ignore); + void grantTypeChanged(const QString& type); public Q_SLOTS: /// Handle verification response. diff --git a/src/o2pollserver.cpp b/src/o2pollserver.cpp index ea0dabc..f105a7e 100644 --- a/src/o2pollserver.cpp +++ b/src/o2pollserver.cpp @@ -43,6 +43,7 @@ int O2PollServer::interval() const void O2PollServer::setInterval(int interval) { pollTimer.setInterval(interval * 1000); + Q_EMIT intervalChanged(interval); } void O2PollServer::startPolling() diff --git a/src/o2pollserver.h b/src/o2pollserver.h index 594bc62..b826217 100644 --- a/src/o2pollserver.h +++ b/src/o2pollserver.h @@ -21,13 +21,14 @@ class O0_EXPORT O2PollServer : public QObject explicit O2PollServer(QNetworkAccessManager * manager, const QNetworkRequest &request, const QByteArray & payload, int expiresIn, QObject *parent = nullptr); /// Seconds to wait between polling requests - Q_PROPERTY(int interval READ interval WRITE setInterval) + Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) int interval() const; void setInterval(int interval); Q_SIGNALS: void verificationReceived(QMap); void serverClosed(bool); // whether it has found parameters + void intervalChanged(int interval); public Q_SLOTS: void startPolling(); diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 87ebaab..a2611bd 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -152,7 +152,10 @@ QByteArray O2ReplyServer::replyContent() { } void O2ReplyServer::setReplyContent(const QByteArray &value) { - replyContent_ = value; + if (replyContent_ == value) + return; + replyContent_ = value; + Q_EMIT replyContentChanged(); } int O2ReplyServer::timeout() @@ -162,7 +165,11 @@ int O2ReplyServer::timeout() void O2ReplyServer::setTimeout(int timeout) { - timeout_ = timeout; + if ( timeout_ == timeout ) + return; + + timeout_ = timeout; + Q_EMIT timeoutChanged(timeout_); } int O2ReplyServer::callbackTries() @@ -172,7 +179,11 @@ int O2ReplyServer::callbackTries() void O2ReplyServer::setCallbackTries(int maxtries) { - maxtries_ = maxtries; + if (maxtries_ == maxtries) + return; + + maxtries_ = maxtries; + Q_EMIT callbackTriesChanged(maxtries_); } QString O2ReplyServer::uniqueState() diff --git a/src/o2replyserver.h b/src/o2replyserver.h index e6b9c44..8e2649b 100644 --- a/src/o2replyserver.h +++ b/src/o2replyserver.h @@ -16,17 +16,17 @@ class O0_EXPORT O2ReplyServer: public QTcpServer { explicit O2ReplyServer(QObject *parent = nullptr); /// Page content on local host after successful oauth - in case you do not want to close the browser, but display something - Q_PROPERTY(QByteArray replyContent READ replyContent WRITE setReplyContent) + Q_PROPERTY(QByteArray replyContent READ replyContent WRITE setReplyContent NOTIFY replyContentChanged) QByteArray replyContent(); void setReplyContent(const QByteArray &value); /// Seconds to keep listening *after* first response for a callback with token content - Q_PROPERTY(int timeout READ timeout WRITE setTimeout) + Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged) int timeout(); void setTimeout(int timeout); /// Maximum number of callback tries to accept, in case some don't have token content (favicons, etc.) - Q_PROPERTY(int callbackTries READ callbackTries WRITE setCallbackTries) + Q_PROPERTY(int callbackTries READ callbackTries WRITE setCallbackTries NOTIFY callbackTriesChanged) int callbackTries(); void setCallbackTries(int maxtries); @@ -36,6 +36,9 @@ class O0_EXPORT O2ReplyServer: public QTcpServer { Q_SIGNALS: void verificationReceived(QMap); void serverClosed(bool); // whether it has found parameters + void replyContentChanged(); + void timeoutChanged(int timeout); + void callbackTriesChanged(int maxtries); public Q_SLOTS: void onIncomingConnection();