diff --git a/CMakeLists.txt b/CMakeLists.txt index b1970ecd0..5f9bca933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 2.6) find_package(KDE4 REQUIRED) -if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-std=gnu++0x) -endif() +#if(CMAKE_COMPILER_IS_GNUCXX) +# add_definitions(-std=gnu++0x) +#endif() include(KDE4Defaults) include_directories(${KDE4_INCLUDES}) diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 1bddc53ef..007dea513 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -17,9 +17,6 @@ set(kded_kdeconnect_SRCS networkpackage.cpp daemon.cpp device.cpp - - ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.xml - ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.device.xml ) kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS}) @@ -46,6 +43,16 @@ qt4_generate_dbus_interface( OPTIONS -a ) +add_custom_target( + org.kde.kdeconnect.xml + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.xml +) + +add_custom_target( + org.kde.kdeconnect.device.xml + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.device.xml +) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.device.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}) install(TARGETS kded_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR}) diff --git a/daemon/linkproviders/linkprovider.h b/daemon/linkproviders/linkprovider.h index 3d422d016..cef0f641e 100644 --- a/daemon/linkproviders/linkprovider.h +++ b/daemon/linkproviders/linkprovider.h @@ -36,9 +36,9 @@ class LinkProvider public: - const int PRIORITY_LOW = 0; //eg: 3g - const int PRIORITY_MEDIUM = 50; //eg: internet - const int PRIORITY_HIGH = 100; //eg: lan + const static int PRIORITY_LOW = 0; //eg: 3g + const static int PRIORITY_MEDIUM = 50; //eg: internet + const static int PRIORITY_HIGH = 100; //eg: lan LinkProvider(); virtual ~LinkProvider() { } diff --git a/daemon/packageinterfaces/pausemusicpackageinterface.cpp b/daemon/packageinterfaces/pausemusicpackageinterface.cpp index f3e55bc74..e38ba2be0 100644 --- a/daemon/packageinterfaces/pausemusicpackageinterface.cpp +++ b/daemon/packageinterfaces/pausemusicpackageinterface.cpp @@ -29,7 +29,7 @@ PauseMusicPackageInterface::PauseMusicPackageInterface() { - //TODO: Be able to change this from settings + //TODO: Be able to change this from plugin settings pauseWhen = PauseWhenRinging; } @@ -57,40 +57,32 @@ bool PauseMusicPackageInterface::receivePackage (const Device& device, const Net qDebug() << "PauseMusicPackageReceiver - PauseCondition:" << pauseConditionFulfilled; + //TODO: Make this async + //TODO: Make this not crash if dbus is not working if (pauseConditionFulfilled) { - //TODO: Make this async //Search for interfaces currently playing QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); Q_FOREACH (const QString& iface, interfaces) { if (iface.startsWith("org.mpris.MediaPlayer2")) { - QDBusInterface *dbusInterface = new QDBusInterface(iface, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus(), this); - QDBusInterface *mprisInterface = new QDBusInterface(iface, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", QDBusConnection::sessionBus(), this); - - QString status = (qvariant_cast(dbusInterface->call(QDBus::Block,"Get","org.mpris.MediaPlayer2.Player","PlaybackStatus").arguments().first()).variant()).toString(); + QDBusInterface mprisInterface(iface, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player"); + QString status = mprisInterface.property("PlaybackStatus").toString(); if (status == "Playing") { if (!pausedSources.contains(iface)) { pausedSources.insert(iface); - mprisInterface->call(QDBus::Block,"Pause"); + mprisInterface.call(QDBus::Block,"Pause"); } } - - delete dbusInterface; - delete mprisInterface; } } } if (!pauseConditionFulfilled) { - //TODO: Make this async Q_FOREACH (const QString& iface, pausedSources) { - QDBusInterface *mprisInterface = new QDBusInterface(iface, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", QDBusConnection::sessionBus(), this); - //FIXME: Calling play does not work in spotify + QDBusInterface mprisInterface(iface, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player"); + //Calling play does not work in spotify //mprisInterface->call(QDBus::Block,"Play"); //Workaround: Using playpause instead (checking first if it is already playing) - QDBusInterface *dbusInterface = new QDBusInterface(iface, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus(), this); - QString status = (qvariant_cast(dbusInterface->call(QDBus::Block,"Get","org.mpris.MediaPlayer2.Player","PlaybackStatus").arguments().first()).variant()).toString(); - if (status == "Paused") mprisInterface->call(QDBus::Block,"PlayPause"); - delete dbusInterface; + QString status = mprisInterface.property("PlaybackStatus").toString(); + if (status == "Paused") mprisInterface.call(QDBus::Block,"PlayPause"); //End of workaround - delete mprisInterface; } pausedSources.clear(); } diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt index 9ea9dcc6e..f279a5d75 100644 --- a/kcm/CMakeLists.txt +++ b/kcm/CMakeLists.txt @@ -10,6 +10,7 @@ qt4_add_dbus_interface( ${CMAKE_BINARY_DIR}/daemon/org.kde.kdeconnect.xml daemoninterface ) + qt4_add_dbus_interface( kcm_SRCS ${CMAKE_BINARY_DIR}/daemon/org.kde.kdeconnect.device.xml @@ -27,6 +28,11 @@ target_link_libraries(kcm_kdeconnect ${KDE4_KIO_LIBRARY} ) +add_dependencies(kcm_kdeconnect + org.kde.kdeconnect.xml + org.kde.kdeconnect.device.xml +) + install(TARGETS kcm_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES kcm_kdeconnect.desktop DESTINATION ${SERVICES_INSTALL_DIR})