diff --git a/CMakeLists.txt b/CMakeLists.txt index abd3438c7..4efde154b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 359ea8d49..649fe4a4d 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -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) diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index 1b7a84139..556fd9ebe 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -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(); } diff --git a/plugins/telephony/CMakeLists.txt b/plugins/telephony/CMakeLists.txt index 666c54fe7..583aa8f34 100644 --- a/plugins/telephony/CMakeLists.txt +++ b/plugins/telephony/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp index d285c3995..5015c6c42 100644 --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -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("messageBody",""); + QString messageBody = np.get("messageBody", ""); content = i18n("SMS from %1
%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("event") == QLatin1String("sms")) { const QString messageBody = np.get("messageBody",""); const QString phoneNumber = np.get("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(); diff --git a/plugins/telephony/telephonyplugin.h b/plugins/telephony/telephonyplugin.h index d1a6873bb..58b9752ab 100644 --- a/plugins/telephony/telephonyplugin.h +++ b/plugins/telephony/telephonyplugin.h @@ -26,10 +26,7 @@ #include #include - -#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 diff --git a/telepathy-cm/CMakeLists.txt b/telepathy-cm/CMakeLists.txt index fc763fbd9..bf526a958 100644 --- a/telepathy-cm/CMakeLists.txt +++ b/telepathy-cm/CMakeLists.txt @@ -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=$") + +install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.Telepathy.ConnectionManager.kdeconnect.service DESTINATION share/dbus-1/services) + +install( + FILES kdeconnect.manager + DESTINATION share/telepathy/managers +) diff --git a/telepathy-cm/connectcm_export.h b/telepathy-cm/connectcm_export.h deleted file mode 100644 index 740ae985b..000000000 --- a/telepathy-cm/connectcm_export.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CONNECTCM_EXPORT_H -#define CONNECTCM_EXPORT_H - -#include - -#if defined(CONNECTCM_LIBRARY) -#define CONNECTCM_EXPORT Q_DECL_EXPORT -#else -#define CONNECTCM_EXPORT Q_DECL_IMPORT -#endif - -#endif diff --git a/telepathy-cm/connection.h b/telepathy-cm/connection.h index b4438bf9c..291665569 100644 --- a/telepathy-cm/connection.h +++ b/telepathy-cm/connection.h @@ -14,12 +14,10 @@ #ifndef CONNECTCM_CONNECTION_H #define CONNECTCM_CONNECTION_H -#include "connectcm_export.h" - #include #include -class CONNECTCM_EXPORT ConnectConnection : public Tp::BaseConnection +class ConnectConnection : public Tp::BaseConnection { Q_OBJECT public: diff --git a/telepathy-cm/kdeconnect.manager b/telepathy-cm/kdeconnect.manager index fcdeb08ad..a4dd29051 100644 --- a/telepathy-cm/kdeconnect.manager +++ b/telepathy-cm/kdeconnect.manager @@ -1,6 +1,4 @@ [ConnectionManager] -BusName=org.freedesktop.Telepathy.ConnectionManager.kdeconnect -ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/kdeconnect -Interfaces= - -[Protocol kdeconnect] \ No newline at end of file +Name = kdeconnect +BusName = org.freedesktop.Telepathy.ConnectionManager.kdeconnect +ObjectPath = /org/freedesktop/Telepathy/ConnectionManager/kdeconnect diff --git a/telepathy-cm/kdeconnecttelepathyprotocolfactory.h b/telepathy-cm/kdeconnecttelepathyprotocolfactory.h index 51b44fdf2..84d048a5b 100644 --- a/telepathy-cm/kdeconnecttelepathyprotocolfactory.h +++ b/telepathy-cm/kdeconnecttelepathyprotocolfactory.h @@ -1,7 +1,5 @@ #include "protocol.h" -#include "connectcm_export.h" - typedef Tp::SharedPtr ConnectProtocolPtr; /* @@ -9,7 +7,7 @@ typedef Tp::SharedPtr ConnectProtocolPtr; * Whilst the main process also holds a reference. * */ -class CONNECTCM_EXPORT KDEConnectTelepathyProtocolFactory +class KDEConnectTelepathyProtocolFactory { public: static ConnectProtocolPtr interface(); diff --git a/telepathy-cm/main.cpp b/telepathy-cm/main.cpp new file mode 100644 index 000000000..b229178ce --- /dev/null +++ b/telepathy-cm/main.cpp @@ -0,0 +1,17 @@ +#include + +#include +#include +#include + +#include "kdeconnecttelepathyprotocolfactory.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + app.setApplicationName(QLatin1String("telepathy-morse")); + + KDEConnectTelepathyProtocolFactory::interface(); + + return app.exec(); +} diff --git a/telepathy-cm/protocol.cpp b/telepathy-cm/protocol.cpp index 1e987294e..eb4fbb37c 100644 --- a/telepathy-cm/protocol.cpp +++ b/telepathy-cm/protocol.cpp @@ -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; } diff --git a/telepathy-cm/protocol.h b/telepathy-cm/protocol.h index 5431aa8b0..6d4e4faf4 100644 --- a/telepathy-cm/protocol.h +++ b/telepathy-cm/protocol.h @@ -14,16 +14,15 @@ #ifndef CONNECTCM_PROTOCOL_H #define CONNECTCM_PROTOCOL_H -#include "connectcm_export.h" - #include 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); diff --git a/telepathy-cm/textchannel.h b/telepathy-cm/textchannel.h index 3781283c9..163a23e08 100644 --- a/telepathy-cm/textchannel.h +++ b/telepathy-cm/textchannel.h @@ -14,15 +14,13 @@ #ifndef CONNECTCM_TEXTCHANNEL_H #define CONNECTCM_TEXTCHANNEL_H -#include "connectcm_export.h" - #include class ConnectTextChannel; typedef Tp::SharedPtr ConnectTextChannelPtr; -class CONNECTCM_EXPORT ConnectTextChannel : public Tp::BaseChannelTextType +class ConnectTextChannel : public Tp::BaseChannelTextType { Q_OBJECT public: