aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/CMakeLists.txt8
-rw-r--r--desktop-widgets/mainwindow.cpp64
-rw-r--r--desktop-widgets/mainwindow.h5
-rw-r--r--desktop-widgets/mainwindow.ui12
-rw-r--r--desktop-widgets/plugins/CMakeLists.txt1
-rw-r--r--desktop-widgets/plugins/facebook/CMakeLists.txt22
-rw-r--r--desktop-widgets/plugins/facebook/facebook_integration.cpp43
-rw-r--r--desktop-widgets/plugins/facebook/facebook_integration.h26
-rw-r--r--desktop-widgets/plugins/facebook/facebookconnectwidget.cpp421
-rw-r--r--desktop-widgets/plugins/facebook/facebookconnectwidget.h99
-rw-r--r--desktop-widgets/plugins/facebook/facebookconnectwidget.ui104
-rw-r--r--desktop-widgets/plugins/facebook/socialnetworksdialog.ui189
12 files changed, 0 insertions, 994 deletions
diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt
index 629c0507e..ea09e5ce6 100644
--- a/desktop-widgets/CMakeLists.txt
+++ b/desktop-widgets/CMakeLists.txt
@@ -7,20 +7,12 @@ if(BTSUPPORT)
set(BT_SRC_FILES btdeviceselectiondialog.cpp)
endif()
-if (FBSUPPORT)
- add_definitions(-DFBSUPPORT)
-endif()
-
-
include_directories(.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}
)
add_subdirectory(preferences)
-if(NOT DISABLE_PLUGINS)
- add_subdirectory(plugins)
-endif()
set (SUBSURFACE_UI
about.ui
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 584ad9e0c..2d1f61d2b 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -22,10 +22,8 @@
#include "core/divesitehelpers.h"
#include "core/gettextfromc.h"
#include "core/git-access.h"
-#include "core/isocialnetworkintegration.h"
#include "core/import-csv.h"
#include "core/planner.h"
-#include "core/pluginmanager.h"
#include "core/qthelper.h"
#include "core/subsurface-string.h"
#include "core/version.h"
@@ -76,11 +74,6 @@
#include "usermanual.h"
#endif
-#if defined(FBSUPPORT)
-#include "plugins/facebook/facebook_integration.h"
-#include "plugins/facebook/facebookconnectwidget.h"
-#endif
-
namespace {
QProgressDialog *progressDialog = nullptr;
bool progressDialogCanceled = false;
@@ -380,63 +373,6 @@ MainWindow::~MainWindow()
void MainWindow::setupSocialNetworkMenu()
{
-#ifdef FBSUPPORT
- connections = new QMenu(tr("Connect to"));
- FacebookPlugin *facebookPlugin = new FacebookPlugin();
- QAction *toggle_connection = new QAction(this);
- QObject *obj = facebookPlugin;
- toggle_connection->setText(facebookPlugin->socialNetworkName());
- toggle_connection->setIcon(QIcon(facebookPlugin->socialNetworkIcon()));
- toggle_connection->setData(QVariant::fromValue(obj));
- connect(toggle_connection, SIGNAL(triggered()), this, SLOT(socialNetworkRequestConnect()));
- FacebookManager *fb = FacebookManager::instance();
- connect(fb, &FacebookManager::justLoggedIn, this, &MainWindow::facebookLoggedIn);
- connect(fb, &FacebookManager::justLoggedOut, this, &MainWindow::facebookLoggedOut);
- connect(fb, &FacebookManager::sendMessage, [this](const QString& msg) {
- statusBar()->showMessage(msg, 10000); // show message for 10 secs on the statusbar.
- });
- share_on_fb = new QAction(this);
- share_on_fb->setText(facebookPlugin->socialNetworkName());
- share_on_fb->setIcon(QIcon(facebookPlugin->socialNetworkIcon()));
- share_on_fb->setData(QVariant::fromValue(obj));
- share_on_fb->setEnabled(false);
- ui.menuShare_on->addAction(share_on_fb);
- connections->addAction(toggle_connection);
- connect(share_on_fb, SIGNAL(triggered()), this, SLOT(socialNetworkRequestUpload()));
- ui.menuShare_on->addSeparator();
- ui.menuShare_on->addMenu(connections);
- ui.menubar->show();
-#endif
-}
-
-void MainWindow::facebookLoggedIn()
-{
- connections->setTitle(tr("Disconnect from"));
- share_on_fb->setEnabled(true);
-}
-
-void MainWindow::facebookLoggedOut()
-{
- connections->setTitle(tr("Connect to"));
- share_on_fb->setEnabled(false);
-}
-
-void MainWindow::socialNetworkRequestConnect()
-{
- qDebug() << "Requesting connect on the social network";
- QAction *action = qobject_cast<QAction*>(sender());
- ISocialNetworkIntegration *plugin = qobject_cast<ISocialNetworkIntegration*>(action->data().value<QObject*>());
- if (plugin->isConnected())
- plugin->requestLogoff();
- else
- plugin->requestLogin();
-}
-
-void MainWindow::socialNetworkRequestUpload()
-{
- QAction *action = qobject_cast<QAction*>(sender());
- ISocialNetworkIntegration *plugin = action->data().value<ISocialNetworkIntegration*>();
- plugin->requestUpload();
}
void MainWindow::setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl, const PropertyList& br)
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index e9632779c..4a2de1c6b 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -175,11 +175,6 @@ slots:
// should only be enabled when the profile's visible.
void disableShortcuts(bool disablePaste = true);
void enableShortcuts();
-
- void socialNetworkRequestConnect();
- void socialNetworkRequestUpload();
- void facebookLoggedIn();
- void facebookLoggedOut();
void updateVariations(QString);
diff --git a/desktop-widgets/mainwindow.ui b/desktop-widgets/mainwindow.ui
index 2dcd3e8a6..afd4168eb 100644
--- a/desktop-widgets/mainwindow.ui
+++ b/desktop-widgets/mainwindow.ui
@@ -137,18 +137,11 @@
<string>&amp;Edit</string>
</property>
</widget>
- <widget class="QMenu" name="menuShare_on">
- <property name="title">
- <string>Share o&amp;n</string>
- </property>
- <addaction name="separator"/>
- </widget>
<addaction name="menuFile"/>
<addaction name="menu_Edit"/>
<addaction name="menuImport"/>
<addaction name="menuLog"/>
<addaction name="menuView"/>
- <addaction name="menuShare_on"/>
<addaction name="menuHelp"/>
</widget>
<action name="actionNew">
@@ -700,11 +693,6 @@
<string>Dive Site &amp;Edit</string>
</property>
</action>
- <action name="actionFacebook">
- <property name="text">
- <string>Facebook</string>
- </property>
- </action>
<action name="actionCloudOnline">
<property name="checkable">
<bool>true</bool>
diff --git a/desktop-widgets/plugins/CMakeLists.txt b/desktop-widgets/plugins/CMakeLists.txt
deleted file mode 100644
index f424e172e..000000000
--- a/desktop-widgets/plugins/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(facebook) \ No newline at end of file
diff --git a/desktop-widgets/plugins/facebook/CMakeLists.txt b/desktop-widgets/plugins/facebook/CMakeLists.txt
deleted file mode 100644
index 592700ad4..000000000
--- a/desktop-widgets/plugins/facebook/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-if (ANDROID)
- set(FACEBOOK_INTEGRATION "")
-elseif (${FBSUPPORT})
- add_definitions(-DFBSUPPORT)
- set(FACEBOOK_INTEGRATION facebook_integration)
- include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
- set(FACEBOOK_PLUGIN_UI
- facebookconnectwidget.ui
- socialnetworksdialog.ui
- )
-
- set(FACEBOOK_PLUGIN_SRCS
- facebook_integration.cpp
- facebookconnectwidget.cpp
- )
-
- qt5_wrap_ui(FACEBOOK_PLUGIN_UI_SRCS ${FACEBOOK_PLUGIN_UI})
- add_library(facebook_integration STATIC ${FACEBOOK_PLUGIN_SRCS} ${FACEBOOK_PLUGIN_UI_SRCS})
- target_link_libraries(facebook_integration ${QT_LIBRARIES})
- add_dependencies(facebook_integration subsurface_corelib)
-endif()
diff --git a/desktop-widgets/plugins/facebook/facebook_integration.cpp b/desktop-widgets/plugins/facebook/facebook_integration.cpp
deleted file mode 100644
index 30fa83610..000000000
--- a/desktop-widgets/plugins/facebook/facebook_integration.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "facebook_integration.h"
-#include "facebookconnectwidget.h"
-
-#include <QDebug>
-
-FacebookPlugin::FacebookPlugin(QObject*) :
- fbConnectWidget(new FacebookConnectWidget())
-{
-}
-
-bool FacebookPlugin::isConnected()
-{
- FacebookManager *instance = FacebookManager::instance();
- return instance->loggedIn();
-}
-
-void FacebookPlugin::requestLogin()
-{
- fbConnectWidget->exec();
-}
-
-void FacebookPlugin::requestLogoff()
-{
- FacebookManager::instance()->logout();
-}
-
-QString FacebookPlugin::socialNetworkIcon() const
-{
- return QString();
-}
-
-QString FacebookPlugin::socialNetworkName() const
-{
- return tr("Facebook");
-}
-
-void FacebookPlugin::requestUpload()
-{
- FacebookManager *instance = FacebookManager::instance();
- if (instance->loggedIn())
- instance->sendDiveInit();
-}
diff --git a/desktop-widgets/plugins/facebook/facebook_integration.h b/desktop-widgets/plugins/facebook/facebook_integration.h
deleted file mode 100644
index 7a9ebc700..000000000
--- a/desktop-widgets/plugins/facebook/facebook_integration.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#ifndef FACEBOOK_INTEGRATION_H
-#define FACEBOOK_INTEGRATION_H
-
-#include "core/isocialnetworkintegration.h"
-#include <QString>
-
-class FacebookConnectWidget;
-class SocialNetworkDialog;
-class FacebookManager;
-
-class FacebookPlugin : public ISocialNetworkIntegration {
- Q_OBJECT
-public:
- explicit FacebookPlugin(QObject* parent = 0);
- bool isConnected() override;
- void requestLogin() override;
- void requestLogoff() override;
- QString socialNetworkIcon() const override;
- QString socialNetworkName() const override;
- void requestUpload() override;
-private:
- FacebookConnectWidget *fbConnectWidget;
-};
-
-#endif
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp
deleted file mode 100644
index 7a497e218..000000000
--- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include "facebookconnectwidget.h"
-
-#include <QJsonDocument>
-#include <QJsonArray>
-#include <QJsonObject>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QNetworkAccessManager>
-#include <QNetworkCookieJar>
-
-#include <QUrlQuery>
-#include <QHttpMultiPart>
-#include <QFile>
-#include <QBuffer>
-#include <QDebug>
-#include <QMessageBox>
-#include <QInputDialog>
-#include <QLoggingCategory>
-#ifdef USE_WEBENGINE
-#include <QWebEngineView>
-#else
-#include <QWebView>
-#endif
-#include "mainwindow.h"
-#include "profile-widget/profilewidget2.h"
-
-#include "core/pref.h"
-#include "core/qthelper.h"
-#include "core/settings/qPrefFacebook.h"
-
-#include "ui_socialnetworksdialog.h"
-#include "ui_facebookconnectwidget.h"
-
-Q_LOGGING_CATEGORY(lcFacebook, "subsurface.facebook")
-
-FacebookManager *FacebookManager::instance()
-{
- static FacebookManager *self = new FacebookManager();
- return self;
-}
-
-FacebookManager::FacebookManager(QObject *parent) :
- QObject(parent),
- manager(new QNetworkAccessManager(this))
-{
- // log only in verbose mode
- QLoggingCategory::setFilterRules(QStringLiteral("subsurface.facebook=%1").arg(verbose ? "true" : "false"));
- connect(this, &FacebookManager::albumIdReceived, this, &FacebookManager::sendDiveToAlbum);
-}
-
-static QString graphApi = QStringLiteral("https://graph.facebook.com/v2.10/");
-
-QUrl FacebookManager::albumListUrl()
-{
- return QUrl("https://graph.facebook.com/me/albums?access_token=" + QString(prefs.facebook.access_token));
-}
-
-QUrl FacebookManager::connectUrl() {
- return QUrl("https://www.facebook.com/dialog/oauth?"
- "client_id=427722490709000"
- "&redirect_uri=https://www.facebook.com/connect/login_success.html"
- "&response_type=token,granted_scopes"
- "&display=popup"
- "&scope=publish_actions,user_photos"
- );
-}
-
-bool FacebookManager::loggedIn() {
- return prefs.facebook.access_token != NULL;
-}
-
-void FacebookManager::tryLogin(const QUrl& loginResponse)
-{
- qCDebug(lcFacebook) << "Current url call" << loginResponse;
- QString result = loginResponse.toString();
- if (!result.contains("access_token")) {
- qCDebug(lcFacebook) << "Response without access token!";
- return;
- }
-
- if (result.contains("denied_scopes=publish_actions") || result.contains("denied_scopes=user_photos")) {
- qCDebug(lcFacebook) << "user did not allow us access" << result;
- return;
- }
-
- int from = result.indexOf("access_token=") + strlen("access_token=");
- int to = result.indexOf("&expires_in");
- QString securityToken = result.mid(from, to-from);
-
- qPrefFacebook::set_access_token(securityToken);
- qCDebug(lcFacebook) << "Got securityToken" << securityToken;
- requestUserId();
-}
-
-void FacebookManager::logout()
-{
- qPrefFacebook::set_access_token(QString());
- qPrefFacebook::set_user_id(QString());
- qPrefFacebook::set_album_id(QString());
- emit justLoggedOut(true);
-}
-
-void FacebookManager::requestAlbumId()
-{
- qCDebug(lcFacebook) << "Starting to request the album id" << albumListUrl();
- QNetworkReply *reply = manager->get(QNetworkRequest(albumListUrl()));
- connect(reply, &QNetworkReply::finished, this, &FacebookManager::albumListReceived);
-}
-
-void FacebookManager::albumListReceived()
-{
- qCDebug(lcFacebook) << "Reply for the album id";
- QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
- QJsonDocument albumsDoc = QJsonDocument::fromJson(reply->readAll());
- QJsonArray albumObj = albumsDoc.object().value("data").toArray();
-
- reply->deleteLater();
- foreach(const QJsonValue &v, albumObj){
- QJsonObject obj = v.toObject();
- if (obj.value("name").toString() == fbInfo.albumName) {
- qPrefFacebook::set_album_id(obj.value("id").toString());
- qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "already exists, using id" << obj.value("id").toString();
- emit albumIdReceived(qPrefFacebook::album_id());
- return;
- }
- }
-
- // No album with the name we requested, create a new one.
- createFacebookAlbum();
-}
-
-void FacebookManager::createFacebookAlbum()
-{
- qCDebug(lcFacebook) << "Album with name" << fbInfo.albumName << "doesn't exists, creating it.";
- QUrlQuery params;
- params.addQueryItem("name", fbInfo.albumName );
- params.addQueryItem("description", "Subsurface Album");
- params.addQueryItem("privacy", "{'value': 'SELF'}");
-
- QNetworkRequest request(albumListUrl());
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
-
- QNetworkReply *reply = manager->post(request, params.query().toUtf8());
- connect(reply, &QNetworkReply::finished, this, &FacebookManager::facebookAlbumCreated);
-}
-
-void FacebookManager::facebookAlbumCreated()
-{
- QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
- QJsonDocument albumsDoc = QJsonDocument::fromJson(reply->readAll());
- QJsonObject album = albumsDoc.object();
-
- reply->deleteLater();
-
- if (album.contains("id")) {
- qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "created successfully with id" << album.value("id").toString();
- 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;
- qCDebug(lcFacebook).noquote() << "Reply was: " << QString(albumsDoc.toJson(QJsonDocument::Indented));
- // 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'";
- emit albumIdReceived(qPrefFacebook::album_id());
- }
-}
-
-void FacebookManager::requestUserId()
-{
- qCDebug(lcFacebook) << "Requesting user id";
- QUrl userIdRequest("https://graph.facebook.com/me?fields=id&access_token=" + QString(prefs.facebook.access_token));
- QNetworkReply *reply = manager->get(QNetworkRequest(userIdRequest));
-
- 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")) {
- qCDebug(lcFacebook) << "User id requested successfully:" << obj.value("id").toString();
- qPrefFacebook::set_user_id(obj.value("id").toString());
- emit sendMessage(tr("Facebook logged in successfully"));
- emit justLoggedIn(true);
- } else {
- emit sendMessage(tr("Error, unknown user id, cannot login."));
- qCDebug(lcFacebook) << "Error, unknown user id, cannot login.";
- }
- reply->deleteLater();
-}
-
-QPixmap FacebookManager::grabProfilePixmap()
-{
- qCDebug(lcFacebook) << "Grabbing Dive Profile pixmap";
- ProfileWidget2 *profile = MainWindow::instance()->graphics;
-
- QSize size = fbInfo.profileSize == FacebookInfo::SMALL ? QSize(800,600) :
- fbInfo.profileSize == FacebookInfo::MEDIUM ? QSize(1024,760) :
- fbInfo.profileSize == FacebookInfo::BIG ? QSize(1280,1024) : QSize();
-
- auto currSize = profile->size();
- profile->resize(size);
- profile->setToolTipVisibile(false);
- QPixmap pix = profile->grab();
- profile->setToolTipVisibile(true);
- profile->resize(currSize);
-
- return pix;
-}
-
-
-/* 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::sendDiveInit()
-{
- qCDebug(lcFacebook) << "Starting to upload the dive to facebook";
-
- SocialNetworkDialog dialog(qApp->activeWindow());
- if (dialog.exec() != QDialog::Accepted) {
- qCDebug(lcFacebook) << "User cancelled.";
- return;
- }
-
- fbInfo.bodyText = dialog.text();
- fbInfo.profileSize = dialog.profileSize();
- fbInfo.profileData = grabProfilePixmap();
- fbInfo.albumName = dialog.album();
- fbInfo.albumId = QString(); // request Album Id wil handle that.
-
- // will emit albumIdReceived, that's connected to sendDiveToAlbum
- requestAlbumId();
-}
-
-void FacebookManager::sendDiveToAlbum(const QString& albumId)
-{
- qCDebug(lcFacebook) << "Starting to upload the dive to album" << fbInfo.albumName << "id" << albumId;
- QUrl url(graphApi + albumId + "/photos?" +
- "&access_token=" + QString(prefs.facebook.access_token) +
- "&source=image" +
- "&message=" + fbInfo.bodyText.replace("&quot;", "%22"));
-
- QNetworkRequest request(url);
-
- QString bound="margin";
-
- //according to rfc 1867 we need to put this string here:
- QByteArray data(QString("--" + bound + "\r\n").toUtf8());
- data.append("Content-Disposition: form-data; name=\"action\"\r\n\r\n");
- data.append(graphApi + "\r\n");
- data.append("--" + bound + "\r\n"); //according to rfc 1867
-
- //name of the input is "uploaded" in my form, next one is a file name.
- 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
-
- QByteArray bytes;
- QBuffer buffer(&bytes);
- buffer.open(QIODevice::WriteOnly);
- 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
-
- request.setRawHeader(QByteArray("Content-Type"),QString("multipart/form-data; boundary=" + bound).toUtf8());
- request.setRawHeader(QByteArray("Content-Length"), QString::number(data.length()).toUtf8());
- QNetworkReply *reply = manager->post(request,data);
-
- connect(reply, &QNetworkReply::finished, this, &FacebookManager::uploadFinished);
-}
-
-void FacebookManager::uploadFinished()
-{
- qCDebug(lcFacebook) << "Upload finish";
- auto reply = qobject_cast<QNetworkReply*>(sender());
- QByteArray response = reply->readAll();
- QJsonDocument jsonDoc = QJsonDocument::fromJson(response);
- QJsonObject obj = jsonDoc.object();
-
- reply->deleteLater();
-
- if (obj.keys().contains("id")){
- emit sendMessage(tr("Dive uploaded successfully to Facebook"));
- } else {
- emit sendMessage(tr("Dive upload failed. Please see debug output and send to Subsurface mailing list"));
- qCDebug(lcFacebook) << "Dive upload failed" << response;
- }
-
- emit sendDiveFinished();
-}
-
-void FacebookConnectWidget::showEvent(QShowEvent *event)
-{
- if (FacebookManager::instance()->loggedIn()) {
- facebookLoggedIn();
- } else {
- facebookDisconnect();
- }
- return QDialog::showEvent(event);
-}
-
-FacebookConnectWidget::FacebookConnectWidget(QWidget *parent) : QDialog(parent), ui(new Ui::FacebookConnectWidget) {
- ui->setupUi(this);
- FacebookManager *fb = FacebookManager::instance();
-#ifdef USE_WEBENGINE
- facebookWebView = new QWebEngineView(this);
-#else
- facebookWebView = new QWebView(this);
-#endif
- ui->fbWebviewContainer->layout()->addWidget(facebookWebView);
-#ifdef USE_WEBENGINE
- connect(facebookWebView, &QWebEngineView::urlChanged, fb, &FacebookManager::tryLogin);
-#else
- connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin);
-#endif
- connect(fb, &FacebookManager::justLoggedIn, this, &FacebookConnectWidget::facebookLoggedIn);
- connect(fb, &FacebookManager::justLoggedOut, this, &FacebookConnectWidget::facebookDisconnect);
-}
-
-void FacebookConnectWidget::facebookLoggedIn()
-{
- ui->fbWebviewContainer->hide();
- ui->fbWebviewContainer->setEnabled(false);
- ui->FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the 'Share on' menu entry."));
- close();
-}
-
-void FacebookConnectWidget::facebookDisconnect()
-{
- qCDebug(lcFacebook) << "Disconnecting from facebook";
- // remove the connect/disconnect button
- // and instead add the login view
- ui->fbWebviewContainer->show();
- ui->fbWebviewContainer->setEnabled(true);
- ui->FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline"));
- if (facebookWebView) {
-#ifdef USE_WEBENGINE
- //FIX ME
-#else
- facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
-#endif
- facebookWebView->setUrl(FacebookManager::instance()->connectUrl());
- }
-}
-
-SocialNetworkDialog::SocialNetworkDialog(QWidget *parent) :
- QDialog(parent),
- ui( new Ui::SocialnetworksDialog())
-{
- ui->setupUi(this);
- ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
- connect(ui->date, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->duration, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->Buddy, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->Divemaster, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->Location, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->Notes, &QCheckBox::clicked, this, &SocialNetworkDialog::selectionChanged);
- connect(ui->album, &QLineEdit::textChanged, this, &SocialNetworkDialog::albumChanged);
-}
-
-FacebookInfo::Size SocialNetworkDialog::profileSize() const
-{
- QString currText = ui->profileSize->currentText();
- return currText.startsWith(tr("Small")) ? FacebookInfo::SMALL :
- currText.startsWith(tr("Medium")) ? FacebookInfo::MEDIUM :
- /* currText.startsWith(tr("Big")) ? */ FacebookInfo::BIG;
-}
-
-
-void SocialNetworkDialog::albumChanged()
-{
- QAbstractButton *button = ui->buttonBox->button(QDialogButtonBox::Ok);
- button->setEnabled(!ui->album->text().isEmpty());
-}
-
-void SocialNetworkDialog::selectionChanged()
-{
- struct dive *d = current_dive;
- QString fullText;
-
- if (!d)
- return;
-
- if (ui->date->isChecked()) {
- fullText += tr("Dive date: %1 \n").arg(get_short_dive_date_string(d->when));
- }
- if (ui->duration->isChecked()) {
- fullText += tr("Duration: %1 \n").arg(get_dive_duration_string(d->duration.seconds,
- tr("h", "abbreviation for hours"),
- tr("min", "abbreviation for minutes")));
- }
- if (ui->Location->isChecked()) {
- fullText += tr("Dive location: %1 \n").arg(get_dive_location(d));
- }
- if (ui->Buddy->isChecked()) {
- fullText += tr("Buddy: %1 \n").arg(d->buddy);
- }
- if (ui->Divemaster->isChecked()) {
- fullText += tr("Divemaster: %1 \n").arg(d->divemaster);
- }
- if (ui->Notes->isChecked()) {
- fullText += tr("\n%1").arg(d->notes);
- }
- ui->text->setPlainText(fullText);
-}
-
-QString SocialNetworkDialog::text() const {
- return ui->text->toPlainText().toHtmlEscaped();
-}
-
-QString SocialNetworkDialog::album() const {
- return ui->album->text().toHtmlEscaped();
-}
-
-
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.h b/desktop-widgets/plugins/facebook/facebookconnectwidget.h
deleted file mode 100644
index ebaded04b..000000000
--- a/desktop-widgets/plugins/facebook/facebookconnectwidget.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#ifndef FACEBOOKCONNECTWIDGET_H
-#define FACEBOOKCONNECTWIDGET_H
-
-#include <QDialog>
-#include <QUrl>
-#ifdef USE_WEBENGINE
-class QWebEngineView;
-#else
-class QWebView;
-#endif
-class QNetworkReply;
-class QNetworkAccessManager;
-
-namespace Ui {
- class FacebookConnectWidget;
- class SocialnetworksDialog;
-}
-
-struct FacebookInfo {
- enum Size {SMALL, MEDIUM, BIG};
-
- QString bodyText;
- QString albumId;
- QString albumName;
- Size profileSize;
- QPixmap profileData;
-};
-
-class FacebookManager : public QObject
-{
- Q_OBJECT
-public:
- static FacebookManager *instance();
- void requestAlbumId();
- void requestUserId();
- QUrl connectUrl();
- QUrl albumListUrl();
- bool loggedIn();
- QPixmap grabProfilePixmap();
-
-signals:
- void justLoggedIn(bool triggererd);
- void justLoggedOut(bool triggered);
- void albumIdReceived(const QString& albumId);
- void sendDiveFinished();
- void sendMessage(const QString& message);
-
-public slots:
- void tryLogin(const QUrl& loginResponse);
- void logout();
- void sendDiveInit();
- void sendDiveToAlbum(const QString& album);
-
- void uploadFinished();
- void albumListReceived();
- void userIdReceived();
- void createFacebookAlbum();
- void facebookAlbumCreated();
-private:
- explicit FacebookManager(QObject *parent = 0);
- FacebookInfo fbInfo;
- QNetworkAccessManager *manager;
-};
-
-
-class FacebookConnectWidget : public QDialog {
- Q_OBJECT
-public:
- explicit FacebookConnectWidget(QWidget* parent = 0);
- void facebookLoggedIn();
- void facebookDisconnect();
- void showEvent(QShowEvent *event);
-private:
- Ui::FacebookConnectWidget *ui;
-#ifdef USE_WEBENGINE
- QWebEngineView *facebookWebView;
-#else
- QWebView *facebookWebView;
-#endif
-};
-
-class SocialNetworkDialog : public QDialog {
- Q_OBJECT
-public:
-
- SocialNetworkDialog(QWidget *parent = 0);
- QString text() const;
- QString album() const;
- FacebookInfo::Size profileSize() const;
-
-public slots:
- void selectionChanged();
- void albumChanged();
-private:
- Ui::SocialnetworksDialog *ui;
-};
-
-#endif
diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.ui b/desktop-widgets/plugins/facebook/facebookconnectwidget.ui
deleted file mode 100644
index b5caa5ab1..000000000
--- a/desktop-widgets/plugins/facebook/facebookconnectwidget.ui
+++ /dev/null
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FacebookConnectWidget</class>
- <widget class="QDialog" name="FacebookConnectWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>835</width>
- <height>698</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Preferences</string>
- </property>
- <property name="windowIcon">
- <iconset>
- <normalon>:subsurface-icon</normalon>
- </iconset>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <property name="leftMargin">
- <number>5</number>
- </property>
- <property name="topMargin">
- <number>5</number>
- </property>
- <property name="rightMargin">
- <number>5</number>
- </property>
- <property name="bottomMargin">
- <number>5</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="mainHorizontalLayout">
- <item>
- <widget class="QStackedWidget" name="stackedWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="facebook_page">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QVBoxLayout" name="fbLayout" stretch="0">
- <property name="spacing">
- <number>5</number>
- </property>
- <property name="leftMargin">
- <number>5</number>
- </property>
- <property name="topMargin">
- <number>5</number>
- </property>
- <property name="rightMargin">
- <number>5</number>
- </property>
- <property name="bottomMargin">
- <number>5</number>
- </property>
- <item>
- <widget class="QWidget" name="widget" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_9">
- <item>
- <widget class="QLabel" name="FBLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Connect to Facebook text placeholder</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QWidget" name="fbWebviewContainer" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_10"/>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/desktop-widgets/plugins/facebook/socialnetworksdialog.ui b/desktop-widgets/plugins/facebook/socialnetworksdialog.ui
deleted file mode 100644
index 2e68a2a99..000000000
--- a/desktop-widgets/plugins/facebook/socialnetworksdialog.ui
+++ /dev/null
@@ -1,189 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SocialnetworksDialog</class>
- <widget class="QDialog" name="SocialnetworksDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>591</width>
- <height>619</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
- <property name="margin">
- <number>1</number>
- </property>
- <item row="7" column="0">
- <widget class="QComboBox" name="profileSize">
- <item>
- <property name="text">
- <string>Small</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Medium</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Big</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>The text to the right will be posted as the description with your dive profile graph to Facebook. The album name is required (the profile graph will be posted to that album).</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Album</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLineEdit" name="album">
- <property name="toolTip">
- <string>The profile picture will be posted in this album (required)</string>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Include</string>
- </property>
- </widget>
- </item>
- <item row="9" column="0">
- <widget class="QCheckBox" name="date">
- <property name="text">
- <string>Date and time</string>
- </property>
- </widget>
- </item>
- <item row="10" column="0">
- <widget class="QCheckBox" name="duration">
- <property name="text">
- <string>Duration</string>
- </property>
- </widget>
- </item>
- <item row="11" column="0">
- <widget class="QCheckBox" name="Location">
- <property name="text">
- <string>Location</string>
- </property>
- </widget>
- </item>
- <item row="12" column="0">
- <widget class="QCheckBox" name="Divemaster">
- <property name="text">
- <string>Divemaster</string>
- </property>
- </widget>
- </item>
- <item row="13" column="0">
- <widget class="QCheckBox" name="Buddy">
- <property name="text">
- <string>Buddy</string>
- </property>
- </widget>
- </item>
- <item row="14" column="0">
- <widget class="QCheckBox" name="Notes">
- <property name="text">
- <string>Notes</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="label">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Facebook post preview</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1" rowspan="11">
- <widget class="QPlainTextEdit" name="text"/>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Image Size</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>SocialnetworksDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>SocialnetworksDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>