Back to index

libunity  5.92.0
test-mpris-backend-prop-updates-server.c
Go to the documentation of this file.
00001 /* test-mpris-backend-prop-updates-server.c generated by valac 0.17.2, the Vala compiler
00002  * generated from test-mpris-backend-prop-updates-server.vala, do not modify */
00003 
00004 
00005 #include <glib.h>
00006 #include <glib-object.h>
00007 #include <unity-internal.h>
00008 #include <gio/gio.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <config.h>
00012 
00013 
00014 #define TYPE_MPRIS_SERVER (mpris_server_get_type ())
00015 #define MPRIS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_SERVER, MprisServer))
00016 #define MPRIS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_SERVER, MprisServerClass))
00017 #define IS_MPRIS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_SERVER))
00018 #define IS_MPRIS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_SERVER))
00019 #define MPRIS_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_SERVER, MprisServerClass))
00020 
00021 typedef struct _MprisServer MprisServer;
00022 typedef struct _MprisServerClass MprisServerClass;
00023 typedef struct _MprisServerPrivate MprisServerPrivate;
00024 
00025 #define TYPE_TYPICAL_PLAYER (typical_player_get_type ())
00026 #define TYPICAL_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TYPICAL_PLAYER, TypicalPlayer))
00027 #define TYPICAL_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TYPICAL_PLAYER, TypicalPlayerClass))
00028 #define IS_TYPICAL_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TYPICAL_PLAYER))
00029 #define IS_TYPICAL_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TYPICAL_PLAYER))
00030 #define TYPICAL_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TYPICAL_PLAYER, TypicalPlayerClass))
00031 
00032 typedef struct _TypicalPlayer TypicalPlayer;
00033 typedef struct _TypicalPlayerClass TypicalPlayerClass;
00034 #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
00035 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00036 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
00037 #define _g_free0(var) (var = (g_free (var), NULL))
00038 typedef struct _TypicalPlayerPrivate TypicalPlayerPrivate;
00039 
00040 struct _MprisServer {
00041        GObject parent_instance;
00042        MprisServerPrivate * priv;
00043 };
00044 
00045 struct _MprisServerClass {
00046        GObjectClass parent_class;
00047 };
00048 
00049 struct _MprisServerPrivate {
00050        GMainLoop* _mainloop;
00051        TypicalPlayer* _player;
00052 };
00053 
00054 struct _TypicalPlayer {
00055        GObject parent_instance;
00056        TypicalPlayerPrivate * priv;
00057 };
00058 
00059 struct _TypicalPlayerClass {
00060        GObjectClass parent_class;
00061 };
00062 
00063 struct _TypicalPlayerPrivate {
00064        UnityMusicPlayer* _menu_player;
00065 };
00066 
00067 
00068 static gpointer mpris_server_parent_class = NULL;
00069 static gpointer typical_player_parent_class = NULL;
00070 
00071 GType mpris_server_get_type (void) G_GNUC_CONST;
00072 GType typical_player_get_type (void) G_GNUC_CONST;
00073 #define MPRIS_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_SERVER, MprisServerPrivate))
00074 enum  {
00075        MPRIS_SERVER_DUMMY_PROPERTY,
00076        MPRIS_SERVER_MAINLOOP,
00077        MPRIS_SERVER_PLAYER
00078 };
00079 MprisServer* mpris_server_new (GMainLoop* loop, TypicalPlayer* p);
00080 MprisServer* mpris_server_construct (GType object_type, GMainLoop* loop, TypicalPlayer* p);
00081 gboolean mpris_server_escape (MprisServer* self);
00082 GMainLoop* mpris_server_get_mainloop (MprisServer* self);
00083 gboolean mpris_server_set_up_typical_consumer (MprisServer* self);
00084 TypicalPlayer* mpris_server_get_player (MprisServer* self);
00085 UnityMusicPlayer* typical_player_get_menu_player (TypicalPlayer* self);
00086 static gboolean _mpris_server_escape_gsource_func (gpointer self);
00087 gboolean mpris_server_change_playlist_names (MprisServer* self);
00088 gint mpris_server_main (gchar** args, int args_length1);
00089 TypicalPlayer* typical_player_new (void);
00090 TypicalPlayer* typical_player_construct (GType object_type);
00091 static void mpris_server_set_mainloop (MprisServer* self, GMainLoop* value);
00092 static void mpris_server_set_player (MprisServer* self, TypicalPlayer* value);
00093 static GObject * mpris_server_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
00094 static gboolean _mpris_server_set_up_typical_consumer_gsource_func (gpointer self);
00095 static void mpris_server_finalize (GObject* obj);
00096 static void _vala_mpris_server_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
00097 static void _vala_mpris_server_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
00098 #define TYPICAL_PLAYER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TYPICAL_PLAYER, TypicalPlayerPrivate))
00099 enum  {
00100        TYPICAL_PLAYER_DUMMY_PROPERTY,
00101        TYPICAL_PLAYER_MENU_PLAYER
00102 };
00103 static void typical_player_on_raise (TypicalPlayer* self);
00104 static void typical_player_on_play_pause (TypicalPlayer* self);
00105 static void typical_player_on_previous (TypicalPlayer* self);
00106 static void typical_player_on_next (TypicalPlayer* self);
00107 static void typical_player_on_activate_playlist (TypicalPlayer* self, const char* playlist_id);
00108 static void typical_player_set_menu_player (TypicalPlayer* self, UnityMusicPlayer* value);
00109 static GObject * typical_player_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
00110 static void _typical_player_on_raise_unity_music_player_raise (UnityMusicPlayer* _sender, gpointer self);
00111 static void _typical_player_on_play_pause_unity_music_player_play_pause (UnityMusicPlayer* _sender, gpointer self);
00112 static void _typical_player_on_previous_unity_music_player_previous (UnityMusicPlayer* _sender, gpointer self);
00113 static void _typical_player_on_next_unity_music_player_next (UnityMusicPlayer* _sender, gpointer self);
00114 static void _typical_player_on_activate_playlist_unity_music_player_activate_playlist (UnityMusicPlayer* _sender, const char* playlist_id, gpointer self);
00115 static void typical_player_finalize (GObject* obj);
00116 static void _vala_typical_player_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
00117 static void _vala_typical_player_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
00118 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
00119 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
00120 
00121 
00122 MprisServer* mpris_server_construct (GType object_type, GMainLoop* loop, TypicalPlayer* p) {
00123        MprisServer * self = NULL;
00124        GMainLoop* _tmp0_;
00125        TypicalPlayer* _tmp1_;
00126        g_return_val_if_fail (loop != NULL, NULL);
00127        g_return_val_if_fail (p != NULL, NULL);
00128        _tmp0_ = loop;
00129        _tmp1_ = p;
00130        self = (MprisServer*) g_object_new (object_type, "mainloop", _tmp0_, "player", _tmp1_, NULL);
00131        return self;
00132 }
00133 
00134 
00135 MprisServer* mpris_server_new (GMainLoop* loop, TypicalPlayer* p) {
00136        return mpris_server_construct (TYPE_MPRIS_SERVER, loop, p);
00137 }
00138 
00139 
00140 gboolean mpris_server_escape (MprisServer* self) {
00141        gboolean result = FALSE;
00142        GMainLoop* _tmp0_;
00143        g_return_val_if_fail (self != NULL, FALSE);
00144        _tmp0_ = self->priv->_mainloop;
00145        g_main_loop_quit (_tmp0_);
00146        result = FALSE;
00147        return result;
00148 }
00149 
00150 
00151 static gboolean _mpris_server_escape_gsource_func (gpointer self) {
00152        gboolean result;
00153        result = mpris_server_escape (self);
00154        return result;
00155 }
00156 
00157 
00158 gboolean mpris_server_set_up_typical_consumer (MprisServer* self) {
00159        gboolean result = FALSE;
00160        UnityTrackMetadata* _tmp0_;
00161        UnityTrackMetadata* metadata;
00162        UnityTrackMetadata* _tmp1_;
00163        UnityTrackMetadata* _tmp2_;
00164        UnityTrackMetadata* _tmp3_;
00165        UnityTrackMetadata* _tmp4_;
00166        GFile* _tmp5_ = NULL;
00167        GFile* _tmp6_;
00168        TypicalPlayer* _tmp7_;
00169        UnityMusicPlayer* _tmp8_;
00170        UnityMusicPlayer* _tmp9_;
00171        UnityTrackMetadata* _tmp10_;
00172        TypicalPlayer* _tmp11_;
00173        UnityMusicPlayer* _tmp12_;
00174        UnityMusicPlayer* _tmp13_;
00175        UnityPlaylist* _tmp14_;
00176        UnityPlaylist* pl;
00177        UnityPlaylist* _tmp15_;
00178        TypicalPlayer* _tmp20_;
00179        UnityMusicPlayer* _tmp21_;
00180        UnityMusicPlayer* _tmp22_;
00181        UnityPlaylist* _tmp23_;
00182        TypicalPlayer* _tmp24_;
00183        UnityMusicPlayer* _tmp25_;
00184        UnityMusicPlayer* _tmp26_;
00185        UnityPlaylist* _tmp27_;
00186        UnityPlaylist* _tmp28_;
00187        UnityPlaylist* pl2;
00188        UnityPlaylist* _tmp29_;
00189        TypicalPlayer* _tmp34_;
00190        UnityMusicPlayer* _tmp35_;
00191        UnityMusicPlayer* _tmp36_;
00192        UnityPlaylist* _tmp37_;
00193        GError * _inner_error_ = NULL;
00194        g_return_val_if_fail (self != NULL, FALSE);
00195        _tmp0_ = unity_track_metadata_new ();
00196        metadata = _tmp0_;
00197        _tmp1_ = metadata;
00198        unity_track_metadata_set_artist (_tmp1_, "Autechre");
00199        _tmp2_ = metadata;
00200        unity_track_metadata_set_album (_tmp2_, "LP5");
00201        _tmp3_ = metadata;
00202        unity_track_metadata_set_title (_tmp3_, "Rae");
00203        _tmp4_ = metadata;
00204        _tmp5_ = g_file_new_for_uri ("file:///home/user/download/ae_lp5.jpg");
00205        _tmp6_ = _tmp5_;
00206        unity_track_metadata_set_art_location (_tmp4_, _tmp6_);
00207        _g_object_unref0 (_tmp6_);
00208        _tmp7_ = self->priv->_player;
00209        _tmp8_ = typical_player_get_menu_player (_tmp7_);
00210        _tmp9_ = _tmp8_;
00211        _tmp10_ = metadata;
00212        unity_music_player_set_current_track (_tmp9_, _tmp10_);
00213        _tmp11_ = self->priv->_player;
00214        _tmp12_ = typical_player_get_menu_player (_tmp11_);
00215        _tmp13_ = _tmp12_;
00216        unity_music_player_set_is_blacklisted (_tmp13_, FALSE);
00217        _tmp14_ = unity_playlist_new ("/fake/pl/id");
00218        pl = _tmp14_;
00219        _tmp15_ = pl;
00220        unity_playlist_set_name (_tmp15_, "yellow swans like");
00221        {
00222               GIcon* _tmp16_ = NULL;
00223               GIcon* _tmp17_;
00224               UnityPlaylist* _tmp18_;
00225               GIcon* _tmp19_;
00226               _tmp16_ = g_icon_new_for_string ("audio-volume-high", &_inner_error_);
00227               _tmp17_ = _tmp16_;
00228               if (_inner_error_ != NULL) {
00229                      goto __catch0_g_error;
00230               }
00231               _tmp18_ = pl;
00232               _tmp19_ = _tmp17_;
00233               unity_playlist_set_icon (_tmp18_, _tmp19_);
00234               _g_object_unref0 (_tmp19_);
00235        }
00236        goto __finally0;
00237        __catch0_g_error:
00238        {
00239               GError* e = NULL;
00240               e = _inner_error_;
00241               _inner_error_ = NULL;
00242               g_warning ("test-mpris-backend-prop-updates-server.vala:39: Unable to load Icon fr" \
00243 "om name provided - unable to complete test");
00244               result = FALSE;
00245               _g_error_free0 (e);
00246               _g_object_unref0 (pl);
00247               _g_object_unref0 (metadata);
00248               return result;
00249        }
00250        __finally0:
00251        if (_inner_error_ != NULL) {
00252               _g_object_unref0 (pl);
00253               _g_object_unref0 (metadata);
00254               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);
00255               g_clear_error (&_inner_error_);
00256               return FALSE;
00257        }
00258        _tmp20_ = self->priv->_player;
00259        _tmp21_ = typical_player_get_menu_player (_tmp20_);
00260        _tmp22_ = _tmp21_;
00261        _tmp23_ = pl;
00262        unity_music_player_set_current_playlist (_tmp22_, _tmp23_);
00263        _tmp24_ = self->priv->_player;
00264        _tmp25_ = typical_player_get_menu_player (_tmp24_);
00265        _tmp26_ = _tmp25_;
00266        _tmp27_ = pl;
00267        unity_music_player_add_playlist (_tmp26_, _tmp27_);
00268        _tmp28_ = unity_playlist_new ("/fake/pl2/id");
00269        pl2 = _tmp28_;
00270        _tmp29_ = pl2;
00271        unity_playlist_set_name (_tmp29_, "another playlist");
00272        {
00273               GIcon* _tmp30_ = NULL;
00274               GIcon* _tmp31_;
00275               UnityPlaylist* _tmp32_;
00276               GIcon* _tmp33_;
00277               _tmp30_ = g_icon_new_for_string ("audio-volume-high", &_inner_error_);
00278               _tmp31_ = _tmp30_;
00279               if (_inner_error_ != NULL) {
00280                      goto __catch1_g_error;
00281               }
00282               _tmp32_ = pl2;
00283               _tmp33_ = _tmp31_;
00284               unity_playlist_set_icon (_tmp32_, _tmp33_);
00285               _g_object_unref0 (_tmp33_);
00286        }
00287        goto __finally1;
00288        __catch1_g_error:
00289        {
00290               GError* e = NULL;
00291               e = _inner_error_;
00292               _inner_error_ = NULL;
00293               g_warning ("test-mpris-backend-prop-updates-server.vala:52: Unable to load Icon fr" \
00294 "om name provided - unable to complete test");
00295               result = FALSE;
00296               _g_error_free0 (e);
00297               _g_object_unref0 (pl2);
00298               _g_object_unref0 (pl);
00299               _g_object_unref0 (metadata);
00300               return result;
00301        }
00302        __finally1:
00303        if (_inner_error_ != NULL) {
00304               _g_object_unref0 (pl2);
00305               _g_object_unref0 (pl);
00306               _g_object_unref0 (metadata);
00307               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);
00308               g_clear_error (&_inner_error_);
00309               return FALSE;
00310        }
00311        _tmp34_ = self->priv->_player;
00312        _tmp35_ = typical_player_get_menu_player (_tmp34_);
00313        _tmp36_ = _tmp35_;
00314        _tmp37_ = pl2;
00315        unity_music_player_add_playlist (_tmp36_, _tmp37_);
00316        g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 10, _mpris_server_escape_gsource_func, g_object_ref (self), g_object_unref);
00317        result = FALSE;
00318        _g_object_unref0 (pl2);
00319        _g_object_unref0 (pl);
00320        _g_object_unref0 (metadata);
00321        return result;
00322 }
00323 
00324 
00325 static gpointer _g_object_ref0 (gpointer self) {
00326        return self ? g_object_ref (self) : NULL;
00327 }
00328 
00329 
00330 gboolean mpris_server_change_playlist_names (MprisServer* self) {
00331        gboolean result = FALSE;
00332        gint i;
00333        TypicalPlayer* _tmp0_;
00334        UnityMusicPlayer* _tmp1_;
00335        UnityMusicPlayer* _tmp2_;
00336        gint _tmp3_ = 0;
00337        UnityPlaylist** _tmp4_ = NULL;
00338        g_return_val_if_fail (self != NULL, FALSE);
00339        i = 0;
00340        _tmp0_ = self->priv->_player;
00341        _tmp1_ = typical_player_get_menu_player (_tmp0_);
00342        _tmp2_ = _tmp1_;
00343        _tmp4_ = unity_music_player_get_playlists (_tmp2_, &_tmp3_);
00344        {
00345               UnityPlaylist** pl_collection = NULL;
00346               gint pl_collection_length1 = 0;
00347               gint _pl_collection_size_ = 0;
00348               gint pl_it = 0;
00349               pl_collection = _tmp4_;
00350               pl_collection_length1 = _tmp3_;
00351               for (pl_it = 0; pl_it < _tmp3_; pl_it = pl_it + 1) {
00352                      UnityPlaylist* _tmp5_;
00353                      UnityPlaylist* pl = NULL;
00354                      _tmp5_ = _g_object_ref0 (pl_collection[pl_it]);
00355                      pl = _tmp5_;
00356                      {
00357                             UnityPlaylist* _tmp6_;
00358                             const gchar* _tmp7_;
00359                             const gchar* _tmp8_;
00360                             UnityPlaylist* _tmp9_;
00361                             gint _tmp10_;
00362                             gchar* _tmp11_ = NULL;
00363                             gchar* _tmp12_;
00364                             gchar* _tmp13_;
00365                             gchar* _tmp14_;
00366                             gint _tmp15_;
00367                             _tmp6_ = pl;
00368                             _tmp7_ = unity_playlist_get_name (_tmp6_);
00369                             _tmp8_ = _tmp7_;
00370                             g_debug ("test-mpris-backend-prop-updates-server.vala:66: old playlist name = %s", _tmp8_);
00371                             _tmp9_ = pl;
00372                             _tmp10_ = i;
00373                             _tmp11_ = g_strdup_printf ("%i", _tmp10_);
00374                             _tmp12_ = _tmp11_;
00375                             _tmp13_ = g_strconcat ("name-changed-", _tmp12_, NULL);
00376                             _tmp14_ = _tmp13_;
00377                             unity_playlist_set_name (_tmp9_, _tmp14_);
00378                             _g_free0 (_tmp14_);
00379                             _g_free0 (_tmp12_);
00380                             _tmp15_ = i;
00381                             i = _tmp15_ + 1;
00382                             _g_object_unref0 (pl);
00383                      }
00384               }
00385               pl_collection = (_vala_array_free (pl_collection, pl_collection_length1, (GDestroyNotify) g_object_unref), NULL);
00386        }
00387        result = FALSE;
00388        return result;
00389 }
00390 
00391 
00392 gint mpris_server_main (gchar** args, int args_length1) {
00393        gint result = 0;
00394        GMainContext* _tmp0_ = NULL;
00395        GMainLoop* _tmp1_;
00396        GMainLoop* mainloop;
00397        TypicalPlayer* player = NULL;
00398        TypicalPlayer* _tmp2_;
00399        GMainLoop* _tmp3_;
00400        TypicalPlayer* _tmp4_;
00401        MprisServer* _tmp5_;
00402        MprisServer* server;
00403        GMainLoop* _tmp11_;
00404        g_setenv ("XDG_DATA_HOME", TESTDIR "/data", TRUE);
00405        _tmp0_ = g_main_context_default ();
00406        _tmp1_ = g_main_loop_new (_tmp0_, FALSE);
00407        mainloop = _tmp1_;
00408        _tmp2_ = typical_player_new ();
00409        _g_object_unref0 (player);
00410        player = _tmp2_;
00411        _tmp3_ = mainloop;
00412        _tmp4_ = player;
00413        _tmp5_ = mpris_server_new (_tmp3_, _tmp4_);
00414        server = _tmp5_;
00415        while (TRUE) {
00416               GMainLoop* _tmp6_;
00417               GMainContext* _tmp7_ = NULL;
00418               gboolean _tmp8_ = FALSE;
00419               GMainLoop* _tmp9_;
00420               GMainContext* _tmp10_ = NULL;
00421               _tmp6_ = mainloop;
00422               _tmp7_ = g_main_loop_get_context (_tmp6_);
00423               _tmp8_ = g_main_context_pending (_tmp7_);
00424               if (!(_tmp8_ == TRUE)) {
00425                      break;
00426               }
00427               _tmp9_ = mainloop;
00428               _tmp10_ = g_main_loop_get_context (_tmp9_);
00429               g_main_context_iteration (_tmp10_, TRUE);
00430        }
00431        _tmp11_ = mainloop;
00432        g_main_loop_run (_tmp11_);
00433        result = 0;
00434        _g_object_unref0 (server);
00435        _g_object_unref0 (player);
00436        _g_main_loop_unref0 (mainloop);
00437        return result;
00438 }
00439 
00440 
00441 int main (int argc, char ** argv) {
00442        g_type_init ();
00443        return mpris_server_main (argv, argc);
00444 }
00445 
00446 
00447 GMainLoop* mpris_server_get_mainloop (MprisServer* self) {
00448        GMainLoop* result;
00449        GMainLoop* _tmp0_;
00450        g_return_val_if_fail (self != NULL, NULL);
00451        _tmp0_ = self->priv->_mainloop;
00452        result = _tmp0_;
00453        return result;
00454 }
00455 
00456 
00457 static gpointer _g_main_loop_ref0 (gpointer self) {
00458        return self ? g_main_loop_ref (self) : NULL;
00459 }
00460 
00461 
00462 static void mpris_server_set_mainloop (MprisServer* self, GMainLoop* value) {
00463        GMainLoop* _tmp0_;
00464        GMainLoop* _tmp1_;
00465        g_return_if_fail (self != NULL);
00466        _tmp0_ = value;
00467        _tmp1_ = _g_main_loop_ref0 (_tmp0_);
00468        _g_main_loop_unref0 (self->priv->_mainloop);
00469        self->priv->_mainloop = _tmp1_;
00470        g_object_notify ((GObject *) self, "mainloop");
00471 }
00472 
00473 
00474 TypicalPlayer* mpris_server_get_player (MprisServer* self) {
00475        TypicalPlayer* result;
00476        TypicalPlayer* _tmp0_;
00477        g_return_val_if_fail (self != NULL, NULL);
00478        _tmp0_ = self->priv->_player;
00479        result = _tmp0_;
00480        return result;
00481 }
00482 
00483 
00484 static void mpris_server_set_player (MprisServer* self, TypicalPlayer* value) {
00485        TypicalPlayer* _tmp0_;
00486        TypicalPlayer* _tmp1_;
00487        g_return_if_fail (self != NULL);
00488        _tmp0_ = value;
00489        _tmp1_ = _g_object_ref0 (_tmp0_);
00490        _g_object_unref0 (self->priv->_player);
00491        self->priv->_player = _tmp1_;
00492        g_object_notify ((GObject *) self, "player");
00493 }
00494 
00495 
00496 static gboolean _mpris_server_set_up_typical_consumer_gsource_func (gpointer self) {
00497        gboolean result;
00498        result = mpris_server_set_up_typical_consumer (self);
00499        return result;
00500 }
00501 
00502 
00503 static GObject * mpris_server_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
00504        GObject * obj;
00505        GObjectClass * parent_class;
00506        MprisServer * self;
00507        parent_class = G_OBJECT_CLASS (mpris_server_parent_class);
00508        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
00509        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MPRIS_SERVER, MprisServer);
00510        g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 2, _mpris_server_set_up_typical_consumer_gsource_func, g_object_ref (self), g_object_unref);
00511        return obj;
00512 }
00513 
00514 
00515 static void mpris_server_class_init (MprisServerClass * klass) {
00516        mpris_server_parent_class = g_type_class_peek_parent (klass);
00517        g_type_class_add_private (klass, sizeof (MprisServerPrivate));
00518        G_OBJECT_CLASS (klass)->get_property = _vala_mpris_server_get_property;
00519        G_OBJECT_CLASS (klass)->set_property = _vala_mpris_server_set_property;
00520        G_OBJECT_CLASS (klass)->constructor = mpris_server_constructor;
00521        G_OBJECT_CLASS (klass)->finalize = mpris_server_finalize;
00522        g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS_SERVER_MAINLOOP, g_param_spec_pointer ("mainloop", "mainloop", "mainloop", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00523        g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS_SERVER_PLAYER, g_param_spec_object ("player", "player", "player", TYPE_TYPICAL_PLAYER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00524 }
00525 
00526 
00527 static void mpris_server_instance_init (MprisServer * self) {
00528        self->priv = MPRIS_SERVER_GET_PRIVATE (self);
00529 }
00530 
00531 
00532 static void mpris_server_finalize (GObject* obj) {
00533        MprisServer * self;
00534        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MPRIS_SERVER, MprisServer);
00535        _g_main_loop_unref0 (self->priv->_mainloop);
00536        _g_object_unref0 (self->priv->_player);
00537        G_OBJECT_CLASS (mpris_server_parent_class)->finalize (obj);
00538 }
00539 
00540 
00541 GType mpris_server_get_type (void) {
00542        static volatile gsize mpris_server_type_id__volatile = 0;
00543        if (g_once_init_enter (&mpris_server_type_id__volatile)) {
00544               static const GTypeInfo g_define_type_info = { sizeof (MprisServerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mpris_server_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MprisServer), 0, (GInstanceInitFunc) mpris_server_instance_init, NULL };
00545               GType mpris_server_type_id;
00546               mpris_server_type_id = g_type_register_static (G_TYPE_OBJECT, "MprisServer", &g_define_type_info, 0);
00547               g_once_init_leave (&mpris_server_type_id__volatile, mpris_server_type_id);
00548        }
00549        return mpris_server_type_id__volatile;
00550 }
00551 
00552 
00553 static void _vala_mpris_server_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
00554        MprisServer * self;
00555        self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MPRIS_SERVER, MprisServer);
00556        switch (property_id) {
00557               case MPRIS_SERVER_MAINLOOP:
00558               g_value_set_pointer (value, mpris_server_get_mainloop (self));
00559               break;
00560               case MPRIS_SERVER_PLAYER:
00561               g_value_set_object (value, mpris_server_get_player (self));
00562               break;
00563               default:
00564               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00565               break;
00566        }
00567 }
00568 
00569 
00570 static void _vala_mpris_server_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
00571        MprisServer * self;
00572        self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MPRIS_SERVER, MprisServer);
00573        switch (property_id) {
00574               case MPRIS_SERVER_MAINLOOP:
00575               mpris_server_set_mainloop (self, g_value_get_pointer (value));
00576               break;
00577               case MPRIS_SERVER_PLAYER:
00578               mpris_server_set_player (self, g_value_get_object (value));
00579               break;
00580               default:
00581               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00582               break;
00583        }
00584 }
00585 
00586 
00587 TypicalPlayer* typical_player_construct (GType object_type) {
00588        TypicalPlayer * self = NULL;
00589        self = (TypicalPlayer*) g_object_new (object_type, NULL);
00590        return self;
00591 }
00592 
00593 
00594 TypicalPlayer* typical_player_new (void) {
00595        return typical_player_construct (TYPE_TYPICAL_PLAYER);
00596 }
00597 
00598 
00599 static void typical_player_on_raise (TypicalPlayer* self) {
00600        g_return_if_fail (self != NULL);
00601 }
00602 
00603 
00604 static void typical_player_on_play_pause (TypicalPlayer* self) {
00605        UnityPlaybackState _tmp0_ = 0;
00606        UnityMusicPlayer* _tmp1_;
00607        UnityPlaybackState _tmp2_;
00608        UnityPlaybackState _tmp3_;
00609        UnityMusicPlayer* _tmp4_;
00610        UnityPlaybackState _tmp5_;
00611        g_return_if_fail (self != NULL);
00612        _tmp1_ = self->priv->_menu_player;
00613        _tmp2_ = unity_music_player_get_playback_state (_tmp1_);
00614        _tmp3_ = _tmp2_;
00615        if (_tmp3_ == UNITY_PLAYBACK_STATE_PLAYING) {
00616               _tmp0_ = UNITY_PLAYBACK_STATE_PAUSED;
00617        } else {
00618               _tmp0_ = UNITY_PLAYBACK_STATE_PLAYING;
00619        }
00620        _tmp4_ = self->priv->_menu_player;
00621        _tmp5_ = _tmp0_;
00622        unity_music_player_set_playback_state (_tmp4_, _tmp5_);
00623 }
00624 
00625 
00626 static void typical_player_on_previous (TypicalPlayer* self) {
00627        g_return_if_fail (self != NULL);
00628 }
00629 
00630 
00631 static void typical_player_on_next (TypicalPlayer* self) {
00632        UnityTrackMetadata* _tmp0_;
00633        UnityTrackMetadata* metadata;
00634        GFile* _tmp1_ = NULL;
00635        GFile* _tmp2_;
00636        UnityMusicPlayer* _tmp3_;
00637        g_return_if_fail (self != NULL);
00638        _tmp0_ = unity_track_metadata_new ();
00639        metadata = _tmp0_;
00640        unity_track_metadata_set_artist (metadata, "Sonnamble");
00641        unity_track_metadata_set_album (metadata, "Seven months in E minor");
00642        unity_track_metadata_set_title (metadata, "Sehnsucht");
00643        _tmp1_ = g_file_new_for_uri ("file:///home/user/download/sonnamble.jpg");
00644        _tmp2_ = _tmp1_;
00645        unity_track_metadata_set_art_location (metadata, _tmp2_);
00646        _g_object_unref0 (_tmp2_);
00647        _tmp3_ = self->priv->_menu_player;
00648        unity_music_player_set_current_track (_tmp3_, metadata);
00649        _g_object_unref0 (metadata);
00650 }
00651 
00652 
00653 static void typical_player_on_activate_playlist (TypicalPlayer* self, const char* playlist_id) {
00654        UnityMusicPlayer* _tmp0_;
00655        gint _tmp1_ = 0;
00656        UnityPlaylist** _tmp2_ = NULL;
00657        g_return_if_fail (self != NULL);
00658        g_return_if_fail (playlist_id != NULL);
00659        _tmp0_ = self->priv->_menu_player;
00660        _tmp2_ = unity_music_player_get_playlists (_tmp0_, &_tmp1_);
00661        {
00662               UnityPlaylist** pl_collection = NULL;
00663               gint pl_collection_length1 = 0;
00664               gint _pl_collection_size_ = 0;
00665               gint pl_it = 0;
00666               pl_collection = _tmp2_;
00667               pl_collection_length1 = _tmp1_;
00668               for (pl_it = 0; pl_it < _tmp1_; pl_it = pl_it + 1) {
00669                      UnityPlaylist* _tmp3_;
00670                      UnityPlaylist* pl = NULL;
00671                      _tmp3_ = _g_object_ref0 (pl_collection[pl_it]);
00672                      pl = _tmp3_;
00673                      {
00674                             UnityPlaylist* _tmp4_;
00675                             const gchar* _tmp5_;
00676                             const gchar* _tmp6_;
00677                             const char* _tmp7_;
00678                             _tmp4_ = pl;
00679                             _tmp5_ = unity_playlist_get_id (_tmp4_);
00680                             _tmp6_ = _tmp5_;
00681                             _tmp7_ = playlist_id;
00682                             if (g_strcmp0 (_tmp6_, (const gchar*) _tmp7_) == 0) {
00683                                    UnityMusicPlayer* _tmp8_;
00684                                    UnityPlaylist* _tmp9_;
00685                                    _tmp8_ = self->priv->_menu_player;
00686                                    _tmp9_ = pl;
00687                                    unity_music_player_set_current_playlist (_tmp8_, _tmp9_);
00688                                    _g_object_unref0 (pl);
00689                                    pl_collection = (_vala_array_free (pl_collection, pl_collection_length1, (GDestroyNotify) g_object_unref), NULL);
00690                                    return;
00691                             }
00692                             _g_object_unref0 (pl);
00693                      }
00694               }
00695               pl_collection = (_vala_array_free (pl_collection, pl_collection_length1, (GDestroyNotify) g_object_unref), NULL);
00696        }
00697 }
00698 
00699 
00700 UnityMusicPlayer* typical_player_get_menu_player (TypicalPlayer* self) {
00701        UnityMusicPlayer* result;
00702        UnityMusicPlayer* _tmp0_;
00703        g_return_val_if_fail (self != NULL, NULL);
00704        _tmp0_ = self->priv->_menu_player;
00705        result = _tmp0_;
00706        return result;
00707 }
00708 
00709 
00710 static void typical_player_set_menu_player (TypicalPlayer* self, UnityMusicPlayer* value) {
00711        UnityMusicPlayer* _tmp0_;
00712        UnityMusicPlayer* _tmp1_;
00713        g_return_if_fail (self != NULL);
00714        _tmp0_ = value;
00715        _tmp1_ = _g_object_ref0 (_tmp0_);
00716        _g_object_unref0 (self->priv->_menu_player);
00717        self->priv->_menu_player = _tmp1_;
00718        g_object_notify ((GObject *) self, "menu-player");
00719 }
00720 
00721 
00722 static void _typical_player_on_raise_unity_music_player_raise (UnityMusicPlayer* _sender, gpointer self) {
00723        typical_player_on_raise (self);
00724 }
00725 
00726 
00727 static void _typical_player_on_play_pause_unity_music_player_play_pause (UnityMusicPlayer* _sender, gpointer self) {
00728        typical_player_on_play_pause (self);
00729 }
00730 
00731 
00732 static void _typical_player_on_previous_unity_music_player_previous (UnityMusicPlayer* _sender, gpointer self) {
00733        typical_player_on_previous (self);
00734 }
00735 
00736 
00737 static void _typical_player_on_next_unity_music_player_next (UnityMusicPlayer* _sender, gpointer self) {
00738        typical_player_on_next (self);
00739 }
00740 
00741 
00742 static void _typical_player_on_activate_playlist_unity_music_player_activate_playlist (UnityMusicPlayer* _sender, const char* playlist_id, gpointer self) {
00743        typical_player_on_activate_playlist (self, playlist_id);
00744 }
00745 
00746 
00747 static GObject * typical_player_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
00748        GObject * obj;
00749        GObjectClass * parent_class;
00750        TypicalPlayer * self;
00751        UnityMusicPlayer* _tmp0_;
00752        UnityMusicPlayer* _tmp1_;
00753        UnityMusicPlayer* _tmp2_;
00754        UnityMusicPlayer* _tmp3_;
00755        UnityMusicPlayer* _tmp4_;
00756        UnityMusicPlayer* _tmp5_;
00757        UnityMusicPlayer* _tmp6_;
00758        parent_class = G_OBJECT_CLASS (typical_player_parent_class);
00759        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
00760        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TYPICAL_PLAYER, TypicalPlayer);
00761        _tmp0_ = unity_music_player_new ("rhythmbox.desktop");
00762        _tmp1_ = _tmp0_;
00763        typical_player_set_menu_player (self, _tmp1_);
00764        _g_object_unref0 (_tmp1_);
00765        _tmp2_ = self->priv->_menu_player;
00766        g_signal_connect_object (_tmp2_, "raise", (GCallback) _typical_player_on_raise_unity_music_player_raise, self, 0);
00767        _tmp3_ = self->priv->_menu_player;
00768        g_signal_connect_object (_tmp3_, "play-pause", (GCallback) _typical_player_on_play_pause_unity_music_player_play_pause, self, 0);
00769        _tmp4_ = self->priv->_menu_player;
00770        g_signal_connect_object (_tmp4_, "previous", (GCallback) _typical_player_on_previous_unity_music_player_previous, self, 0);
00771        _tmp5_ = self->priv->_menu_player;
00772        g_signal_connect_object (_tmp5_, "next", (GCallback) _typical_player_on_next_unity_music_player_next, self, 0);
00773        _tmp6_ = self->priv->_menu_player;
00774        g_signal_connect_object (_tmp6_, "activate-playlist", (GCallback) _typical_player_on_activate_playlist_unity_music_player_activate_playlist, self, 0);
00775        return obj;
00776 }
00777 
00778 
00779 static void typical_player_class_init (TypicalPlayerClass * klass) {
00780        typical_player_parent_class = g_type_class_peek_parent (klass);
00781        g_type_class_add_private (klass, sizeof (TypicalPlayerPrivate));
00782        G_OBJECT_CLASS (klass)->get_property = _vala_typical_player_get_property;
00783        G_OBJECT_CLASS (klass)->set_property = _vala_typical_player_set_property;
00784        G_OBJECT_CLASS (klass)->constructor = typical_player_constructor;
00785        G_OBJECT_CLASS (klass)->finalize = typical_player_finalize;
00786        g_object_class_install_property (G_OBJECT_CLASS (klass), TYPICAL_PLAYER_MENU_PLAYER, g_param_spec_object ("menu-player", "menu-player", "menu-player", UNITY_TYPE_MUSIC_PLAYER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00787 }
00788 
00789 
00790 static void typical_player_instance_init (TypicalPlayer * self) {
00791        self->priv = TYPICAL_PLAYER_GET_PRIVATE (self);
00792 }
00793 
00794 
00795 static void typical_player_finalize (GObject* obj) {
00796        TypicalPlayer * self;
00797        self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TYPICAL_PLAYER, TypicalPlayer);
00798        _g_object_unref0 (self->priv->_menu_player);
00799        G_OBJECT_CLASS (typical_player_parent_class)->finalize (obj);
00800 }
00801 
00802 
00803 GType typical_player_get_type (void) {
00804        static volatile gsize typical_player_type_id__volatile = 0;
00805        if (g_once_init_enter (&typical_player_type_id__volatile)) {
00806               static const GTypeInfo g_define_type_info = { sizeof (TypicalPlayerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) typical_player_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TypicalPlayer), 0, (GInstanceInitFunc) typical_player_instance_init, NULL };
00807               GType typical_player_type_id;
00808               typical_player_type_id = g_type_register_static (G_TYPE_OBJECT, "TypicalPlayer", &g_define_type_info, 0);
00809               g_once_init_leave (&typical_player_type_id__volatile, typical_player_type_id);
00810        }
00811        return typical_player_type_id__volatile;
00812 }
00813 
00814 
00815 static void _vala_typical_player_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
00816        TypicalPlayer * self;
00817        self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TYPICAL_PLAYER, TypicalPlayer);
00818        switch (property_id) {
00819               case TYPICAL_PLAYER_MENU_PLAYER:
00820               g_value_set_object (value, typical_player_get_menu_player (self));
00821               break;
00822               default:
00823               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00824               break;
00825        }
00826 }
00827 
00828 
00829 static void _vala_typical_player_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
00830        TypicalPlayer * self;
00831        self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TYPICAL_PLAYER, TypicalPlayer);
00832        switch (property_id) {
00833               case TYPICAL_PLAYER_MENU_PLAYER:
00834               typical_player_set_menu_player (self, g_value_get_object (value));
00835               break;
00836               default:
00837               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00838               break;
00839        }
00840 }
00841 
00842 
00843 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
00844        if ((array != NULL) && (destroy_func != NULL)) {
00845               int i;
00846               for (i = 0; i < array_length; i = i + 1) {
00847                      if (((gpointer*) array)[i] != NULL) {
00848                             destroy_func (((gpointer*) array)[i]);
00849                      }
00850               }
00851        }
00852 }
00853 
00854 
00855 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
00856        _vala_array_destroy (array, array_length, destroy_func);
00857        g_free (array);
00858 }
00859 
00860 
00861