mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: activate qPrefFacebook
remove Facebook from SettingsObjectWrapper and reference qPrefFacebook update files using SettingsObjectWrapper/Facebook to use qPrefFacebook this activated qPrefFacebook and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
e0f1817fdc
commit
f175890632
5 changed files with 34 additions and 124 deletions
|
@ -88,18 +88,18 @@ void FacebookManager::tryLogin(const QUrl& loginResponse)
|
|||
int to = result.indexOf("&expires_in");
|
||||
QString securityToken = result.mid(from, to-from);
|
||||
|
||||
auto fb = SettingsObjectWrapper::instance()->facebook;
|
||||
fb->setAccessToken(securityToken);
|
||||
auto fb = qPrefFacebook::instance();
|
||||
fb->set_access_token(securityToken);
|
||||
qCDebug(lcFacebook) << "Got securityToken" << securityToken;
|
||||
requestUserId();
|
||||
}
|
||||
|
||||
void FacebookManager::logout()
|
||||
{
|
||||
auto fb = SettingsObjectWrapper::instance()->facebook;
|
||||
fb->setAccessToken(QString());
|
||||
fb->setUserId(QString());
|
||||
fb->setAlbumId(QString());
|
||||
auto fb = qPrefFacebook::instance();
|
||||
fb->set_access_token(QString());
|
||||
fb->set_user_id(QString());
|
||||
fb->set_album_id(QString());
|
||||
emit justLoggedOut(true);
|
||||
}
|
||||
|
||||
|
@ -116,15 +116,15 @@ void FacebookManager::albumListReceived()
|
|||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
QJsonDocument albumsDoc = QJsonDocument::fromJson(reply->readAll());
|
||||
QJsonArray albumObj = albumsDoc.object().value("data").toArray();
|
||||
auto fb = SettingsObjectWrapper::instance()->facebook;
|
||||
auto fb = qPrefFacebook::instance();
|
||||
|
||||
reply->deleteLater();
|
||||
foreach(const QJsonValue &v, albumObj){
|
||||
QJsonObject obj = v.toObject();
|
||||
if (obj.value("name").toString() == fbInfo.albumName) {
|
||||
fb->setAlbumId(obj.value("id").toString());
|
||||
fb->set_album_id(obj.value("id").toString());
|
||||
qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "already exists, using id" << obj.value("id").toString();
|
||||
emit albumIdReceived(fb->albumId());
|
||||
emit albumIdReceived(fb->album_id());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -158,9 +158,9 @@ void FacebookManager::facebookAlbumCreated()
|
|||
|
||||
if (album.contains("id")) {
|
||||
qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "created successfully with id" << album.value("id").toString();
|
||||
auto fb = SettingsObjectWrapper::instance()->facebook;
|
||||
fb->setAlbumId(album.value("id").toString());
|
||||
emit albumIdReceived(fb->albumId());
|
||||
auto fb = qPrefFacebook::instance();
|
||||
fb->set_album_id(album.value("id").toString());
|
||||
emit albumIdReceived(fb->album_id());
|
||||
return;
|
||||
} else {
|
||||
qCDebug(lcFacebook) << "It was not possible to create the album with name" << fbInfo.albumName;
|
||||
|
@ -168,8 +168,8 @@ 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 = SettingsObjectWrapper::instance()->facebook;
|
||||
emit albumIdReceived(fb->albumId());
|
||||
auto fb = qPrefFacebook::instance();
|
||||
emit albumIdReceived(fb->album_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ void FacebookManager::userIdReceived()
|
|||
QJsonObject obj = jsonDoc.object();
|
||||
if (obj.keys().contains("id")) {
|
||||
qCDebug(lcFacebook) << "User id requested successfully:" << obj.value("id").toString();
|
||||
SettingsObjectWrapper::instance()->facebook->setUserId(obj.value("id").toString());
|
||||
qPrefFacebook::instance()->set_user_id(obj.value("id").toString());
|
||||
emit sendMessage(tr("Facebook logged in successfully"));
|
||||
emit justLoggedIn(true);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue