From 57988f6c4e40e557dc0e2b8e6dea6c945ae2b13c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:08:37 +1000 Subject: [PATCH 01/17] Apply modernize-use-nullptr --- examples/facebookdemo/fbdemo.h | 2 +- examples/msgraphdemo/msgraphdemo.h | 2 +- examples/msgraphexternalinterceptordemo/msgraphdemo.cpp | 4 ++-- examples/msgraphexternalinterceptordemo/msgraphdemo.h | 2 +- examples/msgraphexternalinterceptordemo/webenginepage.cpp | 2 +- examples/twitterdemo/tweeter.h | 2 +- examples/vimeodemo/vimeodemo.h | 2 +- examples/youtubedemo/ytdemo.h | 2 +- src/o0abstractstore.h | 2 +- src/o0baseauth.cpp | 2 +- src/o0baseauth.h | 2 +- src/o0keychainstore.h | 2 +- src/o0settingsstore.h | 4 ++-- src/o1.cpp | 2 +- src/o1.h | 2 +- src/o1dropbox.h | 2 +- src/o1flickr.h | 2 +- src/o1freshbooks.h | 2 +- src/o1requestor.h | 2 +- src/o1smugmug.h | 2 +- src/o1twitter.h | 2 +- src/o2.cpp | 4 ++-- src/o2.h | 2 +- src/o2facebook.h | 2 +- src/o2gft.h | 2 +- src/o2google.h | 2 +- src/o2googledevice.h | 2 +- src/o2hubic.h | 2 +- src/o2msgraph.h | 2 +- src/o2pollserver.h | 2 +- src/o2reply.cpp | 2 +- src/o2reply.h | 2 +- src/o2replyserver.h | 4 ++-- src/o2requestor.cpp | 2 +- src/o2requestor.h | 2 +- src/o2skydrive.h | 2 +- src/o2spotify.h | 2 +- src/o2surveymonkey.h | 2 +- src/o2vimeo.h | 2 +- src/oxtwitter.h | 2 +- 40 files changed, 44 insertions(+), 44 deletions(-) diff --git a/examples/facebookdemo/fbdemo.h b/examples/facebookdemo/fbdemo.h index 054e006..0521e9e 100644 --- a/examples/facebookdemo/fbdemo.h +++ b/examples/facebookdemo/fbdemo.h @@ -10,7 +10,7 @@ class FBDemo : public QObject Q_OBJECT public: - explicit FBDemo(QObject *parent = 0); + explicit FBDemo(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/examples/msgraphdemo/msgraphdemo.h b/examples/msgraphdemo/msgraphdemo.h index 01d8512..08dbbc6 100644 --- a/examples/msgraphdemo/msgraphdemo.h +++ b/examples/msgraphdemo/msgraphdemo.h @@ -10,7 +10,7 @@ class MsgraphDemo : public QObject Q_OBJECT public: - explicit MsgraphDemo(QObject *parent = 0); + explicit MsgraphDemo(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index 04017f9..e50d33c 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -20,7 +20,7 @@ const char MSGRAPH_USER_INFO_URL[] = "https://graph.microsoft.com/v1.0/me"; #define GRANTFLOW_STR(v) QString(QENUM_NAME(O2, GrantFlow, v)) MsgraphDemo::MsgraphDemo(QObject *parent) : - QObject(parent), authDialog(NULL), requestId_(0) { + QObject(parent), authDialog(nullptr), requestId_(0) { o2Msgraph_ = new O2Msgraph(this); o2Msgraph_->setClientId(MSGRAPH_APP_ID); @@ -79,7 +79,7 @@ void MsgraphDemo::onOpenBrowser(const QUrl &url) { void MsgraphDemo::onAuthWindowCallbackCalled(const QString &inURLString) { - if(o2Msgraph_ != NULL) + if(o2Msgraph_ != nullptr) { QUrl getTokenUrl(inURLString); QUrlQuery query(getTokenUrl); diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.h b/examples/msgraphexternalinterceptordemo/msgraphdemo.h index b9971a5..075b804 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.h +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.h @@ -11,7 +11,7 @@ class MsgraphDemo : public QObject Q_OBJECT public: - explicit MsgraphDemo(QObject *parent = 0); + explicit MsgraphDemo(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/examples/msgraphexternalinterceptordemo/webenginepage.cpp b/examples/msgraphexternalinterceptordemo/webenginepage.cpp index 906e9e1..bf3de7c 100644 --- a/examples/msgraphexternalinterceptordemo/webenginepage.cpp +++ b/examples/msgraphexternalinterceptordemo/webenginepage.cpp @@ -46,7 +46,7 @@ QWebEnginePage *WebEnginePage::createWindow(WebWindowType type) } } - return NULL; + return nullptr; } void WebEnginePage::onAuthWindowCallbackCalled(const QString &inURLString) diff --git a/examples/twitterdemo/tweeter.h b/examples/twitterdemo/tweeter.h index 6108725..7f5353b 100644 --- a/examples/twitterdemo/tweeter.h +++ b/examples/twitterdemo/tweeter.h @@ -13,7 +13,7 @@ class Tweeter : public QObject { Q_OBJECT public: - explicit Tweeter(QObject *parent = 0); + explicit Tweeter(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/examples/vimeodemo/vimeodemo.h b/examples/vimeodemo/vimeodemo.h index 8d53502..2414b48 100644 --- a/examples/vimeodemo/vimeodemo.h +++ b/examples/vimeodemo/vimeodemo.h @@ -10,7 +10,7 @@ class VimeoDemo : public QObject Q_OBJECT public: - explicit VimeoDemo(QObject *parent = 0); + explicit VimeoDemo(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/examples/youtubedemo/ytdemo.h b/examples/youtubedemo/ytdemo.h index 6be20af..d6ebd5b 100644 --- a/examples/youtubedemo/ytdemo.h +++ b/examples/youtubedemo/ytdemo.h @@ -10,7 +10,7 @@ class YTDemo : public QObject Q_OBJECT public: - explicit YTDemo(QObject *parent = 0); + explicit YTDemo(QObject *parent = nullptr); signals: void extraTokensReady(const QVariantMap &extraTokens); diff --git a/src/o0abstractstore.h b/src/o0abstractstore.h index 2807118..7ee6081 100644 --- a/src/o0abstractstore.h +++ b/src/o0abstractstore.h @@ -11,7 +11,7 @@ class O0_EXPORT O0AbstractStore: public QObject { Q_OBJECT public: - explicit O0AbstractStore(QObject *parent = 0): QObject(parent) { + explicit O0AbstractStore(QObject *parent = nullptr): QObject(parent) { } /// Retrieve a string value by key. diff --git a/src/o0baseauth.cpp b/src/o0baseauth.cpp index 3329baa..d9721b2 100644 --- a/src/o0baseauth.cpp +++ b/src/o0baseauth.cpp @@ -13,7 +13,7 @@ static const quint16 DefaultLocalPort = 1965; std::function O0BaseAuth::sLoggingFunction; -O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent), store_(0), useExternalWebInterceptor_(false), replyServer_(NULL), pollServer_(NULL) { +O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent), store_(nullptr), useExternalWebInterceptor_(false), replyServer_(nullptr), pollServer_(nullptr) { localPort_ = DefaultLocalPort; setStore(store); } diff --git a/src/o0baseauth.h b/src/o0baseauth.h index f453029..340b655 100644 --- a/src/o0baseauth.h +++ b/src/o0baseauth.h @@ -26,7 +26,7 @@ class O0_EXPORT O0BaseAuth : public QObject Warning, Critical }; - explicit O0BaseAuth(QObject *parent = 0, O0AbstractStore *store = 0); + explicit O0BaseAuth(QObject *parent = nullptr, O0AbstractStore *store = nullptr); public: /// Are we authenticated? diff --git a/src/o0keychainstore.h b/src/o0keychainstore.h index b915f4f..5354f69 100644 --- a/src/o0keychainstore.h +++ b/src/o0keychainstore.h @@ -22,7 +22,7 @@ class Job; class O0_EXPORT o0keyChainStore : public O0AbstractStore{ Q_OBJECT public: - explicit o0keyChainStore(const QString& app,const QString& name,QObject *parent = 0); + explicit o0keyChainStore(const QString& app,const QString& name,QObject *parent = nullptr); /// Retrieve a string value by key. QString value(const QString &key, const QString &defaultValue = QString()); diff --git a/src/o0settingsstore.h b/src/o0settingsstore.h index bfe1c6d..f0b4e70 100644 --- a/src/o0settingsstore.h +++ b/src/o0settingsstore.h @@ -14,10 +14,10 @@ class O0_EXPORT O0SettingsStore: public O0AbstractStore { public: /// Constructor - explicit O0SettingsStore(const QString &encryptionKey, QObject *parent = 0); + explicit O0SettingsStore(const QString &encryptionKey, QObject *parent = nullptr); /// Construct with an explicit QSettings instance - explicit O0SettingsStore(QSettings *settings, const QString &encryptionKey, QObject *parent = 0); + explicit O0SettingsStore(QSettings *settings, const QString &encryptionKey, QObject *parent = nullptr); /// Group key prefix Q_PROPERTY(QString groupKey READ groupKey WRITE setGroupKey NOTIFY groupKeyChanged) diff --git a/src/o1.cpp b/src/o1.cpp index 5983800..7923065 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -216,7 +216,7 @@ void O1::link() { // Create the reply server if it doesn't exist // and we don't use an external web interceptor if(!useExternalWebInterceptor_) { - if(replyServer() == NULL) { + if(replyServer() == nullptr) { O2ReplyServer * replyServer = new O2ReplyServer(this); connect(replyServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); setReplyServer(replyServer); diff --git a/src/o1.h b/src/o1.h index b54abd5..6fad791 100644 --- a/src/o1.h +++ b/src/o1.h @@ -54,7 +54,7 @@ class O0_EXPORT O1: public O0BaseAuth { void setAccessTokenUrl(const QUrl &value); /// Constructor. - explicit O1(QObject *parent = 0, QNetworkAccessManager *manager = 0, O0AbstractStore *store = 0); + explicit O1(QObject *parent = nullptr, QNetworkAccessManager *manager = nullptr, O0AbstractStore *store = nullptr); /// Parse a URL-encoded response string. static QMap parseResponse(const QByteArray &response); diff --git a/src/o1dropbox.h b/src/o1dropbox.h index 59f9d4d..622d03a 100644 --- a/src/o1dropbox.h +++ b/src/o1dropbox.h @@ -9,7 +9,7 @@ class O0_EXPORT O1Dropbox: public O1 { Q_OBJECT public: - explicit O1Dropbox(QObject *parent = 0): O1(parent) { + explicit O1Dropbox(QObject *parent = nullptr): O1(parent) { setRequestTokenUrl(QUrl("https://api.dropbox.com/1/oauth/request_token")); setAuthorizeUrl(QUrl("https://www.dropbox.com/1/oauth/authorize?display=mobile")); setAccessTokenUrl(QUrl("https://api.dropbox.com/1/oauth/access_token")); diff --git a/src/o1flickr.h b/src/o1flickr.h index fb28416..9ef4a20 100644 --- a/src/o1flickr.h +++ b/src/o1flickr.h @@ -9,7 +9,7 @@ class O0_EXPORT O1Flickr: public O1 { Q_OBJECT public: - explicit O1Flickr(QObject *parent = 0): O1(parent) { + explicit O1Flickr(QObject *parent = nullptr): O1(parent) { setRequestTokenUrl(QUrl("http://www.flickr.com/services/oauth/request_token")); setAuthorizeUrl(QUrl("http://www.flickr.com/services/oauth/authorize?perms=write")); setAccessTokenUrl(QUrl("http://www.flickr.com/services/oauth/access_token")); diff --git a/src/o1freshbooks.h b/src/o1freshbooks.h index 61b0d68..22fc422 100644 --- a/src/o1freshbooks.h +++ b/src/o1freshbooks.h @@ -9,7 +9,7 @@ class O0_EXPORT O1Freshbooks: public O1 { Q_OBJECT public: - explicit O1Freshbooks(QObject *parent = 0): O1(parent) { + explicit O1Freshbooks(QObject *parent = nullptr): O1(parent) { } void setClientId(const QString &value) { diff --git a/src/o1requestor.h b/src/o1requestor.h index 9d07c98..5f63c1b 100644 --- a/src/o1requestor.h +++ b/src/o1requestor.h @@ -17,7 +17,7 @@ class O0_EXPORT O1Requestor: public QObject { Q_OBJECT public: - explicit O1Requestor(QNetworkAccessManager *manager, O1 *authenticator, QObject *parent = 0); + explicit O1Requestor(QNetworkAccessManager *manager, O1 *authenticator, QObject *parent = nullptr); public Q_SLOTS: /// Make a GET request. diff --git a/src/o1smugmug.h b/src/o1smugmug.h index 902058e..5c8740b 100644 --- a/src/o1smugmug.h +++ b/src/o1smugmug.h @@ -63,7 +63,7 @@ class O0_EXPORT O1SmugMug: public O1 { void initAuthorizationUrl(const AuthorizationUrlBuilder &builder); #endif // QT_VERSION >= 0x050000 - explicit O1SmugMug(QObject *parent = 0, QNetworkAccessManager *manager = 0, O0AbstractStore *store = 0); + explicit O1SmugMug(QObject *parent = nullptr, QNetworkAccessManager *manager = nullptr, O0AbstractStore *store = nullptr); }; #endif // O1SMUGMUG_H diff --git a/src/o1twitter.h b/src/o1twitter.h index de1a10e..c229ac7 100644 --- a/src/o1twitter.h +++ b/src/o1twitter.h @@ -9,7 +9,7 @@ class O0_EXPORT O1Twitter: public O1 { Q_OBJECT public: - explicit O1Twitter(QObject *parent = 0): O1(parent) { + explicit O1Twitter(QObject *parent = nullptr): O1(parent) { setRequestTokenUrl(QUrl("https://api.twitter.com/oauth/request_token")); setAuthorizeUrl(QUrl("https://api.twitter.com/oauth/authenticate")); setAccessTokenUrl(QUrl("https://api.twitter.com/oauth/access_token")); diff --git a/src/o2.cpp b/src/o2.cpp index a5da989..afb024b 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -171,7 +171,7 @@ void O2::link() { // Create the reply server if it doesn't exist // and we don't use an external web interceptor if(!useExternalWebInterceptor_) { - if(replyServer() == NULL) { + if(replyServer() == nullptr) { O2ReplyServer * replyServer = new O2ReplyServer(this); connect(replyServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); connect(replyServer, SIGNAL(serverClosed(bool)), this, SLOT(serverHasClosed(bool))); @@ -651,7 +651,7 @@ void O2::serverHasClosed(bool paramsfound) Q_EMIT linkingFailed(); } // poll server is not re-used for later auth requests - setPollServer(NULL); + setPollServer(nullptr); } QString O2::localhostPolicy() const { diff --git a/src/o2.h b/src/o2.h index 04894d3..0267358 100644 --- a/src/o2.h +++ b/src/o2.h @@ -95,7 +95,7 @@ class O0_EXPORT O2: public O0BaseAuth public: /// Constructor. /// @param parent Parent object. - explicit O2(QObject *parent = 0, QNetworkAccessManager *manager = 0, O0AbstractStore *store = 0); + explicit O2(QObject *parent = nullptr, QNetworkAccessManager *manager = nullptr, O0AbstractStore *store = nullptr); /// Get authentication code. QString code(); diff --git a/src/o2facebook.h b/src/o2facebook.h index 6889afe..6c0cbc3 100644 --- a/src/o2facebook.h +++ b/src/o2facebook.h @@ -9,7 +9,7 @@ class O0_EXPORT O2Facebook: public O2 { Q_OBJECT public: - explicit O2Facebook(QObject *parent = 0); + explicit O2Facebook(QObject *parent = nullptr); public Q_SLOTS: void onVerificationReceived(QMap); diff --git a/src/o2gft.h b/src/o2gft.h index fa0e5b1..f9563bf 100644 --- a/src/o2gft.h +++ b/src/o2gft.h @@ -9,7 +9,7 @@ class O0_EXPORT O2Gft: public O2Google{ Q_OBJECT public: - explicit O2Gft(QObject *parent = 0); + explicit O2Gft(QObject *parent = nullptr); }; #endif // O2GFT_H diff --git a/src/o2google.h b/src/o2google.h index 21e07e6..fdaffa4 100644 --- a/src/o2google.h +++ b/src/o2google.h @@ -10,7 +10,7 @@ class O2Google : public O2 { Q_OBJECT public: - explicit O2Google(QObject *parent = 0); + explicit O2Google(QObject *parent = nullptr); }; diff --git a/src/o2googledevice.h b/src/o2googledevice.h index a2a84a8..745c6a6 100644 --- a/src/o2googledevice.h +++ b/src/o2googledevice.h @@ -10,7 +10,7 @@ class O0_EXPORT O2GoogleDevice : public O2 { Q_OBJECT public: - explicit O2GoogleDevice(QObject *parent = 0); + explicit O2GoogleDevice(QObject *parent = nullptr); }; #endif // O2GOOGLEDEVICE_H diff --git a/src/o2hubic.h b/src/o2hubic.h index bb93fcf..b8c96dc 100644 --- a/src/o2hubic.h +++ b/src/o2hubic.h @@ -11,7 +11,7 @@ class O0_EXPORT O2Hubic: public O2 { public: /// Constructor. /// @param parent Parent object. - explicit O2Hubic(QObject *parent = 0); + explicit O2Hubic(QObject *parent = nullptr); }; diff --git a/src/o2msgraph.h b/src/o2msgraph.h index 48db6c9..89c65ac 100644 --- a/src/o2msgraph.h +++ b/src/o2msgraph.h @@ -9,7 +9,7 @@ class O0_EXPORT O2Msgraph: public O2 { Q_OBJECT public: - explicit O2Msgraph(QObject *parent = 0); + explicit O2Msgraph(QObject *parent = nullptr); }; #endif // O2MSGRAPH_H diff --git a/src/o2pollserver.h b/src/o2pollserver.h index 69a2f9f..594bc62 100644 --- a/src/o2pollserver.h +++ b/src/o2pollserver.h @@ -18,7 +18,7 @@ class O0_EXPORT O2PollServer : public QObject Q_OBJECT public: - explicit O2PollServer(QNetworkAccessManager * manager, const QNetworkRequest &request, const QByteArray & payload, int expiresIn, QObject *parent = 0); + 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) diff --git a/src/o2reply.cpp b/src/o2reply.cpp index 4faf7ff..a1cda3a 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -48,7 +48,7 @@ O2Reply *O2ReplyList::find(const QNetworkReply *reply) { return timedReply; } } - return 0; + return nullptr; } bool O2ReplyList::ignoreSslErrors() const diff --git a/src/o2reply.h b/src/o2reply.h index 5ee41ee..909cf15 100644 --- a/src/o2reply.h +++ b/src/o2reply.h @@ -15,7 +15,7 @@ class O0_EXPORT O2Reply: public QTimer { Q_OBJECT public: - explicit O2Reply(QNetworkReply *reply, int timeOut = 60 * 1000, QObject *parent = 0); + explicit O2Reply(QNetworkReply *reply, int timeOut = 60 * 1000, QObject *parent = nullptr); Q_SIGNALS: void error(QNetworkReply::NetworkError); diff --git a/src/o2replyserver.h b/src/o2replyserver.h index 666b330..3efcf87 100644 --- a/src/o2replyserver.h +++ b/src/o2replyserver.h @@ -13,7 +13,7 @@ class O0_EXPORT O2ReplyServer: public QTcpServer { Q_OBJECT public: - explicit O2ReplyServer(QObject *parent = 0); + 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) @@ -41,7 +41,7 @@ public Q_SLOTS: void onIncomingConnection(); void onBytesReady(); QMap parseQueryParams(QByteArray *data); - void closeServer(QTcpSocket *socket = 0, bool hasparameters = false); + void closeServer(QTcpSocket *socket = nullptr, bool hasparameters = false); protected: QByteArray replyContent_; diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index d312bd9..48f845f 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -10,7 +10,7 @@ #include "o2.h" #include "o0globals.h" -O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent): QObject(parent), reply_(NULL), status_(Idle), addAccessTokenInQuery_(true), rawData_(false) { +O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent): QObject(parent), reply_(nullptr), status_(Idle), addAccessTokenInQuery_(true), rawData_(false) { manager_ = manager; authenticator_ = authenticator; if (authenticator) { diff --git a/src/o2requestor.h b/src/o2requestor.h index c2ff20a..b238666 100644 --- a/src/o2requestor.h +++ b/src/o2requestor.h @@ -19,7 +19,7 @@ class O0_EXPORT O2Requestor: public QObject { Q_OBJECT public: - explicit O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent = 0); + explicit O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent = nullptr); ~O2Requestor(); diff --git a/src/o2skydrive.h b/src/o2skydrive.h index 32263cf..0602a40 100644 --- a/src/o2skydrive.h +++ b/src/o2skydrive.h @@ -9,7 +9,7 @@ class O0_EXPORT O2Skydrive: public O2 { Q_OBJECT public: - explicit O2Skydrive(QObject *parent = 0); + explicit O2Skydrive(QObject *parent = nullptr); public Q_SLOTS: Q_INVOKABLE void link(); diff --git a/src/o2spotify.h b/src/o2spotify.h index 1312536..0f48eb7 100644 --- a/src/o2spotify.h +++ b/src/o2spotify.h @@ -8,7 +8,7 @@ class O0_EXPORT O2Spotify: public O2 { Q_OBJECT public: - explicit O2Spotify(QObject *parent = 0); + explicit O2Spotify(QObject *parent = nullptr); struct Scope { static const QString PLAYLIST_READ_PRIVATE; diff --git a/src/o2surveymonkey.h b/src/o2surveymonkey.h index f73c532..4284626 100644 --- a/src/o2surveymonkey.h +++ b/src/o2surveymonkey.h @@ -9,7 +9,7 @@ class O0_EXPORT O2SurveyMonkey: public O2 { Q_OBJECT public: - explicit O2SurveyMonkey(QObject *parent = 0); + explicit O2SurveyMonkey(QObject *parent = nullptr); }; #endif // O2SURVEYMONKEY_H diff --git a/src/o2vimeo.h b/src/o2vimeo.h index f1acd16..2f25657 100644 --- a/src/o2vimeo.h +++ b/src/o2vimeo.h @@ -9,7 +9,7 @@ class O0_EXPORT O2Vimeo : public O2 { Q_OBJECT public: - explicit O2Vimeo(QObject *parent = 0); + explicit O2Vimeo(QObject *parent = nullptr); }; #endif // O2VIMEO_H diff --git a/src/oxtwitter.h b/src/oxtwitter.h index d3c6ff1..cd35af8 100644 --- a/src/oxtwitter.h +++ b/src/oxtwitter.h @@ -9,7 +9,7 @@ class O0_EXPORT OXTwitter: public O1Twitter { Q_OBJECT public: - explicit OXTwitter(QObject *parent = 0); + explicit OXTwitter(QObject *parent = nullptr); /// XAuth Username Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) From 74dcc6469961bb750fdc224ba029e1f126221dc4 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:15:08 +1000 Subject: [PATCH 02/17] modernize-use-override --- examples/msgraphexternalinterceptordemo/webenginepage.h | 6 +++--- examples/msgraphexternalinterceptordemo/webwindow.h | 4 ++-- src/o0keychainstore.h | 4 ++-- src/o0settingsstore.h | 4 ++-- src/o1.h | 4 ++-- src/o2.h | 4 ++-- src/o2facebook.h | 4 ++-- src/o2requestor.h | 2 +- src/o2skydrive.h | 2 +- src/oxtwitter.h | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/msgraphexternalinterceptordemo/webenginepage.h b/examples/msgraphexternalinterceptordemo/webenginepage.h index 4b9ec42..d536db4 100644 --- a/examples/msgraphexternalinterceptordemo/webenginepage.h +++ b/examples/msgraphexternalinterceptordemo/webenginepage.h @@ -13,12 +13,12 @@ class WebEnginePage : public QWebEnginePage WebEnginePage(QWebEngineProfile *inProfile, const QString &inRedirectURLString) : QWebEnginePage(inProfile), mRedirectURLString(inRedirectURLString) { } - virtual ~WebEnginePage(); + ~WebEnginePage() override; - bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame); + bool acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame) override; protected: - QWebEnginePage *createWindow(WebWindowType type); + QWebEnginePage *createWindow(WebWindowType type) override; signals: void callbackCatched(const QString &inURLString); diff --git a/examples/msgraphexternalinterceptordemo/webwindow.h b/examples/msgraphexternalinterceptordemo/webwindow.h index f87a503..45d27d9 100644 --- a/examples/msgraphexternalinterceptordemo/webwindow.h +++ b/examples/msgraphexternalinterceptordemo/webwindow.h @@ -14,14 +14,14 @@ class WebWindow : public QDialog public: explicit WebWindow(QSize inWindowSize, QUrl inLoginURL, QString inRedirectURLString, bool inAutoclose); - ~WebWindow(); + ~WebWindow() override; QString resultStr; QWebEnginePage *GetWebEnginePage() { return mWebEnginePage; } protected: - void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; signals: void windowClosed(); diff --git a/src/o0keychainstore.h b/src/o0keychainstore.h index 5354f69..45a1dcf 100644 --- a/src/o0keychainstore.h +++ b/src/o0keychainstore.h @@ -25,10 +25,10 @@ class O0_EXPORT o0keyChainStore : public O0AbstractStore{ explicit o0keyChainStore(const QString& app,const QString& name,QObject *parent = nullptr); /// Retrieve a string value by key. - QString value(const QString &key, const QString &defaultValue = QString()); + QString value(const QString &key, const QString &defaultValue = QString()) override; /// Set a string value for a key. - void setValue(const QString &key, const QString &value); + void setValue(const QString &key, const QString &value) override; // The functions below return QKeychain::Error casted to int. They don't // return the enumerator directly because it can not be forward-declared reliably, diff --git a/src/o0settingsstore.h b/src/o0settingsstore.h index f0b4e70..ac8e8ef 100644 --- a/src/o0settingsstore.h +++ b/src/o0settingsstore.h @@ -25,10 +25,10 @@ class O0_EXPORT O0SettingsStore: public O0AbstractStore { void setGroupKey(const QString &groupKey); /// Get a string value for a key - QString value(const QString &key, const QString &defaultValue = QString()); + QString value(const QString &key, const QString &defaultValue = QString()) override; /// Set a string value for a key - void setValue(const QString &key, const QString &value); + void setValue(const QString &key, const QString &value) override; Q_SIGNALS: // Property change signals diff --git a/src/o1.h b/src/o1.h index 6fad791..635add5 100644 --- a/src/o1.h +++ b/src/o1.h @@ -89,10 +89,10 @@ class O0_EXPORT O1: public O0BaseAuth { public Q_SLOTS: /// Authenticate. - Q_INVOKABLE virtual void link(); + Q_INVOKABLE void link() override; /// De-authenticate. - Q_INVOKABLE virtual void unlink(); + Q_INVOKABLE void unlink() override; Q_SIGNALS: void requestTokenUrlChanged(); diff --git a/src/o2.h b/src/o2.h index 0267358..e89d48d 100644 --- a/src/o2.h +++ b/src/o2.h @@ -108,10 +108,10 @@ class O0_EXPORT O2: public O0BaseAuth public Q_SLOTS: /// Authenticate. - Q_INVOKABLE virtual void link(); + Q_INVOKABLE void link() override; /// De-authenticate. - Q_INVOKABLE virtual void unlink(); + Q_INVOKABLE void unlink() override; /// Refresh token. Q_INVOKABLE void refresh(); diff --git a/src/o2facebook.h b/src/o2facebook.h index 6c0cbc3..9a44ca8 100644 --- a/src/o2facebook.h +++ b/src/o2facebook.h @@ -12,10 +12,10 @@ class O0_EXPORT O2Facebook: public O2 { explicit O2Facebook(QObject *parent = nullptr); public Q_SLOTS: - void onVerificationReceived(QMap); + void onVerificationReceived(QMap) override; protected Q_SLOTS: - virtual void onTokenReplyFinished(); + void onTokenReplyFinished() override; }; #endif // O2FACEBOOK_H diff --git a/src/o2requestor.h b/src/o2requestor.h index b238666..ff68d38 100644 --- a/src/o2requestor.h +++ b/src/o2requestor.h @@ -20,7 +20,7 @@ class O0_EXPORT O2Requestor: public QObject { public: explicit O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent = nullptr); - ~O2Requestor(); + ~O2Requestor() override; /// Some services require the access token to be sent as a Authentication HTTP header diff --git a/src/o2skydrive.h b/src/o2skydrive.h index 0602a40..013caa1 100644 --- a/src/o2skydrive.h +++ b/src/o2skydrive.h @@ -12,7 +12,7 @@ class O0_EXPORT O2Skydrive: public O2 { explicit O2Skydrive(QObject *parent = nullptr); public Q_SLOTS: - Q_INVOKABLE void link(); + Q_INVOKABLE void link() override; Q_INVOKABLE virtual void redirected(const QUrl &url); }; diff --git a/src/oxtwitter.h b/src/oxtwitter.h index cd35af8..a1353af 100644 --- a/src/oxtwitter.h +++ b/src/oxtwitter.h @@ -23,7 +23,7 @@ class O0_EXPORT OXTwitter: public O1Twitter { public Q_SLOTS: /// Authenticate. - Q_INVOKABLE virtual void link(); + Q_INVOKABLE void link() override; Q_SIGNALS: void usernameChanged(); From 990ad4c7ce94e33d8f07cbeca2cc8207510381a4 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:17:27 +1000 Subject: [PATCH 03/17] modernize-use-default-member-init --- examples/facebookdemo/main.cpp | 4 ++-- examples/msgraphdemo/msgraphdemo.cpp | 2 +- examples/msgraphdemo/msgraphdemo.h | 2 +- examples/msgraphexternalinterceptordemo/msgraphdemo.cpp | 2 +- examples/msgraphexternalinterceptordemo/msgraphdemo.h | 4 ++-- examples/twitterdemo/main.cpp | 4 ++-- examples/vimeodemo/main.cpp | 4 ++-- examples/vimeodemo/vimeodemo.cpp | 2 +- examples/vimeodemo/vimeodemo.h | 2 +- examples/youtubedemo/main.cpp | 4 ++-- examples/youtubedemo/ytdemo.cpp | 2 +- examples/youtubedemo/ytdemo.h | 2 +- src/o0baseauth.cpp | 2 +- src/o0baseauth.h | 8 ++++---- src/o2replyserver.cpp | 3 +-- src/o2replyserver.h | 6 +++--- src/o2requestor.cpp | 2 +- src/o2requestor.h | 8 ++++---- 18 files changed, 31 insertions(+), 32 deletions(-) diff --git a/examples/facebookdemo/main.cpp b/examples/facebookdemo/main.cpp index ca83551..c8d3dfb 100644 --- a/examples/facebookdemo/main.cpp +++ b/examples/facebookdemo/main.cpp @@ -20,7 +20,7 @@ class Helper : public QObject { Q_OBJECT public: - Helper() : QObject(), fbdemo_(this), waitForMsg_(false), msg_(QString()) {} + Helper() : QObject(), fbdemo_(this) {} public slots: void processArgs() { @@ -57,7 +57,7 @@ public slots: private: FBDemo fbdemo_; - bool waitForMsg_; + bool waitForMsg_{false}; QString msg_; }; diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp index 907f394..58d78ca 100644 --- a/examples/msgraphdemo/msgraphdemo.cpp +++ b/examples/msgraphdemo/msgraphdemo.cpp @@ -22,7 +22,7 @@ const int localPort = 8888; #define GRANTFLOW_STR(v) QString(QENUM_NAME(O2, GrantFlow, v)) MsgraphDemo::MsgraphDemo(QObject *parent) : - QObject(parent), requestId_(0) { + QObject(parent) { o2Msgraph_ = new O2Msgraph(this); o2Msgraph_->setClientId(MSGRAPH_APP_ID); diff --git a/examples/msgraphdemo/msgraphdemo.h b/examples/msgraphdemo/msgraphdemo.h index 08dbbc6..9996025 100644 --- a/examples/msgraphdemo/msgraphdemo.h +++ b/examples/msgraphdemo/msgraphdemo.h @@ -32,7 +32,7 @@ private slots: private: O2Msgraph *o2Msgraph_; - int requestId_; + int requestId_{0}; }; #endif // MSGRAPHDEMO_H diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index e50d33c..ac20d5c 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -20,7 +20,7 @@ const char MSGRAPH_USER_INFO_URL[] = "https://graph.microsoft.com/v1.0/me"; #define GRANTFLOW_STR(v) QString(QENUM_NAME(O2, GrantFlow, v)) MsgraphDemo::MsgraphDemo(QObject *parent) : - QObject(parent), authDialog(nullptr), requestId_(0) { + QObject(parent) { o2Msgraph_ = new O2Msgraph(this); o2Msgraph_->setClientId(MSGRAPH_APP_ID); diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.h b/examples/msgraphexternalinterceptordemo/msgraphdemo.h index 075b804..0d6a436 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.h +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.h @@ -35,8 +35,8 @@ private slots: private: O2Msgraph *o2Msgraph_; - WebWindow* authDialog; - int requestId_; + WebWindow* authDialog{nullptr}; + int requestId_{0}; }; #endif // MSGRAPHDEMO_H diff --git a/examples/twitterdemo/main.cpp b/examples/twitterdemo/main.cpp index c189ca1..3c80cc6 100644 --- a/examples/twitterdemo/main.cpp +++ b/examples/twitterdemo/main.cpp @@ -27,7 +27,7 @@ class Helper : public QObject { Q_OBJECT public: - Helper() : QObject(), tweeter_(this), waitForMsg_(false), msg_(QString()) {} + Helper() : QObject(), tweeter_(this) {} public slots: void processArgs() { @@ -95,7 +95,7 @@ private slots: private: Tweeter tweeter_; - bool waitForMsg_; + bool waitForMsg_{false}; QString msg_; }; diff --git a/examples/vimeodemo/main.cpp b/examples/vimeodemo/main.cpp index 9886b57..15bbf89 100644 --- a/examples/vimeodemo/main.cpp +++ b/examples/vimeodemo/main.cpp @@ -14,7 +14,7 @@ class Helper : public QObject { Q_OBJECT public: - Helper() : QObject(), demo_(this), waitForMsg_(false), msg_(QString()) {} + Helper() : QObject(), demo_(this) {} public slots: void run() { @@ -48,7 +48,7 @@ public slots: private: VimeoDemo demo_; - bool waitForMsg_; + bool waitForMsg_{false}; QString msg_; }; diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp index adfb373..f5939bb 100644 --- a/examples/vimeodemo/vimeodemo.cpp +++ b/examples/vimeodemo/vimeodemo.cpp @@ -22,7 +22,7 @@ const int localPort = 8888; #define GRANTFLOW_STR(v) QString(QENUM_NAME(O2, GrantFlow, v)) VimeoDemo::VimeoDemo(QObject *parent) : - QObject(parent), requestId_(0) { + QObject(parent) { o2Vimeo_ = new O2Vimeo(this); o2Vimeo_->setClientId(VIMEO_APP_KEY); diff --git a/examples/vimeodemo/vimeodemo.h b/examples/vimeodemo/vimeodemo.h index 2414b48..ca7c38d 100644 --- a/examples/vimeodemo/vimeodemo.h +++ b/examples/vimeodemo/vimeodemo.h @@ -32,7 +32,7 @@ private slots: private: O2Vimeo *o2Vimeo_; - int requestId_; + int requestId_{0}; }; #endif // VMDEMO_H diff --git a/examples/youtubedemo/main.cpp b/examples/youtubedemo/main.cpp index 5c91f8e..150f3d7 100644 --- a/examples/youtubedemo/main.cpp +++ b/examples/youtubedemo/main.cpp @@ -11,7 +11,7 @@ class Helper : public QObject { Q_OBJECT public: - Helper() : QObject(), ytdemo_(this), waitForMsg_(false), msg_(QString()) {} + Helper() : QObject(), ytdemo_(this) {} public slots: void run() { @@ -45,7 +45,7 @@ public slots: private: YTDemo ytdemo_; - bool waitForMsg_; + bool waitForMsg_{false}; QString msg_; }; diff --git a/examples/youtubedemo/ytdemo.cpp b/examples/youtubedemo/ytdemo.cpp index 4293e35..4970c0c 100644 --- a/examples/youtubedemo/ytdemo.cpp +++ b/examples/youtubedemo/ytdemo.cpp @@ -21,7 +21,7 @@ const int localPort = 8888; #define GRANTFLOW_STR(v) QString(QENUM_NAME(O2, GrantFlow, v)) YTDemo::YTDemo(QObject *parent) : - QObject(parent), requestId_(0) { + QObject(parent) { o2Google_ = new O2Google(this); o2Google_->setClientId(GOOGLE_APP_KEY); diff --git a/examples/youtubedemo/ytdemo.h b/examples/youtubedemo/ytdemo.h index d6ebd5b..02234e9 100644 --- a/examples/youtubedemo/ytdemo.h +++ b/examples/youtubedemo/ytdemo.h @@ -32,7 +32,7 @@ private slots: private: O2Google *o2Google_; - int requestId_; + int requestId_{0}; }; #endif // YTDEMO_H diff --git a/src/o0baseauth.cpp b/src/o0baseauth.cpp index d9721b2..07ea7ee 100644 --- a/src/o0baseauth.cpp +++ b/src/o0baseauth.cpp @@ -13,7 +13,7 @@ static const quint16 DefaultLocalPort = 1965; std::function O0BaseAuth::sLoggingFunction; -O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent), store_(nullptr), useExternalWebInterceptor_(false), replyServer_(nullptr), pollServer_(nullptr) { +O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent) { localPort_ = DefaultLocalPort; setStore(store); } diff --git a/src/o0baseauth.h b/src/o0baseauth.h index 340b655..54aa0e6 100644 --- a/src/o0baseauth.h +++ b/src/o0baseauth.h @@ -155,17 +155,17 @@ public Q_SLOTS: QUrl authorizeUrl_; QUrl accessTokenUrl_; quint16 localPort_; - O0AbstractStore *store_; + O0AbstractStore *store_{nullptr}; QVariantMap extraTokens_; QByteArray pkceCodeVerifier_; QString pkceCodeChallenge_; - bool useExternalWebInterceptor_; + bool useExternalWebInterceptor_{false}; QByteArray replyContent_; static std::function sLoggingFunction; private: - O2ReplyServer *replyServer_; - O2PollServer *pollServer_; + O2ReplyServer *replyServer_{nullptr}; + O2PollServer *pollServer_{nullptr}; }; #endif // O0BASEAUTH diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 331058d..3f83fda 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -15,8 +15,7 @@ #include "o2replyserver.h" #include "o0baseauth.h" -O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent), - timeout_(15), maxtries_(3), tries_(0) { +O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent) { O0BaseAuth::log( QStringLiteral( "O2ReplyServer: Starting" ) ); connect(this, SIGNAL(newConnection()), this, SLOT(onIncomingConnection())); replyContent_ = ""; diff --git a/src/o2replyserver.h b/src/o2replyserver.h index 3efcf87..95681c9 100644 --- a/src/o2replyserver.h +++ b/src/o2replyserver.h @@ -45,9 +45,9 @@ public Q_SLOTS: protected: QByteArray replyContent_; - int timeout_; - int maxtries_; - int tries_; + int timeout_{15}; + int maxtries_{3}; + int tries_{0}; QString uniqueState_; }; diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index 48f845f..83fa1bb 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -10,7 +10,7 @@ #include "o2.h" #include "o0globals.h" -O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent): QObject(parent), reply_(nullptr), status_(Idle), addAccessTokenInQuery_(true), rawData_(false) { +O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObject *parent): QObject(parent) { manager_ = manager; authenticator_ = authenticator; if (authenticator) { diff --git a/src/o2requestor.h b/src/o2requestor.h index ff68d38..9ad0f4d 100644 --- a/src/o2requestor.h +++ b/src/o2requestor.h @@ -115,16 +115,16 @@ protected Q_SLOTS: QNetworkRequest request_; QByteArray data_; QHttpMultiPart* multipartData_; - QNetworkReply *reply_; - Status status_; + QNetworkReply *reply_{nullptr}; + Status status_{Idle}; int id_; QNetworkAccessManager::Operation operation_; QUrl url_; O2ReplyList timedReplies_; QNetworkReply::NetworkError error_; - bool addAccessTokenInQuery_; + bool addAccessTokenInQuery_{true}; QString accessTokenInAuthenticationHTTPHeaderFormat_; - bool rawData_; + bool rawData_{false}; }; #endif // O2REQUESTOR_H From 84d20187bf614ff19aae0e48f14f1fe1a8030081 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:18:17 +1000 Subject: [PATCH 04/17] modernize-use-equals-default --- src/o2requestor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index 83fa1bb..fda7423 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -20,8 +20,7 @@ O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObj connect(authenticator, SIGNAL(refreshFinished(QNetworkReply::NetworkError)), this, SLOT(onRefreshFinished(QNetworkReply::NetworkError)), Qt::QueuedConnection); } -O2Requestor::~O2Requestor() { -} +O2Requestor::~O2Requestor() = default; void O2Requestor::setAddAccessTokenInQuery(bool value) { addAccessTokenInQuery_ = value; From 6a0967d71093a16571a89781002155e229b3e879 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:23:36 +1000 Subject: [PATCH 05/17] Fix some clang-tidy warnings --- src/o2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/o2.cpp b/src/o2.cpp index afb024b..120a88a 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -195,7 +195,8 @@ void O2::link() { if (grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowImplicit) { #if QT_VERSION >= 0x050000 - QString uniqueState = QUuid::createUuid().toString().remove(QRegularExpression("([^a-zA-Z0-9]|[-])")); + const thread_local QRegularExpression rx("([^a-zA-Z0-9]|[-])"); + QString uniqueState = QUuid::createUuid().toString().remove(rx); #else QString uniqueState = QUuid::createUuid().toString().remove(QRegExp("([^a-zA-Z0-9]|[-])")); #endif @@ -618,7 +619,7 @@ void O2::onDeviceAuthReplyFinished() log( QStringLiteral("O2::onDeviceAuthReplyFinished: Tokens returned:\n") ); foreach (QString key, params.keys()) { // SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first - log( QStringLiteral("%1: %2...").arg( key ).arg( params.value( key ).toString().left( 3 ) ) ); + log( QStringLiteral("%1: %2...").arg( key, params.value( key ).toString().left( 3 ) ) ); } // Check for mandatory parameters From bbda9e4fa7b281652dee832927fa5f7522114507 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:40:06 +1000 Subject: [PATCH 06/17] Some old style connect fixes --- examples/facebookdemo/fbdemo.cpp | 12 +-- examples/facebookdemo/main.cpp | 6 +- examples/msgraphdemo/main.cpp | 16 ++-- examples/msgraphdemo/msgraphdemo.cpp | 10 +-- .../msgraphexternalinterceptordemo/main.cpp | 16 ++-- .../msgraphdemo.cpp | 20 +++-- .../webenginepage.cpp | 17 +++- .../webwindow.cpp | 2 +- examples/twitterdemo/main.cpp | 6 +- examples/twitterdemo/tweeter.cpp | 22 ++--- examples/vimeodemo/main.cpp | 10 +-- examples/vimeodemo/vimeodemo.cpp | 10 +-- examples/youtubedemo/main.cpp | 10 +-- examples/youtubedemo/ytdemo.cpp | 10 +-- src/o0keychainstore.cpp | 2 +- src/o1.cpp | 4 +- src/o1timedreply.cpp | 4 +- src/o2.cpp | 28 +++++-- src/o2pollserver.cpp | 6 +- src/o2reply.cpp | 2 +- src/o2replyserver.cpp | 6 +- src/o2requestor.cpp | 80 ++++++++++++++----- src/o2skydrive.cpp | 6 +- src/oxtwitter.cpp | 2 +- 24 files changed, 197 insertions(+), 110 deletions(-) diff --git a/examples/facebookdemo/fbdemo.cpp b/examples/facebookdemo/fbdemo.cpp index b41ab14..9cf26c9 100644 --- a/examples/facebookdemo/fbdemo.cpp +++ b/examples/facebookdemo/fbdemo.cpp @@ -34,11 +34,11 @@ FBDemo::FBDemo(QObject *parent) : store->setGroupKey("facebook"); o2Facebook_->setStore(store); - connect(o2Facebook_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o2Facebook_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o2Facebook_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o2Facebook_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o2Facebook_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o2Facebook_, &O2Facebook::linkedChanged, this, &FBDemo::onLinkedChanged); + connect(o2Facebook_, &O2Facebook::linkingFailed, this, &FBDemo::linkingFailed); + connect(o2Facebook_, &O2Facebook::linkingSucceeded, this, &FBDemo::onLinkingSucceeded); + connect(o2Facebook_, &O2Facebook::openBrowser, this, &FBDemo::onOpenBrowser); + connect(o2Facebook_, &O2Facebook::closeBrowser, this, &FBDemo::onCloseBrowser); } void FBDemo::doOAuth(O2::GrantFlow grantFlowType) { @@ -60,7 +60,7 @@ void FBDemo::validateToken() { QNetworkRequest request = QNetworkRequest(QUrl(debugUrlStr)); QNetworkAccessManager *mgr = new QNetworkAccessManager(this); QNetworkReply *reply = mgr->get(request); - connect(reply, SIGNAL(finished()), this, SLOT(onFinished())); + connect(reply, &QNetworkReply::finished, this, &FBDemo::onFinished); qDebug() << "Validating user token. Please wait..."; } diff --git a/examples/facebookdemo/main.cpp b/examples/facebookdemo/main.cpp index c8d3dfb..7aa9f12 100644 --- a/examples/facebookdemo/main.cpp +++ b/examples/facebookdemo/main.cpp @@ -28,8 +28,8 @@ public slots: QByteArray help = QString(USAGE).arg(OPT_OAUTH_CODE, OPT_VALIDATE_TOKEN).toLatin1(); const char* helpText = help.constData(); - connect(&fbdemo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&fbdemo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); + connect(&fbdemo_, &FBDemo::linkingFailed, this, &Helper::onLinkingFailed); + connect(&fbdemo_, &FBDemo::linkingSucceeded, this, &Helper::onLinkingSucceeded); if (argList.contains(OPT_OAUTH_CODE)) { // Start OAuth fbdemo_.doOAuth(O2::GrantFlowAuthorizationCode); @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationDomain("mysoft.com"); QCoreApplication::setApplicationName("facebookdemo"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(processArgs())); + QTimer::singleShot(0, &helper, &Helper::processArgs); return a.exec(); } diff --git a/examples/msgraphdemo/main.cpp b/examples/msgraphdemo/main.cpp index ec486b4..6c449fb 100644 --- a/examples/msgraphdemo/main.cpp +++ b/examples/msgraphdemo/main.cpp @@ -16,10 +16,16 @@ class Helper : public QObject { public slots: void run() { - connect(&demo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&demo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(&demo_, SIGNAL(userPrincipalNameReceived()), this, SLOT(onUserPrincipalNameReceived())); - connect(&demo_, SIGNAL(userPrincipalNameFailed()), this, SLOT(onUserPrincipalNameFailed())); + connect(&demo_, &MsgraphDemo::linkingFailed, this, &Helper::onLinkingFailed); + connect(&demo_, &MsgraphDemo::linkingSucceeded, this, &Helper::onLinkingSucceeded); + connect(&demo_, + &MsgraphDemo::userPrincipalNameReceived, + this, + &Helper::onUserPrincipalNameReceived); + connect(&demo_, + &MsgraphDemo::userPrincipalNameFailed, + this, + &Helper::onUserPrincipalNameFailed); demo_.doOAuth(O2::GrantFlowAuthorizationCode); } @@ -53,7 +59,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("O2"); QCoreApplication::setApplicationName("Msgraph Example"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(run())); + QTimer::singleShot(0, &helper, &Helper::run); return a.exec(); } diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp index 58d78ca..5527696 100644 --- a/examples/msgraphdemo/msgraphdemo.cpp +++ b/examples/msgraphdemo/msgraphdemo.cpp @@ -35,11 +35,11 @@ MsgraphDemo::MsgraphDemo(QObject *parent) : store->setGroupKey("msgraph"); o2Msgraph_->setStore(store); - connect(o2Msgraph_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o2Msgraph_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o2Msgraph_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o2Msgraph_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o2Msgraph_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o2Msgraph_, &O0BaseAuth::linkedChanged, this, &MsgraphDemo::onLinkedChanged); + connect(o2Msgraph_, &O0BaseAuth::linkingFailed, this, &MsgraphDemo::linkingFailed); + connect(o2Msgraph_, &O0BaseAuth::linkingSucceeded, this, &MsgraphDemo::onLinkingSucceeded); + connect(o2Msgraph_, &O0BaseAuth::openBrowser, this, &MsgraphDemo::onOpenBrowser); + connect(o2Msgraph_, &O0BaseAuth::closeBrowser, this, &MsgraphDemo::onCloseBrowser); } void MsgraphDemo::doOAuth(O2::GrantFlow grantFlowType) { diff --git a/examples/msgraphexternalinterceptordemo/main.cpp b/examples/msgraphexternalinterceptordemo/main.cpp index c2101ac..1a93cc5 100644 --- a/examples/msgraphexternalinterceptordemo/main.cpp +++ b/examples/msgraphexternalinterceptordemo/main.cpp @@ -13,10 +13,16 @@ class Helper : public QObject { public slots: void run() { - connect(&demo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&demo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(&demo_, SIGNAL(userPrincipalNameReceived()), this, SLOT(onUserPrincipalNameReceived())); - connect(&demo_, SIGNAL(userPrincipalNameFailed()), this, SLOT(onUserPrincipalNameFailed())); + connect(&demo_, &MsgraphDemo::linkingFailed, this, &Helper::onLinkingFailed); + connect(&demo_, &MsgraphDemo::linkingSucceeded, this, &Helper::onLinkingSucceeded); + connect(&demo_, + &MsgraphDemo::userPrincipalNameReceived, + this, + &Helper::onUserPrincipalNameReceived); + connect(&demo_, + &MsgraphDemo::userPrincipalNameFailed, + this, + &Helper::onUserPrincipalNameFailed); // Start OAuth demo_.doOAuth(O2::GrantFlowAuthorizationCode); @@ -51,7 +57,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("O2"); QCoreApplication::setApplicationName("Msgraph Example"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(run())); + QTimer::singleShot(0, &helper, &Helper::run); return a.exec(); } diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index ac20d5c..580c846 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -34,11 +34,11 @@ MsgraphDemo::MsgraphDemo(QObject *parent) : store->setGroupKey("msgraph"); o2Msgraph_->setStore(store); - connect(o2Msgraph_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o2Msgraph_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o2Msgraph_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o2Msgraph_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o2Msgraph_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o2Msgraph_, &O0BaseAuth::linkedChanged, this, &MsgraphDemo::onLinkedChanged); + connect(o2Msgraph_, &O0BaseAuth::linkingFailed, this, &MsgraphDemo::linkingFailed); + connect(o2Msgraph_, &O0BaseAuth::linkingSucceeded, this, &MsgraphDemo::onLinkingSucceeded); + connect(o2Msgraph_, &O0BaseAuth::openBrowser, this, &MsgraphDemo::onOpenBrowser); + connect(o2Msgraph_, &O0BaseAuth::closeBrowser, this, &MsgraphDemo::onCloseBrowser); } void MsgraphDemo::doOAuth(O2::GrantFlow grantFlowType) { @@ -71,8 +71,14 @@ void MsgraphDemo::getUserPrincipalName() { void MsgraphDemo::onOpenBrowser(const QUrl &url) { if (authDialog == Q_NULLPTR) { authDialog = new WebWindow(QSize(650, 600), url, MSGRAPH_REDIRECT_URI, false); - QObject::connect(authDialog, SIGNAL(callbackCalled(const QString &)), this, SLOT(onAuthWindowCallbackCalled(const QString &))); - QObject::connect(authDialog, SIGNAL(windowClosed()), this, SLOT(onAuthWindowClosed())); + QObject::connect(authDialog, + &WebWindow::callbackCalled, + this, + &MsgraphDemo::onAuthWindowCallbackCalled); + QObject::connect(authDialog, + &WebWindow::windowClosed, + this, + &MsgraphDemo::onAuthWindowClosed); authDialog->exec(); } } diff --git a/examples/msgraphexternalinterceptordemo/webenginepage.cpp b/examples/msgraphexternalinterceptordemo/webenginepage.cpp index bf3de7c..c5a3da9 100644 --- a/examples/msgraphexternalinterceptordemo/webenginepage.cpp +++ b/examples/msgraphexternalinterceptordemo/webenginepage.cpp @@ -37,10 +37,19 @@ QWebEnginePage *WebEnginePage::createWindow(WebWindowType type) case QWebEnginePage::WebDialog: { WebWindow *webViewDialog = new WebWindow(QSize(600, 500), QUrl(), mRedirectURLString, false); - QObject::connect(webViewDialog, SIGNAL(callbackCalled(const QString &)), this, SLOT(onAuthWindowCallbackCalled(const QString &))); - QObject::connect(webViewDialog, SIGNAL(windowClosed()), this, SLOT(onCreatedWindowClosed())); - QObject::connect(webViewDialog->GetWebEnginePage(), SIGNAL(windowCloseRequested()), this, SLOT(onWindowCloseRequested())); - mCreatedWindows.push_back(webViewDialog); + QObject::connect(webViewDialog, + &WebWindow::callbackCalled, + this, + &WebEnginePage::onAuthWindowCallbackCalled); + QObject::connect(webViewDialog, + &WebWindow::windowClosed, + this, + &WebEnginePage::onCreatedWindowClosed); + QObject::connect(webViewDialog->GetWebEnginePage(), + &QWebEnginePage::windowCloseRequested, + this, + &WebEnginePage::onWindowCloseRequested); + mCreatedWindows.push_back(webViewDialog); webViewDialog->open(); return webViewDialog->GetWebEnginePage(); } diff --git a/examples/msgraphexternalinterceptordemo/webwindow.cpp b/examples/msgraphexternalinterceptordemo/webwindow.cpp index bc5f850..732edd7 100644 --- a/examples/msgraphexternalinterceptordemo/webwindow.cpp +++ b/examples/msgraphexternalinterceptordemo/webwindow.cpp @@ -65,7 +65,7 @@ void WebWindow::closeEvent(QCloseEvent *) void WebWindow::onCallbackCatched(const QString &inURLString) { mCatchedOAuthURL = inURLString; - QTimer::singleShot(100, this, SLOT(onCallbackCatchedSafe())); + QTimer::singleShot(100, this, &WebWindow::onCallbackCatchedSafe); } void WebWindow::onCallbackCatchedSafe() diff --git a/examples/twitterdemo/main.cpp b/examples/twitterdemo/main.cpp index 3c80cc6..5bd0d8d 100644 --- a/examples/twitterdemo/main.cpp +++ b/examples/twitterdemo/main.cpp @@ -38,8 +38,8 @@ public slots: OPT_PASSWORD, OPT_STATUS).toLatin1(); const char *helpText = help.constData(); - connect(&tweeter_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&tweeter_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); + connect(&tweeter_, &Tweeter::linkingFailed, this, &Helper::onLinkingFailed); + connect(&tweeter_, &Tweeter::linkingSucceeded, this, &Helper::onLinkingSucceeded); if (argList.contains(OPT_OAUTH)) { if (argList.contains(OPT_STATUS)) { @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationDomain("mysoft.com"); QCoreApplication::setApplicationName("tweeter"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(processArgs())); + QTimer::singleShot(0, &helper, &Helper::processArgs); return a.exec(); } diff --git a/examples/twitterdemo/tweeter.cpp b/examples/twitterdemo/tweeter.cpp index 4212e11..dc8de46 100644 --- a/examples/twitterdemo/tweeter.cpp +++ b/examples/twitterdemo/tweeter.cpp @@ -29,11 +29,11 @@ void Tweeter::doOAuth() { o1Twitter_->setStore(store); // Connect signals - connect(o1Twitter_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o1Twitter_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o1Twitter_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o1Twitter_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o1Twitter_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o1Twitter_, &O0BaseAuth::linkedChanged, this, &Tweeter::onLinkedChanged); + connect(o1Twitter_, &O0BaseAuth::linkingFailed, this, &Tweeter::linkingFailed); + connect(o1Twitter_, &O0BaseAuth::linkingSucceeded, this, &Tweeter::onLinkingSucceeded); + connect(o1Twitter_, &O0BaseAuth::openBrowser, this, &Tweeter::onOpenBrowser); + connect(o1Twitter_, &O0BaseAuth::closeBrowser, this, &Tweeter::onCloseBrowser); qDebug() << "Starting OAuth..."; o1Twitter_->unlink(); // For the sake of this demo @@ -54,11 +54,11 @@ void Tweeter::doXAuth(const QString &username, const QString &password) { store->setGroupKey("twitter"); oxTwitter_->setStore(store); - connect(oxTwitter_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(oxTwitter_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(oxTwitter_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(oxTwitter_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(oxTwitter_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(oxTwitter_, &O0BaseAuth::linkedChanged, this, &Tweeter::onLinkedChanged); + connect(oxTwitter_, &O0BaseAuth::linkingFailed, this, &Tweeter::linkingFailed); + connect(oxTwitter_, &O0BaseAuth::linkingSucceeded, this, &Tweeter::onLinkingSucceeded); + connect(oxTwitter_, &O0BaseAuth::openBrowser, this, &Tweeter::onOpenBrowser); + connect(oxTwitter_, &O0BaseAuth::closeBrowser, this, &Tweeter::onCloseBrowser); qDebug() << "Starting XAuth..."; qDebug() << "Username:" << username << "Password:" << password; @@ -92,7 +92,7 @@ void Tweeter::postStatusUpdate(const QString &message) { request.setHeader(QNetworkRequest::ContentTypeHeader, O2_MIME_TYPE_XFORM); QNetworkReply *reply = requestor->post(request, reqParams, postData); - connect(reply, SIGNAL(finished()), this, SLOT(tweetReplyDone())); + connect(reply, &QNetworkReply::finished, this, &Tweeter::tweetReplyDone); } void Tweeter::onOpenBrowser(const QUrl &url) { diff --git a/examples/vimeodemo/main.cpp b/examples/vimeodemo/main.cpp index 15bbf89..e341ed7 100644 --- a/examples/vimeodemo/main.cpp +++ b/examples/vimeodemo/main.cpp @@ -18,10 +18,10 @@ class Helper : public QObject { public slots: void run() { - connect(&demo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&demo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(&demo_, SIGNAL(userNameReceived()), this, SLOT(onUserNameReceived())); - connect(&demo_, SIGNAL(userNameFailed()), this, SLOT(onUserNameFailed())); + connect(&demo_, &VimeoDemo::linkingFailed, this, &Helper::onLinkingFailed); + connect(&demo_, &VimeoDemo::linkingSucceeded, this, &Helper::onLinkingSucceeded); + connect(&demo_, &VimeoDemo::userNameReceived, this, &Helper::onUserNameReceived); + connect(&demo_, &VimeoDemo::userNameFailed, this, &Helper::onUserNameFailed); demo_.doOAuth(O2::GrantFlowAuthorizationCode); } @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("O2"); QCoreApplication::setApplicationName("Vimeo Test"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(run())); + QTimer::singleShot(0, &helper, &Helper::run); return a.exec(); } diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp index f5939bb..f861f64 100644 --- a/examples/vimeodemo/vimeodemo.cpp +++ b/examples/vimeodemo/vimeodemo.cpp @@ -35,11 +35,11 @@ VimeoDemo::VimeoDemo(QObject *parent) : store->setGroupKey("google"); o2Vimeo_->setStore(store); - connect(o2Vimeo_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o2Vimeo_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o2Vimeo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o2Vimeo_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o2Vimeo_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o2Vimeo_, &O0BaseAuth::linkedChanged, this, &VimeoDemo::onLinkedChanged); + connect(o2Vimeo_, &O0BaseAuth::linkingFailed, this, &VimeoDemo::linkingFailed); + connect(o2Vimeo_, &O0BaseAuth::linkingSucceeded, this, &VimeoDemo::onLinkingSucceeded); + connect(o2Vimeo_, &O0BaseAuth::openBrowser, this, &VimeoDemo::onOpenBrowser); + connect(o2Vimeo_, &O0BaseAuth::closeBrowser, this, &VimeoDemo::onCloseBrowser); } void VimeoDemo::doOAuth(O2::GrantFlow grantFlowType) { diff --git a/examples/youtubedemo/main.cpp b/examples/youtubedemo/main.cpp index 150f3d7..e749134 100644 --- a/examples/youtubedemo/main.cpp +++ b/examples/youtubedemo/main.cpp @@ -15,10 +15,10 @@ class Helper : public QObject { public slots: void run() { - connect(&ytdemo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); - connect(&ytdemo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(&ytdemo_, SIGNAL(channelInfoReceived()), this, SLOT(onChannelInfoReceived())); - connect(&ytdemo_, SIGNAL(channelInfoFailed()), this, SLOT(onChannelInfoFailed())); + connect(&ytdemo_, &YTDemo::linkingFailed, this, &Helper::onLinkingFailed); + connect(&ytdemo_, &YTDemo::linkingSucceeded, this, &Helper::onLinkingSucceeded); + connect(&ytdemo_, &YTDemo::channelInfoReceived, this, &Helper::onChannelInfoReceived); + connect(&ytdemo_, &YTDemo::channelInfoFailed, this, &Helper::onChannelInfoFailed); ytdemo_.doOAuth(O2::GrantFlowAuthorizationCode); } @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("O2"); QCoreApplication::setApplicationName("YouTube Test"); Helper helper; - QTimer::singleShot(0, &helper, SLOT(run())); + QTimer::singleShot(0, &helper, &Helper::run); return a.exec(); } diff --git a/examples/youtubedemo/ytdemo.cpp b/examples/youtubedemo/ytdemo.cpp index 4970c0c..e7d3418 100644 --- a/examples/youtubedemo/ytdemo.cpp +++ b/examples/youtubedemo/ytdemo.cpp @@ -34,11 +34,11 @@ YTDemo::YTDemo(QObject *parent) : store->setGroupKey("google"); o2Google_->setStore(store); - connect(o2Google_, SIGNAL(linkedChanged()), this, SLOT(onLinkedChanged())); - connect(o2Google_, SIGNAL(linkingFailed()), this, SIGNAL(linkingFailed())); - connect(o2Google_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); - connect(o2Google_, SIGNAL(openBrowser(QUrl)), this, SLOT(onOpenBrowser(QUrl))); - connect(o2Google_, SIGNAL(closeBrowser()), this, SLOT(onCloseBrowser())); + connect(o2Google_, &O0BaseAuth::linkedChanged, this, &YTDemo::onLinkedChanged); + connect(o2Google_, &O0BaseAuth::linkingFailed, this, &YTDemo::linkingFailed); + connect(o2Google_, &O0BaseAuth::linkingSucceeded, this, &YTDemo::onLinkingSucceeded); + connect(o2Google_, &O0BaseAuth::openBrowser, this, &YTDemo::onOpenBrowser); + connect(o2Google_, &O0BaseAuth::closeBrowser, this, &YTDemo::onCloseBrowser); } void YTDemo::doOAuth(O2::GrantFlow grantFlowType) { diff --git a/src/o0keychainstore.cpp b/src/o0keychainstore.cpp index 502f6f1..ccf21a7 100644 --- a/src/o0keychainstore.cpp +++ b/src/o0keychainstore.cpp @@ -70,7 +70,7 @@ void o0keyChainStore::initJob(QKeychain::Job &job) const { int o0keyChainStore::executeJob(QKeychain::Job &job, const char *actionName) const { QEventLoop loop; - job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) ); + job.connect(&job, &Job::finished, &loop, &QEventLoop::quit); job.start(); loop.exec(); diff --git a/src/o1.cpp b/src/o1.cpp index 7923065..c983de1 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -292,7 +292,7 @@ void O1::link() { #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenRequestError(QNetworkReply::NetworkError))); #endif - connect(reply, SIGNAL(finished()), this, SLOT(onTokenRequestFinished())); + connect(reply, &QNetworkReply::finished, this, &O1::onTokenRequestFinished); } void O1::onTokenRequestError(QNetworkReply::NetworkError error) { @@ -382,7 +382,7 @@ void O1::exchangeToken() { #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #endif - connect(reply, SIGNAL(finished()), this, SLOT(onTokenExchangeFinished())); + connect(reply, &QNetworkReply::finished, this, &O1::onTokenExchangeFinished); } void O1::onTokenExchangeError(QNetworkReply::NetworkError error) { diff --git a/src/o1timedreply.cpp b/src/o1timedreply.cpp index 14897f5..3389556 100644 --- a/src/o1timedreply.cpp +++ b/src/o1timedreply.cpp @@ -6,8 +6,8 @@ O1TimedReply::O1TimedReply(QNetworkReply *parent, int pTimeout): QTimer(parent) { setSingleShot(true); setInterval(pTimeout); - connect(this, SIGNAL(timeout()), this, SLOT(onTimeout())); - connect(parent, SIGNAL(finished()), this, SLOT(onFinished())); + connect(this, &QTimer::timeout, this, &O1TimedReply::onTimeout); + connect(parent, &QNetworkReply::finished, this, &O1TimedReply::onFinished); } void O1TimedReply::onFinished() { diff --git a/src/o2.cpp b/src/o2.cpp index 120a88a..4069742 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -174,7 +174,7 @@ void O2::link() { if(replyServer() == nullptr) { O2ReplyServer * replyServer = new O2ReplyServer(this); connect(replyServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); - connect(replyServer, SIGNAL(serverClosed(bool)), this, SLOT(serverHasClosed(bool))); + connect(replyServer, &O2ReplyServer::serverClosed, this, &O2::serverHasClosed); setReplyServer(replyServer); } } @@ -262,7 +262,11 @@ void O2::link() { tokenRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *tokenReply = getManager()->post(tokenRequest, payload); - connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); + connect(tokenReply, + &QNetworkReply::finished, + this, + &O2::onTokenReplyFinished, + Qt::QueuedConnection); #if QT_VERSION < 0x051500 connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else @@ -280,7 +284,11 @@ void O2::link() { deviceRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *tokenReply = getManager()->post(deviceRequest, payload); - connect(tokenReply, SIGNAL(finished()), this, SLOT(onDeviceAuthReplyFinished()), Qt::QueuedConnection); + connect(tokenReply, + &QNetworkReply::finished, + this, + &O2::onDeviceAuthReplyFinished, + Qt::QueuedConnection); #if QT_VERSION < 0x051500 connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else @@ -332,7 +340,11 @@ void O2::onVerificationReceived(const QMap response) { QNetworkReply *tokenReply = getManager()->post(tokenRequest, data); timedReplies_.add(tokenReply); - connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); + connect(tokenReply, + &QNetworkReply::finished, + this, + &O2::onTokenReplyFinished, + Qt::QueuedConnection); #if QT_VERSION < 0x051500 connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else @@ -504,7 +516,7 @@ void O2::startPollServer(const QVariantMap ¶ms) pollServer->setInterval(interval); } connect(pollServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); - connect(pollServer, SIGNAL(serverClosed(bool)), this, SLOT(serverHasClosed(bool))); + connect(pollServer, &O2PollServer::serverClosed, this, &O2::serverHasClosed); setPollServer(pollServer); pollServer->startPolling(); } @@ -545,7 +557,11 @@ void O2::refresh() { QByteArray data = buildRequestBody(parameters); QNetworkReply *refreshReply = getManager()->post(refreshRequest, data); timedReplies_.add(refreshReply); - connect(refreshReply, SIGNAL(finished()), this, SLOT(onRefreshFinished()), Qt::QueuedConnection); + connect(refreshReply, + &QNetworkReply::finished, + this, + &O2::onRefreshFinished, + Qt::QueuedConnection); #if QT_VERSION < 0x051500 connect(refreshReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRefreshError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else diff --git a/src/o2pollserver.cpp b/src/o2pollserver.cpp index a07ac9e..ea0dabc 100644 --- a/src/o2pollserver.cpp +++ b/src/o2pollserver.cpp @@ -26,13 +26,13 @@ O2PollServer::O2PollServer(QNetworkAccessManager *manager, const QNetworkRequest expirationTimer.setTimerType(Qt::VeryCoarseTimer); expirationTimer.setInterval(expiresIn * 1000); expirationTimer.setSingleShot(true); - connect(&expirationTimer, SIGNAL(timeout()), this, SLOT(onExpiration())); + connect(&expirationTimer, &QTimer::timeout, this, &O2PollServer::onExpiration); expirationTimer.start(); pollTimer.setTimerType(Qt::VeryCoarseTimer); pollTimer.setInterval(5 * 1000); pollTimer.setSingleShot(true); - connect(&pollTimer, SIGNAL(timeout()), this, SLOT(onPollTimeout())); + connect(&pollTimer, &QTimer::timeout, this, &O2PollServer::onPollTimeout); } int O2PollServer::interval() const @@ -56,7 +56,7 @@ void O2PollServer::onPollTimeout() { O0BaseAuth::log( QStringLiteral( "O2PollServer::onPollTimeout: retrying" ) ); QNetworkReply * reply = manager_->post(request_, payload_); - connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished())); + connect(reply, &QNetworkReply::finished, this, &O2PollServer::onReplyFinished); } void O2PollServer::onExpiration() diff --git a/src/o2reply.cpp b/src/o2reply.cpp index a1cda3a..9636502 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -10,7 +10,7 @@ O2Reply::O2Reply(QNetworkReply *reply, int timeOut, QObject *parent): QTimer(par #else connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(this, SIGNAL(timeout()), this, SLOT(onTimeOut()), Qt::QueuedConnection); + connect(this, &QTimer::timeout, this, &O2Reply::onTimeOut, Qt::QueuedConnection); start(timeOut); } diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 3f83fda..08b3801 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -17,15 +17,15 @@ O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent) { O0BaseAuth::log( QStringLiteral( "O2ReplyServer: Starting" ) ); - connect(this, SIGNAL(newConnection()), this, SLOT(onIncomingConnection())); + connect(this, &QTcpServer::newConnection, this, &O2ReplyServer::onIncomingConnection); replyContent_ = ""; } void O2ReplyServer::onIncomingConnection() { O0BaseAuth::log( QStringLiteral( "O2ReplyServer::onIncomingConnection: Receiving..." ) ); QTcpSocket *socket = nextPendingConnection(); - connect(socket, SIGNAL(readyRead()), this, SLOT(onBytesReady()), Qt::UniqueConnection); - connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater())); + connect(socket, &QIODevice::readyRead, this, &O2ReplyServer::onBytesReady, Qt::UniqueConnection); + connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); // Wait for a bit *after* first response, then close server if no useable data has arrived // Helps with implicit flow, where a URL fragment may need processed by local user-agent and diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index fda7423..f688be4 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -17,7 +17,11 @@ O2Requestor::O2Requestor(QNetworkAccessManager *manager, O2 *authenticator, QObj timedReplies_.setIgnoreSslErrors(authenticator->ignoreSslErrors()); } qRegisterMetaType("QNetworkReply::NetworkError"); - connect(authenticator, SIGNAL(refreshFinished(QNetworkReply::NetworkError)), this, SLOT(onRefreshFinished(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(authenticator, + &O2::refreshFinished, + this, + &O2Requestor::onRefreshFinished, + Qt::QueuedConnection); } O2Requestor::~O2Requestor() = default; @@ -42,7 +46,11 @@ int O2Requestor::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) { #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); return id_; } @@ -59,8 +67,12 @@ int O2Requestor::post(const QNetworkRequest &req, const QByteArray &data, int ti #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); return id_; } @@ -79,8 +91,12 @@ int O2Requestor::post(const QNetworkRequest & req, QHttpMultiPart* data, int tim #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); return id_; } @@ -97,8 +113,12 @@ int O2Requestor::put(const QNetworkRequest &req, const QByteArray &data, int tim #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); return id_; } @@ -117,8 +137,12 @@ int O2Requestor::put(const QNetworkRequest & req, QHttpMultiPart* data, int time #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); return id_; } @@ -135,7 +159,11 @@ int O2Requestor::deleteResource(const QNetworkRequest & req, int timeout/* = 60* #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); return id_; } @@ -157,8 +185,12 @@ int O2Requestor::customRequest(const QNetworkRequest &req, const QByteArray &ver #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); return id_; } @@ -174,7 +206,11 @@ int O2Requestor::head(const QNetworkRequest &req, int timeout/* = 60*1000*/) #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); return id_; } @@ -184,10 +220,10 @@ void O2Requestor::onRefreshFinished(QNetworkReply::NetworkError error) { return; } if (QNetworkReply::NoError == error) { - QTimer::singleShot(100, this, SLOT(retry())); + QTimer::singleShot(100, this, &O2Requestor::retry); } else { error_ = error; - QTimer::singleShot(10, this, SLOT(finish())); + QTimer::singleShot(10, this, &O2Requestor::finish); } } @@ -199,7 +235,7 @@ void O2Requestor::onRequestFinished() { return; } if (reply_->error() == QNetworkReply::NoError) { - QTimer::singleShot(10, this, SLOT(finish())); + QTimer::singleShot(10, this, &O2Requestor::finish); } } @@ -221,7 +257,7 @@ void O2Requestor::onRequestError(QNetworkReply::NetworkError error) { O0BaseAuth::log( QStringLiteral( "O2Requestor::onRequestError: Invoking remote refresh failed" ), O0BaseAuth::LogLevel::Critical ); } error_ = error; - QTimer::singleShot(10, this, SLOT(finish())); + QTimer::singleShot(10, this, &O2Requestor::finish); } void O2Requestor::onUploadProgress(qint64 uploaded, qint64 total) { @@ -356,6 +392,10 @@ void O2Requestor::retry() { #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #endif - connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()), Qt::QueuedConnection); - connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64))); + connect(reply_, + &QNetworkReply::finished, + this, + &O2Requestor::onRequestFinished, + Qt::QueuedConnection); + connect(reply_, &QNetworkReply::uploadProgress, this, &O2Requestor::onUploadProgress); } diff --git a/src/o2skydrive.cpp b/src/o2skydrive.cpp index b8e1f7b..2c4bd1d 100644 --- a/src/o2skydrive.cpp +++ b/src/o2skydrive.cpp @@ -84,7 +84,11 @@ void O2Skydrive::redirected(const QUrl &url) { QByteArray data = buildRequestBody(parameters); QNetworkReply *tokenReply = manager_->post(tokenRequest, data); timedReplies_.add(tokenReply); - connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); + connect(tokenReply, + &QNetworkReply::finished, + this, + &O2Skydrive::onTokenReplyFinished, + Qt::QueuedConnection); #if QT_VERSION < 0x051500 connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else diff --git a/src/oxtwitter.cpp b/src/oxtwitter.cpp index b0768b9..29c5cfa 100644 --- a/src/oxtwitter.cpp +++ b/src/oxtwitter.cpp @@ -73,5 +73,5 @@ void OXTwitter::link() { #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #endif - connect(reply, SIGNAL(finished()), this, SLOT(onTokenExchangeFinished())); + connect(reply, &QNetworkReply::finished, this, &OXTwitter::onTokenExchangeFinished); } From 084ba80d9b7dc4cf7275206d9dbff6b4dcf000f1 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 07:40:35 +1000 Subject: [PATCH 07/17] Fix broken qt version checks --- src/o0jsonresponse.cpp | 4 ++-- src/o1.cpp | 28 ++++++++++++++-------------- src/o1requestor.cpp | 2 +- src/o1smugmug.cpp | 4 ++-- src/o1smugmug.h | 6 +++--- src/o2.cpp | 16 ++++++++-------- src/o2facebook.cpp | 6 +++--- src/o2reply.cpp | 2 +- src/o2replyserver.cpp | 4 ++-- src/o2requestor.cpp | 24 ++++++++++++------------ src/o2simplecrypt.cpp | 4 ++-- src/o2skydrive.cpp | 8 ++++---- src/o2surveymonkey.cpp | 2 +- src/oxtwitter.cpp | 4 ++-- 14 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/o0jsonresponse.cpp b/src/o0jsonresponse.cpp index 6b2bcd8..8390a61 100644 --- a/src/o0jsonresponse.cpp +++ b/src/o0jsonresponse.cpp @@ -2,7 +2,7 @@ #include "o0baseauth.h" #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #include #else @@ -11,7 +11,7 @@ #endif QVariantMap parseJsonResponse(const QByteArray &data) { -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(data, &err); if (err.error != QJsonParseError::NoError) { diff --git a/src/o1.cpp b/src/o1.cpp index c983de1..c813dea 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -8,15 +8,15 @@ #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif -#if QT_VERSION >= 0x050100 +#if QT_VERSION >= QT_VERSION_CHECK(5,1,0) #include #endif -#if QT_VERSION >= 0x051500 +#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) #include #endif @@ -103,7 +103,7 @@ void O1::unlink() { Q_EMIT linkingSucceeded(); } -#if QT_VERSION < 0x050100 +#if QT_VERSION < QT_VERSION_CHECK(5,1,0) /// Calculate the HMAC variant of SHA1 hash. /// @author http://qt-project.org/wiki/HMAC-SHA1. /// @copyright Creative Commons Attribution-ShareAlike 2.5 Generic. @@ -163,7 +163,7 @@ QByteArray O1::getRequestBase(const QList &oauthParams, cons QByteArray O1::sign(const QList &oauthParams, const QList &otherParams, const QUrl &url, QNetworkAccessManager::Operation op, const QString &consumerSecret, const QString &tokenSecret) { QByteArray baseString = getRequestBase(oauthParams, otherParams, url, op); QByteArray secret = QUrl::toPercentEncoding(consumerSecret) + "&" + QUrl::toPercentEncoding(tokenSecret); -#if QT_VERSION >= 0x050100 +#if QT_VERSION >= QT_VERSION_CHECK(5,1,0) return QMessageAuthenticationCode::hash(baseString, secret, QCryptographicHash::Sha256).toBase64(); #else return hmacSha1(secret, baseString); @@ -192,7 +192,7 @@ QByteArray O1::buildAuthorizationHeader(const QList &oauthPa void O1::decorateRequest(QNetworkRequest &req, const QList &oauthParams) { req.setRawHeader(O2_HTTP_AUTHORIZATION_HEADER, buildAuthorizationHeader(oauthParams)); if (!userAgent_.isEmpty()) { -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) req.setHeader(QNetworkRequest::UserAgentHeader, userAgent_); #else req.setRawHeader("User-Agent", userAgent_); @@ -241,7 +241,7 @@ void O1::link() { } // Get any query parameters for the request -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QUrlQuery requestData; #else QUrl requestData = requestTokenUrl(); @@ -251,7 +251,7 @@ void O1::link() { requestData.addQueryItem(QString(param.name), QUrl::toPercentEncoding(QString(param.value))); // Get the request url and add parameters -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QUrl requestUrl = requestTokenUrl(); requestUrl.setQuery(requestData); // Create request @@ -266,7 +266,7 @@ void O1::link() { headers.append(O0RequestParameter(O2_OAUTH_CALLBACK, callbackUrl().arg(localPort()).toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_CONSUMER_KEY, clientId().toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_NONCE, nonce())); -#if QT_VERSION >= 0x050800 +#if QT_VERSION >= QT_VERSION_CHECK(5,8,0) headers.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentSecsSinceEpoch()).toLatin1())); #else headers.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentDateTimeUtc().toTime_t()).toLatin1())); @@ -287,7 +287,7 @@ void O1::link() { decorateRequest(request, headers); request.setHeader(QNetworkRequest::ContentTypeHeader, O2_MIME_TYPE_XFORM); QNetworkReply *reply = manager_->post(request, QByteArray()); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenRequestError(QNetworkReply::NetworkError))); #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenRequestError(QNetworkReply::NetworkError))); @@ -329,7 +329,7 @@ void O1::onTokenRequestFinished() { // Continue authorization flow in the browser QUrl url(authorizeUrl()); -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.addQueryItem(O2_OAUTH_TOKEN, requestToken_); url.addQueryItem(O2_OAUTH_CALLBACK, callbackUrl().arg(localPort()).toLatin1()); #else @@ -362,7 +362,7 @@ void O1::exchangeToken() { QList oauthParams; oauthParams.append(O0RequestParameter(O2_OAUTH_CONSUMER_KEY, clientId().toLatin1())); oauthParams.append(O0RequestParameter(O2_OAUTH_VERSION, "1.0")); -#if QT_VERSION >= 0x050800 +#if QT_VERSION >= QT_VERSION_CHECK(5,8,0) oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentSecsSinceEpoch()).toLatin1())); #else oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentDateTimeUtc().toTime_t()).toLatin1())); @@ -377,7 +377,7 @@ void O1::exchangeToken() { decorateRequest(request, oauthParams); request.setHeader(QNetworkRequest::ContentTypeHeader, O2_MIME_TYPE_XFORM); QNetworkReply *reply = manager_->post(request, QByteArray()); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); @@ -435,7 +435,7 @@ QMap O1::parseResponse(const QByteArray &response) { } QByteArray O1::nonce() { -#if QT_VERSION >= 0x050800 +#if QT_VERSION >= QT_VERSION_CHECK(5,8,0) QString u = QString::number(QDateTime::currentSecsSinceEpoch()).toLatin1(); #else QString u = QString::number(QDateTime::currentDateTimeUtc().toTime_t()).toLatin1(); diff --git a/src/o1requestor.cpp b/src/o1requestor.cpp index 3801f99..4d19252 100644 --- a/src/o1requestor.cpp +++ b/src/o1requestor.cpp @@ -45,7 +45,7 @@ QNetworkRequest O1Requestor::setup(const QNetworkRequest &request, const QListtoken().toLatin1())); oauthParams.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, authenticator_->signatureMethod().toLatin1())); oauthParams.append(O0RequestParameter(O2_OAUTH_NONCE, O1::nonce())); -#if QT_VERSION >= 0x050800 +#if QT_VERSION >= QT_VERSION_CHECK(5,8,0) oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentSecsSinceEpoch()).toLatin1())); #else oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentDateTimeUtc().toTime_t()).toLatin1())); diff --git a/src/o1smugmug.cpp b/src/o1smugmug.cpp index 3c6562b..c433090 100644 --- a/src/o1smugmug.cpp +++ b/src/o1smugmug.cpp @@ -40,7 +40,7 @@ void O1SmugMug::initAuthorizationUrl(Access access, Permissions permissions) { + "&Permissions=" + ::permissionsToString(permissions))); } -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) void O1SmugMug::AuthorizationUrlBuilder::setAccess(Access value) { query_.addQueryItem("Access", ::accessToString(value)); @@ -77,7 +77,7 @@ void O1SmugMug::initAuthorizationUrl(const AuthorizationUrlBuilder &builder) { setAuthorizeUrl(builder.url()); } -#endif // QT_VERSION >= 0x050000 +#endif // QT_VERSION >= QT_VERSION_CHECK(5,0,0) O1SmugMug::O1SmugMug(QObject *parent, QNetworkAccessManager *manager, O0AbstractStore *store) : O1(parent, manager, store) { diff --git a/src/o1smugmug.h b/src/o1smugmug.h index 5c8740b..714b8ad 100644 --- a/src/o1smugmug.h +++ b/src/o1smugmug.h @@ -4,7 +4,7 @@ #include "o0export.h" #include "o1.h" -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif @@ -44,7 +44,7 @@ class O0_EXPORT O1SmugMug: public O1 { Q_INVOKABLE void initAuthorizationUrl(Access access, Permissions permissions); -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) class AuthorizationUrlBuilder { public: void setAccess(Access value); @@ -61,7 +61,7 @@ class O0_EXPORT O1SmugMug: public O1 { }; void initAuthorizationUrl(const AuthorizationUrlBuilder &builder); -#endif // QT_VERSION >= 0x050000 +#endif // QT_VERSION >= QT_VERSION_CHECK(5,0,0) explicit O1SmugMug(QObject *parent = nullptr, QNetworkAccessManager *manager = nullptr, O0AbstractStore *store = nullptr); }; diff --git a/src/o2.cpp b/src/o2.cpp index 4069742..3f6a970 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -11,11 +11,11 @@ #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #else #include @@ -30,7 +30,7 @@ /// Add query parameters to a query static void addQueryParametersToUrl(QUrl &url, QList > parameters) { -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.setQueryItems(parameters); #else QUrlQuery query(url); @@ -194,7 +194,7 @@ void O2::link() { if (grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowImplicit) { -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) const thread_local QRegularExpression rx("([^a-zA-Z0-9]|[-])"); QString uniqueState = QUuid::createUuid().toString().remove(rx); #else @@ -267,7 +267,7 @@ void O2::link() { this, &O2::onTokenReplyFinished, Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -289,7 +289,7 @@ void O2::link() { this, &O2::onDeviceAuthReplyFinished, Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -345,7 +345,7 @@ void O2::onVerificationReceived(const QMap response) { this, &O2::onTokenReplyFinished, Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -562,7 +562,7 @@ void O2::refresh() { this, &O2::onRefreshFinished, Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(refreshReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRefreshError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(refreshReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRefreshError(QNetworkReply::NetworkError)), Qt::QueuedConnection); diff --git a/src/o2facebook.cpp b/src/o2facebook.cpp index 20778a7..9ecd98e 100644 --- a/src/o2facebook.cpp +++ b/src/o2facebook.cpp @@ -6,7 +6,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif @@ -40,7 +40,7 @@ void O2Facebook::onVerificationReceived(const QMap response) { // Exchange access code for access/refresh tokens QUrl url(tokenUrl_); -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.addQueryItem(O2_OAUTH2_CLIENT_ID, clientId_); url.addQueryItem(O2_OAUTH2_CLIENT_SECRET, clientSecret_); url.addQueryItem(O2_OAUTH2_SCOPE, scope_); @@ -60,7 +60,7 @@ void O2Facebook::onVerificationReceived(const QMap response) { QNetworkReply *tokenReply = manager_->get(tokenRequest); timedReplies_.add(tokenReply); connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); diff --git a/src/o2reply.cpp b/src/o2reply.cpp index 9636502..458016d 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -5,7 +5,7 @@ O2Reply::O2Reply(QNetworkReply *reply, int timeOut, QObject *parent): QTimer(parent), reply(reply) { setSingleShot(true); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(error(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), Qt::QueuedConnection); diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 08b3801..a873fa6 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -7,7 +7,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif @@ -95,7 +95,7 @@ QMap O2ReplyServer::parseQueryParams(QByteArray *data) { QUrl getTokenUrl(splitGetLine); QList< QPair > tokens; -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) tokens = getTokenUrl.queryItems(); #else QUrlQuery query(getTokenUrl); diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index f688be4..3313f91 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -2,7 +2,7 @@ #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif @@ -41,7 +41,7 @@ int O2Requestor::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) { reply_ = manager_->get(request_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -62,7 +62,7 @@ int O2Requestor::post(const QNetworkRequest &req, const QByteArray &data, int ti data_ = data; reply_ = manager_->post(request_, data_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -86,7 +86,7 @@ int O2Requestor::post(const QNetworkRequest & req, QHttpMultiPart* data, int tim reply_ = manager_->post(request_, multipartData_); multipartData_->setParent(reply_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -108,7 +108,7 @@ int O2Requestor::put(const QNetworkRequest &req, const QByteArray &data, int tim data_ = data; reply_ = manager_->put(request_, data_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -132,7 +132,7 @@ int O2Requestor::put(const QNetworkRequest & req, QHttpMultiPart* data, int time reply_ = manager_->put(request_, multipartData_); multipartData_->setParent(reply_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -154,7 +154,7 @@ int O2Requestor::deleteResource(const QNetworkRequest & req, int timeout/* = 60* rawData_ = false; reply_ = manager_->deleteResource(request_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -180,7 +180,7 @@ int O2Requestor::customRequest(const QNetworkRequest &req, const QByteArray &ver reply_ = manager_->sendCustomRequest(request_, verb, buffer); buffer->setParent(reply_); timedReplies_.add(new O2Reply(reply_)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -201,7 +201,7 @@ int O2Requestor::head(const QNetworkRequest &req, int timeout/* = 60*1000*/) } reply_ = manager_->head(request_); timedReplies_.add(new O2Reply(reply_, timeout)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); @@ -290,7 +290,7 @@ int O2Requestor::setup(const QNetworkRequest &request, QNetworkAccessManager::Op QUrl url = url_; if (addAccessTokenInQuery_) { -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.addQueryItem(O2_OAUTH2_ACCESS_TOKEN, authenticator_->token()); #else QUrlQuery query(url); @@ -343,7 +343,7 @@ void O2Requestor::retry() { reply_->deleteLater(); QUrl url = url_; if (addAccessTokenInQuery_) { -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.addQueryItem(O2_OAUTH2_ACCESS_TOKEN, authenticator_->token()); #else QUrlQuery query(url); @@ -387,7 +387,7 @@ void O2Requestor::retry() { break; } timedReplies_.add(reply_); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); diff --git a/src/o2simplecrypt.cpp b/src/o2simplecrypt.cpp index f0495d5..5c58881 100644 --- a/src/o2simplecrypt.cpp +++ b/src/o2simplecrypt.cpp @@ -112,7 +112,7 @@ QByteArray O0SimpleCrypt::encryptToByteArray(QByteArray plaintext) if (m_protectionMode == ProtectionChecksum) { flags |= CryptoFlagChecksum; QDataStream s(&integrityProtection, QIODevice::WriteOnly); -#if QT_VERSION >= 0x060000 +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) s << qChecksum(QByteArrayView(ba)); #else s << qChecksum(ba.constData(), ba.length()); @@ -244,7 +244,7 @@ QByteArray O0SimpleCrypt::decryptToByteArray(QByteArray cypher) s >> storedChecksum; } ba = ba.mid(2); -#if QT_VERSION >= 0x060000 +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) quint16 checksum = qChecksum(QByteArrayView(ba)); #else quint16 checksum = qChecksum(ba.constData(), ba.length()); diff --git a/src/o2skydrive.cpp b/src/o2skydrive.cpp index 2c4bd1d..7cd03a0 100644 --- a/src/o2skydrive.cpp +++ b/src/o2skydrive.cpp @@ -3,7 +3,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif @@ -41,7 +41,7 @@ void O2Skydrive::link() { // Show authentication URL with a web browser QUrl url(requestUrl_); -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) url.setQueryItems(parameters); #else QUrlQuery query(url); @@ -59,7 +59,7 @@ void O2Skydrive::redirected(const QUrl &url) { if (grantFlow_ == GrantFlowAuthorizationCode) { // Get access code QString urlCode; -#if QT_VERSION < 0x050000 +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) urlCode = url.queryItemValue(O2_OAUTH2_GRANT_TYPE_CODE); #else QUrlQuery query(url); @@ -89,7 +89,7 @@ void O2Skydrive::redirected(const QUrl &url) { this, &O2Skydrive::onTokenReplyFinished, Qt::QueuedConnection); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); diff --git a/src/o2surveymonkey.cpp b/src/o2surveymonkey.cpp index 0f1b4a2..71e52c3 100644 --- a/src/o2surveymonkey.cpp +++ b/src/o2surveymonkey.cpp @@ -2,7 +2,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #endif diff --git a/src/oxtwitter.cpp b/src/oxtwitter.cpp index 29c5cfa..55912ea 100644 --- a/src/oxtwitter.cpp +++ b/src/oxtwitter.cpp @@ -51,7 +51,7 @@ void OXTwitter::link() { oauthParams.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, O2_SIGNATURE_TYPE_HMAC_SHA1)); oauthParams.append(O0RequestParameter(O2_OAUTH_CONSUMER_KEY, clientId().toLatin1())); oauthParams.append(O0RequestParameter(O2_OAUTH_VERSION, "1.0")); -#if QT_VERSION >= 0x050800 +#if QT_VERSION >= QT_VERSION_CHECK(5,8,0) oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentSecsSinceEpoch()).toLatin1())); #else oauthParams.append(O0RequestParameter(O2_OAUTH_TIMESTAMP, QString::number(QDateTime::currentDateTimeUtc().toTime_t()).toLatin1())); @@ -68,7 +68,7 @@ void OXTwitter::link() { decorateRequest(request, oauthParams); request.setHeader(QNetworkRequest::ContentTypeHeader, O2_MIME_TYPE_XFORM); QNetworkReply *reply = manager_->post(request, createQueryParameters(xAuthParams_)); -#if QT_VERSION < 0x051500 +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #else connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); From 6a607e4b6ca03575667be542bda41ca7e0310d2f Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:10:41 +1000 Subject: [PATCH 08/17] Some old style connect fixes --- examples/msgraphdemo/msgraphdemo.cpp | 4 ++-- examples/msgraphexternalinterceptordemo/msgraphdemo.cpp | 4 ++-- examples/msgraphexternalinterceptordemo/webwindow.cpp | 5 +++-- examples/twitterdemo/main.cpp | 2 +- examples/vimeodemo/vimeodemo.cpp | 4 ++-- examples/youtubedemo/ytdemo.cpp | 6 +++--- src/o1.cpp | 8 +++++--- src/oxtwitter.cpp | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp index 5527696..fde4464 100644 --- a/examples/msgraphdemo/msgraphdemo.cpp +++ b/examples/msgraphdemo/msgraphdemo.cpp @@ -63,8 +63,8 @@ void MsgraphDemo::getUserPrincipalName() { requestor->setAddAccessTokenInQuery(false); requestor->setAccessTokenInAuthenticationHTTPHeaderFormat("Bearer %1"); requestId_ = requestor->get(request); - connect(requestor, SIGNAL(finished(int, QNetworkReply::NetworkError, QByteArray)), - this, SLOT(onFinished(int, QNetworkReply::NetworkError, QByteArray)) + connect(requestor, qOverload(&O2Requestor::finished), + this, &MsgraphDemo::onFinished ); qDebug() << "Getting user info... Please wait."; } diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index 580c846..3ee79f3 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -62,8 +62,8 @@ void MsgraphDemo::getUserPrincipalName() { requestor->setAddAccessTokenInQuery(false); requestor->setAccessTokenInAuthenticationHTTPHeaderFormat("Bearer %1"); requestId_ = requestor->get(request); - connect(requestor, SIGNAL(finished(int, QNetworkReply::NetworkError, QByteArray)), - this, SLOT(onFinished(int, QNetworkReply::NetworkError, QByteArray)) + connect(requestor, qOverload(&O2Requestor::finished), + this, &MsgraphDemo::onFinished ); qDebug() << "Getting user info... Please wait."; } diff --git a/examples/msgraphexternalinterceptordemo/webwindow.cpp b/examples/msgraphexternalinterceptordemo/webwindow.cpp index 732edd7..a4e8f13 100644 --- a/examples/msgraphexternalinterceptordemo/webwindow.cpp +++ b/examples/msgraphexternalinterceptordemo/webwindow.cpp @@ -25,8 +25,9 @@ WebWindow::WebWindow(QSize inWindowSize, QUrl inLoginURL, QString inRedirectURLS mWebEngineProfile = new QWebEngineProfile(); - mWebEnginePage = new WebEnginePage(mWebEngineProfile, inRedirectURLString); - QObject::connect(mWebEnginePage, SIGNAL(callbackCatched(const QString &)), this, SLOT(onCallbackCatched(const QString &))); + WebEnginePage* page = new WebEnginePage(mWebEngineProfile, inRedirectURLString); + QObject::connect(page, &WebEnginePage::callbackCatched, this, &WebWindow::onCallbackCatched); + mWebEnginePage = page; mWebView->setPage(mWebEnginePage); diff --git a/examples/twitterdemo/main.cpp b/examples/twitterdemo/main.cpp index 5bd0d8d..659d30f 100644 --- a/examples/twitterdemo/main.cpp +++ b/examples/twitterdemo/main.cpp @@ -89,7 +89,7 @@ public slots: private slots: void postStatusUpdate(const QString& msg) { - connect(&tweeter_, SIGNAL(statusPosted()), qApp, SLOT(quit())); + connect(&tweeter_, &Tweeter::statusPosted, qApp, &QApplication::quit); tweeter_.postStatusUpdate(msg); } diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp index f861f64..f8ccf30 100644 --- a/examples/vimeodemo/vimeodemo.cpp +++ b/examples/vimeodemo/vimeodemo.cpp @@ -61,8 +61,8 @@ void VimeoDemo::getUserName() { QNetworkAccessManager *mgr = new QNetworkAccessManager(this); O2Requestor *requestor = new O2Requestor(mgr, o2Vimeo_, this); requestId_ = requestor->get(request); - connect(requestor, SIGNAL(finished(int, QNetworkReply::NetworkError, QByteArray)), - this, SLOT(onFinished(int, QNetworkReply::NetworkError, QByteArray)) + connect(requestor, qOverload(&O2Requestor::finished), + this, &VimeoDemo::onFinished ); qDebug() << "Getting user channel info... Please wait."; } diff --git a/examples/youtubedemo/ytdemo.cpp b/examples/youtubedemo/ytdemo.cpp index e7d3418..9e5862e 100644 --- a/examples/youtubedemo/ytdemo.cpp +++ b/examples/youtubedemo/ytdemo.cpp @@ -60,9 +60,9 @@ void YTDemo::getUserChannelInfo() { QNetworkAccessManager *mgr = new QNetworkAccessManager(this); O2Requestor *requestor = new O2Requestor(mgr, o2Google_, this); requestId_ = requestor->get(request); - connect(requestor, SIGNAL(finished(int, QNetworkReply::NetworkError, QByteArray)), - this, SLOT(onFinished(int, QNetworkReply::NetworkError, QByteArray)) - ); + connect(requestor, qOverload(&O2Requestor::finished), + this, &YTDemo::onFinished + ); qDebug() << "Getting user channel info... Please wait."; } diff --git a/src/o1.cpp b/src/o1.cpp index c813dea..22c742a 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -218,7 +218,9 @@ void O1::link() { if(!useExternalWebInterceptor_) { if(replyServer() == nullptr) { O2ReplyServer * replyServer = new O2ReplyServer(this); - connect(replyServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); + connect(replyServer, &O2ReplyServer::verificationReceived, + this, &O1::onVerificationReceived + ); setReplyServer(replyServer); } } @@ -290,7 +292,7 @@ void O1::link() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenRequestError(QNetworkReply::NetworkError))); #else - connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenRequestError(QNetworkReply::NetworkError))); + connect(reply, &QNetworkReply::errorOccurred, this, &O1::onTokenRequestError); #endif connect(reply, &QNetworkReply::finished, this, &O1::onTokenRequestFinished); } @@ -380,7 +382,7 @@ void O1::exchangeToken() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #else - connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); + connect(reply, &QNetworkReply::errorOccurred, this, &O1::onTokenExchangeError); #endif connect(reply, &QNetworkReply::finished, this, &O1::onTokenExchangeFinished); } diff --git a/src/oxtwitter.cpp b/src/oxtwitter.cpp index 55912ea..f67533b 100644 --- a/src/oxtwitter.cpp +++ b/src/oxtwitter.cpp @@ -71,7 +71,7 @@ void OXTwitter::link() { #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); #else - connect(reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenExchangeError(QNetworkReply::NetworkError))); + connect(reply, &QNetworkReply::errorOccurred, this, &OXTwitter::onTokenExchangeError); #endif connect(reply, &QNetworkReply::finished, this, &OXTwitter::onTokenExchangeFinished); } From 3b57d23281c1bfdc703cdd35589a7593410a62ae Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:14:04 +1000 Subject: [PATCH 09/17] Some old style connect fixes --- src/o2.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/o2.cpp b/src/o2.cpp index 3f6a970..25ee100 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -173,7 +173,7 @@ void O2::link() { if(!useExternalWebInterceptor_) { if(replyServer() == nullptr) { O2ReplyServer * replyServer = new O2ReplyServer(this); - connect(replyServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); + connect(replyServer, &O2ReplyServer::verificationReceived, this, &O2::onVerificationReceived); connect(replyServer, &O2ReplyServer::serverClosed, this, &O2::serverHasClosed); setReplyServer(replyServer); } @@ -270,7 +270,7 @@ void O2::link() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(tokenReply, &QNetworkReply::errorOccurred, this, &O2::onTokenReplyError, Qt::QueuedConnection); #endif } else if (grantFlow_ == GrantFlowDevice) { @@ -292,7 +292,7 @@ void O2::link() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(tokenReply, &QNetworkReply::errorOccurred, this, &O2::onTokenReplyError, Qt::QueuedConnection); #endif } } @@ -348,7 +348,7 @@ void O2::onVerificationReceived(const QMap response) { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(tokenReply, &QNetworkReply::errorOccurred, this, &O2::onTokenReplyError, Qt::QueuedConnection); #endif } else if (grantFlow_ == GrantFlowImplicit || grantFlow_ == GrantFlowDevice) { // Check for mandatory tokens @@ -515,7 +515,7 @@ void O2::startPollServer(const QVariantMap ¶ms) if (ok) pollServer->setInterval(interval); } - connect(pollServer, SIGNAL(verificationReceived(QMap)), this, SLOT(onVerificationReceived(QMap))); + connect(pollServer, &O2PollServer::verificationReceived, this, &O2::onVerificationReceived); connect(pollServer, &O2PollServer::serverClosed, this, &O2::serverHasClosed); setPollServer(pollServer); pollServer->startPolling(); @@ -565,7 +565,7 @@ void O2::refresh() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(refreshReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRefreshError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(refreshReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRefreshError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(refreshReply, &QNetworkReply::errorOccurred, this, &O2::onRefreshError, Qt::QueuedConnection); #endif } From 0da65dee8a663b6e2df12686ff4fadd5324c36d7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:15:37 +1000 Subject: [PATCH 10/17] Some old style connect fixes --- src/o2facebook.cpp | 4 ++-- src/o2reply.cpp | 2 +- src/o2requestor.cpp | 54 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/o2facebook.cpp b/src/o2facebook.cpp index 9ecd98e..5fa5bca 100644 --- a/src/o2facebook.cpp +++ b/src/o2facebook.cpp @@ -59,11 +59,11 @@ void O2Facebook::onVerificationReceived(const QMap response) { QNetworkRequest tokenRequest(url); QNetworkReply *tokenReply = manager_->get(tokenRequest); timedReplies_.add(tokenReply); - connect(tokenReply, SIGNAL(finished()), this, SLOT(onTokenReplyFinished()), Qt::QueuedConnection); + connect(tokenReply, &QNetworkReply::finished, this, &O2Facebook::onTokenReplyFinished, Qt::QueuedConnection); #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(tokenReply, &QNetworkReply::errorOccurred, this, &O2Facebook::onTokenReplyError, Qt::QueuedConnection); #endif } diff --git a/src/o2reply.cpp b/src/o2reply.cpp index 458016d..5a301a7 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -8,7 +8,7 @@ O2Reply::O2Reply(QNetworkReply *reply, int timeOut, QObject *parent): QTimer(par #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(error(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(this, &O2Reply::error, reply, &QNetworkReply::errorOccurred, Qt::QueuedConnection); #endif connect(this, &QTimer::timeout, this, &O2Reply::onTimeOut, Qt::QueuedConnection); start(timeOut); diff --git a/src/o2requestor.cpp b/src/o2requestor.cpp index 3313f91..9fffb9b 100644 --- a/src/o2requestor.cpp +++ b/src/o2requestor.cpp @@ -44,7 +44,11 @@ int O2Requestor::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -65,7 +69,11 @@ int O2Requestor::post(const QNetworkRequest &req, const QByteArray &data, int ti #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -89,7 +97,11 @@ int O2Requestor::post(const QNetworkRequest & req, QHttpMultiPart* data, int tim #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -111,7 +123,11 @@ int O2Requestor::put(const QNetworkRequest &req, const QByteArray &data, int tim #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -135,7 +151,11 @@ int O2Requestor::put(const QNetworkRequest & req, QHttpMultiPart* data, int time #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -157,7 +177,11 @@ int O2Requestor::deleteResource(const QNetworkRequest & req, int timeout/* = 60* #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -183,7 +207,11 @@ int O2Requestor::customRequest(const QNetworkRequest &req, const QByteArray &ver #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -204,7 +232,11 @@ int O2Requestor::head(const QNetworkRequest &req, int timeout/* = 60*1000*/) #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, @@ -390,7 +422,11 @@ void O2Requestor::retry() { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(reply_, + &QNetworkReply::errorOccurred, + this, + &O2Requestor::onRequestError, + Qt::QueuedConnection); #endif connect(reply_, &QNetworkReply::finished, From 06ce8b24580b3a63bdf67225a036b162d85b4d62 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:20:10 +1000 Subject: [PATCH 11/17] Fix remaining old style connects --- src/o2replyserver.cpp | 9 +++++++-- src/o2replyserver.h | 3 ++- src/o2skydrive.cpp | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index a873fa6..abdf3c1 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -33,10 +33,10 @@ void O2ReplyServer::onIncomingConnection() { // like for favicons, etc., before such secondary callbacks are fired QTimer *timer = new QTimer(socket); timer->setObjectName("timeoutTimer"); - connect(timer, SIGNAL(timeout()), this, SLOT(closeServer())); + connect(timer, &QTimer::timeout, this, qOverload<>(&O2ReplyServer::closeServer)); timer->setSingleShot(true); timer->setInterval(timeout() * 1000); - connect(socket, SIGNAL(readyRead()), timer, SLOT(start())); + connect(socket, &QTcpSocket::readyRead, timer, qOverload<>(&QTimer::start)); } void O2ReplyServer::onBytesReady() { @@ -112,6 +112,11 @@ QMap O2ReplyServer::parseQueryParams(QByteArray *data) { return queryParams; } +void O2ReplyServer::closeServer() +{ + closeServer( nullptr ); +} + void O2ReplyServer::closeServer(QTcpSocket *socket, bool hasparameters) { if (!isListening()) { diff --git a/src/o2replyserver.h b/src/o2replyserver.h index 95681c9..e6b9c44 100644 --- a/src/o2replyserver.h +++ b/src/o2replyserver.h @@ -41,7 +41,8 @@ public Q_SLOTS: void onIncomingConnection(); void onBytesReady(); QMap parseQueryParams(QByteArray *data); - void closeServer(QTcpSocket *socket = nullptr, bool hasparameters = false); + void closeServer(); + void closeServer(QTcpSocket *socket, bool hasparameters = false); protected: QByteArray replyContent_; diff --git a/src/o2skydrive.cpp b/src/o2skydrive.cpp index 7cd03a0..e24f3ab 100644 --- a/src/o2skydrive.cpp +++ b/src/o2skydrive.cpp @@ -92,7 +92,11 @@ void O2Skydrive::redirected(const QUrl &url) { #if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(tokenReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); #else - connect(tokenReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onTokenReplyError(QNetworkReply::NetworkError)), Qt::QueuedConnection); + connect(tokenReply, + &QNetworkReply::errorOccurred, + this, + &O2Skydrive::onTokenReplyError, + Qt::QueuedConnection); #endif } else { // Get access token From 198b05f66175b73cb88948032d3c5f4bed15c81f Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:20:19 +1000 Subject: [PATCH 12/17] Emit is not a function --- examples/msgraphexternalinterceptordemo/webwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/msgraphexternalinterceptordemo/webwindow.cpp b/examples/msgraphexternalinterceptordemo/webwindow.cpp index a4e8f13..c24c9cd 100644 --- a/examples/msgraphexternalinterceptordemo/webwindow.cpp +++ b/examples/msgraphexternalinterceptordemo/webwindow.cpp @@ -60,7 +60,7 @@ WebWindow::~WebWindow() void WebWindow::closeEvent(QCloseEvent *) { - emit (windowClosed()); + emit windowClosed(); } void WebWindow::onCallbackCatched(const QString &inURLString) From 445d068b7df84e4fca1cd14d53202dac191c9bfe Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:21:13 +1000 Subject: [PATCH 13/17] Use Q_ENUM, not older Q_ENUMS --- src/o1smugmug.h | 4 ++-- src/o2.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/o1smugmug.h b/src/o1smugmug.h index 714b8ad..7bf5359 100644 --- a/src/o1smugmug.h +++ b/src/o1smugmug.h @@ -27,20 +27,20 @@ /// @endcode class O0_EXPORT O1SmugMug: public O1 { Q_OBJECT - Q_ENUMS(Access) - Q_ENUMS(Permissions) public: enum Access { AccessPublic, AccessFull }; + Q_ENUM(Access) enum Permissions { PermissionsRead, PermissionsAdd, PermissionsModify }; + Q_ENUM(Permissions) Q_INVOKABLE void initAuthorizationUrl(Access access, Permissions permissions); diff --git a/src/o2.h b/src/o2.h index e89d48d..8c16e8c 100644 --- a/src/o2.h +++ b/src/o2.h @@ -16,9 +16,7 @@ class O0_EXPORT O2: public O0BaseAuth { Q_OBJECT public: - Q_ENUMS(GrantFlow) -public: /// Authorization flow types. enum GrantFlow { GrantFlowAuthorizationCode, ///< @see http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.1 @@ -27,6 +25,7 @@ class O0_EXPORT O2: public O0BaseAuth GrantFlowPkce, ///< @see https://www.rfc-editor.org/rfc/rfc7636 GrantFlowDevice ///< @see https://tools.ietf.org/html/rfc8628#section-1 }; + Q_ENUM(GrantFlow) /// Authorization flow. Q_PROPERTY(GrantFlow grantFlow READ grantFlow WRITE setGrantFlow NOTIFY grantFlowChanged) From b3b933e4e211790e6e014edffa71e33746704226 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:21:43 +1000 Subject: [PATCH 14/17] Avoid detach on range based loop --- src/o2facebook.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/o2facebook.cpp b/src/o2facebook.cpp index 5fa5bca..00b2607 100644 --- a/src/o2facebook.cpp +++ b/src/o2facebook.cpp @@ -78,7 +78,8 @@ void O2Facebook::onTokenReplyFinished() { const QJsonObject rootObject = doc.object(); QVariantMap reply; - for (const QString &key : rootObject.keys()) { + const QStringList keys = rootObject.keys(); + for (const QString &key : keys) { reply.insert(key, rootObject[key].toVariant()); } From ba1ec8e5bd23d54bcebc4daebacfdc28969dc8fd Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:26:25 +1000 Subject: [PATCH 15/17] Don't use deprecated foreach, use range based loops instead --- examples/facebookdemo/fbdemo.cpp | 2 +- examples/msgraphdemo/msgraphdemo.cpp | 2 +- .../msgraphexternalinterceptordemo/msgraphdemo.cpp | 4 ++-- examples/msgraphexternalinterceptordemo/webwindow.cpp | 3 +-- examples/twitterdemo/tweeter.cpp | 2 +- examples/vimeodemo/vimeodemo.cpp | 2 +- examples/youtubedemo/ytdemo.cpp | 2 +- src/o0baseauth.cpp | 2 +- src/o1.cpp | 10 +++++----- src/o2.cpp | 10 +++++----- src/o2facebook.cpp | 2 +- src/o2reply.cpp | 4 ++-- src/o2replyserver.cpp | 3 +-- src/o2skydrive.cpp | 2 +- 14 files changed, 24 insertions(+), 26 deletions(-) diff --git a/examples/facebookdemo/fbdemo.cpp b/examples/facebookdemo/fbdemo.cpp index 9cf26c9..cd5c60c 100644 --- a/examples/facebookdemo/fbdemo.cpp +++ b/examples/facebookdemo/fbdemo.cpp @@ -84,7 +84,7 @@ void FBDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key: extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp index fde4464..12fa322 100644 --- a/examples/msgraphdemo/msgraphdemo.cpp +++ b/examples/msgraphdemo/msgraphdemo.cpp @@ -89,7 +89,7 @@ void MsgraphDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key: extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index 3ee79f3..6f4c41e 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -93,7 +93,7 @@ void MsgraphDemo::onAuthWindowCallbackCalled(const QString &inURLString) QMultiMap queryParams; QPair tokenPair; - foreach (tokenPair, tokens) { + for (const QPair& tokenPair: tokens) { // FIXME: We are decoding key and value again. This helps with Google OAuth, but is it mandated by the standard? QString key = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.first.trimmed().toLatin1())); QString value = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.second.trimmed().toLatin1())); @@ -129,7 +129,7 @@ void MsgraphDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key : extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/examples/msgraphexternalinterceptordemo/webwindow.cpp b/examples/msgraphexternalinterceptordemo/webwindow.cpp index c24c9cd..629ad1f 100644 --- a/examples/msgraphexternalinterceptordemo/webwindow.cpp +++ b/examples/msgraphexternalinterceptordemo/webwindow.cpp @@ -78,8 +78,7 @@ void WebWindow::onCallbackCatchedSafe() QList< QPair > tokens = query.queryItems(); QMultiMap queryParams; - QPair tokenPair; - foreach (tokenPair, tokens) { + for (const QPair& tokenPair: tokens) { QString key = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.first.trimmed().toLatin1())); QString value = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.second.trimmed().toLatin1())); queryParams.insert(key, value); diff --git a/examples/twitterdemo/tweeter.cpp b/examples/twitterdemo/tweeter.cpp index dc8de46..65c8392 100644 --- a/examples/twitterdemo/tweeter.cpp +++ b/examples/twitterdemo/tweeter.cpp @@ -116,7 +116,7 @@ void Tweeter::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key: extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp index f8ccf30..abbffbb 100644 --- a/examples/vimeodemo/vimeodemo.cpp +++ b/examples/vimeodemo/vimeodemo.cpp @@ -86,7 +86,7 @@ void VimeoDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key : extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/examples/youtubedemo/ytdemo.cpp b/examples/youtubedemo/ytdemo.cpp index 9e5862e..b2706eb 100644 --- a/examples/youtubedemo/ytdemo.cpp +++ b/examples/youtubedemo/ytdemo.cpp @@ -86,7 +86,7 @@ void YTDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - foreach (QString key, extraTokens.keys()) { + for (const QString &key: extraTokens.keys()) { qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); } } diff --git a/src/o0baseauth.cpp b/src/o0baseauth.cpp index 07ea7ee..badbb06 100644 --- a/src/o0baseauth.cpp +++ b/src/o0baseauth.cpp @@ -193,7 +193,7 @@ void O0BaseAuth::log(const QString& message, LogLevel level) QByteArray O0BaseAuth::createQueryParameters(const QList ¶meters) { QByteArray ret; bool first = true; - foreach (O0RequestParameter h, parameters) { + for (const O0RequestParameter& h : parameters) { if (first) { first = false; } else { diff --git a/src/o1.cpp b/src/o1.cpp index 22c742a..4c67a8c 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -175,7 +175,7 @@ QByteArray O1::buildAuthorizationHeader(const QList &oauthPa QByteArray ret("OAuth "); QList headers(oauthParams); std::sort(headers.begin(), headers.end()); - foreach (O0RequestParameter h, headers) { + for (const O0RequestParameter &h: headers) { if (first) { first = false; } else { @@ -249,7 +249,7 @@ void O1::link() { QUrl requestData = requestTokenUrl(); #endif O0RequestParameter param("", ""); - foreach(param, requestParameters()) + for(const O0RequestParameter& param :requestParameters()) requestData.addQueryItem(QString(param.name), QUrl::toPercentEncoding(QString(param.value))); // Get the request url and add parameters @@ -277,7 +277,7 @@ void O1::link() { headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, signatureMethod().toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE, generateSignature(headers, request, requestParameters(), QNetworkAccessManager::PostOperation))); log( QStringLiteral( "O1:link: Token request headers:" ) ); - foreach(param, headers) { + for(const O0RequestParameter¶m: headers) { log( QStringLiteral( " %1=%2" ).arg( param.name, param.value ) ); } @@ -412,7 +412,7 @@ void O1::onTokenExchangeFinished() { // Set extra tokens if any if (!response.isEmpty()) { QVariantMap extraTokens; - foreach (QString key, response.keys()) { + for(const QString &key : response.keys()) { extraTokens.insert(key, response.value(key)); } setExtraTokens(extraTokens); @@ -427,7 +427,7 @@ void O1::onTokenExchangeFinished() { QMap O1::parseResponse(const QByteArray &response) { QMap ret; - foreach (QByteArray param, response.split('&')) { + for (const QByteArray ¶m: response.split('&')) { QList kv = param.split('='); if (kv.length() == 2) { ret.insert(QUrl::fromPercentEncoding(kv[0]), QUrl::fromPercentEncoding(kv[1])); diff --git a/src/o2.cpp b/src/o2.cpp index 25ee100..3fdff68 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -232,7 +232,7 @@ void O2::link() { parameters.append(qMakePair(QString(O2_OAUTH2_STATE), uniqueState)); if ( !apiKey_.isEmpty() ) parameters.append(qMakePair(QString(O2_OAUTH2_API_KEY), apiKey_)); - foreach (QString key, extraRequestParams().keys()) { + for (const QString &key: extraRequestParams().keys()) { parameters.append(qMakePair(key, extraRequestParams().value(key).toString())); } // Show authentication URL with a web browser @@ -251,7 +251,7 @@ void O2::link() { parameters.append(O0RequestParameter(O2_OAUTH2_SCOPE, scope_.toUtf8())); if ( !apiKey_.isEmpty() ) parameters.append(O0RequestParameter(O2_OAUTH2_API_KEY, apiKey_.toUtf8())); - foreach (QString key, extraRequestParams().keys()) { + for (const QString &key: extraRequestParams().keys()) { parameters.append(O0RequestParameter(key.toUtf8(), extraRequestParams().value(key).toByteArray())); } QByteArray payload = O0BaseAuth::createQueryParameters(parameters); @@ -408,7 +408,7 @@ void O2::onTokenReplyFinished() { // Dump tokens log( QStringLiteral("O2::onTokenReplyFinished: Tokens returned:\n") ); - foreach (QString key, tokens.keys()) { + for (const QString &key: tokens.keys()) { // SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first log( QStringLiteral("%1: %2...").arg( key, tokens.value( key ).toString().left( 3 ) ) ); } @@ -455,7 +455,7 @@ void O2::onTokenReplyError(QNetworkReply::NetworkError error) { QByteArray O2::buildRequestBody(const QMap ¶meters) { QByteArray body; bool first = true; - foreach (QString key, parameters.keys()) { + for (const QString &key: parameters.keys()) { if (first) { first = false; } else { @@ -633,7 +633,7 @@ void O2::onDeviceAuthReplyFinished() // Dump tokens log( QStringLiteral("O2::onDeviceAuthReplyFinished: Tokens returned:\n") ); - foreach (QString key, params.keys()) { + for (const QString &key: params.keys()) { // SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first log( QStringLiteral("%1: %2...").arg( key, params.value( key ).toString().left( 3 ) ) ); } diff --git a/src/o2facebook.cpp b/src/o2facebook.cpp index 00b2607..1305a21 100644 --- a/src/o2facebook.cpp +++ b/src/o2facebook.cpp @@ -28,7 +28,7 @@ void O2Facebook::onVerificationReceived(const QMap response) { if (response.contains("error")) { qWarning() << "O2Facebook::onVerificationReceived: Verification failed"; - foreach (QString key, response.keys()) { + for (const QString &key: response.keys()) { qWarning() << "O2Facebook::onVerificationReceived:" << key << response.value(key); } Q_EMIT linkingFailed(); diff --git a/src/o2reply.cpp b/src/o2reply.cpp index 5a301a7..ed12d0d 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -19,7 +19,7 @@ void O2Reply::onTimeOut() { } O2ReplyList::~O2ReplyList() { - foreach (O2Reply *timedReply, replies_) { + for (O2Reply *timedReply: replies_) { delete timedReply; } } @@ -43,7 +43,7 @@ void O2ReplyList::remove(QNetworkReply *reply) { } O2Reply *O2ReplyList::find(const QNetworkReply *reply) { - foreach (O2Reply *timedReply, replies_) { + for (O2Reply *timedReply: replies_) { if (timedReply->reply == reply) { return timedReply; } diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index abdf3c1..8b20394 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -102,8 +102,7 @@ QMap O2ReplyServer::parseQueryParams(QByteArray *data) { tokens = query.queryItems(); #endif QMap queryParams; - QPair tokenPair; - foreach (tokenPair, tokens) { + for (const QPair &tokenPair: tokens) { // FIXME: We are decoding key and value again. This helps with Google OAuth, but is it mandated by the standard? QString key = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.first.trimmed().toLatin1())); QString value = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.second.trimmed().toLatin1())); diff --git a/src/o2skydrive.cpp b/src/o2skydrive.cpp index e24f3ab..9ccec7b 100644 --- a/src/o2skydrive.cpp +++ b/src/o2skydrive.cpp @@ -106,7 +106,7 @@ void O2Skydrive::redirected(const QUrl &url) { QStringList parts = url.toString().split("#"); if (parts.length() > 1) { - foreach (QString item, parts[1].split("&")) { + for (const QString &item: parts[1].split("&")) { int index = item.indexOf("="); if (index == -1) { continue; From 9bf020f8e41ece51533a891f1e2d9a65d85f4e5c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 08:35:08 +1000 Subject: [PATCH 16/17] Avoid unncessary allocatons in range based loops --- examples/facebookdemo/fbdemo.cpp | 4 ++-- examples/msgraphdemo/msgraphdemo.cpp | 4 ++-- .../msgraphdemo.cpp | 4 ++-- examples/twitterdemo/tweeter.cpp | 4 ++-- examples/vimeodemo/vimeodemo.cpp | 4 ++-- examples/youtubedemo/ytdemo.cpp | 4 ++-- src/o1.cpp | 12 ++++++---- src/o2.cpp | 24 ++++++++++--------- src/o2facebook.cpp | 4 ++-- src/o2reply.cpp | 4 ++-- src/o2replyserver.cpp | 2 +- src/o2skydrive.cpp | 3 ++- 12 files changed, 39 insertions(+), 34 deletions(-) diff --git a/examples/facebookdemo/fbdemo.cpp b/examples/facebookdemo/fbdemo.cpp index cd5c60c..ab2b361 100644 --- a/examples/facebookdemo/fbdemo.cpp +++ b/examples/facebookdemo/fbdemo.cpp @@ -84,8 +84,8 @@ void FBDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key: extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp index 12fa322..8095b03 100644 --- a/examples/msgraphdemo/msgraphdemo.cpp +++ b/examples/msgraphdemo/msgraphdemo.cpp @@ -89,8 +89,8 @@ void MsgraphDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key: extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp index 6f4c41e..c0895c0 100644 --- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp @@ -129,8 +129,8 @@ void MsgraphDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key : extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/examples/twitterdemo/tweeter.cpp b/examples/twitterdemo/tweeter.cpp index 65c8392..ed2d338 100644 --- a/examples/twitterdemo/tweeter.cpp +++ b/examples/twitterdemo/tweeter.cpp @@ -116,8 +116,8 @@ void Tweeter::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key: extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp index abbffbb..49d43d0 100644 --- a/examples/vimeodemo/vimeodemo.cpp +++ b/examples/vimeodemo/vimeodemo.cpp @@ -86,8 +86,8 @@ void VimeoDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key : extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/examples/youtubedemo/ytdemo.cpp b/examples/youtubedemo/ytdemo.cpp index b2706eb..049bca5 100644 --- a/examples/youtubedemo/ytdemo.cpp +++ b/examples/youtubedemo/ytdemo.cpp @@ -86,8 +86,8 @@ void YTDemo::onLinkingSucceeded() { if (!extraTokens.isEmpty()) { emit extraTokensReady(extraTokens); qDebug() << "Extra tokens in response:"; - for (const QString &key: extraTokens.keys()) { - qDebug() << "\t" << key << ":" << (extraTokens.value(key).toString().left(3) + "..."); + for (auto it = extraTokens.constBegin(); it != extraTokens.constEnd(); ++it) { + qDebug() << "\t" << it.key() << ":" << (it.value().toString().left(3) + "..."); } } emit linkingSucceeded(); diff --git a/src/o1.cpp b/src/o1.cpp index 4c67a8c..de2c5a4 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -249,7 +249,8 @@ void O1::link() { QUrl requestData = requestTokenUrl(); #endif O0RequestParameter param("", ""); - for(const O0RequestParameter& param :requestParameters()) + const QList parameters = requestParameters(); + for(const O0RequestParameter& param :parameters) requestData.addQueryItem(QString(param.name), QUrl::toPercentEncoding(QString(param.value))); // Get the request url and add parameters @@ -277,7 +278,7 @@ void O1::link() { headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, signatureMethod().toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE, generateSignature(headers, request, requestParameters(), QNetworkAccessManager::PostOperation))); log( QStringLiteral( "O1:link: Token request headers:" ) ); - for(const O0RequestParameter¶m: headers) { + for(const O0RequestParameter¶m: qAsConst(headers)) { log( QStringLiteral( " %1=%2" ).arg( param.name, param.value ) ); } @@ -412,8 +413,8 @@ void O1::onTokenExchangeFinished() { // Set extra tokens if any if (!response.isEmpty()) { QVariantMap extraTokens; - for(const QString &key : response.keys()) { - extraTokens.insert(key, response.value(key)); + for (auto it = response.constBegin(); it != response.constEnd(); ++it) { + extraTokens.insert(it.key(), it.value()); } setExtraTokens(extraTokens); } @@ -427,7 +428,8 @@ void O1::onTokenExchangeFinished() { QMap O1::parseResponse(const QByteArray &response) { QMap ret; - for (const QByteArray ¶m: response.split('&')) { + const QList params = response.split('&'); + for (const QByteArray ¶m: params) { QList kv = param.split('='); if (kv.length() == 2) { ret.insert(QUrl::fromPercentEncoding(kv[0]), QUrl::fromPercentEncoding(kv[1])); diff --git a/src/o2.cpp b/src/o2.cpp index 3fdff68..93bf78e 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -232,8 +232,9 @@ void O2::link() { parameters.append(qMakePair(QString(O2_OAUTH2_STATE), uniqueState)); if ( !apiKey_.isEmpty() ) parameters.append(qMakePair(QString(O2_OAUTH2_API_KEY), apiKey_)); - for (const QString &key: extraRequestParams().keys()) { - parameters.append(qMakePair(key, extraRequestParams().value(key).toString())); + const QVariantMap extraParams = extraRequestParams(); + for (auto it = extraParams.constBegin(); it != extraParams.constEnd(); ++it) { + parameters.append(qMakePair(it.key(), it.value().toString())); } // Show authentication URL with a web browser QUrl url(requestUrl_); @@ -251,8 +252,10 @@ void O2::link() { parameters.append(O0RequestParameter(O2_OAUTH2_SCOPE, scope_.toUtf8())); if ( !apiKey_.isEmpty() ) parameters.append(O0RequestParameter(O2_OAUTH2_API_KEY, apiKey_.toUtf8())); - for (const QString &key: extraRequestParams().keys()) { - parameters.append(O0RequestParameter(key.toUtf8(), extraRequestParams().value(key).toByteArray())); + + const QVariantMap extraParams = extraRequestParams(); + for (auto it = extraParams.constBegin(); it != extraParams.constEnd(); ++it) { + parameters.append(O0RequestParameter(it.key().toUtf8(), it.value().toByteArray())); } QByteArray payload = O0BaseAuth::createQueryParameters(parameters); @@ -408,9 +411,9 @@ void O2::onTokenReplyFinished() { // Dump tokens log( QStringLiteral("O2::onTokenReplyFinished: Tokens returned:\n") ); - for (const QString &key: tokens.keys()) { + for (auto it = tokens.constBegin(); it != tokens.constEnd(); ++it) { // SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first - log( QStringLiteral("%1: %2...").arg( key, tokens.value( key ).toString().left( 3 ) ) ); + log( QStringLiteral("%1: %2...").arg( it.key(), it.value().toString().left( 3 ) ) ); } // Check for mandatory tokens @@ -455,14 +458,13 @@ void O2::onTokenReplyError(QNetworkReply::NetworkError error) { QByteArray O2::buildRequestBody(const QMap ¶meters) { QByteArray body; bool first = true; - for (const QString &key: parameters.keys()) { + for (auto it = parameters.constBegin(); it != parameters.constEnd(); ++it) { if (first) { first = false; } else { body.append("&"); } - QString value = parameters.value(key); - body.append(QUrl::toPercentEncoding(key) + QString("=").toUtf8() + QUrl::toPercentEncoding(value)); + body.append(QUrl::toPercentEncoding(it.key()) + QString("=").toUtf8() + QUrl::toPercentEncoding(it.value())); } return body; } @@ -633,9 +635,9 @@ void O2::onDeviceAuthReplyFinished() // Dump tokens log( QStringLiteral("O2::onDeviceAuthReplyFinished: Tokens returned:\n") ); - for (const QString &key: params.keys()) { + for (auto it = params.constBegin(); it != params.constEnd(); ++it) { // SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first - log( QStringLiteral("%1: %2...").arg( key, params.value( key ).toString().left( 3 ) ) ); + log( QStringLiteral("%1: %2...").arg( it.key(), it.value().toString().left( 3 ) ) ); } // Check for mandatory parameters diff --git a/src/o2facebook.cpp b/src/o2facebook.cpp index 1305a21..c76ba22 100644 --- a/src/o2facebook.cpp +++ b/src/o2facebook.cpp @@ -28,8 +28,8 @@ void O2Facebook::onVerificationReceived(const QMap response) { if (response.contains("error")) { qWarning() << "O2Facebook::onVerificationReceived: Verification failed"; - for (const QString &key: response.keys()) { - qWarning() << "O2Facebook::onVerificationReceived:" << key << response.value(key); + for (auto it = response.constBegin(); it != response.constEnd(); ++it) { + qWarning() << "O2Facebook::onVerificationReceived:" << it.key() << it.value(); } Q_EMIT linkingFailed(); return; diff --git a/src/o2reply.cpp b/src/o2reply.cpp index ed12d0d..b610e80 100644 --- a/src/o2reply.cpp +++ b/src/o2reply.cpp @@ -19,7 +19,7 @@ void O2Reply::onTimeOut() { } O2ReplyList::~O2ReplyList() { - for (O2Reply *timedReply: replies_) { + for (O2Reply *timedReply: qAsConst(replies_)) { delete timedReply; } } @@ -43,7 +43,7 @@ void O2ReplyList::remove(QNetworkReply *reply) { } O2Reply *O2ReplyList::find(const QNetworkReply *reply) { - for (O2Reply *timedReply: replies_) { + for (O2Reply *timedReply: qAsConst(replies_)) { if (timedReply->reply == reply) { return timedReply; } diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 8b20394..87ebaab 100755 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -102,7 +102,7 @@ QMap O2ReplyServer::parseQueryParams(QByteArray *data) { tokens = query.queryItems(); #endif QMap queryParams; - for (const QPair &tokenPair: tokens) { + for (const QPair &tokenPair: qAsConst(tokens)) { // FIXME: We are decoding key and value again. This helps with Google OAuth, but is it mandated by the standard? QString key = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.first.trimmed().toLatin1())); QString value = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.second.trimmed().toLatin1())); diff --git a/src/o2skydrive.cpp b/src/o2skydrive.cpp index 9ccec7b..401275c 100644 --- a/src/o2skydrive.cpp +++ b/src/o2skydrive.cpp @@ -106,7 +106,8 @@ void O2Skydrive::redirected(const QUrl &url) { QStringList parts = url.toString().split("#"); if (parts.length() > 1) { - for (const QString &item: parts[1].split("&")) { + const QStringList items = parts[1].split("&"); + for (const QString &item: items) { int index = item.indexOf("="); if (index == -1) { continue; From d44d74f6531f5248274a2f3cbb53e9d6f6879d84 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 25 Nov 2024 09:49:44 +1000 Subject: [PATCH 17/17] Cppcheck fixes --- scripts/cppcheck.sh | 1 + src/o0baseauth.cpp | 8 +++----- src/o1.cpp | 19 +++++++++---------- src/o2uber.h | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index ba1dec6..b796bbc 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -25,6 +25,7 @@ cppcheck --inline-suppr \ -DQ_PROPERTY = \ -DQ_DECLARE_FLAGS = \ -DQ_ENUMS = \ + -DQ_ENUM = \ -DQ_DECLARE_OPERATORS_FOR_FLAGS = \ -Dforeach = \ -j $(nproc) \ diff --git a/src/o0baseauth.cpp b/src/o0baseauth.cpp index badbb06..5fca3a0 100644 --- a/src/o0baseauth.cpp +++ b/src/o0baseauth.cpp @@ -13,8 +13,7 @@ static const quint16 DefaultLocalPort = 1965; std::function O0BaseAuth::sLoggingFunction; -O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent) { - localPort_ = DefaultLocalPort; +O0BaseAuth::O0BaseAuth(QObject *parent, O0AbstractStore *store): QObject(parent), localPort_( DefaultLocalPort ) { setStore(store); } @@ -118,9 +117,8 @@ void O0BaseAuth::setLocalPort(int value) { } QVariantMap O0BaseAuth::extraTokens() { - QString key = QString(O2_KEY_EXTRA_TOKENS).arg(clientId_); - QString value = store_->value(key); - QByteArray bytes = QByteArray::fromBase64(value.toLatin1()); + const QString key = QString(O2_KEY_EXTRA_TOKENS).arg(clientId_); + QByteArray bytes = QByteArray::fromBase64(store_->value(key).toLatin1()); QDataStream stream(&bytes, QIODevice::ReadOnly); stream >> extraTokens_; return extraTokens_; diff --git a/src/o1.cpp b/src/o1.cpp index de2c5a4..5f72146 100644 --- a/src/o1.cpp +++ b/src/o1.cpp @@ -38,16 +38,16 @@ QByteArray O1::userAgent() const { return userAgent_; } -void O1::setUserAgent(const QByteArray &v) { - userAgent_ = v; +void O1::setUserAgent(const QByteArray &value) { + userAgent_ = value; } QUrl O1::requestTokenUrl() { return requestTokenUrl_; } -void O1::setRequestTokenUrl(const QUrl &v) { - requestTokenUrl_ = v; +void O1::setRequestTokenUrl(const QUrl &value) { + requestTokenUrl_ = value; Q_EMIT requestTokenUrlChanged(); } @@ -55,16 +55,16 @@ QList O1::requestParameters() { return requestParameters_; } -void O1::setRequestParameters(const QList &v) { - requestParameters_ = v; +void O1::setRequestParameters(const QList &value) { + requestParameters_ = value; } QString O1::callbackUrl() { return callbackUrl_; } -void O1::setCallbackUrl(const QString &v) { - callbackUrl_ = v; +void O1::setCallbackUrl(const QString &value) { + callbackUrl_ = value; } QUrl O1::authorizeUrl() { @@ -248,7 +248,6 @@ void O1::link() { #else QUrl requestData = requestTokenUrl(); #endif - O0RequestParameter param("", ""); const QList parameters = requestParameters(); for(const O0RequestParameter& param :parameters) requestData.addQueryItem(QString(param.name), QUrl::toPercentEncoding(QString(param.value))); @@ -278,7 +277,7 @@ void O1::link() { headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE_METHOD, signatureMethod().toLatin1())); headers.append(O0RequestParameter(O2_OAUTH_SIGNATURE, generateSignature(headers, request, requestParameters(), QNetworkAccessManager::PostOperation))); log( QStringLiteral( "O1:link: Token request headers:" ) ); - for(const O0RequestParameter¶m: qAsConst(headers)) { + for(const O0RequestParameter ¶m: qAsConst(headers)) { log( QStringLiteral( " %1=%2" ).arg( param.name, param.value ) ); } diff --git a/src/o2uber.h b/src/o2uber.h index 3d90260..f47714f 100644 --- a/src/o2uber.h +++ b/src/o2uber.h @@ -11,10 +11,10 @@ class O0_EXPORT O2Uber: public O2{ O2Uber(QObject *parent = 0); public Q_SLOTS: - void onVerificationReceived(QMap); + void onVerificationReceived(QMap) override; protected Q_SLOTS: - virtual void onTokenReplyFinished(); + void onTokenReplyFinished() override; }; #endif // O2UBER_H