diff options
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r-- | src/music-player-bridge.vala | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 9ab1b3c..f13c2f4 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -50,18 +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, - app_info, + app_info, + mpris_key, playersDB.fetch_icon_name(app), calculate_menu_position(), PlayerController.state.OFFLINE); - ctrl.app_info = app_info; - this.registered_clients.set(determine_key(app), ctrl); + this.registered_clients.set(mpris_key, ctrl); } } @@ -91,22 +92,29 @@ public class MusicPlayerBridge : GLib.Object { MusicPlayerBridge bridge = data as MusicPlayerBridge; AppInfo? app_info = create_app_info(path); - 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, - app_info, - playersDB.fetch_icon_name(path), - bridge.calculate_menu_position(), - PlayerController.state.READY); - 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); } } |