~ubuntu-branches/ubuntu/trusty/unity-china-music-scope/trusty

« back to all changes in this revision

Viewing changes to src/musicbaidu-daemon.c

  • Committer: Package Import Robot
  • Author(s): whzhang-kylin
  • Date: 2012-12-13 09:29:34 UTC
  • Revision ID: package-import@ubuntu.com-20121213092934-0z4qywr7i1fp6nsy
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* musicbaidu-daemon.c generated by valac 0.18.1, the Vala compiler
 
2
 * generated from musicbaidu-daemon.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2013 Kylin Ltd
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License version 3 as
 
9
 * published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 * Authored by Weihua Zhang <fly2high@126.com>
 
20
 * Authored by liuxing <liuxingcs@yeah.net>
 
21
 * Modified Information: 
 
22
 * Rewrite perform_search to search China music from music.baidu.com
 
23
 */
 
24
/*
 
25
 * Copyright (C) 2011 Canonical Ltd
 
26
 *
 
27
 * This program is free software: you can redistribute it and/or modify
 
28
 * it under the terms of the GNU General Public License version 3 as
 
29
 * published by the Free Software Foundation.
 
30
 *
 
31
 * This program is distributed in the hope that it will be useful,
 
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
34
 * GNU General Public License for more details.
 
35
 *
 
36
 * You should have received a copy of the GNU General Public License
 
37
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
38
 *
 
39
 * Authored by Alex Launi <alex.launi@canonical.com>
 
40
 *
 
41
 */
 
42
 
 
43
#include <glib.h>
 
44
#include <glib-object.h>
 
45
#include <gio/gio.h>
 
46
#include <unity.h>
 
47
#include <stdlib.h>
 
48
#include <string.h>
 
49
#include <stdio.h>
 
50
#include <glib/gi18n-lib.h>
 
51
#include <dee.h>
 
52
#include <locale.h>
 
53
 
 
54
 
 
55
#define UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE (unity_music_lens_simple_scope_get_type ())
 
56
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScope))
 
57
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScopeClass))
 
58
#define UNITY_MUSIC_LENS_IS_SIMPLE_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE))
 
59
#define UNITY_MUSIC_LENS_IS_SIMPLE_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE))
 
60
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScopeClass))
 
61
 
 
62
typedef struct _UnityMusicLensSimpleScope UnityMusicLensSimpleScope;
 
63
typedef struct _UnityMusicLensSimpleScopeClass UnityMusicLensSimpleScopeClass;
 
64
 
 
65
#define UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY (unity_music_lens_music_baidu_scope_proxy_get_type ())
 
66
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxy))
 
67
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxyClass))
 
68
#define UNITY_MUSIC_LENS_IS_MUSIC_BAIDU_SCOPE_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY))
 
69
#define UNITY_MUSIC_LENS_IS_MUSIC_BAIDU_SCOPE_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY))
 
70
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxyClass))
 
71
 
 
72
typedef struct _UnityMusicLensMusicBaiduScopeProxy UnityMusicLensMusicBaiduScopeProxy;
 
73
typedef struct _UnityMusicLensMusicBaiduScopeProxyClass UnityMusicLensMusicBaiduScopeProxyClass;
 
74
typedef struct _UnityMusicLensSimpleScopePrivate UnityMusicLensSimpleScopePrivate;
 
75
 
 
76
#define UNITY_MUSIC_LENS_TYPE_FILTER_PARSER (unity_music_lens_filter_parser_get_type ())
 
77
#define UNITY_MUSIC_LENS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParser))
 
78
#define UNITY_MUSIC_LENS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
79
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
80
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
81
#define UNITY_MUSIC_LENS_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
82
 
 
83
typedef struct _UnityMusicLensFilterParser UnityMusicLensFilterParser;
 
84
typedef struct _UnityMusicLensFilterParserClass UnityMusicLensFilterParserClass;
 
85
typedef struct _UnityMusicLensMusicBaiduScopeProxyPrivate UnityMusicLensMusicBaiduScopeProxyPrivate;
 
86
 
 
87
#define UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION (unity_music_lens_music_baidu_collection_get_type ())
 
88
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION, UnityMusicLensMusicBaiduCollection))
 
89
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION, UnityMusicLensMusicBaiduCollectionClass))
 
90
#define UNITY_MUSIC_LENS_IS_MUSIC_BAIDU_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION))
 
91
#define UNITY_MUSIC_LENS_IS_MUSIC_BAIDU_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION))
 
92
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_COLLECTION, UnityMusicLensMusicBaiduCollectionClass))
 
93
 
 
94
typedef struct _UnityMusicLensMusicBaiduCollection UnityMusicLensMusicBaiduCollection;
 
95
typedef struct _UnityMusicLensMusicBaiduCollectionClass UnityMusicLensMusicBaiduCollectionClass;
 
96
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
97
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
98
#define _g_free0(var) (var = (g_free (var), NULL))
 
99
 
 
100
#define UNITY_MUSIC_LENS_TYPE_ALBUM (unity_music_lens_album_get_type ())
 
101
#define UNITY_MUSIC_LENS_ALBUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_ALBUM, UnityMusicLensAlbum))
 
102
#define UNITY_MUSIC_LENS_ALBUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_ALBUM, UnityMusicLensAlbumClass))
 
103
#define UNITY_MUSIC_LENS_IS_ALBUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_ALBUM))
 
104
#define UNITY_MUSIC_LENS_IS_ALBUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_ALBUM))
 
105
#define UNITY_MUSIC_LENS_ALBUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_ALBUM, UnityMusicLensAlbumClass))
 
106
 
 
107
typedef struct _UnityMusicLensAlbum UnityMusicLensAlbum;
 
108
typedef struct _UnityMusicLensAlbumClass UnityMusicLensAlbumClass;
 
109
 
 
110
#define UNITY_MUSIC_LENS_TYPE_TRACK (unity_music_lens_track_get_type ())
 
111
#define UNITY_MUSIC_LENS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrack))
 
112
#define UNITY_MUSIC_LENS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrackClass))
 
113
#define UNITY_MUSIC_LENS_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_TRACK))
 
114
#define UNITY_MUSIC_LENS_IS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_TRACK))
 
115
#define UNITY_MUSIC_LENS_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrackClass))
 
116
 
 
117
typedef struct _UnityMusicLensTrack UnityMusicLensTrack;
 
118
typedef struct _UnityMusicLensTrackClass UnityMusicLensTrackClass;
 
119
#define __g_slist_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_object_unref0_ (var), NULL)))
 
120
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
 
121
typedef struct _UnityMusicLensMusicBaiduScopeProxyPerformSearchData UnityMusicLensMusicBaiduScopeProxyPerformSearchData;
 
122
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
 
123
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
 
124
 
 
125
struct _UnityMusicLensSimpleScope {
 
126
        GObject parent_instance;
 
127
        UnityMusicLensSimpleScopePrivate * priv;
 
128
};
 
129
 
 
130
struct _UnityMusicLensSimpleScopeClass {
 
131
        GObjectClass parent_class;
 
132
        void (*perform_search) (UnityMusicLensSimpleScope* self, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
133
        void (*perform_search_finish) (UnityMusicLensSimpleScope* self, GAsyncResult* _res_);
 
134
        gint (*get_num_results_without_search) (UnityMusicLensSimpleScope* self);
 
135
        gint (*get_num_results_global_search) (UnityMusicLensSimpleScope* self);
 
136
        gint (*get_num_results_lens_search) (UnityMusicLensSimpleScope* self);
 
137
};
 
138
 
 
139
struct _UnityMusicLensMusicBaiduScopeProxy {
 
140
        UnityMusicLensSimpleScope parent_instance;
 
141
        UnityMusicLensMusicBaiduScopeProxyPrivate * priv;
 
142
};
 
143
 
 
144
struct _UnityMusicLensMusicBaiduScopeProxyClass {
 
145
        UnityMusicLensSimpleScopeClass parent_class;
 
146
};
 
147
 
 
148
struct _UnityMusicLensMusicBaiduScopeProxyPrivate {
 
149
        UnityMusicLensMusicBaiduCollection* collection;
 
150
        UnityMusicPreview* music_preview;
 
151
};
 
152
 
 
153
struct _UnityMusicLensMusicBaiduScopeProxyPerformSearchData {
 
154
        int _state_;
 
155
        GObject* _source_object_;
 
156
        GAsyncResult* _res_;
 
157
        GSimpleAsyncResult* _async_result;
 
158
        UnityMusicLensMusicBaiduScopeProxy* self;
 
159
        UnityLensSearch* search;
 
160
        UnitySearchType search_type;
 
161
        GList* filters;
 
162
        gint max_results;
 
163
        GCancellable* cancellable;
 
164
        UnityLensSearch* _tmp0_;
 
165
        gboolean _tmp1_;
 
166
        UnityLensSearch* _tmp2_;
 
167
        DeeSerializableModel* _tmp3_;
 
168
        DeeSerializableModel* _tmp4_;
 
169
        guint _tmp5_;
 
170
        UnityMusicLensMusicBaiduCollection* _tmp6_;
 
171
        UnityLensSearch* _tmp7_;
 
172
        UnitySearchType _tmp8_;
 
173
        GList* _tmp9_;
 
174
        gint _tmp10_;
 
175
        GCancellable* _tmp11_;
 
176
        UnityLensSearch* _tmp12_;
 
177
        DeeSerializableModel* _tmp13_;
 
178
        DeeSerializableModel* _tmp14_;
 
179
        guint _tmp15_;
 
180
        GError* e;
 
181
        UnityLensSearch* _tmp16_;
 
182
        const gchar* _tmp17_;
 
183
        const gchar* _tmp18_;
 
184
        GError* _tmp19_;
 
185
        const gchar* _tmp20_;
 
186
        GError * _inner_error_;
 
187
};
 
188
 
 
189
 
 
190
extern GApplication* unity_music_lens_app;
 
191
GApplication* unity_music_lens_app = NULL;
 
192
extern UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_daemon;
 
193
UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_daemon = NULL;
 
194
static gpointer unity_music_lens_music_baidu_scope_proxy_parent_class = NULL;
 
195
 
 
196
GType unity_music_lens_simple_scope_get_type (void) G_GNUC_CONST;
 
197
GType unity_music_lens_music_baidu_scope_proxy_get_type (void) G_GNUC_CONST;
 
198
GType unity_music_lens_filter_parser_get_type (void) G_GNUC_CONST;
 
199
GType unity_music_lens_music_baidu_collection_get_type (void) G_GNUC_CONST;
 
200
#define UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxyPrivate))
 
201
enum  {
 
202
        UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_DUMMY_PROPERTY,
 
203
        UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_WITHOUT_SEARCH,
 
204
        UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_GLOBAL_SEARCH,
 
205
        UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_LENS_SEARCH
 
206
};
 
207
UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_music_baidu_scope_proxy_new (void);
 
208
UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_music_baidu_scope_proxy_construct (GType object_type);
 
209
UnityMusicLensSimpleScope* unity_music_lens_simple_scope_construct (GType object_type);
 
210
void unity_music_lens_simple_scope_set_scope (UnityMusicLensSimpleScope* self, UnityScope* value);
 
211
UnityScope* unity_music_lens_simple_scope_get_scope (UnityMusicLensSimpleScope* self);
 
212
UnityActivationResponse* unity_music_lens_music_baidu_scope_proxy_activate (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri);
 
213
static UnityActivationResponse* _unity_music_lens_music_baidu_scope_proxy_activate_unity_scope_activate_uri (UnityScope* _sender, const gchar* uri, gpointer self);
 
214
UnityPreview* unity_music_lens_music_baidu_scope_proxy_preview (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri);
 
215
static UnityPreview* _unity_music_lens_music_baidu_scope_proxy_preview_unity_scope_preview_uri (UnityScope* _sender, const gchar* uri, gpointer self);
 
216
void unity_music_lens_simple_scope_initialize (UnityMusicLensSimpleScope* self);
 
217
UnityMusicLensMusicBaiduCollection* unity_music_lens_music_baidu_collection_new (void);
 
218
UnityMusicLensMusicBaiduCollection* unity_music_lens_music_baidu_collection_construct (GType object_type);
 
219
UnityActivationResponse* unity_music_lens_music_baidu_scope_proxy_download_album (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri);
 
220
GType unity_music_lens_album_get_type (void) G_GNUC_CONST;
 
221
GType unity_music_lens_track_get_type (void) G_GNUC_CONST;
 
222
void unity_music_lens_music_baidu_collection_get_album_details (UnityMusicLensMusicBaiduCollection* self, const gchar* uri, UnityMusicLensAlbum** album, GSList** tracks, GCancellable* cancellable);
 
223
static void _g_object_unref0_ (gpointer var);
 
224
static void _g_slist_free__g_object_unref0_ (GSList* self);
 
225
void unity_music_lens_music_baidu_collection_get_song_details (UnityMusicLensMusicBaiduCollection* self, const gchar* uri, UnityMusicLensAlbum** album, GSList** tracks, GCancellable* cancellable);
 
226
const gchar* unity_music_lens_album_get_artwork_path (UnityMusicLensAlbum* self);
 
227
const gchar* unity_music_lens_album_get_title (UnityMusicLensAlbum* self);
 
228
const gchar* unity_music_lens_album_get_artist (UnityMusicLensAlbum* self);
 
229
const gchar* unity_music_lens_track_get_uri (UnityMusicLensTrack* self);
 
230
const gchar* unity_music_lens_track_get_title (UnityMusicLensTrack* self);
 
231
gint unity_music_lens_track_get_duration (UnityMusicLensTrack* self);
 
232
#define CONFIG_DATADIR "/usr/local/share"
 
233
static UnityActivationResponse* _unity_music_lens_music_baidu_scope_proxy_download_album_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self);
 
234
static void _g_list_free__g_object_unref0_ (GList* self);
 
235
static void unity_music_lens_music_baidu_scope_proxy_real_perform_search_data_free (gpointer _data);
 
236
static void unity_music_lens_music_baidu_scope_proxy_real_perform_search (UnityMusicLensSimpleScope* base, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
237
static gboolean unity_music_lens_music_baidu_scope_proxy_real_perform_search_co (UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_);
 
238
gboolean unity_music_lens_simple_scope_is_search_empty (UnityMusicLensSimpleScope* self, UnityLensSearch* search);
 
239
void unity_music_lens_music_baidu_collection_search (UnityMusicLensMusicBaiduCollection* self, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
240
void unity_music_lens_music_baidu_collection_search_finish (UnityMusicLensMusicBaiduCollection* self, GAsyncResult* _res_, GError** error);
 
241
static void unity_music_lens_music_baidu_scope_proxy_perform_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
 
242
static void unity_music_lens_music_baidu_scope_proxy_finalize (GObject* obj);
 
243
gint unity_music_lens_simple_scope_get_num_results_without_search (UnityMusicLensSimpleScope* self);
 
244
gint unity_music_lens_simple_scope_get_num_results_global_search (UnityMusicLensSimpleScope* self);
 
245
gint unity_music_lens_simple_scope_get_num_results_lens_search (UnityMusicLensSimpleScope* self);
 
246
static void _vala_unity_music_lens_music_baidu_scope_proxy_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
 
247
gboolean unity_music_lens_dbus_name_has_owner (const gchar* name);
 
248
gint unity_music_lens_main (gchar** args, int args_length1);
 
249
#define CONFIG_PACKAGE "unity-china-music-scope"
 
250
#define CONFIG_LOCALEDIR "/usr/local/share/locale"
 
251
 
 
252
 
 
253
static UnityActivationResponse* _unity_music_lens_music_baidu_scope_proxy_activate_unity_scope_activate_uri (UnityScope* _sender, const gchar* uri, gpointer self) {
 
254
        UnityActivationResponse* result;
 
255
        result = unity_music_lens_music_baidu_scope_proxy_activate (self, uri);
 
256
        return result;
 
257
}
 
258
 
 
259
 
 
260
static UnityPreview* _unity_music_lens_music_baidu_scope_proxy_preview_unity_scope_preview_uri (UnityScope* _sender, const gchar* uri, gpointer self) {
 
261
        UnityPreview* result;
 
262
        result = unity_music_lens_music_baidu_scope_proxy_preview (self, uri);
 
263
        return result;
 
264
}
 
265
 
 
266
 
 
267
UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_music_baidu_scope_proxy_construct (GType object_type) {
 
268
        UnityMusicLensMusicBaiduScopeProxy * self = NULL;
 
269
        UnityScope* _tmp0_;
 
270
        UnityScope* _tmp1_;
 
271
        UnityScope* _tmp2_;
 
272
        UnityScope* _tmp3_;
 
273
        UnityScope* _tmp4_;
 
274
        UnityScope* _tmp5_;
 
275
        UnityScope* _tmp6_;
 
276
        UnityScope* _tmp7_;
 
277
        UnityMusicLensMusicBaiduCollection* _tmp8_;
 
278
        GError * _inner_error_ = NULL;
 
279
        self = (UnityMusicLensMusicBaiduScopeProxy*) unity_music_lens_simple_scope_construct (object_type);
 
280
        _tmp0_ = unity_scope_new ("/com/canonical/unity/scope/musicbaidu");
 
281
        _tmp1_ = _tmp0_;
 
282
        unity_music_lens_simple_scope_set_scope ((UnityMusicLensSimpleScope*) self, _tmp1_);
 
283
        _g_object_unref0 (_tmp1_);
 
284
        _tmp2_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
285
        _tmp3_ = _tmp2_;
 
286
        unity_scope_set_search_in_global (_tmp3_, TRUE);
 
287
        _tmp4_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
288
        _tmp5_ = _tmp4_;
 
289
        g_signal_connect_object (_tmp5_, "activate-uri", (GCallback) _unity_music_lens_music_baidu_scope_proxy_activate_unity_scope_activate_uri, self, 0);
 
290
        _tmp6_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
291
        _tmp7_ = _tmp6_;
 
292
        g_signal_connect_object (_tmp7_, "preview-uri", (GCallback) _unity_music_lens_music_baidu_scope_proxy_preview_unity_scope_preview_uri, self, 0);
 
293
        unity_music_lens_simple_scope_initialize (G_TYPE_CHECK_INSTANCE_CAST (self, UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScope));
 
294
        _tmp8_ = unity_music_lens_music_baidu_collection_new ();
 
295
        _g_object_unref0 (self->priv->collection);
 
296
        self->priv->collection = _tmp8_;
 
297
        {
 
298
                UnityScope* _tmp9_;
 
299
                UnityScope* _tmp10_;
 
300
                _tmp9_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
301
                _tmp10_ = _tmp9_;
 
302
                unity_scope_export (_tmp10_, &_inner_error_);
 
303
                if (_inner_error_ != NULL) {
 
304
                        if (_inner_error_->domain == G_IO_ERROR) {
 
305
                                goto __catch4_g_io_error;
 
306
                        }
 
307
                        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);
 
308
                        g_clear_error (&_inner_error_);
 
309
                        return NULL;
 
310
                }
 
311
        }
 
312
        goto __finally4;
 
313
        __catch4_g_io_error:
 
314
        {
 
315
                GError* e = NULL;
 
316
                FILE* _tmp11_;
 
317
                GError* _tmp12_;
 
318
                const gchar* _tmp13_;
 
319
                e = _inner_error_;
 
320
                _inner_error_ = NULL;
 
321
                _tmp11_ = stdout;
 
322
                _tmp12_ = e;
 
323
                _tmp13_ = _tmp12_->message;
 
324
                fprintf (_tmp11_, "%s", _tmp13_);
 
325
                _g_error_free0 (e);
 
326
        }
 
327
        __finally4:
 
328
        if (_inner_error_ != NULL) {
 
329
                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);
 
330
                g_clear_error (&_inner_error_);
 
331
                return NULL;
 
332
        }
 
333
        return self;
 
334
}
 
335
 
 
336
 
 
337
UnityMusicLensMusicBaiduScopeProxy* unity_music_lens_music_baidu_scope_proxy_new (void) {
 
338
        return unity_music_lens_music_baidu_scope_proxy_construct (UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY);
 
339
}
 
340
 
 
341
 
 
342
static glong string_strnlen (gchar* str, glong maxlen) {
 
343
        glong result = 0L;
 
344
        gchar* _tmp0_;
 
345
        glong _tmp1_;
 
346
        gchar* _tmp2_ = NULL;
 
347
        gchar* end;
 
348
        gchar* _tmp3_;
 
349
        _tmp0_ = str;
 
350
        _tmp1_ = maxlen;
 
351
        _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
 
352
        end = _tmp2_;
 
353
        _tmp3_ = end;
 
354
        if (_tmp3_ == NULL) {
 
355
                glong _tmp4_;
 
356
                _tmp4_ = maxlen;
 
357
                result = _tmp4_;
 
358
                return result;
 
359
        } else {
 
360
                gchar* _tmp5_;
 
361
                gchar* _tmp6_;
 
362
                _tmp5_ = end;
 
363
                _tmp6_ = str;
 
364
                result = (glong) (_tmp5_ - _tmp6_);
 
365
                return result;
 
366
        }
 
367
}
 
368
 
 
369
 
 
370
static gchar* string_substring (const gchar* self, glong offset, glong len) {
 
371
        gchar* result = NULL;
 
372
        glong string_length = 0L;
 
373
        gboolean _tmp0_ = FALSE;
 
374
        glong _tmp1_;
 
375
        gboolean _tmp3_;
 
376
        glong _tmp9_;
 
377
        glong _tmp15_;
 
378
        glong _tmp18_;
 
379
        glong _tmp19_;
 
380
        glong _tmp20_;
 
381
        glong _tmp21_;
 
382
        glong _tmp22_;
 
383
        gchar* _tmp23_ = NULL;
 
384
        g_return_val_if_fail (self != NULL, NULL);
 
385
        _tmp1_ = offset;
 
386
        if (_tmp1_ >= ((glong) 0)) {
 
387
                glong _tmp2_;
 
388
                _tmp2_ = len;
 
389
                _tmp0_ = _tmp2_ >= ((glong) 0);
 
390
        } else {
 
391
                _tmp0_ = FALSE;
 
392
        }
 
393
        _tmp3_ = _tmp0_;
 
394
        if (_tmp3_) {
 
395
                glong _tmp4_;
 
396
                glong _tmp5_;
 
397
                glong _tmp6_ = 0L;
 
398
                _tmp4_ = offset;
 
399
                _tmp5_ = len;
 
400
                _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
 
401
                string_length = _tmp6_;
 
402
        } else {
 
403
                gint _tmp7_;
 
404
                gint _tmp8_;
 
405
                _tmp7_ = strlen (self);
 
406
                _tmp8_ = _tmp7_;
 
407
                string_length = (glong) _tmp8_;
 
408
        }
 
409
        _tmp9_ = offset;
 
410
        if (_tmp9_ < ((glong) 0)) {
 
411
                glong _tmp10_;
 
412
                glong _tmp11_;
 
413
                glong _tmp12_;
 
414
                _tmp10_ = string_length;
 
415
                _tmp11_ = offset;
 
416
                offset = _tmp10_ + _tmp11_;
 
417
                _tmp12_ = offset;
 
418
                g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
 
419
        } else {
 
420
                glong _tmp13_;
 
421
                glong _tmp14_;
 
422
                _tmp13_ = offset;
 
423
                _tmp14_ = string_length;
 
424
                g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
 
425
        }
 
426
        _tmp15_ = len;
 
427
        if (_tmp15_ < ((glong) 0)) {
 
428
                glong _tmp16_;
 
429
                glong _tmp17_;
 
430
                _tmp16_ = string_length;
 
431
                _tmp17_ = offset;
 
432
                len = _tmp16_ - _tmp17_;
 
433
        }
 
434
        _tmp18_ = offset;
 
435
        _tmp19_ = len;
 
436
        _tmp20_ = string_length;
 
437
        g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
 
438
        _tmp21_ = offset;
 
439
        _tmp22_ = len;
 
440
        _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
 
441
        result = _tmp23_;
 
442
        return result;
 
443
}
 
444
 
 
445
 
 
446
UnityActivationResponse* unity_music_lens_music_baidu_scope_proxy_activate (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri) {
 
447
        UnityActivationResponse* result = NULL;
 
448
        UnityActivationResponse* _tmp13_;
 
449
        GError * _inner_error_ = NULL;
 
450
        g_return_val_if_fail (self != NULL, NULL);
 
451
        g_return_val_if_fail (uri != NULL, NULL);
 
452
        {
 
453
                const gchar* _tmp0_;
 
454
                gboolean _tmp1_ = FALSE;
 
455
                _tmp0_ = uri;
 
456
                _tmp1_ = g_str_has_prefix (_tmp0_, "song://");
 
457
                if (_tmp1_) {
 
458
                        const gchar* _tmp2_;
 
459
                        gchar* _tmp3_ = NULL;
 
460
                        gchar* _tmp4_;
 
461
                        _tmp2_ = uri;
 
462
                        _tmp3_ = string_substring (_tmp2_, (glong) 7, (glong) (-1));
 
463
                        _tmp4_ = _tmp3_;
 
464
                        g_app_info_launch_default_for_uri (_tmp4_, NULL, &_inner_error_);
 
465
                        _g_free0 (_tmp4_);
 
466
                        if (_inner_error_ != NULL) {
 
467
                                goto __catch5_g_error;
 
468
                        }
 
469
                } else {
 
470
                        const gchar* _tmp5_;
 
471
                        gboolean _tmp6_ = FALSE;
 
472
                        _tmp5_ = uri;
 
473
                        _tmp6_ = g_str_has_prefix (_tmp5_, "album://");
 
474
                        if (_tmp6_) {
 
475
                                const gchar* _tmp7_;
 
476
                                gchar* _tmp8_ = NULL;
 
477
                                gchar* _tmp9_;
 
478
                                _tmp7_ = uri;
 
479
                                _tmp8_ = string_substring (_tmp7_, (glong) 8, (glong) (-1));
 
480
                                _tmp9_ = _tmp8_;
 
481
                                g_app_info_launch_default_for_uri (_tmp9_, NULL, &_inner_error_);
 
482
                                _g_free0 (_tmp9_);
 
483
                                if (_inner_error_ != NULL) {
 
484
                                        goto __catch5_g_error;
 
485
                                }
 
486
                        }
 
487
                }
 
488
        }
 
489
        goto __finally5;
 
490
        __catch5_g_error:
 
491
        {
 
492
                GError* e = NULL;
 
493
                const gchar* _tmp10_;
 
494
                GError* _tmp11_;
 
495
                const gchar* _tmp12_;
 
496
                e = _inner_error_;
 
497
                _inner_error_ = NULL;
 
498
                _tmp10_ = uri;
 
499
                _tmp11_ = e;
 
500
                _tmp12_ = _tmp11_->message;
 
501
                g_warning ("musicbaidu-daemon.vala:107: Failed to open uri %s. %s", _tmp10_, _tmp12_);
 
502
                _g_error_free0 (e);
 
503
        }
 
504
        __finally5:
 
505
        if (_inner_error_ != NULL) {
 
506
                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);
 
507
                g_clear_error (&_inner_error_);
 
508
                return NULL;
 
509
        }
 
510
        _tmp13_ = unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, "");
 
511
        g_object_ref_sink (_tmp13_);
 
512
        result = _tmp13_;
 
513
        return result;
 
514
}
 
515
 
 
516
 
 
517
UnityActivationResponse* unity_music_lens_music_baidu_scope_proxy_download_album (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri) {
 
518
        UnityActivationResponse* result = NULL;
 
519
        const gchar* _tmp0_;
 
520
        UnityActivationResponse* _tmp1_ = NULL;
 
521
        g_return_val_if_fail (self != NULL, NULL);
 
522
        g_return_val_if_fail (uri != NULL, NULL);
 
523
        _tmp0_ = uri;
 
524
        _tmp1_ = unity_music_lens_music_baidu_scope_proxy_activate (self, _tmp0_);
 
525
        result = _tmp1_;
 
526
        return result;
 
527
}
 
528
 
 
529
 
 
530
static void _g_object_unref0_ (gpointer var) {
 
531
        (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
 
532
}
 
533
 
 
534
 
 
535
static void _g_slist_free__g_object_unref0_ (GSList* self) {
 
536
        g_slist_foreach (self, (GFunc) _g_object_unref0_, NULL);
 
537
        g_slist_free (self);
 
538
}
 
539
 
 
540
 
 
541
static gpointer _g_object_ref0 (gpointer self) {
 
542
        return self ? g_object_ref (self) : NULL;
 
543
}
 
544
 
 
545
 
 
546
static UnityActivationResponse* _unity_music_lens_music_baidu_scope_proxy_download_album_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self) {
 
547
        UnityActivationResponse* result;
 
548
        result = unity_music_lens_music_baidu_scope_proxy_download_album (self, uri);
 
549
        return result;
 
550
}
 
