aboutsummaryrefslogtreecommitdiff
path: root/src/music-player-bridge.vala
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-11-18 11:11:14 -0500
committerKen VanDine <ken.vandine@canonical.com>2010-11-18 11:11:14 -0500
commit2133a62fd09fc431c146c74b4ca13e89d610c1c9 (patch)
treec4d27e2357498eba9fde88e64e53e2afe926d981 /src/music-player-bridge.vala
parentfb9140db72f565fa6180a55da02302844e21c05c (diff)
parent908222c0681fba3c6e1265d0f85a0b667927c169 (diff)
downloadayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.tar.gz
ayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.tar.bz2
ayatana-indicator-sound-2133a62fd09fc431c146c74b4ca13e89d610c1c9.zip
releasing version 0.5.1-0ubuntu1
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r--src/music-player-bridge.vala60
1 files changed, 25 insertions, 35 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 57f5636..f13c2f4 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -24,7 +24,6 @@ using GLib;
public class MusicPlayerBridge : GLib.Object
{
-
private Listener listener;
private Dbusmenu.Menuitem root_menu;
private HashMap<string, PlayerController> registered_clients;
@@ -51,20 +50,19 @@ public class MusicPlayerBridge : GLib.Object
DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
if(info == null){
- warning("Could not create a desktopappinfo instance from app: %s", app);
+ warning("Could not create a desktopappinfo instance from app,: %s , moving on to the next client", app);
continue;
}
GLib.AppInfo app_info = info as GLib.AppInfo;
+ var mpris_key = determine_key(app);
PlayerController ctrl = new PlayerController(this.root_menu,
- truncate_player_name(app_info.get_name()),
- determine_key(app),
+ app_info,
+ mpris_key,
+ playersDB.fetch_icon_name(app),
calculate_menu_position(),
PlayerController.state.OFFLINE);
- ctrl.app_info = app_info;
- if(ctrl.app_info == null)
- warning("for some reason the app info is null");
- this.registered_clients.set(determine_key(app), ctrl);
+ this.registered_clients.set(mpris_key, ctrl);
}
}
@@ -94,24 +92,29 @@ public class MusicPlayerBridge : GLib.Object
{
MusicPlayerBridge bridge = data as MusicPlayerBridge;
AppInfo? app_info = create_app_info(path);
- var name = truncate_player_name(app_info.get_name());
- if(path.contains("/") && bridge.playersDB.already_familiar(path) == false){
- debug("About to store desktop file path: %s", path);
+ if ( app_info == null ){
+ warning ( "Could not create app_info for path %s \n Getting out of here ", path);
+ return;
+ }
+
+ var mpris_key = determine_key(path);
+
+ if(bridge.playersDB.already_familiar(path) == false){
+ debug("New client has registered that we have seen before: %s", path);
bridge.playersDB.insert(path);
- PlayerController ctrl = new PlayerController(bridge.root_menu,
- name,
- determine_key(path),
- bridge.calculate_menu_position(),
- PlayerController.state.READY);
- ctrl.set("app_info", app_info);
- bridge.registered_clients.set(determine_key(path), ctrl);
+ PlayerController ctrl = new PlayerController ( bridge.root_menu,
+ app_info,
+ mpris_key,
+ playersDB.fetch_icon_name(path),
+ bridge.calculate_menu_position(),
+ PlayerController.state.READY );
+ bridge.registered_clients.set(mpris_key, ctrl);
debug("successfully created appinfo and instance from path and set it on the respective instance");
}
else{
- var key = determine_key(path);
- bridge.registered_clients[key].update_state(PlayerController.state.READY);
- bridge.registered_clients[key].activate();
- debug("Ignoring desktop file path callback because the db cache file has it already: %s", path);
+ bridge.registered_clients[mpris_key].update_state(PlayerController.state.READY);
+ bridge.registered_clients[mpris_key].activate();
+ debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
}
}
@@ -155,19 +158,6 @@ public class MusicPlayerBridge : GLib.Object
return app_info;
}
- private static string truncate_player_name(owned string app_info_name)
- {
- string result = app_info_name.down().strip();
-
- var tokens = result.split(" ");
-
- if(tokens.length > 1){
- result = tokens[0];
- }
- debug("truncate player name %s", result);
- return result;
- }
-
private static string? determine_key(owned string path)
{
var tokens = path.split("/");