Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Weixuan Xiao
kdeconnect-kde
Commits
7b0bbebc
Commit
7b0bbebc
authored
Jul 29, 2013
by
Albert Vaca Cintora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First implementation of the mpris control packageinterface
parent
3eb6ecaa
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
6 deletions
+100
-6
daemon/CMakeLists.txt
daemon/CMakeLists.txt
+1
-0
daemon/daemon.cpp
daemon/daemon.cpp
+2
-0
daemon/networkpackagetypes.h
daemon/networkpackagetypes.h
+1
-1
daemon/packageinterfaces/mpriscontrolpackageinterface.cpp
daemon/packageinterfaces/mpriscontrolpackageinterface.cpp
+53
-0
daemon/packageinterfaces/mpriscontrolpackageinterface.h
daemon/packageinterfaces/mpriscontrolpackageinterface.h
+38
-0
daemon/packageinterfaces/pausemusicpackageinterface.cpp
daemon/packageinterfaces/pausemusicpackageinterface.cpp
+2
-2
daemon/packageinterfaces/pausemusicpackageinterface.h
daemon/packageinterfaces/pausemusicpackageinterface.h
+3
-3
No files found.
daemon/CMakeLists.txt
View file @
7b0bbebc
...
...
@@ -14,6 +14,7 @@ set(kded_kdeconnect_SRCS
packageinterfaces/pausemusicpackageinterface.cpp
packageinterfaces/clipboardpackageinterface.cpp
packageinterfaces/batterypackageinterface.cpp
packageinterfaces/mpriscontrolpackageinterface.cpp
packageinterfaces/devicebatteryinformation_p.cpp
networkpackage.cpp
...
...
daemon/daemon.cpp
View file @
7b0bbebc
...
...
@@ -27,6 +27,7 @@
#include "packageinterfaces/pausemusicpackageinterface.h"
#include "packageinterfaces/clipboardpackageinterface.h"
#include "packageinterfaces/batterypackageinterface.h"
#include "packageinterfaces/mpriscontrolpackageinterface.h"
#include "linkproviders/avahitcplinkprovider.h"
#include "linkproviders/loopbacklinkprovider.h"
...
...
@@ -65,6 +66,7 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
mPackageInterfaces
.
push_back
(
new
PauseMusicPackageInterface
());
mPackageInterfaces
.
push_back
(
new
ClipboardPackageInterface
());
mPackageInterfaces
.
push_back
(
new
BatteryPackageInterface
(
this
));
mPackageInterfaces
.
push_back
(
new
MprisControlPackageInterface
());
//TODO: Do not hardcode the load of the device locators
//use: https://techbase.kde.org/Development/Tutorials/Services/Plugins
...
...
daemon/networkpackagetypes.h
View file @
7b0bbebc
...
...
@@ -27,7 +27,7 @@
#define PACKAGE_TYPE_BATTERY QString("kdeconnect.battery")
#define PACKAGE_TYPE_CALL QString("kdeconnect.call")
#define PACKAGE_TYPE_CLIPBOARD QString("kdeconnect.clipboard")
#define PACKAGE_TYPE_MPRIS QString("kdeconnect.mpris")
#endif // NETWORKPACKAGETYPES_H
daemon/packageinterfaces/mpriscontrolpackageinterface.cpp
0 → 100644
View file @
7b0bbebc
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mpriscontrolpackageinterface.h"
#include <QDebug>
#include <QDBusConnection>
#include <QDBusInterface>
#include <qdbusconnectioninterface.h>
#include <QDBusReply>
#include <QDBusMessage>
MprisControlPackageInterface
::
MprisControlPackageInterface
()
{
//TODO: Emit info read form mpris to the phone
}
bool
MprisControlPackageInterface
::
receivePackage
(
const
Device
&
device
,
const
NetworkPackage
&
np
)
{
Q_UNUSED
(
device
);
if
(
np
.
type
()
!=
PACKAGE_TYPE_MPRIS
)
return
false
;
QString
action
=
np
.
get
<
QString
>
(
"action"
);
QStringList
interfaces
=
QDBusConnection
::
sessionBus
().
interface
()
->
registeredServiceNames
().
value
();
Q_FOREACH
(
const
QString
&
iface
,
interfaces
)
{
if
(
iface
.
startsWith
(
"org.mpris.MediaPlayer2"
))
{
QDBusInterface
mprisInterface
(
iface
,
"/org/mpris/MediaPlayer2"
,
"org.mpris.MediaPlayer2.Player"
);
mprisInterface
.
asyncCall
(
action
);
}
}
return
true
;
}
daemon/packageinterfaces/mpriscontrolpackageinterface.h
0 → 100644
View file @
7b0bbebc
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MPRISCONTROLPACKAGEINTERFACE_H
#define MPRISCONTROLPACKAGEINTERFACE_H
#include "packageinterface.h"
#include <QSet>
#include <QString>
class
MprisControlPackageInterface
:
public
PackageInterface
{
public:
MprisControlPackageInterface
();
virtual
bool
receivePackage
(
const
Device
&
device
,
const
NetworkPackage
&
np
);
};
#endif
daemon/packageinterfaces/pausemusicpackageinterface.cpp
View file @
7b0bbebc
...
...
@@ -69,7 +69,7 @@ bool PauseMusicPackageInterface::receivePackage (const Device& device, const Net
if
(
status
==
"Playing"
)
{
if
(
!
pausedSources
.
contains
(
iface
))
{
pausedSources
.
insert
(
iface
);
mprisInterface
.
call
(
QDBus
::
Block
,
"Pause"
);
mprisInterface
.
asyncCall
(
"Pause"
);
}
}
}
...
...
@@ -81,7 +81,7 @@ bool PauseMusicPackageInterface::receivePackage (const Device& device, const Net
//mprisInterface->call(QDBus::Block,"Play");
//Workaround: Using playpause instead (checking first if it is already playing)
QString
status
=
mprisInterface
.
property
(
"PlaybackStatus"
).
toString
();
if
(
status
==
"Paused"
)
mprisInterface
.
call
(
QDBus
::
Block
,
"PlayPause"
);
if
(
status
==
"Paused"
)
mprisInterface
.
asyncCall
(
"PlayPause"
);
//End of workaround
}
pausedSources
.
clear
();
...
...
daemon/packageinterfaces/pausemusicpackageinterface.h
View file @
7b0bbebc
...
...
@@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PAUSEMUSICPACKAGE
RECEIVER
_H
#define PAUSEMUSICPACKAGE
RECEIVER
_H
#ifndef PAUSEMUSICPACKAGE
INTERFACE
_H
#define PAUSEMUSICPACKAGE
INTERFACE
_H
#include "packageinterface.h"
...
...
@@ -40,4 +40,4 @@ private:
};
#endif
// PAUSEMUSICPACKAGERECEIVER_H
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment