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

« back to all changes in this revision

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

  • Committer: Kees Cook
  • Date: 2011-08-11 23:17:39 UTC
  • mfrom: (20.1.1 cairo-dock-plug-ins)
  • Revision ID: kees@outflux.net-20110811231739-cteedan51tmdg77v
Tags: 2.4.0~0beta2-0ubuntu1
releasing version 2.4.0~0beta2-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
76 <arg type="i" />
94
94
77 </signal>
95
95
78 </interface>
96
 
79 </node> 
 
96
79 </node>
97
97
 
98
98
service : org.mpris.audacious
99
99
interface : org.freedesktop.MediaPlayer
108
108
        GetStatus(int[4]: status:play=0,pause,stop shuffle=random no_playlist_advance repeat=loop)
109
109
        GetMetadata(hash: length title artist album genre codec quality track-number location)
110
110
        PositionGet(int=time_in_second)
111
 
        
 
111
 
112
112
        TrackChange(hash: idem)
113
113
        StatusChange(int[4])
114
114
 
146
146
                        myData.cArtist = g_strdup (str);
147
147
        }
148
148
        cd_message ("  cArtist <- %s", myData.cArtist);
149
 
        
 
149
 
150
150
        g_free (myData.cAlbum);
151
151
        myData.cAlbum = NULL;
152
152
        value = (GValue *) g_hash_table_lookup(data_list, "album");
157
157
                        myData.cAlbum = g_strdup (str);
158
158
        }
159
159
        cd_message ("  cAlbum <- %s", myData.cAlbum);
160
 
        
 
160
 
161
161
        g_free (myData.cTitle);
162
162
        myData.cTitle = NULL;
163
163
        value = (GValue *) g_hash_table_lookup(data_list, "title");
168
168
                        myData.cTitle = g_strdup (str);
169
169
        }
170
170
        cd_message ("  cTitle <- %s", myData.cTitle);
171
 
        
 
171
 
172
172
        value = (GValue *) g_hash_table_lookup(data_list, "tracknumber");
173
173
        if (value == NULL)
174
174
                value = (GValue *) g_hash_table_lookup(data_list, "track-number");  // old parameter.
177
177
        else
178
178
                myData.iTrackNumber = 0.;
179
179
        cd_message ("  iTrackNumber <- %d", myData.iTrackNumber);
180
 
        
 
180
 
181
181
        value = (GValue *) g_hash_table_lookup(data_list, "mtime");
182
182
        if (value == NULL)
183
183
                value = (GValue *) g_hash_table_lookup(data_list, "length");  // old parameter.
184
184
        if (value != NULL && G_VALUE_HOLDS_INT(value)) myData.iSongLength = g_value_get_int(value) / 1000;
185
185
        else myData.iSongLength = 0;
186
186
        cd_message ("  iSongLength <- %ds", myData.iSongLength);
187
 
        
 
187
 
188
188
        g_free (myData.cPlayingUri);
189
189
        value = (GValue *) g_hash_table_lookup(data_list, "location");
190
190
        if (value != NULL && G_VALUE_HOLDS_STRING(value)) myData.cPlayingUri = g_strdup (g_value_get_string(value));
191
191
        else myData.cPlayingUri = NULL;
192
192
        cd_message ("  cUri <- %s", myData.cPlayingUri);
193
 
        
 
193
 
194
194
        cd_musicplayer_get_cover_path (NULL, TRUE);
195
195
}
196
196
 