551
 
 
552
 
 
553
UnityPreview* unity_music_lens_music_baidu_scope_proxy_preview (UnityMusicLensMusicBaiduScopeProxy* self, const gchar* uri) {
 
554
        UnityPreview* result = NULL;
 
555
        UnityMusicLensAlbum* album;
 
556
        GSList* tracks;
 
557
        const gchar* _tmp0_;
 
558
        gboolean _tmp1_ = FALSE;
 
559
        UnityMusicLensAlbum* _tmp12_;
 
560
        UnityMusicPreview* _tmp59_;
 
561
        UnityPreview* _tmp60_;
 
562
        g_return_val_if_fail (self != NULL, NULL);
 
563
        g_return_val_if_fail (uri != NULL, NULL);
 
564
        _g_object_unref0 (self->priv->music_preview);
 
565
        self->priv->music_preview = NULL;
 
566
        album = NULL;
 
567
        tracks = NULL;
 
568
        _tmp0_ = uri;
 
569
        _tmp1_ = g_str_has_prefix (_tmp0_, "album://");
 
570
        if (_tmp1_) {
 
571
                UnityMusicLensMusicBaiduCollection* _tmp2_;
 
572
                const gchar* _tmp3_;
 
573
                UnityMusicLensAlbum* _tmp4_ = NULL;
 
574
                GSList* _tmp5_ = NULL;
 
575
                _tmp2_ = self->priv->collection;
 
576
                _tmp3_ = uri;
 
577
                unity_music_lens_music_baidu_collection_get_album_details (_tmp2_, _tmp3_, &_tmp4_, &_tmp5_, NULL);
 
578
                _g_object_unref0 (album);
 
579
                album = _tmp4_;
 
580
                __g_slist_free__g_object_unref0_0 (tracks);
 
581
                tracks = _tmp5_;
 
582
        } else {
 
583
                const gchar* _tmp6_;
 
584
                gboolean _tmp7_ = FALSE;
 
585
                _tmp6_ = uri;
 
586
                _tmp7_ = g_str_has_prefix (_tmp6_, "song://");
 
587
                if (_tmp7_) {
 
588
                        UnityMusicLensMusicBaiduCollection* _tmp8_;
 
589
                        const gchar* _tmp9_;
 
590
                        UnityMusicLensAlbum* _tmp10_ = NULL;
 
591
                        GSList* _tmp11_ = NULL;
 
592
                        _tmp8_ = self->priv->collection;
 
593
                        _tmp9_ = uri;
 
594
                        unity_music_lens_music_baidu_collection_get_song_details (_tmp8_, _tmp9_, &_tmp10_, &_tmp11_, NULL);
 
595
                        _g_object_unref0 (album);
 
596
                        album = _tmp10_;
 
597
                        __g_slist_free__g_object_unref0_0 (tracks);
 
598
                        tracks = _tmp11_;
 
599
                }
 
600
        }
 
601
        _tmp12_ = album;
 
602
        if (_tmp12_ != NULL) {
 
603
                GIcon* icon_file;
 
604
                gint i;
 
605
                UnityMusicLensAlbum* _tmp13_;
 
606
                const gchar* _tmp14_;
 
607
                const gchar* _tmp15_;
 
608
                gchar* _tmp16_;
 
609
                gchar* artwork_path;
 
610
                const gchar* _tmp17_;
 
611
                GFile* _tmp18_ = NULL;
 
612
                GFile* _tmp19_;
 
613
                GFileIcon* _tmp20_;
 
614
                UnityMusicLensAlbum* _tmp21_;
 
615
                const gchar* _tmp22_;
 
616
                const gchar* _tmp23_;
 
617
                UnityMusicLensAlbum* _tmp24_;
 
618
                const gchar* _tmp25_;
 
619
                const gchar* _tmp26_;
 
620
                GIcon* _tmp27_;
 
621
                UnityMusicPreview* _tmp28_;
 
622
                GSList* _tmp29_;
 
623
                GFile* _tmp49_ = NULL;
 
624
                GFile* _tmp50_;
 
625
                GFileIcon* _tmp51_;
 
626
                GIcon* _tmp52_;
 
627
                GIcon* icon;
 
628
                const gchar* _tmp53_ = NULL;
 
629
                GIcon* _tmp54_;
 
630
                UnityPreviewAction* _tmp55_;
 
631
                UnityPreviewAction* download_action;
 
632
                UnityPreviewAction* _tmp56_;
 
633
                UnityMusicPreview* _tmp57_;
 
634
                UnityPreviewAction* _tmp58_;
 
635
                icon_file = NULL;
 
636
                i = 1;
 
637
                _tmp13_ = album;
 
638
                _tmp14_ = unity_music_lens_album_get_artwork_path (_tmp13_);
 
639
                _tmp15_ = _tmp14_;
 
640
                _tmp16_ = g_strdup (_tmp15_);
 
641
                artwork_path = _tmp16_;
 
642
                _tmp17_ = artwork_path;
 
643
                _tmp18_ = g_file_new_for_uri (_tmp17_);
 
644
                _tmp19_ = _tmp18_;
 
645
                _tmp20_ = (GFileIcon*) g_file_icon_new (_tmp19_);
 
646
                _g_object_unref0 (icon_file);
 
647
                icon_file = (GIcon*) _tmp20_;
 
648
                _g_object_unref0 (_tmp19_);
 
649
                _tmp21_ = album;
 
650
                _tmp22_ = unity_music_lens_album_get_title (_tmp21_);
 
651
                _tmp23_ = _tmp22_;
 
652
                _tmp24_ = album;
 
653
                _tmp25_ = unity_music_lens_album_get_artist (_tmp24_);
 
654
                _tmp26_ = _tmp25_;
 
655
                _tmp27_ = icon_file;
 
656
                _tmp28_ = unity_music_preview_new (_tmp23_, _tmp26_, _tmp27_);
 
657
                _g_object_unref0 (self->priv->music_preview);
 
658
                self->priv->music_preview = _tmp28_;
 
659
                _tmp29_ = tracks;
 
660
                if (_tmp29_ != NULL) {
 
661
                        GSList* _tmp30_;
 
662
                        _tmp30_ = tracks;
 
663
                        {
 
664
                                GSList* track_collection = NULL;
 
665
                                GSList* track_it = NULL;
 
666
                                track_collection = _tmp30_;
 
667
                                for (track_it = track_collection; track_it != NULL; track_it = track_it->next) {
 
668
                                        UnityMusicLensTrack* _tmp31_;
 
669
                                        UnityMusicLensTrack* track = NULL;
 
670
                                        _tmp31_ = _g_object_ref0 ((UnityMusicLensTrack*) track_it->data);
 
671
                                        track = _tmp31_;
 
672
                                        {
 
673
                                                UnityTrackMetadata* _tmp32_;
 
674
                                                UnityTrackMetadata* tm;
 
675
                                                UnityTrackMetadata* _tmp33_;
 
676
                                                UnityMusicLensTrack* _tmp34_;
 
677
                                                const gchar* _tmp35_;
 
678
                                                const gchar* _tmp36_;
 
679
                                                UnityTrackMetadata* _tmp37_;
 
680
                                                gint _tmp38_;
 
681
                                                UnityTrackMetadata* _tmp39_;
 
682
                                                UnityMusicLensTrack* _tmp40_;
 
683
                                                const gchar* _tmp41_;
 
684
                                                const gchar* _tmp42_;
 
685
                                                UnityTrackMetadata* _tmp43_;
 
686
                                                UnityMusicLensTrack* _tmp44_;
 
687
                                                gint _tmp45_;
 
688
                                                gint _tmp46_;
 
689
                                                UnityMusicPreview* _tmp47_;
 
690
                                                UnityTrackMetadata* _tmp48_;
 
691
                                                _tmp32_ = unity_track_metadata_new ();
 
692
                                                tm = _tmp32_;
 
693
                                                _tmp33_ = tm;
 
694
                                                _tmp34_ = track;
 
695
                                                _tmp35_ = unity_music_lens_track_get_uri (_tmp34_);
 
696
                                                _tmp36_ = _tmp35_;
 
697
                                                unity_track_metadata_set_uri (_tmp33_, _tmp36_);
 
698
                                                _tmp37_ = tm;
 
699
                                                _tmp38_ = i;
 
700
                                                i = _tmp38_ + 1;
 
701
                                                unity_track_metadata_set_track_no (_tmp37_, _tmp38_);
 
702
                                                _tmp39_ = tm;
 
703
                                                _tmp40_ = track;
 
704
                                                _tmp41_ = unity_music_lens_track_get_title (_tmp40_);
 
705
                                                _tmp42_ = _tmp41_;
 
706
                                                unity_track_metadata_set_title (_tmp39_, _tmp42_);
 
707
                                                _tmp43_ = tm;
 
708
                                                _tmp44_ = track;
 
709
                                                _tmp45_ = unity_music_lens_track_get_duration (_tmp44_);
 
710
                                                _tmp46_ = _tmp45_;
 
711
                                                unity_track_metadata_set_length (_tmp43_, (guint) _tmp46_);
 
712
                                                _tmp47_ = self->priv->music_preview;
 
713
                                                _tmp48_ = tm;
 
714
                                                unity_music_preview_add_track (_tmp47_, _tmp48_);
 
715
                                                _g_object_unref0 (tm);
 
716
                                                _g_object_unref0 (track);
 
717
                                        }
 
718
                                }
 
719
                        }
 
720
                }
 
721
                _tmp49_ = g_file_new_for_path (CONFIG_DATADIR "/icons/unity-icon-theme/places/svg/service-u1.svg");
 
722
                _tmp50_ = _tmp49_;
 
723
                _tmp51_ = (GFileIcon*) g_file_icon_new (_tmp50_);
 
724
                _tmp52_ = (GIcon*) _tmp51_;
 
725
                _g_object_unref0 (_tmp50_);
 
726
                icon = _tmp52_;
 
727
                _tmp53_ = _ ("Download");
 
728
                _tmp54_ = icon;
 
729
                _tmp55_ = unity_preview_action_new ("download_album", _tmp53_, _tmp54_);
 
730
                download_action = _tmp55_;
 
731
                _tmp56_ = download_action;
 
732
                g_signal_connect_object (_tmp56_, "activated", (GCallback) _unity_music_lens_music_baidu_scope_proxy_download_album_unity_preview_action_activated, self, 0);
 
733
                _tmp57_ = self->priv->music_preview;
 
734
                _tmp58_ = download_action;
 
735
                unity_preview_add_action ((UnityPreview*) _tmp57_, _tmp58_);
 
736
                _g_object_unref0 (download_action);
 
737
                _g_object_unref0 (icon);
 
738
                _g_free0 (artwork_path);
 
739
                _g_object_unref0 (icon_file);
 
740
        }
 
741
        _tmp59_ = self->priv->music_preview;
 
742
        _tmp60_ = _g_object_ref0 ((UnityPreview*) _tmp59_);
 
743
        result = _tmp60_;
 
744
        __g_slist_free__g_object_unref0_0 (tracks);
 
745
        _g_object_unref0 (album);
 
746
        return result;
 
747
}
 
