Fixed cmakelists bug that made necessary to run make without -j
Using a nicer dbus syntax in pausemusicpackageinterface
This commit is contained in:
parent
c2336a22a1
commit
ee7f6b0c6d
5 changed files with 32 additions and 27 deletions
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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<QDBusVariant>(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<QDBusVariant>(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();
|
||||
}
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue