summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-10-29 21:47:08 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:52 -0700
commit8dad3457ef1f412517c4d81f08ebd14680788ec3 (patch)
treefd98ffd89584e4fa7a295b0116e8594a94c92e07
parent391172240ae00e9729ddb9db1b2cd50be3feb51b (diff)
downloadsubsurface-8dad3457ef1f412517c4d81f08ebd14680788ec3.tar.gz
Make the skeleton Facebook plugin and make sure it is loaded
Currently we need to copy manually the plugin dynamic library to the /plugins folder. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--desktop-widgets/mainwindow.cpp4
-rw-r--r--desktop-widgets/plugins/facebook/CMakeLists.txt5
-rw-r--r--desktop-widgets/plugins/facebook/facebook_integration.cpp36
-rw-r--r--desktop-widgets/plugins/facebook/facebook_integration.h21
-rw-r--r--subsurface-core/isocialnetworkintegration.h2
-rw-r--r--subsurface-core/pluginmanager.cpp24
6 files changed, 78 insertions, 14 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 0150a7c6f..23b4fb9b0 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -256,15 +256,17 @@ MainWindow::MainWindow() : QMainWindow(),
#endif
if(PluginManager::instance().socialNetworkIntegrationPlugins().count()) {
- QMenu *connections = new QMenu();
+ QMenu *connections = new QMenu(tr("Connect to"));
for(ISocialNetworkIntegration *plugin : PluginManager::instance().socialNetworkIntegrationPlugins()){
QAction *toggle_connection = new QAction(this);
toggle_connection->setText(plugin->socialNetworkName());
toggle_connection->setIcon(QIcon(plugin->socialNetworkIcon()));
+ toggle_connection->setData(QVariant::fromValue(plugin));
QAction *share_on = new QAction(this);
share_on->setText(plugin->socialNetworkName());
share_on->setIcon(QIcon(plugin->socialNetworkIcon()));
+ share_on->setData(QVariant::fromValue(plugin));
ui.menuShare_on->addAction(share_on);
connections->addAction(toggle_connection);
}
diff --git a/desktop-widgets/plugins/facebook/CMakeLists.txt b/desktop-widgets/plugins/facebook/CMakeLists.txt
index cccfec1f5..8628bd070 100644
--- a/desktop-widgets/plugins/facebook/CMakeLists.txt
+++ b/desktop-widgets/plugins/facebook/CMakeLists.txt
@@ -1,5 +1,6 @@
set(FACEBOOK_PLUGIN_SRCS facebook_integration.cpp)
-add_library(facebook_integration ${FACEBOOK_PLUGIN_SRCS})
+add_library(facebook_integration SHARED ${FACEBOOK_PLUGIN_SRCS})
-target_link_libraries(facebook_integration subsurface_core ${QT_LIBRARIES})
+target_link_libraries(facebook_integration subsurface_corelib ${QT_LIBRARIES})
+add_dependencies(facebook_integration subsurface_corelib) \ No newline at end of file
diff --git a/desktop-widgets/plugins/facebook/facebook_integration.cpp b/desktop-widgets/plugins/facebook/facebook_integration.cpp
index e69de29bb..e9b2297a0 100644
--- a/desktop-widgets/plugins/facebook/facebook_integration.cpp
+++ b/desktop-widgets/plugins/facebook/facebook_integration.cpp
@@ -0,0 +1,36 @@
+#include "facebook_integration.h"
+
+FacebookPlugin::FacebookPlugin(QObject* parent): QObject(parent)
+{
+
+}
+
+bool FacebookPlugin::isConnected()
+{
+
+}
+
+void FacebookPlugin::requestLogin()
+{
+
+}
+
+void FacebookPlugin::requestLogoff()
+{
+
+}
+
+QString FacebookPlugin::socialNetworkIcon() const
+{
+ return QString();
+}
+
+QString FacebookPlugin::socialNetworkName() const
+{
+ return tr("Facebook");
+}
+
+void FacebookPlugin::uploadCurrentDive()
+{
+
+}
diff --git a/desktop-widgets/plugins/facebook/facebook_integration.h b/desktop-widgets/plugins/facebook/facebook_integration.h
index e69de29bb..a9d212e7e 100644
--- a/desktop-widgets/plugins/facebook/facebook_integration.h
+++ b/desktop-widgets/plugins/facebook/facebook_integration.h
@@ -0,0 +1,21 @@
+#ifndef FACEBOOK_INTEGRATION_H
+#define FACEBOOK_INTEGRATION_H
+
+#include "subsurface-core/isocialnetworkintegration.h"
+#include <QString>
+
+class FacebookPlugin : public QObject, public ISocialNetworkIntegration {
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.subsurface.plugins.ISocialNetworkIntegration")
+ Q_INTERFACES(ISocialNetworkIntegration)
+public:
+ explicit FacebookPlugin(QObject* parent = 0);
+ virtual bool isConnected();
+ virtual void requestLogin();
+ virtual void requestLogoff();
+ virtual QString socialNetworkIcon() const;
+ virtual QString socialNetworkName() const;
+ virtual void uploadCurrentDive();
+};
+
+#endif \ No newline at end of file
diff --git a/subsurface-core/isocialnetworkintegration.h b/subsurface-core/isocialnetworkintegration.h
index 97ff91dc2..778a171b3 100644
--- a/subsurface-core/isocialnetworkintegration.h
+++ b/subsurface-core/isocialnetworkintegration.h
@@ -68,5 +68,5 @@ public:
};
Q_DECLARE_INTERFACE(ISocialNetworkIntegration, "org.subsurface.ISocialNetworkIntegration.v1")
-
+Q_DECLARE_METATYPE(ISocialNetworkIntegration*);
#endif \ No newline at end of file
diff --git a/subsurface-core/pluginmanager.cpp b/subsurface-core/pluginmanager.cpp
index 290f43df0..5c0f22525 100644
--- a/subsurface-core/pluginmanager.cpp
+++ b/subsurface-core/pluginmanager.cpp
@@ -3,18 +3,22 @@
#include <QApplication>
#include <QDir>
#include <QPluginLoader>
+#include <QDebug>
static QList<ISocialNetworkIntegration*> _socialNetworks;
-PluginManager& PluginManager::instance() {
+PluginManager& PluginManager::instance()
+{
static PluginManager self;
return self;
}
-PluginManager::PluginManager() {
+PluginManager::PluginManager()
+{
}
-void PluginManager::loadPlugins() {
+void PluginManager::loadPlugins()
+{
QDir pluginsDir(qApp->applicationDirPath());
#if defined(Q_OS_WIN)
@@ -29,19 +33,19 @@ void PluginManager::loadPlugins() {
#endif
pluginsDir.cd("plugins");
+ qDebug() << "Plugins Directory: " << pluginsDir;
foreach (const QString& fileName, pluginsDir.entryList(QDir::Files)) {
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
- if(!plugin) {
+ if(!plugin)
continue;
- }
- if (ISocialNetworkIntegration *social = qobject_cast<ISocialNetworkIntegration*>(plugin)){
+ if (ISocialNetworkIntegration *social = qobject_cast<ISocialNetworkIntegration*>(plugin))
_socialNetworks.push_back(social);
- }
- }
+ }
}
-QList<ISocialNetworkIntegration*> PluginManager::socialNetworkIntegrationPlugins() const {
+QList<ISocialNetworkIntegration*> PluginManager::socialNetworkIntegrationPlugins() const
+{
return _socialNetworks;
-} \ No newline at end of file
+}