Skip to content

Commit

Permalink
Add some missing notifys
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 25, 2024
1 parent 9ff4996 commit 9a8f38a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/o0baseauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,26 @@ bool O0BaseAuth::useExternalWebInterceptor() {
}

void O0BaseAuth::setUseExternalWebInterceptor(bool useExternalWebInterceptor) {
if ( useExternalWebInterceptor_ == useExternalWebInterceptor )
return;
useExternalWebInterceptor_ = useExternalWebInterceptor;
Q_EMIT useExternalWebInterceptorChanged(useExternalWebInterceptor_);
}

QByteArray O0BaseAuth::replyContent() const {
return replyContent_;
}

void O0BaseAuth::setReplyContent(const QByteArray &value) {
bool changed = replyContent_ != value;
replyContent_ = value;
if (replyServer_) {
replyServer_->setReplyContent(replyContent_);
}
if ( changed )
{
Q_EMIT replyContentChanged();
}
}

int O0BaseAuth::localPort() {
Expand Down
6 changes: 4 additions & 2 deletions src/o0baseauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class O0_EXPORT O0BaseAuth : public QObject
void setClientSecret(const QString &value);

/// Should we use a reply server (default) or an external web interceptor?
Q_PROPERTY(bool useExternalWebInterceptor READ useExternalWebInterceptor WRITE setUseExternalWebInterceptor)
Q_PROPERTY(bool useExternalWebInterceptor READ useExternalWebInterceptor WRITE setUseExternalWebInterceptor NOTIFY useExternalWebInterceptorChanged)
bool useExternalWebInterceptor();
void setUseExternalWebInterceptor(bool useExternalWebInterceptor);

/// Page content on local host after successful oauth.
/// Provide it 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() const;
void setReplyContent(const QByteArray &value);

Expand Down Expand Up @@ -121,6 +121,8 @@ public Q_SLOTS:
void tokenChanged();
void tokenSecretChanged();
void extraTokensChanged();
void useExternalWebInterceptorChanged( bool enabled );
void replyContentChanged();

protected:
/// Set authentication token.
Expand Down
9 changes: 9 additions & 0 deletions src/o1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ QByteArray O1::userAgent() const {
}

void O1::setUserAgent(const QByteArray &value) {
if (userAgent_ == value)
return;

userAgent_ = value;
Q_EMIT userAgentChanged(userAgent_);
}

QUrl O1::requestTokenUrl() {
Expand All @@ -57,14 +61,19 @@ QList<O0RequestParameter> O1::requestParameters() {

void O1::setRequestParameters(const QList<O0RequestParameter> &value) {
requestParameters_ = value;
Q_EMIT requestParametersChanged();
}

QString O1::callbackUrl() {
return callbackUrl_;
}

void O1::setCallbackUrl(const QString &value) {
if ( callbackUrl_ == value )
return;

callbackUrl_ = value;
Q_EMIT callbackUrlChanged(callbackUrl_);
}

QUrl O1::authorizeUrl() {
Expand Down
9 changes: 6 additions & 3 deletions src/o1.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class O0_EXPORT O1: public O0BaseAuth {
/// Set user agent to a value unique for your application (https://tools.ietf.org/html/rfc7231#section-5.5.3)
/// if you see the following error in the application log:
/// O1::onTokenRequestError: 201 "Error transferring requestTokenUrl() - server replied: Forbidden" "Bad bot"
Q_PROPERTY(QByteArray userAgent READ userAgent WRITE setUserAgent)
Q_PROPERTY(QByteArray userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged)
QByteArray userAgent() const;
void setUserAgent(const QByteArray &value);

Expand All @@ -32,14 +32,14 @@ class O0_EXPORT O1: public O0BaseAuth {
void setRequestTokenUrl(const QUrl &value);

/// Parameters to pass with request URL.
Q_PROPERTY(QList<O0RequestParameter> requestParameters READ requestParameters WRITE setRequestParameters)
Q_PROPERTY(QList<O0RequestParameter> requestParameters READ requestParameters WRITE setRequestParameters NOTIFY requestParametersChanged)
QList<O0RequestParameter> requestParameters();
void setRequestParameters(const QList<O0RequestParameter> &value);

/// Callback URL.
/// It should contain a `%1` place marker, to be replaced by `O0BaseAuth::localPort()`.
/// Defaults to `O2_CALLBACK_URL`.
Q_PROPERTY(QString callbackUrl READ callbackUrl WRITE setCallbackUrl)
Q_PROPERTY(QString callbackUrl READ callbackUrl WRITE setCallbackUrl NOTIFY callbackUrlChanged)
QString callbackUrl();
void setCallbackUrl(const QString &value);

Expand Down Expand Up @@ -99,6 +99,9 @@ public Q_SLOTS:
void authorizeUrlChanged();
void accessTokenUrlChanged();
void signatureMethodChanged();
void userAgentChanged(const QByteArray& agent);
void requestParametersChanged();
void callbackUrlChanged(const QString& url);

public Q_SLOTS:
/// Handle verification received from the reply server.
Expand Down

0 comments on commit 9a8f38a

Please sign in to comment.