diff --git a/daemon/plugins/CMakeLists.txt b/daemon/plugins/CMakeLists.txt index fa90ebf82..5818863b6 100644 --- a/daemon/plugins/CMakeLists.txt +++ b/daemon/plugins/CMakeLists.txt @@ -4,4 +4,4 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) add_subdirectory(ping) add_subdirectory(pausemusic) add_subdirectory(mpriscontrol) - +add_subdirectory(clipboard) diff --git a/daemon/plugins/clipboard/CMakeLists.txt b/daemon/plugins/clipboard/CMakeLists.txt new file mode 100644 index 000000000..6ece9e21f --- /dev/null +++ b/daemon/plugins/clipboard/CMakeLists.txt @@ -0,0 +1,23 @@ +find_package(KDE4 REQUIRED) +include (KDE4Defaults) +include_directories(${KDE4_INCLUDES}) + +set(kdeconnect_clipboard_SRCS + clipboardplugin.cpp + ../kdeconnectplugin.cpp + ../pluginloader.cpp + ../../networkpackage.cpp + ../../device.cpp +) + +kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS}) + +target_link_libraries(kdeconnect_clipboard + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTNETWORK_LIBRARY} + qjson +) + +install(TARGETS kdeconnect_clipboard DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(FILES kdeconnect_clipboard.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/daemon/plugins/clipboard/clipboardpackageinterface.cpp b/daemon/plugins/clipboard/clipboardplugin.cpp similarity index 76% rename from daemon/plugins/clipboard/clipboardpackageinterface.cpp rename to daemon/plugins/clipboard/clipboardplugin.cpp index 1454bf8d0..94fd73e7f 100644 --- a/daemon/plugins/clipboard/clipboardpackageinterface.cpp +++ b/daemon/plugins/clipboard/clipboardplugin.cpp @@ -18,20 +18,24 @@ * along with this program. If not, see . */ -#include "clipboardpackageinterface.h" +#include "clipboardplugin.h" #include #include #include -ClipboardPackageInterface::ClipboardPackageInterface() +K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< ClipboardPlugin >(); ) +K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_clipboard", "kdeconnect_clipboard") ) + +ClipboardPlugin::ClipboardPlugin(QObject *parent, const QVariantList &args) + : KdeConnectPlugin(parent, args) { clipboard = QApplication::clipboard(); ignore_next_clipboard_change = false; connect(clipboard,SIGNAL(changed(QClipboard::Mode)),this,SLOT(clipboardChanged(QClipboard::Mode))); } -void ClipboardPackageInterface::clipboardChanged(QClipboard::Mode mode) +void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode) { if (mode != QClipboard::QClipboard::Clipboard) return; @@ -42,12 +46,12 @@ void ClipboardPackageInterface::clipboardChanged(QClipboard::Mode mode) //qDebug() << "ClipboardChanged"; NetworkPackage np(PACKAGE_TYPE_CLIPBOARD); np.set("content",clipboard->text()); - emit sendPackage(np); + device()->sendPackage(np); } -bool ClipboardPackageInterface::receivePackage(const Device& device, const NetworkPackage& np) +bool ClipboardPlugin::receivePackage(const NetworkPackage& np) { - Q_UNUSED(device); + qDebug() << "AAAAAAAAAAAAAAAAAA"; if (np.type() == PACKAGE_TYPE_CLIPBOARD) { ignore_next_clipboard_change = true; clipboard->setText(np.get("content")); diff --git a/daemon/plugins/clipboard/clipboardpackageinterface.h b/daemon/plugins/clipboard/clipboardplugin.h similarity index 75% rename from daemon/plugins/clipboard/clipboardpackageinterface.h rename to daemon/plugins/clipboard/clipboardplugin.h index bc896d755..3d065640f 100644 --- a/daemon/plugins/clipboard/clipboardpackageinterface.h +++ b/daemon/plugins/clipboard/clipboardplugin.h @@ -18,27 +18,26 @@ * along with this program. If not, see . */ -#ifndef CLIPBOARDPACKAGEINTERFACE_H -#define CLIPBOARDPACKAGEINTERFACE_H +#ifndef CLIPBOARDPLUGIN_H +#define CLIPBOARDPLUGIN_H #include #include -#include "networkpackage.h" -#include "device.h" -#include "packageinterface.h" +#include "../kdeconnectplugin.h" +#include "../../networkpackage.h" +#include "../../device.h" -class ClipboardPackageInterface - : public PackageInterface +class ClipboardPlugin + : public KdeConnectPlugin { Q_OBJECT public: - ClipboardPackageInterface(); - virtual ~ClipboardPackageInterface() { } + explicit ClipboardPlugin(QObject *parent, const QVariantList &args); public Q_SLOTS: - virtual bool receivePackage(const Device& device, const NetworkPackage& np); + virtual bool receivePackage(const NetworkPackage& np); private Q_SLOTS: void clipboardChanged(QClipboard::Mode mode); diff --git a/daemon/plugins/clipboard/kdeconnect_clipboard.desktop b/daemon/plugins/clipboard/kdeconnect_clipboard.desktop new file mode 100644 index 000000000..5cb09280b --- /dev/null +++ b/daemon/plugins/clipboard/kdeconnect_clipboard.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KdeConnect/Plugin +X-KDE-Library=kdeconnect_clipboard +X-KDE-PluginInfo-Author=Albert Vaca +X-KDE-PluginInfo-Email=albertvaka@gmail.com +X-KDE-PluginInfo-Name=kdeconnect_clipboard +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Icon=edit-paste +Name=Clipboard +Comment=Share the clipboard between devices diff --git a/daemon/plugins/mpriscontrol/mpriscontrolplugin.h b/daemon/plugins/mpriscontrol/mpriscontrolplugin.h index 656f7f482..acf3e822a 100644 --- a/daemon/plugins/mpriscontrol/mpriscontrolplugin.h +++ b/daemon/plugins/mpriscontrol/mpriscontrolplugin.h @@ -18,8 +18,8 @@ * along with this program. If not, see . */ -#ifndef MPRISCONTROLPACKAGEINTERFACE_H -#define MPRISCONTROLPACKAGEINTERFACE_H +#ifndef MPRISCONTROLPLUGIN_H +#define MPRISCONTROLPLUGIN_H #include #include @@ -45,10 +45,11 @@ private Q_SLOTS: void propertiesChanged(const QString& interface, const QVariantMap& properties); private: - QHash playerList; void addPlayer(const QString& ifaceName); void removePlayer(const QString& ifaceName); void sendPlayerList(); + + QHash playerList; int prevVolume; };