200
200
{
201
201
        GHashTable *data_list = NULL;
202
202
        const gchar *data;
203
 
                
 
203
 
204
204
        if(dbus_g_proxy_call (myData.dbus_proxy_player, "GetMetadata", NULL,
205
205
                G_TYPE_INVALID,
206
206
                MP_DBUS_TYPE_SONG_METADATA,
239
239
{
240
240
        CD_APPLET_ENTER;
241
241
        cd_debug ("MP : %s ()\n", __func__);
242
 
        
 
242
 
243
243
        if (metadata != NULL)
244
244
        {
245
245
                _extract_metadata (metadata);
262
262
                myData.iSongLength = 0;
263
263
                myData.iTrackNumber = 0;
264
264
                myData.cover_exist = FALSE;
265
 
                
 
265
 
266
266
                cd_musicplayer_dbus_detect_player ();
267
267
        }
268
268
        cd_musicplayer_update_icon (TRUE);
281
281
        if (cairo_dock_dbus_is_enabled ())
282
282
        {
283
283
                myData.dbus_enable = cd_musicplayer_dbus_connect_to_bus (); // cree le proxy.
284
 
                
 
284
 
285
285
                myData.dbus_enable_shell = musicplayer_dbus_connect_to_bus_Shell ();  // cree le proxy pour la 2eme interface car AU en a 2.
286
 
                
 
286
 
287
287
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "StatusChange",
288
288
                        MP_DBUS_TYPE_PLAYER_STATUS_MPRIS,
289
289
                        G_TYPE_INVALID);
290
290
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "StatusChange",
291
291
                        G_CALLBACK(onChangePlaying_mpris), NULL, NULL);
292
 
                
 
292
 
293
293
                dbus_g_proxy_add_signal(myData.dbus_proxy_player, "TrackChange",
294
294
                        MP_DBUS_TYPE_SONG_METADATA,
295
295
                        G_TYPE_INVALID);
296
296
                dbus_g_proxy_connect_signal(myData.dbus_proxy_player, "TrackChange",
297
297
                        G_CALLBACK(onChangeSong), NULL, NULL);  // pas de TrackListChange, donc on fera tout dedans.
298
 
                
 
298
 
299
299
                return TRUE;
300
300
        }
301
301
        return FALSE;
309
309
        {
310
310
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "StatusChange",
311
311
                        G_CALLBACK(onChangePlaying_mpris), NULL);
312
 
                
 
312
 
313
313
                dbus_g_proxy_disconnect_signal(myData.dbus_proxy_player, "TrackChange",
314
314
                        G_CALLBACK(onChangeSong), NULL);
315
315
        }
316
 
        
 
316
 
317
317
        musicplayer_dbus_disconnect_from_bus();
318
318
        musicplayer_dbus_disconnect_from_bus_Shell();
319
319
}
324
324
static void cd_audacious_control (MyPlayerControl pControl, const char* song)
325
325
{
326
326
        const gchar *cCommand = NULL;
327
 
                
 
327
 
328
328
        switch (pControl) {
329
329
                case PLAYER_PREVIOUS :
330
330
                        cCommand = "Prev";
331
331
                break;
332
 
                
 
332
 
333
333
                case PLAYER_STOP :
334
334
                        cCommand = "Stop";
335
335
                break;
336
 
                
 
336
 
337
337
                case PLAYER_PLAY_PAUSE :
338
338
                        if (myData.iPlayingStatus != PLAYER_PLAYING)
339
339
                                cCommand = "Play";
344
344
                case PLAYER_NEXT :
345
345
                        cCommand = "Next";
346
346
                break;
347
 
                
 
347
 
348
348
                case PLAYER_JUMPBOX :
349
349
                case PLAYER_SHUFFLE :
350
350
                case PLAYER_REPEAT :
351
351
                {
352
 
                        
 
352
 
353
353
                        DBusGProxy *dbus_proxy_atheme = cairo_dock_create_new_session_proxy (
354
354
                                "org.atheme.audacious",
355
355
                                "/org/atheme/audacious",
381
381
                                cd_warning ("org.atheme.audacious not valid !");
382
382
                }
383
383
                break;
384
 
                
 
384
 
385
385
                case PLAYER_ENQUEUE :
386
386
                        cd_debug ("enqueue %s\n", song);
387
387
                        dbus_g_proxy_call_no_reply (myData.dbus_proxy_shell, "AddTrack",
390
390
                                G_TYPE_BOOLEAN, FALSE,
391
391
                                G_TYPE_INVALID);
392
392
                break;
393
 
                
 
393
 
394
394
                default :
395
395
                        return;
396
396
                break;
397
397
        }
398
 
        
399
 
        if (cCommand != NULL) 
 
398
 
 
399
        if (cCommand != NULL)
400
400
        {
401
401
                cd_debug ("MP : Handler audacious : will use '%s'", cCommand);
402
402
                cairo_dock_dbus_call (myData.dbus_proxy_player, cCommand);
439
439
        myData.DBus_commands.path2 = "/TrackList";
440
440
        myData.DBus_commands.interface = "org.freedesktop.MediaPlayer";
441
441
        myData.DBus_commands.interface2 = "org.freedesktop.MediaPlayer";
442
 
        
 
442
 
443
443
        myData.dbus_enable = _cd_audacious_dbus_connect_to_bus ();  // se connecte au bus et aux signaux de AU.
444
444
        if (myData.dbus_enable)
445
445
        {
474
474
        pAudacious->control = cd_audacious_control;
475
475
        pAudacious->get_cover = NULL;
476
476
        pAudacious->cCoverDir = NULL;  /// a confirmer...
477
 
        
478
 
        pAudacious->appclass = "audacious";  // les classes sont passees en minuscule par le dock.
 
477
 
 
478
        gchar *cResult = cairo_dock_launch_command_sync ("which audacious2");
 
479
        if (cResult != NULL && *cResult == '/')
 
480
        {
 
481
                cd_debug ("MusicPlayer: Audacious2");
 
482
                pAudacious->appclass = "audacious2";
 
483
                pAudacious->launch = "audacious2";
 
484
        }
 
485
        else
 
486
        {
 
487
                cd_debug ("MusicPlayer: Audacious (without 2)");
 
488
                pAudacious->appclass = "audacious"; // now it's without this '2'
 
489
                pAudacious->launch = "audacious";
 
490
        }
 
491
        g_free (cResult);
479
492
        pAudacious->name = "Audacious";
480
 
        pAudacious->launch = "audacious2";
481
493
        pAudacious->cMprisService = "org.mpris.audacious";
482
494
        pAudacious->iPlayer = MP_AUDACIOUS;
483
495
        pAudacious->bSeparateAcquisition = FALSE;  // inutile de threader.
484
496
        pAudacious->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT | PLAYER_STOP | PLAYER_JUMPBOX | PLAYER_SHUFFLE | PLAYER_REPEAT | PLAYER_ENQUEUE;
485
497
        pAudacious->iLevel = PLAYER_GOOD;  // n'a besoin d'une boucle que pour afficher le temps ecoule.
486
 
        
 
498
 
487
499
        cd_musicplayer_register_my_handler(pAudacious, "audacious");
488
500
}