~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-rhythmbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Iain Lane
  • Date: 2011-10-09 00:19:16 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20111009001916-9czstskx2t6l0b3x
Tags: 2.4.0~2-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream bug fix release. (LP: #859984)
* Upstream (short) ChangeLog (2.4.0~0beta2 -> 2.4.0~1):
 - Powermanager: correctly release the reference on the device object
 - logout: now works if there is no session-manager
 - Status-Notifier: fixed a small bug
    (wrong callback in cairo_dock_stop_watching_dbus_name_owner)
 - Folders: fixed the positionning of the new icon
    and the dialog when dropping a folder inside the dock
    and fixed the icon-rendering
 - Dustbin: use the default theme if no icon is found
 - Impulse: the default context seems to be ok and not an error
 - Status-Notifier: On Ubuntu Oneiric (with indicator-0.4)
    the ApplicationAdded signal has changed and has a new parameter
 - Disable MeMenu on Oneiric (no longer available with indicator-0.4)
 - CMakeLists.txt: Improved output messages
 - Slide view: fixed a small offset in vertical view
 - musicPlayer:
  + split MPRIS 1.0 and 2.0 to help debugging and finding the right
     name of the bug.
  + 'rhythmbox-client' tool is no longer available: used MPRIS
  + Disable Amazon service (it no longer work)
  + Cover: fixed corrupted icons: some players (e.g. the latest version
     of RB) copy covers on their cache forlder but it takes a few time.
  + Fixed the update the icon and its name if the player is stopped.
  + Prevent a crash if the name given by MPRIS is NULL
 - Powermanager: try to prevent to have a few dialogues at the same time
 - PowerManager and AlsaMixer: hidden gnome2 or 3 apps if not available
 - Messaging-Menu: Updated for Natty and Oneiric
    (dbus-menu gives us GVariant instead of GValue objects)
 - Alsamixer: fixed a small bug on reload
 - Dbus: Bash interface: Fixed a typo with emblem positions
 - Sys-monitor: fixed a bug which prevented from getting
    the CPU temperature in some cases
 - Compiz (0.9): type filter: replaced type=utility by type=Utility
 - Updated the version of all applets that have gauges
   in order to use the right directory
 - Wifi: Fixed the status if we are not connected
 - Dbus: removed a conflict with the Help applet
 - Messaging-Menu: updated applet-menu.c => Memory leaks on pixbufs
 - Dbus: Fixed a crash when changing dock theme if a 'third-party' applet
    is running
 - Netspeed: in /proc/net/dev, there are 8 values to drop after the card id
    except if there is whitespaces just after this ':' character
    and fixed order and value for ON_ICON display
 - dock-rendering/toto: removed a useless file
 - Clipper: fixed the loading of the remembered items
    (they had the wrong type) and fixed a bug if we reduce the list of items
 - Folders, dustbin, Network-Monitor: tried to not use cast if it's possible
 - Code cleaned and re-organised a few functions
   (e.g. emblem references has been renamed)
 - Removed useless files: powermanager-dbus*
 - Updating translations
 - Fixed a few warnings at the compilation
 - Removed a few useless output messages
 - Fixed these LP bugs:
  + Empty trash from the trashcan does not delete files
     from usb harddisks: LP: #658681
  + Switcher applet doesn't respect desktop numbers LP: #626782
* Upstream (short) ChangeLog (2.4.0~1 -> 2.4.0~2):
 - Messaging-Menu: fixed a wrong g_object_unref (double free)
    and a small memory leak
 - Folders: fixed a tiny warning at the compilation (32bits)
 - switcher: removed an unnecessary config parameter
 - Folders: file size: used English instead of French translation.
 - Indicator applet: Forced a cast to remove an annoying warning
    due to clumsy dbusmenu_gtkmenu_new() declaration
 - Fixed the detection of the screensaver
 - Fixed tiny warnings at the compilation (with CAIRO_CONTAINER)
* debian/control:
 - Updated the version of cairo-dock-[core;data;dev].
 - Added gvfs as 'Suggests' for cairo-dock-plug-ins-integration
    (Used for managing files)
 - Removed 'libthunar-vfs-1-dev' (libthunar-vfs is no longer installed
    by default since XFCE 4.8 and it is replaced by gvfs)
 - Removed 'indicator-me' (no longer available
    and the installation of Cairo-Dock produces an error)
 - Moved 'indicator-messages' to 'Recommends'
* debian/rules:
 - Updated the name of CMake extras flags
* debian/cairo-dock-plug-ins-data.lintian-overrides:
 - Deleted (now useless)
* debian/cairo-dock-plug-ins.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - shlib-without-versioned-soname: forwarded to upstream.
* debian/cairo-dock-plug-ins-integration.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - ldconfig and shlibs are not needed
* debian/cairo-dock-plug-ins.install:
 - Fixed lintian errors: package-installs-python-bytecode
* debian/control: Fixed lintian warnings:
 - python-script-but-no-python-dep
 - description-synopsis-starts-with-article
* debian/changelog:
 - Fixed lintian warning: old-fsf-address-in-copyright-file
* debian/patches/01-switcher-force-compact-view.patch: 
 - Forced the compact view because the other doesn't work

[ Iain Lane ]
* Fix Mono/CLI build to be ~policy compliant and use correct compiler

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "applet-dbus.h"
29
29
#include "applet-draw.h"
30
30
#include "applet-cover.h"
 
31
#include "applet-mpris.h"
31
32
#include "applet-rhythmbox.h"
32
33
 
33
34
/////////////////////////////////
129
130
// Les callbacks des signaux DBus. //
130
131
/////////////////////////////////////
131
132
 
132
 
/* Fonction executée à chaque changement de musique.
 
133
/* Fonction executee a chaque changement de musique.
133
134
 */
134
135
static void onChangeSong(DBusGProxy *player_proxy,const gchar *uri, gpointer data)
135
136
{
140
141
        if(uri != NULL && *uri != '\0')
141
142
        {
142
143
                myData.cPlayingUri = g_strdup (uri);
143
 
                myData.bIsRunning = TRUE;
144
144
                cd_rhythmbox_getSongInfos (TRUE);  // TRUE <=> get all
145
145
        }
146
146
        else
158
158
                myData.cCoverPath = NULL;
159
159
                myData.iSongLength = 0;
160
160
                myData.iTrackNumber = 0;
161
 
                
162
 
                cd_musicplayer_dbus_detect_player ();
163
161
        }
164
162
        cd_musicplayer_update_icon (TRUE);
165
163
        CD_APPLET_LEAVE ();
166
164
}
167
165
 
