~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/3.0.0.0rc1

« back to all changes in this revision

Viewing changes to musicPlayer/src/applet-listen.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne, Matthieu Baerts (matttbe), Julien Lavergne
  • Date: 2009-10-05 19:27:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091005192717-mvqvb395guktr401
Tags: 2.0.9-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream release (LP: #435590)
* debian/control: 
 - Remove ${shlibs:Depends} for integration plug-ins to avoid
   pulling shared libraries which are detected automatically.
 - Added curl as depends for cairo-dock-plug-ins
* debian/rules:
 - Add --enable-dnd2share and --enable-musicplayer to enable new applets.
 - Remove --enable-rhythmbox and --enable-nvidia to remove those applets,
   not maintained upstream.
* Update *.install to take all generated applets.

[ Julien Lavergne ]
* Adjust changelog with Daniel Holbach suggestions.
* cairo-dock-plug-ins.changelogs:  Install specific changelog for 2.0.9
* Build-depends on cairo-dock-dev (>= 2.0.9)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
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.
 
11
*
 
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/>.
 
18
*/
 
19
 
 
20
#include <stdlib.h>
 
21
#include <string.h>
 
22
#include <stdio.h>
 
23
#include <glib/gi18n.h>
 
24
#include <cairo-dock.h>
 
25
 
 
26
 
 
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"
 
32
 
 
33
 
 
34
//Les Fonctions
 
35
void cd_listen_getSongInfos(void)
 
36
{
 
37
        if( myData.cPreviousRawTitle )
 
38
        {
 
39
                g_free( myData.cPreviousRawTitle ); myData.cPreviousRawTitle = NULL;
 
40
        }
 
41
        if( myData.cRawTitle )
 
42
        {
 
43
                myData.cPreviousRawTitle = g_strdup(myData.cRawTitle);
 
44
        }
 
45
        myData.cRawTitle=cairo_dock_dbus_get_string (myData.dbus_proxy_player, myData.DBus_commands.get_title); 
 
46
}
 
47
 
 
48
 
 
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();
 
53
}
 
54
 
 
55
 
 
56
/* Controle du lecteur */
 
57
void cd_listen_control (MyPlayerControl pControl, const char *file) { //Permet d'effectuer les actions de bases sur le lecteur
 
58
        cd_debug ("");
 
59
        
 
60
        static gchar *cCommand = NULL;
 
61
        /* Conseil de ChangFu pour redetecter le titre à coup sûr */
 
62
        g_free (myData.cRawTitle);
 
63
        myData.cRawTitle = NULL;
 
64
                
 
65
        switch (pControl) {
 
66
                case PLAYER_PREVIOUS :
 
67
                        cCommand = myData.DBus_commands.previous;
 
68
                break;
 
69
                
 
70
                case PLAYER_PLAY_PAUSE :
 
71
                        cCommand = myData.DBus_commands.play;
 
72
                break;
 
73
 
 
74
                case PLAYER_NEXT :
 
75
                        cCommand = myData.DBus_commands.next;
 
76
                break;
 
77
 
 
78
                default :
 
79
                        return;
 
80
                break;
 
81
        }
 
82
        
 
83
        if (cCommand != NULL) {
 
84
                cd_debug ("MP : Handeler Listen : will use '%s'", cCommand);
 
85
                cairo_dock_dbus_call(myData.dbus_proxy_player, cCommand);
 
86
        }
 
87
}
 
88
 
 
89
/* Fonction de lecture des infos */
 
90
void cd_listen_read_data (void) {
 
91
        if (myData.bIsRunning)
 
92
        {
 
93
                if (myData.dbus_enable)
 
94
                {
 
95
                                cd_listen_getSongInfos(); // On récupère toutes les infos de la piste en cours
 
96
                }
 
97
                else
 
98
                {
 
99
                        //cd_debug("MP : Impossible d'accéder au bus");
 
100
                        myData.iPlayingStatus = PLAYER_BROKEN;
 
101
                }
 
102
        }
 
103
        else
 
104
        {
 
105
                //cd_debug("MP : lecteur non ouvert");
 
106
                myData.iPlayingStatus = PLAYER_NONE;
 
107
        }
 
108
}
 
109
 
 
110
void cd_listen_load_dbus_commands (void)
 
111
{
 
112
        cd_debug ("");
 
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 = "";
 
128
}
 
129
 
 
130
 
 
131
void cd_musicplayer_register_listen_handler (void) { //On enregistre notre lecteur
 
132
        cd_debug ("");
 
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
        cd_musicplayer_register_my_handler (pListen, "Listen");
 
146
}
 
147