aboutsummaryrefslogtreecommitdiff
path: root/src/music-player-bridge.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-10-07 10:08:18 -0400
committerKen VanDine <ken.vandine@canonical.com>2010-10-07 10:08:18 -0400
commitaeb17c8f7825a68e367c50421f89695d41fcd5fb (patch)
treea8bbd335136def8b8096d37129fd7ac798b5ddcd /src/music-player-bridge.c
parent7695b78d05fd79ad7581d82b1f5ad171529e19e0 (diff)
parent7ea2deb67919da59bbeab00e3b4e244c8395ff58 (diff)
downloadayatana-indicator-sound-aeb17c8f7825a68e367c50421f89695d41fcd5fb.tar.gz
ayatana-indicator-sound-aeb17c8f7825a68e367c50421f89695d41fcd5fb.tar.bz2
ayatana-indicator-sound-aeb17c8f7825a68e367c50421f89695d41fcd5fb.zip
Import upstream version 0.4.8
Diffstat (limited to 'src/music-player-bridge.c')
-rw-r--r--src/music-player-bridge.c382
1 files changed, 169 insertions, 213 deletions
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index f139738..3746bf6 100644
--- a/src/music-player-bridge.c
+++ b/src/music-player-bridge.c
@@ -1,4 +1,4 @@
-/* music-player-bridge.c generated by valac 0.9.8, the Vala compiler
+/* music-player-bridge.c generated by valac 0.10.0, the Vala compiler
* generated from music-player-bridge.vala, do not modify */
/*
@@ -111,36 +111,29 @@ MusicPlayerBridge* music_player_bridge_new (void);
MusicPlayerBridge* music_player_bridge_construct (GType object_type);
FamiliarPlayersDB* familiar_players_db_new (void);
FamiliarPlayersDB* familiar_players_db_construct (GType object_type);
-void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-static void _music_player_bridge_on_indicator_added_indicate_listener_indicator_added (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self);
-void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
-static void _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self);
-void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s);
-static void _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* p1, gpointer self);
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
static void _music_player_bridge_on_server_added_indicate_listener_server_added (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self);
void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
static void _music_player_bridge_on_server_removed_indicate_listener_server_removed (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self);
-void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i);
-static void _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed (IndicateListener* _sender, IndicateListenerServer* object, guint p0, gpointer self);
static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self);
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self);
-static char* music_player_bridge_truncate_player_name (const char* app_info_name);
+static char* music_player_bridge_truncate_player_name (char* app_info_name);
static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self);
GType player_controller_state_get_type (void) G_GNUC_CONST;
PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
void player_controller_set_app_info (PlayerController* self, GAppInfo* value);
GAppInfo* player_controller_get_app_info (PlayerController* self);
+static char* music_player_bridge_determine_key (char* path);
#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4
static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type);
-void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
-void player_controller_activate (PlayerController* self);
static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data);
-void player_controller_hibernate (PlayerController* self);
+GAppInfo* music_player_bridge_create_app_info (const char* path);
gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop);
void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
-GAppInfo* music_player_bridge_create_app_info (const char* path);
+void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
+void player_controller_activate (PlayerController* self);
+void player_controller_hibernate (PlayerController* self);
void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu);
static void music_player_bridge_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
@@ -149,21 +142,6 @@ static gint _vala_array_length (gpointer array);
-static void _music_player_bridge_on_indicator_added_indicate_listener_indicator_added (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self) {
- music_player_bridge_on_indicator_added (self, object, p0);
-}
-
-
-static void _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, gpointer self) {
- music_player_bridge_on_indicator_removed (self, object, p0);
-}
-
-
-static void _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified (IndicateListener* _sender, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* p1, gpointer self) {
- music_player_bridge_on_indicator_modified (self, object, p0, p1);
-}
-
-
static void _music_player_bridge_on_server_added_indicate_listener_server_added (IndicateListener* _sender, IndicateListenerServer* object, const char* p0, gpointer self) {
music_player_bridge_on_server_added (self, object, p0);
}
@@ -174,11 +152,6 @@ static void _music_player_bridge_on_server_removed_indicate_listener_server_remo
}
-static void _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed (IndicateListener* _sender, IndicateListenerServer* object, guint p0, gpointer self) {
- music_player_bridge_on_server_count_changed (self, object, p0);
-}
-
-
MusicPlayerBridge* music_player_bridge_construct (GType object_type) {
MusicPlayerBridge * self;
FamiliarPlayersDB* _tmp0_;
@@ -188,12 +161,8 @@ MusicPlayerBridge* music_player_bridge_construct (GType object_type) {
self->priv->playersDB = (_tmp0_ = familiar_players_db_new (), _g_object_unref0 (self->priv->playersDB), _tmp0_);
self->priv->registered_clients = (_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, TYPE_PLAYER_CONTROLLER, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL), _g_object_unref0 (self->priv->registered_clients), _tmp1_);
self->priv->listener = (_tmp2_ = indicate_listener_ref_default (), _g_object_unref0 (self->priv->listener), _tmp2_);
- g_signal_connect_object (self->priv->listener, "indicator-added", (GCallback) _music_player_bridge_on_indicator_added_indicate_listener_indicator_added, self, 0);
- g_signal_connect_object (self->priv->listener, "indicator-removed", (GCallback) _music_player_bridge_on_indicator_removed_indicate_listener_indicator_removed, self, 0);
- g_signal_connect_object (self->priv->listener, "indicator-modified", (GCallback) _music_player_bridge_on_indicator_modified_indicate_listener_indicator_modified, self, 0);
g_signal_connect_object (self->priv->listener, "server-added", (GCallback) _music_player_bridge_on_server_added_indicate_listener_server_added, self, 0);
g_signal_connect_object (self->priv->listener, "server-removed", (GCallback) _music_player_bridge_on_server_removed_indicate_listener_server_removed, self, 0);
- g_signal_connect_object (self->priv->listener, "server-count-changed", (GCallback) _music_player_bridge_on_server_count_changed_indicate_listener_server_count_changed, self, 0);
return self;
}
@@ -229,27 +198,27 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
app = (char*) gee_iterator_get (_app_it);
if (app == NULL) {
- g_warning ("music-player-bridge.vala:49: App string in keyfile is null therefore m" \
+ g_warning ("music-player-bridge.vala:45: App string in keyfile is null therefore m" \
"oving on to next player");
_g_free0 (app);
continue;
}
- g_debug ("music-player-bridge.vala:53: attempting to make an app info from %s", app);
+ g_debug ("music-player-bridge.vala:49: attempting to make an app info from %s", app);
info = g_desktop_app_info_new_from_filename (app);
if (info == NULL) {
- g_warning ("music-player-bridge.vala:57: Could not create a desktopappinfo instanc" \
+ g_warning ("music-player-bridge.vala:54: Could not create a desktopappinfo instanc" \
"e from app: %s", app);
_g_object_unref0 (info);
_g_free0 (app);
continue;
}
app_info = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL));
- ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_app_info_get_name (app_info)), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_);
+ ctrl = (_tmp4_ = player_controller_new (self->priv->root_menu, _tmp3_ = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info))), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE), _g_free0 (_tmp3_), _tmp4_);
player_controller_set_app_info (ctrl, app_info);
if (player_controller_get_app_info (ctrl) == NULL) {
- g_warning ("music-player-bridge.vala:69: for some reason the app info is null");
+ g_warning ("music-player-bridge.vala:65: for some reason the app info is null");
}
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp5_ = music_player_bridge_truncate_player_name (g_app_info_get_name (app_info)), ctrl);
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp5_ = music_player_bridge_determine_key (g_strdup (app)), ctrl);
_g_free0 (_tmp5_);
_g_object_unref0 (ctrl);
_g_object_unref0 (app_info);
@@ -261,41 +230,6 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
-static char* string_strip (const char* self) {
- char* result = NULL;
- char* _result_;
- g_return_val_if_fail (self != NULL, NULL);
- _result_ = g_strdup (self);
- g_strstrip (_result_);
- result = _result_;
- return result;
-}
-
-
-static char* music_player_bridge_truncate_player_name (const char* app_info_name) {
- char* result = NULL;
- char* _tmp0_;
- char* _tmp1_;
- char* _result_;
- gint tokens_length1;
- gint _tokens_size_;
- char** _tmp3_;
- char** _tmp2_;
- char** tokens;
- g_return_val_if_fail (app_info_name != NULL, NULL);
- _result_ = (_tmp1_ = string_strip (_tmp0_ = g_utf8_strdown (app_info_name, -1)), _g_free0 (_tmp0_), _tmp1_);
- tokens = (_tmp3_ = _tmp2_ = g_strsplit (_result_, " ", 0), tokens_length1 = _vala_array_length (_tmp2_), _tokens_size_ = tokens_length1, _tmp3_);
- if (tokens_length1 > 1) {
- char* _tmp4_;
- _result_ = (_tmp4_ = g_strdup (tokens[0]), _g_free0 (_result_), _tmp4_);
- }
- g_debug ("music-player-bridge.vala:84: truncate player name %s", _result_);
- result = _result_;
- tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
- return result;
-}
-
-
static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self) {
gint result = 0;
g_return_val_if_fail (self != NULL, 0);
@@ -310,84 +244,18 @@ static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
- char** _tmp0_;
- char** _tmp1_;
- gint _tmp1__length1;
- char* _tmp2_;
- char* client_name;
- gboolean _tmp3_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:100: MusicPlayerBridge -> on_server_added wit" \
-"h value %s", type);
+ g_debug ("music-player-bridge.vala:82: MusicPlayerBridge -> on_server_added with" \
+" value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
}
- client_name = (_tmp2_ = g_strdup ((_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), _tmp1__length1 = _vala_array_length (_tmp0_), _tmp1_)[1]), _tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL), _tmp2_);
if (self->priv->root_menu != NULL) {
- _tmp3_ = client_name != NULL;
- } else {
- _tmp3_ = FALSE;
- }
- if (_tmp3_) {
- GeeSet* _tmp4_;
- gboolean _tmp5_;
- PlayerController* _tmp8_;
- gboolean _tmp9_;
- if ((_tmp5_ = gee_collection_contains ((GeeCollection*) (_tmp4_ = gee_map_get_keys ((GeeMap*) self->priv->registered_clients)), client_name), _g_object_unref0 (_tmp4_), _tmp5_)) {
- PlayerController* _tmp6_;
- PlayerController* _tmp7_;
- g_debug ("music-player-bridge.vala:106: It figured out that it already has an in" \
-"stance for this player already");
- player_controller_update_state (_tmp6_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name), PLAYER_CONTROLLER_STATE_READY);
- _g_object_unref0 (_tmp6_);
- player_controller_activate (_tmp7_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
- _g_object_unref0 (_tmp7_);
- } else {
- PlayerController* ctrl;
- ctrl = player_controller_new (self->priv->root_menu, client_name, music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_READY);
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, client_name, ctrl);
- g_debug ("music-player-bridge.vala:117: New Client of name %s has successfully r" \
-"egistered with us", client_name);
- _g_object_unref0 (ctrl);
- }
- if ((_tmp9_ = player_controller_get_app_info (_tmp8_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name)) == NULL, _g_object_unref0 (_tmp8_), _tmp9_)) {
- indicate_listener_get_server_property_cb cb;
- cb = (indicate_listener_get_server_property_cb) music_player_bridge_desktop_info_callback;
- indicate_listener_server_get_desktop (self->priv->listener, object, cb, self);
- }
- }
- _g_free0 (client_name);
-}
-
-
-void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
- char** _tmp0_;
- char** _tmp1_;
- gint _tmp1__length1;
- char* _tmp2_;
- char* client_name;
- gboolean _tmp3_ = FALSE;
- g_return_if_fail (self != NULL);
- g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:129: MusicPlayerBridge -> on_server_removed w" \
-"ith value %s", type);
- if (music_player_bridge_server_is_not_of_interest (self, type)) {
- return;
- }
- client_name = (_tmp2_ = g_strdup ((_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), _tmp1__length1 = _vala_array_length (_tmp0_), _tmp1_)[1]), _tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL), _tmp2_);
- if (self->priv->root_menu != NULL) {
- _tmp3_ = client_name != NULL;
- } else {
- _tmp3_ = FALSE;
+ indicate_listener_get_server_property_cb cb;
+ cb = (indicate_listener_get_server_property_cb) music_player_bridge_desktop_info_callback;
+ indicate_listener_server_get_desktop (self->priv->listener, object, cb, self);
}
- if (_tmp3_) {
- PlayerController* _tmp4_;
- player_controller_hibernate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
- _g_object_unref0 (_tmp4_);
- g_debug ("music-player-bridge.vala:134: Successively offlined client %s", client_name);
- }
- _g_free0 (client_name);
}
@@ -400,97 +268,106 @@ static gboolean string_contains (const char* self, const char* needle) {
}
-static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type) {
- gboolean result = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
- if (type == NULL) {
- result = TRUE;
- return result;
- }
- if (string_contains (type, "music") == FALSE) {
- g_debug ("music-player-bridge.vala:141: server is of no interest, it is not an " \
-"music server");
- result = TRUE;
- return result;
- }
- result = FALSE;
- return result;
-}
-
-
static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self, IndicateListenerServer* server, char* path, void* data) {
void* _tmp0_;
MusicPlayerBridge* bridge;
+ GAppInfo* app_info;
+ char* name;
gboolean _tmp1_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
bridge = _g_object_ref0 ((_tmp0_ = data, IS_MUSIC_PLAYER_BRIDGE (_tmp0_) ? ((MusicPlayerBridge*) _tmp0_) : NULL));
+ app_info = music_player_bridge_create_app_info (path);
+ name = music_player_bridge_truncate_player_name (g_strdup (g_app_info_get_name (app_info)));
if (string_contains (path, "/")) {
_tmp1_ = familiar_players_db_already_familiar (bridge->priv->playersDB, path) == FALSE;
} else {
_tmp1_ = FALSE;
}
if (_tmp1_) {
- GAppInfo* app_info;
- g_debug ("music-player-bridge.vala:152: About to store desktop file path: %s", path);
+ PlayerController* ctrl;
+ char* _tmp2_;
+ g_debug ("music-player-bridge.vala:98: About to store desktop file path: %s", path);
familiar_players_db_insert (bridge->priv->playersDB, path);
- app_info = music_player_bridge_create_app_info (path);
- if (app_info != NULL) {
- char* _tmp2_;
- char* _tmp3_;
- PlayerController* _tmp4_;
- PlayerController* ctrl;
- ctrl = (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp3_ = string_strip (_tmp2_ = g_utf8_strdown (g_app_info_get_name (app_info), -1))), _g_free0 (_tmp3_), _g_free0 (_tmp2_), _tmp4_);
- g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
- g_debug ("music-player-bridge.vala:158: successfully created appinfo from path a" \
-"nd set it on the respective instance");
- _g_object_unref0 (ctrl);
- }
- _g_object_unref0 (app_info);
+ ctrl = player_controller_new (bridge->priv->root_menu, name, music_player_bridge_calculate_menu_position (bridge), PLAYER_CONTROLLER_STATE_READY);
+ g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
+ gee_abstract_map_set ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp2_ = music_player_bridge_determine_key (g_strdup (path)), ctrl);
+ _g_free0 (_tmp2_);
+ g_debug ("music-player-bridge.vala:106: successfully created appinfo and instanc" \
+"e from path and set it on the respective instance");
+ _g_object_unref0 (ctrl);
} else {
- g_debug ("music-player-bridge.vala:162: Ignoring desktop file path because its e" \
-"ither invalid of the db cache file has it already: %s", path);
+ char* key;
+ PlayerController* _tmp3_;
+ PlayerController* _tmp4_;
+ key = music_player_bridge_determine_key (g_strdup (path));
+ player_controller_update_state (_tmp3_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key), PLAYER_CONTROLLER_STATE_READY);
+ _g_object_unref0 (_tmp3_);
+ player_controller_activate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, key));
+ _g_object_unref0 (_tmp4_);
+ g_debug ("music-player-bridge.vala:112: Ignoring desktop file path callback beca" \
+"use the db cache file has it already: %s", path);
+ _g_free0 (key);
}
+ _g_free0 (name);
+ _g_object_unref0 (app_info);
_g_object_unref0 (bridge);
_g_free0 (path);
}
-void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu) {
- DbusmenuMenuitem* _tmp0_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (menu != NULL);
- self->priv->root_menu = (_tmp0_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->root_menu), _tmp0_);
- music_player_bridge_try_to_add_inactive_familiar_clients (self);
-}
-
-
-void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i) {
- g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:174: MusicPlayerBridge-> on_server_count_chan" \
-"ged with value %u", i);
-}
-
-
-void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
+void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:178: MusicPlayerBridge-> on_indicator_added");
+ g_return_if_fail (type != NULL);
+ g_debug ("music-player-bridge.vala:118: MusicPlayerBridge -> on_server_removed w" \
+"ith value %s", type);
+ if (music_player_bridge_server_is_not_of_interest (self, type)) {
+ return;
+ }
+ if (self->priv->root_menu != NULL) {
+ gint tmp_length1;
+ gint _tmp_size_;
+ char** _tmp1_;
+ char** _tmp0_;
+ char** tmp;
+ tmp = (_tmp1_ = _tmp0_ = g_strsplit (type, ".", 0), tmp_length1 = _vala_array_length (_tmp0_), _tmp_size_ = tmp_length1, _tmp1_);
+ g_debug ("music-player-bridge.vala:122: attempt to remove %s", tmp[tmp_length1 - 1]);
+ if (tmp_length1 > 0) {
+ PlayerController* _tmp2_;
+ player_controller_hibernate (_tmp2_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, tmp[tmp_length1 - 1]));
+ _g_object_unref0 (_tmp2_);
+ g_debug ("music-player-bridge.vala:125: Successively offlined client %s", tmp[tmp_length1 - 1]);
+ }
+ tmp = (_vala_array_free (tmp, tmp_length1, (GDestroyNotify) g_free), NULL);
+ }
}
-void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
- g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:183: MusicPlayerBridge -> on_indicator_remove" \
-"d");
+static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type) {
+ gboolean result = FALSE;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (type != NULL, FALSE);
+ if (type == NULL) {
+ result = TRUE;
+ return result;
+ }
+ if (string_contains (type, "music") == FALSE) {
+ g_debug ("music-player-bridge.vala:133: server is of no interest, it is not an " \
+"music server");
+ result = TRUE;
+ return result;
+ }
+ result = FALSE;
+ return result;
}
-void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s) {
+void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu) {
+ DbusmenuMenuitem* _tmp0_;
g_return_if_fail (self != NULL);
- g_return_if_fail (s != NULL);
- g_debug ("music-player-bridge.vala:188: MusicPlayerBridge -> indicator_modified " \
-"with vale %s", s);
+ g_return_if_fail (menu != NULL);
+ self->priv->root_menu = (_tmp0_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->root_menu), _tmp0_);
+ music_player_bridge_try_to_add_inactive_familiar_clients (self);
}
@@ -502,7 +379,7 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) {
g_return_val_if_fail (path != NULL, NULL);
info = g_desktop_app_info_new_from_filename (path);
if (path == NULL) {
- g_warning ("music-player-bridge.vala:195: Could not create a desktopappinfo instan" \
+ g_warning ("music-player-bridge.vala:149: Could not create a desktopappinfo instan" \
"ce from app: %s", path);
result = NULL;
_g_object_unref0 (info);
@@ -515,6 +392,85 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) {
}
+static char* string_strip (const char* self) {
+ char* result = NULL;
+ char* _result_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _result_ = g_strdup (self);
+ g_strstrip (_result_);
+ result = _result_;
+ return result;
+}
+
+
+static char* music_player_bridge_truncate_player_name (char* app_info_name) {
+ char* result = NULL;
+ char* _tmp0_;
+ char* _tmp1_;
+ char* _result_;
+ gint tokens_length1;
+ gint _tokens_size_;
+ char** _tmp3_;
+ char** _tmp2_;
+ char** tokens;
+ g_return_val_if_fail (app_info_name != NULL, NULL);
+ _result_ = (_tmp1_ = string_strip (_tmp0_ = g_utf8_strdown (app_info_name, -1)), _g_free0 (_tmp0_), _tmp1_);
+ tokens = (_tmp3_ = _tmp2_ = g_strsplit (_result_, " ", 0), tokens_length1 = _vala_array_length (_tmp2_), _tokens_size_ = tokens_length1, _tmp3_);
+ if (tokens_length1 > 1) {
+ char* _tmp4_;
+ _result_ = (_tmp4_ = g_strdup (tokens[0]), _g_free0 (_result_), _tmp4_);
+ }
+ g_debug ("music-player-bridge.vala:165: truncate player name %s", _result_);
+ result = _result_;
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (app_info_name);
+ return result;
+}
+
+
+static char* music_player_bridge_determine_key (char* path) {
+ char* result = NULL;
+ gint tokens_length1;
+ gint _tokens_size_;
+ char** _tmp1_;
+ char** _tmp0_;
+ char** tokens;
+ char* filename;
+ char** _tmp2_;
+ char** _tmp3_;
+ gint _tmp3__length1;
+ char* _tmp4_;
+ char* _result_;
+ gint temp_length1;
+ gint _temp_size_;
+ char** _tmp6_;
+ char** _tmp5_;
+ char** temp;
+ g_return_val_if_fail (path != NULL, NULL);
+ tokens = (_tmp1_ = _tmp0_ = g_strsplit (path, "/", 0), tokens_length1 = _vala_array_length (_tmp0_), _tokens_size_ = tokens_length1, _tmp1_);
+ if (tokens_length1 < 2) {
+ result = NULL;
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (path);
+ return result;
+ }
+ filename = g_strdup (tokens[tokens_length1 - 1]);
+ _result_ = (_tmp4_ = g_strdup ((_tmp3_ = _tmp2_ = g_strsplit (filename, ".", 0), _tmp3__length1 = _vala_array_length (_tmp2_), _tmp3_)[0]), _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL), _tmp4_);
+ temp = (_tmp6_ = _tmp5_ = g_strsplit (_result_, "-", 0), temp_length1 = _vala_array_length (_tmp5_), _temp_size_ = temp_length1, _tmp6_);
+ if (temp_length1 > 1) {
+ char* _tmp7_;
+ _result_ = (_tmp7_ = g_strdup (temp[0]), _g_free0 (_result_), _tmp7_);
+ }
+ g_debug ("music-player-bridge.vala:179: determine key result = %s", _result_);
+ result = _result_;
+ temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (filename);
+ tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (path);
+ return result;
+}
+
+
static void music_player_bridge_class_init (MusicPlayerBridgeClass * klass) {
music_player_bridge_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (MusicPlayerBridgePrivate));