mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
[Facebook] Use correct albumName variable
and code cleanup Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5595d9a8b0
commit
3a564f412c
2 changed files with 14 additions and 13 deletions
|
@ -120,9 +120,9 @@ void FacebookManager::albumListReceived()
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
foreach(const QJsonValue &v, albumObj){
|
foreach(const QJsonValue &v, albumObj){
|
||||||
QJsonObject obj = v.toObject();
|
QJsonObject obj = v.toObject();
|
||||||
if (obj.value("name").toString() == albumName) {
|
if (obj.value("name").toString() == fbInfo.albumName) {
|
||||||
fb->setAlbumId(obj.value("id").toString());
|
fb->setAlbumId(obj.value("id").toString());
|
||||||
qCDebug(lcFacebook) << "Album" << albumName << "already exists, using 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->albumId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -134,9 +134,9 @@ void FacebookManager::albumListReceived()
|
||||||
|
|
||||||
void FacebookManager::createFacebookAlbum()
|
void FacebookManager::createFacebookAlbum()
|
||||||
{
|
{
|
||||||
qCDebug(lcFacebook) << "Album with name" << albumName << "doesn't exists, creating it.";
|
qCDebug(lcFacebook) << "Album with name" << fbInfo.albumName << "doesn't exists, creating it.";
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("name", albumName );
|
params.addQueryItem("name", fbInfo.albumName );
|
||||||
params.addQueryItem("description", "Subsurface Album");
|
params.addQueryItem("description", "Subsurface Album");
|
||||||
params.addQueryItem("privacy", "{'value': 'SELF'}");
|
params.addQueryItem("privacy", "{'value': 'SELF'}");
|
||||||
|
|
||||||
|
@ -156,13 +156,13 @@ void FacebookManager::facebookAlbumCreated()
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (album.contains("id")) {
|
if (album.contains("id")) {
|
||||||
qCDebug(lcFacebook) << "Album" << albumName << "created successfully with id" << album.value("id").toString();
|
qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "created successfully with id" << album.value("id").toString();
|
||||||
auto fb = SettingsObjectWrapper::instance()->facebook;
|
auto fb = SettingsObjectWrapper::instance()->facebook;
|
||||||
fb->setAlbumId(album.value("id").toString());
|
fb->setAlbumId(album.value("id").toString());
|
||||||
emit albumIdReceived(fb->albumId());
|
emit albumIdReceived(fb->albumId());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(lcFacebook) << "It was not possible to create the album with name" << albumName;
|
qCDebug(lcFacebook) << "It was not possible to create the album with name" << fbInfo.albumName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +226,7 @@ void FacebookManager::sendDiveInit()
|
||||||
fbInfo.bodyText = dialog.text();
|
fbInfo.bodyText = dialog.text();
|
||||||
fbInfo.profileSize = dialog.profileSize();
|
fbInfo.profileSize = dialog.profileSize();
|
||||||
fbInfo.profileData = grabProfilePixmap();
|
fbInfo.profileData = grabProfilePixmap();
|
||||||
|
fbInfo.albumName = dialog.album();
|
||||||
fbInfo.albumId = QString(); // request Album Id wil handle that.
|
fbInfo.albumId = QString(); // request Album Id wil handle that.
|
||||||
|
|
||||||
// will emit albumIdReceived, that's connected to sendDiveToAlbum
|
// will emit albumIdReceived, that's connected to sendDiveToAlbum
|
||||||
|
@ -234,7 +235,7 @@ void FacebookManager::sendDiveInit()
|
||||||
|
|
||||||
void FacebookManager::sendDiveToAlbum(const QString& albumId)
|
void FacebookManager::sendDiveToAlbum(const QString& albumId)
|
||||||
{
|
{
|
||||||
qCDebug(lcFacebook) << "Starting to upload the dive to album" << albumName << "id" << albumId;
|
qCDebug(lcFacebook) << "Starting to upload the dive to album" << fbInfo.albumName << "id" << albumId;
|
||||||
QUrl url(graphApi + albumId + "/photos?" +
|
QUrl url(graphApi + albumId + "/photos?" +
|
||||||
"&access_token=" + QString(prefs.facebook.access_token) +
|
"&access_token=" + QString(prefs.facebook.access_token) +
|
||||||
"&source=image" +
|
"&source=image" +
|
||||||
|
|
|
@ -18,12 +18,13 @@ namespace Ui {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FacebookInfo {
|
struct FacebookInfo {
|
||||||
enum Size {SMALL, MEDIUM, BIG};
|
enum Size {SMALL, MEDIUM, BIG};
|
||||||
|
|
||||||
QString bodyText;
|
QString bodyText;
|
||||||
QString albumId;
|
QString albumId;
|
||||||
Size profileSize;
|
QString albumName;
|
||||||
QPixmap profileData;
|
Size profileSize;
|
||||||
|
QPixmap profileData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FacebookManager : public QObject
|
class FacebookManager : public QObject
|
||||||
|
@ -56,7 +57,6 @@ public slots:
|
||||||
void facebookAlbumCreated();
|
void facebookAlbumCreated();
|
||||||
private:
|
private:
|
||||||
explicit FacebookManager(QObject *parent = 0);
|
explicit FacebookManager(QObject *parent = 0);
|
||||||
QString albumName;
|
|
||||||
FacebookInfo fbInfo;
|
FacebookInfo fbInfo;
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue