diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-01-11 16:44:38 -0600 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-01-11 16:44:38 -0600 |
commit | 412bffad64182bfae1e2408b89f9488f0da38481 (patch) | |
tree | 1617f11e230dcd76678196fd1fde6b95a1742bcd /src/mpris2-controller.c | |
parent | 13d392dab3f0fcba861bd6607ce17d68990b9228 (diff) | |
parent | 714c7c49776e8a341254a3e4297b465d181206cd (diff) | |
download | ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.tar.gz ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.tar.bz2 ayatana-indicator-sound-412bffad64182bfae1e2408b89f9488f0da38481.zip |
Import upstream version 0.5.5
Diffstat (limited to 'src/mpris2-controller.c')
-rw-r--r-- | src/mpris2-controller.c | 523 |
1 files changed, 146 insertions, 377 deletions
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index acedf64..9e198d7 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -1,4 +1,4 @@ -/* mpris2-controller.c generated by valac 0.11.2, the Vala compiler +/* mpris2-controller.c generated by valac 0.11.3, the Vala compiler * generated from mpris2-controller.vala, do not modify */ /* @@ -22,9 +22,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <glib-object.h> +#include <gio/gio.h> #include <stdlib.h> #include <string.h> -#include <gio/gio.h> #include <gee.h> #include <libdbusmenu-glib/client.h> #include <libdbusmenu-glib/menuitem-proxy.h> @@ -32,20 +32,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> -#define TYPE_FREE_DESKTOP_PROPERTIES (free_desktop_properties_get_type ()) -#define FREE_DESKTOP_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FREE_DESKTOP_PROPERTIES, FreeDesktopProperties)) -#define IS_FREE_DESKTOP_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FREE_DESKTOP_PROPERTIES)) -#define FREE_DESKTOP_PROPERTIES_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_FREE_DESKTOP_PROPERTIES, FreeDesktopPropertiesIface)) - -typedef struct _FreeDesktopProperties FreeDesktopProperties; -typedef struct _FreeDesktopPropertiesIface FreeDesktopPropertiesIface; - -#define TYPE_FREE_DESKTOP_PROPERTIES_PROXY (free_desktop_properties_proxy_get_type ()) -typedef GDBusProxy FreeDesktopPropertiesProxy; -typedef GDBusProxyClass FreeDesktopPropertiesProxyClass; -#define _g_free0(var) (var = (g_free (var), NULL)) -#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) - #define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) #define MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2Controller)) #define MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass)) @@ -93,6 +79,16 @@ typedef struct _PlaylistDetails PlaylistDetails; #define TYPE_ACTIVE_PLAYLIST_CONTAINER (active_playlist_container_get_type ()) typedef struct _ActivePlaylistContainer ActivePlaylistContainer; +#define TYPE_FREE_DESKTOP_PROPERTIES (free_desktop_properties_get_type ()) +#define FREE_DESKTOP_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FREE_DESKTOP_PROPERTIES, FreeDesktopProperties)) +#define IS_FREE_DESKTOP_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FREE_DESKTOP_PROPERTIES)) +#define FREE_DESKTOP_PROPERTIES_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_FREE_DESKTOP_PROPERTIES, FreeDesktopPropertiesIface)) + +typedef struct _FreeDesktopProperties FreeDesktopProperties; +typedef struct _FreeDesktopPropertiesIface FreeDesktopPropertiesIface; + +#define TYPE_FREE_DESKTOP_PROPERTIES_PROXY (free_desktop_properties_proxy_get_type ()) + #define TYPE_PLAYER_CONTROLLER (player_controller_get_type ()) #define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController)) #define PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_CONTROLLER, PlayerControllerClass)) @@ -128,6 +124,8 @@ typedef struct _PlayerItemClass PlayerItemClass; typedef struct _TransportMenuitem TransportMenuitem; typedef struct _TransportMenuitemClass TransportMenuitemClass; +#define _g_free0(var) (var = (g_free (var), NULL)) +#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) #define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ()) @@ -143,10 +141,6 @@ typedef struct _PlaylistsMenuitem PlaylistsMenuitem; typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) -struct _FreeDesktopPropertiesIface { - GTypeInterface parent_iface; -}; - struct _Mpris2Controller { GObject parent_instance; Mpris2ControllerPrivate * priv; @@ -214,6 +208,10 @@ struct _MprisPlaylistsIface { void (*set_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); }; +struct _FreeDesktopPropertiesIface { + GTypeInterface parent_iface; +}; + struct _Mpris2ControllerPrivate { MprisRoot* _mpris2_root; MprisPlayer* _player; @@ -233,6 +231,7 @@ struct _PlayerController { gint current_state; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; + gboolean* use_playlists; }; struct _PlayerControllerClass { @@ -256,18 +255,6 @@ typedef enum { static gpointer mpris2_controller_parent_class = NULL; -GType free_desktop_properties_get_type (void) G_GNUC_CONST; -GType free_desktop_properties_proxy_get_type (void) G_GNUC_CONST; -guint free_desktop_properties_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); -static void g_cclosure_user_marshal_VOID__STRING_BOXED_BOXED_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data); -static void free_desktop_properties_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); -static void _dbus_handle_free_desktop_properties_properties_changed (FreeDesktopProperties* self, GVariant* parameters); -static void free_desktop_properties_proxy_free_desktop_properties_interface_init (FreeDesktopPropertiesIface* iface); -static void free_desktop_properties_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data); -static GVariant* free_desktop_properties_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data); -static gboolean free_desktop_properties_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data); -static void _dbus_free_desktop_properties_properties_changed (GObject* _sender, const gchar* source, GHashTable* changed_properties, gchar** invalid, int invalid_length1, gpointer* _data); -static void _free_desktop_properties_unregister_object (gpointer user_data); GType mpris2_controller_get_type (void) G_GNUC_CONST; GType mpris_root_proxy_get_type (void) G_GNUC_CONST; guint mpris_root_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); @@ -288,6 +275,9 @@ void active_playlist_container_free (ActivePlaylistContainer* self); void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest); void active_playlist_container_destroy (ActivePlaylistContainer* self); GType mpris_playlists_get_type (void) G_GNUC_CONST; +GType free_desktop_properties_get_type (void) G_GNUC_CONST; +GType free_desktop_properties_proxy_get_type (void) G_GNUC_CONST; +guint free_desktop_properties_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); GType player_controller_get_type (void) G_GNUC_CONST; #define MPRIS2_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerPrivate)) enum { @@ -303,7 +293,7 @@ Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerControll void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* interface_source, GHashTable* changed_properties, gchar** invalid, int invalid_length1); PlayerController* mpris2_controller_get_owner (Mpris2Controller* self); const gchar* player_controller_get_dbus_name (PlayerController* self); -#define MPRIS2_WATCHER_MPRIS_PREFIX "org.mpris.MediaPlayer2." +#define MPRIS_PREFIX "org.mpris.MediaPlayer2." MprisPlayer* mpris2_controller_get_player (Mpris2Controller* self); gchar* mpris_player_get_PlaybackStatus (MprisPlayer* self); static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controller* self); @@ -319,11 +309,8 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs); GeeHashSet* metadata_menuitem_attributes_format (void); void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes); gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self); -gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self); -MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self); -guint32 mpris_playlists_get_PlaylistCount (MprisPlaylists* self); -static guint32* _uint32_dup (guint32* self); GHashTable* mpris_player_get_Metadata (MprisPlayer* self); static gchar** _variant_get1 (GVariant* value, int* result_length1); static gchar** _vala_array_dup1 (gchar** self, int length); @@ -340,9 +327,11 @@ void mpris_player_Previous (MprisPlayer* self, GAsyncReadyCallback _callback_, g void mpris_player_Previous_finish (MprisPlayer* self, GAsyncResult* _res_, GError** error); void mpris_player_Next (MprisPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_); void mpris_player_Next_finish (MprisPlayer* self, GAsyncResult* _res_, GError** error); +MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self); PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error); GType playlists_menuitem_get_type (void) G_GNUC_CONST; void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1); +static gboolean* _bool_dup (gboolean* self); static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length); void mpris_playlists_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result); void playlists_menuitem_update_active_playlist (PlaylistsMenuitem* self, PlaylistDetails* detail); @@ -368,227 +357,6 @@ static void _vala_mpris2_controller_set_property (GObject * object, guint proper static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); -static const GDBusMethodInfo * const _free_desktop_properties_dbus_method_info[] = {NULL}; -static const GDBusArgInfo _free_desktop_properties_dbus_arg_info_properties_changed_source = {-1, "source", "s"}; -static const GDBusArgInfo _free_desktop_properties_dbus_arg_info_properties_changed_changed_properties = {-1, "changed_properties", "a{sv}"}; -static const GDBusArgInfo _free_desktop_properties_dbus_arg_info_properties_changed_invalid = {-1, "invalid", "as"}; -static const GDBusArgInfo * const _free_desktop_properties_dbus_arg_info_properties_changed[] = {&_free_desktop_properties_dbus_arg_info_properties_changed_source, &_free_desktop_properties_dbus_arg_info_properties_changed_changed_properties, &_free_desktop_properties_dbus_arg_info_properties_changed_invalid, NULL}; -static const GDBusSignalInfo _free_desktop_properties_dbus_signal_info_properties_changed = {-1, "PropertiesChanged", (GDBusArgInfo **) (&_free_desktop_properties_dbus_arg_info_properties_changed)}; -static const GDBusSignalInfo * const _free_desktop_properties_dbus_signal_info[] = {&_free_desktop_properties_dbus_signal_info_properties_changed, NULL}; -static const GDBusPropertyInfo * const _free_desktop_properties_dbus_property_info[] = {NULL}; -static const GDBusInterfaceInfo _free_desktop_properties_dbus_interface_info = {-1, "org.freedesktop.DBus.Properties", (GDBusMethodInfo **) (&_free_desktop_properties_dbus_method_info), (GDBusSignalInfo **) (&_free_desktop_properties_dbus_signal_info), (GDBusPropertyInfo **) (&_free_desktop_properties_dbus_property_info)}; -static const GDBusInterfaceVTable _free_desktop_properties_dbus_interface_vtable = {free_desktop_properties_dbus_interface_method_call, free_desktop_properties_dbus_interface_get_property, free_desktop_properties_dbus_interface_set_property}; - -static void g_cclosure_user_marshal_VOID__STRING_BOXED_BOXED_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__STRING_BOXED_BOXED_INT) (gpointer data1, const char* arg_1, gpointer arg_2, gpointer arg_3, gint arg_4, gpointer data2); - register GMarshalFunc_VOID__STRING_BOXED_BOXED_INT callback; - register GCClosure * cc; - register gpointer data1, data2; - cc = (GCClosure *) closure; - g_return_if_fail (n_param_values == 5); - if (G_CCLOSURE_SWAP_DATA (closure)) { - data1 = closure->data; - data2 = param_values->data[0].v_pointer; - } else { - data1 = param_values->data[0].v_pointer; - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__STRING_BOXED_BOXED_INT) (marshal_data ? marshal_data : cc->callback); - callback (data1, g_value_get_string (param_values + 1), g_value_get_boxed (param_values + 2), g_value_get_boxed (param_values + 3), g_value_get_int (param_values + 4), data2); -} - - -static void free_desktop_properties_base_init (FreeDesktopPropertiesIface * iface) { - static gboolean initialized = FALSE; - if (!initialized) { - initialized = TRUE; - g_signal_new ("properties_changed", TYPE_FREE_DESKTOP_PROPERTIES, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_BOXED_BOXED_INT, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_HASH_TABLE, G_TYPE_STRV, G_TYPE_INT); - g_type_set_qdata (TYPE_FREE_DESKTOP_PROPERTIES, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_properties_register_object); - } -} - - -GType free_desktop_properties_get_type (void) { - static volatile gsize free_desktop_properties_type_id__volatile = 0; - if (g_once_init_enter (&free_desktop_properties_type_id__volatile)) { - static const GTypeInfo g_define_type_info = { sizeof (FreeDesktopPropertiesIface), (GBaseInitFunc) free_desktop_properties_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; - GType free_desktop_properties_type_id; - free_desktop_properties_type_id = g_type_register_static (G_TYPE_INTERFACE, "FreeDesktopProperties", &g_define_type_info, 0); - g_type_interface_add_prerequisite (free_desktop_properties_type_id, G_TYPE_OBJECT); - g_once_init_leave (&free_desktop_properties_type_id__volatile, free_desktop_properties_type_id); - } - return free_desktop_properties_type_id__volatile; -} - - -G_DEFINE_TYPE_EXTENDED (FreeDesktopPropertiesProxy, free_desktop_properties_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_FREE_DESKTOP_PROPERTIES, free_desktop_properties_proxy_free_desktop_properties_interface_init) ); -static void free_desktop_properties_proxy_class_init (FreeDesktopPropertiesProxyClass* klass) { - G_DBUS_PROXY_CLASS (klass)->g_signal = free_desktop_properties_proxy_g_signal; -} - - -static void _dbus_handle_free_desktop_properties_properties_changed (FreeDesktopProperties* self, GVariant* parameters) { - GVariantIter _arguments_iter; - gchar* source = NULL; - GVariant* _tmp79_; - GHashTable* changed_properties = NULL; - GVariant* _tmp80_; - GHashTable* _tmp81_; - GVariantIter _tmp82_; - GVariant* _tmp83_; - GVariant* _tmp84_; - gchar** invalid = NULL; - int invalid_length1; - GVariant* _tmp85_; - gchar** _tmp86_; - int _tmp86__length; - int _tmp86__size; - int _tmp86__length1; - GVariantIter _tmp87_; - GVariant* _tmp88_; - g_variant_iter_init (&_arguments_iter, parameters); - _tmp79_ = g_variant_iter_next_value (&_arguments_iter); - source = g_variant_dup_string (_tmp79_, NULL); - g_variant_unref (_tmp79_); - _tmp80_ = g_variant_iter_next_value (&_arguments_iter); - _tmp81_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_variant_iter_init (&_tmp82_, _tmp80_); - while (g_variant_iter_loop (&_tmp82_, "{?*}", &_tmp83_, &_tmp84_)) { - g_hash_table_insert (_tmp81_, g_variant_dup_string (_tmp83_, NULL), g_variant_get_variant (_tmp84_)); - } - changed_properties = _tmp81_; - g_variant_unref (_tmp80_); - invalid_length1 = 0; - _tmp85_ = g_variant_iter_next_value (&_arguments_iter); - _tmp86_ = g_new (gchar*, 5); - _tmp86__length = 0; - _tmp86__size = 4; - _tmp86__length1 = 0; - g_variant_iter_init (&_tmp87_, _tmp85_); - for (; _tmp88_ = g_variant_iter_next_value (&_tmp87_); _tmp86__length1++) { - if (_tmp86__size == _tmp86__length) { - _tmp86__size = 2 * _tmp86__size; - _tmp86_ = g_renew (gchar*, _tmp86_, _tmp86__size + 1); - } - _tmp86_[_tmp86__length++] = g_variant_dup_string (_tmp88_, NULL); - g_variant_unref (_tmp88_); - } - invalid_length1 = _tmp86__length1; - _tmp86_[_tmp86__length] = NULL; - invalid = _tmp86_; - g_variant_unref (_tmp85_); - g_signal_emit_by_name (self, "properties-changed", source, changed_properties, invalid, invalid_length1); - _g_free0 (source); - _g_hash_table_unref0 (changed_properties); - invalid = (_vala_array_free (invalid, invalid_length1, (GDestroyNotify) g_free), NULL); -} - - -static void free_desktop_properties_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) { - if (strcmp (signal_name, "PropertiesChanged") == 0) { - _dbus_handle_free_desktop_properties_properties_changed (proxy, parameters); - } -} - - -static void free_desktop_properties_proxy_init (FreeDesktopPropertiesProxy* self) { -} - - -static void free_desktop_properties_proxy_free_desktop_properties_interface_init (FreeDesktopPropertiesIface* iface) { -} - - -static void free_desktop_properties_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) { - gpointer* data; - gpointer object; - data = user_data; - object = data[0]; - g_object_unref (invocation); -} - - -static GVariant* free_desktop_properties_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) { - gpointer* data; - gpointer object; - data = user_data; - object = data[0]; - return NULL; -} - - -static gboolean free_desktop_properties_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) { - gpointer* data; - gpointer object; - data = user_data; - object = data[0]; - return FALSE; -} - - -static void _dbus_free_desktop_properties_properties_changed (GObject* _sender, const gchar* source, GHashTable* changed_properties, gchar** invalid, int invalid_length1, gpointer* _data) { - GDBusConnection * _connection; - const gchar * _path; - GVariant *_arguments; - GVariantBuilder _arguments_builder; - GVariantBuilder _tmp89_; - GHashTableIter _tmp90_; - gpointer _tmp91_; - gpointer _tmp92_; - gchar** _tmp93_; - GVariantBuilder _tmp94_; - int _tmp95_; - _connection = _data[1]; - _path = _data[2]; - g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (source)); - g_hash_table_iter_init (&_tmp90_, changed_properties); - g_variant_builder_init (&_tmp89_, G_VARIANT_TYPE_DICTIONARY); - while (g_hash_table_iter_next (&_tmp90_, &_tmp91_, &_tmp92_)) { - gchar* _key; - GVariant* _value; - _key = (gchar*) _tmp91_; - _value = (GVariant*) _tmp92_; - g_variant_builder_add (&_tmp89_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value)); - } - g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp89_)); - _tmp93_ = invalid; - g_variant_builder_init (&_tmp94_, G_VARIANT_TYPE ("as")); - for (_tmp95_ = 0; _tmp95_ < invalid_length1; _tmp95_++) { - g_variant_builder_add_value (&_tmp94_, g_variant_new_string (*_tmp93_)); - _tmp93_++; - } - g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp94_)); - _arguments = g_variant_builder_end (&_arguments_builder); - g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.DBus.Properties", "PropertiesChanged", _arguments, NULL); -} - - -guint free_desktop_properties_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) { - guint result; - gpointer *data; - data = g_new (gpointer, 3); - data[0] = g_object_ref (object); - data[1] = g_object_ref (connection); - data[2] = g_strdup (path); - result = g_dbus_connection_register_object (connection, path, &_free_desktop_properties_dbus_interface_info, &_free_desktop_properties_dbus_interface_vtable, data, _free_desktop_properties_unregister_object, error); - if (!result) { - return 0; - } - g_signal_connect (object, "properties-changed", (GCallback) _dbus_free_desktop_properties_properties_changed, data); - return result; -} - - -static void _free_desktop_properties_unregister_object (gpointer user_data) { - gpointer* data; - data = user_data; - g_object_unref (data[0]); - g_object_unref (data[1]); - g_free (data[2]); - g_free (data); -} - Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl) { Mpris2Controller * self = NULL; @@ -615,6 +383,20 @@ static gboolean _mpris2_controller_ensure_correct_playback_status_gsource_func ( } +static gboolean _bool_equal (const gboolean* s1, const gboolean* s2) { + if (s1 == s2) { + return TRUE; + } + if (s1 == NULL) { + return FALSE; + } + if (s2 == NULL) { + return FALSE; + } + return (*s1) == (*s2); +} + + void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* interface_source, GHashTable* changed_properties, gchar** invalid, int invalid_length1) { const gchar* _tmp0_ = NULL; gboolean _tmp1_ = FALSE; @@ -627,21 +409,22 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* gconstpointer _tmp21_ = NULL; GVariant* _tmp22_; GVariant* playlist_v; + gboolean _tmp23_ = FALSE; g_return_if_fail (self != NULL); g_return_if_fail (interface_source != NULL); g_return_if_fail (changed_properties != NULL); _tmp0_ = player_controller_get_dbus_name (self->priv->_owner); - g_debug ("mpris2-controller.vala:71: properties-changed for interface %s and own" \ + g_debug ("mpris2-controller.vala:66: properties-changed for interface %s and own" \ "er %s", interface_source, _tmp0_); if (changed_properties == NULL) { _tmp1_ = TRUE; } else { gboolean _tmp2_; - _tmp2_ = g_str_has_prefix (interface_source, MPRIS2_WATCHER_MPRIS_PREFIX); + _tmp2_ = g_str_has_prefix (interface_source, MPRIS_PREFIX); _tmp1_ = _tmp2_ == FALSE; } if (_tmp1_) { - g_warning ("mpris2-controller.vala:74: Property-changed hash is null or this is an" \ + g_warning ("mpris2-controller.vala:69: Property-changed hash is null or this is an" \ " interface that doesn't concerns us"); return; } @@ -706,6 +489,12 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* _tmp22_ = _g_variant_ref0 ((GVariant*) _tmp21_); playlist_v = _tmp22_; if (playlist_v != NULL) { + gboolean _tmp24_; + _tmp23_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp24_ = TRUE, &_tmp24_)) == TRUE; + } else { + _tmp23_ = FALSE; + } + if (_tmp23_) { mpris2_controller_fetch_active_playlist (self); } _g_variant_unref0 (playlist_v); @@ -714,49 +503,6 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* } -static guint32* _uint32_dup (guint32* self) { - guint32* dup; - dup = g_new0 (guint32, 1); - memcpy (dup, self, sizeof (guint32)); - return dup; -} - - -static gpointer __uint32_dup0 (gpointer self) { - return self ? _uint32_dup (self) : NULL; -} - - -gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self) { - gboolean result = FALSE; - guint32 _tmp0_; - guint32* _tmp1_; - guint32* count; - gboolean _tmp2_ = FALSE; - g_return_val_if_fail (self != NULL, FALSE); - if (self->priv->_playlists == NULL) { - result = FALSE; - return result; - } - _tmp0_ = mpris_playlists_get_PlaylistCount (self->priv->_playlists); - _tmp1_ = __uint32_dup0 (&_tmp0_); - count = _tmp1_; - if (count == NULL) { - _tmp2_ = TRUE; - } else { - _tmp2_ = (*count) <= 0; - } - if (_tmp2_) { - result = FALSE; - _g_free0 (count); - return result; - } - result = TRUE; - _g_free0 (count); - return result; -} - - static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controller* self) { gboolean result = FALSE; gchar* _tmp0_ = NULL; @@ -772,7 +518,7 @@ static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controll g_return_val_if_fail (self != NULL, FALSE); _tmp0_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp1_ = _tmp0_; - g_debug ("mpris2-controller.vala:113: TEST playback status = %s", _tmp1_); + g_debug ("mpris2-controller.vala:99: TEST playback status = %s", _tmp1_); _g_free0 (_tmp1_); _tmp2_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp3_ = _tmp2_; @@ -799,7 +545,7 @@ static gchar** _variant_get1 (GVariant* value, int* result_length1) { _tmp10__size = 4; _tmp10__length1 = 0; g_variant_iter_init (&_tmp11_, value); - for (; _tmp12_ = g_variant_iter_next_value (&_tmp11_); _tmp10__length1++) { + for (; (_tmp12_ = g_variant_iter_next_value (&_tmp11_)) != NULL; _tmp10__length1++) { if (_tmp10__size == _tmp10__length) { _tmp10__size = 2 * _tmp10__size; _tmp10_ = g_renew (gchar*, _tmp10_, _tmp10__size + 1); @@ -892,7 +638,7 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { _tmp18_ = g_strdup ("xesam:artist"); g_hash_table_replace (changed_updates, _tmp18_, _variant_new2 (display_artists)); _tmp19_ = g_hash_table_lookup (changed_updates, "xesam:artist"); - g_debug ("mpris2-controller.vala:127: artist : %s", _variant_get3 ((GVariant*) _tmp19_)); + g_debug ("mpris2-controller.vala:113: artist : %s", _variant_get3 ((GVariant*) _tmp19_)); _g_free0 (display_artists); artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL); } @@ -957,6 +703,7 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { PlayerItem* _tmp9_; GeeHashSet* _tmp10_ = NULL; GeeHashSet* _tmp11_; + gboolean _tmp12_; g_return_if_fail (self != NULL); _tmp0_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp1_ = _tmp0_; @@ -978,15 +725,17 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { player_item_update (_tmp9_, cleaned_metadata, _tmp11_); _g_object_unref0 (_tmp11_); _g_object_unref0 (_tmp9_); - mpris2_controller_fetch_playlists (self); - mpris2_controller_fetch_active_playlist (self); + if (_bool_equal (self->priv->_owner->use_playlists, (_tmp12_ = TRUE, &_tmp12_)) == TRUE) { + mpris2_controller_fetch_playlists (self); + mpris2_controller_fetch_active_playlist (self); + } _g_hash_table_unref0 (cleaned_metadata); } void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command) { g_return_if_fail (self != NULL); - g_debug ("mpris2-controller.vala:163: transport_event input = %i", (gint) command); + g_debug ("mpris2-controller.vala:152: transport_event input = %i", (gint) command); if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) { mpris_player_PlayPause (self->priv->_player, NULL, NULL); } else { @@ -1001,6 +750,19 @@ void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuit } +static gboolean* _bool_dup (gboolean* self) { + gboolean* dup; + dup = g_new0 (gboolean, 1); + memcpy (dup, self, sizeof (gboolean)); + return dup; +} + + +static gpointer __bool_dup0 (gpointer self) { + return self ? _bool_dup (self) : NULL; +} + + static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length) { if (array != NULL) { int i; @@ -1021,9 +783,6 @@ void mpris2_controller_fetch_playlists (Mpris2Controller* self) { PlaylistDetails* current_playlists; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); - if (self->priv->_playlists == NULL) { - return; - } _tmp1_ = mpris_playlists_GetPlaylists (self->priv->_playlists, (guint32) 0, (guint32) 10, "Alphabetical", FALSE, &_tmp0_, &_inner_error_); _tmp2_ = _tmp1_; current_playlists_length1 = _tmp0_; @@ -1038,11 +797,21 @@ void mpris2_controller_fetch_playlists (Mpris2Controller* self) { gpointer _tmp3_ = NULL; PlayerItem* _tmp4_; PlaylistsMenuitem* playlists_item; - g_debug ("mpris2-controller.vala:184: Size of the playlist array = %i", current_playlists_length1); + g_debug ("mpris2-controller.vala:171: Size of the playlist array = %i", current_playlists_length1); _tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); playlists_item = (_tmp4_ = (PlayerItem*) _tmp3_, IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL); playlists_menuitem_update (playlists_item, current_playlists, current_playlists_length1); _g_object_unref0 (playlists_item); + } else { + gboolean _tmp5_; + gboolean* _tmp6_; + gboolean* _tmp7_; + g_warning ("mpris2-controller.vala:176: Playlists are on but its returning no cur" \ +"rent_playlists"); + _tmp6_ = __bool_dup0 ((_tmp5_ = FALSE, &_tmp5_)); + _tmp7_ = _tmp6_; + _g_free0 (self->priv->_owner->use_playlists); + self->priv->_owner->use_playlists = _tmp7_; } current_playlists = (_vala_PlaylistDetails_array_free (current_playlists, current_playlists_length1), NULL); return; @@ -1050,26 +819,19 @@ void mpris2_controller_fetch_playlists (Mpris2Controller* self) { static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self) { - gboolean _tmp0_ = FALSE; + ActivePlaylistContainer _tmp0_ = {0}; + ActivePlaylistContainer _tmp1_; + gboolean _tmp2_; gpointer _tmp3_ = NULL; PlayerItem* _tmp4_; PlaylistsMenuitem* playlists_item; ActivePlaylistContainer _tmp5_ = {0}; ActivePlaylistContainer _tmp6_; g_return_if_fail (self != NULL); - if (self->priv->_playlists == NULL) { - ActivePlaylistContainer _tmp1_ = {0}; - ActivePlaylistContainer _tmp2_; - mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp1_); - _tmp2_ = _tmp1_; - _tmp0_ = _tmp2_.valid == FALSE; - active_playlist_container_destroy (&_tmp2_); - } else { - _tmp0_ = FALSE; - } - if (_tmp0_) { - g_warning ("mpris2-controller.vala:194: Playlists object is null or we don't have " \ -"an active playlist"); + mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp0_); + _tmp1_ = _tmp0_; + if ((_tmp2_ = _tmp1_.valid == FALSE, active_playlist_container_destroy (&_tmp1_), _tmp2_)) { + g_debug ("mpris2-controller.vala:185: We don't have an active playlist"); } _tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); playlists_item = (_tmp4_ = (PlayerItem*) _tmp3_, IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL); @@ -1109,21 +871,17 @@ void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* pa GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (path != NULL); - if (self->priv->_playlists == NULL) { - g_warning ("mpris2-controller.vala:216: playlists mpris instance is null !"); - return; - } mpris_playlists_ActivatePlaylist (self->priv->_playlists, path, NULL, NULL); - goto __finally10; - __catch10_g_io_error: + goto __finally11; + __catch11_g_io_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; - g_debug ("mpris2-controller.vala:223: Could not activate playlist %s because %s", (const gchar*) path, e->message); + g_debug ("mpris2-controller.vala:210: Could not activate playlist %s because %s", (const gchar*) path, e->message); _g_error_free0 (e); } - __finally10: + __finally11: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -1248,83 +1006,94 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr Mpris2Controller * self; const gchar* _tmp0_ = NULL; const gchar* _tmp1_ = NULL; - MprisRoot* _tmp2_; + MprisRoot* _tmp2_ = NULL; MprisRoot* _tmp3_; - const gchar* _tmp4_ = NULL; + MprisRoot* _tmp4_; const gchar* _tmp5_ = NULL; - MprisPlayer* _tmp6_; - MprisPlayer* _tmp7_; - const gchar* _tmp8_ = NULL; - const gchar* _tmp9_ = NULL; - MprisPlaylists* _tmp10_; - MprisPlaylists* _tmp11_; - FreeDesktopProperties* _tmp12_; - FreeDesktopProperties* _tmp13_; + const gchar* _tmp6_ = NULL; + MprisPlayer* _tmp7_ = NULL; + MprisPlayer* _tmp8_; + MprisPlayer* _tmp9_; + gboolean _tmp10_; + FreeDesktopProperties* _tmp16_ = NULL; + FreeDesktopProperties* _tmp17_; + FreeDesktopProperties* _tmp18_; GError * _inner_error_ = NULL; parent_class = G_OBJECT_CLASS (mpris2_controller_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = MPRIS2_CONTROLLER (obj); _tmp0_ = player_controller_get_dbus_name (self->priv->_owner); _tmp1_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp2_ = (MprisRoot*) g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp1_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2", NULL); + _tmp2_ = g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp1_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2", NULL); + _tmp3_ = (MprisRoot*) _tmp2_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch11_g_io_error; + goto __catch12_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp3_ = _tmp2_; - mpris2_controller_set_mpris2_root (self, _tmp3_); - _g_object_unref0 (_tmp3_); - _tmp4_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp4_ = _tmp3_; + mpris2_controller_set_mpris2_root (self, _tmp4_); + _g_object_unref0 (_tmp4_); _tmp5_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp6_ = (MprisPlayer*) g_initable_new (TYPE_MPRIS_PLAYER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp5_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Player", NULL); + _tmp6_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp7_ = g_initable_new (TYPE_MPRIS_PLAYER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp6_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Player", NULL); + _tmp8_ = (MprisPlayer*) _tmp7_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch11_g_io_error; + goto __catch12_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp7_ = _tmp6_; - mpris2_controller_set_player (self, _tmp7_); - _g_object_unref0 (_tmp7_); - _tmp8_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp9_ = player_controller_get_dbus_name (self->priv->_owner); - _tmp10_ = (MprisPlaylists*) g_initable_new (TYPE_MPRIS_PLAYLISTS_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp9_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Playlists", NULL); - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_IO_ERROR) { - goto __catch11_g_io_error; + _tmp9_ = _tmp8_; + mpris2_controller_set_player (self, _tmp9_); + _g_object_unref0 (_tmp9_); + if (_bool_equal (self->priv->_owner->use_playlists, (_tmp10_ = TRUE, &_tmp10_)) == TRUE) { + const gchar* _tmp11_ = NULL; + const gchar* _tmp12_ = NULL; + MprisPlaylists* _tmp13_ = NULL; + MprisPlaylists* _tmp14_; + MprisPlaylists* _tmp15_; + _tmp11_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp12_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp13_ = g_initable_new (TYPE_MPRIS_PLAYLISTS_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp12_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Playlists", NULL); + _tmp14_ = (MprisPlaylists*) _tmp13_; + if (_inner_error_ != NULL) { + if (_inner_error_->domain == G_IO_ERROR) { + goto __catch12_g_io_error; + } + g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); } - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); + _tmp15_ = _tmp14_; + mpris2_controller_set_playlists (self, _tmp15_); + _g_object_unref0 (_tmp15_); } - _tmp11_ = _tmp10_; - mpris2_controller_set_playlists (self, _tmp11_); - _g_object_unref0 (_tmp11_); - _tmp12_ = (FreeDesktopProperties*) g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); + _tmp16_ = g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); + _tmp17_ = (FreeDesktopProperties*) _tmp16_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch11_g_io_error; + goto __catch12_g_io_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); } - _tmp13_ = _tmp12_; - mpris2_controller_set_properties_interface (self, _tmp13_); - _g_object_unref0 (_tmp13_); + _tmp18_ = _tmp17_; + mpris2_controller_set_properties_interface (self, _tmp18_); + _g_object_unref0 (_tmp18_); g_signal_connect_object (self->priv->_properties_interface, "properties-changed", (GCallback) _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed, self, 0); - goto __finally11; - __catch11_g_io_error: + goto __finally12; + __catch12_g_io_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; - g_error ("mpris2-controller.vala:63: Problems connecting to the session bus - %s", e->message); + g_error ("mpris2-controller.vala:58: Problems connecting to the session bus - %s", e->message); _g_error_free0 (e); } - __finally11: + __finally12: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); |