748
 
 
749
 
 
750
static void _g_list_free__g_object_unref0_ (GList* self) {
 
751
        g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
 
752
        g_list_free (self);
 
753
}
 
754
 
 
755
 
 
756
static void unity_music_lens_music_baidu_scope_proxy_real_perform_search_data_free (gpointer _data) {
 
757
        UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_;
 
758
        _data_ = _data;
 
759
        _g_object_unref0 (_data_->search);
 
760
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
761
        _g_object_unref0 (_data_->cancellable);
 
762
        _g_object_unref0 (_data_->self);
 
763
        g_slice_free (UnityMusicLensMusicBaiduScopeProxyPerformSearchData, _data_);
 
764
}
 
765
 
 
766
 
 
767
static void unity_music_lens_music_baidu_scope_proxy_real_perform_search (UnityMusicLensSimpleScope* base, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
768
        UnityMusicLensMusicBaiduScopeProxy * self;
 
769
        UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_;
 
770
        UnityMusicLensMusicBaiduScopeProxy* _tmp0_;
 
771
        UnityLensSearch* _tmp1_;
 
772
        UnityLensSearch* _tmp2_;
 
773
        UnitySearchType _tmp3_;
 
774
        gint _tmp4_;
 
775
        GCancellable* _tmp5_;
 
776
        GCancellable* _tmp6_;
 
777
        self = (UnityMusicLensMusicBaiduScopeProxy*) base;
 
778
        _data_ = g_slice_new0 (UnityMusicLensMusicBaiduScopeProxyPerformSearchData);
 
779
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_music_lens_music_baidu_scope_proxy_real_perform_search);
 
780
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_music_lens_music_baidu_scope_proxy_real_perform_search_data_free);
 
781
        _tmp0_ = _g_object_ref0 (self);
 
782
        _data_->self = _tmp0_;
 
783
        _tmp1_ = search;
 
784
        _tmp2_ = _g_object_ref0 (_tmp1_);
 
785
        _g_object_unref0 (_data_->search);
 
786
        _data_->search = _tmp2_;
 
787
        _tmp3_ = search_type;
 
788
        _data_->search_type = _tmp3_;
 
789
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
790
        _data_->filters = filters;
 
791
        _tmp4_ = max_results;
 
792
        _data_->max_results = _tmp4_;
 
793
        _tmp5_ = cancellable;
 
794
        _tmp6_ = _g_object_ref0 (_tmp5_);
 
795
        _g_object_unref0 (_data_->cancellable);
 
796
        _data_->cancellable = _tmp6_;
 
797
        unity_music_lens_music_baidu_scope_proxy_real_perform_search_co (_data_);
 
798
}
 
799
 
 
800
 
 
801
static void unity_music_lens_music_baidu_scope_proxy_real_perform_search_finish (UnityMusicLensSimpleScope* base, GAsyncResult* _res_) {
 
802
        UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_;
 
803
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
804
}
 
805
 
 
806
 
 
807
static void unity_music_lens_music_baidu_scope_proxy_perform_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
 
808
        UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_;
 
809
        _data_ = _user_data_;
 
810
        _data_->_source_object_ = source_object;
 
811
        _data_->_res_ = _res_;
 
812
        unity_music_lens_music_baidu_scope_proxy_real_perform_search_co (_data_);
 
813
}
 
814
 
 
815
 
 
816
static gboolean unity_music_lens_music_baidu_scope_proxy_real_perform_search_co (UnityMusicLensMusicBaiduScopeProxyPerformSearchData* _data_) {
 
817
        switch (_data_->_state_) {
 
818
                case 0:
 
819
                goto _state_0;
 
820
                case 1:
 
821
                goto _state_1;
 
822
                default:
 
823
                g_assert_not_reached ();
 
824
        }
 
825
        _state_0:
 
826
        _data_->_tmp0_ = _data_->search;
 
827
        _data_->_tmp1_ = FALSE;
 
828
        _data_->_tmp1_ = unity_music_lens_simple_scope_is_search_empty ((UnityMusicLensSimpleScope*) _data_->self, _data_->_tmp0_);
 
829
        if (_data_->_tmp1_) {
 
830
                __g_list_free__g_object_unref0_0 (_data_->filters);
 
831
                if (_data_->_state_ == 0) {
 
832
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
833
                } else {
 
834
                        g_simple_async_result_complete (_data_->_async_result);
 
835
                }
 
836
                g_object_unref (_data_->_async_result);
 
837
                return FALSE;
 
838
        }
 
839
        {
 
840
                _data_->_tmp2_ = _data_->search;
 
841
                _data_->_tmp3_ = unity_lens_search_get_results_model (_data_->_tmp2_);
 
842
                _data_->_tmp4_ = _data_->_tmp3_;
 
843
                _data_->_tmp5_ = 0U;
 
844
                _data_->_tmp5_ = dee_model_get_n_rows ((DeeModel*) _data_->_tmp4_);
 
845
                g_debug ("musicbaidu-daemon.vala:177: model has %u rows before search", _data_->_tmp5_);
 
846
                _data_->_tmp6_ = _data_->self->priv->collection;
 
847
                _data_->_tmp7_ = _data_->search;
 
848
                _data_->_tmp8_ = _data_->search_type;
 
849
                _data_->_tmp9_ = _data_->filters;
 
850
                _data_->filters = NULL;
 
851
                _data_->_tmp10_ = _data_->max_results;
 
852
                _data_->_tmp11_ = _data_->cancellable;
 
853
                _data_->_state_ = 1;
 
854
                unity_music_lens_music_baidu_collection_search (_data_->_tmp6_, _data_->_tmp7_, _data_->_tmp8_, _data_->_tmp9_, _data_->_tmp10_, _data_->_tmp11_, unity_music_lens_music_baidu_scope_proxy_perform_search_ready, _data_);
 
855
                return FALSE;
 
856
                _state_1:
 
857
                unity_music_lens_music_baidu_collection_search_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error_);
 
858
                if (_data_->_inner_error_ != NULL) {
 
859
                        if (_data_->_inner_error_->domain == G_IO_ERROR) {
 
860
                                goto __catch6_g_io_error;
 
861
                        }
 
862
                        __g_list_free__g_object_unref0_0 (_data_->filters);
 
863
                        g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
 
864
                        g_clear_error (&_data_->_inner_error_);
 
865
                        return FALSE;
 
866
                }
 
867
                _data_->_tmp12_ = _data_->search;
 
868
                _data_->_tmp13_ = unity_lens_search_get_results_model (_data_->_tmp12_);
 
869
                _data_->_tmp14_ = _data_->_tmp13_;
 
870
                _data_->_tmp15_ = 0U;
 
871
                _data_->_tmp15_ = dee_model_get_n_rows ((DeeModel*) _data_->_tmp14_);
 
872
                g_debug ("musicbaidu-daemon.vala:183: model has %u rows after search", _data_->_tmp15_);
 
873
        }
 
