Skip to content

Commit

Permalink
Add remaining missing NOTIFYs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 25, 2024
1 parent 40f4219 commit 977858e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/o2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -697,15 +700,23 @@ QString O2::localhostPolicy() const {
}

void O2::setLocalhostPolicy(const QString &value) {
if (localhostPolicy_ == value)
return;

localhostPolicy_ = value;
Q_EMIT localHostPolicyChanged(localhostPolicy_);
}

QString O2::apiKey() {
return apiKey_;
}

void O2::setApiKey(const QString &value) {
if (apiKey_ == value)
return;

apiKey_ = value;
Q_EMIT apiKeyChanged(apiKey_);
}

bool O2::ignoreSslErrors() {
Expand All @@ -714,4 +725,5 @@ bool O2::ignoreSslErrors() {

void O2::setIgnoreSslErrors(bool ignoreSslErrors) {
timedReplies_.setIgnoreSslErrors(ignoreSslErrors);
Q_EMIT ignoreSslErrorsChanged(ignoreSslErrors);
}
12 changes: 8 additions & 4 deletions src/o2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/o2pollserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ int O2PollServer::interval() const
void O2PollServer::setInterval(int interval)
{
pollTimer.setInterval(interval * 1000);
Q_EMIT intervalChanged(interval);
}

void O2PollServer::startPolling()
Expand Down
3 changes: 2 additions & 1 deletion src/o2pollserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString, QString>);
void serverClosed(bool); // whether it has found parameters
void intervalChanged(int interval);

public Q_SLOTS:
void startPolling();
Expand Down
17 changes: 14 additions & 3 deletions src/o2replyserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions src/o2replyserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -36,6 +36,9 @@ class O0_EXPORT O2ReplyServer: public QTcpServer {
Q_SIGNALS:
void verificationReceived(QMap<QString, QString>);
void serverClosed(bool); // whether it has found parameters
void replyContentChanged();
void timeoutChanged(int timeout);
void callbackTriesChanged(int maxtries);

public Q_SLOTS:
void onIncomingConnection();
Expand Down

0 comments on commit 977858e

Please sign in to comment.