diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-06-24 18:16:23 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-06-24 18:16:23 +0100 |
commit | 0336970086fb3bbd00b3a906e9879f4a50ae015c (patch) | |
tree | 5a567be23e2f1dcf6bfdbda4d8b461fd8314e41c /src/music-player-bridge.vala | |
parent | 49db751d456ee144f7c7910278b35613dc90db8a (diff) | |
parent | 1d721c275ba6962d60f47b184849db7bd2a5290a (diff) | |
download | ayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.tar.gz ayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.tar.bz2 ayatana-indicator-sound-0336970086fb3bbd00b3a906e9879f4a50ae015c.zip |
merge the familiar players db work
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r-- | src/music-player-bridge.vala | 90 |
1 files changed, 65 insertions, 25 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index b03ecbd..6fc9032 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -1,5 +1,4 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: @@ -21,6 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. using Indicate; using Dbusmenu; using Gee; +using GLib; public class MusicPlayerBridge : GLib.Object { @@ -28,9 +28,11 @@ public class MusicPlayerBridge : GLib.Object private Listener listener; private Dbusmenu.Menuitem root_menu; private HashMap<string, PlayerController> registered_clients; + private FamiliarPlayersDB playersDB; public MusicPlayerBridge() { + playersDB = new FamiliarPlayersDB(); registered_clients = new HashMap<string, PlayerController> (); listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); @@ -40,33 +42,43 @@ public class MusicPlayerBridge : GLib.Object listener.server_removed.connect(on_server_removed); listener.server_count_changed.connect(on_server_count_changed); } - - public void set_root_menu_item(Dbusmenu.Menuitem menu) - { - root_menu = menu; - } - - public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) - { - debug("MusicPlayerBridge-> on_indicator_added"); - } - - public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) - { - debug("MusicPlayerBridge -> on_indicator_removed"); - } - - public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s) - { - debug("MusicPlayerBridge -> indicator_modified with vale %s", s ); - } - - public void on_server_added(Indicate.ListenerServer object, string type) + // Alpha 2 not in use ... yet. + private void try_to_add_inactive_familiar_clients(){ + // for now just use one of the entries. + int count = 0; + foreach(string app in this.playersDB.records()){ + if(count == 0){ + debug("we have found %s", app); + string[] bits = app.split("/"); + + try{ + string app_name = bits[bits.length -1].split(".")[0]; + debug("we have found %s", app_name); + PlayerController ctrl = new PlayerController(this.root_menu, + app_name, + false); + this.registered_clients.set(app_name, ctrl); + DesktopAppInfo info = new DesktopAppInfo.from_filename(app_name); + string desc = info.get_display_name(); + debug("description from app %s", desc); + count += 1; + } + catch(Error er){ + warning("desktop path in cache is not formatted as we have anticipated"); + } + } + break; + } + } + + public void on_server_added(Indicate.ListenerServer object, string type) { debug("MusicPlayerBridge -> on_server_added with value %s", type); if(server_is_not_of_interest(type)) return; - string client_name = type.split(".")[1]; + string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ + listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback; + this.listener.server_get_desktop(object, cb, this); PlayerController ctrl = new PlayerController(root_menu, client_name, true); registered_clients.set(client_name, ctrl); debug("client of name %s has successfully registered with us", client_name); @@ -94,10 +106,38 @@ public class MusicPlayerBridge : GLib.Object return false; } - public void on_server_count_changed(Indicate.ListenerServer object, uint i) + private void desktop_info_callback(Indicate.ListenerServer server, + owned string path, void* data) + { + debug("we got a desktop file path hopefully: %s", path); + MusicPlayerBridge bridge = data as MusicPlayerBridge; + bridge.playersDB.insert(path); + } + + public void set_root_menu_item(Dbusmenu.Menuitem menu) + { + this.root_menu = menu; + //try_to_add_inactive_familiar_clients(); + } + + public void on_server_count_changed(Indicate.ListenerServer object, uint i) { debug("MusicPlayerBridge-> on_server_count_changed with value %u", i); } + public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge-> on_indicator_added"); + } + + public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge -> on_indicator_removed"); + } + + public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s) + { + debug("MusicPlayerBridge -> indicator_modified with vale %s", s ); + } } |