Mpris plugin to new format +commited missing files

Added files missing from previous commits (KDevelop git support fault :)
Fixed includes in linkprovider.h
Added icons to plugins
This commit is contained in:
Albert Vaca 2013-08-13 06:35:58 +02:00
parent a062c68848
commit 049c708743
12 changed files with 121 additions and 38 deletions

View file

@ -25,8 +25,7 @@
#include <QVector>
#include <QNetworkSession>
#include "devicelinks/devicelink.h"
#include "device.h"
#include "../networkpackage.h"
class DeviceLink;

View file

@ -3,4 +3,5 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
add_subdirectory(ping)
add_subdirectory(pausemusic)
add_subdirectory(mpriscontrol)

View file

@ -0,0 +1,5 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=KdeConnect/Plugin
X-KDE-Derived=KPluginInfo
Name=KDEConnect Plugin

View file

@ -1,12 +0,0 @@
qt4_add_dbus_interface(
kded_kdeconnect_SRCS
packageinterfaces/mprisdbusinterface.xml
mprisdbusinterface
)
qt4_add_dbus_interface(
kded_kdeconnect_SRCS
packageinterfaces/propertiesInterface.xml
propertiesdbusinterface
)

View file

@ -0,0 +1,36 @@
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(kdeconnect_mpriscontrol_SRCS
mpriscontrolplugin.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../device.cpp
)
qt4_add_dbus_interface(
kdeconnect_mpriscontrol_SRCS
mprisdbusinterface.xml
mprisdbusinterface
)
qt4_add_dbus_interface(
kdeconnect_mpriscontrol_SRCS
propertiesInterface.xml
propertiesdbusinterface
)
kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS})
target_link_libraries(kdeconnect_mpriscontrol
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
qjson
)
install(TARGETS kdeconnect_mpriscontrol DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_mpriscontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -0,0 +1,15 @@
[Desktop Entry]
Encoding=UTF-8
Type=Service
ServiceTypes=KdeConnect/Plugin
X-KDE-Library=kdeconnect_mpriscontrol
X-KDE-PluginInfo-Author=Albert Vaca
X-KDE-PluginInfo-Email=albertvaka@gmail.com
X-KDE-PluginInfo-Name=kdeconnect_mpriscontrol
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=media-playback-start
Name=Multimedia control receiver
Comment=Remote control your music and videos

View file

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mpriscontrolpackageinterface.h"
#include "mpriscontrolplugin.h"
#include "propertiesdbusinterface.h"
@ -29,7 +29,11 @@
#include <QDBusReply>
#include <QDBusMessage>
MprisControlPackageInterface::MprisControlPackageInterface()
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MprisControlPlugin >(); )
K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mpriscontrol", "kdeconnect_mpriscontrol") )
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
//Detect new interfaces
@ -46,7 +50,7 @@ MprisControlPackageInterface::MprisControlPackageInterface()
}
void MprisControlPackageInterface::serviceOwnerChanged(const QString &name,
void MprisControlPlugin::serviceOwnerChanged(const QString &name,
const QString &oldOwner,
const QString &newOwner)
{
@ -54,7 +58,7 @@ void MprisControlPackageInterface::serviceOwnerChanged(const QString &name,
if (name.startsWith("org.mpris.MediaPlayer2")) {
qDebug() << "Something (un)registered in bus" << name << oldOwner << newOwner;
qDebug() << "Mpris (un)registered in bus" << name << oldOwner << newOwner;
if (oldOwner.isEmpty()) {
addPlayer(name);
@ -64,7 +68,7 @@ void MprisControlPackageInterface::serviceOwnerChanged(const QString &name,
}
}
void MprisControlPackageInterface::addPlayer(const QString& service)
void MprisControlPlugin::addPlayer(const QString& service)
{
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
const QString& identity = mprisInterface.property("Identity").toString();
@ -77,7 +81,7 @@ void MprisControlPackageInterface::addPlayer(const QString& service)
}
void MprisControlPackageInterface::propertiesChanged(const QString& propertyInterface, const QVariantMap& properties)
void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, const QVariantMap& properties)
{
NetworkPackage np(PACKAGE_TYPE_MPRIS);
@ -115,19 +119,18 @@ void MprisControlPackageInterface::propertiesChanged(const QString& propertyInte
const QString& service = interface->service();
const QString& player = playerList.key(service);
np.set("player", player);
sendPackage(np);
device()->sendPackage(np);
}
}
void MprisControlPackageInterface::removePlayer(const QString& ifaceName)
void MprisControlPlugin::removePlayer(const QString& ifaceName)
{
playerList.remove(playerList.key(ifaceName));
sendPlayerList();
}
bool MprisControlPackageInterface::receivePackage (const Device& device, const NetworkPackage& np)
bool MprisControlPlugin::receivePackage (const NetworkPackage& np)
{
Q_UNUSED(device);
if (np.type() != PACKAGE_TYPE_MPRIS) return false;
@ -135,7 +138,7 @@ bool MprisControlPackageInterface::receivePackage (const Device& device, const N
const QString& player = np.get<QString>("player");
bool valid_player = playerList.contains(player);
if (!valid_player || np.get<bool>("requestPlayerList")) {
sendPlayerList(&device);
sendPlayerList();
if (!valid_player) {
return true;
}
@ -185,17 +188,16 @@ bool MprisControlPackageInterface::receivePackage (const Device& device, const N
}
if (somethingToSend) {
answer.set("player", player);
device.sendPackage(answer);
device()->sendPackage(answer);
}
return true;
}
void MprisControlPackageInterface::sendPlayerList(const Device* device)
void MprisControlPlugin::sendPlayerList()
{
NetworkPackage np(PACKAGE_TYPE_MPRIS);
np.set("playerList",playerList.keys());
if (device == NULL) Q_EMIT sendPackage(np);
else device->sendPackage(np);
device()->sendPackage(np);
}

View file

@ -21,22 +21,24 @@
#ifndef MPRISCONTROLPACKAGEINTERFACE_H
#define MPRISCONTROLPACKAGEINTERFACE_H
#include "packageinterface.h"
#include "mprisdbusinterface.h"
#include <QSet>
#include <QString>
#include <QHash>
#include <QDBusArgument>
class MprisControlPackageInterface
: public PackageInterface
#include "../kdeconnectplugin.h"
#include "mprisdbusinterface.h"
class MprisControlPlugin
: public KdeConnectPlugin
{
Q_OBJECT
public:
MprisControlPackageInterface();
virtual bool receivePackage(const Device& device, const NetworkPackage& np);
explicit MprisControlPlugin(QObject *parent, const QVariantList &args);
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);
private Q_SLOTS:
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
@ -46,7 +48,7 @@ private:
QHash<QString, QString> playerList;
void addPlayer(const QString& ifaceName);
void removePlayer(const QString& ifaceName);
void sendPlayerList(const Device* device = 0);
void sendPlayerList();
int prevVolume;
};

View file

@ -28,7 +28,7 @@
<property access="readwrite" type="d" name="Rate"/>
<property access="readwrite" type="b" name="Shuffle"/>
<property access="read" type="a{sv}" name="Metadata">
<annotation value="QVariantMap" name="com.trolltech.QtDBus.QtTypeName"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName"/>
</property>
<property access="readwrite" type="d" name="Volume"/>
<property access="read" type="x" name="Position"/>

View file

@ -0,0 +1,20 @@
find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(kdeconnect_pausemusic_SRCS
pausemusicplugin.cpp
../kdeconnectplugin.cpp
)
kde4_add_plugin(kdeconnect_pausemusic ${kdeconnect_pausemusic_SRCS})
target_link_libraries(kdeconnect_pausemusic
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
qjson
)
install(TARGETS kdeconnect_pausemusic DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_pausemusic.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -0,0 +1,15 @@
[Desktop Entry]
Encoding=UTF-8
Type=Service
ServiceTypes=KdeConnect/Plugin
X-KDE-Library=kdeconnect_pausemusic
X-KDE-PluginInfo-Author=Albert Vaca
X-KDE-PluginInfo-Email=albertvaka@gmail.com
X-KDE-PluginInfo-Name=kdeconnect_pausemusic
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=speaker
Name=Pause music on call
Comment=Pause music during a phone call