874
        goto __finally6;
 
875
        __catch6_g_io_error:
 
876
        {
 
877
                _data_->e = _data_->_inner_error_;
 
878
                _data_->_inner_error_ = NULL;
 
879
                _data_->_tmp16_ = _data_->search;
 
880
                _data_->_tmp17_ = unity_lens_search_get_search_string (_data_->_tmp16_);
 
881
                _data_->_tmp18_ = _data_->_tmp17_;
 
882
                _data_->_tmp19_ = _data_->e;
 
883
                _data_->_tmp20_ = _data_->_tmp19_->message;
 
884
                g_warning ("musicbaidu-daemon.vala:187: Failed to search for '%s': %s", _data_->_tmp18_, _data_->_tmp20_);
 
885
                _g_error_free0 (_data_->e);
 
886
        }
 
887
        __finally6:
 
888
        if (_data_->_inner_error_ != NULL) {
 
889
                __g_list_free__g_object_unref0_0 (_data_->filters);
 
890
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
 
891
                g_clear_error (&_data_->_inner_error_);
 
892
                return FALSE;
 
893
        }
 
894
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
895
        if (_data_->_state_ == 0) {
 
896
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
897
        } else {
 
898
                g_simple_async_result_complete (_data_->_async_result);
 
899
        }
 
900
        g_object_unref (_data_->_async_result);
 
901
        return FALSE;
 
902
}
 
903
 
 
904
 
 
905
static gint unity_music_lens_music_baidu_scope_proxy_real_get_num_results_without_search (UnityMusicLensSimpleScope* base) {
 
906
        gint result;
 
907
        UnityMusicLensMusicBaiduScopeProxy* self;
 
908
        self = (UnityMusicLensMusicBaiduScopeProxy*) base;
 
909
        result = 100;
 
910
        return result;
 
911
}
 
912
 
 
913
 
 
914
static gint unity_music_lens_music_baidu_scope_proxy_real_get_num_results_global_search (UnityMusicLensSimpleScope* base) {
 
915
        gint result;
 
916
        UnityMusicLensMusicBaiduScopeProxy* self;
 
917
        self = (UnityMusicLensMusicBaiduScopeProxy*) base;
 
918
        result = 20;
 
919
        return result;
 
920
}
 
921
 
 
922
 
 
923
static gint unity_music_lens_music_baidu_scope_proxy_real_get_num_results_lens_search (UnityMusicLensSimpleScope* base) {
 
924
        gint result;
 
925
        UnityMusicLensMusicBaiduScopeProxy* self;
 
926
        self = (UnityMusicLensMusicBaiduScopeProxy*) base;
 
927
        result = 50;
 
928
        return result;
 
929
}
 
930
 
 
931
 
 
932
static void unity_music_lens_music_baidu_scope_proxy_class_init (UnityMusicLensMusicBaiduScopeProxyClass * klass) {
 
933
        unity_music_lens_music_baidu_scope_proxy_parent_class = g_type_class_peek_parent (klass);
 
934
        g_type_class_add_private (klass, sizeof (UnityMusicLensMusicBaiduScopeProxyPrivate));
 
935
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->perform_search = unity_music_lens_music_baidu_scope_proxy_real_perform_search;
 
936
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->perform_search_finish = unity_music_lens_music_baidu_scope_proxy_real_perform_search_finish;
 
937
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_without_search = unity_music_lens_music_baidu_scope_proxy_real_get_num_results_without_search;
 
938
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_global_search = unity_music_lens_music_baidu_scope_proxy_real_get_num_results_global_search;
 
939
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_lens_search = unity_music_lens_music_baidu_scope_proxy_real_get_num_results_lens_search;
 
940
        G_OBJECT_CLASS (klass)->get_property = _vala_unity_music_lens_music_baidu_scope_proxy_get_property;
 
941
        G_OBJECT_CLASS (klass)->finalize = unity_music_lens_music_baidu_scope_proxy_finalize;
 
942
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_WITHOUT_SEARCH, g_param_spec_int ("num-results-without-search", "num-results-without-search", "num-results-without-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
943
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_GLOBAL_SEARCH, g_param_spec_int ("num-results-global-search", "num-results-global-search", "num-results-global-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
944
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_LENS_SEARCH, g_param_spec_int ("num-results-lens-search", "num-results-lens-search", "num-results-lens-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
945
}
 
946
 
 
947
 
 
948
static void unity_music_lens_music_baidu_scope_proxy_instance_init (UnityMusicLensMusicBaiduScopeProxy * self) {
 
949
        self->priv = UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_GET_PRIVATE (self);
 
950
}
 
951
 
 
952
 
 
953
static void unity_music_lens_music_baidu_scope_proxy_finalize (GObject* obj) {
 
954
        UnityMusicLensMusicBaiduScopeProxy * self;
 
955
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxy);
 
956
        _g_object_unref0 (self->priv->collection);
 
957
        _g_object_unref0 (self->priv->music_preview);
 
958
        G_OBJECT_CLASS (unity_music_lens_music_baidu_scope_proxy_parent_class)->finalize (obj);
 
959
}
 
960
 
 
961
 
 
962
GType unity_music_lens_music_baidu_scope_proxy_get_type (void) {
 
963
        static volatile gsize unity_music_lens_music_baidu_scope_proxy_type_id__volatile = 0;
 
964
        if (g_once_init_enter (&unity_music_lens_music_baidu_scope_proxy_type_id__volatile)) {
 
965
                static const GTypeInfo g_define_type_info = { sizeof (UnityMusicLensMusicBaiduScopeProxyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_music_lens_music_baidu_scope_proxy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMusicLensMusicBaiduScopeProxy), 0, (GInstanceInitFunc) unity_music_lens_music_baidu_scope_proxy_instance_init, NULL };
 
966
                GType unity_music_lens_music_baidu_scope_proxy_type_id;
 
967
                unity_music_lens_music_baidu_scope_proxy_type_id = g_type_register_static (UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, "UnityMusicLensMusicBaiduScopeProxy", &g_define_type_info, 0);
 
968
                g_once_init_leave (&unity_music_lens_music_baidu_scope_proxy_type_id__volatile, unity_music_lens_music_baidu_scope_proxy_type_id);
 
969
        }
 
970
        return unity_music_lens_music_baidu_scope_proxy_type_id__volatile;
 
971
}
 
972
 
 
973
 
 
974
static void _vala_unity_music_lens_music_baidu_scope_proxy_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
 
975
        UnityMusicLensMusicBaiduScopeProxy * self;
 
976
        self = G_TYPE_CHECK_INSTANCE_CAST (object, UNITY_MUSIC_LENS_TYPE_MUSIC_BAIDU_SCOPE_PROXY, UnityMusicLensMusicBaiduScopeProxy);
 
977
        switch (property_id) {
 
978
                case UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_WITHOUT_SEARCH:
 
979
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_without_search ((UnityMusicLensSimpleScope*) self));
 
980
                break;
 
981
                case UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_GLOBAL_SEARCH:
 
982
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_global_search ((UnityMusicLensSimpleScope*) self));
 
983
                break;
 
984
                case UNITY_MUSIC_LENS_MUSIC_BAIDU_SCOPE_PROXY_NUM_RESULTS_LENS_SEARCH:
 
985
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_lens_search ((UnityMusicLensSimpleScope*) self));
 
