From d8943f03ae609e0bb09a3a0793a74dd06f5141d6 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Sun, 9 Nov 2014 22:10:51 -0800 Subject: [PATCH] Added dbus activation to org.kde.kdeconnect --- cmake/DbusActivationMacros.cmake | 31 +++++++++++++++++++ ...macros.cmake => DbusInterfaceMacros.cmake} | 0 core/CMakeLists.txt | 2 +- kded/CMakeLists.txt | 7 ++--- kded/org.kde.kdeconnect.service.in | 3 ++ plugins/battery/CMakeLists.txt | 2 +- plugins/notifications/CMakeLists.txt | 3 +- plugins/sftp/CMakeLists.txt | 2 +- 8 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 cmake/DbusActivationMacros.cmake rename cmake/{macros.cmake => DbusInterfaceMacros.cmake} (100%) create mode 100644 kded/org.kde.kdeconnect.service.in diff --git a/cmake/DbusActivationMacros.cmake b/cmake/DbusActivationMacros.cmake new file mode 100644 index 000000000..2a038a591 --- /dev/null +++ b/cmake/DbusActivationMacros.cmake @@ -0,0 +1,31 @@ +include(UsePkgConfig) + +MACRO(PKGCONFIG_GETVAR _package _var _output_variable) + SET(${_output_variable}) + + # if pkg-config has been found + IF(PKGCONFIG_EXECUTABLE) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull ) + + # and if the package of interest also exists for pkg-config, then get the information + IF(NOT _return_VALUE) + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable ${_var} OUTPUT_VARIABLE ${_output_variable} ) + + ENDIF(NOT _return_VALUE) + + ENDIF(PKGCONFIG_EXECUTABLE) + +ENDMACRO(PKGCONFIG_GETVAR _package _var _output_variable) + +macro(dbus_add_activation_service _sources) + PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir) + foreach (_i ${_sources}) + get_filename_component(_service_file ${_i} ABSOLUTE) + string(REGEX REPLACE "\\.service.*$" ".service" _output_file ${_i}) + set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file}) + configure_file(${_service_file} ${_target}) + install(FILES ${_target} DESTINATION ${_install_dir}) + endforeach (_i ${ARGN}) +endmacro(dbus_add_activation_service _sources) diff --git a/cmake/macros.cmake b/cmake/DbusInterfaceMacros.cmake similarity index 100% rename from cmake/macros.cmake rename to cmake/DbusInterfaceMacros.cmake diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e165a36b3..17209b1a8 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -48,7 +48,7 @@ LINK_PRIVATE target_include_directories(kdeconnectcore PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) generate_export_header(kdeconnectcore EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectcore_export.h BASE_NAME KDEConnectCore) -include(macros) +include(DbusInterfaceMacros) generate_and_install_dbus_interface( kdeconnectcore diff --git a/kded/CMakeLists.txt b/kded/CMakeLists.txt index d429dce23..4c4e46b34 100644 --- a/kded/CMakeLists.txt +++ b/kded/CMakeLists.txt @@ -2,13 +2,12 @@ include_directories(${CMAKE_SOURCE_DIR}) kde4_add_executable(kdeconnectd kdeconnectd.cpp) target_link_libraries(kdeconnectd kdeconnectcore ${KDE4_KDEUI_LIBS}) +install(TARGETS kdeconnectd DESTINATION ${LIBEXEC_INSTALL_DIR}) kde4_add_plugin(kded_kdeconnect kded.cpp) - target_link_libraries(kded_kdeconnect ${KDE4_KDECORE_LIBS}) - -install(TARGETS kdeconnectd DESTINATION ${LIBEXEC_INSTALL_DIR}) install(TARGETS kded_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES kdeconnect.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded) - +include(DbusActivationMacros) +dbus_add_activation_service(org.kde.kdeconnect.service.in) diff --git a/kded/org.kde.kdeconnect.service.in b/kded/org.kde.kdeconnect.service.in new file mode 100644 index 000000000..977764294 --- /dev/null +++ b/kded/org.kde.kdeconnect.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.kde.kdeconnect +Exec=@LIBEXEC_INSTALL_DIR@/kdeconnectd diff --git a/plugins/battery/CMakeLists.txt b/plugins/battery/CMakeLists.txt index b6da5cbb6..1fea3b792 100644 --- a/plugins/battery/CMakeLists.txt +++ b/plugins/battery/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(kdeconnect_battery kdeconnectcore ${KDE4_KDEUI_LIBS}) install(TARGETS kdeconnect_battery DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_battery.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -include(macros) +include(DbusInterfaceMacros) generate_and_install_dbus_interface( kdeconnect_battery diff --git a/plugins/notifications/CMakeLists.txt b/plugins/notifications/CMakeLists.txt index cc6dd97d7..cfd271d22 100644 --- a/plugins/notifications/CMakeLists.txt +++ b/plugins/notifications/CMakeLists.txt @@ -11,7 +11,8 @@ target_link_libraries(kdeconnect_notifications kdeconnectcore ${KDE4_KDEUI_LIBS} install(TARGETS kdeconnect_notifications DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_notifications.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -include(macros) +include(DbusInterfaceMacros) + generate_and_install_dbus_interface( kdeconnect_notifications notificationsdbusinterface.h diff --git a/plugins/sftp/CMakeLists.txt b/plugins/sftp/CMakeLists.txt index 500067e2f..e6fd20444 100644 --- a/plugins/sftp/CMakeLists.txt +++ b/plugins/sftp/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries(kdeconnect_sftp kdeconnectcore ${KDE4_KFILE_LIBS}) install(TARGETS kdeconnect_sftp DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_sftp.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -include(macros) +include(DbusInterfaceMacros) generate_and_install_dbus_interface( kdeconnect_sftp