~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

Viewing changes to musicPlayer/src/applet-dbus.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:
27
27
#include "applet-musicplayer.h"
28
28
 
29
29
 
30
 
gboolean cd_musicplayer_dbus_connect_to_bus (void)
31
 
{
32
 
        if (cairo_dock_dbus_is_enabled ())
33
 
        {
34
 
                myData.dbus_proxy_player = cairo_dock_create_new_session_proxy (
35
 
                        myData.DBus_commands.service,
36
 
                        myData.DBus_commands.path,
37
 
                        myData.DBus_commands.interface);
38
 
                return (myData.dbus_proxy_player != NULL);
39
 
        }
40
 
        return FALSE;
41
 
}
42
 
 
43
 
gboolean musicplayer_dbus_connect_to_bus_Shell (void)
44
 
{
45
 
        if (cairo_dock_dbus_is_enabled ())
46
 
        {
47
 
                myData.dbus_proxy_shell = cairo_dock_create_new_session_proxy (
48
 
                        myData.DBus_commands.service,
49
 
                        myData.DBus_commands.path2,
50
 
                        myData.DBus_commands.interface2);
51
 
                return (myData.dbus_proxy_shell != NULL);
52
 
        }
53
 
        return FALSE;
54
 
}
55
 
 
56
 
void musicplayer_dbus_disconnect_from_bus (void)
 
30
gboolean cd_musicplayer_dbus_connect_handler (MusicPlayerHandler *pHandler)
 
31
{
 
32
        g_return_val_if_fail (pHandler != NULL && pHandler->cMprisService != NULL, FALSE);
 
33
        if (cairo_dock_dbus_is_enabled ())
 
34
        {
 
35
                if (pHandler->path != NULL)
 
36
                {
 
37
                        myData.dbus_proxy_player = cairo_dock_create_new_session_proxy (
 
38
                                pHandler->cMprisService,
 
39
                                pHandler->path,
 
40
                                pHandler->interface);
 
41
                }
 
42
                if (pHandler->path2 != NULL)
 
43
                {
 
44
                        myData.dbus_proxy_shell = cairo_dock_create_new_session_proxy (
 
45
                                pHandler->cMprisService,
 
46
                                pHandler->path2,
 
47
                                pHandler->interface2);
 
48
                }
 
49
                return (myData.dbus_proxy_player != NULL || myData.dbus_proxy_shell != NULL);
 
50
        }
 
51
        return FALSE;
 
52
}
 
53
 
 
54
 
 
55
void cd_musicplayer_dbus_disconnect_from_bus (void)
57
56
{
58
57
        if (myData.dbus_proxy_player != NULL)
59
58
        {
66
65
                dbus_g_proxy_cancel_call (pProxy, myData.pDetectPlayerCall);
67
66
                myData.pDetectPlayerCall = NULL;
68
67
        }
69
 
}
70
 
 
71
 
void musicplayer_dbus_disconnect_from_bus_Shell (void)
72
 
{
73
68
        if (myData.dbus_proxy_shell != NULL)
74
69
        {
75
70
                g_object_unref (myData.dbus_proxy_shell);
77
72
        }
78
73
}
79
74
 
80
 
static void _on_detect_player (gboolean bPresent, GVoidFunc pCallback)
81
 
{
82
 
        myData.bIsRunning = bPresent;
83
 
        pCallback ();
84
 
}
85
 
void cd_musicplayer_dbus_detect_player_async (GVoidFunc pCallback)
86
 
{
87
 
        myData.bIsRunning = FALSE;
88
 
        if (myData.pDetectPlayerCall != NULL)
89
 
        {
90
 
                DBusGProxy *pProxy = cairo_dock_get_main_proxy ();
91
 
                dbus_g_proxy_cancel_call (pProxy, myData.pDetectPlayerCall);
92
 
        }
93
 
        myData.pDetectPlayerCall = cairo_dock_dbus_detect_application_async (myData.DBus_commands.service, (CairoDockOnAppliPresentOnDbus) _on_detect_player, pCallback);
94
 
}
95
 
 
96
 
void cd_musicplayer_dbus_detect_player (void)
97
 
{
98
 
        myData.bIsRunning = cairo_dock_dbus_detect_application (myData.DBus_commands.service);
99
 
}
100
 
 
101
 
 
102
 
//*********************************************************************************
103
 
// musicplayer_getStatus_*() : Test si musicplayer joue de la musique ou non
104
 
//*********************************************************************************
105
 
void cd_musicplayer_getStatus_string (const char *status_paused, const char *status_playing, const char* status_stopped )
106
 
{
107
 
                gchar *status=NULL;
108
 
                status = cairo_dock_dbus_get_string (myData.dbus_proxy_player, myData.DBus_commands.get_status);
109
 
                myData.pPreviousPlayingStatus = myData.iPlayingStatus;
110
 
                if ((! g_ascii_strcasecmp(status, status_playing)) || (!g_ascii_strcasecmp(status, "1")))
111
 
                {
112
 
                        //cd_debug("MP : le lecteur est en statut PLAY");
113
 
                        myData.iPlayingStatus = PLAYER_PLAYING;
114
 
                }
115
 
                else if (! g_ascii_strcasecmp(status, status_paused))
116
 
                {
117
 
                        //cd_debug("MP : le lecteur est en statut PAUSED");
118
 
                        myData.iPlayingStatus = PLAYER_PAUSED;
119
 
                }
120
 
                else if ((status_stopped) &&(! g_ascii_strcasecmp(status, status_stopped)))
121
 
                {
122
 
                        //cd_debug("MP : le lecteur est en statut STOPPED");
123
 
                        myData.iPlayingStatus = PLAYER_STOPPED;
124
 
                }
125
 
                if (status != NULL)
126
 
                {
127
 
                        g_free(status);
128
 
                        status=NULL;
129
 
                }
130
 
}
131
 
 
132
 
