diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2017-09-29 12:21:35 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-09-29 12:57:34 -0700 |
commit | a6aeaf897a445952b7e81542df00e0b9a77ce9b6 (patch) | |
tree | ac3770c4625d7c8c2a474366207b11a4e9dbea30 /desktop-widgets | |
parent | 689dcf105877f86e315a55c9d7a3aa04e071b2c2 (diff) | |
download | subsurface-a6aeaf897a445952b7e81542df00e0b9a77ce9b6.tar.gz |
[Facebook] create userIdReceived slot
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/plugins/facebook/facebookconnectwidget.cpp | 10 | ||||
-rw-r--r-- | desktop-widgets/plugins/facebook/facebookconnectwidget.h | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp index 83fa25d28..b2e5f96f2 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp @@ -162,16 +162,18 @@ void FacebookManager::requestUserId() QUrl userIdRequest("https://graph.facebook.com/me?fields=id&access_token=" + QString(prefs.facebook.access_token)); QNetworkReply *reply = manager->get(QNetworkRequest(userIdRequest)); - QEventLoop loop; - connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - loop.exec(); + connect(reply, &QNetworkReply::finished, this, &FacebookManager::userIdReceived); +} +void FacebookManager::userIdReceived() +{ + QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); QJsonObject obj = jsonDoc.object(); if (obj.keys().contains("id")){ SettingsObjectWrapper::instance()->facebook->setUserId(obj.value("id").toString()); - return; } + reply->deleteLater(); } void FacebookManager::setDesiredAlbumName(const QString& a) diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.h b/desktop-widgets/plugins/facebook/facebookconnectwidget.h index e39286832..da87c0ecf 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.h +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.h @@ -38,6 +38,7 @@ public slots: void sendDive(); void uploadFinished(); void albumListReceived(); + void userIdReceived(); void createFacebookAlbum(); void facebookAlbumCreated(); private: |