Reorganize sources
We broke kded into core and kded, core contains the library with the backends and plugins. Also we renamed libkdeconnect to interfaces.
This commit is contained in:
parent
807f90f132
commit
b88897847b
141 changed files with 165 additions and 183 deletions
|
@ -15,12 +15,14 @@ include(KDE4Defaults)
|
||||||
include_directories(${KDE4_INCLUDES})
|
include_directories(${KDE4_INCLUDES})
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_subdirectory(kded)
|
add_subdirectory(core)
|
||||||
add_subdirectory(libkdeconnect)
|
|
||||||
add_subdirectory(kcm)
|
add_subdirectory(kcm)
|
||||||
add_subdirectory(kio)
|
add_subdirectory(kio)
|
||||||
add_subdirectory(plasmoid)
|
|
||||||
add_subdirectory(icon)
|
add_subdirectory(icon)
|
||||||
|
add_subdirectory(interfaces)
|
||||||
|
|
||||||
|
add_subdirectory(kded)
|
||||||
|
add_subdirectory(plasmoid)
|
||||||
add_subdirectory(cli)
|
add_subdirectory(cli)
|
||||||
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
#include <kcmdlineargs.h>
|
#include <kcmdlineargs.h>
|
||||||
#include <kaboutdata.h>
|
#include <kaboutdata.h>
|
||||||
#include <libkdeconnect/devicesmodel.h>
|
#include <interfaces/devicesmodel.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
59
core/CMakeLists.txt
Normal file
59
core/CMakeLists.txt
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
project(KDEConnectCore)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
|
${QJSON_INCLUDE_DIR}
|
||||||
|
${QCA2_INCLUDE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(plugins)
|
||||||
|
|
||||||
|
add_subdirectory(backends/lan)
|
||||||
|
add_subdirectory(backends/loopback)
|
||||||
|
|
||||||
|
set(kded_kdeconnect_SRCS
|
||||||
|
${kded_kdeconnect_SRCS}
|
||||||
|
|
||||||
|
backends/linkprovider.cpp
|
||||||
|
backends/devicelink.cpp
|
||||||
|
|
||||||
|
plugins/kdeconnectplugin.cpp
|
||||||
|
plugins/pluginloader.cpp
|
||||||
|
|
||||||
|
networkpackage.cpp
|
||||||
|
filetransferjob.cpp
|
||||||
|
daemon.cpp
|
||||||
|
device.cpp
|
||||||
|
kdebugnamespace.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
kde4_add_library(kdeconnectcore SHARED ${kded_kdeconnect_SRCS})
|
||||||
|
target_link_libraries(kdeconnectcore
|
||||||
|
PUBLIC
|
||||||
|
${KDE4_KDECORE_LIBS}
|
||||||
|
|
||||||
|
PRIVATE
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
|
${QJSON_LIBRARIES}
|
||||||
|
${QT_QTNETWORK_LIBRARY}
|
||||||
|
${QCA2_LIBRARIES}
|
||||||
|
)
|
||||||
|
generate_export_header(kdeconnectcore EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectcore_export.h BASE_NAME KDEConnectCore)
|
||||||
|
|
||||||
|
include(../macros.cmake)
|
||||||
|
|
||||||
|
generate_and_install_dbus_interface(
|
||||||
|
kdeconnectcore
|
||||||
|
../core/daemon.h
|
||||||
|
org.kde.kdeconnect.daemon.xml
|
||||||
|
OPTIONS -a
|
||||||
|
)
|
||||||
|
|
||||||
|
generate_and_install_dbus_interface(
|
||||||
|
kdeconnectcore
|
||||||
|
../core/device.h
|
||||||
|
org.kde.kdeconnect.device.xml
|
||||||
|
OPTIONS -a
|
||||||
|
)
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QNetworkSession>
|
#include <QNetworkSession>
|
||||||
#include <QNetworkConfigurationManager>
|
#include <QNetworkConfigurationManager>
|
||||||
|
#include <QtCrypto>
|
||||||
|
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
|
@ -35,8 +36,27 @@
|
||||||
#include "networkpackage.h"
|
#include "networkpackage.h"
|
||||||
#include "backends/lan/lanlinkprovider.h"
|
#include "backends/lan/lanlinkprovider.h"
|
||||||
#include "backends/loopback/loopbacklinkprovider.h"
|
#include "backends/loopback/loopbacklinkprovider.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "networkpackage.h"
|
||||||
|
#include "backends/devicelink.h"
|
||||||
|
#include "backends/linkprovider.h"
|
||||||
|
|
||||||
Daemon::Daemon(QObject *parent) : QObject(parent)
|
struct DaemonPrivate
|
||||||
|
{
|
||||||
|
//Different ways to find devices and connect to them
|
||||||
|
QSet<LinkProvider*> mLinkProviders;
|
||||||
|
|
||||||
|
//Every known device
|
||||||
|
QMap<QString, Device*> mDevices;
|
||||||
|
|
||||||
|
// The Initializer object sets things up, and also does cleanup when it goes out of scope
|
||||||
|
// Note it's not being used anywhere. That's inteneded
|
||||||
|
QCA::Initializer mQcaInitializer;
|
||||||
|
};
|
||||||
|
|
||||||
|
Daemon::Daemon(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, d(new DaemonPrivate)
|
||||||
{
|
{
|
||||||
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
|
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
|
||||||
|
|
||||||
|
@ -97,8 +117,8 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
|
||||||
kDebug(kdeconnect_kded()) << "Starting KdeConnect daemon";
|
kDebug(kdeconnect_kded()) << "Starting KdeConnect daemon";
|
||||||
|
|
||||||
//Load backends (hardcoded by now, should be plugins in a future)
|
//Load backends (hardcoded by now, should be plugins in a future)
|
||||||
mLinkProviders.insert(new LanLinkProvider());
|
d->mLinkProviders.insert(new LanLinkProvider());
|
||||||
//mLinkProviders.insert(new LoopbackLinkProvider());
|
//d->mLinkProviders.insert(new LoopbackLinkProvider());
|
||||||
|
|
||||||
//Read remebered paired devices
|
//Read remebered paired devices
|
||||||
const KConfigGroup& known = config->group("trusted_devices");
|
const KConfigGroup& known = config->group("trusted_devices");
|
||||||
|
@ -107,13 +127,13 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
|
||||||
Device* device = new Device(this, id);
|
Device* device = new Device(this, id);
|
||||||
connect(device, SIGNAL(reachableStatusChanged()),
|
connect(device, SIGNAL(reachableStatusChanged()),
|
||||||
this, SLOT(onDeviceReachableStatusChanged()));
|
this, SLOT(onDeviceReachableStatusChanged()));
|
||||||
mDevices[id] = device;
|
d->mDevices[id] = device;
|
||||||
Q_EMIT deviceAdded(id);
|
Q_EMIT deviceAdded(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Listen to connectivity changes
|
//Listen to connectivity changes
|
||||||
QNetworkSession* network = new QNetworkSession(QNetworkConfigurationManager().defaultConfiguration());
|
QNetworkSession* network = new QNetworkSession(QNetworkConfigurationManager().defaultConfiguration());
|
||||||
Q_FOREACH (LinkProvider* a, mLinkProviders) {
|
Q_FOREACH (LinkProvider* a, d->mLinkProviders) {
|
||||||
connect(network, SIGNAL(stateChanged(QNetworkSession::State)),
|
connect(network, SIGNAL(stateChanged(QNetworkSession::State)),
|
||||||
a, SLOT(onNetworkChange(QNetworkSession::State)));
|
a, SLOT(onNetworkChange(QNetworkSession::State)));
|
||||||
connect(a, SIGNAL(onConnectionReceived(NetworkPackage, DeviceLink*)),
|
connect(a, SIGNAL(onConnectionReceived(NetworkPackage, DeviceLink*)),
|
||||||
|
@ -130,7 +150,7 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
|
||||||
void Daemon::setDiscoveryEnabled(bool b)
|
void Daemon::setDiscoveryEnabled(bool b)
|
||||||
{
|
{
|
||||||
//Listen to incomming connections
|
//Listen to incomming connections
|
||||||
Q_FOREACH (LinkProvider* a, mLinkProviders) {
|
Q_FOREACH (LinkProvider* a, d->mLinkProviders) {
|
||||||
if (b)
|
if (b)
|
||||||
a->onStart();
|
a->onStart();
|
||||||
else
|
else
|
||||||
|
@ -141,7 +161,7 @@ void Daemon::setDiscoveryEnabled(bool b)
|
||||||
|
|
||||||
void Daemon::forceOnNetworkChange()
|
void Daemon::forceOnNetworkChange()
|
||||||
{
|
{
|
||||||
Q_FOREACH (LinkProvider* a, mLinkProviders) {
|
Q_FOREACH (LinkProvider* a, d->mLinkProviders) {
|
||||||
a->onNetworkChange(QNetworkSession::Connected);
|
a->onNetworkChange(QNetworkSession::Connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +169,7 @@ void Daemon::forceOnNetworkChange()
|
||||||
QStringList Daemon::devices(bool onlyReachable, bool onlyVisible) const
|
QStringList Daemon::devices(bool onlyReachable, bool onlyVisible) const
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
Q_FOREACH(Device* device, mDevices) {
|
Q_FOREACH(Device* device, d->mDevices) {
|
||||||
if (onlyReachable && !device->isReachable()) continue;
|
if (onlyReachable && !device->isReachable()) continue;
|
||||||
if (onlyVisible && !device->isPaired()) continue;
|
if (onlyVisible && !device->isPaired()) continue;
|
||||||
ret.append(device->id());
|
ret.append(device->id());
|
||||||
|
@ -164,16 +184,16 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
|
||||||
|
|
||||||
//kDebug(kdeconnect_kded()) << "Device discovered" << id << "via" << dl->provider()->name();
|
//kDebug(kdeconnect_kded()) << "Device discovered" << id << "via" << dl->provider()->name();
|
||||||
|
|
||||||
if (mDevices.contains(id)) {
|
if (d->mDevices.contains(id)) {
|
||||||
//kDebug(kdeconnect_kded()) << "It is a known device";
|
//kDebug(kdeconnect_kded()) << "It is a known device";
|
||||||
Device* device = mDevices[id];
|
Device* device = d->mDevices[id];
|
||||||
device->addLink(identityPackage, dl);
|
device->addLink(identityPackage, dl);
|
||||||
} else {
|
} else {
|
||||||
//kDebug(kdeconnect_kded()) << "It is a new device";
|
//kDebug(kdeconnect_kded()) << "It is a new device";
|
||||||
|
|
||||||
Device* device = new Device(this, identityPackage, dl);
|
Device* device = new Device(this, identityPackage, dl);
|
||||||
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged()));
|
connect(device, SIGNAL(reachableStatusChanged()), this, SLOT(onDeviceReachableStatusChanged()));
|
||||||
mDevices[id] = device;
|
d->mDevices[id] = device;
|
||||||
|
|
||||||
Q_EMIT deviceAdded(id);
|
Q_EMIT deviceAdded(id);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +217,7 @@ void Daemon::onDeviceReachableStatusChanged()
|
||||||
if (!device->isPaired()) {
|
if (!device->isPaired()) {
|
||||||
kDebug(kdeconnect_kded()) << "Destroying device" << device->name();
|
kDebug(kdeconnect_kded()) << "Destroying device" << device->name();
|
||||||
Q_EMIT deviceRemoved(id);
|
Q_EMIT deviceRemoved(id);
|
||||||
mDevices.remove(id);
|
d->mDevices.remove(id);
|
||||||
device->deleteLater();
|
device->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,14 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QtCrypto>
|
|
||||||
|
|
||||||
#include <KDEDModule>
|
#include <KDEDModule>
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include "kdeconnectcore_export.h"
|
#include "kdeconnectcore_export.h"
|
||||||
|
|
||||||
#include "device.h"
|
class DaemonPrivate;
|
||||||
#include "networkpackage.h"
|
class NetworkPackage;
|
||||||
#include "backends/devicelink.h"
|
class DeviceLink;
|
||||||
#include "backends/linkprovider.h"
|
|
||||||
|
|
||||||
class KDECONNECTCORE_EXPORT Daemon
|
class KDECONNECTCORE_EXPORT Daemon
|
||||||
: public QObject
|
: public QObject
|
||||||
|
@ -65,15 +63,7 @@ private Q_SLOTS:
|
||||||
void onDeviceReachableStatusChanged();
|
void onDeviceReachableStatusChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QScopedPointer<DaemonPrivate> d;
|
||||||
//Different ways to find devices and connect to them
|
|
||||||
QSet<LinkProvider*> mLinkProviders;
|
|
||||||
|
|
||||||
//Every known device
|
|
||||||
QMap<QString, Device*> mDevices;
|
|
||||||
|
|
||||||
// The Initializer object sets things up, and also does cleanup when it goes out of scope
|
|
||||||
QCA::Initializer mQcaInitializer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue