diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f61e83b9..e0feb636f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,5 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_subdirectory(daemon) add_subdirectory(kcm) -#add_subdirectory(kioslave) add_subdirectory(test) diff --git a/daemon/networkpackagetypes.h b/daemon/networkpackagetypes.h index aff696c5d..96ccaabef 100644 --- a/daemon/networkpackagetypes.h +++ b/daemon/networkpackagetypes.h @@ -25,7 +25,7 @@ #define PACKAGE_TYPE_PING QString("kdeconnect.ping") #define PACKAGE_TYPE_NOTIFICATION QString("kdeconnect.notification") #define PACKAGE_TYPE_BATTERY QString("kdeconnect.battery") -#define PACKAGE_TYPE_CALL QString("kdeconnect.call") +#define PACKAGE_TYPE_TELEPHONY QString("kdeconnect.telephony") #define PACKAGE_TYPE_CLIPBOARD QString("kdeconnect.clipboard") #define PACKAGE_TYPE_MPRIS QString("kdeconnect.mpris") diff --git a/daemon/plugins/pausemusic/pausemusicplugin.cpp b/daemon/plugins/pausemusic/pausemusicplugin.cpp index 72267130f..bb69a95a4 100644 --- a/daemon/plugins/pausemusic/pausemusicplugin.cpp +++ b/daemon/plugins/pausemusic/pausemusicplugin.cpp @@ -41,28 +41,20 @@ PauseMusicPlugin::PauseMusicPlugin(QObject* parent, const QVariantList& args) bool PauseMusicPlugin::receivePackage(const NetworkPackage& np) { + if (np.type() != PACKAGE_TYPE_TELEPHONY) return false; - bool pauseConditionFulfilled = false; - - //TODO: I have manually tested it and it works for both "pauseWhen" cases, but I should somehow write a test for this logic + //TODO: Test this logic again if (pauseWhen == PauseWhenRinging) { - if (np.type() == PACKAGE_TYPE_NOTIFICATION) { - if (np.get("notificationType") != "ringing") return false; - pauseConditionFulfilled = !np.get("isCancel"); - } else if (np.type() == PACKAGE_TYPE_CALL) { - pauseConditionFulfilled = !np.get("isCancel"); - } else { - return false; - } + if (np.get("event") != "ringing" || np.get("event") != "talking") return false; } else if (pauseWhen == PauseWhenTalking){ - if (np.type() != PACKAGE_TYPE_CALL) return false; - pauseConditionFulfilled = !np.get("isCancel"); + if (np.get("event") != "talking") return false; } + + bool pauseConditionFulfilled = !np.get("isCancel"); + qDebug() << "PauseMusicPackageReceiver - PauseCondition:" << pauseConditionFulfilled; - //TODO: Make this async - //TODO: Make this not crash if dbus is not working if (pauseConditionFulfilled) { //Search for interfaces currently playing QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); @@ -78,7 +70,7 @@ bool PauseMusicPlugin::receivePackage(const NetworkPackage& np) } } } - } if (!pauseConditionFulfilled) { + } else { Q_FOREACH (const QString& iface, pausedSources) { QDBusInterface mprisInterface(iface, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player"); //Calling play does not work in spotify diff --git a/daemon/plugins/telephony/telephonyplugin.cpp b/daemon/plugins/telephony/telephonyplugin.cpp index 67e814181..656f51a73 100644 --- a/daemon/plugins/telephony/telephonyplugin.cpp +++ b/daemon/plugins/telephony/telephonyplugin.cpp @@ -125,7 +125,7 @@ void TelephonyPlugin::showPendingNotifications() bool TelephonyPlugin::receivePackage(const NetworkPackage& np) { - if (np.type() != PACKAGE_TYPE_NOTIFICATION) return false; + if (np.type() != PACKAGE_TYPE_TELEPHONY) return false; if (np.get("isCancel")) {