Back to index

unity-lens-music  6.0.0
musicstore-filter-parser-genre.c
Go to the documentation of this file.
00001 /* musicstore-filter-parser-genre.c generated by valac 0.14.2, the Vala compiler
00002  * generated from musicstore-filter-parser-genre.vala, do not modify */
00003 
00004 /*
00005  * Copyright (C) 2011 Canonical Ltd
00006  *
00007  * This program is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License version 3 as
00009  * published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018  *
00019  * Authored by Alex Launi <alex.launi@canonical.com>
00020  *
00021  */
00022 
00023 #include <glib.h>
00024 #include <glib-object.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #include <unity.h>
00028 #include <gee.h>
00029 
00030 
00031 #define UNITY_MUSIC_LENS_TYPE_FILTER_PARSER (unity_music_lens_filter_parser_get_type ())
00032 #define UNITY_MUSIC_LENS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParser))
00033 #define UNITY_MUSIC_LENS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
00034 #define UNITY_MUSIC_LENS_IS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
00035 #define UNITY_MUSIC_LENS_IS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
00036 #define UNITY_MUSIC_LENS_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
00037 
00038 typedef struct _UnityMusicLensFilterParser UnityMusicLensFilterParser;
00039 typedef struct _UnityMusicLensFilterParserClass UnityMusicLensFilterParserClass;
00040 typedef struct _UnityMusicLensFilterParserPrivate UnityMusicLensFilterParserPrivate;
00041 
00042 #define UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER (unity_music_lens_genre_filter_parser_get_type ())
00043 #define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParser))
00044 #define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParserClass))
00045 #define UNITY_MUSIC_LENS_IS_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER))
00046 #define UNITY_MUSIC_LENS_IS_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER))
00047 #define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParserClass))
00048 
00049 typedef struct _UnityMusicLensGenreFilterParser UnityMusicLensGenreFilterParser;
00050 typedef struct _UnityMusicLensGenreFilterParserClass UnityMusicLensGenreFilterParserClass;
00051 typedef struct _UnityMusicLensGenreFilterParserPrivate UnityMusicLensGenreFilterParserPrivate;
00052 
00053 #define UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER (unity_music_lens_music_store_filter_parser_get_type ())
00054 #define UNITY_MUSIC_LENS_MUSIC_STORE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, UnityMusicLensMusicStoreFilterParser))
00055 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER))
00056 #define UNITY_MUSIC_LENS_MUSIC_STORE_FILTER_PARSER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, UnityMusicLensMusicStoreFilterParserIface))
00057 
00058 typedef struct _UnityMusicLensMusicStoreFilterParser UnityMusicLensMusicStoreFilterParser;
00059 typedef struct _UnityMusicLensMusicStoreFilterParserIface UnityMusicLensMusicStoreFilterParserIface;
00060 
00061 #define UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER (unity_music_lens_music_store_genre_filter_parser_get_type ())
00062 #define UNITY_MUSIC_LENS_MUSIC_STORE_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER, UnityMusicLensMusicStoreGenreFilterParser))
00063 #define UNITY_MUSIC_LENS_MUSIC_STORE_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER, UnityMusicLensMusicStoreGenreFilterParserClass))
00064 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER))
00065 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER))
00066 #define UNITY_MUSIC_LENS_MUSIC_STORE_GENRE_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER, UnityMusicLensMusicStoreGenreFilterParserClass))
00067 
00068 typedef struct _UnityMusicLensMusicStoreGenreFilterParser UnityMusicLensMusicStoreGenreFilterParser;
00069 typedef struct _UnityMusicLensMusicStoreGenreFilterParserClass UnityMusicLensMusicStoreGenreFilterParserClass;
00070 typedef struct _UnityMusicLensMusicStoreGenreFilterParserPrivate UnityMusicLensMusicStoreGenreFilterParserPrivate;
00071 #define _g_free0(var) (var = (g_free (var), NULL))
00072 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00073 
00074 #define UNITY_MUSIC_LENS_TYPE_GENRE (unity_music_lens_genre_get_type ())
00075 #define UNITY_MUSIC_LENS_GENRE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenre))
00076 #define UNITY_MUSIC_LENS_GENRE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenreClass))
00077 #define UNITY_MUSIC_LENS_IS_GENRE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_GENRE))
00078 #define UNITY_MUSIC_LENS_IS_GENRE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_GENRE))
00079 #define UNITY_MUSIC_LENS_GENRE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenreClass))
00080 
00081 typedef struct _UnityMusicLensGenre UnityMusicLensGenre;
00082 typedef struct _UnityMusicLensGenreClass UnityMusicLensGenreClass;
00083 #define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
00084 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
00085 
00086 struct _UnityMusicLensFilterParser {
00087        GObject parent_instance;
00088        UnityMusicLensFilterParserPrivate * priv;
00089 };
00090 
00091 struct _UnityMusicLensFilterParserClass {
00092        GObjectClass parent_class;
00093        gchar* (*parse) (UnityMusicLensFilterParser* self);
00094        const gchar* (*get_id) (UnityMusicLensFilterParser* self);
00095 };
00096 
00097 struct _UnityMusicLensGenreFilterParser {
00098        UnityMusicLensFilterParser parent_instance;
00099        UnityMusicLensGenreFilterParserPrivate * priv;
00100 };
00101 
00102 struct _UnityMusicLensGenreFilterParserClass {
00103        UnityMusicLensFilterParserClass parent_class;
00104 };
00105 
00106 struct _UnityMusicLensMusicStoreFilterParserIface {
00107        GTypeInterface parent_iface;
00108 };
00109 
00110 struct _UnityMusicLensMusicStoreGenreFilterParser {
00111        UnityMusicLensGenreFilterParser parent_instance;
00112        UnityMusicLensMusicStoreGenreFilterParserPrivate * priv;
00113 };
00114 
00115 struct _UnityMusicLensMusicStoreGenreFilterParserClass {
00116        UnityMusicLensGenreFilterParserClass parent_class;
00117 };
00118 
00119 
00120 static gpointer unity_music_lens_music_store_genre_filter_parser_parent_class = NULL;
00121 static UnityMusicLensMusicStoreFilterParserIface* unity_music_lens_music_store_genre_filter_parser_unity_music_lens_music_store_filter_parser_parent_iface = NULL;
00122 
00123 GType unity_music_lens_filter_parser_get_type (void) G_GNUC_CONST;
00124 GType unity_music_lens_genre_filter_parser_get_type (void) G_GNUC_CONST;
00125 GType unity_music_lens_music_store_filter_parser_get_type (void) G_GNUC_CONST;
00126 GType unity_music_lens_music_store_genre_filter_parser_get_type (void) G_GNUC_CONST;
00127 enum  {
00128        UNITY_MUSIC_LENS_MUSIC_STORE_GENRE_FILTER_PARSER_DUMMY_PROPERTY
00129 };
00130 UnityMusicLensMusicStoreGenreFilterParser* unity_music_lens_music_store_genre_filter_parser_new (UnityMusicLensGenreFilterParser* parser);
00131 UnityMusicLensMusicStoreGenreFilterParser* unity_music_lens_music_store_genre_filter_parser_construct (GType object_type, UnityMusicLensGenreFilterParser* parser);
00132 UnityFilter* unity_music_lens_filter_parser_get_filter (UnityMusicLensFilterParser* self);
00133 UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_new (UnityCheckOptionFilterCompact* filter);
00134 UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_construct (GType object_type, UnityCheckOptionFilterCompact* filter);
00135 static gchar* unity_music_lens_music_store_genre_filter_parser_real_parse (UnityMusicLensFilterParser* base);
00136 GList* unity_music_lens_genre_filter_parser_get_all_selected_genres (UnityMusicLensGenreFilterParser* self);
00137 GType unity_music_lens_genre_get_type (void) G_GNUC_CONST;
00138 UnityMusicLensGenre* unity_music_lens_genre_filter_parser_get_map (UnityMusicLensGenreFilterParser* self);
00139 GeeCollection* unity_music_lens_genre_get_genre_synonyms (UnityMusicLensGenre* self, const gchar* genre_id);
00140 static void _g_object_unref0_ (gpointer var);
00141 static void _g_list_free__g_object_unref0_ (GList* self);
00142 
00143 
00144 UnityMusicLensMusicStoreGenreFilterParser* unity_music_lens_music_store_genre_filter_parser_construct (GType object_type, UnityMusicLensGenreFilterParser* parser) {
00145        UnityMusicLensMusicStoreGenreFilterParser * self = NULL;
00146        UnityMusicLensGenreFilterParser* _tmp0_;
00147        UnityFilter* _tmp1_;
00148        UnityFilter* _tmp2_;
00149        g_return_val_if_fail (parser != NULL, NULL);
00150        _tmp0_ = parser;
00151        _tmp1_ = unity_music_lens_filter_parser_get_filter ((UnityMusicLensFilterParser*) _tmp0_);
00152        _tmp2_ = _tmp1_;
00153        self = (UnityMusicLensMusicStoreGenreFilterParser*) unity_music_lens_genre_filter_parser_construct (object_type, UNITY_IS_CHECK_OPTION_FILTER_COMPACT (_tmp2_) ? ((UnityCheckOptionFilterCompact*) _tmp2_) : NULL);
00154        return self;
00155 }
00156 
00157 
00158 UnityMusicLensMusicStoreGenreFilterParser* unity_music_lens_music_store_genre_filter_parser_new (UnityMusicLensGenreFilterParser* parser) {
00159        return unity_music_lens_music_store_genre_filter_parser_construct (UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_GENRE_FILTER_PARSER, parser);
00160 }
00161 
00162 
00163 static gpointer _g_object_ref0 (gpointer self) {
00164        return self ? g_object_ref (self) : NULL;
00165 }
00166 
00167 
00168 static void _g_object_unref0_ (gpointer var) {
00169        (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
00170 }
00171 
00172 
00173 static void _g_list_free__g_object_unref0_ (GList* self) {
00174        g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
00175        g_list_free (self);
00176 }
00177 
00178 
00179 static gchar* unity_music_lens_music_store_genre_filter_parser_real_parse (UnityMusicLensFilterParser* base) {
00180        UnityMusicLensMusicStoreGenreFilterParser * self;
00181        gchar* result = NULL;
00182        GString* _tmp0_;
00183        GString* builder;
00184        GList* _tmp1_ = NULL;
00185        GString* _tmp23_;
00186        GString* _tmp24_;
00187        gssize _tmp25_;
00188        GString* _tmp26_;
00189        const gchar* _tmp27_;
00190        gchar* _tmp28_;
00191        self = (UnityMusicLensMusicStoreGenreFilterParser*) base;
00192        _tmp0_ = g_string_new ("&genres=");
00193        builder = _tmp0_;
00194        _tmp1_ = unity_music_lens_genre_filter_parser_get_all_selected_genres ((UnityMusicLensGenreFilterParser*) self);
00195        {
00196               GList* genre_collection = NULL;
00197               GList* genre_it = NULL;
00198               genre_collection = _tmp1_;
00199               for (genre_it = genre_collection; genre_it != NULL; genre_it = genre_it->next) {
00200                      UnityFilterOption* _tmp2_;
00201                      UnityFilterOption* genre = NULL;
00202                      _tmp2_ = _g_object_ref0 ((UnityFilterOption*) genre_it->data);
00203                      genre = _tmp2_;
00204                      {
00205                             UnityFilterOption* _tmp3_;
00206                             const gchar* _tmp4_;
00207                             const gchar* _tmp5_;
00208                             gchar* _tmp6_;
00209                             gchar* id;
00210                             UnityFilterOption* _tmp7_;
00211                             const gchar* _tmp8_;
00212                             const gchar* _tmp9_;
00213                             _tmp3_ = genre;
00214                             _tmp4_ = unity_filter_option_get_id (_tmp3_);
00215                             _tmp5_ = _tmp4_;
00216                             _tmp6_ = g_strdup (_tmp5_);
00217                             id = _tmp6_;
00218                             _tmp7_ = genre;
00219                             _tmp8_ = unity_filter_option_get_id (_tmp7_);
00220                             _tmp9_ = _tmp8_;
00221                             if (_tmp9_ == NULL) {
00222                                    _g_free0 (id);
00223                                    _g_object_unref0 (genre);
00224                                    continue;
00225                             }
00226                             {
00227                                    UnityMusicLensGenre* _tmp10_;
00228                                    UnityMusicLensGenre* _tmp11_;
00229                                    const gchar* _tmp12_;
00230                                    GeeCollection* _tmp13_ = NULL;
00231                                    GeeCollection* _tmp14_;
00232                                    GeeIterator* _tmp15_ = NULL;
00233                                    GeeIterator* _tmp16_;
00234                                    GeeIterator* _alt_it;
00235                                    _tmp10_ = unity_music_lens_genre_filter_parser_get_map ((UnityMusicLensGenreFilterParser*) self);
00236                                    _tmp11_ = _tmp10_;
00237                                    _tmp12_ = id;
00238                                    _tmp13_ = unity_music_lens_genre_get_genre_synonyms (_tmp11_, _tmp12_);
00239                                    _tmp14_ = _tmp13_;
00240                                    _tmp15_ = gee_iterable_iterator ((GeeIterable*) _tmp14_);
00241                                    _tmp16_ = _tmp15_;
00242                                    _g_object_unref0 (_tmp14_);
00243                                    _alt_it = _tmp16_;
00244                                    while (TRUE) {
00245                                           GeeIterator* _tmp17_;
00246                                           gboolean _tmp18_ = FALSE;
00247                                           GeeIterator* _tmp19_;
00248                                           gpointer _tmp20_ = NULL;
00249                                           gchar* alt;
00250                                           GString* _tmp21_;
00251                                           const gchar* _tmp22_;
00252                                           _tmp17_ = _alt_it;
00253                                           _tmp18_ = gee_iterator_next (_tmp17_);
00254                                           if (!_tmp18_) {
00255                                                  break;
00256                                           }
00257                                           _tmp19_ = _alt_it;
00258                                           _tmp20_ = gee_iterator_get (_tmp19_);
00259                                           alt = (gchar*) _tmp20_;
00260                                           _tmp21_ = builder;
00261                                           _tmp22_ = alt;
00262                                           g_string_append_printf (_tmp21_, "%s,", _tmp22_);
00263                                           _g_free0 (alt);
00264                                    }
00265                                    _g_object_unref0 (_alt_it);
00266                             }
00267                             _g_free0 (id);
00268                             _g_object_unref0 (genre);
00269                      }
00270               }
00271               __g_list_free__g_object_unref0_0 (genre_collection);
00272        }
00273        _tmp23_ = builder;
00274        _tmp24_ = builder;
00275        _tmp25_ = _tmp24_->len;
00276        g_string_truncate (_tmp23_, (gsize) (_tmp25_ - 1));
00277        _tmp26_ = builder;
00278        _tmp27_ = _tmp26_->str;
00279        _tmp28_ = g_strdup (_tmp27_);
00280        result = _tmp28_;
00281        _g_string_free0 (builder);
00282        return result;
00283 }
00284 
00285 
00286 static void unity_music_lens_music_store_genre_filter_parser_class_init (UnityMusicLensMusicStoreGenreFilterParserClass * klass) {
00287        unity_music_lens_music_store_genre_filter_parser_parent_class = g_type_class_peek_parent (klass);
00288        UNITY_MUSIC_LENS_FILTER_PARSER_CLASS (klass)->parse = unity_music_lens_music_store_genre_filter_parser_real_parse;
00289 }
00290 
00291 
00292 static void unity_music_lens_music_store_genre_filter_parser_unity_music_lens_music_store_filter_parser_interface_init (UnityMusicLensMusicStoreFilterParserIface * iface) {
00293        unity_music_lens_music_store_genre_filter_parser_unity_music_lens_music_store_filter_parser_parent_iface = g_type_interface_peek_parent (iface);
00294 }
00295 
00296 
00297 static void unity_music_lens_music_store_genre_filter_parser_instance_init (UnityMusicLensMusicStoreGenreFilterParser * self) {
00298 }
00299 
00300 
00301 GType unity_music_lens_music_store_genre_filter_parser_get_type (void) {
00302        static volatile gsize unity_music_lens_music_store_genre_filter_parser_type_id__volatile = 0;
00303        if (g_once_init_enter (&unity_music_lens_music_store_genre_filter_parser_type_id__volatile)) {
00304               static const GTypeInfo g_define_type_info = { sizeof (UnityMusicLensMusicStoreGenreFilterParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_music_lens_music_store_genre_filter_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMusicLensMusicStoreGenreFilterParser), 0, (GInstanceInitFunc) unity_music_lens_music_store_genre_filter_parser_instance_init, NULL };
00305               static const GInterfaceInfo unity_music_lens_music_store_filter_parser_info = { (GInterfaceInitFunc) unity_music_lens_music_store_genre_filter_parser_unity_music_lens_music_store_filter_parser_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
00306               GType unity_music_lens_music_store_genre_filter_parser_type_id;
00307               unity_music_lens_music_store_genre_filter_parser_type_id = g_type_register_static (UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, "UnityMusicLensMusicStoreGenreFilterParser", &g_define_type_info, 0);
00308               g_type_add_interface_static (unity_music_lens_music_store_genre_filter_parser_type_id, UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, &unity_music_lens_music_store_filter_parser_info);
00309               g_once_init_leave (&unity_music_lens_music_store_genre_filter_parser_type_id__volatile, unity_music_lens_music_store_genre_filter_parser_type_id);
00310        }
00311        return unity_music_lens_music_store_genre_filter_parser_type_id__volatile;
00312 }
00313 
00314 
00315