summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2013-11-11 23:40:27 +0100
committerdavemds <dave@gurumeditation.it>2013-11-11 23:40:27 +0100
commit771c352281d61f2603ba26c41047af2325c16803 (patch)
tree43759ca73a6e83bb269c2af9a3c85dd3f15a7e95
parent5920551f153f43b9317b7ee23009d3f05ace0c7d (diff)
music-control: do not request props if the service is not up.
This prevent music player that support the dbus activation system to be launched at module startup. Instead of blindly request properties first check if the name has an owner. As a side effect now the module fully support the dbus activation system: if your player is not running it will be launched when you click his name or any of the controls in the popup. Note: If your player does not provide the autorun feature you can just create a .service file in dbus share folder with the following content: [D-BUS Service] Name=org.mpris.MediaPlayer2.quodlibet Exec=/usr/bin/quodlibet ...of course you must change the name of your player ;)
-rw-r--r--src/modules/music-control/e_mod_main.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/modules/music-control/e_mod_main.c b/src/modules/music-control/e_mod_main.c
index c13fc5291..335b77cdd 100644
--- a/src/modules/music-control/e_mod_main.c
+++ b/src/modules/music-control/e_mod_main.c
@@ -319,6 +319,25 @@ prop_changed(void *data, Eldbus_Proxy *proxy, void *event_info)
319 } 319 }
320} 320}
321 321
322static void
323cb_name_owner_has(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
324{
325 E_Music_Control_Module_Context *ctxt = data;
326 Eina_Bool owner_exists;
327
328 if (eldbus_message_error_get(msg, NULL, NULL))
329 return;
330 if (!eldbus_message_arguments_get(msg, "b", &owner_exists))
331 return;
332 if (owner_exists)
333 {
334 media_player2_player_playback_status_propget(ctxt->mpris2_player,
335 cb_playback_status_get, ctxt);
336 media_player2_player_metadata_propget(ctxt->mpris2_player,
337 cb_metadata_get, ctxt);
338 }
339}
340
322Eina_Bool 341Eina_Bool
323music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus) 342music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus)
324{ 343{
@@ -328,10 +347,9 @@ music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus)
328 347
329 ctxt->mrpis2 = mpris_media_player2_proxy_get(ctxt->conn, bus, NULL); 348 ctxt->mrpis2 = mpris_media_player2_proxy_get(ctxt->conn, bus, NULL);
330 ctxt->mpris2_player = media_player2_player_proxy_get(ctxt->conn, bus, NULL); 349 ctxt->mpris2_player = media_player2_player_proxy_get(ctxt->conn, bus, NULL);
331 media_player2_player_playback_status_propget(ctxt->mpris2_player, cb_playback_status_get, ctxt);
332 media_player2_player_metadata_propget(ctxt->mpris2_player, cb_metadata_get, ctxt);
333 eldbus_proxy_event_callback_add(ctxt->mpris2_player, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, 350 eldbus_proxy_event_callback_add(ctxt->mpris2_player, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
334 prop_changed, ctxt); 351 prop_changed, ctxt);
352 eldbus_name_owner_has(ctxt->conn, bus, cb_name_owner_has, ctxt);
335 return EINA_TRUE; 353 return EINA_TRUE;
336} 354}
337 355