168
 
/* Fonction executée à chaque changement play/pause
 
166
/* Fonction executee a chaque changement play/pause
169
167
 */
170
168
static void onChangePlaying(DBusGProxy *player_proxy, gboolean playing, gpointer data)
171
169
{
187
185
}
188
186
 
189
187
 
190
 
/* Fonction executée à chaque changement de temps joué
 
188
/* Fonction executee a chaque changement de temps joué
191
189
 */
192
190
static void onElapsedChanged (DBusGProxy *player_proxy, int elapsed, gpointer data)
193
191
{
239
237
// Definition du backend. //
240
238
////////////////////////////
241
239
 
242
 
/* Fonction de connexion au bus de rhythmbox.
243
 
 */
244
 
gboolean cd_rhythmbox_dbus_connect_to_bus (void)
245
 
{
246
 
        if (cairo_dock_dbus_is_enabled ())
247
 
        {
248
 
                myData.dbus_enable = cd_musicplayer_dbus_connect_to_bus (); // cree le proxy.
249
 
                
250
 
                myData.dbus_enable_shell = musicplayer_dbus_connect_to_bus_Shell ();  // cree le proxy pour la 2eme interface car RB en a 2.
251
 
                
252
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingChanged",
253
 
                        G_TYPE_BOOLEAN,
254
 
                        G_TYPE_INVALID);
255
 
                
256
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingUriChanged",
257
 
                        G_TYPE_STRING,
258
 
                        G_TYPE_INVALID);
259
 
                
260
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "elapsedChanged",
261
 
                        G_TYPE_UINT,
262
 
                        G_TYPE_INVALID);
