diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2017-10-02 14:35:36 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-02 08:54:03 -0700 |
commit | 15c4fadde9b880bd81ad441296227536985c7084 (patch) | |
tree | 27808113cd4032d6a22cb13b9a597864db75f25c /desktop-widgets/plugins/facebook/facebookconnectwidget.cpp | |
parent | e662ce1cec935e13b7f3c078e527e1b05dfeaceb (diff) | |
download | subsurface-15c4fadde9b880bd81ad441296227536985c7084.tar.gz |
[Facebook] Use the nonblocking calls to post on fb
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/plugins/facebook/facebookconnectwidget.cpp')
-rw-r--r-- | desktop-widgets/plugins/facebook/facebookconnectwidget.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp index ab79c8731..bfe563384 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp @@ -41,6 +41,7 @@ FacebookManager::FacebookManager(QObject *parent) : QObject(parent), manager(new QNetworkAccessManager(this)) { + connect(this, &FacebookManager::albumIdReceived, this, &FacebookManager::sendDiveToAlbum); } static QString graphApi = QStringLiteral("https://graph.facebook.com/v2.10/"); @@ -190,7 +191,7 @@ QPixmap FacebookManager::grabProfilePixmap() /* to be changed to export the currently selected dive as shown on the profile. * Much much easier, and its also good to people do not select all the dives * and send erroniously *all* of them to facebook. */ -void FacebookManager::sendDive() +void FacebookManager::sendDiveInit() { SocialNetworkDialog dialog(qApp->activeWindow()); if (dialog.exec() != QDialog::Accepted) @@ -201,12 +202,16 @@ void FacebookManager::sendDive() fbInfo.profileData = grabProfilePixmap(); fbInfo.albumId = QString(); // request Album Id wil handle that. + // will emit albumIdReceived, that's connected to sendDiveToAlbum requestAlbumId(); +} - QUrl url(graphApi + QString(prefs.facebook.album_id) + "/photos?" + +void FacebookManager::sendDiveToAlbum(const QString& album) +{ + QUrl url(graphApi + album + "/photos?" + "&access_token=" + QString(prefs.facebook.access_token) + "&source=image" + - "&message=" + dialog.text().replace(""", "%22")); + "&message=" + fbInfo.bodyText.replace(""", "%22")); QNetworkRequest request(url); @@ -222,11 +227,11 @@ void FacebookManager::sendDive() data.append("Content-Disposition: form-data; name=\"uploaded\"; filename=\"" + QString::number(qrand()) + ".png\"\r\n"); data.append("Content-Type: image/jpeg\r\n\r\n"); //data type - QPixmap pix = grabProfilePixmap(); QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); - pix.save(&buffer, "PNG"); + fbInfo.profileData.save(&buffer, "PNG"); + data.append(bytes); //let's read the file data.append("\r\n"); data.append("--" + bound + "--\r\n"); //closing boundary according to rfc 1867 @@ -260,6 +265,8 @@ void FacebookManager::uploadFinished() + response), QMessageBox::Ok); } + + emit sendDiveFinished(); } FacebookConnectWidget::FacebookConnectWidget(QWidget *parent) : QDialog(parent), ui(new Ui::FacebookConnectWidget) { |