986
                break;
 
987
                default:
 
988
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
989
                break;
 
990
        }
 
991
}
 
992
 
 
993
 
 
994
gboolean unity_music_lens_dbus_name_has_owner (const gchar* name) {
 
995
        gboolean result = FALSE;
 
996
        GError * _inner_error_ = NULL;
 
997
        g_return_val_if_fail (name != NULL, FALSE);
 
998
        {
 
999
                gboolean has_owner = FALSE;
 
1000
                GDBusConnection* _tmp0_ = NULL;
 
1001
                GDBusConnection* bus;
 
1002
                GDBusConnection* _tmp1_;
 
1003
                const gchar* _tmp2_;
 
1004
                GVariant* _tmp3_;
 
1005
                GVariant* _tmp4_;
 
1006
                GVariantType* _tmp5_;
 
1007
                GVariantType* _tmp6_;
 
1008
                GVariant* _tmp7_ = NULL;
 
1009
                GVariant* _tmp8_;
 
1010
                GVariant* _result_;
 
1011
                GVariant* _tmp9_;
 
1012
                _tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
 
1013
                bus = _tmp0_;
 
1014
                if (_inner_error_ != NULL) {
 
1015
                        goto __catch7_g_error;
 
1016
                }
 
1017
                _tmp1_ = bus;
 
1018
                _tmp2_ = name;
 
1019
                _tmp3_ = g_variant_new ("(s)", _tmp2_, NULL);
 
1020
                g_variant_ref_sink (_tmp3_);
 
1021
                _tmp4_ = _tmp3_;
 
1022
                _tmp5_ = g_variant_type_new ("(b)");
 
1023
                _tmp6_ = _tmp5_;
 
1024
                _tmp7_ = g_dbus_connection_call_sync (_tmp1_, "org.freedesktop.DBus", "/org/freedesktop/dbus", "org.freedesktop.DBus", "NameHasOwner", _tmp4_, _tmp6_, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &_inner_error_);
 
1025
                _tmp8_ = _tmp7_;
 
1026
                _g_variant_type_free0 (_tmp6_);
 
1027
                _g_variant_unref0 (_tmp4_);
 
1028
                _result_ = _tmp8_;
 
1029
                if (_inner_error_ != NULL) {
 
1030
                        _g_object_unref0 (bus);
 
1031
                        goto __catch7_g_error;
 
1032
                }
 
1033
                _tmp9_ = _result_;
 
1034
                g_variant_get (_tmp9_, "(b)", &has_owner, NULL);
 
1035
                result = has_owner;
 
1036
                _g_variant_unref0 (_result_);
 
1037
                _g_object_unref0 (bus);
 
1038
                return result;
 
1039
        }
 
1040
        goto __finally7;
 
1041
        __catch7_g_error:
 
1042
        {
 
1043
                GError* e = NULL;
 
1044
                const gchar* _tmp10_;
 
1045
                GError* _tmp11_;
 
1046
                const gchar* _tmp12_;
 
1047
                e = _inner_error_;
 
1048
                _inner_error_ = NULL;
 
1049
                _tmp10_ = name;
 
1050
                _tmp11_ = e;
 
1051
                _tmp12_ = _tmp11_->message;
 
1052
                g_warning ("musicbaidu-daemon.vala:214: Unable to decide whether '%s' is running: " \
 
1053
"%s", _tmp10_, _tmp12_);
 
1054
                _g_error_free0 (e);
 
1055
        }
 
1056
        __finally7:
 
1057
        if (_inner_error_ != NULL) {
 
1058
                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);
 
1059
                g_clear_error (&_inner_error_);
 
1060
                return FALSE;
 
1061
        }
 
1062
        result = FALSE;
 
1063
        return result;
 
1064
}
 
1065
 
 
1066
 
 
1067
gint unity_music_lens_main (gchar** args, int args_length1) {
 
1068
        gint result = 0;
 
1069
        gboolean _tmp0_ = FALSE;
 
1070
        UnityMusicLensMusicBaiduScopeProxy* _tmp1_;
 
1071
        GApplication* _tmp2_;
 
1072
        GApplication* _tmp6_;
 
1073
        gboolean _tmp7_ = FALSE;
 
1074
        GApplication* _tmp8_;
 
1075
        GApplication* _tmp9_;
 
1076
        gint _tmp10_ = 0;
 
1077
        GError * _inner_error_ = NULL;
 
1078
        g_set_prgname ("unity-musicbaidu-daemon");
 
1079
        textdomain (CONFIG_PACKAGE);
 
1080
        bindtextdomain (CONFIG_PACKAGE, CONFIG_LOCALEDIR);
 
1081
        bind_textdomain_codeset (CONFIG_PACKAGE, "UTF-8");
 
1082
        setlocale (LC_ALL, "");
 
1083
        _tmp0_ = unity_music_lens_dbus_name_has_owner ("com.canonical.Unity.Scope.MusicBaidu");
 
1084
        if (_tmp0_) {
 
1085
                g_print ("%s", "Another instance of the UbuntuOne Music Daemon " "already appears to be running.\nBailing out.\n");
 
1086
                result = 2;
 
1087
                return result;
 
1088
        }
 
1089
        _tmp1_ = unity_music_lens_music_baidu_scope_proxy_new ();
 
1090
        _g_object_unref0 (unity_music_lens_daemon);
 
1091
        unity_music_lens_daemon = _tmp1_;
 
1092
        _tmp2_ = g_application_new ("com.canonical.Unity.Scope.MusicBaidu", G_APPLICATION_IS_SERVICE);
 
1093
        _g_object_unref0 (unity_music_lens_app);
 
1094
        unity_music_lens_app = _tmp2_;
 
1095
        {
 
1096
                GApplication* _tmp3_;
 
1097
                _tmp3_ = unity_music_lens_app;
 
1098
                g_application_register (_tmp3_, NULL, &_inner_error_);
 
1099
                if (_inner_error_ != NULL) {
 
1100
                        goto __catch8_g_error;
 
1101
                }
 
1102
        }
 
1103
        goto __finally8;
 
1104
        __catch8_g_error:
 
1105
        {
 
1106
                GError* e = NULL;
 
1107
                GError* _tmp4_;
 
1108
                const gchar* _tmp5_;
 
1109
                e = _inner_error_;
 
1110
                _inner_error_ = NULL;
 
1111
                _tmp4_ = e;
 
1112
                _tmp5_ = _tmp4_->message;
 
1113
                g_print ("Failed to start music daemon: %s\n", _tmp5_);
 
1114
                result = 1;
 
1115
                _g_error_free0 (e);
 
1116
                return result;
 
1117
        }
 
1118
        __finally8:
 
1119
        if (_inner_error_ != NULL) {
 
1120
                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);
 
1121
                g_clear_error (&_inner_error_);
 
1122
                return 0;
 
1123
        }
 
1124
        _tmp6_ = unity_music_lens_app;
 
1125
        _tmp7_ = g_application_get_is_remote (_tmp6_);
 
1126
        if (_tmp7_) {
 
1127
                g_print ("%s", "Another instance of the Unity Music Daemon " "already appears to be running.\nBailing out.\n");
 
1128
                result = 2;
 
1129
                return result;
 
1130
        }
 
1131
        _tmp8_ = unity_music_lens_app;
 
1132
        g_application_hold (_tmp8_);
 
1133
        _tmp9_ = unity_music_lens_app;
 
1134
        _tmp10_ = g_application_run (_tmp9_, 0, NULL);
 
1135
        result = _tmp10_;
 
1136
        return result;
 
1137
}
 
1138
 
 
1139
 
 
1140
int main (int argc, char ** argv) {
 
1141
        g_type_init ();
 
1142
        return unity_music_lens_main (argv, argc);
 
1143
}
 
1144
 
 
1145
 
 
1146