263
 
                
264
 
                /*TODO
265
 
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingSongPropertyChanged",
266
 
                        G_TYPE_STRING,
267
 
                        G_TYPE_STRING,
268
 
                        G_TYPE_VALUE,
269
 
                        G_TYPE_VALUE,
270
 
                        G_TYPE_INVALID);*/
271
 
                
272
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingChanged",
273
 
                        G_CALLBACK(onChangePlaying), NULL, NULL);
274
 
                        
275
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingUriChanged",
276
 
                        G_CALLBACK(onChangeSong), NULL, NULL);
277
 
                
278
 
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "elapsedChanged",
279
 
                        G_CALLBACK(onElapsedChanged), NULL, NULL);
280
 
                
281
 
                /*dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingSongPropertyChanged",
282
 
                        G_CALLBACK(onSongPropertyChanged), NULL, NULL);*/
283
 
                
284
 
                return TRUE;
285
 
        }
286
 
        return FALSE;
287
 
}
288
 
 
289
 
/* Permet de libérer la mémoire prise par notre controleur
290
 
 */
291
 
void cd_rhythmbox_free_data (void) {
292
 
        if (myData.dbus_proxy_player != NULL)
293
 
        {
294
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "playingChanged",
295
 
                        G_CALLBACK(onChangePlaying), NULL);
296
 
                
297
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "playingUriChanged",
298
 
                        G_CALLBACK(onChangeSong), NULL);
299
 
                
300
 
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "elapsedChanged",
301
 
                        G_CALLBACK(onElapsedChanged), NULL);
302
 
                
303
 
                /*dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "playingSongPropertyChanged",
304
 
                        G_CALLBACK(onSongPropertyChanged), NULL);*/
305
 
        }
306
 
        
307
 
        musicplayer_dbus_disconnect_from_bus();
308
 
        musicplayer_dbus_disconnect_from_bus_Shell();
309
 
}
310
 
 
311
 
 
312
240
/* Controle du lecteur (permet d'effectuer les actions de bases sur le lecteur)
313
241
 */
314
242
void cd_rhythmbox_control (MyPlayerControl pControl, const char* song)
318
246
                
