Move the Telepathy infrastructure at the plugin level
At the moment, telepathy integration needs to be compiled within the daemon. This creates a rather aggressive dependency with Telepathy. This plugin proposes to move into a plugin, so that if the plugin isn't present, telepathy becomes out of the picture. REVIEW: 128149
This commit is contained in:
parent
aff1740473
commit
a465577005
15 changed files with 56 additions and 83 deletions
|
@ -14,11 +14,8 @@ find_package(Qt5 5.2 REQUIRED COMPONENTS Quick Gui)
|
|||
find_package(KF5 REQUIRED COMPONENTS I18n ConfigWidgets DBusAddons)
|
||||
find_package(KF5DocTools)
|
||||
find_package(Qca-qt5 2.1.0 REQUIRED)
|
||||
# find_package(TelepathyQt5 0.9.5)
|
||||
# find_package(TelepathyQt5Service 0.9.7)
|
||||
if (TelepathyQt5_FOUND AND TelepathyQt5Service_FOUND)
|
||||
add_definitions(-DHAVE_TELEPATHY)
|
||||
endif()
|
||||
find_package(TelepathyQt5 0.9.5)
|
||||
find_package(TelepathyQt5Service 0.9.7)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
|
||||
|
@ -39,6 +36,8 @@ add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
|
|||
include(GenerateExportHeader)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_subdirectory(telepathy-cm)
|
||||
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(kcm)
|
||||
add_subdirectory(kcmplugin)
|
||||
|
@ -59,10 +58,6 @@ if(KF5DocTools_FOUND)
|
|||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
if (TelepathyQt5_FOUND AND TelepathyQt5Service_FOUND)
|
||||
add_subdirectory(telepathy-cm)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -8,9 +8,6 @@ add_executable(kdeconnectd kdeconnectd.cpp)
|
|||
target_link_libraries(kdeconnectd kdeconnectcore KF5::KIOWidgets KF5::DBusAddons KF5::Notifications KF5::I18n Qt5::Widgets)
|
||||
|
||||
ecm_mark_nongui_executable(kdeconnectd)
|
||||
if(TelepathyQt5_FOUND AND TelepathyQt5Service_FOUND)
|
||||
target_link_libraries(kdeconnectd connectcm)
|
||||
endif()
|
||||
|
||||
configure_file(kdeconnectd.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectd.desktop)
|
||||
configure_file(org.kde.kdeconnect.service.in ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.service)
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
#include "core/backends/pairinghandler.h"
|
||||
#include "kdeconnect-version.h"
|
||||
|
||||
#ifdef HAVE_TELEPATHY
|
||||
#include "kdeconnecttelepathyprotocolfactory.h"
|
||||
#endif
|
||||
|
||||
class DesktopDaemon : public Daemon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -95,11 +91,6 @@ int main(int argc, char* argv[])
|
|||
Daemon* daemon = new DesktopDaemon;
|
||||
QObject::connect(daemon, SIGNAL(destroyed(QObject*)), &app, SLOT(quit()));
|
||||
|
||||
#ifdef HAVE_TELEPATHY
|
||||
//keep a reference to the KTP CM so that we can register on DBus
|
||||
auto telepathyPlugin = KDEConnectTelepathyProtocolFactory::interface();
|
||||
#endif
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
find_package(KF5 REQUIRED COMPONENTS Notifications)
|
||||
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
|
||||
set(kdeconnect_telephony_SRCS
|
||||
telephonyplugin.cpp
|
||||
sendsmsdialog.cpp
|
||||
)
|
||||
|
||||
qt5_generate_dbus_interface(${CMAKE_SOURCE_DIR}/telepathy-cm/protocol.h ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectinterface.xml)
|
||||
qt5_add_dbus_interface(kdeconnect_telephony_SRCS ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectinterface.xml kdeconnectinterface)
|
||||
|
||||
kdeconnect_add_plugin(kdeconnect_telephony JSON kdeconnect_telephony.json SOURCES ${kdeconnect_telephony_SRCS})
|
||||
|
||||
target_link_libraries(kdeconnect_telephony
|
||||
kdeconnectcore
|
||||
KF5::I18n
|
||||
KF5::Notifications
|
||||
Qt5::DBus
|
||||
)
|
||||
|
||||
if (TelepathyQt5_FOUND AND TelepathyQt5Service_FOUND)
|
||||
target_link_libraries(kdeconnect_telephony
|
||||
connectcm
|
||||
)
|
||||
endif()
|
|
@ -34,12 +34,9 @@ Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_TELEPHONY, "kdeconnect.plugin.telephony")
|
|||
|
||||
TelephonyPlugin::TelephonyPlugin(QObject *parent, const QVariantList &args)
|
||||
: KdeConnectPlugin(parent, args)
|
||||
, m_telepathyInterface(new OrgFreedesktopTelepathyConnectionManagerKdeconnectInterface("org.freedesktop.Telepathy.ConnectionManager.kdeconnect", "/kdeconnect", QDBusConnection::sessionBus(), this))
|
||||
{
|
||||
#ifdef HAVE_TELEPATHY
|
||||
//keep a reference to the KTP CM so that we can register on DBus
|
||||
m_telepathyInterface = KDEConnectTelepathyProtocolFactory::interface();
|
||||
connect(m_telepathyInterface.constData(), SIGNAL(messageReceived(QString,QString)), SLOT(sendSms(QString,QString)));
|
||||
#endif
|
||||
connect(m_telepathyInterface, SIGNAL(messageReceived(QString,QString)), SLOT(sendSms(QString,QString)));
|
||||
}
|
||||
|
||||
KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
|
||||
|
@ -66,7 +63,7 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
|
|||
} else if (event == "sms") {
|
||||
type = QStringLiteral("smsReceived");
|
||||
icon = QStringLiteral("mail-receive");
|
||||
QString messageBody = np.get<QString>("messageBody","");
|
||||
QString messageBody = np.get<QString>("messageBody", "");
|
||||
content = i18n("SMS from %1<br>%2", contactName, messageBody);
|
||||
flags |= KNotification::Persistent;
|
||||
} else if (event == "talking") {
|
||||
|
@ -118,7 +115,6 @@ bool TelephonyPlugin::receivePackage(const NetworkPackage& np)
|
|||
//TODO: Clear the old notification
|
||||
return true;
|
||||
}
|
||||
#ifdef HAVE_TELEPATHY
|
||||
if (np.get<QString>("event") == QLatin1String("sms")) {
|
||||
const QString messageBody = np.get<QString>("messageBody","");
|
||||
const QString phoneNumber = np.get<QString>("phoneNumber", i18n("unknown number"));
|
||||
|
@ -127,8 +123,7 @@ bool TelephonyPlugin::receivePackage(const NetworkPackage& np)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
KNotification* n = createNotification(np);
|
||||
if (n != nullptr) n->sendEvent();
|
||||
|
||||
|
|
|
@ -26,10 +26,7 @@
|
|||
#include <KNotification>
|
||||
|
||||
#include <core/kdeconnectplugin.h>
|
||||
|
||||
#ifdef HAVE_TELEPATHY
|
||||
#include "kdeconnecttelepathyprotocolfactory.h"
|
||||
#endif
|
||||
#include "kdeconnectinterface.h"
|
||||
|
||||
#define PACKAGE_TYPE_TELEPHONY_REQUEST QLatin1String("kdeconnect.telephony.request")
|
||||
#define PACKAGE_TYPE_SMS_REQUEST QLatin1String("kdeconnect.sms.request")
|
||||
|
@ -55,12 +52,8 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
KNotification* createNotification(const NetworkPackage& np);
|
||||
|
||||
#ifdef HAVE_TELEPATHY
|
||||
ConnectProtocolPtr m_telepathyInterface;
|
||||
#endif
|
||||
|
||||
|
||||
OrgFreedesktopTelepathyConnectionManagerKdeconnectInterface* m_telepathyInterface;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
project(connectcm)
|
||||
|
||||
add_definitions(-DCONNECTCM_LIBRARY)
|
||||
|
||||
set(connectcm_SOURCES
|
||||
add_executable(connectcm
|
||||
main.cpp
|
||||
connection.cpp
|
||||
protocol.cpp
|
||||
textchannel.cpp
|
||||
kdeconnecttelepathyprotocolfactory.cpp
|
||||
)
|
||||
|
||||
add_library(connectcm SHARED ${connectcm_SOURCES})
|
||||
|
||||
target_link_libraries(connectcm
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
${TELEPATHY_QT5_LIBRARIES}
|
||||
${TELEPATHY_QT5_SERVICE_LIBRARIES}
|
||||
)
|
||||
|
||||
install (TARGETS connectcm
|
||||
${INSTALL_TARGETS_DEFAULT_ARGS}
|
||||
)
|
||||
install (TARGETS connectcm DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/org.freedesktop.Telepathy.ConnectionManager.kdeconnect.service "Name=org.freedesktop.Telepathy.ConnectionManager.kdeconnect
|
||||
Exec=$<TARGET_FILE_DIR:connectcm>")
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.Telepathy.ConnectionManager.kdeconnect.service DESTINATION share/dbus-1/services)
|
||||
|
||||
install(
|
||||
FILES kdeconnect.manager
|
||||
DESTINATION share/telepathy/managers
|
||||
)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef CONNECTCM_EXPORT_H
|
||||
#define CONNECTCM_EXPORT_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if defined(CONNECTCM_LIBRARY)
|
||||
#define CONNECTCM_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define CONNECTCM_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -14,12 +14,10 @@
|
|||
#ifndef CONNECTCM_CONNECTION_H
|
||||
#define CONNECTCM_CONNECTION_H
|
||||
|
||||
#include "connectcm_export.h"
|
||||
|
||||
#include <TelepathyQt/BaseConnection>
|
||||
#include <TelepathyQt/BaseChannel>
|
||||
|
||||
class CONNECTCM_EXPORT ConnectConnection : public Tp::BaseConnection
|
||||
class ConnectConnection : public Tp::BaseConnection
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
[ConnectionManager]
|
||||
BusName=org.freedesktop.Telepathy.ConnectionManager.kdeconnect
|
||||
ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/kdeconnect
|
||||
Interfaces=
|
||||
|
||||
[Protocol kdeconnect]
|
||||
Name = kdeconnect
|
||||
BusName = org.freedesktop.Telepathy.ConnectionManager.kdeconnect
|
||||
ObjectPath = /org/freedesktop/Telepathy/ConnectionManager/kdeconnect
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "protocol.h"
|
||||
|
||||
#include "connectcm_export.h"
|
||||
|
||||
typedef Tp::SharedPtr<KDEConnectTelepathyProtocol> ConnectProtocolPtr;
|
||||
|
||||
/*
|
||||
|
@ -9,7 +7,7 @@ typedef Tp::SharedPtr<KDEConnectTelepathyProtocol> ConnectProtocolPtr;
|
|||
* Whilst the main process also holds a reference.
|
||||
*
|
||||
*/
|
||||
class CONNECTCM_EXPORT KDEConnectTelepathyProtocolFactory
|
||||
class KDEConnectTelepathyProtocolFactory
|
||||
{
|
||||
public:
|
||||
static ConnectProtocolPtr interface();
|
||||
|
|
17
telepathy-cm/main.cpp
Normal file
17
telepathy-cm/main.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <QCoreApplication>
|
||||
|
||||
#include <TelepathyQt/BaseConnectionManager>
|
||||
#include <TelepathyQt/Constants>
|
||||
#include <TelepathyQt/Debug>
|
||||
|
||||
#include "kdeconnecttelepathyprotocolfactory.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName(QLatin1String("telepathy-morse"));
|
||||
|
||||
KDEConnectTelepathyProtocolFactory::interface();
|
||||
|
||||
return app.exec();
|
||||
}
|
|
@ -48,6 +48,9 @@ KDEConnectTelepathyProtocol::KDEConnectTelepathyProtocol(const QDBusConnection &
|
|||
presenceIface->setStatuses(Tp::PresenceSpecList(ConnectConnection::getConnectStatusSpecMap()));
|
||||
plugInterface(Tp::AbstractProtocolInterfacePtr::dynamicCast(presenceIface));*/
|
||||
|
||||
auto bus = QDBusConnection::sessionBus();
|
||||
bus.registerObject("/kdeconnect", this, QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots);
|
||||
|
||||
Tp::DBusError err;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,16 +14,15 @@
|
|||
#ifndef CONNECTCM_PROTOCOL_H
|
||||
#define CONNECTCM_PROTOCOL_H
|
||||
|
||||
#include "connectcm_export.h"
|
||||
|
||||
#include <TelepathyQt/BaseProtocol>
|
||||
|
||||
class ConnectConnection;
|
||||
|
||||
class CONNECTCM_EXPORT KDEConnectTelepathyProtocol : public Tp::BaseProtocol
|
||||
class KDEConnectTelepathyProtocol : public Tp::BaseProtocol
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(KDEConnectTelepathyProtocol)
|
||||
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.ConnectionManager.kdeconnect")
|
||||
|
||||
public:
|
||||
KDEConnectTelepathyProtocol(const QDBusConnection &dbusConnection, const QString &name);
|
||||
|
|
|
@ -14,15 +14,13 @@
|
|||
#ifndef CONNECTCM_TEXTCHANNEL_H
|
||||
#define CONNECTCM_TEXTCHANNEL_H
|
||||
|
||||
#include "connectcm_export.h"
|
||||
|
||||
#include <TelepathyQt/BaseChannel>
|
||||
|
||||
class ConnectTextChannel;
|
||||
|
||||
typedef Tp::SharedPtr<ConnectTextChannel> ConnectTextChannelPtr;
|
||||
|
||||
class CONNECTCM_EXPORT ConnectTextChannel : public Tp::BaseChannelTextType
|
||||
class ConnectTextChannel : public Tp::BaseChannelTextType
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue