diff --git a/build.pro b/build.pro index ccd26230f..0b90273a2 100644 --- a/build.pro +++ b/build.pro @@ -1,7 +1,4 @@ TEMPLATE = subdirs SUBDIRS = qwt -unix:!macx { - SUBDIRS += kqoauth -} SUBDIRS += src CONFIG += ordered diff --git a/src/Cloud/OAuthManager.cpp b/deprecated/OAuthManager.cpp similarity index 100% rename from src/Cloud/OAuthManager.cpp rename to deprecated/OAuthManager.cpp diff --git a/src/Cloud/OAuthManager.h b/deprecated/OAuthManager.h similarity index 100% rename from src/Cloud/OAuthManager.h rename to deprecated/OAuthManager.h diff --git a/kqoauth/kqoauth.pc b/deprecated/kqoauth/kqoauth.pc similarity index 100% rename from kqoauth/kqoauth.pc rename to deprecated/kqoauth/kqoauth.pc diff --git a/kqoauth/kqoauth.pro b/deprecated/kqoauth/kqoauth.pro similarity index 100% rename from kqoauth/kqoauth.pro rename to deprecated/kqoauth/kqoauth.pro diff --git a/kqoauth/kqoauthauthreplyserver.cpp b/deprecated/kqoauth/kqoauthauthreplyserver.cpp similarity index 100% rename from kqoauth/kqoauthauthreplyserver.cpp rename to deprecated/kqoauth/kqoauthauthreplyserver.cpp diff --git a/kqoauth/kqoauthauthreplyserver.h b/deprecated/kqoauth/kqoauthauthreplyserver.h similarity index 100% rename from kqoauth/kqoauthauthreplyserver.h rename to deprecated/kqoauth/kqoauthauthreplyserver.h diff --git a/kqoauth/kqoauthauthreplyserver_p.h b/deprecated/kqoauth/kqoauthauthreplyserver_p.h similarity index 100% rename from kqoauth/kqoauthauthreplyserver_p.h rename to deprecated/kqoauth/kqoauthauthreplyserver_p.h diff --git a/kqoauth/kqoauthglobals.h b/deprecated/kqoauth/kqoauthglobals.h similarity index 100% rename from kqoauth/kqoauthglobals.h rename to deprecated/kqoauth/kqoauthglobals.h diff --git a/kqoauth/kqoauthmanager.cpp b/deprecated/kqoauth/kqoauthmanager.cpp similarity index 100% rename from kqoauth/kqoauthmanager.cpp rename to deprecated/kqoauth/kqoauthmanager.cpp diff --git a/kqoauth/kqoauthmanager.h b/deprecated/kqoauth/kqoauthmanager.h similarity index 100% rename from kqoauth/kqoauthmanager.h rename to deprecated/kqoauth/kqoauthmanager.h diff --git a/kqoauth/kqoauthmanager_p.h b/deprecated/kqoauth/kqoauthmanager_p.h similarity index 100% rename from kqoauth/kqoauthmanager_p.h rename to deprecated/kqoauth/kqoauthmanager_p.h diff --git a/kqoauth/kqoauthrequest.cpp b/deprecated/kqoauth/kqoauthrequest.cpp similarity index 100% rename from kqoauth/kqoauthrequest.cpp rename to deprecated/kqoauth/kqoauthrequest.cpp diff --git a/kqoauth/kqoauthrequest.h b/deprecated/kqoauth/kqoauthrequest.h similarity index 100% rename from kqoauth/kqoauthrequest.h rename to deprecated/kqoauth/kqoauthrequest.h diff --git a/kqoauth/kqoauthrequest_1.cpp b/deprecated/kqoauth/kqoauthrequest_1.cpp similarity index 100% rename from kqoauth/kqoauthrequest_1.cpp rename to deprecated/kqoauth/kqoauthrequest_1.cpp diff --git a/kqoauth/kqoauthrequest_1.h b/deprecated/kqoauth/kqoauthrequest_1.h similarity index 100% rename from kqoauth/kqoauthrequest_1.h rename to deprecated/kqoauth/kqoauthrequest_1.h diff --git a/kqoauth/kqoauthrequest_p.h b/deprecated/kqoauth/kqoauthrequest_p.h similarity index 100% rename from kqoauth/kqoauthrequest_p.h rename to deprecated/kqoauth/kqoauthrequest_p.h diff --git a/kqoauth/kqoauthrequest_xauth.cpp b/deprecated/kqoauth/kqoauthrequest_xauth.cpp similarity index 100% rename from kqoauth/kqoauthrequest_xauth.cpp rename to deprecated/kqoauth/kqoauthrequest_xauth.cpp diff --git a/kqoauth/kqoauthrequest_xauth.h b/deprecated/kqoauth/kqoauthrequest_xauth.h similarity index 100% rename from kqoauth/kqoauthrequest_xauth.h rename to deprecated/kqoauth/kqoauthrequest_xauth.h diff --git a/kqoauth/kqoauthrequest_xauth_p.h b/deprecated/kqoauth/kqoauthrequest_xauth_p.h similarity index 100% rename from kqoauth/kqoauthrequest_xauth_p.h rename to deprecated/kqoauth/kqoauthrequest_xauth_p.h diff --git a/kqoauth/kqoauthutils.cpp b/deprecated/kqoauth/kqoauthutils.cpp similarity index 100% rename from kqoauth/kqoauthutils.cpp rename to deprecated/kqoauth/kqoauthutils.cpp diff --git a/kqoauth/kqoauthutils.h b/deprecated/kqoauth/kqoauthutils.h similarity index 100% rename from kqoauth/kqoauthutils.h rename to deprecated/kqoauth/kqoauthutils.h diff --git a/kqoauth/pcfile.sh b/deprecated/kqoauth/pcfile.sh similarity index 100% rename from kqoauth/pcfile.sh rename to deprecated/kqoauth/pcfile.sh diff --git a/src/Cloud/AddCloudWizard.cpp b/src/Cloud/AddCloudWizard.cpp index 86b1622a1..db1aea7f1 100644 --- a/src/Cloud/AddCloudWizard.cpp +++ b/src/Cloud/AddCloudWizard.cpp @@ -25,7 +25,6 @@ #include "Colors.h" #include "CloudService.h" #include "OAuthDialog.h" -#include "OAuthManager.h" #include #include @@ -317,48 +316,27 @@ AddAuth::doAuth() updateServiceSettings(); if (wizard->cloudService->capabilities() & CloudService::OAuth) { - if (wizard->cloudService->capabilities() & CloudService::UserPass) { - OAuthManager *oauthManager = new OAuthManager(wizard->context, OAuthManager::NONE, wizard->cloudService); - if (oauthManager->sslLibMissing()) { - delete oauthManager; - } else { + OAuthDialog *oauthDialog = new OAuthDialog(wizard->context, OAuthDialog::NONE, wizard->cloudService); + if (oauthDialog->sslLibMissing()) { + delete oauthDialog; + } else { + oauthDialog->setWindowModality(Qt::ApplicationModal); + oauthDialog->exec(); + token->setText(wizard->cloudService->getSetting(cname, "").toString()); + + QString msg = wizard->cloudService->message; + if (msg != "") { + message->setText(msg); messageLabel->show(); message->show(); - message->setText(QString("Connecting with %1...").arg(wizard->cloudService->id())); - oauthManager->authorize(); - token->setText(wizard->cloudService->getSetting(cname, "").toString()); - - QString msg = wizard->cloudService->message; - if (msg != "") { - message->setText(msg); - - wizard->cloudService->message = ""; - } + wizard->cloudService->message = ""; } - } else { - OAuthDialog *oauthDialog = new OAuthDialog(wizard->context, OAuthDialog::NONE, wizard->cloudService); - if (oauthDialog->sslLibMissing()) { - delete oauthDialog; - } else { - oauthDialog->setWindowModality(Qt::ApplicationModal); - oauthDialog->exec(); - token->setText(wizard->cloudService->getSetting(cname, "").toString()); - QString msg = wizard->cloudService->message; - if (msg != "") { - message->setText(msg); - messageLabel->show(); - message->show(); - wizard->cloudService->message = ""; - } - - // Due to the OAuth dialog being modal, the order of the background windows can get out of order - // This ensures the wizard is back on top - wizard->raise(); - } + // Due to the OAuth dialog being modal, the order of the background windows can get out of order + // This ensures the wizard is back on top + wizard->raise(); } } - } void diff --git a/src/Cloud/OAuthDialog.h b/src/Cloud/OAuthDialog.h index e6c945410..02cae448b 100644 --- a/src/Cloud/OAuthDialog.h +++ b/src/Cloud/OAuthDialog.h @@ -21,9 +21,6 @@ #include "GoldenCheetah.h" #include "Pages.h" #include "CloudService.h" -#ifdef GC_HAVE_KQOAUTH -#include -#endif #include #include #include @@ -108,11 +105,6 @@ private: QNetworkAccessManager* manager; QUrl url; - -#ifdef GC_HAVE_KQOAUTH - KQOAuthManager *oauthManager; - KQOAuthRequest *oauthRequest; -#endif }; #endif // OAUTHDIALOG_H diff --git a/src/Cloud/WithingsDownload.cpp b/src/Cloud/WithingsDownload.cpp index 8f2df8770..0cc70fbca 100644 --- a/src/Cloud/WithingsDownload.cpp +++ b/src/Cloud/WithingsDownload.cpp @@ -25,11 +25,6 @@ #include "BodyMeasures.h" #include -#ifdef GC_HAVE_KQOAUTH -#include -#include -#endif - #ifndef WITHINGS_DEBUG #define WITHINGS_DEBUG true #endif @@ -57,49 +52,21 @@ WithingsDownload::WithingsDownload(Context *context) : context(context) nam = new QNetworkAccessManager(this); connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*))); - #ifdef GC_HAVE_KQOAUTH - oauthRequest = new KQOAuthRequest(); - oauthManager = new KQOAuthManager(); - - connect(oauthManager, SIGNAL(authorizedRequestDone()), - this, SLOT(onAuthorizedRequestDone())); - connect(oauthManager, SIGNAL(requestReady(QByteArray)), - this, SLOT(onRequestReady(QByteArray))); - - #endif } bool WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, QList &data) { response = ""; - // New API (OAuth) - QString strToken = ""; - QString strSecret = ""; QString strNokiaToken = ""; QString strNokiaRefreshToken = ""; - QString access_token = ""; - #ifdef GC_HAVE_KQOAUTH - strToken = appsettings->cvalue(context->athlete->cyclist, GC_WITHINGS_TOKEN).toString(); - strSecret= appsettings->cvalue(context->athlete->cyclist, GC_WITHINGS_SECRET).toString(); - #endif - strNokiaToken = appsettings->cvalue(context->athlete->cyclist, GC_NOKIA_TOKEN).toString(); strNokiaRefreshToken = appsettings->cvalue(context->athlete->cyclist, GC_NOKIA_REFRESH_TOKEN).toString(); - - QString strOldKey = appsettings->cvalue(context->athlete->cyclist, GC_WIKEY).toString(); - - - if((strToken.isEmpty() || strSecret.isEmpty() || - strToken == "" || strToken == "0" || - strSecret == "" || strSecret == "0" ) && - (strOldKey.isEmpty() || strOldKey == "" || strOldKey == "0" ) && - (strNokiaRefreshToken.isEmpty() || strNokiaRefreshToken == "" || strNokiaRefreshToken == "0" )) - { + if(strNokiaRefreshToken.isEmpty() || strNokiaRefreshToken == "" || strNokiaRefreshToken == "0" ) { #ifdef Q_OS_MACX #define GC_PREF tr("Golden Cheetah->Preferences") #else @@ -111,10 +78,7 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, return false; } - if(!strNokiaRefreshToken.isEmpty() || - (!strToken.isEmpty() &&! strSecret.isEmpty() && - strToken != "" && strToken != "0" && - strSecret != "" && strSecret != "0" )) { + if(!strNokiaRefreshToken.isEmpty()) { printd("OAuth 2.0 API\n"); #if QT_VERSION > 0x050000 @@ -124,8 +88,6 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, #endif QString refresh_token = appsettings->cvalue(context->athlete->cyclist, GC_NOKIA_REFRESH_TOKEN).toString(); - if (refresh_token.isEmpty()) - refresh_token = QString("%1:%2").arg(strToken).arg(strSecret); postData.addQueryItem("grant_type", "refresh_token"); postData.addQueryItem("client_id", GC_NOKIA_CLIENT_ID ); @@ -136,7 +98,6 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, emit downloadStarted(100); - //oauthManager->executeRequest(oauthRequest); QNetworkRequest request(url); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); nam->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); @@ -197,106 +158,10 @@ WithingsDownload::getBodyMeasures(QString &error, QDateTime from, QDateTime to, } } - - if(access_token.isEmpty() && !strToken.isEmpty() &&! strSecret.isEmpty() && - strToken != "" && strToken != "0" && - strSecret != "" && strSecret != "0" ) { - printd("OAuth 1.0 API\n"); - - #ifdef GC_HAVE_KQOAUTH - oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, QUrl("http://wbsapi.withings.net/measure")); - oauthRequest->setHttpMethod(KQOAuthRequest::GET); - //oauthRequest->setEnableDebugOutput(true); - - oauthRequest->setConsumerKey(GC_WITHINGS_CONSUMER_KEY); - oauthRequest->setConsumerSecretKey(GC_WITHINGS_CONSUMER_SECRET); - - // set the user token and secret - oauthRequest->setToken(strToken); - oauthRequest->setTokenSecret(strSecret); - - KQOAuthParameters params; - params.insert("action", "getmeas"); - params.insert("userid", appsettings->cvalue(context->athlete->cyclist, GC_WIUSER, "").toString()); - params.insert("startdate", QString::number(from.toMSecsSinceEpoch()/1000)); - params.insert("enddate", QString::number(to.toMSecsSinceEpoch()/1000)); - - oauthRequest->setAdditionalParameters(params); - - // Hack... - // Why should we add params manually (GET) ???? - // We can use KQOAuth because Nokia/Withings expect token in url. - - QList requestParameters = oauthRequest->requestParameters(); - -#if QT_VERSION > 0x050000 - QUrlQuery params2; -#else - QUrl params2; -#endif - for (int i=0; icvalue(context->athlete->cyclist, GC_WIUSER, "").toString()); - params2.addQueryItem("startdate", QString::number(from.toMSecsSinceEpoch()/1000)); - params2.addQueryItem("enddate", QString::number(to.toMSecsSinceEpoch()/1000)); - - QUrl url = QUrl( "https://wbsapi.withings.net/measure?" + params2.toString() ); - printd("URL : %s\n", url.url().toStdString().c_str()); - - emit downloadStarted(100); - - //oauthManager->executeRequest(oauthRequest); - QNetworkRequest request(url); - nam->get(request); - - emit downloadProgress(50); - - // blocking request - loop.exec(); // we go on after receiving the data in SLOT(onRequestReady(QByteArray)) - - emit downloadEnded(100); - #endif - } else if (access_token.isEmpty()) { - printd("Withings password API\n"); - - // account for trailing slash, remove it if it is there (it was the default in preferences) - QString server = appsettings->cvalue(context->athlete->cyclist, GC_WIURL, "http://wbsapi.withings.net").toString(); - if (server.endsWith("/")) server=server.mid(0, server.length()-1); - - QString request = QString("%1/measure?action=getmeas&userid=%2&publickey=%3&startdate=%4&enddate=%5") - .arg(server) - .arg(appsettings->cvalue(context->athlete->cyclist, GC_WIUSER, "").toString()) - .arg(appsettings->cvalue(context->athlete->cyclist, GC_WIKEY, "").toString()) - .arg(QString::number(from.toMSecsSinceEpoch()/1000)) - .arg(QString::number(to.toMSecsSinceEpoch()/1000)); - - emit downloadStarted(100); - QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(request))); - - emit downloadProgress(50); - // blocking request - loop.exec(); // we go on after receiving the data in SLOT(downloadFinished(QNetworkReply)) - - emit downloadEnded(100); - if (reply->error() != QNetworkReply::NoError) { - QMessageBox::warning(context->mainWindow, tr("Nokia Health (Withings) Data Download"), reply->errorString()); - return false; - } - } - printd("response: %s\n", response.toStdString().c_str()); QJsonParseError parseResult; - if (response.contains("\"status\":0", Qt::CaseInsensitive)) - { + if (response.contains("\"status\":0", Qt::CaseInsensitive)) { parseResult = parse(response, data); } else { QMessageBox oautherr(QMessageBox::Critical, tr("Error"), @@ -410,20 +275,3 @@ WithingsDownload::downloadFinished(QNetworkReply *reply) response = reply->readAll(); loop.exit(0); } - - -#ifdef GC_HAVE_KQOAUTH -void -WithingsDownload::onAuthorizedRequestDone() { - // printd("Request sent to Withings!\n"); -} - -void -WithingsDownload::onRequestReady(QByteArray r) { - //printd("Response from the Withings's service: %s\n", response..toStdString().c_str()); - - response = r; - loop.exit(0); - -} -#endif diff --git a/src/Cloud/WithingsDownload.h b/src/Cloud/WithingsDownload.h index cf70b0ca8..e2eb88687 100644 --- a/src/Cloud/WithingsDownload.h +++ b/src/Cloud/WithingsDownload.h @@ -29,10 +29,6 @@ #include "BodyMeasures.h" #include "WithingsReading.h" -#ifdef GC_HAVE_KQOAUTH -#include -#endif - class WithingsDownload : public QObject { Q_OBJECT @@ -53,10 +49,6 @@ private: QNetworkAccessManager *nam; QString response; - #ifdef GC_HAVE_KQOAUTH - KQOAuthManager *oauthManager; - KQOAuthRequest *oauthRequest; - #endif QEventLoop loop; QJsonParseError parse(QString text, QList &bodyMeasures); @@ -65,9 +57,5 @@ private: private slots: void downloadFinished(QNetworkReply *reply); - #ifdef GC_HAVE_KQOAUTH - void onRequestReady(QByteArray); - void onAuthorizedRequestDone(); - #endif }; #endif diff --git a/src/Gui/GcCrashDialog.cpp b/src/Gui/GcCrashDialog.cpp index 30dab472a..a90e31bb4 100644 --- a/src/Gui/GcCrashDialog.cpp +++ b/src/Gui/GcCrashDialog.cpp @@ -59,10 +59,6 @@ #include "srmio.h" #endif -#ifdef GC_HAVE_KQOAUTH -#include "kqoauthmanager.h" -#endif - #ifdef GC_HAVE_SAMPLERATE #include #endif diff --git a/src/src.pro b/src/src.pro index 3beb2e076..8b108e17e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -331,33 +331,6 @@ contains(DEFINES, "GC_WANT_R") { QT += opengl } -###==================== -### OPTIONAL => KQOAUTH -###==================== - -unix:!macx { - - # build from version in repo for Linux builds since - # kqoauth is not packaged for the Debian and this makes - # life much easier for the package maintainer - INCLUDEPATH += $${PWD}/../kqoauth - LIBS += $${PWD}/../kqoauth/libkqoauth.a - DEFINES += GC_HAVE_KQOAUTH - -} else { - - !isEmpty(KQOAUTH_INSTALL) { - - # we will work out the rest if you tell us where it is installed - isEmpty(KQOAUTH_INCLUDE) { KQOAUTH_INCLUDE = $${KQOAUTH_INSTALL}/src } - isEmpty(KQOAUTH_LIBS) { KQOAUTH_LIBS = -L$${KQOAUTH_INSTALL}/lib -lkqoauth } - - INCLUDEPATH += $${KQOAUTH_INCLUDE} - LIBS += $${KQOAUTH_LIBS} - DEFINES += GC_HAVE_KQOAUTH - } -} - ###======================================================= ### OPTIONAL => D2XX FOR FTDI DRIVERS ON WINDOWS PLATFORMS ###======================================================= @@ -707,7 +680,7 @@ HEADERS += Charts/Aerolab.h Charts/AerolabWindow.h Charts/AllPlot.h Charts/AllPl # cloud services HEADERS += Cloud/BodyMeasuresDownload.h Cloud/CalDAVCloud.h Cloud/CalendarDownload.h Cloud/CloudService.h \ - Cloud/LocalFileStore.h Cloud/OAuthDialog.h Cloud/OAuthManager.h Cloud/TodaysPlanBodyMeasures.h \ + Cloud/LocalFileStore.h Cloud/OAuthDialog.h Cloud/TodaysPlanBodyMeasures.h \ Cloud/WithingsDownload.h Cloud/Strava.h Cloud/CyclingAnalytics.h Cloud/RideWithGPS.h \ Cloud/TrainingsTageBuch.h Cloud/Selfloops.h Cloud/Velohero.h Cloud/SportsPlusHealth.h \ Cloud/AddCloudWizard.h Cloud/Withings.h Cloud/HrvMeasuresDownload.h Cloud/Xert.h @@ -800,7 +773,7 @@ SOURCES += Charts/Aerolab.cpp Charts/AerolabWindow.cpp Charts/AllPlot.cpp Charts ## Cloud Services / Web resources SOURCES += Cloud/BodyMeasuresDownload.cpp Cloud/CalDAVCloud.cpp Cloud/CalendarDownload.cpp Cloud/CloudService.cpp \ - Cloud/LocalFileStore.cpp Cloud/OAuthDialog.cpp Cloud/OAuthManager.cpp Cloud/TodaysPlanBodyMeasures.cpp \ + Cloud/LocalFileStore.cpp Cloud/OAuthDialog.cpp Cloud/TodaysPlanBodyMeasures.cpp \ Cloud/WithingsDownload.cpp Cloud/Strava.cpp Cloud/CyclingAnalytics.cpp Cloud/RideWithGPS.cpp \ Cloud/TrainingsTageBuch.cpp Cloud/Selfloops.cpp Cloud/Velohero.cpp Cloud/SportsPlusHealth.cpp \ Cloud/AddCloudWizard.cpp Cloud/Withings.cpp Cloud/HrvMeasuresDownload.cpp Cloud/Xert.cpp