319
247
        switch (pControl) {
320
248
                case PLAYER_PREVIOUS :
321
 
                        cCommand = myData.DBus_commands.previous;  // ou bien rhythmbox-client --previous
 
249
                        cCommand = "previous";  // ou bien rhythmbox-client --previous
322
250
                break;
323
251
                
324
252
                case PLAYER_PLAY_PAUSE :
325
 
                        cCommand = myData.DBus_commands.play;  // ou bien rhythmbox-client --pause/--play
 
253
                        cCommand = "playPause";  // ou bien rhythmbox-client --pause/--play
326
254
                break;
327
255
 
328
256
                case PLAYER_NEXT :
329
 
                        cCommand = myData.DBus_commands.next;  // ou bien rhythmbox-client --next
 
257
                        cCommand = "next";  // ou bien rhythmbox-client --next
330
258
                break;
331
259
                
332
260
                case PLAYER_ENQUEUE :
364
292
 
365
293
/* Initialise le backend de RB.
366
294
 */
367
 
void cd_rhythmbox_configure (void)
368
 
{
369
 
        cd_debug ("");
370
 
        myData.DBus_commands.service = "org.gnome.Rhythmbox";
371
 
        myData.DBus_commands.path = "/org/gnome/Rhythmbox/Player";
372
 
        myData.DBus_commands.path2 = "/org/gnome/Rhythmbox/Shell";
373
 
        myData.DBus_commands.interface = "org.gnome.Rhythmbox.Player";
374
 
        myData.DBus_commands.interface2 = "org.gnome.Rhythmbox.Shell";
375
 
        myData.DBus_commands.play = "playPause";
376
 
        myData.DBus_commands.pause = "playPause";
377
 
        myData.DBus_commands.stop = "";
378
 
        myData.DBus_commands.next = "next";
379
 
        myData.DBus_commands.previous = "previous";
380
 
        
381
 
        myData.dbus_enable = cd_rhythmbox_dbus_connect_to_bus ();  // se connecte au bus et aux signaux de RB.
382
 
        if (myData.dbus_enable)
383
 
        {
384
 
                cd_musicplayer_dbus_detect_player ();  // on teste la presence de RB sur le bus <=> s'il est ouvert ou pas.
385
 
                if(myData.bIsRunning)  // player en cours d'execution, on recupere son etat.
386
 
                {
387
 
                        cd_debug ("MP : RB is running");
388
 
                        _rhythmbox_getPlaying();
389
 
                        _rhythmbox_getPlayingUri();
390
 
                        cd_rhythmbox_getSongInfos (TRUE);  // TRUE <=> get all
391
 
                        cd_musicplayer_update_icon (TRUE);
392
 
                }
393
 
                else  // player eteint.
394
 
                {
395
 
                        cd_musicplayer_set_surface (PLAYER_NONE);
396
 
                }
397
 
        }
398
 
        else  // sinon on signale par l'icone appropriee que le bus n'est pas accessible.
399
 
        {
400
 
                cd_musicplayer_set_surface (PLAYER_BROKEN);
401
 
        }
 
295
static void cd_rhythmbox_start (void)
 
296
{
 
297
        // register to the signals
 
298
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingChanged",
 
299
                G_TYPE_BOOLEAN,
 
300
                G_TYPE_INVALID);
 
301
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingChanged",
 
302
                G_CALLBACK(onChangePlaying), NULL, NULL);
 
303
        
 
304
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingUriChanged",
 
305
                G_TYPE_STRING,
 
306
                G_TYPE_INVALID);
 
307
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingUriChanged",
 
308
                G_CALLBACK(onChangeSong), NULL, NULL);
 
309
        
 
310
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "elapsedChanged",
 
311
                G_TYPE_UINT,
 
312
                G_TYPE_INVALID);
 
313
        dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "elapsedChanged",
 
314
                G_CALLBACK(onElapsedChanged), NULL, NULL);
 
315
        
 
316
        /*TODO (or maybe not, if they included MPRIS2)
 
317
        dbus_g_proxy_add_signal(myData.dbus_proxy_player, "playingSongPropertyChanged",
 
318
                G_TYPE_STRING,
 
319
                G_TYPE_STRING,
 
320
                G_TYPE_VALUE,
 
321
                G_TYPE_VALUE,
 
322
                G_TYPE_INVALID);
 
323
        /*dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "playingSongPropertyChanged",
 
324
                G_CALLBACK(onSongPropertyChanged), NULL, NULL);*/
 
325
        
 
326
        // get the current state.
 
327
        _rhythmbox_getPlaying();
 
328
        _rhythmbox_getPlayingUri();
 
329
        cd_rhythmbox_getSongInfos (TRUE);  // TRUE <=> get all
 
330
        cd_musicplayer_update_icon (TRUE);
 
331
}
 
332
 
 
333
/*
 
334
 * We can't test if a bus is available because the dock is launched after.
 
335
 * Or we have to connect to a bus before and react if there is something after...
 
336
 *  but it's a bit annoying because we have to register the handler and then disable it (e.g. MPRIS vs MPRIS2)!
 
337
 * But with the version 2.90 of RB, we have to use MPRIS2 because rhythmbox-client is unavailable.
 
338
 */
 
339
static gboolean _is_MPRIS2_available (void)
 
340
{
 
341
        gchar *cResult = cairo_dock_launch_command_sync ("which rhythmbox-client");
 
342
        gboolean bResult = ! (cResult != NULL && *cResult == '/');
 
343
        g_free (cResult);
 
344
        return bResult;
402
345
}
403
346
 
404
347
/* On enregistre notre lecteur.
405
348
 */
