Rename PackageInterface -> Plugin

This commit is contained in:
Albert Vaca 2013-08-13 05:14:46 +02:00
parent 88fab1f333
commit 37de0654df
13 changed files with 34 additions and 45 deletions

View file

@ -9,7 +9,7 @@ set(kded_kdeconnect_SRCS
devicelinks/echodevicelink.cpp
devicelinks/tcpdevicelink.cpp
plugins/packageinterface.cpp
plugins/kdeconnectplugin.cpp
plugins/pluginloader.cpp
networkpackage.cpp

View file

@ -22,9 +22,6 @@
#include "networkpackage.h"
#include "plugins/packageinterface.h"
#include "plugins/pluginloader.h"
#include "linkproviders/broadcasttcplinkprovider.h"
#include "linkproviders/avahitcplinkprovider.h"
#include "linkproviders/loopbacklinkprovider.h"

View file

@ -39,7 +39,6 @@
#include <KConfig>
#include "device.h"
#include "plugins/packageinterface.h"
#include "devicelinks/devicelink.h"
#include "linkproviders/linkprovider.h"

View file

@ -10,6 +10,7 @@
#include <QDebug>
#include "plugins/kdeconnectplugin.h"
#include "plugins/pluginloader.h"
#include "devicelinks/devicelink.h"
#include "linkproviders/linkprovider.h"
@ -80,7 +81,7 @@ void Device::reloadPlugins()
qDebug() << pluginName << "enabled:" << enabled;
if (enabled) {
PackageInterface* plugin = loader->instantiatePluginForDevice(pluginName, this);
KdeConnectPlugin* plugin = loader->instantiatePluginForDevice(pluginName, this);
connect(this, SIGNAL(receivedPackage(const NetworkPackage&)),
plugin, SLOT(receivePackage(const NetworkPackage&)));

View file

@ -25,10 +25,9 @@
#include <QDBusConnection>
#include <QString>
#include <qvector.h>
#include "devicelinks/devicelink.h"
class DeviceLink;
class PackageInterface;
class KdeConnectPlugin;
class Device
: public QObject
@ -49,7 +48,7 @@ public:
//(not supported yet, do we need it or we can rely on the device presenging itself?)
//Device(const QString& id, DeviceLink* dl);
QString id() const{ return m_deviceId; }
QString id() const { return m_deviceId; }
QString name() const { return m_deviceName; }
//Add and remove links
@ -84,7 +83,7 @@ private:
QString m_deviceId;
QString m_deviceName;
QList<DeviceLink*> m_deviceLinks;
QList<PackageInterface*> m_plugins;
QList<KdeConnectPlugin*> m_plugins;
bool m_knownIdentiy;

View file

@ -1,5 +1,5 @@
install(FILES kdeconnect_package_interface.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
add_subdirectory(ping)

View file

@ -18,19 +18,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "packageinterface.h"
#include "kdeconnectplugin.h"
#include <QPointer>
#include "../device.h"
PackageInterface::PackageInterface(QObject* parent, const QVariantList& args)
KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args)
: QObject(parent)
{
mDevice = qvariant_cast< Device* >(args.first());
}
Device* PackageInterface::device()
Device* KdeConnectPlugin::device()
{
return mDevice;
}

View file

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PACKAGEINTERFACE_H
#define PACKAGEINTERFACE_H
#ifndef KDECONNECTPLUGIN_H
#define KDECONNECTPLUGIN_H
#include <QObject>
#include <QVariantList>
@ -31,18 +31,13 @@
#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
class KDE_EXPORT KdeConnectPlugin
: public QObject
{
Q_OBJECT
public:
PackageInterface(QObject* parent, const QVariantList& args);
virtual ~PackageInterface() { }
KdeConnectPlugin(QObject* parent, const QVariantList& args);
Device* device();
public Q_SLOTS:

View file

@ -3,8 +3,8 @@ include (KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(kdeconnect_ping_SRCS
pingpackageinterface.cpp
../packageinterface.cpp
pingplugin.cpp
../kdeconnectplugin.cpp
)
kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS})

View file

@ -18,22 +18,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pingpackageinterface.h"
#include "pingplugin.h"
#include <KNotification>
#include <KIcon>
#include <QDebug>
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPackageInterface >(); )
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PingPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_ping", "kdeconnect_ping") )
PingPackageInterface::PingPackageInterface(QObject* parent, const QVariantList& args)
: PackageInterface(parent, args)
PingPlugin::PingPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
qDebug() << "Plugin constructor for device" << device()->name();
}
bool PingPackageInterface::receivePackage(const NetworkPackage& np)
bool PingPlugin::receivePackage(const NetworkPackage& np)
{
if (np.type() != PACKAGE_TYPE_PING) return false;

View file

@ -18,21 +18,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PINGPACKAGEINTERFACE_H
#define PINGPACKAGEINTERFACE_H
#ifndef PINGPLUGIN_H
#define PINGPLUGIN_H
#include <QObject>
#include "../packageinterface.h"
#include "../kdeconnectplugin.h"
class KDE_EXPORT PingPackageInterface
: public PackageInterface
class KDE_EXPORT PingPlugin
: public KdeConnectPlugin
{
Q_OBJECT
public:
explicit PingPackageInterface(QObject *parent, const QVariantList &args);
explicit PingPlugin(QObject *parent, const QVariantList &args);
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);

View file

@ -20,8 +20,7 @@
#include "pluginloader.h"
#include "packageinterface.h"
#include "plugins/ping/pingpackageinterface.h"
#include "kdeconnectplugin.h"
#include <KServiceTypeTrader>
#include <KDebug>
@ -48,7 +47,7 @@ QStringList PluginLoader::getPluginList()
return plugins.keys();
}
PackageInterface* PluginLoader::instantiatePluginForDevice(QString id, Device* device) {
KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(QString id, Device* device) {
KService::Ptr service = plugins[id];
if (!service) {
@ -65,7 +64,7 @@ PackageInterface* PluginLoader::instantiatePluginForDevice(QString id, Device* d
QVariant deviceVariant;
deviceVariant.setValue<Device*>(device);
//FIXME: create<PackageInterface> return NULL
//FIXME: create<KdeConnectPlugin> return NULL
QObject *plugin = factory->create<QObject>(device, QVariantList() << deviceVariant);
if (!plugin) {
qDebug() << "Error loading plugin";
@ -73,6 +72,6 @@ PackageInterface* PluginLoader::instantiatePluginForDevice(QString id, Device* d
}
qDebug() << "Loaded plugin:" << service->name();
return (PackageInterface*)plugin;
return (KdeConnectPlugin*)plugin;
}

View file

@ -25,19 +25,18 @@
#include <QMap>
#include <QString>
#include "packageinterface.h"
#include <KPluginFactory>
#include <KService>
class Device;
class KdeConnectPlugin;
class PluginLoader
{
public:
static PluginLoader* instance();
PackageInterface* instantiatePluginForDevice(QString name, Device* device);
KdeConnectPlugin* instantiatePluginForDevice(QString name, Device* device);
QStringList getPluginList();
private: