diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 40f1e1812..82cd429da 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -2,49 +2,31 @@ set(kded_kdeconnect_SRCS linkproviders/linkprovider.cpp linkproviders/loopbacklinkprovider.cpp - linkproviders/avahitcplinkprovider.cpp + #linkproviders/avahitcplinkprovider.cpp linkproviders/broadcasttcplinkprovider.cpp devicelinks/devicelink.cpp devicelinks/echodevicelink.cpp devicelinks/tcpdevicelink.cpp - packageinterfaces/packageinterface.cpp - packageinterfaces/pingpackageinterface.cpp - packageinterfaces/notificationpackageinterface.cpp - packageinterfaces/pausemusicpackageinterface.cpp - packageinterfaces/clipboardpackageinterface.cpp - packageinterfaces/batterypackageinterface.cpp - packageinterfaces/mpriscontrolpackageinterface.cpp - packageinterfaces/devicebatteryinformation_p.cpp + plugins/packageinterface.cpp + plugins/pluginloader.cpp networkpackage.cpp daemon.cpp device.cpp ) +add_subdirectory(plugins) -qt4_add_dbus_interface( - kded_kdeconnect_SRCS - packageinterfaces/mprisdbusinterface.xml - mprisdbusinterface -) - -qt4_add_dbus_interface( - kded_kdeconnect_SRCS - packageinterfaces/propertiesInterface.xml - propertiesdbusinterface -) kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS}) target_link_libraries(kded_kdeconnect ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} - kdnssd + #kdnssd qjson ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QJSON_LIBRARY} ) macro (generate_and_install_dbus_interface main_project_target header_file output_xml_file) #OPTIONS qdbus_options @@ -86,20 +68,6 @@ generate_and_install_dbus_interface( OPTIONS -a ) -generate_and_install_dbus_interface( - kded_kdeconnect - packageinterfaces/devicebatteryinformation_p.h - org.kde.kdeconnect.device.battery.xml - OPTIONS -a -) - -generate_and_install_dbus_interface( - kded_kdeconnect - packageinterfaces/batterypackageinterface.h - org.kde.kdeconnect.battery.xml - OPTIONS -a -) - install(TARGETS kded_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES kdeconnect.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded) install(FILES kdeconnect.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kdeconnect) diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 375dd8bd2..9b947167f 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -22,12 +22,8 @@ #include "networkpackage.h" -#include "packageinterfaces/pingpackageinterface.h" -#include "packageinterfaces/notificationpackageinterface.h" -#include "packageinterfaces/pausemusicpackageinterface.h" -#include "packageinterfaces/clipboardpackageinterface.h" -#include "packageinterfaces/batterypackageinterface.h" -#include "packageinterfaces/mpriscontrolpackageinterface.h" +#include "plugins/packageinterface.h" +#include "plugins/pluginloader.h" #include "linkproviders/broadcasttcplinkprovider.h" #include "linkproviders/avahitcplinkprovider.h" @@ -51,25 +47,22 @@ Daemon::Daemon(QObject *parent, const QList&) KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc"); if (!config->group("myself").hasKey("id")) { - QString uid = QUuid::createUuid().toString(); - uid = uid.mid(1,uid.length()-2).replace("-","_"); - config->group("myself").writeEntry("id",uid); - qDebug() << uid; + QString uuid = QUuid::createUuid().toString(); + //uuids contain charcaters that are not exportable in dbus paths + uuid = uuid.mid(1, uuid.length() - 2).replace("-", "_"); + config->group("myself").writeEntry("id", uuid); + qDebug() << "My id:" << uuid; } //Debugging qDebug() << "Starting KdeConnect daemon"; - //TODO: Do not hardcode the load of the package interfaces - //use: https://techbase.kde.org/Development/Tutorials/Services/Plugins - mPackageInterfaces.push_back(new PingPackageInterface()); - mPackageInterfaces.push_back(new NotificationPackageInterface()); - mPackageInterfaces.push_back(new PauseMusicPackageInterface()); - mPackageInterfaces.push_back(new ClipboardPackageInterface()); - mPackageInterfaces.push_back(new BatteryPackageInterface(this)); - mPackageInterfaces.push_back(new MprisControlPackageInterface()); + //Load plugins + PluginLoader *loader = new PluginLoader(this); + connect(loader, SIGNAL(pluginLoaded(PackageInterface*)), this, SLOT(pluginLoaded(PackageInterface*))); + loader->loadAllPlugins(); - //TODO: Do not hardcode the load of the device locators + //Load backends (hardcoded by now) //use: https://techbase.kde.org/Development/Tutorials/Services/Plugins mLinkProviders.insert(new BroadcastTcpLinkProvider()); //mLinkProviders.insert(new AvahiTcpLinkProvider()); @@ -81,14 +74,14 @@ Daemon::Daemon(QObject *parent, const QList&) const QString defaultName("unnamed"); Q_FOREACH(const QString& id, list) { const KConfigGroup& data = known.group(id); - const QString& name = data.readEntry("name",defaultName); - Device* device = new Device(id,name); + const QString& name = data.readEntry("name", defaultName); + Device* device = new Device(id, name); mDevices[id] = device; Q_FOREACH (PackageInterface* pr, mPackageInterfaces) { - connect(device,SIGNAL(receivedPackage(const Device&, const NetworkPackage&)), - pr,SLOT(receivePackage(const Device&, const NetworkPackage&))); - connect(pr,SIGNAL(sendPackage(const NetworkPackage&)), - device,SLOT(sendPackage(const NetworkPackage&))); + connect(device, SIGNAL(receivedPackage(const Device&, const NetworkPackage&)), + pr, SLOT(receivePackage(const Device&, const NetworkPackage&))); + connect(pr, SIGNAL(sendPackage(const NetworkPackage&)), + device, SLOT(sendPackage(const NetworkPackage&))); } } @@ -98,8 +91,8 @@ Daemon::Daemon(QObject *parent, const QList&) Q_FOREACH (LinkProvider* a, mLinkProviders) { connect(network, SIGNAL(stateChanged(QNetworkSession::State)), a, SLOT(onNetworkChange(QNetworkSession::State))); - connect(a,SIGNAL(onConnectionReceived(NetworkPackage,DeviceLink*)), - this,SLOT(onNewDeviceLink(NetworkPackage,DeviceLink*))); + connect(a, SIGNAL(onConnectionReceived(NetworkPackage, DeviceLink*)), + this, SLOT(onNewDeviceLink(NetworkPackage, DeviceLink*))); } QDBusConnection::sessionBus().registerService("org.kde.kdeconnect"); @@ -130,6 +123,19 @@ QStringList Daemon::devices() return mDevices.keys(); } +void Daemon::pluginLoaded(PackageInterface* packageInterface) +{ + qDebug() << "PLUUUUUUUUUUUUUUUUGINLOADEEEEEEEEEEEEEEEEEEEEEEED"; + mPackageInterfaces.append(packageInterface); + Q_FOREACH(Device* device, mDevices) { + connect(device, SIGNAL(receivedPackage(const Device&, const NetworkPackage&)), + packageInterface, SLOT(receivePackage(const Device&, const NetworkPackage&))); + connect(packageInterface, SIGNAL(sendPackage(const NetworkPackage&)), + device, SLOT(sendPackage(const NetworkPackage&))); + } + +} + void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl) { const QString& id = identityPackage.get("deviceId"); @@ -158,11 +164,11 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* const QString& name = identityPackage.get("deviceName"); - Device* device = new Device(id,name,dl); + Device* device = new Device(id, name, dl); mDevices[id] = device; Q_FOREACH (PackageInterface* pr, mPackageInterfaces) { - connect(device,SIGNAL(receivedPackage(const Device&, const NetworkPackage&)), - pr,SLOT(receivePackage(const Device&, const NetworkPackage&))); + connect(device, SIGNAL(receivedPackage(const Device&, const NetworkPackage&)), + pr, SLOT(receivePackage(const Device&, const NetworkPackage&))); } Q_EMIT newDeviceAdded(id); } diff --git a/daemon/daemon.h b/daemon/daemon.h index 1077ccfcb..9e6a8bb07 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -39,7 +39,7 @@ #include #include "device.h" -#include "packageinterfaces/packageinterface.h" +#include "plugins/packageinterface.h" #include "devicelinks/devicelink.h" #include "linkproviders/linkprovider.h" @@ -72,6 +72,7 @@ Q_SIGNALS: private Q_SLOTS: void onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl); + void pluginLoaded(PackageInterface*); private: diff --git a/daemon/device.cpp b/daemon/device.cpp index f8869693d..b380a6850 100644 --- a/daemon/device.cpp +++ b/daemon/device.cpp @@ -1,12 +1,14 @@ #include "device.h" -#include -#include -#include "devicelinks/devicelink.h" -#include "linkproviders/linkprovider.h" -#include "packageinterfaces/devicebatteryinformation_p.h" + +#include +#include #include #include +#include "devicelinks/devicelink.h" +#include "linkproviders/linkprovider.h" +#include "networkpackage.h" + Device::Device(const QString& id, const QString& name) { m_deviceId = id; @@ -107,6 +109,9 @@ void Device::removeLink(DeviceLink* link) bool Device::sendPackage(const NetworkPackage& np) const { Q_FOREACH(DeviceLink* dl, m_deviceLinks) { + //TODO: Actually detect if a package is received or not, now when have TCP + //"ESTABLISHED" connections that look legit and return true when we use them, + //but that are actually broken if (dl->sendPackage(np)) return true; } return false; diff --git a/daemon/devicelinks/devicelink.h b/daemon/devicelinks/devicelink.h index a8b31258e..34a5dda51 100644 --- a/daemon/devicelinks/devicelink.h +++ b/daemon/devicelinks/devicelink.h @@ -23,8 +23,8 @@ #include -#include "networkpackage.h" +class NetworkPackage; class Device; class LinkProvider; diff --git a/daemon/devicelinks/tcpdevicelink.cpp b/daemon/devicelinks/tcpdevicelink.cpp index 913f283e3..798f805cd 100644 --- a/daemon/devicelinks/tcpdevicelink.cpp +++ b/daemon/devicelinks/tcpdevicelink.cpp @@ -19,14 +19,18 @@ */ #include "tcpdevicelink.h" + #include "linkproviders/linkprovider.h" +#include "networkpackage.h" TcpDeviceLink::TcpDeviceLink(const QString& d, LinkProvider* a, QTcpSocket* socket) : DeviceLink(d, a) { mSocket = socket; - connect(mSocket, SIGNAL(disconnected()), this, SLOT(deleteLater())); - connect(mSocket, SIGNAL(readyRead()), this, SLOT(dataReceived())); + connect(mSocket, SIGNAL(disconnected()), + this, SLOT(deleteLater())); + connect(mSocket, SIGNAL(readyRead()), + this, SLOT(dataReceived())); } bool TcpDeviceLink::sendPackage(const NetworkPackage& np) const @@ -46,7 +50,7 @@ void TcpDeviceLink::dataReceived() if (package.length() < 3) continue; NetworkPackage np(""); - NetworkPackage::unserialize(package,&np); + NetworkPackage::unserialize(package, &np); emit receivedPackage(np); diff --git a/daemon/linkproviders/broadcasttcplinkprovider.cpp b/daemon/linkproviders/broadcasttcplinkprovider.cpp index 688c4af3d..bbfd27423 100644 --- a/daemon/linkproviders/broadcasttcplinkprovider.cpp +++ b/daemon/linkproviders/broadcasttcplinkprovider.cpp @@ -20,12 +20,13 @@ #include "broadcasttcplinkprovider.h" -#include "devicelinks/tcpdevicelink.h" - #include #include #include +#include "devicelinks/tcpdevicelink.h" +#include "networkpackage.h" + BroadcastTcpLinkProvider::BroadcastTcpLinkProvider() { diff --git a/daemon/plugins/CMakeLists.txt b/daemon/plugins/CMakeLists.txt new file mode 100644 index 000000000..4467d269d --- /dev/null +++ b/daemon/plugins/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory(ping) diff --git a/daemon/plugins/battery/CMakeLists.txt b/daemon/plugins/battery/CMakeLists.txt new file mode 100644 index 000000000..b4583cfe2 --- /dev/null +++ b/daemon/plugins/battery/CMakeLists.txt @@ -0,0 +1,14 @@ + +generate_and_install_dbus_interface( + kded_kdeconnect + packageinterfaces/devicebatteryinformation_p.h + org.kde.kdeconnect.device.battery.xml + OPTIONS -a +) + +generate_and_install_dbus_interface( + kded_kdeconnect + packageinterfaces/batterypackageinterface.h + org.kde.kdeconnect.battery.xml + OPTIONS -a +) diff --git a/daemon/packageinterfaces/batterypackageinterface.cpp b/daemon/plugins/battery/batterypackageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/batterypackageinterface.cpp rename to daemon/plugins/battery/batterypackageinterface.cpp diff --git a/daemon/packageinterfaces/batterypackageinterface.h b/daemon/plugins/battery/batterypackageinterface.h similarity index 100% rename from daemon/packageinterfaces/batterypackageinterface.h rename to daemon/plugins/battery/batterypackageinterface.h diff --git a/daemon/packageinterfaces/devicebatteryinformation_p.cpp b/daemon/plugins/battery/devicebatteryinformation_p.cpp similarity index 100% rename from daemon/packageinterfaces/devicebatteryinformation_p.cpp rename to daemon/plugins/battery/devicebatteryinformation_p.cpp diff --git a/daemon/packageinterfaces/devicebatteryinformation_p.h b/daemon/plugins/battery/devicebatteryinformation_p.h similarity index 100% rename from daemon/packageinterfaces/devicebatteryinformation_p.h rename to daemon/plugins/battery/devicebatteryinformation_p.h diff --git a/daemon/packageinterfaces/clipboardpackageinterface.cpp b/daemon/plugins/clipboard/clipboardpackageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/clipboardpackageinterface.cpp rename to daemon/plugins/clipboard/clipboardpackageinterface.cpp diff --git a/daemon/packageinterfaces/clipboardpackageinterface.h b/daemon/plugins/clipboard/clipboardpackageinterface.h similarity index 100% rename from daemon/packageinterfaces/clipboardpackageinterface.h rename to daemon/plugins/clipboard/clipboardpackageinterface.h diff --git a/daemon/packageinterfaces/notificationpackageinterface.cpp b/daemon/plugins/eventnotifications/notificationpackageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/notificationpackageinterface.cpp rename to daemon/plugins/eventnotifications/notificationpackageinterface.cpp diff --git a/daemon/packageinterfaces/notificationpackageinterface.h b/daemon/plugins/eventnotifications/notificationpackageinterface.h similarity index 100% rename from daemon/packageinterfaces/notificationpackageinterface.h rename to daemon/plugins/eventnotifications/notificationpackageinterface.h diff --git a/daemon/plugins/mpris/CMakeLists.txt b/daemon/plugins/mpris/CMakeLists.txt new file mode 100644 index 000000000..e8ca6d1aa --- /dev/null +++ b/daemon/plugins/mpris/CMakeLists.txt @@ -0,0 +1,12 @@ + +qt4_add_dbus_interface( + kded_kdeconnect_SRCS + packageinterfaces/mprisdbusinterface.xml + mprisdbusinterface +) + +qt4_add_dbus_interface( + kded_kdeconnect_SRCS + packageinterfaces/propertiesInterface.xml + propertiesdbusinterface +) diff --git a/daemon/packageinterfaces/mpriscontrolpackageinterface.cpp b/daemon/plugins/mpris/mpriscontrolpackageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/mpriscontrolpackageinterface.cpp rename to daemon/plugins/mpris/mpriscontrolpackageinterface.cpp diff --git a/daemon/packageinterfaces/mpriscontrolpackageinterface.h b/daemon/plugins/mpris/mpriscontrolpackageinterface.h similarity index 100% rename from daemon/packageinterfaces/mpriscontrolpackageinterface.h rename to daemon/plugins/mpris/mpriscontrolpackageinterface.h diff --git a/daemon/packageinterfaces/mprisdbusinterface.xml b/daemon/plugins/mpris/mprisdbusinterface.xml similarity index 100% rename from daemon/packageinterfaces/mprisdbusinterface.xml rename to daemon/plugins/mpris/mprisdbusinterface.xml diff --git a/daemon/packageinterfaces/propertiesInterface.xml b/daemon/plugins/mpris/propertiesInterface.xml similarity index 100% rename from daemon/packageinterfaces/propertiesInterface.xml rename to daemon/plugins/mpris/propertiesInterface.xml diff --git a/daemon/packageinterfaces/packageinterface.cpp b/daemon/plugins/packageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/packageinterface.cpp rename to daemon/plugins/packageinterface.cpp diff --git a/daemon/packageinterfaces/packageinterface.h b/daemon/plugins/packageinterface.h similarity index 76% rename from daemon/packageinterfaces/packageinterface.h rename to daemon/plugins/packageinterface.h index 9578cc05d..4569087b5 100644 --- a/daemon/packageinterfaces/packageinterface.h +++ b/daemon/plugins/packageinterface.h @@ -23,10 +23,18 @@ #include -#include "networkpackage.h" -#include "device.h" +#include +#include +#include -class PackageInterface +#include "../networkpackage.h" +#include "../device.h" + +#define KDECONNECT_PLUGIN_EXPORT( c ) \ + K_PLUGIN_FACTORY( KdeConnectFactory, registerPlugin< c >(); ) \ + K_EXPORT_PLUGIN( KdeConnectFactory("c") ) + +class KDE_EXPORT PackageInterface : public QObject { Q_OBJECT @@ -37,9 +45,11 @@ public: public Q_SLOTS: //Returns true if it has handled the package in some way + //device.sendPackage can be used to send an answer back to the device virtual bool receivePackage(const Device& device, const NetworkPackage& np) = 0; Q_SIGNALS: + //Sends a package to *all* connected devices void sendPackage(const NetworkPackage& np); }; diff --git a/daemon/packageinterfaces/pausemusicpackageinterface.cpp b/daemon/plugins/pausemusic/pausemusicpackageinterface.cpp similarity index 100% rename from daemon/packageinterfaces/pausemusicpackageinterface.cpp rename to daemon/plugins/pausemusic/pausemusicpackageinterface.cpp diff --git a/daemon/packageinterfaces/pausemusicpackageinterface.h b/daemon/plugins/pausemusic/pausemusicpackageinterface.h similarity index 100% rename from daemon/packageinterfaces/pausemusicpackageinterface.h rename to daemon/plugins/pausemusic/pausemusicpackageinterface.h diff --git a/daemon/plugins/ping/CMakeLists.txt b/daemon/plugins/ping/CMakeLists.txt new file mode 100644 index 000000000..59259571e --- /dev/null +++ b/daemon/plugins/ping/CMakeLists.txt @@ -0,0 +1,20 @@ +find_package(KDE4 REQUIRED) +include (KDE4Defaults) +include_directories(${KDE4_INCLUDES}) + +set(kdeconnect_ping_SRCS + pingpackageinterface.cpp + ../packageinterface.cpp +) + +kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS}) + +target_link_libraries(kdeconnect_ping + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTNETWORK_LIBRARY} + qjson +) + +install(TARGETS kdeconnect_ping DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(FILES kdeconnect_ping.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/daemon/plugins/ping/kdeconnect_ping.desktop b/daemon/plugins/ping/kdeconnect_ping.desktop new file mode 100644 index 000000000..fe19ccdb8 --- /dev/null +++ b/daemon/plugins/ping/kdeconnect_ping.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KdeConnect/Plugin +X-KDE-Library=kdeconnect_ping +X-KDE-PluginInfo-Author=Albert Vaca +X-KDE-PluginInfo-Email=albertvaka@gmail.com +X-KDE-PluginInfo-Name=kdeconnect_ping +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com +X-KDE-PluginInfo-Category=Network +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +X-KDE-ParentApp=kdeconnect +X-KDE-Version=4.0 +Name=Ping +Comment=Send and receive pings diff --git a/daemon/packageinterfaces/pingpackageinterface.cpp b/daemon/plugins/ping/pingpackageinterface.cpp similarity index 82% rename from daemon/packageinterfaces/pingpackageinterface.cpp rename to daemon/plugins/ping/pingpackageinterface.cpp index b984fdd5b..4bc0a5370 100644 --- a/daemon/packageinterfaces/pingpackageinterface.cpp +++ b/daemon/plugins/ping/pingpackageinterface.cpp @@ -23,6 +23,15 @@ #include #include +K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPackageInterface >(); ) +K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_ping", "kdeconnect_ping") ) + +PingPackageInterface::PingPackageInterface(QObject* parent, const QVariantList& args) + : PackageInterface(parent) +{ + Q_UNUSED(args); +} + bool PingPackageInterface::receivePackage(const Device& device, const NetworkPackage& np) { diff --git a/daemon/packageinterfaces/pingpackageinterface.h b/daemon/plugins/ping/pingpackageinterface.h similarity index 87% rename from daemon/packageinterfaces/pingpackageinterface.h rename to daemon/plugins/ping/pingpackageinterface.h index 29dd64b12..5ad4474cb 100644 --- a/daemon/packageinterfaces/pingpackageinterface.h +++ b/daemon/plugins/ping/pingpackageinterface.h @@ -23,13 +23,16 @@ #include -#include "packageinterface.h" +#include "../packageinterface.h" -class PingPackageInterface +class KDE_EXPORT PingPackageInterface : public PackageInterface { + Q_OBJECT public: + explicit PingPackageInterface(QObject *parent, const QVariantList &args); + virtual bool receivePackage(const Device& device, const NetworkPackage& np); }; diff --git a/daemon/plugins/pluginloader.cpp b/daemon/plugins/pluginloader.cpp new file mode 100644 index 000000000..b6eaedc4d --- /dev/null +++ b/daemon/plugins/pluginloader.cpp @@ -0,0 +1,69 @@ +/** + * Copyright 2013 Albert Vaca + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "pluginloader.h" + +#include "packageinterface.h" + +#include +#include + +PluginLoader::PluginLoader(QObject * parent) + : QObject(parent) +{ +} + +PluginLoader::~PluginLoader() +{ +} + +void PluginLoader::loadAllPlugins() +{ + kDebug() << "Load all plugins"; + KService::List offers = KServiceTypeTrader::self()->query("KdeConnect/Plugin"); + + qDebug() << "LO TRAIGO DE OFERTA CHACHO" << offers; + + KService::List::const_iterator iter; + for(iter = offers.begin(); iter < offers.end(); ++iter) + { + QString error; + KService::Ptr service = *iter; + + KPluginFactory *factory = KPluginLoader(service->library()).factory(); + + if (!factory) + { + //KMessageBox::error(0, i18n("

KPluginFactory could not load the plugin:
%1

", + // service->library())); + kError(5001) << "KPluginFactory could not load the plugin:" << service->library(); + continue; + } + + PackageInterface *plugin = factory->create(this); + + if (plugin) { + kDebug() << "Load plugin:" << service->name(); + emit pluginLoaded(plugin); + } else { + kDebug() << error; + } + } +} \ No newline at end of file diff --git a/daemon/plugins/pluginloader.h b/daemon/plugins/pluginloader.h new file mode 100644 index 000000000..4ae29d22d --- /dev/null +++ b/daemon/plugins/pluginloader.h @@ -0,0 +1,42 @@ +/** + * Copyright 2013 Albert Vaca + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PACKAGEINTERFACELOADER_H +#define PACKAGEINTERFACELOADER_H + +#include + +#include "packageinterface.h" + + +class PluginLoader : public QObject +{ + Q_OBJECT + public: + PluginLoader(QObject * parent); + virtual ~PluginLoader(); + + void loadAllPlugins(); + + signals: + void pluginLoaded(PackageInterface * plugin); +}; + +#endif diff --git a/letsgo.sh b/letsgo.sh index fccdf733d..232072aba 100755 --- a/letsgo.sh +++ b/letsgo.sh @@ -9,6 +9,10 @@ export VERBOSE=1 if kdebuild; then + echo "--------BUILD DONE--------------" + + kbuildsycoca4 + killall kded4 2> /dev/null while killall -9 kded4 2> /dev/null; do true @@ -17,6 +21,8 @@ if kdebuild; then #qdbus org.kde.kded /kded unloadModule kdeconnect #qdbus org.kde.kded /kded loadModule kdeconnect + echo "--------STARTING KDED--------------" + kded4 --nofork # 2>&1 | grep -v "^kded(" & fi