406
349
void cd_musicplayer_register_rhythmbox_handler (void)
407
350
{
408
 
        cd_debug ("");
409
 
        MusicPlayerHandeler *pRhythmbox = g_new0 (MusicPlayerHandeler, 1);
410
 
        pRhythmbox->read_data = NULL;  // rien a faire vu que l'echange de donnees se fait entierement avec les proxys DBus.
411
 
        pRhythmbox->free_data = cd_rhythmbox_free_data;
412
 
        pRhythmbox->configure = cd_rhythmbox_configure;  // renseigne les proprietes DBus et se connecte au bus.
413
 
        pRhythmbox->control = cd_rhythmbox_control;
414
 
        pRhythmbox->get_cover = cd_rhythmbox_get_cover_path;
415
 
        
416
 
        pRhythmbox->appclass = "rhythmbox";
417
 
        pRhythmbox->name = "Rhythmbox";
418
 
        pRhythmbox->launch = "rhythmbox";
419
 
        pRhythmbox->cMprisService = "org.gnome.Rhythmbox";
420
 
        pRhythmbox->cCoverDir = g_strdup_printf ("%s/.cache/rhythmbox/covers", g_getenv ("HOME"));
421
 
        pRhythmbox->iPlayer = MP_RHYTHMBOX;
422
 
        pRhythmbox->bSeparateAcquisition = FALSE;
423
 
        pRhythmbox->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT | PLAYER_ENQUEUE;
424
 
        pRhythmbox->iLevel = PLAYER_EXCELLENT;
425
 
        
426
 
        cd_musicplayer_register_my_handler(pRhythmbox, "rhythmbox");
 
351
        if (_is_MPRIS2_available ())
 
352
        {
 
353
                cd_debug ("MP - MPRIS2 for RB seems to be available");
 
354
                MusicPlayerHandler *pHandler = cd_mpris_new_handler ();
 
355
                pHandler->cMprisService = "org.mpris.MediaPlayer2.rhythmbox";
 
356
                pHandler->appclass = "rhythmbox";
 
357
                pHandler->launch = "rhythmbox";
 
358
                pHandler->name = "Rhythmbox";
 
359
                cd_musicplayer_register_my_handler (pHandler);
 
360
                myData.bForceCoverNeedsTest = TRUE; // it seems RB copy the cover on its cache but it takes a few time...
 
361
        }
 
362
        else
 
363
        {
 
364
                cd_debug ("MP - Used RB DBus methods");
 
365
                MusicPlayerHandler *pHandler = g_new0 (MusicPlayerHandler, 1);
 
366
                pHandler->name = "Rhythmbox";
 
367
                pHandler->get_data = NULL;  // rien a faire vu que l'echange de donnees se fait entierement avec les proxys DBus.
 
368
                pHandler->stop = NULL;  // signals are disconnected when the proxy is destroyed.
 
369
                pHandler->start = cd_rhythmbox_start;  // renseigne les proprietes DBus et se connecte au bus.
 
370
                pHandler->control = cd_rhythmbox_control;
 
371
                pHandler->get_cover = cd_rhythmbox_get_cover_path;
 
372
                
 
373
                pHandler->appclass = "rhythmbox";
 
374
                pHandler->launch = "rhythmbox";
 
375
                pHandler->cMprisService = "org.gnome.Rhythmbox";
 
376
                pHandler->path = "/org/gnome/Rhythmbox/Player";
 
377
                pHandler->interface = "org.gnome.Rhythmbox.Player";
 
378
                pHandler->path2 = "/org/gnome/Rhythmbox/Shell";
 
379
                pHandler->interface2 = "org.gnome.Rhythmbox.Shell";
 
380
                
 
381
                pHandler->cCoverDir = g_strdup_printf ("%s/.cache/rhythmbox/covers", g_getenv ("HOME"));
 
382
                pHandler->bSeparateAcquisition = FALSE;
 
383
                pHandler->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT | PLAYER_ENQUEUE;
 
384
                pHandler->iLevel = PLAYER_EXCELLENT;
 
385
                
 
386
                cd_musicplayer_register_my_handler(pHandler);
 
387
        }
427
388
}