2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include <glib/gi18n.h>
24
#include <cairo-dock.h>
27
#include "applet-struct.h"
28
#include "applet-musicplayer.h"
29
#include "applet-dbus.h"
30
#include "applet-draw.h"
31
#include "applet-listen.h"
35
void cd_listen_getSongInfos(void)
37
if( myData.cPreviousRawTitle )
39
g_free( myData.cPreviousRawTitle ); myData.cPreviousRawTitle = NULL;
41
if( myData.cRawTitle )
43
myData.cPreviousRawTitle = g_strdup(myData.cRawTitle);
45
myData.cRawTitle=cairo_dock_dbus_get_string (myData.dbus_proxy_player, myData.DBus_commands.get_title);
49
/* Permet de libérer la mémoire prise par notre controleur */
50
void cd_listen_free_data (void) {
51
cd_debug("MP : Deconnexion de DBus");
52
musicplayer_dbus_disconnect_from_bus();
56
/* Controle du lecteur */
57
void cd_listen_control (MyPlayerControl pControl, const char *file) { //Permet d'effectuer les actions de bases sur le lecteur
60
const gchar *cCommand = NULL;
61
/* Conseil de ChangFu pour redetecter le titre à coup sûr */
62
g_free (myData.cRawTitle);
63
myData.cRawTitle = NULL;
66
case PLAYER_PREVIOUS :
67
cCommand = myData.DBus_commands.previous;
70
case PLAYER_PLAY_PAUSE :
71
cCommand = myData.DBus_commands.play;
75
cCommand = myData.DBus_commands.next;
83
if (cCommand != NULL) {
84
cd_debug ("MP : Handeler Listen : will use '%s'", cCommand);
85
cairo_dock_dbus_call(myData.dbus_proxy_player, cCommand);
89
/* Fonction de lecture des infos */
90
void cd_listen_read_data (void) {
91
if (myData.bIsRunning)
93
if (myData.dbus_enable)
95
cd_listen_getSongInfos(); // On recupere toutes les infos de la piste en cours
99
//cd_debug("MP : Impossible d'acceder au bus");
100
myData.iPlayingStatus = PLAYER_BROKEN;
105
//cd_debug("MP : lecteur non ouvert");
106
myData.iPlayingStatus = PLAYER_NONE;
110
void cd_listen_load_dbus_commands (void)
113
myData.DBus_commands.service = "org.gnome.Listen";
114
myData.DBus_commands.path = "/org/gnome/listen";
115
myData.DBus_commands.interface = "org.gnome.Listen";
116
myData.DBus_commands.play = "play_pause";
117
myData.DBus_commands.pause = "play_pause";
118
myData.DBus_commands.stop = "";
119
myData.DBus_commands.next = "next";
120
myData.DBus_commands.previous = "previous";
121
myData.DBus_commands.get_title = "current_playing";
122
myData.DBus_commands.get_artist = "";
123
myData.DBus_commands.get_album = "";
124
myData.DBus_commands.get_cover_path = "";
125
myData.DBus_commands.get_status = "";
126
myData.DBus_commands.duration = "";
127
myData.DBus_commands.current_position = "";
131
void cd_musicplayer_register_listen_handler (void) { //On enregistre notre lecteur
133
MusicPlayerHandeler *pListen = g_new0 (MusicPlayerHandeler, 1);
134
pListen->read_data = cd_listen_read_data;
135
pListen->free_data = cd_listen_free_data;
136
pListen->configure = cd_listen_load_dbus_commands; //Cette fonction permettera de préparé le controleur
137
//Pour les lecteurs utilisants dbus, c'est elle qui connectera le dock aux services des lecteurs etc..
138
pListen->control = cd_listen_control;
139
pListen->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT;
140
pListen->appclass = "listen.py";
141
pListen->name = "Listen";
142
pListen->name = "listen"; /// a verifier ...
143
pListen->cMprisService = "org.gnome.Listen";
144
pListen->bSeparateAcquisition = FALSE;
145
pListen->iLevel = PLAYER_BAD;
146
cd_musicplayer_register_my_handler (pListen, "Listen");