aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/plugins/facebook
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-15 11:55:27 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-15 16:11:39 -0700
commitc6998ee92680f2724c2a6adbb4c7a06c9bae0633 (patch)
tree3b43c59c8774c3f22a5f5f67411dfa2d1033c7e3 /desktop-widgets/plugins/facebook
parent4b2071728dd450e8fa9b81d4ccd3a1d80d78a305 (diff)
downloadsubsurface-c6998ee92680f2724c2a6adbb4c7a06c9bae0633.tar.gz
desktop-widgets/facebook: remove SettingsObjectWrapper
remove use of SettingsObjectWrapper:: remove include of SettingsObjectWrapper.h use qPrefFoo:: for setters and getters replace prefs.foo with qPrefXYZ::foo() where feasible (this expands to the same code, but gives us more control over the variable). Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'desktop-widgets/plugins/facebook')
-rw-r--r--desktop-widgets/plugins/facebook/facebookconnectwidget.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp
index d76cc88cd..37410d2d6 100644
--- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp
+++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp
@@ -27,7 +27,7 @@
#include "core/pref.h"
#include "core/qthelper.h"
-#include "core/subsurface-qt/SettingsObjectWrapper.h"
+#include "core/settings/qPrefFacebook.h"
#include "ui_socialnetworksdialog.h"
#include "ui_facebookconnectwidget.h"
@@ -88,18 +88,16 @@ void FacebookManager::tryLogin(const QUrl& loginResponse)
int to = result.indexOf("&expires_in");
QString securityToken = result.mid(from, to-from);
- auto fb = qPrefFacebook::instance();
- fb->set_access_token(securityToken);
+ qPrefFacebook::set_access_token(securityToken);
qCDebug(lcFacebook) << "Got securityToken" << securityToken;
requestUserId();
}
void FacebookManager::logout()
{
- auto fb = qPrefFacebook::instance();
- fb->set_access_token(QString());
- fb->set_user_id(QString());
- fb->set_album_id(QString());
+ qPrefFacebook::set_access_token(QString());
+ qPrefFacebook::set_user_id(QString());
+ qPrefFacebook::set_album_id(QString());
emit justLoggedOut(true);
}
@@ -116,15 +114,14 @@ void FacebookManager::albumListReceived()
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QJsonDocument albumsDoc = QJsonDocument::fromJson(reply->readAll());
QJsonArray albumObj = albumsDoc.object().value("data").toArray();
- auto fb = qPrefFacebook::instance();
reply->deleteLater();
foreach(const QJsonValue &v, albumObj){
QJsonObject obj = v.toObject();
if (obj.value("name").toString() == fbInfo.albumName) {
- fb->set_album_id(obj.value("id").toString());
+ qPrefFacebook::set_album_id(obj.value("id").toString());
qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "already exists, using id" << obj.value("id").toString();
- emit albumIdReceived(fb->album_id());
+ emit albumIdReceived(qPrefFacebook::album_id());
return;
}
}
@@ -158,9 +155,8 @@ void FacebookManager::facebookAlbumCreated()
if (album.contains("id")) {
qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "created successfully with id" << album.value("id").toString();
- auto fb = qPrefFacebook::instance();
- fb->set_album_id(album.value("id").toString());
- emit albumIdReceived(fb->album_id());
+ qPrefFacebook::set_album_id(album.value("id").toString());
+ emit albumIdReceived(qPrefFacebook::album_id());
return;
} else {
qCDebug(lcFacebook) << "It was not possible to create the album with name" << fbInfo.albumName;
@@ -168,8 +164,7 @@ void FacebookManager::facebookAlbumCreated()
// FIXME: we are lacking 'user_photos' facebook permission to create an album,
// but we are able to upload the image to Facebook (album will be named 'Subsurface Photos')
qCDebug(lcFacebook) << "But we are still able to upload data. Album name will be 'Subsurface Photos'";
- auto fb = qPrefFacebook::instance();
- emit albumIdReceived(fb->album_id());
+ emit albumIdReceived(qPrefFacebook::album_id());
}
}
@@ -189,7 +184,7 @@ void FacebookManager::userIdReceived()
QJsonObject obj = jsonDoc.object();
if (obj.keys().contains("id")) {
qCDebug(lcFacebook) << "User id requested successfully:" << obj.value("id").toString();
- qPrefFacebook::instance()->set_user_id(obj.value("id").toString());
+ qPrefFacebook::set_user_id(obj.value("id").toString());
emit sendMessage(tr("Facebook logged in successfully"));
emit justLoggedIn(true);
} else {