Telephony and pausemusic plugins now use kdeconnect.telephony packages (need changes in the Android code to work)

This commit is contained in:
Albert Vaca 2013-08-14 06:46:24 +02:00
parent 3d6178ae95
commit d32a667f04
4 changed files with 10 additions and 19 deletions

View file

@ -13,6 +13,5 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(daemon)
add_subdirectory(kcm)
#add_subdirectory(kioslave)
add_subdirectory(test)

View file

@ -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")

View file

@ -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<QString>("notificationType") != "ringing") return false;
pauseConditionFulfilled = !np.get<bool>("isCancel");
} else if (np.type() == PACKAGE_TYPE_CALL) {
pauseConditionFulfilled = !np.get<bool>("isCancel");
} else {
return false;
}
if (np.get<QString>("event") != "ringing" || np.get<QString>("event") != "talking") return false;
} else if (pauseWhen == PauseWhenTalking){
if (np.type() != PACKAGE_TYPE_CALL) return false;
pauseConditionFulfilled = !np.get<bool>("isCancel");
if (np.get<QString>("event") != "talking") return false;
}
bool pauseConditionFulfilled = !np.get<bool>("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

View file

@ -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<bool>("isCancel")) {