void cd_musicplayer_getStatus_integer (int status_paused, int status_playing)
133
 
{
134
 
        int status;
135
 
        
136
 
        status=cairo_dock_dbus_get_integer(myData.dbus_proxy_player, myData.DBus_commands.get_status);
137
 
        //cd_debug("MP : Statut du lecteur : %d",status);
138
 
        if (status == status_paused) myData.iPlayingStatus = PLAYER_PAUSED;
139
 
        else if (status == status_playing) myData.iPlayingStatus = PLAYER_PLAYING;
140
 
        else myData.iPlayingStatus = PLAYER_STOPPED;
141
 
}
142
 
 
143
 
//*********************************************************************************
144
 
// musicplayer_getCoverPath() : Retourne l'adresse de la pochette
145
 
//*********************************************************************************
146
 
 
147
 
void cd_musicplayer_getCoverPath (void)
148
 
{
149
 
        if (myData.cCoverPath != NULL) {
150
 
                g_free (myData.cCoverPath);
151
 
                myData.cCoverPath = NULL;
152
 
        }
153
 
        
154
 
        myData.cCoverPath = cairo_dock_dbus_get_string (myData.dbus_proxy_player, myData.DBus_commands.get_cover_path);
155
 
        if (myData.cCoverPath != NULL)
156
 
                cd_message("MP : Couverture -> %s", myData.cCoverPath);
157
 
        else
158
 
                cd_message("MP : Pas de couverture dispo");
159
 
}
160
 
 
161
 
 
162
 
MusicPlayerHandeler *cd_musicplayer_dbus_find_opened_player (void)
163
 
{
164
 
        // on recupere la liste des services existants.
 
75
 
 
76
MusicPlayerHandler *cd_musicplayer_dbus_find_opened_player (void)
 
77
{
 
78
        if (myData.pCurrentHandler != NULL && myData.bIsRunning)
 
79
                return myData.pCurrentHandler;
 
80
        
 
81
        // get the list of services.    
 
82
        MusicPlayerHandler *pHandler = NULL;
165
83
        gchar **name_list = cairo_dock_dbus_get_services ();
166
 
        if (name_list)
 
84
        
 
85
        if (name_list != NULL)
167
86
        {
168
 
                // on teste chaque lecteur.
169
 
                MusicPlayerHandeler *pHandler = NULL;
 
87
                // check if an MPRIS2 service is present.
170
88
                int i;
171
 
                GList *h;
172
 
                for (h = myData.pHandelers; h != NULL; h = h->next)
173
 
                {
174
 
                        pHandler = h->data;
175
 
                        //cd_debug ("%s : %s\n", pHandler->name, pHandler->cMprisService);
176
 
                        if (pHandler->cMprisService == NULL)
177
 
                                continue;
 
89
                for (i = 0; name_list[i] != NULL; i ++)
 
90
                {
 
91
                        if (strncmp (name_list[i], CD_MPRIS2_SERVICE_BASE, strlen (CD_MPRIS2_SERVICE_BASE)) == 0)  // it's an MPRIS2 player.
 
92
                        {
 
93
                                pHandler = cd_musicplayer_get_handler_by_name ("Mpris2");
 
94
                                g_free ((gchar*)pHandler->cMprisService);
 
95
                                pHandler->cMprisService = g_strdup (name_list[i]);
 
96
                                pHandler->launch = g_strdup (name_list[i] + strlen (CD_MPRIS2_SERVICE_BASE)+1);
 
97
                                gchar *str = strchr (pHandler->launch, '.');
 
98
                                if (str)
 
99
                                        *str = '\0';
 
100
                                /// set the properties (command, class), manage the class...
 
101
                                
 
102
                                break;
 
103
                        }
 
104
                }
 
105
                
 
106
                // if no MPRIS2 service is present, look for a known handler.
 
107
                if (pHandler == NULL)
 
108
                {
 
109
                        GList *h;
 
110
                        MusicPlayerHandler *handler;
178
111
                        for (i = 0; name_list[i] != NULL; i ++)
179
112
                        {
180
 
                                cd_debug ("%s : %s\n", pHandler->cMprisService, name_list[i]);
181
 
                                if (strcmp (name_list[i], pHandler->cMprisService) == 0)  // trouve, on quitte.
 
113
                                for (h = myData.pHandlers; h != NULL; h = h->next)  // see if a known handler matches.
182
114
                                {
183
 
                                        cd_debug ("found %s\n", pHandler->name);
184
 
                                        break;
 
115
                                        handler = h->data;
 
116
                                        if (handler->cMprisService == NULL)
 
117
                                                continue;
 
118
                                        if (strcmp (name_list[i], handler->cMprisService) == 0)
 
119
                                        {
 
120
                                                pHandler = handler;
 
121
                                                break;
 
122
                                        }
185
123
                                }
186
124
                        }
187
 
                        if (name_list[i] != NULL)
188
 
                                break ;
189
125
                }
 
126
                
190
127
                g_strfreev (name_list);
191
 
                return (h ? pHandler : NULL);
192
 
        }
193
 
        else
194
 
        {
195
 
                return NULL;
196
 
        }
 
128
        }
 
129
        return pHandler;
197
130
}
198