mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
facebook: remove the featute from the code base
Remove from: - unit tests - desktop widgets - preferences - core intergration - cmakefiles - build scripts - icons - docs Also remove the plugins and social network integration. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
0c07b02974
commit
a1ffe115cf
41 changed files with 2 additions and 1671 deletions
|
@ -40,7 +40,6 @@ option(NO_PRINTING "disable the printing support" OFF)
|
|||
option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
|
||||
|
||||
#Options regarding enabling parts of subsurface
|
||||
option(FBSUPPORT "allow posting to Facebook" ON)
|
||||
option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
|
||||
option(FTDISUPPORT "enable support for libftdi based serial" OFF)
|
||||
option(USE_WEBENGINE "Use QWebEngine instead of QWebKit" OFF)
|
||||
|
@ -335,15 +334,10 @@ elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
|
|||
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
|
||||
endif()
|
||||
|
||||
if(FBSUPPORT)
|
||||
set(FACEBOOK_INTEGRATION facebook_integration)
|
||||
add_dependencies(facebook_integration subsurface_generated_ui)
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${SUBSURFACE_TARGET}
|
||||
subsurface_generated_ui
|
||||
subsurface_interface
|
||||
${FACEBOOK_INTEGRATION}
|
||||
subsurface_profile
|
||||
subsurface_statistics
|
||||
subsurface_models_desktop
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
Before Width: | Height: | Size: 33 KiB |
|
@ -2719,44 +2719,6 @@ There are two ways to export dive information from Subsurface:
|
|||
|
||||
- xref:S_Export_other[Export dive information to other destinations or formats]
|
||||
|
||||
[[S_Facebook]]
|
||||
=== Exporting dive information to _Facebook_
|
||||
|
||||
Export of dives to _Facebook_ is handled differently from other types of export because
|
||||
a connection to _Facebook_ is required, needing a _Facebook_ userID and password.
|
||||
From the *Main Menu*, select _Share on -> Connect to -> Facebook_ (image *A* below)
|
||||
A _Facebook_ login screen appears (image *B* below). Provide a _Facebook_ userID and password.
|
||||
From the _Subsurface_ window it’s easy to determine whether _Subsurface_ has a valid connection to _Facebook_:
|
||||
from the *Main Menu*, select _Share on_ (image *A*, below). Normally, the _Facebook_ option is greyed out. But
|
||||
if there is a connection to _Facebook_, this option is active (i.e. in black color and can be selected).
|
||||
|
||||
Once logged into to _Facebook_ , a panel is shown with a message:
|
||||
"_To disconnect Subsurface from your Facebook account, use the 'Share on' menu entry_."
|
||||
Close this message panel.
|
||||
|
||||
image::images/facebook1.jpg["Figure: Facebook login",align="center"]
|
||||
|
||||
Having established a login to _Facebook_, transferring a dive profile to a _Facebook_ timeline is easy.
|
||||
In the _Subsurface_ *Dive List* panel, highlight the dive to be transferred.
|
||||
Then, from the *Main Menu*, select _Share on -> Facebook_. A dialogue box
|
||||
is shown, determining the amount of additional information to be transferred
|
||||
with the dive profile (image *A*, below). To transfer a dive profile to _Facebook_, the name of a
|
||||
_Facebook_ album is needed. The checkboxes on the left hand side determine how much
|
||||
additional information is added to the dive profile, shown in the text box
|
||||
on the right hand side of the panel (image *A*, below). Customise the message that will be posted
|
||||
with the dive profile by editing any of the information. After specifying additional information
|
||||
and verifying the text, select the _OK_ button that triggers the transfer to _Facebook_. After the transfer
|
||||
is done, an acknowledgement dialogue appears, indicating it was successful.
|
||||
|
||||
Both the album created and the post to your timeline are marked as
|
||||
private. In order for friends to be able to see the post,
|
||||
log into _Facebook_ using a browser or Facebook app and change its permissions.
|
||||
|
||||
image::images/facebook2.jpg["Figure: Facebook data submission",align="center"]
|
||||
|
||||
If required, then close the _Facebook_ connection by selecting, from the *Main Menu*,
|
||||
_Share on -> Disconnect from -> Facebook_ (image *B* above).
|
||||
|
||||
[[S_Export_other]]
|
||||
=== Export dive information to other destinations or formats
|
||||
For non-_Facebook exports_, the export function can be found by selecting _File -> Export_, which brings up
|
||||
|
|
|
@ -2934,55 +2934,6 @@ Hay dos posibilidades de exportar información de buceo desde _Subsurface_:
|
|||
|
||||
- xref:S_Export_other[Exportar información de buceo a otros destinos o formatos]
|
||||
|
||||
[[S_Facebook]]
|
||||
=== Exportar información de buceo a _Facebook_
|
||||
|
||||
La exportación de inmersiones a _Facebook_ se maneja de forma diferente a otros
|
||||
tipos de exportación porque se requiere una
|
||||
conexión a esta red social y se necesita un usuario de _Facebook_ y su password.
|
||||
Si, desde el menú principal, seleccionamos _Compartir -> Conectar a ->
|
||||
Facebook_ (imagen *A* siguiente), se nos presentará una pantalla de acceso
|
||||
(imagen *B* a continuación). Introducimos nuestro usuario y password de
|
||||
_Facebook_.
|
||||
Desde la ventana de _Subsurface_ es fácil saber si se tiene una conexión válida
|
||||
con _Facebook_. Desde el *Menú principal*, selecciona _Compartir_
|
||||
(ver imagen *A* a continuación). Normalmente la opción _Facebook_ está
|
||||
desactivada, pero, si hay una conexión establecida, la opción está activa y
|
||||
puede ser seleccionada.
|
||||
Tras haber establecido una conexión con _Facebook_, se mostrará un panel con
|
||||
un mensaje: "_Para desconectar Subsurface de tu cuenta de Facebook, utiliza la
|
||||
entrada del menú 'Compartir'_."
|
||||
Cierra este panel.
|
||||
|
||||
image::images/facebook1.jpg["Figure: Facebook login",align="center"]
|
||||
|
||||
Habiendo establecido una conexión a _Facebook_, transferir un perfil al
|
||||
historial es fácil.
|
||||
Selecciona en la *Lista de Inmersiones* de _Subsurface_ el buceo que quieras
|
||||
transferir; entonces, desde el *Menú* selecciona _Compartir -> Facebook_,
|
||||
aparecerá un diálogo en el que se definirá la cantidad de información
|
||||
adicional que se desea compartir en el historial junto con el perfil (ver imagen
|
||||
*A*, a continuación). Se necesita proporcionar el nombre de un álbum de _Facebook_
|
||||
para poder enviar el perfil de inmersión. Las casillas seleccionables de la
|
||||
izquierda nos permiten seleccionar la información que vamos a enviar. Esta
|
||||
información se muestra en la ventana de texto de la derecha (ver imagen *A*
|
||||
a continuación). El mensaje que se va a enviar se puede editar directamente en
|
||||
esta ventana de texto. Tras haber elegido la información y verificado lo que se va
|
||||
a subir, se selecciona el botón _OK_ lo que inicia la transferencia a _Facebook_.
|
||||
Unos momentos después aparecerá un mensaje indicando una transferencia correcta.
|
||||
|
||||
El álbum creado y el post al historial se marcarán como privados. Para que
|
||||
los amigos puedan ver el post habrá que cambiar los permisos desde un acceso
|
||||
normal a _Facebook_ desde un navegador o desde la app de _Facebook_. Aunque
|
||||
esto suponga un paso de más, los desarrolladores entienden que esta es la mejor
|
||||
solución para evitar subidas no deseadas en el historial público.
|
||||
|
||||
image::images/facebook2.jpg["Figure: Facebook data submission",align="center"]
|
||||
|
||||
Si se considera necesario, cierra la conexión a _Facebook_, seleccionando
|
||||
desde el *Menú principal*, _Compartir -> Desconectar de -> Facebook_ (imagen
|
||||
*B* anterior).
|
||||
|
||||
[[S_Export_other]]
|
||||
=== Exportar información de buceo a otros destinos o formatos
|
||||
Para exportar a otros destinos,
|
||||
|
|
|
@ -2987,53 +2987,6 @@ Il y a deux façons d'exporter des informations de plongée depuis Subsurface:
|
|||
- xref:S_Export_other[Exporter des informations de plongée vers d'autres
|
||||
destinations ou formats]
|
||||
|
||||
[[S_Facebook]]
|
||||
=== Export des informations de plongée vers _Facebook_
|
||||
|
||||
L'export des plongées vers _Facebook_ est géré différemment des autres types
|
||||
d'export car une connexion vers _Facebook_ est nécessaire, nécessitant un
|
||||
identifiant et un mot de passe. À partir du menu principal, sélectionnez
|
||||
_Partager sur -> Connecter à -> Facebook_ (image *A* ci-dessous). Un écran
|
||||
de connexion s'affiche (image *B* ci dessous). Entrez l'identifiant et le
|
||||
mot de passe _Facebook_. Depuis la fenêtre _Subsurface_, il est facile de
|
||||
vérifier si _Subsurface_ a une connection valide vers _Facebook_ : Depuis le
|
||||
"Menu principal", sélectionnez _Partager sur_ (image *A*
|
||||
ci-dessous). Normalement, l'option _Facebook_ est grisée. Mais si une
|
||||
connection vers _Facebook_ existe, cette option est active (c'est à dire
|
||||
écrit en noir et sélectionnable).
|
||||
|
||||
Once logged into to _Facebook_ , a panel is shown with a message: "_To
|
||||
disconnect Subsurface from your Facebook account, use the 'Share on' menu
|
||||
entry_." Close this message panel.
|
||||
|
||||
image::images/facebook1.jpg["Figure: Facebook login", align="center"]
|
||||
|
||||
Une fois qu'une connexion à _Facebook_ est établie, transférer un profil de
|
||||
plongée vers _Facebook_ est facile. Dans le panneau *Liste des plongées* de
|
||||
_Subsurface_, sélectionnez la plongée à transférer. Ensuite, à partir du
|
||||
*menu principal*, sélectionnez _Partager sur -> Facebook_. Une fenêtre
|
||||
s'affiche, pour déterminer quelles informations seront transférées avec le
|
||||
profil de plongée (image *A* ci-dessous). Pour transférer un profil de
|
||||
plongée vers _Facebook_, le nom d'un album _Facebook_ doit être fourni. Les
|
||||
cases à cocher sur la partie gauche permettent de sélectionner des
|
||||
informations supplémentaires à transférer avec le profil de plongée. Ces
|
||||
informations sont affichées dans le champs de texte sur la partie droite du
|
||||
panneau. (image *A* ci dessous). Personnalisez le message qui sera envoyé
|
||||
avec le profil de plongée en modifiant les informations. Une fois les
|
||||
informations supplémentaires ajoutées et vérifiées, sélectionner le bouton
|
||||
_OK_ qui effectue le transfert vers _Facebook_. Après le transfert, une
|
||||
fenêtre de confirmation apparait ,indiquant le succès du transfert.
|
||||
|
||||
À la fois l'album créé et la publication sur votre ligne temporelle seront
|
||||
marquées comme privés. Pour que vos amis puissent la voir, connectez-vous à
|
||||
_Facebook_ depuis un navigateur ou l'application Facebook et modifiez les
|
||||
permissions.
|
||||
|
||||
image::images/facebook2.jpg["Figure: Facebook data submission", align="center"]
|
||||
|
||||
If required, then close the _Facebook_ connection by selecting, from the
|
||||
*Main Menu*, _Share on -> Disconnect from -> Facebook_ (image *B* above).
|
||||
|
||||
[[S_Export_other]]
|
||||
=== Exporter des informations de plongée vers d'autres destinations ou formats
|
||||
For non-_Facebook exports_, the export function can be found by selecting
|
||||
|
|
|
@ -2545,49 +2545,6 @@ Er zijn twee manieren om duik informatie uit _Subsurface_ te exporteren:
|
|||
|
||||
- xref:S_Export_other[Exporteer duikinformatie naar andere bestemmingen of formaten]
|
||||
|
||||
[[S_Facebook]]
|
||||
=== Exporteer duikinformatie naar _Facebook_
|
||||
|
||||
Exporteren naar _Facebook_ werkt op een andere manier dan andere vormen van
|
||||
export, met name omdat er een verbinding met _Facebook_ aanwezig moet zijn die
|
||||
is ingelogd. Selecteer vanuit het hoofdmenu _Deel via -> Facebook_ (zie figuur
|
||||
*A* hieronder). Een inlogscherm voor _Facebook_ verschijnt (zie figuur
|
||||
*B* hieronder), en log in bij _Facebook_.
|
||||
|
||||
Het is eenvoudig te zien in het hoofdmenu of er een verbinding met _Facebook_
|
||||
actief is. In het _Deel via_ menu is de _Facebook knop_ grijs en niet-selecteerbaar
|
||||
als er geen verbinding is (figuur *A* hieronder).
|
||||
|
||||
Eenmaal ingelogd op _Facebook_ wordt er een paneel getoond met het bericht:
|
||||
"Gebruik het 'Deel via' menu om de verbinding van Subsurface met uw Facebook
|
||||
account te sluiten.". Sluit dit paneel.
|
||||
|
||||
image::images/facebook1.jpg["Figuur: Facebook login",align="center"]
|
||||
|
||||
Met de verbinding met _Facebook_ geactiveerd is het overdragen van een duik naar
|
||||
_Facebook_ eenvoudig. Selecteer eerst de duik in de *Duiklijst*. Selecteer dan
|
||||
uit het hoofdmenu _Deel via -> Facebook_. Er verschijnt een dialoog, waarin
|
||||
aangegeven kan worden welke informatie naast het duikprofiel, moet worden
|
||||
overgedragen naar _Facebook_ (zie figuur *A* hieronder).
|
||||
|
||||
Om een duikprofiel naar _Facebook_ te exporteren is de naam van een (foto) album
|
||||
nodig. De keuzevakjes aan de linker zijde bepalen welke data uit het logboek
|
||||
eveneens wordt geëxporteerd. Deze verschijnen in het tekst veld aan de rechter zijde,
|
||||
welke verder handmatig kan worden aangepast. Nadat alles naar wens is ingevuld,
|
||||
kan via de _OK_ knop de feitelijke export worden gedaan. Als de export gereed is
|
||||
volgt een bevestiging.
|
||||
|
||||
Zowel het album als de geëxporteerde profiel (met annotaties) is in _Facebook_ als
|
||||
privé aangemerkt, en de rechten van de geëxporteerde data moeten dus handmatig
|
||||
in _Facebook_ worden gezet zoals gewenst.
|
||||
|
||||
image::images/facebook2.jpg["Figuur: Facebook data submission",align="center"]
|
||||
|
||||
De verbinding met _Facebook_ kan nu worden afgesloten als dat gewenst is. Gebruik
|
||||
hiervoor uit het hoofdmenu _Deel via -> Verbinding verbreken met -> Facebook_ (
|
||||
figuur *B* hierboven).
|
||||
|
||||
|
||||
[[S_Export_other]]
|
||||
=== Exporteer duikinformatie naar andere bestemmingen of formaten
|
||||
Andere dan _Facebook_ exports kunnen gevonden worden door in het hoofdmenu
|
||||
|
|
|
@ -2824,44 +2824,6 @@ image::images/Filterpanel.jpg["Рисунок: Панель фильтров",al
|
|||
|
||||
- xref:S_Export_other[Экспорт данных погружения в другие форматы]
|
||||
|
||||
[[S_Facebook]]
|
||||
=== Экспорт информации о погружении в _Facebook_
|
||||
|
||||
Экспорт в _Facebook_ отличается от всех других видов экспорта, поскольку он требует подключения
|
||||
учетной записи, что в свою очередь требует от вас логин и пароль _Facebook_. Для авторизации
|
||||
необходимо в главном меню выбрать _Файл -> Настройки_ и там выбрать вкладку _Facebook_, на которой
|
||||
вам будет представлена форма авторизации (см. рисунок *А* слева внизу). Авторизуйтесь своими логином
|
||||
и паролем, после чего экран должен выглядеть как показано на рисунке *В*. При необходимости вы
|
||||
можете отключить _Subsurface_ от _Facebook_, нажав на соответствующую кнопку.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
image::images/facebook1.jpg["Рисунок: Авторизация Facebook",align="center"]
|
||||
|
||||
После того как соединение с _Facebook_ установлено, публикация профиля погружения в вашей Хронике не
|
||||
составит проблем. Выберите погружение в списке и убедитесь в том, что именно этот дайв должен быть
|
||||
опубликован. Нажмите кнопку с логотипом _Facebook_, расположенную в *Информационной панели* справа
|
||||
от поля _Примечания_ (см. рисунок *А* ниже). По нажатию на эту кнопку вам будет представлено окно, в
|
||||
котором вы можете выбрать какую дополнительную информацию опубликовать вместе с профилем погружения
|
||||
(рисунок *В*). Обязательным является только поле _Альбом_. Кроме указания стандартных параметров
|
||||
погружения, вы можете вручную отредактировать сопроводительный текст. Для отправки профиля
|
||||
погружения в вашу Хронику _Facebook_ нажмите кнопку _ОК_. Спустя короткое время вы должны получить
|
||||
подтверждение, что запись опубликована.
|
||||
|
||||
|
||||
Созданный альбом и запись в хронике по умолчанию будут доступны только вам. Для того, чтобы ваши
|
||||
друзья смогли увидеть эти записи, вам необходимо изменить настройки безопасности приложений,
|
||||
войдя в _Facebook_ с помощью обычного броузера или приложения _Facebook_. Возможно это и является
|
||||
некоторым неудобством, но разработчики придерживаются мнения, что такой дополнительный шаг позволит избежать нежелательных записей в вашей Хронике.
|
||||
|
||||
image::images/facebook2.jpg["Рисунок: Авторизация в Facebook",align="center"]
|
||||
|
||||
Разорвать соединение с _Facebook_ можно из *Настроек* приложения, либо просто закрыв _Subsurface_.
|
||||
|
||||
|
||||
[[S_Export_other]]
|
||||
=== Экспорт данных погружения в другие форматы
|
||||
Функция экспорта доступна через главное меню _Файл -> Экспорт_. Диалог
|
||||
|
|
|
@ -63,7 +63,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
git-access.c
|
||||
gpslocation.cpp
|
||||
imagedownloader.cpp
|
||||
isocialnetworkintegration.cpp
|
||||
libdivecomputer.c
|
||||
liquivision.c
|
||||
load-git.c
|
||||
|
@ -81,7 +80,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
import-csv.c
|
||||
planner.c
|
||||
plannernotes.c
|
||||
pluginmanager.cpp
|
||||
profile.c
|
||||
qthelper.cpp
|
||||
qt-init.cpp
|
||||
|
@ -108,7 +106,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
settings/qPrefDisplay.cpp
|
||||
settings/qPrefDiveComputer.cpp
|
||||
settings/qPrefDivePlanner.cpp
|
||||
settings/qPrefFacebook.cpp
|
||||
settings/qPrefGeneral.cpp
|
||||
settings/qPrefGeocoding.cpp
|
||||
settings/qPrefLanguage.cpp
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "isocialnetworkintegration.h"
|
||||
|
||||
//Hack for moc.
|
||||
ISocialNetworkIntegration::ISocialNetworkIntegration(QObject* parent) : QObject(parent)
|
||||
{
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef ISOCIALNETWORKINTEGRATION_H
|
||||
#define ISOCIALNETWORKINTEGRATION_H
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
/* This Interface represents a Plugin for Social Network integration,
|
||||
* with it you may be able to create plugins for facebook, instagram,
|
||||
* twitpic, google plus and any other thing you may imagine.
|
||||
*
|
||||
* We bundle facebook integration as an example.
|
||||
*/
|
||||
|
||||
class ISocialNetworkIntegration : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ISocialNetworkIntegration(QObject* parent = 0);
|
||||
|
||||
/*!
|
||||
* @name socialNetworkName
|
||||
* @brief The name of this social network
|
||||
* @return The name of this social network
|
||||
*
|
||||
* The name of this social network will be used to populate the Menu to toggle states
|
||||
* between connected/disconnected, and also submit stuff to it.
|
||||
*/
|
||||
virtual QString socialNetworkName() const = 0;
|
||||
|
||||
/*!
|
||||
* @name socialNetworkIcon
|
||||
* @brief The icon of this social network
|
||||
* @return The icon of this social network
|
||||
*
|
||||
* The icon of this social network will be used to populate the menu, and can also be
|
||||
* used on a toolbar if requested.
|
||||
*/
|
||||
virtual QString socialNetworkIcon() const = 0;
|
||||
|
||||
/*!
|
||||
* @name isConnected
|
||||
* @brief returns true if connected to this social network, false otherwise
|
||||
* @return true if connected to this social network, false otherwise
|
||||
*/
|
||||
virtual bool isConnected() = 0;
|
||||
|
||||
/*!
|
||||
* @name requestLogin
|
||||
* @brief try to login on this social network.
|
||||
*
|
||||
* Try to login on this social network. All widget implementation that
|
||||
* manages login should be done inside this function.
|
||||
*/
|
||||
virtual void requestLogin() = 0;
|
||||
|
||||
/*!
|
||||
* @name requestLogoff
|
||||
* @brief tries to logoff from this social network
|
||||
*
|
||||
* Try to logoff from this social network.
|
||||
*/
|
||||
virtual void requestLogoff() = 0;
|
||||
|
||||
/*!
|
||||
* @name uploadCurrentDive
|
||||
* @brief send the current dive info to the Social Network
|
||||
*
|
||||
* Should format all the options and pixmaps from the current dive
|
||||
* to update to the social network. All widget stuff related to sendint
|
||||
* dive information should be executed inside this function.
|
||||
*/
|
||||
virtual void requestUpload() = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "pluginmanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QPluginLoader>
|
||||
#include <QDebug>
|
||||
|
||||
static QList<ISocialNetworkIntegration*> _socialNetworks;
|
||||
|
||||
// no point in including dive.h for this
|
||||
extern int verbose;
|
||||
|
||||
PluginManager& PluginManager::instance()
|
||||
{
|
||||
static PluginManager self;
|
||||
return self;
|
||||
}
|
||||
|
||||
PluginManager::PluginManager()
|
||||
{
|
||||
}
|
||||
|
||||
void PluginManager::loadPlugins()
|
||||
{
|
||||
QDir pluginsDir(qApp->applicationDirPath());
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
|
||||
pluginsDir.cdUp();
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (pluginsDir.dirName() == "MacOS") {
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
}
|
||||
#endif
|
||||
pluginsDir.cd("plugins");
|
||||
|
||||
if (verbose)
|
||||
qDebug() << "Plugins Directory: " << pluginsDir;
|
||||
|
||||
foreach (const QString& fileName, pluginsDir.entryList(QDir::Files)) {
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *plugin = loader.instance();
|
||||
if(!plugin)
|
||||
continue;
|
||||
|
||||
if (ISocialNetworkIntegration *social = qobject_cast<ISocialNetworkIntegration*>(plugin)) {
|
||||
qDebug() << "Adding the plugin: " << social->socialNetworkName();
|
||||
_socialNetworks.push_back(social);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef PLUGINMANAGER_H
|
||||
#define PLUGINMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "isocialnetworkintegration.h"
|
||||
|
||||
class PluginManager {
|
||||
public:
|
||||
static PluginManager& instance();
|
||||
void loadPlugins();
|
||||
private:
|
||||
PluginManager();
|
||||
PluginManager(const PluginManager&);
|
||||
PluginManager& operator=(const PluginManager&);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -22,12 +22,6 @@ typedef struct
|
|||
double phe_threshold;
|
||||
} partial_pressure_graphs_t;
|
||||
|
||||
typedef struct {
|
||||
const char *access_token;
|
||||
const char *user_id;
|
||||
const char *album_id;
|
||||
} facebook_prefs_t;
|
||||
|
||||
typedef struct {
|
||||
enum taxonomy_category category[3];
|
||||
} geocoding_prefs_t;
|
||||
|
@ -111,9 +105,6 @@ struct preferences {
|
|||
double mobile_scale;
|
||||
bool show_developer;
|
||||
|
||||
// ********** Facebook **********
|
||||
facebook_prefs_t facebook;
|
||||
|
||||
// ********** General **********
|
||||
bool auto_recalculate_thumbnails;
|
||||
bool extract_video_thumbnails;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "qPrefDisplay.h"
|
||||
#include "qPrefDiveComputer.h"
|
||||
#include "qPrefDivePlanner.h"
|
||||
#include "qPrefFacebook.h"
|
||||
#include "qPrefGeneral.h"
|
||||
#include "qPrefGeocoding.h"
|
||||
#include "qPrefLanguage.h"
|
||||
|
@ -51,7 +50,6 @@ void qPref::loadSync(bool doSync)
|
|||
qPrefDisplay::loadSync(doSync);
|
||||
qPrefDiveComputer::loadSync(doSync);
|
||||
qPrefDivePlanner::loadSync(doSync);
|
||||
qPrefFacebook::loadSync(doSync);
|
||||
qPrefGeneral::loadSync(doSync);
|
||||
qPrefGeocoding::loadSync(doSync);
|
||||
qPrefLanguage::loadSync(doSync);
|
||||
|
@ -76,7 +74,6 @@ void qPref::registerQML(QQmlEngine *engine)
|
|||
ct->setContextProperty("PrefDisplay", qPrefDisplay::instance());
|
||||
ct->setContextProperty("PrefDiveComputer", qPrefDiveComputer::instance());
|
||||
ct->setContextProperty("PrefDivePlanner", qPrefDivePlanner::instance());
|
||||
ct->setContextProperty("PrefFacebook", qPrefFacebook::instance());
|
||||
ct->setContextProperty("PrefGeneral", qPrefGeneral::instance());
|
||||
ct->setContextProperty("PrefGeocoding", qPrefGeocoding::instance());
|
||||
ct->setContextProperty("PrefLanguage", qPrefLanguage::instance());
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "qPrefFacebook.h"
|
||||
#include "qPrefPrivate.h"
|
||||
|
||||
static const QString group = QStringLiteral("WebApps/Facebook");
|
||||
|
||||
qPrefFacebook::qPrefFacebook(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
qPrefFacebook*qPrefFacebook::instance()
|
||||
{
|
||||
static qPrefFacebook *self = new qPrefFacebook;
|
||||
return self;
|
||||
}
|
||||
|
||||
void qPrefFacebook::loadSync(bool doSync)
|
||||
{
|
||||
// Empty, because FB probs are not loaded/synced to disk
|
||||
}
|
||||
|
||||
void qPrefFacebook::set_access_token(const QString &value)
|
||||
{
|
||||
if (value != prefs.facebook.access_token) {
|
||||
qPrefPrivate::copy_txt(&prefs.facebook.access_token, value);
|
||||
emit instance()->access_tokenChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void qPrefFacebook::set_album_id(const QString &value)
|
||||
{
|
||||
if (value != prefs.facebook.album_id) {
|
||||
qPrefPrivate::copy_txt(&prefs.facebook.album_id, value);
|
||||
emit instance()->album_idChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void qPrefFacebook::set_user_id(const QString &value)
|
||||
{
|
||||
if (value != prefs.facebook.user_id) {
|
||||
qPrefPrivate::copy_txt(&prefs.facebook.user_id, value);
|
||||
emit instance()->user_idChanged(value);
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef QPREFSFACEBOOK_H
|
||||
#define QPREFSFACEBOOK_H
|
||||
#include "core/pref.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class qPrefFacebook : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString access_token READ access_token WRITE set_access_token NOTIFY access_tokenChanged);
|
||||
Q_PROPERTY(QString album_id READ album_id WRITE set_album_id NOTIFY album_idChanged);
|
||||
Q_PROPERTY(QString user_id READ user_id WRITE set_user_id NOTIFY user_idChanged);
|
||||
|
||||
public:
|
||||
qPrefFacebook(QObject *parent = NULL);
|
||||
static qPrefFacebook *instance();
|
||||
|
||||
// Load/Sync local settings (disk) and struct preference
|
||||
static void loadSync(bool doSync);
|
||||
static void load() {loadSync(false); }
|
||||
static void sync() {loadSync(true); }
|
||||
|
||||
public:
|
||||
static QString access_token() { return prefs.facebook.access_token; }
|
||||
static QString album_id() { return prefs.facebook.album_id; }
|
||||
static QString user_id() { return prefs.facebook.user_id; }
|
||||
|
||||
public slots:
|
||||
static void set_access_token(const QString& value);
|
||||
static void set_album_id(const QString& value);
|
||||
static void set_user_id(const QString& value);
|
||||
|
||||
signals:
|
||||
void access_tokenChanged(const QString& value);
|
||||
void album_idChanged(const QString& value);
|
||||
void user_idChanged(const QString& value);
|
||||
|
||||
private:
|
||||
static void disk_access_token(bool doSync);
|
||||
static void disk_album_id(bool doSync);
|
||||
static void disk_user_id(bool doSync);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -77,11 +77,6 @@ struct preferences default_prefs = {
|
|||
.pscr_ratio = 100,
|
||||
.show_pictures_in_profile = true,
|
||||
.tankbar = false,
|
||||
.facebook = {
|
||||
.user_id = NULL,
|
||||
.album_id = NULL,
|
||||
.access_token = NULL
|
||||
},
|
||||
.defaultsetpoint = 1100,
|
||||
.geocoding = {
|
||||
.category = { 0 }
|
||||
|
@ -312,9 +307,6 @@ void copy_prefs(struct preferences *src, struct preferences *dest)
|
|||
dest->cloud_storage_password = copy_string(src->cloud_storage_password);
|
||||
dest->cloud_storage_email = copy_string(src->cloud_storage_email);
|
||||
dest->cloud_storage_email_encoded = copy_string(src->cloud_storage_email_encoded);
|
||||
dest->facebook.access_token = copy_string(src->facebook.access_token);
|
||||
dest->facebook.user_id = copy_string(src->facebook.user_id);
|
||||
dest->facebook.album_id = copy_string(src->facebook.album_id);
|
||||
dest->ffmpeg_executable = copy_string(src->ffmpeg_executable);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -137,18 +137,11 @@
|
|||
<string>&Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuShare_on">
|
||||
<property name="title">
|
||||
<string>Share o&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 &Edit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFacebook">
|
||||
<property name="text">
|
||||
<string>Facebook</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCloudOnline">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
add_subdirectory(facebook)
|
|
@ -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()
|
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -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(""", "%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();
|
||||
}
|
||||
|
||||
|
|
@ -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
|
|
@ -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>
|
|
@ -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>
|
Binary file not shown.
Before Width: | Height: | Size: 150 KiB |
|
@ -419,7 +419,6 @@ cmake $MOBILE_CMAKE \
|
|||
-DNO_PRINTING=ON \
|
||||
-DNO_USERMANUAL=ON \
|
||||
-DNO_DOCS=ON \
|
||||
-DFBSUPPORT=OFF \
|
||||
-DCMAKE_PREFIX_PATH:UNINITIALIZED="$QT5_ANDROID_CMAKE" \
|
||||
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
||||
-DMAKE_TESTS=OFF \
|
||||
|
|
|
@ -29,9 +29,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \
|
|||
../../core/exif.cpp \
|
||||
../../core/format.cpp \
|
||||
../../core/gettextfromc.cpp \
|
||||
../../core/isocialnetworkintegration.cpp \
|
||||
../../core/metrics.cpp \
|
||||
../../core/pluginmanager.cpp \
|
||||
../../core/qt-init.cpp \
|
||||
../../core/subsurfacesysinfo.cpp \
|
||||
../../core/windowtitleupdate.cpp \
|
||||
|
@ -82,7 +80,6 @@ SOURCES += ../../subsurface-mobile-main.cpp \
|
|||
../../core/settings/qPrefDisplay.cpp \
|
||||
../../core/settings/qPrefDiveComputer.cpp \
|
||||
../../core/settings/qPrefDivePlanner.cpp \
|
||||
../../core/settings/qPrefFacebook.cpp \
|
||||
../../core/settings/qPrefGeneral.cpp \
|
||||
../../core/settings/qPrefGeocoding.cpp \
|
||||
../../core/settings/qPrefLanguage.cpp \
|
||||
|
@ -178,10 +175,8 @@ HEADERS += \
|
|||
../../core/gaspressures.h \
|
||||
../../core/gettext.h \
|
||||
../../core/gettextfromc.h \
|
||||
../../core/isocialnetworkintegration.h \
|
||||
../../core/membuffer.h \
|
||||
../../core/metrics.h \
|
||||
../../core/pluginmanager.h \
|
||||
../../core/qt-gui.h \
|
||||
../../core/sha1.h \
|
||||
../../core/strndup.h \
|
||||
|
@ -202,7 +197,6 @@ HEADERS += \
|
|||
../../core/settings/qPrefDisplay.h \
|
||||
../../core/settings/qPrefDiveComputer.h \
|
||||
../../core/settings/qPrefDivePlanner.h \
|
||||
../../core/settings/qPrefFacebook.h \
|
||||
../../core/settings/qPrefGeneral.h \
|
||||
../../core/settings/qPrefGeocoding.h \
|
||||
../../core/settings/qPrefLanguage.h \
|
||||
|
|
|
@ -392,9 +392,9 @@ fi
|
|||
cd $SRC
|
||||
|
||||
if [ "$BUILD_WITH_WEBKIT" = "1" ]; then
|
||||
EXTRA_OPTS="-DNO_USERMANUAL=OFF -DFBSUPPORT=ON"
|
||||
EXTRA_OPTS="-DNO_USERMANUAL=OFF"
|
||||
else
|
||||
EXTRA_OPTS="-DNO_USERMANUAL=ON -DFBSUPPORT=OFF"
|
||||
EXTRA_OPTS="-DNO_USERMANUAL=ON"
|
||||
fi
|
||||
|
||||
if [ "$BUILDGRANTLEE" = "1" ] ; then
|
||||
|
|
|
@ -141,7 +141,6 @@ fi
|
|||
|
||||
cmake -DBTSUPPORT=OFF \
|
||||
-DCMAKE_BUILD_TYPE="$RELEASE" \
|
||||
-DFBSUPPORT=OFF \
|
||||
-DFORCE_LIBSSH=OFF \
|
||||
-DFTDISUPPORT=OFF \
|
||||
-DMAKE_TESTS=OFF \
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "mobile-widgets/qml/kirigami/src/kirigamiplugin.h"
|
||||
#else
|
||||
#include "desktop-widgets/mainwindow.h"
|
||||
#include "core/pluginmanager.h"
|
||||
#endif
|
||||
|
||||
#ifndef SUBSURFACE_TEST_DATA
|
||||
|
@ -41,7 +40,6 @@ void init_ui()
|
|||
register_meta_types();
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
register_qml_types(NULL);
|
||||
PluginManager::instance().loadPlugins();
|
||||
|
||||
MainWindow *window = new MainWindow();
|
||||
window->setTitle();
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
<file alias="dc-ostc-3-icon">icons/ostc3.png</file>
|
||||
<file alias="dc-ostc-4-icon">icons/ostc4.png</file>
|
||||
<file alias="dc-suunto-vyper-icon">icons/suunto_vyper.png</file>
|
||||
<file alias="facebook-icon">icons/facebook.png</file>
|
||||
<file alias="duplicate-geotag-icon">icons/georeference.png</file>
|
||||
<file alias="edit-clear-icon">icons/edit-undo.svg</file>
|
||||
<file alias="show-icon">icons/go-top.svg</file>
|
||||
|
|
|
@ -108,7 +108,6 @@ TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp)
|
|||
TEST(TestQPrefDisplay testqPrefDisplay.cpp)
|
||||
TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp)
|
||||
TEST(TestQPrefDivePlanner testqPrefDivePlanner.cpp)
|
||||
TEST(TestQPrefFacebook testqPrefFacebook.cpp)
|
||||
TEST(TestQPrefGeneral testqPrefGeneral.cpp)
|
||||
TEST(TestQPrefGeocoding testqPrefGeocoding.cpp)
|
||||
TEST(TestQPrefLanguage testqPrefLanguage.cpp)
|
||||
|
@ -139,7 +138,6 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
|||
TestQPrefDisplay
|
||||
TestQPrefDiveComputer
|
||||
TestQPrefDivePlanner
|
||||
TestQPrefFacebook
|
||||
TestQPrefGeneral
|
||||
TestQPrefGeocoding
|
||||
TestQPrefLanguage
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "testqPrefFacebook.h"
|
||||
|
||||
#include "core/settings/qPrefFacebook.h"
|
||||
#include "core/pref.h"
|
||||
#include "core/qthelper.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QSignalSpy>
|
||||
|
||||
void TestQPrefFacebook::initTestCase()
|
||||
{
|
||||
QCoreApplication::setOrganizationName("Subsurface");
|
||||
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
||||
QCoreApplication::setApplicationName("SubsurfaceTestQPrefFacebook");
|
||||
}
|
||||
|
||||
void TestQPrefFacebook::test_struct_get()
|
||||
{
|
||||
// Test struct pref -> get func.
|
||||
|
||||
auto tst = qPrefFacebook::instance();
|
||||
|
||||
prefs.facebook.access_token = copy_qstring("t1 token");
|
||||
prefs.facebook.album_id = copy_qstring("t1 album");
|
||||
prefs.facebook.user_id = copy_qstring("t1 user");
|
||||
|
||||
QCOMPARE(tst->access_token(), QString(prefs.facebook.access_token));
|
||||
QCOMPARE(tst->album_id(), QString(prefs.facebook.album_id));
|
||||
QCOMPARE(tst->user_id(), QString(prefs.facebook.user_id));
|
||||
}
|
||||
|
||||
void TestQPrefFacebook::test_set_struct()
|
||||
{
|
||||
// Test set func -> struct pref
|
||||
|
||||
auto tst = qPrefFacebook::instance();
|
||||
|
||||
tst->set_access_token("t2 token");
|
||||
tst->set_album_id("t2 album");
|
||||
tst->set_user_id("t2 user");
|
||||
|
||||
QCOMPARE(QString(prefs.facebook.access_token), QString("t2 token"));
|
||||
QCOMPARE(QString(prefs.facebook.album_id), QString("t2 album"));
|
||||
QCOMPARE(QString(prefs.facebook.user_id), QString("t2 user"));
|
||||
}
|
||||
|
||||
void TestQPrefFacebook::test_multiple()
|
||||
{
|
||||
// test multiple instances have the same information
|
||||
|
||||
auto tst_direct = new qPrefFacebook;
|
||||
prefs.facebook.access_token = copy_qstring("test 1");
|
||||
|
||||
auto tst = qPrefFacebook::instance();
|
||||
prefs.facebook.album_id = copy_qstring("test 2");
|
||||
|
||||
QCOMPARE(tst->access_token(), tst_direct->access_token());
|
||||
QCOMPARE(tst->access_token(), QString("test 1"));
|
||||
QCOMPARE(tst->album_id(), tst_direct->album_id());
|
||||
QCOMPARE(tst->album_id(), QString("test 2"));
|
||||
}
|
||||
|
||||
#define TEST(METHOD, VALUE) \
|
||||
QCOMPARE(METHOD, VALUE); \
|
||||
fb->sync(); \
|
||||
fb->load(); \
|
||||
QCOMPARE(METHOD, VALUE);
|
||||
|
||||
void TestQPrefFacebook::test_oldPreferences()
|
||||
{
|
||||
auto fb = qPrefFacebook::instance();
|
||||
fb->set_access_token("rand-access-token");
|
||||
fb->set_user_id("tomaz-user-id");
|
||||
fb->set_album_id("album-id");
|
||||
|
||||
TEST(fb->access_token(),QStringLiteral("rand-access-token"));
|
||||
TEST(fb->user_id(), QStringLiteral("tomaz-user-id"));
|
||||
TEST(fb->album_id(), QStringLiteral("album-id"));
|
||||
|
||||
fb->set_access_token("rand-access-token-2");
|
||||
fb->set_user_id("tomaz-user-id-2");
|
||||
fb->set_album_id("album-id-2");
|
||||
|
||||
TEST(fb->access_token(),QStringLiteral("rand-access-token-2"));
|
||||
TEST(fb->user_id(), QStringLiteral("tomaz-user-id-2"));
|
||||
TEST(fb->album_id(), QStringLiteral("album-id-2"));
|
||||
}
|
||||
|
||||
void TestQPrefFacebook::test_signals()
|
||||
{
|
||||
QSignalSpy spy1(qPrefFacebook::instance(), SIGNAL(access_tokenChanged(QString)));
|
||||
QSignalSpy spy2(qPrefFacebook::instance(), SIGNAL(album_idChanged(QString)));
|
||||
QSignalSpy spy3(qPrefFacebook::instance(), SIGNAL(user_idChanged(QString)));
|
||||
|
||||
qPrefFacebook::set_access_token("t_signal token");
|
||||
qPrefFacebook::set_album_id("t_signal album");
|
||||
qPrefFacebook::set_user_id("t_signal user");
|
||||
|
||||
QCOMPARE(spy1.count(), 1);
|
||||
QCOMPARE(spy2.count(), 1);
|
||||
QCOMPARE(spy3.count(), 1);
|
||||
QVERIFY(spy1.takeFirst().at(0).toString() == "t_signal token");
|
||||
QVERIFY(spy2.takeFirst().at(0).toString() == "t_signal album");
|
||||
QVERIFY(spy3.takeFirst().at(0).toString() == "t_signal user");
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestQPrefFacebook)
|
|
@ -1,20 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef TESTQPREFFACEBOOK_H
|
||||
#define TESTQPREFFACEBOOK_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class TestQPrefFacebook : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void test_struct_get();
|
||||
void test_set_struct();
|
||||
void test_multiple();
|
||||
void test_oldPreferences();
|
||||
void test_signals();
|
||||
};
|
||||
|
||||
#endif // TESTQPREFFACEBOOK_H
|
|
@ -1,46 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
import QtQuick 2.6
|
||||
import QtTest 1.2
|
||||
|
||||
TestCase {
|
||||
name: "qPrefFacebook"
|
||||
|
||||
function test_variables() {
|
||||
var x1 = PrefFacebook.access_token
|
||||
PrefFacebook.access_token = "my token"
|
||||
compare(PrefFacebook.access_token, "my token")
|
||||
|
||||
var x2 = PrefFacebook.album_id
|
||||
PrefFacebook.album_id = "my album"
|
||||
compare(PrefFacebook.album_id, "my album")
|
||||
|
||||
var x3 = PrefFacebook.user_id
|
||||
PrefFacebook.user_id = "my user"
|
||||
compare(PrefFacebook.user_id, "my user")
|
||||
}
|
||||
|
||||
Item {
|
||||
id: spyCatcher
|
||||
|
||||
property bool spy1 : false
|
||||
property bool spy2 : false
|
||||
property bool spy3 : false
|
||||
|
||||
Connections {
|
||||
target: PrefFacebook
|
||||
onAccess_tokenChanged: {spyCatcher.spy1 = true }
|
||||
onAlbum_idChanged: {spyCatcher.spy2 = true }
|
||||
onUser_idChanged: {spyCatcher.spy3 = true }
|
||||
}
|
||||
}
|
||||
|
||||
function test_signals() {
|
||||
PrefFacebook.access_token = "qml"
|
||||
PrefFacebook.album_id = "qml"
|
||||
PrefFacebook.user_id = "qml"
|
||||
|
||||
compare(spyCatcher.spy1, true)
|
||||
compare(spyCatcher.spy2, true)
|
||||
compare(spyCatcher.spy3, true)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue