~pishuilu1128/unity-china-video-scope/unity-china-video-scope

« back to all changes in this revision

Viewing changes to src/remote-scope.c

  • Committer: Package Import Robot
  • Author(s): shijing
  • Date: 2013-07-20 17:01:30 UTC
  • Revision ID: package-import@ubuntu.com-20130720170130-ngvubtekpiuzfrls
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* remote-scope.c generated by valac 0.20.1, the Vala compiler
 
2
 * generated from remote-scope.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2013 National University of Defense Technology(NUDT) & 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 shijing <jingshi@ubuntukylin.com>
 
21
 * Modified Information:
 
22
 * 1. Modify build_preview function , get the description information of video from youku.
 
23
 * 2. Modify preview_result function, get the uri of single video from youku.
 
24
 *
 
25
 */
 
26
/*
 
27
 * Copyright (C) 2012 Canonical Ltd
 
28
 *
 
29
 * This program is free software: you can redistribute it and/or modify
 
30
 * it under the terms of the GNU General Public License version 3 as
 
31
 * published by the Free Software Foundation.
 
32
 *
 
33
 * This program is distributed in the hope that it will be useful,
 
34
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
35
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
36
 * GNU General Public License for more details.
 
37
 *
 
38
 * You should have received a copy of the GNU General Public License
 
39
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
40
 *
 
41
 * Authored by Pawel Stolowski <pawel.stolowski@canonical.com>
 
42
 * based on python code by David Calle <davidc@framli.eu>
 
43
 *
 
44
 */
 
45
 
 
46
#include <glib.h>
 
47
#include <glib-object.h>
 
48
#include <unity.h>
 
49
#include <libsoup/soup.h>
 
50
#include <gee.h>
 
51
#include <stdlib.h>
 
52
#include <string.h>
 
53
#include <zeitgeist.h>
 
54
#include <gio/gio.h>
 
55
#include <libsoup/soup-gnome.h>
 
56
#include <glib/gi18n-lib.h>
 
57
#include <float.h>
 
58
#include <math.h>
 
59
#include <dee.h>
 
60
 
 
61
 
 
62
#define UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE (unity_video_lens_remote_video_scope_get_type ())
 
63
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE, UnityVideoLensRemoteVideoScope))
 
64
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE, UnityVideoLensRemoteVideoScopeClass))
 
65
#define UNITY_VIDEO_LENS_IS_REMOTE_VIDEO_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE))
 
66
#define UNITY_VIDEO_LENS_IS_REMOTE_VIDEO_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE))
 
67
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE, UnityVideoLensRemoteVideoScopeClass))
 
68
 
 
69
typedef struct _UnityVideoLensRemoteVideoScope UnityVideoLensRemoteVideoScope;
 
70
typedef struct _UnityVideoLensRemoteVideoScopeClass UnityVideoLensRemoteVideoScopeClass;
 
71
typedef struct _UnityVideoLensRemoteVideoScopePrivate UnityVideoLensRemoteVideoScopePrivate;
 
72
 
 
73
#define UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_FILE (unity_video_lens_remote_video_file_get_type ())
 
74
typedef struct _UnityVideoLensRemoteVideoFile UnityVideoLensRemoteVideoFile;
 
75
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
76
#define _g_free0(var) (var = (g_free (var), NULL))
 
77
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
78
#define __g_slist_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_free0_ (var), NULL)))
 
79
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
 
80
typedef struct _UnityVideoLensRemoteVideoScopeActivateResultData UnityVideoLensRemoteVideoScopeActivateResultData;
 
81
 
 
82
#define UNITY_VIDEO_LENS_TYPE_REMOTE_URI (unity_video_lens_remote_uri_get_type ())
 
83
#define UNITY_VIDEO_LENS_REMOTE_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_URI, UnityVideoLensRemoteUri))
 
84
#define UNITY_VIDEO_LENS_REMOTE_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_VIDEO_LENS_TYPE_REMOTE_URI, UnityVideoLensRemoteUriClass))
 
85
#define UNITY_VIDEO_LENS_IS_REMOTE_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_URI))
 
86
#define UNITY_VIDEO_LENS_IS_REMOTE_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_VIDEO_LENS_TYPE_REMOTE_URI))
 
87
#define UNITY_VIDEO_LENS_REMOTE_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_VIDEO_LENS_TYPE_REMOTE_URI, UnityVideoLensRemoteUriClass))
 
88
 
 
89
typedef struct _UnityVideoLensRemoteUri UnityVideoLensRemoteUri;
 
90
typedef struct _UnityVideoLensRemoteUriClass UnityVideoLensRemoteUriClass;
 
91
#define _unity_video_lens_remote_uri_unref0(var) ((var == NULL) ? NULL : (var = (unity_video_lens_remote_uri_unref (var), NULL)))
 
92
 
 
93
#define UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_DETAILS (unity_video_lens_remote_video_details_get_type ())
 
94
typedef struct _UnityVideoLensRemoteVideoDetails UnityVideoLensRemoteVideoDetails;
 
95
#define _unity_video_lens_remote_video_details_free0(var) ((var == NULL) ? NULL : (var = (unity_video_lens_remote_video_details_free (var), NULL)))
 
96
typedef struct _UnityVideoLensRemoteVideoScopePreviewResultData UnityVideoLensRemoteVideoScopePreviewResultData;
 
97
typedef struct _Block1Data Block1Data;
 
98
typedef struct _UnityVideoLensRemoteVideoScopeGetDetailsData UnityVideoLensRemoteVideoScopeGetDetailsData;
 
99
typedef struct _UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData;
 
100
typedef struct _Block2Data Block2Data;
 
101
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
 
102
typedef struct _UnityVideoLensRemoteVideoScopePerformSearchData UnityVideoLensRemoteVideoScopePerformSearchData;
 
103
#define _unity_video_lens_remote_video_file_free0(var) ((var == NULL) ? NULL : (var = (unity_video_lens_remote_video_file_free (var), NULL)))
 
104
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
 
105
 
 
106
struct _UnityVideoLensRemoteVideoScope {
 
107
        UnityDeprecatedScope parent_instance;
 
108
        UnityVideoLensRemoteVideoScopePrivate * priv;
 
109
};
 
110
 
 
111
struct _UnityVideoLensRemoteVideoScopeClass {
 
112
        UnityDeprecatedScopeClass parent_class;
 
113
};
 
114
 
 
115
struct _UnityVideoLensRemoteVideoFile {
 
116
        gchar* title;
 
117
        gchar* comment;
 
118
        gchar* uri;
 
119
        gchar* icon;
 
120
        gchar* details_uri;
 
121
        gchar* price;
 
122
        gint category;
 
123
};
 
124
 
 
125
struct _UnityVideoLensRemoteVideoScopePrivate {
 
126
        SoupSession* session;
 
127
        UnityPreferencesManager* preferences;
 
128
        GeeArrayList* recommendations;
 
129
        gint64 recommendations_last_update;
 
130
        ZeitgeistDataSourceRegistry* zg_sources;
 
131
        gboolean use_zeitgeist;
 
132
};
 
133
 
 
134
struct _UnityVideoLensRemoteVideoScopeActivateResultData {
 
135
        int _state_;
 
136
        GObject* _source_object_;
 
137
        GAsyncResult* _res_;
 
138
        GSimpleAsyncResult* _async_result;
 
139
        UnityVideoLensRemoteVideoScope* self;
 
140
        UnityScopeResult _result_;
 
141
        UnityActivationResponse* result;
 
142
        UnityScopeResult _tmp0_;
 
143
        GHashTable* _tmp1_;
 
144
        const gchar* _tmp2_;
 
145
        gconstpointer _tmp3_;
 
146
        GVariant* _tmp4_;
 
147
        GVariant* realcat;
 
148
        gboolean _tmp5_;
 
149
        GVariant* _tmp6_;
 
150
        GVariant* _tmp7_;
 
151
        gboolean _tmp8_;
 
152
        gboolean _tmp9_;
 
153
        UnityScopeResult _tmp10_;
 
154
        UnityPreview* _tmp11_;
 
155
        UnityPreview* preview;
 
156
        UnityPreview* _tmp12_;
 
157
        UnityActivationResponse* _tmp13_;
 
158
        UnityScopeResult _tmp14_;
 
159
        const gchar* _tmp15_;
 
160
        UnityActivationResponse* _tmp16_;
 
161
};
 
162
 
 
163
struct _UnityVideoLensRemoteVideoDetails {
 
164
        gchar* title;
 
165
        gchar* description;
 
166
        gchar* uri;
 
167
        gchar* image;
 
168
        gchar* source;
 
169
        gchar* release_date;
 
170
        gint duration;
 
171
        gchar** directors;
 
172
        gint directors_length1;
 
173
        gchar* starring;
 
174
        gchar** genres;
 
175
        gint genres_length1;
 
176
        gchar* uploaded_by;
 
177
        gchar* date_uploaded;
 
178
        gchar* price;
 
179
};
 
180
 
 
181
struct _UnityVideoLensRemoteVideoScopePreviewResultData {
 
182
        int _state_;
 
183
        GObject* _source_object_;
 
184
        GAsyncResult* _res_;
 
185
        GSimpleAsyncResult* _async_result;
 
186
        UnityVideoLensRemoteVideoScope* self;
 
187
        UnityScopeResult _result_;
 
188
        UnityPreview* result;
 
189
        UnityScopeResult _tmp0_;
 
190
        const gchar* _tmp1_;
 
191
        UnityVideoLensRemoteUri* _tmp2_;
 
192
        UnityVideoLensRemoteUri* fakeuri;
 
193
        UnityVideoLensRemoteUri* _tmp3_;
 
194
        UnityVideoLensRemoteVideoDetails* details;
 
195
        gboolean _tmp4_;
 
196
        UnityVideoLensRemoteUri* _tmp5_;
 
197
        const gchar* _tmp6_;
 
198
        const gchar* _tmp7_;
 
199
        UnityVideoLensRemoteUri* _tmp8_;
 
200
        const gchar* _tmp9_;
 
201
        const gchar* _tmp10_;
 
202
        gboolean _tmp11_;
 
203
        UnityVideoLensRemoteUri* _tmp12_;
 
204
        const gchar* _tmp13_;
 
205
        const gchar* _tmp14_;
 
206
        UnityVideoLensRemoteVideoDetails* _tmp15_;
 
207
        UnityVideoLensRemoteVideoDetails* _tmp16_;
 
208
        GError* e;
 
209
        GError* _tmp17_;
 
210
        const gchar* _tmp18_;
 
211
        UnityVideoLensRemoteUri* _tmp19_;
 
212
        UnityVideoLensRemoteVideoDetails* _tmp20_;
 
213
        UnityPreview* _tmp21_;
 
214
        UnityScopeResult _tmp22_;
 
215
        const gchar* _tmp23_;
 
216
        GError * _inner_error_;
 
217
};
 
218
 
 
219
struct _Block1Data {
 
220
        int _ref_count_;
 
221
        UnityVideoLensRemoteVideoScope * self;
 
222
        SoupMessage* msg;
 
223
        gpointer _async_data_;
 
224
};
 
225
 
 
226
struct _UnityVideoLensRemoteVideoScopeGetDetailsData {
 
227
        int _state_;
 
228
        GObject* _source_object_;
 
229
        GAsyncResult* _res_;
 
230
        GSimpleAsyncResult* _async_result;
 
231
        UnityVideoLensRemoteVideoScope* self;
 
232
        gchar* url;
 
233
        UnityVideoLensRemoteVideoDetails* result;
 
234
        Block1Data* _data1_;
 
235
        const gchar* _tmp0_;
 
236
        SoupMessage* _tmp1_;
 
237
        SoupSession* _tmp2_;
 
238
        SoupMessage* _tmp3_;
 
239
        SoupMessage* _tmp4_;
 
240
        SoupMessage* _tmp5_;
 
241
        guint _tmp6_;
 
242
        guint _tmp7_;
 
243
        SoupMessage* _tmp8_;
 
244
        guint _tmp9_;
 
245
        guint _tmp10_;
 
246
        SoupMessage* _tmp11_;
 
247
        gchar* _tmp12_;
 
248
        gchar* _tmp13_;
 
249
        gchar* _tmp14_;
 
250
        SoupMessage* _tmp15_;
 
251
        SoupMessageBody* _tmp16_;
 
252
        guint8* _tmp17_;
 
253
        gint _tmp17__length1;
 
254
        UnityVideoLensRemoteVideoDetails _tmp18_;
 
255
        UnityVideoLensRemoteVideoDetails details;
 
256
        UnityVideoLensRemoteVideoDetails _tmp19_;
 
257
        UnityVideoLensRemoteVideoDetails* _tmp20_;
 
258
        UnityVideoLensRemoteVideoDetails* _tmp21_;
 
259
        GError * _inner_error_;
 
260
};
 
261
 
 
262
struct _UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData {
 
263
        int _state_;
 
264
        GObject* _source_object_;
 
265
        GAsyncResult* _res_;
 
266
        GSimpleAsyncResult* _async_result;
 
267
        UnityVideoLensRemoteVideoScope* self;
 
268
        UnityDeprecatedScopeSearch* search;
 
269
        UnitySearchType search_type;
 
270
        GCancellable* cancellable;
 
271
        GCancellable* _tmp0_;
 
272
        gboolean _tmp1_;
 
273
        UnityDeprecatedScopeSearch* _tmp2_;
 
274
        const gchar* _tmp3_;
 
275
        const gchar* _tmp4_;
 
276
        gchar* _tmp5_;
 
277
        gchar* search_string;
 
278
        const gchar* _tmp6_;
 
279
        UnityDeprecatedScopeSearch* _tmp7_;
 
280
        DeeSerializableModel* _tmp8_;
 
281
        DeeSerializableModel* _tmp9_;
 
282
        DeeSerializableModel* _tmp10_;
 
283
        DeeSerializableModel* model;
 
284
        DeeSerializableModel* _tmp11_;
 
285
        UnityPreferencesManager* _tmp12_;
 
286
        UnityPreferencesManagerRemoteContent _tmp13_;
 
287
        UnityPreferencesManagerRemoteContent _tmp14_;
 
288
        UnityDeprecatedScopeSearch* _tmp15_;
 
289
        GeeArrayList* _tmp16_;
 
290
        GeeArrayList* active_sources;
 
291
        UnityOptionsFilter* _tmp17_;
 
292
        UnityOptionsFilter* _tmp18_;
 
293
        GList* _tmp19_;
 
294
        GList* opt_collection;
 
295
        GList* opt_it;
 
296
        UnityFilterOption* _tmp20_;
 
297
        UnityFilterOption* opt;
 
298
        UnityFilterOption* _tmp21_;
 
299
        const gchar* _tmp22_;
 
300
        const gchar* _tmp23_;
 
301
        gboolean _tmp24_;
 
302
        GeeArrayList* _tmp25_;
 
303
        UnityFilterOption* _tmp26_;
 
304
        const gchar* _tmp27_;
 
305
        const gchar* _tmp28_;
 
306
        GeeArrayList* _tmp29_;
 
307
        gint _tmp30_;
 
308
        gint _tmp31_;
 
309
        UnityOptionsFilter* _tmp32_;
 
310
        UnityOptionsFilter* _tmp33_;
 
311
        GList* _tmp34_;
 
312
        guint _tmp35_;
 
313
        GeeArrayList* _tmp36_;
 
314
        UnitySearchType _tmp37_;
 
315
        GeeArrayList* _tmp38_;
 
316
        gboolean _tmp39_;
 
317
        const gchar* _tmp40_;
 
318
        UnityDeprecatedScopeSearch* _tmp41_;
 
319
        GeeArrayList* _tmp42_;
 
320
        GCancellable* _tmp43_;
 
321
        GError* e;
 
322
        GError* _tmp44_;
 
323
        const gchar* _tmp45_;
 
324
        UnityDeprecatedScopeSearch* _tmp46_;
 
325
        GError* _vala1_e;
 
326
        GError* _tmp47_;
 
327
        const gchar* _tmp48_;
 
328
        GError * _inner_error_;
 
329
};
 
330
 
 
331
struct _Block2Data {
 
332
        int _ref_count_;
 
333
        UnityVideoLensRemoteVideoScope * self;
 
334
        SoupMessage* msg;
 
335
        gboolean cancelled;
 
336
        gpointer _async_data_;
 
337
};
 
338
 
 
339
struct _UnityVideoLensRemoteVideoScopePerformSearchData {
 
340
        int _state_;
 
341
        GObject* _source_object_;
 
342
        GAsyncResult* _res_;
 
343
        GSimpleAsyncResult* _async_result;
 
344
        UnityVideoLensRemoteVideoScope* self;
 
345
        gchar* search_string;
 
346
        UnityDeprecatedScopeSearch* search;
 
347
        GeeArrayList* active_sources;
 
348
        GCancellable* cancellable;
 
349
        Block2Data* _data2_;
 
350
        UnityDeprecatedScopeSearch* _tmp0_;
 
351
        DeeSerializableModel* _tmp1_;
 
352
        DeeSerializableModel* _tmp2_;
 
353
        gboolean _tmp3_;
 
354
        gboolean _tmp4_;
 
355
        gboolean _tmp5_;
 
356
        const gchar* _tmp6_;
 
357
        const gchar* _tmp7_;
 
358
        gboolean _tmp8_;
 
359
        GeeArrayList* _tmp9_;
 
360
        gint _tmp10_;
 
361
        gint _tmp11_;
 
362
        gboolean _tmp12_;
 
363
        GeeArrayList* _tmp13_;
 
364
        gint _tmp14_;
 
365
        gint _tmp15_;
 
366
        gboolean _tmp16_;
 
367
        GDateTime* _tmp17_;
 
368
        GDateTime* time;
 
369
        GDateTime* _tmp18_;
 
370
        gint64 _tmp19_;
 
371
        gint64 _tmp20_;
 
372
        gint _tmp21_;
 
373
        UnityDeprecatedScopeSearch* _tmp22_;
 
374
        DeeSerializableModel* _tmp23_;
 
375
        DeeSerializableModel* _tmp24_;
 
376
        GeeArrayList* _tmp25_;
 
377
        const gchar* _tmp26_;
 
378
        GeeArrayList* _tmp27_;
 
379
        gchar* _tmp28_;
 
380
        gchar* url;
 
381
        const gchar* _tmp29_;
 
382
        gboolean _tmp30_;
 
383
        gboolean _tmp31_;
 
384
        const gchar* _tmp32_;
 
385
        const gchar* _tmp33_;
 
386
        gboolean _tmp34_;
 
387
        GeeArrayList* _tmp35_;
 
388
        gint _tmp36_;
 
389
        gint _tmp37_;
 
390
        gboolean _tmp38_;
 
391
        gboolean is_treat_yourself;
 
392
        const gchar* _tmp39_;
 
393
        SoupMessage* _tmp40_;
 
394
        SoupSession* _tmp41_;
 
395
        SoupMessage* _tmp42_;
 
396
        SoupMessage* _tmp43_;
 
397
        gulong cancel_id;
 
398
        GCancellable* _tmp44_;
 
399
        GCancellable* _tmp45_;
 
400
        gulong _tmp46_;
 
401
        gboolean _tmp47_;
 
402
        GCancellable* _tmp48_;
 
403
        gulong _tmp49_;
 
404
        GError* _tmp50_;
 
405
        GCancellable* _tmp51_;
 
406
        GCancellable* _tmp52_;
 
407
        gulong _tmp53_;
 
408
        SoupMessage* _tmp54_;
 
409
        gboolean _tmp55_;
 
410
        GeeArrayList* _tmp56_;
 
411
        GeeArrayList* results;
 
412
        GeeArrayList* _tmp57_;
 
413
        gboolean _tmp58_;
 
414
        const gchar* _tmp59_;
 
415
        gboolean _tmp60_;
 
416
        const gchar* _tmp61_;
 
417
        gchar* _tmp62_;
 
418
        gchar* _tmp63_;
 
419
        gboolean _tmp64_;
 
420
        GeeArrayList* _tmp65_;
 
421
        gint _tmp66_;
 
422
        gint _tmp67_;
 
423
        gboolean _tmp68_;
 
424
        gboolean _tmp69_;
 
425
        GDateTime* _tmp70_;
 
426
        GDateTime* _vala1_time;
 
427
        GeeArrayList* _tmp71_;
 
428
        GeeArrayList* _tmp72_;
 
429
        GDateTime* _tmp73_;
 
430
        gint64 _tmp74_;
 
431
        UnityDeprecatedScopeSearch* _tmp75_;
 
432
        DeeSerializableModel* _tmp76_;
 
433
        DeeSerializableModel* _tmp77_;
 
434
        GeeArrayList* _tmp78_;
 
435
        GError * _inner_error_;
 
436
};
 
437
 
 
438
 
 
439
static gpointer unity_video_lens_remote_video_scope_parent_class = NULL;
 
440
static gint unity_video_lens_remote_video_scope_REFRESH_INTERVAL;
 
441
static gint unity_video_lens_remote_video_scope_REFRESH_INTERVAL = 3600;
 
442
static gint unity_video_lens_remote_video_scope_RETRY_INTERVAL;
 
443
static gint unity_video_lens_remote_video_scope_RETRY_INTERVAL = 60;
 
444
static gchar* unity_video_lens_remote_video_scope_IS_IN_CHINA;
 
445
static gchar* unity_video_lens_remote_video_scope_IS_IN_CHINA = NULL;
 
446
static gchar* unity_video_lens_remote_video_scope_PREVIEW_ON_LMB;
 
447
static gchar* unity_video_lens_remote_video_scope_PREVIEW_ON_LMB = NULL;
 
448
extern gint unity_video_lens_CAT_INDEX_MORE;
 
449
 
 
450
GType unity_video_lens_remote_video_scope_get_type (void) G_GNUC_CONST;
 
451
GType unity_video_lens_remote_video_file_get_type (void) G_GNUC_CONST;
 
452
UnityVideoLensRemoteVideoFile* unity_video_lens_remote_video_file_dup (const UnityVideoLensRemoteVideoFile* self);
 
453
void unity_video_lens_remote_video_file_free (UnityVideoLensRemoteVideoFile* self);
 
454
void unity_video_lens_remote_video_file_copy (const UnityVideoLensRemoteVideoFile* self, UnityVideoLensRemoteVideoFile* dest);
 
455
void unity_video_lens_remote_video_file_destroy (UnityVideoLensRemoteVideoFile* self);
 
456
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE, UnityVideoLensRemoteVideoScopePrivate))
 
457
enum  {
 
458
        UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_DUMMY_PROPERTY
 
459
};
 
460
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_ASK_IP_SERVER_URI_ONE "http://ip.chinaz.com/"
 
461
#define UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_ASK_IP_SERVER_URI_TWO "http://www.123myip.co.uk/"
 
462
static gboolean unity_video_lens_remote_video_scope_is_in_China (UnityVideoLensRemoteVideoScope* self, GCancellable* cancellable);
 
463
UnityVideoLensRemoteVideoScope* unity_video_lens_remote_video_scope_new (void);
 
464
UnityVideoLensRemoteVideoScope* unity_video_lens_remote_video_scope_construct (GType object_type);
 
465
static void unity_video_lens_remote_video_scope_real_constructed (GObject* base);
 
466
static void unity_video_lens_remote_video_scope_zeitgeist_init (UnityVideoLensRemoteVideoScope* self, GError** error);
 
467
#define CONFIG_VERSION "1.0"
 
468
static void __lambda3_ (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable);
 
469
static void unity_video_lens_remote_video_scope_update_search_async (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
470
static void unity_video_lens_remote_video_scope_update_search_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_);
 
471
static void ___lambda3__unity_deprecated_scope_search_changed (UnityDeprecatedScope* _sender, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable, gpointer self);
 
472
static gchar* __lambda6_ (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScope* scope, UnityDeprecatedScopeSearch* search);
 
473
static gchar* ___lambda6__unity_deprecated_scope_generate_search_key (UnityDeprecatedScope* _sender, UnityDeprecatedScopeSearch* search, gpointer self);
 
474
static void __lambda7_ (UnityVideoLensRemoteVideoScope* self, GObject* obj, GParamSpec* pspec);
 
475
static void ___lambda7__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
 
476
static void unity_video_lens_remote_video_scope_populate_categories (UnityVideoLensRemoteVideoScope* self);
 
477
static void unity_video_lens_remote_video_scope_query_list_of_sources (UnityVideoLensRemoteVideoScope* self);
 
478
static gboolean __lambda10_ (UnityVideoLensRemoteVideoScope* self);
 
479
static gboolean ___lambda10__gsource_func (gpointer self);
 
480
#define CONFIG_ICON_PATH "/usr/share/icons/unity-icon-theme/places/svg"
 
481
gchar* unity_video_lens_ubuntu_video_search_sources_uri (void);
 
482
static void unity_video_lens_remote_video_scope_sources_cb (UnityVideoLensRemoteVideoScope* self, SoupSession* session, SoupMessage* msg);
 
483
static void _unity_video_lens_remote_video_scope_sources_cb_soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self);
 
484
static GeeArrayList* unity_video_lens_remote_video_scope_handle_search_response (UnityVideoLensRemoteVideoScope* self, SoupMessage* msg, gboolean is_treat_yourself);
 
485
GeeArrayList* unity_video_lens_ubuntu_video_search_process_search_results (const gchar* json_data, gboolean is_treat_yourself, GError** error);
 
486
GeeArrayList* unity_video_lens_ubuntu_video_search_process_sources_results (const gchar* json_data, GError** error);
 
487
static void _g_free0_ (gpointer var);
 
488
static void _g_slist_free__g_free0_ (GSList* self);
 
489
static gboolean __lambda9_ (UnityVideoLensRemoteVideoScope* self);
 
490
static gboolean ___lambda9__gsource_func (gpointer self);
 
491
static void unity_video_lens_remote_video_scope_real_activate_result_data_free (gpointer _data);
 
492
static void unity_video_lens_remote_video_scope_real_activate_result (UnityDeprecatedScope* base, UnityScopeResult* _result_, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
493
static gboolean unity_video_lens_remote_video_scope_real_activate_result_co (UnityVideoLensRemoteVideoScopeActivateResultData* _data_);
 
494
static void unity_video_lens_remote_video_scope_activate_result_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
 
495
static UnityActivationResponse* unity_video_lens_remote_video_scope_on_activate_uri (UnityVideoLensRemoteVideoScope* self, const gchar* rawuri);
 
496
gpointer unity_video_lens_remote_uri_ref (gpointer instance);
 
497
void unity_video_lens_remote_uri_unref (gpointer instance);
 
498
GParamSpec* unity_video_lens_param_spec_remote_uri (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
499
void unity_video_lens_value_set_remote_uri (GValue* value, gpointer v_object);
 
500
void unity_video_lens_value_take_remote_uri (GValue* value, gpointer v_object);
 
501
gpointer unity_video_lens_value_get_remote_uri (const GValue* value);
 
502
GType unity_video_lens_remote_uri_get_type (void) G_GNUC_CONST;
 
503
UnityVideoLensRemoteUri* unity_video_lens_remote_uri_from_rawuri (const gchar* raw_uri);
 
504
static void unity_video_lens_remote_video_scope_zeitgeist_insert_event (UnityVideoLensRemoteVideoScope* self, const gchar* uri, const gchar* title, const gchar* icon);
 
505
const gchar* unity_video_lens_remote_uri_get_uri (UnityVideoLensRemoteUri* self);
 
506
const gchar* unity_video_lens_remote_uri_get_title (UnityVideoLensRemoteUri* self);
 
507
const gchar* unity_video_lens_remote_uri_get_icon (UnityVideoLensRemoteUri* self);
 
508
static UnityActivationResponse* unity_video_lens_remote_video_scope_on_play_video (UnityVideoLensRemoteVideoScope* self, const gchar* rawuri);
 
509
GType unity_video_lens_remote_video_details_get_type (void) G_GNUC_CONST;
 
510
UnityVideoLensRemoteVideoDetails* unity_video_lens_remote_video_details_dup (const UnityVideoLensRemoteVideoDetails* self);
 
511
void unity_video_lens_remote_video_details_free (UnityVideoLensRemoteVideoDetails* self);
 
512
void unity_video_lens_remote_video_details_copy (const UnityVideoLensRemoteVideoDetails* self, UnityVideoLensRemoteVideoDetails* dest);
 
513
void unity_video_lens_remote_video_details_destroy (UnityVideoLensRemoteVideoDetails* self);
 
514
static UnityPreview* unity_video_lens_remote_video_scope_build_preview (UnityVideoLensRemoteVideoScope* self, UnityVideoLensRemoteUri* uri, UnityVideoLensRemoteVideoDetails* details);
 
515
static UnityActivationResponse* _unity_video_lens_remote_video_scope_on_play_video_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self);
 
516
static void unity_video_lens_remote_video_scope_real_preview_result_data_free (gpointer _data);
 
517
static void unity_video_lens_remote_video_scope_real_preview_result (UnityDeprecatedScope* base, UnityScopeResult* _result_, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
518
static gboolean unity_video_lens_remote_video_scope_real_preview_result_co (UnityVideoLensRemoteVideoScopePreviewResultData* _data_);
 
519
const gchar* unity_video_lens_remote_uri_get_details_uri (UnityVideoLensRemoteUri* self);
 
520
static void unity_video_lens_remote_video_scope_get_details (UnityVideoLensRemoteVideoScope* self, const gchar* url, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
521
static UnityVideoLensRemoteVideoDetails* unity_video_lens_remote_video_scope_get_details_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_, GError** error);
 
522
static void unity_video_lens_remote_video_scope_preview_result_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
 
523
static void unity_video_lens_remote_video_scope_get_details_data_free (gpointer _data);
 
524
static gboolean unity_video_lens_remote_video_scope_get_details_co (UnityVideoLensRemoteVideoScopeGetDetailsData* _data_);
 
525
static Block1Data* block1_data_ref (Block1Data* _data1_);
 
526
static void block1_data_unref (void * _userdata_);
 
527
static void __lambda11_ (Block1Data* _data1_, SoupSession* session_, SoupMessage* msg_);
 
528
static void ___lambda11__soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self);
 
529
void unity_video_lens_ubuntu_video_search_process_details_results (const gchar* json_data, UnityVideoLensRemoteVideoDetails* result, GError** error);
 
530
static void unity_video_lens_remote_video_scope_update_search_async_data_free (gpointer _data);
 
531
static gboolean unity_video_lens_remote_video_scope_update_search_async_co (UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_);
 
532
static gboolean unity_video_lens_remote_video_scope_source_activated (UnityVideoLensRemoteVideoScope* self, const gchar* id);
 
533
static gboolean unity_video_lens_remote_video_scope_at_least_one_source_is_on (UnityVideoLensRemoteVideoScope* self, GeeArrayList* active_sources);
 
534
static void unity_video_lens_remote_video_scope_perform_search (UnityVideoLensRemoteVideoScope* self, const gchar* search_string, UnityDeprecatedScopeSearch* search, GeeArrayList* active_sources, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
535
static void unity_video_lens_remote_video_scope_perform_search_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_, GError** error);
 
536
static void unity_video_lens_remote_video_scope_update_search_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
 
537
static void unity_video_lens_remote_video_scope_perform_search_data_free (gpointer _data);
 
538
static gboolean unity_video_lens_remote_video_scope_perform_search_co (UnityVideoLensRemoteVideoScopePerformSearchData* _data_);
 
539
static Block2Data* block2_data_ref (Block2Data* _data2_);
 
540
static void block2_data_unref (void * _userdata_);
 
541
static void unity_video_lens_remote_video_scope_update_results_model (UnityVideoLensRemoteVideoScope* self, DeeModel* model, GeeArrayList* results);
 
542
gchar* unity_video_lens_ubuntu_video_search_build_search_uri (const gchar* query, GeeArrayList* sources);
 
543
static void __lambda4_ (Block2Data* _data2_, SoupSession* session_, SoupMessage* msg_);
 
544
static void ___lambda4__soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self);
 
545
static void ___lambda5_ (Block2Data* _data2_);
 
546
static void ____lambda5__gfunc (gconstpointer data, gpointer self);
 
547
static gboolean _unity_video_lens_remote_video_scope_perform_search_co_gsource_func (gpointer self);
 
548
UnityVideoLensRemoteUri* unity_video_lens_remote_uri_new (const gchar* uri, const gchar* title, const gchar* icon, const gchar* details_uri);
 
549
UnityVideoLensRemoteUri* unity_video_lens_remote_uri_construct (GType object_type, const gchar* uri, const gchar* title, const gchar* icon, const gchar* details_uri);
 
550
static GVariant* _variant_new1 (const gchar* value);
 
551
static GVariant* _variant_new2 (gboolean value);
 
552
gchar* unity_video_lens_remote_uri_to_rawuri (UnityVideoLensRemoteUri* self);
 
553
static void unity_video_lens_remote_video_scope_finalize (GObject* obj);
 
554
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
555
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
556
 
 
557
 
 
558
static gint string_index_of (const gchar* self, const gchar* needle, gint start_index) {
 
559
        gint result = 0;
 
560
        gint _tmp0_;
 
561
        const gchar* _tmp1_;
 
562
        gchar* _tmp2_ = NULL;
 
563
        gchar* _result_;
 
564
        gchar* _tmp3_;
 
565
        g_return_val_if_fail (self != NULL, 0);
 
566
        g_return_val_if_fail (needle != NULL, 0);
 
567
        _tmp0_ = start_index;
 
568
        _tmp1_ = needle;
 
569
        _tmp2_ = strstr (((gchar*) self) + _tmp0_, (gchar*) _tmp1_);
 
570
        _result_ = _tmp2_;
 
571
        _tmp3_ = _result_;
 
572
        if (_tmp3_ != NULL) {
 
573
                gchar* _tmp4_;
 
574
                _tmp4_ = _result_;
 
575
                result = (gint) (_tmp4_ - ((gchar*) self));
 
576
                return result;
 
577
        } else {
 
578
                result = -1;
 
579
                return result;
 
580
        }
 
581
}
 
582
 
 
583
 
 
584
static gboolean unity_video_lens_remote_video_scope_is_in_China (UnityVideoLensRemoteVideoScope* self, GCancellable* cancellable) {
 
585
        gboolean result = FALSE;
 
586
        const gchar* _tmp0_;
 
587
        GError * _inner_error_ = NULL;
 
588
        g_return_val_if_fail (self != NULL, FALSE);
 
589
        _tmp0_ = unity_video_lens_remote_video_scope_IS_IN_CHINA;
 
590
        if (g_strcmp0 (_tmp0_, "Unknown") == 0) {
 
591
                GFile* _tmp1_ = NULL;
 
592
                GFile* file;
 
593
                guint8* data = NULL;
 
594
                gint data_length1 = 0;
 
595
                gint _data_size_ = 0;
 
596
                gchar* content = NULL;
 
597
                gchar* etag_out = NULL;
 
598
                GFile* _tmp2_;
 
599
                GCancellable* _tmp3_;
 
600
                guint8* _tmp4_ = NULL;
 
601
                gsize _tmp5_;
 
602
                gchar* _tmp6_ = NULL;
 
603
                gboolean _tmp7_ = FALSE;
 
604
                gboolean _tmp8_;
 
605
                _tmp1_ = g_file_new_for_uri (UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_ASK_IP_SERVER_URI_ONE);
 
606
                file = _tmp1_;
 
607
                _tmp2_ = file;
 
608
                _tmp3_ = cancellable;
 
609
                _tmp7_ = g_file_load_contents (_tmp2_, _tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_inner_error_);
 
610
                data = (g_free (data), NULL);
 
611
                data = _tmp4_;
 
612
                data_length1 = _tmp5_;
 
613
                _data_size_ = data_length1;
 
614
                _g_free0 (etag_out);
 
615
                etag_out = _tmp6_;
 
616
                _tmp8_ = _tmp7_;
 
617
                if (_inner_error_ != NULL) {
 
618
                        _g_free0 (etag_out);
 
619
                        _g_free0 (content);
 
620
                        data = (g_free (data), NULL);
 
621
                        _g_object_unref0 (file);
 
622
                        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);
 
623
                        g_clear_error (&_inner_error_);
 
624
                        return FALSE;
 
625
                }
 
626
                if (_tmp8_) {
 
627
                        guint8* _tmp9_;
 
628
                        gint _tmp9__length1;
 
629
                        gchar* _tmp10_;
 
630
                        const gchar* _tmp11_;
 
631
                        gint _tmp12_ = 0;
 
632
                        const gchar* _tmp13_;
 
633
                        gint _tmp14_ = 0;
 
634
                        const gchar* _tmp15_;
 
635
                        gint _tmp16_ = 0;
 
636
                        const gchar* _tmp17_;
 
637
                        gint _tmp18_ = 0;
 
638
                        const gchar* _tmp19_;
 
639
                        gint _tmp20_ = 0;
 
640
                        const gchar* _tmp21_;
 
641
                        gint _tmp22_ = 0;
 
642
                        const gchar* _tmp23_;
 
643
                        gint _tmp24_ = 0;
 
644
                        const gchar* _tmp25_;
 
645
                        gint _tmp26_ = 0;
 
646
                        const gchar* _tmp27_;
 
647
                        gint _tmp28_ = 0;
 
648
                        const gchar* _tmp29_;
 
649
                        gint _tmp30_ = 0;
 
650
                        const gchar* _tmp31_;
 
651
                        gint _tmp32_ = 0;
 
652
                        const gchar* _tmp33_;
 
653
                        gint _tmp34_ = 0;
 
654
                        const gchar* _tmp35_;
 
655
                        gint _tmp36_ = 0;
 
656
                        const gchar* _tmp37_;
 
657
                        gint _tmp38_ = 0;
 
658
                        const gchar* _tmp39_;
 
659
                        gint _tmp40_ = 0;
 
660
                        const gchar* _tmp41_;
 
661
                        gint _tmp42_ = 0;
 
662
                        const gchar* _tmp43_;
 
663
                        gint _tmp44_ = 0;
 
664
                        const gchar* _tmp45_;
 
665
                        gint _tmp46_ = 0;
 
666
                        const gchar* _tmp47_;
 
667
                        gint _tmp48_ = 0;
 
668
                        const gchar* _tmp49_;
 
669
                        gint _tmp50_ = 0;
 
670
                        const gchar* _tmp51_;
 
671
                        gint _tmp52_ = 0;
 
672
                        const gchar* _tmp53_;
 
673
                        gint _tmp54_ = 0;
 
674
                        const gchar* _tmp55_;
 
675
                        gint _tmp56_ = 0;
 
676
                        const gchar* _tmp57_;
 
677
                        gint _tmp58_ = 0;
 
678
                        const gchar* _tmp59_;
 
679
                        gint _tmp60_ = 0;
 
680
                        const gchar* _tmp61_;
 
681
                        gint _tmp62_ = 0;
 
682
                        const gchar* _tmp63_;
 
683
                        gint _tmp64_ = 0;
 
684
                        const gchar* _tmp65_;
 
685
                        gint _tmp66_ = 0;
 
686
                        const gchar* _tmp67_;
 
687
                        gint _tmp68_ = 0;
 
688
                        const gchar* _tmp69_;
 
689
                        gint _tmp70_ = 0;
 
690
                        const gchar* _tmp71_;
 
691
                        gint _tmp72_ = 0;
 
692
                        const gchar* _tmp73_;
 
693
                        gint _tmp74_ = 0;
 
694
                        gint location;
 
695
                        gint _tmp75_;
 
696
                        _tmp9_ = data;
 
697
                        _tmp9__length1 = data_length1;
 
698
                        _tmp10_ = g_strdup ((const gchar*) _tmp9_);
 
699
                        _g_free0 (content);
 
700
                        content = _tmp10_;
 
701
                        _tmp11_ = content;
 
702
                        _tmp12_ = string_index_of (_tmp11_, "北äŗ¬", 0);
 
703
                        _tmp13_ = content;
 
704
                        _tmp14_ = string_index_of (_tmp13_, "äøŠęµ·", 0);
 
705
                        _tmp15_ = content;
 
706
                        _tmp16_ = string_index_of (_tmp15_, "å¤©ę“„", 0);
 
707
                        _tmp17_ = content;
 
708
                        _tmp18_ = string_index_of (_tmp17_, "重åŗ†", 0);
 
709
                        _tmp19_ = content;
 
710
                        _tmp20_ = string_index_of (_tmp19_, "é»‘é¾™ę±Ÿ", 0);
 
711
                        _tmp21_ = content;
 
712
                        _tmp22_ = string_index_of (_tmp21_, "å‰ęž—", 0);
 
713
                        _tmp23_ = content;
 
714
                        _tmp24_ = string_index_of (_tmp23_, "č¾½å®", 0);
 
715
                        _tmp25_ = content;
 
716
                        _tmp26_ = string_index_of (_tmp25_, "ę±Ÿč‹", 0);
 
717
                        _tmp27_ = content;
 
718
                        _tmp28_ = string_index_of (_tmp27_, "å±±äøœ", 0);
 
719
                        _tmp29_ = content;
 
720
                        _tmp30_ = string_index_of (_tmp29_, "安徽", 0);
 
721
                        _tmp31_ = content;
 
722
                        _tmp32_ = string_index_of (_tmp31_, "ę²³åŒ—", 0);
 
723
                        _tmp33_ = content;
 
724
                        _tmp34_ = string_index_of (_tmp33_, "ę²³å—", 0);
 
725
                        _tmp35_ = content;
 
726
                        _tmp36_ = string_index_of (_tmp35_, "ę¹–åŒ—", 0);
 
727
                        _tmp37_ = content;
 
728
                        _tmp38_ = string_index_of (_tmp37_, "ę¹–å—", 0);
 
729
                        _tmp39_ = content;
 
730
                        _tmp40_ = string_index_of (_tmp39_, "ę±Ÿč„æ", 0);
 
731
                        _tmp41_ = content;
 
732
                        _tmp42_ = string_index_of (_tmp41_, "陕č„æ", 0);
 
733
                        _tmp43_ = content;
 
734
                        _tmp44_ = string_index_of (_tmp43_, "å±±č„æ", 0);
 
735
                        _tmp45_ = content;
 
736
                        _tmp46_ = string_index_of (_tmp45_, "四川", 0);
 
737
                        _tmp47_ = content;
 
738
                        _tmp48_ = string_index_of (_tmp47_, "é’ęµ·", 0);
 
739
                        _tmp49_ = content;
 
740
                        _tmp50_ = string_index_of (_tmp49_, "ęµ·å—", 0);
 
741
                        _tmp51_ = content;
 
742
                        _tmp52_ = string_index_of (_tmp51_, "å¹æäøœ", 0);
 
743
                        _tmp53_ = content;
 
744
                        _tmp54_ = string_index_of (_tmp53_, "č“µå·ž", 0);
 
745
                        _tmp55_ = content;
 
746
                        _tmp56_ = string_index_of (_tmp55_, "ęµ™ę±Ÿ", 0);
 
747
                        _tmp57_ = content;
 
748
                        _tmp58_ = string_index_of (_tmp57_, "ē¦å»ŗ", 0);
 
749
                        _tmp59_ = content;
 
750
                        _tmp60_ = string_index_of (_tmp59_, "å°ę¹¾", 0);
 
751
                        _tmp61_ = content;
 
752
                        _tmp62_ = string_index_of (_tmp61_, "ē”˜č‚ƒ", 0);
 
753
                        _tmp63_ = content;
 
754
                        _tmp64_ = string_index_of (_tmp63_, "äŗ‘南", 0);
 
755
                        _tmp65_ = content;
 
756
                        _tmp66_ = string_index_of (_tmp65_, "å†…č’™å¤", 0);
 
757
                        _tmp67_ = content;
 
758
                        _tmp68_ = string_index_of (_tmp67_, "宁夏", 0);
 
759
                        _tmp69_ = content;
 
760
                        _tmp70_ = string_index_of (_tmp69_, "ꖰē–†", 0);
 
761
                        _tmp71_ = content;
 
762
                        _tmp72_ = string_index_of (_tmp71_, "č„æ藏", 0);
 
763
                        _tmp73_ = content;
 
764
                        _tmp74_ = string_index_of (_tmp73_, "å¹æč„æ", 0);
 
765
                        location = ((((((((((((((((((((((((((((((_tmp12_ + _tmp14_) + _tmp16_) + _tmp18_) + _tmp20_) + _tmp22_) + _tmp24_) + _tmp26_) + _tmp28_) + _tmp30_) + _tmp32_) + _tmp34_) + _tmp36_) + _tmp38_) + _tmp40_) + _tmp42_) + _tmp44_) + _tmp46_) + _tmp48_) + _tmp50_) + _tmp52_) + _tmp54_) + _tmp56_) + _tmp58_) + _tmp60_) + _tmp62_) + _tmp64_) + _tmp66_) + _tmp68_) + _tmp70_) + _tmp72_) + _tmp74_;
 
766
                        _tmp75_ = location;
 
767
                        if (_tmp75_ < 0) {
 
768
                                GFile* _tmp76_ = NULL;
 
769
                                _tmp76_ = g_file_new_for_uri (UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_ASK_IP_SERVER_URI_TWO);
 
770
                                _g_object_unref0 (file);
 
771
                                file = _tmp76_;
 
772
                                {
 
773
                                        GFile* _tmp77_;
 
774
                                        GCancellable* _tmp78_;
 
775
                                        guint8* _tmp79_ = NULL;
 
776
                                        gsize _tmp80_;
 
777
                                        gchar* _tmp81_ = NULL;
 
778
                                        gboolean _tmp82_ = FALSE;
 
779
                                        gboolean _tmp83_;
 
780
                                        _tmp77_ = file;
 
781
                                        _tmp78_ = cancellable;
 
782
                                        _tmp82_ = g_file_load_contents (_tmp77_, _tmp78_, &_tmp79_, &_tmp80_, &_tmp81_, &_inner_error_);
 
783
                                        data = (g_free (data), NULL);
 
784
                                        data = _tmp79_;
 
785
                                        data_length1 = _tmp80_;
 
786
                                        _data_size_ = data_length1;
 
787
                                        _g_free0 (etag_out);
 
788
                                        etag_out = _tmp81_;
 
789
                                        _tmp83_ = _tmp82_;
 
790
                                        if (_inner_error_ != NULL) {
 
791
                                                goto __catch1_g_error;
 
792
                                        }
 
793
                                        if (_tmp83_) {
 
794
                                                guint8* _tmp84_;
 
795
                                                gint _tmp84__length1;
 
796
                                                gchar* _tmp85_;
 
797
                                                const gchar* _tmp86_;
 
798
                                                gint _tmp87_ = 0;
 
799
                                                gint _tmp88_;
 
800
                                                _tmp84_ = data;
 
801
                                                _tmp84__length1 = data_length1;
 
802
                                                _tmp85_ = g_strdup ((const gchar*) _tmp84_);
 
803
                                                _g_free0 (content);
 
804
                                                content = _tmp85_;
 
805
                                                _tmp86_ = content;
 
806
                                                _tmp87_ = string_index_of (_tmp86_, "China", 0);
 
807
                                                location = _tmp87_;
 
808
                                                _tmp88_ = location;
 
809
                                                if (_tmp88_ > 0) {
 
810
                                                        gchar* _tmp89_;
 
811
                                                        _tmp89_ = g_strdup ("Yes");
 
812
                                                        _g_free0 (unity_video_lens_remote_video_scope_IS_IN_CHINA);
 
813
                                                        unity_video_lens_remote_video_scope_IS_IN_CHINA = _tmp89_;
 
814
                                                        result = TRUE;
 
815
                                                        _g_free0 (etag_out);
 
816
                                                        _g_free0 (content);
 
817
                                                        data = (g_free (data), NULL);
 
818
                                                        _g_object_unref0 (file);
 
819
                                                        return result;
 
820
                                                }
 
821
                                        }
 
822
                                }
 
823
                                goto __finally1;
 
824
                                __catch1_g_error:
 
825
                                {
 
826
                                        GError* e = NULL;
 
827
                                        GFile* _tmp90_;
 
828
                                        gchar* _tmp91_ = NULL;
 
829
                                        gchar* _tmp92_;
 
830
                                        GError* _tmp93_;
 
831
                                        const gchar* _tmp94_;
 
832
                                        e = _inner_error_;
 
833
                                        _inner_error_ = NULL;
 
834
                                        _tmp90_ = file;
 
835
                                        _tmp91_ = g_file_get_uri (_tmp90_);
 
836
                                        _tmp92_ = _tmp91_;
 
837
                                        _tmp93_ = e;
 
838
                                        _tmp94_ = _tmp93_->message;
 
839
                                        g_warning ("remote-scope.vala:120: Error reading URL '%s': %s", _tmp92_, _tmp94_);
 
840
                                        _g_free0 (_tmp92_);
 
841
                                        _g_error_free0 (e);
 
842
                                }
 
843
                                __finally1:
 
844
                                if (_inner_error_ != NULL) {
 
845
                                        _g_free0 (etag_out);
 
846
                                        _g_free0 (content);
 
847
                                        data = (g_free (data), NULL);
 
848
                                        _g_object_unref0 (file);
 
849
                                        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);
 
850
                                        g_clear_error (&_inner_error_);
 
851
                                        return FALSE;
 
852
                                }
 
853
                        } else {
 
854
                                gchar* _tmp95_;
 
855
                                _tmp95_ = g_strdup ("Yes");
 
856
                                _g_free0 (unity_video_lens_remote_video_scope_IS_IN_CHINA);
 
857
                                unity_video_lens_remote_video_scope_IS_IN_CHINA = _tmp95_;
 
858
                                result = TRUE;
 
859
                                _g_free0 (etag_out);
 
860
                                _g_free0 (content);
 
861
                                data = (g_free (data), NULL);
 
862
                                _g_object_unref0 (file);
 
863
                                return result;
 
864
                        }
 
865
                }
 
866
                _g_free0 (etag_out);
 
867
                _g_free0 (content);
 
868
                data = (g_free (data), NULL);
 
869
                _g_object_unref0 (file);
 
870
        } else {
 
871
                result = TRUE;
 
872
                return result;
 
873
        }
 
874
        result = TRUE;
 
875
        return result;
 
876
}
 
877
 
 
878
 
 
879
UnityVideoLensRemoteVideoScope* unity_video_lens_remote_video_scope_construct (GType object_type) {
 
880
        UnityVideoLensRemoteVideoScope * self = NULL;
 
881
        self = (UnityVideoLensRemoteVideoScope*) g_object_new (object_type, "dbus-path", "/net/launchpad/scope/youkuvideos", "id", "videoyouku.scope", NULL);
 
882
        return self;
 
883
}
 
884
 
 
885
 
 
886
UnityVideoLensRemoteVideoScope* unity_video_lens_remote_video_scope_new (void) {
 
887
        return unity_video_lens_remote_video_scope_construct (UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE);
 
888
}
 
889
 
 
890
 
 
891
static void __lambda3_ (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable) {
 
892
        UnityDeprecatedScopeSearch* _tmp0_;
 
893
        UnitySearchType _tmp1_;
 
894
        GCancellable* _tmp2_;
 
895
        g_return_if_fail (search != NULL);
 
896
        g_return_if_fail (cancellable != NULL);
 
897
        _tmp0_ = search;
 
898
        _tmp1_ = search_type;
 
899
        _tmp2_ = cancellable;
 
900
        unity_video_lens_remote_video_scope_update_search_async (self, _tmp0_, _tmp1_, _tmp2_, NULL, NULL);
 
901
}
 
902
 
 
903
 
 
904
static void ___lambda3__unity_deprecated_scope_search_changed (UnityDeprecatedScope* _sender, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable, gpointer self) {
 
905
        __lambda3_ (self, search, search_type, cancellable);
 
906
}
 
907
 
 
908
 
 
909
static gchar* string_strip (const gchar* self) {
 
910
        gchar* result = NULL;
 
911
        gchar* _tmp0_ = NULL;
 
912
        gchar* _result_;
 
913
        const gchar* _tmp1_;
 
914
        g_return_val_if_fail (self != NULL, NULL);
 
915
        _tmp0_ = g_strdup (self);
 
916
        _result_ = _tmp0_;
 
917
        _tmp1_ = _result_;
 
918
        g_strstrip (_tmp1_);
 
919
        result = _result_;
 
920
        return result;
 
921
}
 
922
 
 
923
 
 
924
static gchar* __lambda6_ (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScope* scope, UnityDeprecatedScopeSearch* search) {
 
925
        gchar* result = NULL;
 
926
        UnityDeprecatedScopeSearch* _tmp0_;
 
927
        const gchar* _tmp1_;
 
928
        const gchar* _tmp2_;
 
929
        gchar* _tmp3_ = NULL;
 
930
        g_return_val_if_fail (scope != NULL, NULL);
 
931
        g_return_val_if_fail (search != NULL, NULL);
 
932
        _tmp0_ = search;
 
933
        _tmp1_ = unity_deprecated_scope_search_get_search_string (_tmp0_);
 
934
        _tmp2_ = _tmp1_;
 
935
        _tmp3_ = string_strip (_tmp2_);
 
936
        result = _tmp3_;
 
937
        return result;
 
938
}
 
939
 
 
940
 
 
941
static gchar* ___lambda6__unity_deprecated_scope_generate_search_key (UnityDeprecatedScope* _sender, UnityDeprecatedScopeSearch* search, gpointer self) {
 
942
        gchar* result;
 
943
        result = __lambda6_ (self, _sender, search);
 
944
        return result;
 
945
}
 
946
 
 
947
 
 
948
static void __lambda7_ (UnityVideoLensRemoteVideoScope* self, GObject* obj, GParamSpec* pspec) {
 
949
        g_return_if_fail (obj != NULL);
 
950
        g_return_if_fail (pspec != NULL);
 
951
        unity_deprecated_scope_queue_search_changed ((UnityDeprecatedScope*) self, UNITY_SEARCH_TYPE_DEFAULT);
 
952
}
 
953
 
 
954
 
 
955
static void ___lambda7__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
 
956
        __lambda7_ (self, _sender, pspec);
 
957
}
 
958
 
 
959
 
 
960
static gboolean __lambda10_ (UnityVideoLensRemoteVideoScope* self) {
 
961
        gboolean result = FALSE;
 
962
        unity_deprecated_scope_queue_search_changed ((UnityDeprecatedScope*) self, UNITY_SEARCH_TYPE_DEFAULT);
 
963
        result = TRUE;
 
964
        return result;
 
965
}
 
966
 
 
967
 
 
968
static gboolean ___lambda10__gsource_func (gpointer self) {
 
969
        gboolean result;
 
970
        result = __lambda10_ (self);
 
971
        return result;
 
972
}
 
973
 
 
974
 
 
975
static void unity_video_lens_remote_video_scope_real_constructed (GObject* base) {
 
976
        UnityVideoLensRemoteVideoScope * self;
 
977
        UnitySchema* _tmp0_;
 
978
        UnitySchema* _tmp1_;
 
979
        const gchar* _tmp2_;
 
980
        GeeArrayList* _tmp3_;
 
981
        SoupSessionAsync* _tmp4_;
 
982
        SoupSession* _tmp5_;
 
983
        SoupSession* _tmp6_;
 
984
        SoupSession* _tmp7_;
 
985
        SoupSession* _tmp8_;
 
986
        UnityPreferencesManager* _tmp9_;
 
987
        gint _tmp10_;
 
988
        GError * _inner_error_ = NULL;
 
989
        self = (UnityVideoLensRemoteVideoScope*) base;
 
990
        G_OBJECT_CLASS (unity_video_lens_remote_video_scope_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, UNITY_TYPE_DEPRECATED_SCOPE, UnityDeprecatedScope));
 
991
        _tmp0_ = unity_deprecated_scope_base_get_schema ((UnityDeprecatedScopeBase*) self);
 
992
        _tmp1_ = _tmp0_;
 
993
        _tmp2_ = unity_video_lens_remote_video_scope_PREVIEW_ON_LMB;
 
994
        unity_schema_add_field (_tmp1_, _tmp2_, "b", UNITY_SCHEMA_FIELD_TYPE_OPTIONAL);
 
995
        _tmp3_ = gee_array_list_new (UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_FILE, (GBoxedCopyFunc) unity_video_lens_remote_video_file_dup, unity_video_lens_remote_video_file_free, NULL);
 
996
        _g_object_unref0 (self->priv->recommendations);
 
997
        self->priv->recommendations = _tmp3_;
 
998
        self->priv->use_zeitgeist = FALSE;
 
999
        {
 
1000
                unity_video_lens_remote_video_scope_zeitgeist_init (self, &_inner_error_);
 
1001
                if (_inner_error_ != NULL) {
 
1002
                        goto __catch2_g_error;
 
1003
                }
 
1004
                self->priv->use_zeitgeist = TRUE;
 
1005
        }
 
1006
        goto __finally2;
 
1007
        __catch2_g_error:
 
1008
        {
 
1009
                GError* e = NULL;
 
1010
                e = _inner_error_;
 
1011
                _inner_error_ = NULL;
 
1012
                g_warning ("remote-scope.vala:163: Failed to initialize Zeitgeist, won't store eve" \
 
1013
"nts");
 
1014
                _g_error_free0 (e);
 
1015
        }
 
1016
        __finally2:
 
1017
        if (_inner_error_ != NULL) {
 
1018
                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);
 
1019
                g_clear_error (&_inner_error_);
 
1020
                return;
 
1021
        }
 
1022
        _tmp4_ = (SoupSessionAsync*) soup_session_async_new ();
 
1023
        _g_object_unref0 (self->priv->session);
 
1024
        self->priv->session = (SoupSession*) _tmp4_;
 
1025
        _tmp5_ = self->priv->session;
 
1026
        g_object_set (_tmp5_, "ssl-use-system-ca-file", TRUE, NULL);
 
1027
        _tmp6_ = self->priv->session;
 
1028
        g_object_set (_tmp6_, "ssl-strict", TRUE, NULL);
 
1029
        _tmp7_ = self->priv->session;
 
1030
        g_object_set (_tmp7_, "user-agent", "Unity Video Lens Remote Scope v" CONFIG_VERSION, NULL);
 
1031
        _tmp8_ = self->priv->session;
 
1032
        soup_session_add_feature_by_type (_tmp8_, soup_proxy_resolver_gnome_get_type ());
 
1033
        unity_deprecated_scope_base_set_search_in_global ((UnityDeprecatedScopeBase*) self, FALSE);
 
1034
        g_signal_connect_object ((UnityDeprecatedScope*) self, "search-changed", (GCallback) ___lambda3__unity_deprecated_scope_search_changed, self, 0);
 
1035
        g_signal_connect_object ((UnityDeprecatedScope*) self, "generate-search-key", (GCallback) ___lambda6__unity_deprecated_scope_generate_search_key, self, 0);
 
1036
        _tmp9_ = self->priv->preferences;
 
1037
        g_signal_connect_object ((GObject*) _tmp9_, "notify::remote-content-search", (GCallback) ___lambda7__g_object_notify, self, 0);
 
1038
        unity_video_lens_remote_video_scope_populate_categories (self);
 
1039
        unity_video_lens_remote_video_scope_query_list_of_sources (self);
 
1040
        _tmp10_ = unity_video_lens_remote_video_scope_REFRESH_INTERVAL;
 
1041
        g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) (_tmp10_ / 2), ___lambda10__gsource_func, g_object_ref (self), g_object_unref);
 
1042
        {
 
1043
                unity_deprecated_scope_base_export ((UnityDeprecatedScopeBase*) self, &_inner_error_);
 
1044
                if (_inner_error_ != NULL) {
 
1045
                        goto __catch3_g_error;
 
1046
                }
 
1047
        }
 
1048
        goto __finally3;
 
1049
        __catch3_g_error:
 
1050
        {
 
1051
                GError* e = NULL;
 
1052
                const gchar* _tmp11_;
 
1053
                e = _inner_error_;
 
1054
                _inner_error_ = NULL;
 
1055
                _tmp11_ = e->message;
 
1056
                g_error ("remote-scope.vala:206: Failed to export scope: %s", _tmp11_);
 
1057
                _g_error_free0 (e);
 
1058
        }
 
1059
        __finally3:
 
1060
        if (_inner_error_ != NULL) {
 
1061
                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);
 
1062
                g_clear_error (&_inner_error_);
 
1063
                return;
 
1064
        }
 
1065
}
 
1066
 
 
1067
 
 
1068
static void unity_video_lens_remote_video_scope_populate_categories (UnityVideoLensRemoteVideoScope* self) {
 
1069
        UnityCategorySet* _tmp0_;
 
1070
        UnityCategorySet* categories;
 
1071
        GFile* _tmp1_ = NULL;
 
1072
        GFile* icon_dir;
 
1073
        const gchar* _tmp2_ = NULL;
 
1074
        GFile* _tmp3_ = NULL;
 
1075
        GFile* _tmp4_;
 
1076
        GFileIcon* _tmp5_;
 
1077
        GFileIcon* _tmp6_;
 
1078
        UnityCategory* _tmp7_;
 
1079
        UnityCategory* _tmp8_;
 
1080
        const gchar* _tmp9_ = NULL;
 
1081
        GFile* _tmp10_ = NULL;
 
1082
        GFile* _tmp11_;
 
1083
        GFileIcon* _tmp12_;
 
1084
        GFileIcon* _tmp13_;
 
1085
        UnityCategory* _tmp14_;
 
1086
        UnityCategory* _tmp15_;
 
1087
        g_return_if_fail (self != NULL);
 
1088
        _tmp0_ = unity_category_set_new ();
 
1089
        categories = _tmp0_;
 
1090
        _tmp1_ = g_file_new_for_path (CONFIG_ICON_PATH);
 
1091
        icon_dir = _tmp1_;
 
1092
        _tmp2_ = _ ("Online");
 
1093
        _tmp3_ = g_file_get_child (icon_dir, "group-internet.svg");
 
1094
        _tmp4_ = _tmp3_;
 
1095
        _tmp5_ = (GFileIcon*) g_file_icon_new (_tmp4_);
 
1096
        _tmp6_ = _tmp5_;
 
1097
        _tmp7_ = unity_category_new ("online", _tmp2_, (GIcon*) _tmp6_, UNITY_CATEGORY_RENDERER_VERTICAL_TILE);
 
1098
        _tmp8_ = _tmp7_;
 
1099
        unity_category_set_add (categories, _tmp8_);
 
1100
        _g_object_unref0 (_tmp8_);
 
1101
        _g_object_unref0 (_tmp6_);
 
1102
        _g_object_unref0 (_tmp4_);
 
1103
        _tmp9_ = _ ("More suggestions");
 
1104
        _tmp10_ = g_file_get_child (icon_dir, "group-treat-yourself.svg");
 
1105
        _tmp11_ = _tmp10_;
 
1106
        _tmp12_ = (GFileIcon*) g_file_icon_new (_tmp11_);
 
1107
        _tmp13_ = _tmp12_;
 
1108
        _tmp14_ = unity_category_new ("more", _tmp9_, (GIcon*) _tmp13_, UNITY_CATEGORY_RENDERER_VERTICAL_TILE);
 
1109
        _tmp15_ = _tmp14_;
 
1110
        unity_category_set_add (categories, _tmp15_);
 
1111
        _g_object_unref0 (_tmp15_);
 
1112
        _g_object_unref0 (_tmp13_);
 
1113
        _g_object_unref0 (_tmp11_);
 
1114
        unity_deprecated_scope_base_set_categories ((UnityDeprecatedScopeBase*) self, categories);
 
1115
        _g_object_unref0 (icon_dir);
 
1116
        _g_object_unref0 (categories);
 
1117
}
 
1118
 
 
1119
 
 
1120
static gpointer _g_object_ref0 (gpointer self) {
 
1121
        return self ? g_object_ref (self) : NULL;
 
1122
}
 
1123
 
 
1124
 
 
1125
static void _unity_video_lens_remote_video_scope_sources_cb_soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self) {
 
1126
        unity_video_lens_remote_video_scope_sources_cb (self, session, msg);
 
1127
}
 
1128
 
 
1129
 
 
1130
static void unity_video_lens_remote_video_scope_query_list_of_sources (UnityVideoLensRemoteVideoScope* self) {
 
1131
        gchar* _tmp0_ = NULL;
 
1132
        gchar* _tmp1_;
 
1133
        SoupMessage* _tmp2_;
 
1134
        SoupMessage* _tmp3_;
 
1135
        SoupMessage* msg;
 
1136
        SoupSession* _tmp4_;
 
1137
        SoupMessage* _tmp5_;
 
1138
        g_return_if_fail (self != NULL);
 
1139
        _tmp0_ = unity_video_lens_ubuntu_video_search_sources_uri ();
 
1140
        _tmp1_ = _tmp0_;
 
1141
        _tmp2_ = soup_message_new ("GET", _tmp1_);
 
1142
        _tmp3_ = _tmp2_;
 
1143
        _g_free0 (_tmp1_);
 
1144
        msg = _tmp3_;
 
1145
        _tmp4_ = self->priv->session;
 
1146
        _tmp5_ = _g_object_ref0 (msg);
 
1147
        soup_session_queue_message (_tmp4_, _tmp5_, _unity_video_lens_remote_video_scope_sources_cb_soup_session_callback, self);
 
1148
        _g_object_unref0 (msg);
 
1149
}
 
1150
 
 
1151
 
 
1152
static GeeArrayList* unity_video_lens_remote_video_scope_handle_search_response (UnityVideoLensRemoteVideoScope* self, SoupMessage* msg, gboolean is_treat_yourself) {
 
1153
        GeeArrayList* result = NULL;
 
1154
        SoupMessage* _tmp0_;
 
1155
        guint _tmp1_ = 0U;
 
1156
        guint _tmp2_;
 
1157
        GError * _inner_error_ = NULL;
 
1158
        g_return_val_if_fail (self != NULL, NULL);
 
1159
        g_return_val_if_fail (msg != NULL, NULL);
 
1160
        _tmp0_ = msg;
 
1161
        g_object_get (_tmp0_, "status-code", &_tmp1_, NULL);
 
1162
        _tmp2_ = _tmp1_;
 
1163
        if (_tmp2_ != ((guint) 200)) {
 
1164
                SoupMessage* _tmp3_;
 
1165
                guint _tmp4_ = 0U;
 
1166
                guint _tmp5_;
 
1167
                SoupMessage* _tmp6_;
 
1168
                gchar* _tmp7_ = NULL;
 
1169
                gchar* _tmp8_;
 
1170
                gchar* _tmp9_;
 
1171
                _tmp3_ = msg;
 
1172
                g_object_get (_tmp3_, "status-code", &_tmp4_, NULL);
 
1173
                _tmp5_ = _tmp4_;
 
1174
                _tmp6_ = msg;
 
1175
                g_object_get (_tmp6_, "reason-phrase", &_tmp7_, NULL);
 
1176
                _tmp8_ = _tmp7_;
 
1177
                _tmp9_ = _tmp8_;
 
1178
                g_warning ("remote-scope.vala:234: Unable to get results from the server: %u, %s", _tmp5_, _tmp9_);
 
1179
                _g_free0 (_tmp9_);
 
1180
        } else {
 
1181
                {
 
1182
                        SoupMessage* _tmp10_;
 
1183
                        SoupMessageBody* _tmp11_;
 
1184
                        guint8* _tmp12_;
 
1185
                        gint _tmp12__length1;
 
1186
                        gboolean _tmp13_;
 
1187
                        GeeArrayList* _tmp14_ = NULL;
 
1188
                        GeeArrayList* _tmp15_;
 
1189
                        _tmp10_ = msg;
 
1190
                        _tmp11_ = _tmp10_->response_body;
 
1191
                        _tmp12_ = _tmp11_->data;
 
1192
                        _tmp12__length1 = (gint) _tmp11_->length;
 
1193
                        _tmp13_ = is_treat_yourself;
 
1194
                        _tmp14_ = unity_video_lens_ubuntu_video_search_process_search_results ((const gchar*) _tmp12_, _tmp13_, &_inner_error_);
 
1195
                        _tmp15_ = _tmp14_;
 
1196
                        if (_inner_error_ != NULL) {
 
1197
                                goto __catch4_g_error;
 
1198
                        }
 
1199
                        result = _tmp15_;
 
1200
                        return result;
 
1201
                }
 
1202
                goto __finally4;
 
1203
                __catch4_g_error:
 
1204
                {
 
1205
                        GError* e = NULL;
 
1206
                        GError* _tmp16_;
 
1207
                        const gchar* _tmp17_;
 
1208
                        e = _inner_error_;
 
1209
                        _inner_error_ = NULL;
 
1210
                        _tmp16_ = e;
 
1211
                        _tmp17_ = _tmp16_->message;
 
1212
                        g_warning ("remote-scope.vala:245: Error processing search results: %s", _tmp17_);
 
1213
                        _g_error_free0 (e);
 
1214
                }
 
1215
                __finally4:
 
1216
                if (_inner_error_ != NULL) {
 
1217
                        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);
 
1218
                        g_clear_error (&_inner_error_);
 
1219
                        return NULL;
 
1220
                }
 
1221
        }
 
1222
        result = NULL;
 
1223
        return result;
 
1224
}
 
1225
 
 
1226
 
 
1227
static void _g_free0_ (gpointer var) {
 
1228
        var = (g_free (var), NULL);
 
1229
}
 
1230
 
 
1231
 
 
1232
static void _g_slist_free__g_free0_ (GSList* self) {
 
1233
        g_slist_foreach (self, (GFunc) _g_free0_, NULL);
 
1234
        g_slist_free (self);
 
1235
}
 
1236
 
 
1237
 
 
1238
static gboolean __lambda9_ (UnityVideoLensRemoteVideoScope* self) {
 
1239
        gboolean result = FALSE;
 
1240
        unity_video_lens_remote_video_scope_query_list_of_sources (self);
 
1241
        result = FALSE;
 
1242
        return result;
 
1243
}
 
1244
 
 
1245
 
 
1246
static gboolean ___lambda9__gsource_func (gpointer self) {
 
1247
        gboolean result;
 
1248
        result = __lambda9_ (self);
 
1249
        return result;
 
1250
}
 
1251
 
 
1252
 
 
1253
static void unity_video_lens_remote_video_scope_sources_cb (UnityVideoLensRemoteVideoScope* self, SoupSession* session, SoupMessage* msg) {
 
1254
        gint _tmp0_;
 
1255
        guint interval;
 
1256
        SoupMessage* _tmp1_;
 
1257
        guint _tmp2_ = 0U;
 
1258
        guint _tmp3_;
 
1259
        guint _tmp46_;
 
1260
        GError * _inner_error_ = NULL;
 
1261
        g_return_if_fail (self != NULL);
 
1262
        g_return_if_fail (session != NULL);
 
1263
        g_return_if_fail (msg != NULL);
 
1264
        _tmp0_ = unity_video_lens_remote_video_scope_RETRY_INTERVAL;
 
1265
        interval = (guint) _tmp0_;
 
1266
        _tmp1_ = msg;
 
1267
        g_object_get (_tmp1_, "status-code", &_tmp2_, NULL);
 
1268
        _tmp3_ = _tmp2_;
 
1269
        if (_tmp3_ != ((guint) 200)) {
 
1270
                SoupMessage* _tmp4_;
 
1271
                guint _tmp5_ = 0U;
 
1272
                guint _tmp6_;
 
1273
                SoupMessage* _tmp7_;
 
1274
                gchar* _tmp8_ = NULL;
 
1275
                gchar* _tmp9_;
 
1276
                gchar* _tmp10_;
 
1277
                _tmp4_ = msg;
 
1278
                g_object_get (_tmp4_, "status-code", &_tmp5_, NULL);
 
1279
                _tmp6_ = _tmp5_;
 
1280
                _tmp7_ = msg;
 
1281
                g_object_get (_tmp7_, "reason-phrase", &_tmp8_, NULL);
 
1282
                _tmp9_ = _tmp8_;
 
1283
                _tmp10_ = _tmp9_;
 
1284
                g_warning ("remote-scope.vala:257: Unable to query the server for a list of source" \
 
1285
"s, %u: %s", _tmp6_, _tmp10_);
 
1286
                _g_free0 (_tmp10_);
 
1287
        } else {
 
1288
                {
 
1289
                        SoupMessage* _tmp11_;
 
1290
                        SoupMessageBody* _tmp12_;
 
1291
                        guint8* _tmp13_;
 
1292
                        gint _tmp13__length1;
 
1293
                        GeeArrayList* _tmp14_ = NULL;
 
1294
                        GeeArrayList* sources_array;
 
1295
                        GSList* to_remove;
 
1296
                        UnityOptionsFilter* _tmp15_;
 
1297
                        UnityOptionsFilter* _tmp16_;
 
1298
                        GList* _tmp17_;
 
1299
                        GSList* _tmp23_;
 
1300
                        gint _tmp45_;
 
1301
                        _tmp11_ = msg;
 
1302
                        _tmp12_ = _tmp11_->response_body;
 
1303
                        _tmp13_ = _tmp12_->data;
 
1304
                        _tmp13__length1 = (gint) _tmp12_->length;
 
1305
                        _tmp14_ = unity_video_lens_ubuntu_video_search_process_sources_results ((const gchar*) _tmp13_, &_inner_error_);
 
1306
                        sources_array = _tmp14_;
 
1307
                        if (_inner_error_ != NULL) {
 
1308
                                goto __catch5_g_error;
 
1309
                        }
 
1310
                        to_remove = NULL;
 
1311
                        _tmp15_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
1312
                        _tmp16_ = _tmp15_;
 
1313
                        _tmp17_ = _tmp16_->options;
 
1314
                        {
 
1315
                                GList* opt_collection = NULL;
 
1316
                                GList* opt_it = NULL;
 
1317
                                opt_collection = _tmp17_;
 
1318
                                for (opt_it = opt_collection; opt_it != NULL; opt_it = opt_it->next) {
 
1319
                                        UnityFilterOption* _tmp18_;
 
1320
                                        UnityFilterOption* opt = NULL;
 
1321
                                        _tmp18_ = _g_object_ref0 ((UnityFilterOption*) opt_it->data);
 
1322
                                        opt = _tmp18_;
 
1323
                                        {
 
1324
                                                UnityFilterOption* _tmp19_;
 
1325
                                                const gchar* _tmp20_;
 
1326
                                                const gchar* _tmp21_;
 
1327
                                                gchar* _tmp22_;
 
1328
                                                _tmp19_ = opt;
 
1329
                                                _tmp20_ = unity_filter_option_get_id (_tmp19_);
 
1330
                                                _tmp21_ = _tmp20_;
 
1331
                                                _tmp22_ = g_strdup (_tmp21_);
 
1332
                                                to_remove = g_slist_append (to_remove, _tmp22_);
 
1333
                                                _g_object_unref0 (opt);
 
1334
                                        }
 
1335
                                }
 
1336
                        }
 
1337
                        _tmp23_ = to_remove;
 
1338
                        {
 
1339
                                GSList* id_collection = NULL;
 
1340
                                GSList* id_it = NULL;
 
1341
                                id_collection = _tmp23_;
 
1342
                                for (id_it = id_collection; id_it != NULL; id_it = id_it->next) {
 
1343
                                        gchar* _tmp24_;
 
1344
                                        gchar* id = NULL;
 
1345
                                        _tmp24_ = g_strdup ((const gchar*) id_it->data);
 
1346
                                        id = _tmp24_;
 
1347
                                        {
 
1348
                                                UnityOptionsFilter* _tmp25_;
 
1349
                                                UnityOptionsFilter* _tmp26_;
 
1350
                                                const gchar* _tmp27_;
 
1351
                                                _tmp25_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
1352
                                                _tmp26_ = _tmp25_;
 
1353
                                                _tmp27_ = id;
 
1354
                                                unity_options_filter_remove_option (_tmp26_, _tmp27_);
 
1355
                                                _g_free0 (id);
 
1356
                                        }
 
1357
                                }
 
1358
                        }
 
1359
                        {
 
1360
                                GeeArrayList* _tmp28_;
 
1361
                                GeeArrayList* _tmp29_;
 
1362
                                GeeArrayList* _src_list;
 
1363
                                GeeArrayList* _tmp30_;
 
1364
                                gint _tmp31_;
 
1365
                                gint _tmp32_;
 
1366
                                gint _src_size;
 
1367
                                gint _src_index;
 
1368
                                _tmp28_ = sources_array;
 
1369
                                _tmp29_ = _g_object_ref0 (_tmp28_);
 
1370
                                _src_list = _tmp29_;
 
1371
                                _tmp30_ = _src_list;
 
1372
                                _tmp31_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp30_);
 
1373
                                _tmp32_ = _tmp31_;
 
1374
                                _src_size = _tmp32_;
 
1375
                                _src_index = -1;
 
1376
                                while (TRUE) {
 
1377
                                        gint _tmp33_;
 
1378
                                        gint _tmp34_;
 
1379
                                        gint _tmp35_;
 
1380
                                        GeeArrayList* _tmp36_;
 
1381
                                        gint _tmp37_;
 
1382
                                        gpointer _tmp38_ = NULL;
 
1383
                                        gchar* src;
 
1384
                                        UnityOptionsFilter* _tmp39_;
 
1385
                                        UnityOptionsFilter* _tmp40_;
 
1386
                                        const gchar* _tmp41_;
 
1387
                                        const gchar* _tmp42_;
 
1388
                                        UnityFilterOption* _tmp43_ = NULL;
 
1389
                                        UnityFilterOption* _tmp44_;
 
1390
                                        _tmp33_ = _src_index;
 
1391
                                        _src_index = _tmp33_ + 1;
 
1392
                                        _tmp34_ = _src_index;
 
1393
                                        _tmp35_ = _src_size;
 
1394
                                        if (!(_tmp34_ < _tmp35_)) {
 
1395
                                                break;
 
1396
                                        }
 
1397
                                        _tmp36_ = _src_list;
 
1398
                                        _tmp37_ = _src_index;
 
1399
                                        _tmp38_ = gee_abstract_list_get ((GeeAbstractList*) _tmp36_, _tmp37_);
 
1400
                                        src = (gchar*) _tmp38_;
 
1401
                                        _tmp39_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
1402
                                        _tmp40_ = _tmp39_;
 
1403
                                        _tmp41_ = src;
 
1404
                                        _tmp42_ = src;
 
1405
                                        _tmp43_ = unity_options_filter_add_option (_tmp40_, _tmp41_, _tmp42_, NULL);
 
1406
                                        _tmp44_ = _tmp43_;
 
1407
                                        _g_object_unref0 (_tmp44_);
 
1408
                                        _g_free0 (src);
 
1409
                                }
 
1410
                                _g_object_unref0 (_src_list);
 
1411
                        }
 
1412
                        _tmp45_ = unity_video_lens_remote_video_scope_REFRESH_INTERVAL;
 
1413
                        interval = (guint) _tmp45_;
 
1414
                        __g_slist_free__g_free0_0 (to_remove);
 
1415
                        _g_object_unref0 (sources_array);
 
1416
                }
 
1417
                goto __finally5;
 
1418
                __catch5_g_error:
 
1419
                {
 
1420
                        GError* e = NULL;
 
1421
                        e = _inner_error_;
 
1422
                        _inner_error_ = NULL;
 
1423
                        g_warning ("remote-scope.vala:281: Got invalid json from the server");
 
1424
                        _g_error_free0 (e);
 
1425
                }
 
1426
                __finally5:
 
1427
                if (_inner_error_ != NULL) {
 
1428
                        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);
 
1429
                        g_clear_error (&_inner_error_);
 
1430
                        return;
 
1431
                }
 
1432
        }
 
1433
        _tmp46_ = interval;
 
1434
        g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, _tmp46_, ___lambda9__gsource_func, g_object_ref (self), g_object_unref);
 
1435
}
 
1436
 
 
1437
 
 
1438
static void unity_video_lens_remote_video_scope_real_activate_result_data_free (gpointer _data) {
 
1439
        UnityVideoLensRemoteVideoScopeActivateResultData* _data_;
 
1440
        _data_ = _data;
 
1441
        unity_scope_result_destroy (&_data_->_result_);
 
1442
        _g_object_unref0 (_data_->result);
 
1443
        _g_object_unref0 (_data_->self);
 
1444
        g_slice_free (UnityVideoLensRemoteVideoScopeActivateResultData, _data_);
 
1445
}
 
1446
 
 
1447
 
 
1448
static void unity_video_lens_remote_video_scope_real_activate_result (UnityDeprecatedScope* base, UnityScopeResult* _result_, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
1449
        UnityVideoLensRemoteVideoScope * self;
 
1450
        UnityVideoLensRemoteVideoScopeActivateResultData* _data_;
 
1451
        UnityVideoLensRemoteVideoScope* _tmp0_;
 
1452
        UnityScopeResult _tmp1_;
 
1453
        UnityScopeResult _tmp2_ = {0};
 
1454
        self = (UnityVideoLensRemoteVideoScope*) base;
 
1455
        _data_ = g_slice_new0 (UnityVideoLensRemoteVideoScopeActivateResultData);
 
1456
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_video_lens_remote_video_scope_real_activate_result);
 
1457
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_video_lens_remote_video_scope_real_activate_result_data_free);
 
1458
        _tmp0_ = _g_object_ref0 (self);
 
1459
        _data_->self = _tmp0_;
 
1460
        _tmp1_ = *_result_;
 
1461
        unity_scope_result_copy (&_tmp1_, &_tmp2_);
 
1462
        unity_scope_result_destroy (&_data_->_result_);
 
1463
        _data_->_result_ = _tmp2_;
 
1464
        unity_video_lens_remote_video_scope_real_activate_result_co (_data_);
 
1465
}
 
1466
 
 
1467
 
 
1468
static UnityActivationResponse* unity_video_lens_remote_video_scope_real_activate_result_finish (UnityDeprecatedScope* base, GAsyncResult* _res_) {
 
1469
        UnityActivationResponse* result;
 
1470
        UnityVideoLensRemoteVideoScopeActivateResultData* _data_;
 
1471
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
1472
        result = _data_->result;
 
1473
        _data_->result = NULL;
 
1474
        return result;
 
1475
}
 
1476
 
 
1477
 
 
1478
static gpointer _g_variant_ref0 (gpointer self) {
 
1479
        return self ? g_variant_ref (self) : NULL;
 
1480
}
 
1481
 
 
1482
 
 
1483
static void unity_video_lens_remote_video_scope_activate_result_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
 
1484
        UnityVideoLensRemoteVideoScopeActivateResultData* _data_;
 
1485
        _data_ = _user_data_;
 
1486
        _data_->_source_object_ = source_object;
 
1487
        _data_->_res_ = _res_;
 
1488
        unity_video_lens_remote_video_scope_real_activate_result_co (_data_);
 
1489
}
 
1490
 
 
1491
 
 
1492
static gboolean unity_video_lens_remote_video_scope_real_activate_result_co (UnityVideoLensRemoteVideoScopeActivateResultData* _data_) {
 
1493
        switch (_data_->_state_) {
 
1494
                case 0:
 
1495
                goto _state_0;
 
1496
                case 1:
 
1497
                goto _state_1;
 
1498
                default:
 
1499
                g_assert_not_reached ();
 
1500
        }
 
1501
        _state_0:
 
1502
        _data_->_tmp0_ = _data_->_result_;
 
1503
        _data_->_tmp1_ = _data_->_tmp0_.metadata;
 
1504
        _data_->_tmp2_ = unity_video_lens_remote_video_scope_PREVIEW_ON_LMB;
 
1505
        _data_->_tmp3_ = NULL;
 
1506
        _data_->_tmp3_ = g_hash_table_lookup (_data_->_tmp1_, _data_->_tmp2_);
 
1507
        _data_->_tmp4_ = _g_variant_ref0 ((GVariant*) _data_->_tmp3_);
 
1508
        _data_->realcat = _data_->_tmp4_;
 
1509
        _data_->_tmp6_ = _data_->realcat;
 
1510
        if (_data_->_tmp6_ != NULL) {
 
1511
                _data_->_tmp7_ = _data_->realcat;
 
1512
                _data_->_tmp8_ = FALSE;
 
1513
                _data_->_tmp8_ = g_variant_get_boolean (_data_->_tmp7_);
 
1514
                _data_->_tmp5_ = _data_->_tmp8_;
 
1515
        } else {
 
1516
                _data_->_tmp5_ = FALSE;
 
1517
        }
 
1518
        _data_->_tmp9_ = _data_->_tmp5_;
 
1519
        if (_data_->_tmp9_) {
 
1520
                _data_->_tmp10_ = _data_->_result_;
 
1521
                _data_->_state_ = 1;
 
1522
                unity_deprecated_scope_preview_result ((UnityDeprecatedScope*) _data_->self, &_data_->_tmp10_, unity_video_lens_remote_video_scope_activate_result_ready, _data_);
 
1523
                return FALSE;
 
1524
                _state_1:
 
1525
                _data_->_tmp11_ = NULL;
 
1526
                _data_->_tmp11_ = unity_deprecated_scope_preview_result_finish ((UnityDeprecatedScope*) _data_->self, _data_->_res_);
 
1527
                _data_->preview = _data_->_tmp11_;
 
1528
                _data_->_tmp12_ = _data_->preview;
 
1529
                _data_->_tmp13_ = unity_activation_response_new_with_preview (_data_->_tmp12_);
 
1530
                _data_->result = _data_->_tmp13_;
 
1531
                _g_object_unref0 (_data_->preview);
 
1532
                _g_variant_unref0 (_data_->realcat);
 
1533
                if (_data_->_state_ == 0) {
 
1534
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
1535
                } else {
 
1536
                        g_simple_async_result_complete (_data_->_async_result);
 
1537
                }
 
1538
                g_object_unref (_data_->_async_result);
 
1539
                return FALSE;
 
1540
        }
 
1541
        _data_->_tmp14_ = _data_->_result_;
 
1542
        _data_->_tmp15_ = _data_->_tmp14_.uri;
 
1543
        _data_->_tmp16_ = NULL;
 
1544
        _data_->_tmp16_ = unity_video_lens_remote_video_scope_on_activate_uri (_data_->self, _data_->_tmp15_);
 
1545
        _data_->result = _data_->_tmp16_;
 
1546
        _g_variant_unref0 (_data_->realcat);
 
1547
        if (_data_->_state_ == 0) {
 
1548
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
1549
        } else {
 
1550
                g_simple_async_result_complete (_data_->_async_result);
 
1551
        }
 
1552
        g_object_unref (_data_->_async_result);
 
1553
        return FALSE;
 
1554
        _g_variant_unref0 (_data_->realcat);
 
1555
        if (_data_->_state_ == 0) {
 
1556
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
1557
        } else {
 
1558
                g_simple_async_result_complete (_data_->_async_result);
 
1559
        }
 
1560
        g_object_unref (_data_->_async_result);
 
1561
        return FALSE;
 
1562
}
 
1563
 
 
1564
 
 
1565
static UnityActivationResponse* unity_video_lens_remote_video_scope_on_activate_uri (UnityVideoLensRemoteVideoScope* self, const gchar* rawuri) {
 
1566
        UnityActivationResponse* result = NULL;
 
1567
        const gchar* _tmp0_;
 
1568
        UnityVideoLensRemoteUri* _tmp1_ = NULL;
 
1569
        UnityVideoLensRemoteUri* fakeuri;
 
1570
        UnityVideoLensRemoteUri* _tmp2_;
 
1571
        UnityActivationResponse* _tmp23_;
 
1572
        GError * _inner_error_ = NULL;
 
1573
        g_return_val_if_fail (self != NULL, NULL);
 
1574
        g_return_val_if_fail (rawuri != NULL, NULL);
 
1575
        _tmp0_ = rawuri;
 
1576
        _tmp1_ = unity_video_lens_remote_uri_from_rawuri (_tmp0_);
 
1577
        fakeuri = _tmp1_;
 
1578
        _tmp2_ = fakeuri;
 
1579
        if (_tmp2_ != NULL) {
 
1580
                gboolean _tmp3_;
 
1581
                _tmp3_ = self->priv->use_zeitgeist;
 
1582
                if (_tmp3_) {
 
1583
                        UnityVideoLensRemoteUri* _tmp4_;
 
1584
                        const gchar* _tmp5_;
 
1585
                        const gchar* _tmp6_;
 
1586
                        UnityVideoLensRemoteUri* _tmp7_;
 
1587
                        const gchar* _tmp8_;
 
1588
                        const gchar* _tmp9_;
 
1589
                        UnityVideoLensRemoteUri* _tmp10_;
 
1590
                        const gchar* _tmp11_;
 
1591
                        const gchar* _tmp12_;
 
1592
                        _tmp4_ = fakeuri;
 
1593
                        _tmp5_ = unity_video_lens_remote_uri_get_uri (_tmp4_);
 
1594
                        _tmp6_ = _tmp5_;
 
1595
                        _tmp7_ = fakeuri;
 
1596
                        _tmp8_ = unity_video_lens_remote_uri_get_title (_tmp7_);
 
1597
                        _tmp9_ = _tmp8_;
 
1598
                        _tmp10_ = fakeuri;
 
1599
                        _tmp11_ = unity_video_lens_remote_uri_get_icon (_tmp10_);
 
1600
                        _tmp12_ = _tmp11_;
 
1601
                        unity_video_lens_remote_video_scope_zeitgeist_insert_event (self, _tmp6_, _tmp9_, _tmp12_);
 
1602
                }
 
1603
                {
 
1604
                        UnityVideoLensRemoteUri* _tmp13_;
 
1605
                        const gchar* _tmp14_;
 
1606
                        const gchar* _tmp15_;
 
1607
                        UnityActivationResponse* _tmp16_;
 
1608
                        _tmp13_ = fakeuri;
 
1609
                        _tmp14_ = unity_video_lens_remote_uri_get_uri (_tmp13_);
 
1610
                        _tmp15_ = _tmp14_;
 
1611
                        g_app_info_launch_default_for_uri (_tmp15_, NULL, &_inner_error_);
 
1612
                        if (_inner_error_ != NULL) {
 
1613
                                goto __catch6_g_error;
 
1614
                        }
 
1615
                        _tmp16_ = unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, "");
 
1616
                        result = _tmp16_;
 
1617
                        _unity_video_lens_remote_uri_unref0 (fakeuri);
 
1618
                        return result;
 
1619
                }
 
1620
                goto __finally6;
 
1621
                __catch6_g_error:
 
1622
                {
 
1623
                        GError* e = NULL;
 
1624
                        UnityVideoLensRemoteUri* _tmp17_;
 
1625
                        const gchar* _tmp18_;
 
1626
                        const gchar* _tmp19_;
 
1627
                        GError* _tmp20_;
 
1628
                        const gchar* _tmp21_;
 
1629
                        e = _inner_error_;
 
1630
                        _inner_error_ = NULL;
 
1631
                        _tmp17_ = fakeuri;
 
1632
                        _tmp18_ = unity_video_lens_remote_uri_get_uri (_tmp17_);
 
1633
                        _tmp19_ = _tmp18_;
 
1634
                        _tmp20_ = e;
 
1635
                        _tmp21_ = _tmp20_->message;
 
1636
                        g_warning ("remote-scope.vala:317: Failed to launch default application for '%s': " \
 
1637
"%s", _tmp19_, _tmp21_);
 
1638
                        _g_error_free0 (e);
 
1639
                }
 
1640
                __finally6:
 
1641
                if (_inner_error_ != NULL) {
 
1642
                        _unity_video_lens_remote_uri_unref0 (fakeuri);
 
1643
                        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);
 
1644
                        g_clear_error (&_inner_error_);
 
1645
                        return NULL;
 
1646
                }
 
1647
        } else {
 
1648
                const gchar* _tmp22_;
 
1649
                _tmp22_ = rawuri;
 
1650
                g_warning ("remote-scope.vala:322: Invalid raw uri: '%s'", _tmp22_);
 
1651
        }
 
1652
        _tmp23_ = unity_activation_response_new (UNITY_HANDLED_TYPE_NOT_HANDLED, "");
 
1653
        result = _tmp23_;
 
1654
        _unity_video_lens_remote_uri_unref0 (fakeuri);
 
1655
        return result;
 
1656
}
 
1657
 
 
1658
 
 
1659
static UnityActivationResponse* unity_video_lens_remote_video_scope_on_play_video (UnityVideoLensRemoteVideoScope* self, const gchar* rawuri) {
 
1660
        UnityActivationResponse* result = NULL;
 
1661
        const gchar* _tmp0_;
 
1662
        UnityActivationResponse* _tmp1_ = NULL;
 
1663
        g_return_val_if_fail (self != NULL, NULL);
 
1664
        g_return_val_if_fail (rawuri != NULL, NULL);
 
1665
        _tmp0_ = rawuri;
 
1666
        _tmp1_ = unity_video_lens_remote_video_scope_on_activate_uri (self, _tmp0_);
 
1667
        result = _tmp1_;
 
1668
        return result;
 
1669
}
 
1670
 
 
1671
 
 
1672
static glong string_strnlen (gchar* str, glong maxlen) {
 
1673
        glong result = 0L;
 
1674
        gchar* _tmp0_;
 
1675
        glong _tmp1_;
 
1676
        gchar* _tmp2_ = NULL;
 
1677
        gchar* end;
 
1678
        gchar* _tmp3_;
 
1679
        _tmp0_ = str;
 
1680
        _tmp1_ = maxlen;
 
1681
        _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
 
1682
        end = _tmp2_;
 
1683
        _tmp3_ = end;
 
1684
        if (_tmp3_ == NULL) {
 
1685
                glong _tmp4_;
 
1686
                _tmp4_ = maxlen;
 
1687
                result = _tmp4_;
 
1688
                return result;
 
1689
        } else {
 
1690
                gchar* _tmp5_;
 
1691
                gchar* _tmp6_;
 
1692
                _tmp5_ = end;
 
1693
                _tmp6_ = str;
 
1694
                result = (glong) (_tmp5_ - _tmp6_);
 
1695
                return result;
 
1696
        }
 
1697
}
 
1698
 
 
1699
 
 
1700
static gchar* string_substring (const gchar* self, glong offset, glong len) {
 
1701
        gchar* result = NULL;
 
1702
        glong string_length = 0L;
 
1703
        gboolean _tmp0_ = FALSE;
 
1704
        glong _tmp1_;
 
1705
        gboolean _tmp3_;
 
1706
        glong _tmp9_;
 
1707
        glong _tmp15_;
 
1708
        glong _tmp18_;
 
1709
        glong _tmp19_;
 
1710
        glong _tmp20_;
 
1711
        glong _tmp21_;
 
1712
        glong _tmp22_;
 
1713
        gchar* _tmp23_ = NULL;
 
1714
        g_return_val_if_fail (self != NULL, NULL);
 
1715
        _tmp1_ = offset;
 
1716
        if (_tmp1_ >= ((glong) 0)) {
 
1717
                glong _tmp2_;
 
1718
                _tmp2_ = len;
 
1719
                _tmp0_ = _tmp2_ >= ((glong) 0);
 
1720
        } else {
 
1721
                _tmp0_ = FALSE;
 
1722
        }
 
1723
        _tmp3_ = _tmp0_;
 
1724
        if (_tmp3_) {
 
1725
                glong _tmp4_;
 
1726
                glong _tmp5_;
 
1727
                glong _tmp6_ = 0L;
 
1728
                _tmp4_ = offset;
 
1729
                _tmp5_ = len;
 
1730
                _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
 
1731
                string_length = _tmp6_;
 
1732
        } else {
 
1733
                gint _tmp7_;
 
1734
                gint _tmp8_;
 
1735
                _tmp7_ = strlen (self);
 
1736
                _tmp8_ = _tmp7_;
 
1737
                string_length = (glong) _tmp8_;
 
1738
        }
 
1739
        _tmp9_ = offset;
 
1740
        if (_tmp9_ < ((glong) 0)) {
 
1741
                glong _tmp10_;
 
1742
                glong _tmp11_;
 
1743
                glong _tmp12_;
 
1744
                _tmp10_ = string_length;
 
1745
                _tmp11_ = offset;
 
1746
                offset = _tmp10_ + _tmp11_;
 
1747
                _tmp12_ = offset;
 
1748
                g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
 
1749
        } else {
 
1750
                glong _tmp13_;
 
1751
                glong _tmp14_;
 
1752
                _tmp13_ = offset;
 
1753
                _tmp14_ = string_length;
 
1754
                g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
 
1755
        }
 
1756
        _tmp15_ = len;
 
1757
        if (_tmp15_ < ((glong) 0)) {
 
1758
                glong _tmp16_;
 
1759
                glong _tmp17_;
 
1760
                _tmp16_ = string_length;
 
1761
                _tmp17_ = offset;
 
1762
                len = _tmp16_ - _tmp17_;
 
1763
        }
 
1764
        _tmp18_ = offset;
 
1765
        _tmp19_ = len;
 
1766
        _tmp20_ = string_length;
 
1767
        g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
 
1768
        _tmp21_ = offset;
 
1769
        _tmp22_ = len;
 
1770
        _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
 
1771
        result = _tmp23_;
 
1772
        return result;
 
1773
}
 
1774
 
 
1775
 
 
1776
static UnityActivationResponse* _unity_video_lens_remote_video_scope_on_play_video_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self) {
 
1777
        UnityActivationResponse* result;
 
1778
        result = unity_video_lens_remote_video_scope_on_play_video (self, uri);
 
1779
        return result;
 
1780
}
 
1781
 
 
1782
 
 
1783
static UnityPreview* unity_video_lens_remote_video_scope_build_preview (UnityVideoLensRemoteVideoScope* self, UnityVideoLensRemoteUri* uri, UnityVideoLensRemoteVideoDetails* details) {
 
1784
        UnityPreview* result = NULL;
 
1785
        UnityVideoLensRemoteUri* _tmp0_;
 
1786
        const gchar* _tmp1_;
 
1787
        const gchar* _tmp2_;
 
1788
        gchar* _tmp3_;
 
1789
        gchar* title;
 
1790
        gchar* _tmp4_;
 
1791
        gchar* subtitle;
 
1792
        gchar* _tmp5_;
 
1793
        gchar* description;
 
1794
        GFile* song_file = NULL;
 
1795
        guint8* song_data = NULL;
 
1796
        gint song_data_length1 = 0;
 
1797
        gint _song_data_size_ = 0;
 
1798
        gchar* etag_out = NULL;
 
1799
        gchar* _tmp6_;
 
1800
        gchar* content;
 
1801
        UnityVideoLensRemoteUri* _tmp7_;
 
1802
        const gchar* _tmp8_;
 
1803
        const gchar* _tmp9_;
 
1804
        GFile* _tmp10_ = NULL;
 
1805
        guint8* _tmp11_ = NULL;
 
1806
        gsize _tmp12_;
 
1807
        gchar* _tmp13_ = NULL;
 
1808
        gboolean _tmp14_ = FALSE;
 
1809
        gboolean _tmp15_;
 
1810
        const gchar* _tmp17_;
 
1811
        gint _tmp18_ = 0;
 
1812
        gint iIndex;
 
1813
        const gchar* _tmp19_;
 
1814
        gint _tmp20_;
 
1815
        gchar* _tmp21_ = NULL;
 
1816
        gchar* _tmp22_;
 
1817
        gint _tmp23_ = 0;
 
1818
        gint _tmp24_;
 
1819
        gint iEnd;
 
1820
        const gchar* _tmp25_;
 
1821
        gint _tmp26_;
 
1822
        gint _tmp27_;
 
1823
        gchar* _tmp28_ = NULL;
 
1824
        const gchar* _tmp29_;
 
1825
        gchar* _tmp30_;
 
1826
        UnityVideoLensRemoteVideoDetails* _tmp31_;
 
1827
        const gchar* _tmp63_ = NULL;
 
1828
        UnityVideoLensRemoteVideoDetails* _tmp64_;
 
1829
        const gchar* _tmp70_;
 
1830
        GFile* _tmp71_ = NULL;
 
1831
        GFile* _tmp72_;
 
1832
        GFileIcon* _tmp73_;
 
1833
        GIcon* _tmp74_;
 
1834
        GIcon* thumbnail;
 
1835
        const gchar* _tmp75_;
 
1836
        const gchar* _tmp76_;
 
1837
        const gchar* _tmp77_;
 
1838
        GIcon* _tmp78_;
 
1839
        UnityMoviePreview* _tmp79_;
 
1840
        UnityMoviePreview* real_preview;
 
1841
        const gchar* _tmp80_ = NULL;
 
1842
        UnityPreviewAction* _tmp81_;
 
1843
        UnityPreviewAction* play_video;
 
1844
        UnityPreviewAction* _tmp82_;
 
1845
        UnityMoviePreview* _tmp83_;
 
1846
        UnityPreviewAction* _tmp84_;
 
1847
        UnityMoviePreview* _tmp85_;
 
1848
        UnityVideoLensRemoteVideoDetails* _tmp86_;
 
1849
        GError * _inner_error_ = NULL;
 
1850
        g_return_val_if_fail (self != NULL, NULL);
 
1851
        g_return_val_if_fail (uri != NULL, NULL);
 
1852
        _tmp0_ = uri;
 
1853
        _tmp1_ = unity_video_lens_remote_uri_get_title (_tmp0_);
 
1854
        _tmp2_ = _tmp1_;
 
1855
        _tmp3_ = g_strdup (_tmp2_);
 
1856
        title = _tmp3_;
 
1857
        _tmp4_ = g_strdup ("");
 
1858
        subtitle = _tmp4_;
 
1859
        _tmp5_ = g_strdup ("");
 
1860
        description = _tmp5_;
 
1861
        _tmp6_ = g_strdup ("");
 
1862
        content = _tmp6_;
 
1863
        _tmp7_ = uri;
 
1864
        _tmp8_ = unity_video_lens_remote_uri_get_uri (_tmp7_);
 
1865
        _tmp9_ = _tmp8_;
 
1866
        _tmp10_ = g_file_new_for_uri (_tmp9_);
 
1867
        _g_object_unref0 (song_file);
 
1868
        song_file = _tmp10_;
 
1869
        _tmp14_ = g_file_load_contents (song_file, NULL, &_tmp11_, &_tmp12_, &_tmp13_, &_inner_error_);
 
1870
        song_data = (g_free (song_data), NULL);
 
1871
        song_data = _tmp11_;
 
1872
        song_data_length1 = _tmp12_;
 
1873
        _song_data_size_ = song_data_length1;
 
1874
        _g_free0 (etag_out);
 
1875
        etag_out = _tmp13_;
 
1876
        _tmp15_ = _tmp14_;
 
1877
        if (_inner_error_ != NULL) {
 
1878
                _g_free0 (content);
 
1879
                _g_free0 (etag_out);
 
1880
                song_data = (g_free (song_data), NULL);
 
1881
                _g_object_unref0 (song_file);
 
1882
                _g_free0 (description);
 
1883
                _g_free0 (subtitle);
 
1884
                _g_free0 (title);
 
1885
                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);
 
1886
                g_clear_error (&_inner_error_);
 
1887
                return NULL;
 
1888
        }
 
1889
        if (_tmp15_) {
 
1890
                gchar* _tmp16_;
 
1891
                _tmp16_ = g_strdup ((const gchar*) song_data);
 
1892
                _g_free0 (content);
 
1893
                content = _tmp16_;
 
1894
        }
 
1895
        _tmp17_ = content;
 
1896
        _tmp18_ = string_index_of (_tmp17_, "<meta name=\"description\"", 0);
 
1897
        iIndex = _tmp18_;
 
1898
        _tmp19_ = content;
 
1899
        _tmp20_ = iIndex;
 
1900
        _tmp21_ = string_substring (_tmp19_, (glong) _tmp20_, (glong) (-1));
 
1901
        _tmp22_ = _tmp21_;
 
1902
        _tmp23_ = string_index_of (_tmp22_, ">", 0);
 
1903
        _tmp24_ = _tmp23_;
 
1904
        _g_free0 (_tmp22_);
 
1905
        iEnd = _tmp24_;
 
1906
        _tmp25_ = content;
 
1907
        _tmp26_ = iIndex;
 
1908
        _tmp27_ = iEnd;
 
1909
        _tmp28_ = string_substring (_tmp25_, (glong) (_tmp26_ + 34), (glong) (_tmp27_ - 37));
 
1910
        _g_free0 (content);
 
1911
        content = _tmp28_;
 
1912
        _tmp29_ = content;
 
1913
        _tmp30_ = g_strdup (_tmp29_);
 
1914
        _g_free0 (description);
 
1915
        description = _tmp30_;
 
1916
        _tmp31_ = details;
 
1917
        if (_tmp31_ != NULL) {
 
1918
                UnityVideoLensRemoteVideoDetails* _tmp32_;
 
1919
                const gchar* _tmp33_;
 
1920
                gchar* _tmp34_;
 
1921
                UnityVideoLensRemoteVideoDetails* _tmp35_;
 
1922
                const gchar* _tmp36_;
 
1923
                gchar* _tmp37_;
 
1924
                gboolean _tmp38_ = FALSE;
 
1925
                UnityVideoLensRemoteVideoDetails* _tmp39_;
 
1926
                const gchar* _tmp40_;
 
1927
                gboolean _tmp43_;
 
1928
                UnityVideoLensRemoteVideoDetails* _tmp47_;
 
1929
                gint _tmp48_;
 
1930
                _tmp32_ = details;
 
1931
                _tmp33_ = (*_tmp32_).title;
 
1932
                _tmp34_ = g_strdup (_tmp33_);
 
1933
                _g_free0 (title);
 
1934
                title = _tmp34_;
 
1935
                _tmp35_ = details;
 
1936
                _tmp36_ = (*_tmp35_).description;
 
1937
                _tmp37_ = g_strdup (_tmp36_);
 
1938
                _g_free0 (description);
 
1939
                description = _tmp37_;
 
1940
                _tmp39_ = details;
 
1941
                _tmp40_ = (*_tmp39_).release_date;
 
1942
                if (_tmp40_ != NULL) {
 
1943
                        UnityVideoLensRemoteVideoDetails* _tmp41_;
 
1944
                        const gchar* _tmp42_;
 
1945
                        _tmp41_ = details;
 
1946
                        _tmp42_ = (*_tmp41_).release_date;
 
1947
                        _tmp38_ = g_strcmp0 (_tmp42_, "") != 0;
 
1948
                } else {
 
1949
                        _tmp38_ = FALSE;
 
1950
                }
 
1951
                _tmp43_ = _tmp38_;
 
1952
                if (_tmp43_) {
 
1953
                        UnityVideoLensRemoteVideoDetails* _tmp44_;
 
1954
                        const gchar* _tmp45_;
 
1955
                        gchar* _tmp46_;
 
1956
                        _tmp44_ = details;
 
1957
                        _tmp45_ = (*_tmp44_).release_date;
 
1958
                        _tmp46_ = g_strdup (_tmp45_);
 
1959
                        _g_free0 (subtitle);
 
1960
                        subtitle = _tmp46_;
 
1961
                }
 
1962
                _tmp47_ = details;
 
1963
                _tmp48_ = (*_tmp47_).duration;
 
1964
                if (_tmp48_ > 0) {
 
1965
                        UnityVideoLensRemoteVideoDetails* _tmp49_;
 
1966
                        gint _tmp50_;
 
1967
                        const gchar* _tmp51_ = NULL;
 
1968
                        UnityVideoLensRemoteVideoDetails* _tmp52_;
 
1969
                        gint _tmp53_;
 
1970
                        gchar* _tmp54_ = NULL;
 
1971
                        gchar* duration;
 
1972
                        const gchar* _tmp55_;
 
1973
                        _tmp49_ = details;
 
1974
                        _tmp50_ = (*_tmp49_).duration;
 
1975
                        _tmp51_ = ngettext ("%d min", "%d mins", (gulong) _tmp50_);
 
1976
                        _tmp52_ = details;
 
1977
                        _tmp53_ = (*_tmp52_).duration;
 
1978
                        _tmp54_ = g_strdup_printf (_tmp51_, _tmp53_);
 
1979
                        duration = _tmp54_;
 
1980
                        _tmp55_ = subtitle;
 
1981
                        if (g_strcmp0 (_tmp55_, "") != 0) {
 
1982
                                const gchar* _tmp56_;
 
1983
                                const gchar* _tmp57_;
 
1984
                                gchar* _tmp58_;
 
1985
                                gchar* _tmp59_;
 
1986
                                gchar* _tmp60_;
 
1987
                                _tmp56_ = subtitle;
 
1988
                                _tmp57_ = duration;
 
1989
                                _tmp58_ = g_strconcat (", ", _tmp57_, NULL);
 
1990
                                _tmp59_ = _tmp58_;
 
1991
                                _tmp60_ = g_strconcat (_tmp56_, _tmp59_, NULL);
 
1992
                                _g_free0 (subtitle);
 
1993
                                subtitle = _tmp60_;
 
1994
                                _g_free0 (_tmp59_);
 
1995
                        } else {
 
1996
                                const gchar* _tmp61_;
 
1997
                                gchar* _tmp62_;
 
1998
                                _tmp61_ = duration;
 
1999
                                _tmp62_ = g_strdup (_tmp61_);
 
2000
                                _g_free0 (subtitle);
 
2001
                                subtitle = _tmp62_;
 
2002
                        }
 
2003
                        _g_free0 (duration);
 
2004
                }
 
2005
        }
 
2006
        _tmp64_ = details;
 
2007
        if (_tmp64_ != NULL) {
 
2008
                UnityVideoLensRemoteVideoDetails* _tmp65_;
 
2009
                const gchar* _tmp66_;
 
2010
                _tmp65_ = details;
 
2011
                _tmp66_ = (*_tmp65_).image;
 
2012
                _tmp63_ = _tmp66_;
 
2013
        } else {
 
2014
                UnityVideoLensRemoteUri* _tmp67_;
 
2015
                const gchar* _tmp68_;
 
2016
                const gchar* _tmp69_;
 
2017
                _tmp67_ = uri;
 
2018
                _tmp68_ = unity_video_lens_remote_uri_get_icon (_tmp67_);
 
2019
                _tmp69_ = _tmp68_;
 
2020
                _tmp63_ = _tmp69_;
 
2021
        }
 
2022
        _tmp70_ = _tmp63_;
 
2023
        _tmp71_ = g_file_new_for_uri (_tmp70_);
 
2024
        _tmp72_ = _tmp71_;
 
2025
        _tmp73_ = (GFileIcon*) g_file_icon_new (_tmp72_);
 
2026
        _tmp74_ = (GIcon*) _tmp73_;
 
2027
        _g_object_unref0 (_tmp72_);
 
2028
        thumbnail = _tmp74_;
 
2029
        _tmp75_ = title;
 
2030
        _tmp76_ = subtitle;
 
2031
        _tmp77_ = description;
 
2032
        _tmp78_ = thumbnail;
 
2033
        _tmp79_ = unity_movie_preview_new (_tmp75_, _tmp76_, _tmp77_, _tmp78_);
 
2034
        real_preview = _tmp79_;
 
2035
        _tmp80_ = _ ("Play");
 
2036
        _tmp81_ = unity_preview_action_new ("play", _tmp80_, NULL);
 
2037
        play_video = _tmp81_;
 
2038
        _tmp82_ = play_video;
 
2039
        g_signal_connect_object (_tmp82_, "activated", (GCallback) _unity_video_lens_remote_video_scope_on_play_video_unity_preview_action_activated, self, 0);
 
2040
        _tmp83_ = real_preview;
 
2041
        _tmp84_ = play_video;
 
2042
        unity_preview_add_action ((UnityPreview*) _tmp83_, _tmp84_);
 
2043
        _tmp85_ = real_preview;
 
2044
        unity_movie_preview_set_rating (_tmp85_, (gfloat) (-1), (guint) 0);
 
2045
        _tmp86_ = details;
 
2046
        if (_tmp86_ != NULL) {
 
2047
                UnityVideoLensRemoteVideoDetails* _tmp87_;
 
2048
                gchar** _tmp88_;
 
2049
                gint _tmp88__length1;
 
2050
                gboolean _tmp99_ = FALSE;
 
2051
                UnityVideoLensRemoteVideoDetails* _tmp100_;
 
2052
                const gchar* _tmp101_;
 
2053
                gboolean _tmp104_;
 
2054
                gboolean _tmp111_ = FALSE;
 
2055
                UnityVideoLensRemoteVideoDetails* _tmp112_;
 
2056
                gchar** _tmp113_;
 
2057
                gint _tmp113__length1;
 
2058
                gboolean _tmp116_;
 
2059
                gboolean _tmp127_ = FALSE;
 
2060
                UnityVideoLensRemoteVideoDetails* _tmp128_;
 
2061
                const gchar* _tmp129_;
 
2062
                gboolean _tmp132_;
 
2063
                gboolean _tmp139_ = FALSE;
 
2064
                UnityVideoLensRemoteVideoDetails* _tmp140_;
 
2065
                const gchar* _tmp141_;
 
2066
                gboolean _tmp144_;
 
2067
                _tmp87_ = details;
 
2068
                _tmp88_ = (*_tmp87_).directors;
 
2069
                _tmp88__length1 = (*_tmp87_).directors_length1;
 
2070
                if (_tmp88__length1 > 0) {
 
2071
                        UnityMoviePreview* _tmp89_;
 
2072
                        UnityVideoLensRemoteVideoDetails* _tmp90_;
 
2073
                        gchar** _tmp91_;
 
2074
                        gint _tmp91__length1;
 
2075
                        const gchar* _tmp92_ = NULL;
 
2076
                        UnityVideoLensRemoteVideoDetails* _tmp93_;
 
2077
                        gchar** _tmp94_;
 
2078
                        gint _tmp94__length1;
 
2079
                        gchar* _tmp95_ = NULL;
 
2080
                        gchar* _tmp96_;
 
2081
                        UnityInfoHint* _tmp97_;
 
2082
                        UnityInfoHint* _tmp98_;
 
2083
                        _tmp89_ = real_preview;
 
2084
                        _tmp90_ = details;
 
2085
                        _tmp91_ = (*_tmp90_).directors;
 
2086
                        _tmp91__length1 = (*_tmp90_).directors_length1;
 
2087
                        _tmp92_ = ngettext ("Director", "Directors", (gulong) _tmp91__length1);
 
2088
                        _tmp93_ = details;
 
2089
                        _tmp94_ = (*_tmp93_).directors;
 
2090
                        _tmp94__length1 = (*_tmp93_).directors_length1;
 
2091
                        _tmp95_ = g_strjoinv (", ", _tmp94_);
 
2092
                        _tmp96_ = _tmp95_;
 
2093
                        _tmp97_ = unity_info_hint_new ("directors", _tmp92_, NULL, _tmp96_);
 
2094
                        g_object_ref_sink (_tmp97_);
 
2095
                        _tmp98_ = _tmp97_;
 
2096
                        unity_preview_add_info ((UnityPreview*) _tmp89_, _tmp98_);
 
2097
                        _g_object_unref0 (_tmp98_);
 
2098
                        _g_free0 (_tmp96_);
 
2099
                }
 
2100
                _tmp100_ = details;
 
2101
                _tmp101_ = (*_tmp100_).starring;
 
2102
                if (_tmp101_ != NULL) {
 
2103
                        UnityVideoLensRemoteVideoDetails* _tmp102_;
 
2104
                        const gchar* _tmp103_;
 
2105
                        _tmp102_ = details;
 
2106
                        _tmp103_ = (*_tmp102_).starring;
 
2107
                        _tmp99_ = g_strcmp0 (_tmp103_, "") != 0;
 
2108
                } else {
 
2109
                        _tmp99_ = FALSE;
 
2110
                }
 
2111
                _tmp104_ = _tmp99_;
 
2112
                if (_tmp104_) {
 
2113
                        UnityMoviePreview* _tmp105_;
 
2114
                        const gchar* _tmp106_ = NULL;
 
2115
                        UnityVideoLensRemoteVideoDetails* _tmp107_;
 
2116
                        const gchar* _tmp108_;
 
2117
                        UnityInfoHint* _tmp109_;
 
2118
                        UnityInfoHint* _tmp110_;
 
2119
                        _tmp105_ = real_preview;
 
2120
                        _tmp106_ = _ ("Cast");
 
2121
                        _tmp107_ = details;
 
2122
                        _tmp108_ = (*_tmp107_).starring;
 
2123
                        _tmp109_ = unity_info_hint_new ("cast", _tmp106_, NULL, _tmp108_);
 
2124
                        g_object_ref_sink (_tmp109_);
 
2125
                        _tmp110_ = _tmp109_;
 
2126
                        unity_preview_add_info ((UnityPreview*) _tmp105_, _tmp110_);
 
2127
                        _g_object_unref0 (_tmp110_);
 
2128
                }
 
2129
                _tmp112_ = details;
 
2130
                _tmp113_ = (*_tmp112_).genres;
 
2131
                _tmp113__length1 = (*_tmp112_).genres_length1;
 
2132
                if (_tmp113_ != NULL) {
 
2133
                        UnityVideoLensRemoteVideoDetails* _tmp114_;
 
2134
                        gchar** _tmp115_;
 
2135
                        gint _tmp115__length1;
 
2136
                        _tmp114_ = details;
 
2137
                        _tmp115_ = (*_tmp114_).genres;
 
2138
                        _tmp115__length1 = (*_tmp114_).genres_length1;
 
2139
                        _tmp111_ = _tmp115__length1 > 0;
 
2140
                } else {
 
2141
                        _tmp111_ = FALSE;
 
2142
                }
 
2143
                _tmp116_ = _tmp111_;
 
2144
                if (_tmp116_) {
 
2145
                        UnityMoviePreview* _tmp117_;
 
2146
                        UnityVideoLensRemoteVideoDetails* _tmp118_;
 
2147
                        gchar** _tmp119_;
 
2148
                        gint _tmp119__length1;
 
2149
                        const gchar* _tmp120_ = NULL;
 
2150
                        UnityVideoLensRemoteVideoDetails* _tmp121_;
 
2151
                        gchar** _tmp122_;
 
2152
                        gint _tmp122__length1;
 
2153
                        gchar* _tmp123_ = NULL;
 
2154
                        gchar* _tmp124_;
 
2155
                        UnityInfoHint* _tmp125_;
 
2156
                        UnityInfoHint* _tmp126_;
 
2157
                        _tmp117_ = real_preview;
 
2158
                        _tmp118_ = details;
 
2159
                        _tmp119_ = (*_tmp118_).genres;
 
2160
                        _tmp119__length1 = (*_tmp118_).genres_length1;
 
2161
                        _tmp120_ = ngettext ("Genre", "Genres", (gulong) _tmp119__length1);
 
2162
                        _tmp121_ = details;
 
2163
                        _tmp122_ = (*_tmp121_).genres;
 
2164
                        _tmp122__length1 = (*_tmp121_).genres_length1;
 
2165
                        _tmp123_ = g_strjoinv (", ", _tmp122_);
 
2166
                        _tmp124_ = _tmp123_;
 
2167
                        _tmp125_ = unity_info_hint_new ("genres", _tmp120_, NULL, _tmp124_);
 
2168
                        g_object_ref_sink (_tmp125_);
 
2169
                        _tmp126_ = _tmp125_;
 
2170
                        unity_preview_add_info ((UnityPreview*) _tmp117_, _tmp126_);
 
2171
                        _g_object_unref0 (_tmp126_);
 
2172
                        _g_free0 (_tmp124_);
 
2173
                }
 
2174
                _tmp128_ = details;
 
2175
                _tmp129_ = (*_tmp128_).uploaded_by;
 
2176
                if (_tmp129_ != NULL) {
 
2177
                        UnityVideoLensRemoteVideoDetails* _tmp130_;
 
2178
                        const gchar* _tmp131_;
 
2179
                        _tmp130_ = details;
 
2180
                        _tmp131_ = (*_tmp130_).uploaded_by;
 
2181
                        _tmp127_ = g_strcmp0 (_tmp131_, "") != 0;
 
2182
                } else {
 
2183
                        _tmp127_ = FALSE;
 
2184
                }
 
2185
                _tmp132_ = _tmp127_;
 
2186
                if (_tmp132_) {
 
2187
                        UnityMoviePreview* _tmp133_;
 
2188
                        const gchar* _tmp134_ = NULL;
 
2189
                        UnityVideoLensRemoteVideoDetails* _tmp135_;
 
2190
                        const gchar* _tmp136_;
 
2191
                        UnityInfoHint* _tmp137_;
 
2192
                        UnityInfoHint* _tmp138_;
 
2193
                        _tmp133_ = real_preview;
 
2194
                        _tmp134_ = _ ("Uploaded by");
 
2195
                        _tmp135_ = details;
 
2196
                        _tmp136_ = (*_tmp135_).uploaded_by;
 
2197
                        _tmp137_ = unity_info_hint_new ("uploaded-by", _tmp134_, NULL, _tmp136_);
 
2198
                        g_object_ref_sink (_tmp137_);
 
2199
                        _tmp138_ = _tmp137_;
 
2200
                        unity_preview_add_info ((UnityPreview*) _tmp133_, _tmp138_);
 
2201
                        _g_object_unref0 (_tmp138_);
 
2202
                }
 
2203
                _tmp140_ = details;
 
2204
                _tmp141_ = (*_tmp140_).date_uploaded;
 
2205
                if (_tmp141_ != NULL) {
 
2206
                        UnityVideoLensRemoteVideoDetails* _tmp142_;
 
2207
                        const gchar* _tmp143_;
 
2208
                        _tmp142_ = details;
 
2209
                        _tmp143_ = (*_tmp142_).date_uploaded;
 
2210
                        _tmp139_ = g_strcmp0 (_tmp143_, "") != 0;
 
2211
                } else {
 
2212
                        _tmp139_ = FALSE;
 
2213
                }
 
2214
                _tmp144_ = _tmp139_;
 
2215
                if (_tmp144_) {
 
2216
                        UnityMoviePreview* _tmp145_;
 
2217
                        const gchar* _tmp146_ = NULL;
 
2218
                        UnityVideoLensRemoteVideoDetails* _tmp147_;
 
2219
                        const gchar* _tmp148_;
 
2220
                        UnityInfoHint* _tmp149_;
 
2221
                        UnityInfoHint* _tmp150_;
 
2222
                        _tmp145_ = real_preview;
 
2223
                        _tmp146_ = _ ("Uploaded on");
 
2224
                        _tmp147_ = details;
 
2225
                        _tmp148_ = (*_tmp147_).date_uploaded;
 
2226
                        _tmp149_ = unity_info_hint_new ("uploaded-on", _tmp146_, NULL, _tmp148_);
 
2227
                        g_object_ref_sink (_tmp149_);
 
2228
                        _tmp150_ = _tmp149_;
 
2229
                        unity_preview_add_info ((UnityPreview*) _tmp145_, _tmp150_);
 
2230
                        _g_object_unref0 (_tmp150_);
 
2231
                }
 
2232
        }
 
2233
        result = (UnityPreview*) real_preview;
 
2234
        _g_object_unref0 (play_video);
 
2235
        _g_object_unref0 (thumbnail);
 
2236
        _g_free0 (content);
 
2237
        _g_free0 (etag_out);
 
2238
        song_data = (g_free (song_data), NULL);
 
2239
        _g_object_unref0 (song_file);
 
2240
        _g_free0 (description);
 
2241
        _g_free0 (subtitle);
 
2242
        _g_free0 (title);
 
2243
        return result;
 
2244
}
 
2245
 
 
2246
 
 
2247
static void unity_video_lens_remote_video_scope_real_preview_result_data_free (gpointer _data) {
 
2248
        UnityVideoLensRemoteVideoScopePreviewResultData* _data_;
 
2249
        _data_ = _data;
 
2250
        unity_scope_result_destroy (&_data_->_result_);
 
2251
        _g_object_unref0 (_data_->result);
 
2252
        _g_object_unref0 (_data_->self);
 
2253
        g_slice_free (UnityVideoLensRemoteVideoScopePreviewResultData, _data_);
 
2254
}
 
2255
 
 
2256
 
 
2257
static void unity_video_lens_remote_video_scope_real_preview_result (UnityDeprecatedScope* base, UnityScopeResult* _result_, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
2258
        UnityVideoLensRemoteVideoScope * self;
 
2259
        UnityVideoLensRemoteVideoScopePreviewResultData* _data_;
 
2260
        UnityVideoLensRemoteVideoScope* _tmp0_;
 
2261
        UnityScopeResult _tmp1_;
 
2262
        UnityScopeResult _tmp2_ = {0};
 
2263
        self = (UnityVideoLensRemoteVideoScope*) base;
 
2264
        _data_ = g_slice_new0 (UnityVideoLensRemoteVideoScopePreviewResultData);
 
2265
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_video_lens_remote_video_scope_real_preview_result);
 
2266
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_video_lens_remote_video_scope_real_preview_result_data_free);
 
2267
        _tmp0_ = _g_object_ref0 (self);
 
2268
        _data_->self = _tmp0_;
 
2269
        _tmp1_ = *_result_;
 
2270
        unity_scope_result_copy (&_tmp1_, &_tmp2_);
 
2271
        unity_scope_result_destroy (&_data_->_result_);
 
2272
        _data_->_result_ = _tmp2_;
 
2273
        unity_video_lens_remote_video_scope_real_preview_result_co (_data_);
 
2274
}
 
2275
 
 
2276
 
 
2277
static UnityPreview* unity_video_lens_remote_video_scope_real_preview_result_finish (UnityDeprecatedScope* base, GAsyncResult* _res_) {
 
2278
        UnityPreview* result;
 
2279
        UnityVideoLensRemoteVideoScopePreviewResultData* _data_;
 
2280
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
2281
        result = _data_->result;
 
2282
        _data_->result = NULL;
 
2283
        return result;
 
2284
}
 
2285
 
 
2286
 
 
2287
static void unity_video_lens_remote_video_scope_preview_result_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
 
2288
        UnityVideoLensRemoteVideoScopePreviewResultData* _data_;
 
2289
        _data_ = _user_data_;
 
2290
        _data_->_source_object_ = source_object;
 
2291
        _data_->_res_ = _res_;
 
2292
        unity_video_lens_remote_video_scope_real_preview_result_co (_data_);
 
2293
}
 
2294
 
 
2295
 
 
2296
static gboolean unity_video_lens_remote_video_scope_real_preview_result_co (UnityVideoLensRemoteVideoScopePreviewResultData* _data_) {
 
2297
        switch (_data_->_state_) {
 
2298
                case 0:
 
2299
                goto _state_0;
 
2300
                case 1:
 
2301
                goto _state_1;
 
2302
                default:
 
2303
                g_assert_not_reached ();
 
2304
        }
 
2305
        _state_0:
 
2306
        _data_->_tmp0_ = _data_->_result_;
 
2307
        _data_->_tmp1_ = _data_->_tmp0_.uri;
 
2308
        _data_->_tmp2_ = NULL;
 
2309
        _data_->_tmp2_ = unity_video_lens_remote_uri_from_rawuri (_data_->_tmp1_);
 
2310
        _data_->fakeuri = _data_->_tmp2_;
 
2311
        _data_->_tmp3_ = _data_->fakeuri;
 
2312
        if (_data_->_tmp3_ != NULL) {
 
2313
                _data_->details = NULL;
 
2314
                _data_->_tmp5_ = _data_->fakeuri;
 
2315
                _data_->_tmp6_ = unity_video_lens_remote_uri_get_details_uri (_data_->_tmp5_);
 
2316
                _data_->_tmp7_ = _data_->_tmp6_;
 
2317
                if (_data_->_tmp7_ != NULL) {
 
2318
                        _data_->_tmp8_ = _data_->fakeuri;
 
2319
                        _data_->_tmp9_ = unity_video_lens_remote_uri_get_details_uri (_data_->_tmp8_);
 
2320
                        _data_->_tmp10_ = _data_->_tmp9_;
 
2321
                        _data_->_tmp4_ = g_strcmp0 (_data_->_tmp10_, "") != 0;
 
2322
                } else {
 
2323
                        _data_->_tmp4_ = FALSE;
 
2324
                }
 
2325
                _data_->_tmp11_ = _data_->_tmp4_;
 
2326
                if (_data_->_tmp11_) {
 
2327
                        {
 
2328
                                _data_->_tmp12_ = _data_->fakeuri;
 
2329
                                _data_->_tmp13_ = unity_video_lens_remote_uri_get_uri (_data_->_tmp12_);
 
2330
                                _data_->_tmp14_ = _data_->_tmp13_;
 
2331
                                _data_->_state_ = 1;
 
2332
                                unity_video_lens_remote_video_scope_get_details (_data_->self, _data_->_tmp14_, unity_video_lens_remote_video_scope_preview_result_ready, _data_);
 
2333
                                return FALSE;
 
2334
                                _state_1:
 
2335
                                _data_->_tmp15_ = NULL;
 
2336
                                _data_->_tmp15_ = unity_video_lens_remote_video_scope_get_details_finish (_data_->self, _data_->_res_, &_data_->_inner_error_);
 
2337
                                _data_->_tmp16_ = _data_->_tmp15_;
 
2338
                                if (_data_->_inner_error_ != NULL) {
 
2339
                                        goto __catch7_g_error;
 
2340
                                }
 
2341
                                _unity_video_lens_remote_video_details_free0 (_data_->details);
 
2342
                                _data_->details = _data_->_tmp16_;
 
2343
                        }
 
2344
                        goto __finally7;
 
2345
                        __catch7_g_error:
 
2346
                        {
 
2347
                                _data_->e = _data_->_inner_error_;
 
2348
                                _data_->_inner_error_ = NULL;
 
2349
                                _data_->_tmp17_ = _data_->e;
 
2350
                                _data_->_tmp18_ = _data_->_tmp17_->message;
 
2351
                                g_warning ("remote-scope.vala:420: Failed to fetch video details: %s", _data_->_tmp18_);
 
2352
                                _g_error_free0 (_data_->e);
 
2353
                        }
 
2354
                        __finally7:
 
2355
                        if (_data_->_inner_error_ != NULL) {
 
2356
                                _unity_video_lens_remote_video_details_free0 (_data_->details);
 
2357
                                _unity_video_lens_remote_uri_unref0 (_data_->fakeuri);
 
2358
                                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);
 
2359
                                g_clear_error (&_data_->_inner_error_);
 
2360
                                return FALSE;
 
2361
                        }
 
2362
                }
 
2363
                _data_->_tmp19_ = _data_->fakeuri;
 
2364
                _data_->_tmp20_ = _data_->details;
 
2365
                _data_->_tmp21_ = NULL;
 
2366
                _data_->_tmp21_ = unity_video_lens_remote_video_scope_build_preview (_data_->self, _data_->_tmp19_, _data_->_tmp20_);
 
2367
                _data_->result = _data_->_tmp21_;
 
2368
                _unity_video_lens_remote_video_details_free0 (_data_->details);
 
2369
                _unity_video_lens_remote_uri_unref0 (_data_->fakeuri);
 
2370
                if (_data_->_state_ == 0) {
 
2371
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2372
                } else {
 
2373
                        g_simple_async_result_complete (_data_->_async_result);
 
2374
                }
 
2375
                g_object_unref (_data_->_async_result);
 
2376
                return FALSE;
 
2377
        } else {
 
2378
                _data_->_tmp22_ = _data_->_result_;
 
2379
                _data_->_tmp23_ = _data_->_tmp22_.uri;
 
2380
                g_warning ("remote-scope.vala:428: Invalid raw uri: '%s'", _data_->_tmp23_);
 
2381
        }
 
2382
        _data_->result = NULL;
 
2383
        _unity_video_lens_remote_uri_unref0 (_data_->fakeuri);
 
2384
        if (_data_->_state_ == 0) {
 
2385
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2386
        } else {
 
2387
                g_simple_async_result_complete (_data_->_async_result);
 
2388
        }
 
2389
        g_object_unref (_data_->_async_result);
 
2390
        return FALSE;
 
2391
        _unity_video_lens_remote_uri_unref0 (_data_->fakeuri);
 
2392
        if (_data_->_state_ == 0) {
 
2393
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2394
        } else {
 
2395
                g_simple_async_result_complete (_data_->_async_result);
 
2396
        }
 
2397
        g_object_unref (_data_->_async_result);
 
2398
        return FALSE;
 
2399
}
 
2400
 
 
2401
 
 
2402
static void unity_video_lens_remote_video_scope_get_details_data_free (gpointer _data) {
 
2403
        UnityVideoLensRemoteVideoScopeGetDetailsData* _data_;
 
2404
        _data_ = _data;
 
2405
        _g_free0 (_data_->url);
 
2406
        _unity_video_lens_remote_video_details_free0 (_data_->result);
 
2407
        _g_object_unref0 (_data_->self);
 
2408
        g_slice_free (UnityVideoLensRemoteVideoScopeGetDetailsData, _data_);
 
2409
}
 
2410
 
 
2411
 
 
2412
static void unity_video_lens_remote_video_scope_get_details (UnityVideoLensRemoteVideoScope* self, const gchar* url, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
2413
        UnityVideoLensRemoteVideoScopeGetDetailsData* _data_;
 
2414
        UnityVideoLensRemoteVideoScope* _tmp0_;
 
2415
        const gchar* _tmp1_;
 
2416
        gchar* _tmp2_;
 
2417
        _data_ = g_slice_new0 (UnityVideoLensRemoteVideoScopeGetDetailsData);
 
2418
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_video_lens_remote_video_scope_get_details);
 
2419
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_video_lens_remote_video_scope_get_details_data_free);
 
2420
        _tmp0_ = _g_object_ref0 (self);
 
2421
        _data_->self = _tmp0_;
 
2422
        _tmp1_ = url;
 
2423
        _tmp2_ = g_strdup (_tmp1_);
 
2424
        _g_free0 (_data_->url);
 
2425
        _data_->url = _tmp2_;
 
2426
        unity_video_lens_remote_video_scope_get_details_co (_data_);
 
2427
}
 
2428
 
 
2429
 
 
2430
static UnityVideoLensRemoteVideoDetails* unity_video_lens_remote_video_scope_get_details_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_, GError** error) {
 
2431
        UnityVideoLensRemoteVideoDetails* result;
 
2432
        UnityVideoLensRemoteVideoScopeGetDetailsData* _data_;
 
2433
        if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
 
2434
                return NULL;
 
2435
        }
 
2436
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
2437
        result = _data_->result;
 
2438
        _data_->result = NULL;
 
2439
        return result;
 
2440
}
 
2441
 
 
2442
 
 
2443
static Block1Data* block1_data_ref (Block1Data* _data1_) {
 
2444
        g_atomic_int_inc (&_data1_->_ref_count_);
 
2445
        return _data1_;
 
2446
}
 
2447
 
 
2448
 
 
2449
static void block1_data_unref (void * _userdata_) {
 
2450
        Block1Data* _data1_;
 
2451
        _data1_ = (Block1Data*) _userdata_;
 
2452
        if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
 
2453
                UnityVideoLensRemoteVideoScope * self;
 
2454
                self = _data1_->self;
 
2455
                _g_object_unref0 (_data1_->msg);
 
2456
                _g_object_unref0 (self);
 
2457
                g_slice_free (Block1Data, _data1_);
 
2458
        }
 
2459
}
 
2460
 
 
2461
 
 
2462
static void __lambda11_ (Block1Data* _data1_, SoupSession* session_, SoupMessage* msg_) {
 
2463
        UnityVideoLensRemoteVideoScope * self;
 
2464
        SoupMessage* _tmp0_;
 
2465
        SoupMessage* _tmp1_;
 
2466
        self = _data1_->self;
 
2467
        g_return_if_fail (session_ != NULL);
 
2468
        g_return_if_fail (msg_ != NULL);
 
2469
        _tmp0_ = msg_;
 
2470
        _tmp1_ = _g_object_ref0 (_tmp0_);
 
2471
        _g_object_unref0 (_data1_->msg);
 
2472
        _data1_->msg = _tmp1_;
 
2473
        unity_video_lens_remote_video_scope_get_details_co (_data1_->_async_data_);
 
2474
}
 
2475
 
 
2476
 
 
2477
static void ___lambda11__soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self) {
 
2478
        __lambda11_ (self, session, msg);
 
2479
}
 
2480
 
 
2481
 
 
2482
static gpointer _unity_video_lens_remote_video_details_dup0 (gpointer self) {
 
2483
        return self ? unity_video_lens_remote_video_details_dup (self) : NULL;
 
2484
}
 
2485
 
 
2486
 
 
2487
static gboolean unity_video_lens_remote_video_scope_get_details_co (UnityVideoLensRemoteVideoScopeGetDetailsData* _data_) {
 
2488
        switch (_data_->_state_) {
 
2489
                case 0:
 
2490
                goto _state_0;
 
2491
                case 1:
 
2492
                goto _state_1;
 
2493
                default:
 
2494
                g_assert_not_reached ();
 
2495
        }
 
2496
        _state_0:
 
2497
        _data_->_data1_ = g_slice_new0 (Block1Data);
 
2498
        _data_->_data1_->_ref_count_ = 1;
 
2499
        _data_->_data1_->self = g_object_ref (_data_->self);
 
2500
        _data_->_data1_->_async_data_ = _data_;
 
2501
        _data_->_tmp0_ = _data_->url;
 
2502
        _data_->_tmp1_ = soup_message_new ("GET", _data_->_tmp0_);
 
2503
        _data_->_data1_->msg = _data_->_tmp1_;
 
2504
        _data_->_tmp2_ = _data_->self->priv->session;
 
2505
        _data_->_tmp3_ = _data_->_data1_->msg;
 
2506
        _data_->_tmp4_ = _g_object_ref0 (_data_->_tmp3_);
 
2507
        soup_session_queue_message (_data_->_tmp2_, _data_->_tmp4_, ___lambda11__soup_session_callback, _data_->_data1_);
 
2508
        _data_->_state_ = 1;
 
2509
        return FALSE;
 
2510
        _state_1:
 
2511
        ;
 
2512
        _data_->_tmp5_ = _data_->_data1_->msg;
 
2513
        _data_->_tmp6_ = 0U;
 
2514
        g_object_get (_data_->_tmp5_, "status-code", &_data_->_tmp6_, NULL);
 
2515
        _data_->_tmp7_ = _data_->_tmp6_;
 
2516
        if (_data_->_tmp7_ != ((guint) 200)) {
 
2517
                _data_->_tmp8_ = _data_->_data1_->msg;
 
2518
                _data_->_tmp9_ = 0U;
 
2519
                g_object_get (_data_->_tmp8_, "status-code", &_data_->_tmp9_, NULL);
 
2520
                _data_->_tmp10_ = _data_->_tmp9_;
 
2521
                _data_->_tmp11_ = _data_->_data1_->msg;
 
2522
                _data_->_tmp12_ = NULL;
 
2523
                g_object_get (_data_->_tmp11_, "reason-phrase", &_data_->_tmp12_, NULL);
 
2524
                _data_->_tmp13_ = _data_->_tmp12_;
 
2525
                _data_->_tmp14_ = _data_->_tmp13_;
 
2526
                g_warning ("remote-scope.vala:446: Unable to get details from the server: %u, %s", _data_->_tmp10_, _data_->_tmp14_);
 
2527
                _g_free0 (_data_->_tmp14_);
 
2528
                _data_->result = NULL;
 
2529
                block1_data_unref (_data_->_data1_);
 
2530
                _data_->_data1_ = NULL;
 
2531
                if (_data_->_state_ == 0) {
 
2532
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2533
                } else {
 
2534
                        g_simple_async_result_complete (_data_->_async_result);
 
2535
                }
 
2536
                g_object_unref (_data_->_async_result);
 
2537
                return FALSE;
 
2538
        } else {
 
2539
                _data_->_tmp15_ = _data_->_data1_->msg;
 
2540
                _data_->_tmp16_ = _data_->_tmp15_->response_body;
 
2541
                _data_->_tmp17_ = _data_->_tmp16_->data;
 
2542
                _data_->_tmp17__length1 = (gint) _data_->_tmp16_->length;
 
2543
                memset (&_data_->_tmp18_, 0, sizeof (UnityVideoLensRemoteVideoDetails));
 
2544
                unity_video_lens_ubuntu_video_search_process_details_results ((const gchar*) _data_->_tmp17_, &_data_->_tmp18_, &_data_->_inner_error_);
 
2545
                _data_->details = _data_->_tmp18_;
 
2546
                if (_data_->_inner_error_ != NULL) {
 
2547
                        g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
 
2548
                        g_error_free (_data_->_inner_error_);
 
2549
                        block1_data_unref (_data_->_data1_);
 
2550
                        _data_->_data1_ = NULL;
 
2551
                        if (_data_->_state_ == 0) {
 
2552
                                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2553
                        } else {
 
2554
                                g_simple_async_result_complete (_data_->_async_result);
 
2555
                        }
 
2556
                        g_object_unref (_data_->_async_result);
 
2557
                        return FALSE;
 
2558
                }
 
2559
                _data_->_tmp19_ = _data_->details;
 
2560
                _data_->_tmp20_ = _unity_video_lens_remote_video_details_dup0 (&_data_->_tmp19_);
 
2561
                _data_->_tmp21_ = _data_->_tmp20_;
 
2562
                unity_video_lens_remote_video_details_destroy (&_data_->_tmp19_);
 
2563
                _data_->result = _data_->_tmp21_;
 
2564
                block1_data_unref (_data_->_data1_);
 
2565
                _data_->_data1_ = NULL;
 
2566
                if (_data_->_state_ == 0) {
 
2567
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2568
                } else {
 
2569
                        g_simple_async_result_complete (_data_->_async_result);
 
2570
                }
 
2571
                g_object_unref (_data_->_async_result);
 
2572
                return FALSE;
 
2573
        }
 
2574
        block1_data_unref (_data_->_data1_);
 
2575
        _data_->_data1_ = NULL;
 
2576
        if (_data_->_state_ == 0) {
 
2577
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2578
        } else {
 
2579
                g_simple_async_result_complete (_data_->_async_result);
 
2580
        }
 
2581
        g_object_unref (_data_->_async_result);
 
2582
        return FALSE;
 
2583
}
 
2584
 
 
2585
 
 
2586
static void unity_video_lens_remote_video_scope_update_search_async_data_free (gpointer _data) {
 
2587
        UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_;
 
2588
        _data_ = _data;
 
2589
        _g_object_unref0 (_data_->search);
 
2590
        _g_object_unref0 (_data_->cancellable);
 
2591
        _g_object_unref0 (_data_->self);
 
2592
        g_slice_free (UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData, _data_);
 
2593
}
 
2594
 
 
2595
 
 
2596
static void unity_video_lens_remote_video_scope_update_search_async (UnityVideoLensRemoteVideoScope* self, UnityDeprecatedScopeSearch* search, UnitySearchType search_type, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
2597
        UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_;
 
2598
        UnityVideoLensRemoteVideoScope* _tmp0_;
 
2599
        UnityDeprecatedScopeSearch* _tmp1_;
 
2600
        UnityDeprecatedScopeSearch* _tmp2_;
 
2601
        UnitySearchType _tmp3_;
 
2602
        GCancellable* _tmp4_;
 
2603
        GCancellable* _tmp5_;
 
2604
        _data_ = g_slice_new0 (UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData);
 
2605
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_video_lens_remote_video_scope_update_search_async);
 
2606
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_video_lens_remote_video_scope_update_search_async_data_free);
 
2607
        _tmp0_ = _g_object_ref0 (self);
 
2608
        _data_->self = _tmp0_;
 
2609
        _tmp1_ = search;
 
2610
        _tmp2_ = _g_object_ref0 (_tmp1_);
 
2611
        _g_object_unref0 (_data_->search);
 
2612
        _data_->search = _tmp2_;
 
2613
        _tmp3_ = search_type;
 
2614
        _data_->search_type = _tmp3_;
 
2615
        _tmp4_ = cancellable;
 
2616
        _tmp5_ = _g_object_ref0 (_tmp4_);
 
2617
        _g_object_unref0 (_data_->cancellable);
 
2618
        _data_->cancellable = _tmp5_;
 
2619
        unity_video_lens_remote_video_scope_update_search_async_co (_data_);
 
2620
}
 
2621
 
 
2622
 
 
2623
static void unity_video_lens_remote_video_scope_update_search_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_) {
 
2624
        UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_;
 
2625
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
2626
}
 
2627
 
 
2628
 
 
2629
static void unity_video_lens_remote_video_scope_update_search_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
 
2630
        UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_;
 
2631
        _data_ = _user_data_;
 
2632
        _data_->_source_object_ = source_object;
 
2633
        _data_->_res_ = _res_;
 
2634
        unity_video_lens_remote_video_scope_update_search_async_co (_data_);
 
2635
}
 
2636
 
 
2637
 
 
2638
static gboolean unity_video_lens_remote_video_scope_update_search_async_co (UnityVideoLensRemoteVideoScopeUpdateSearchAsyncData* _data_) {
 
2639
        switch (_data_->_state_) {
 
2640
                case 0:
 
2641
                goto _state_0;
 
2642
                case 1:
 
2643
                goto _state_1;
 
2644
                default:
 
2645
                g_assert_not_reached ();
 
2646
        }
 
2647
        _state_0:
 
2648
        _data_->_tmp0_ = _data_->cancellable;
 
2649
        _data_->_tmp1_ = FALSE;
 
2650
        _data_->_tmp1_ = unity_video_lens_remote_video_scope_is_in_China (_data_->self, _data_->_tmp0_);
 
2651
        if (!_data_->_tmp1_) {
 
2652
                g_warning ("remote-scope.vala:461: Error can not search video from Youku !");
 
2653
                if (_data_->_state_ == 0) {
 
2654
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2655
                } else {
 
2656
                        g_simple_async_result_complete (_data_->_async_result);
 
2657
                }
 
2658
                g_object_unref (_data_->_async_result);
 
2659
                return FALSE;
 
2660
        }
 
2661
        {
 
2662
                _data_->_tmp2_ = _data_->search;
 
2663
                _data_->_tmp3_ = unity_deprecated_scope_search_get_search_string (_data_->_tmp2_);
 
2664
                _data_->_tmp4_ = _data_->_tmp3_;
 
2665
                _data_->_tmp5_ = NULL;
 
2666
                _data_->_tmp5_ = string_strip (_data_->_tmp4_);
 
2667
                _data_->search_string = _data_->_tmp5_;
 
2668
                _data_->_tmp6_ = _data_->search_string;
 
2669
                g_debug ("remote-scope.vala:467: Remote search string changed to: %s", _data_->_tmp6_);
 
2670
                _data_->_tmp7_ = _data_->search;
 
2671
                _data_->_tmp8_ = unity_deprecated_scope_search_get_results_model (_data_->_tmp7_);
 
2672
                _data_->_tmp9_ = _data_->_tmp8_;
 
2673
                _data_->_tmp10_ = _g_object_ref0 (_data_->_tmp9_);
 
2674
                _data_->model = _data_->_tmp10_;
 
2675
                _data_->_tmp11_ = _data_->model;
 
2676
                dee_model_clear ((DeeModel*) _data_->_tmp11_);
 
2677
                _data_->_tmp12_ = _data_->self->priv->preferences;
 
2678
                _data_->_tmp13_ = unity_preferences_manager_get_remote_content_search (_data_->_tmp12_);
 
2679
                _data_->_tmp14_ = _data_->_tmp13_;
 
2680
                if (_data_->_tmp14_ != UNITY_PREFERENCES_MANAGER_REMOTE_CONTENT_ALL) {
 
2681
                        _data_->_tmp15_ = _data_->search;
 
2682
                        g_signal_emit_by_name (_data_->_tmp15_, "finished");
 
2683
                        _g_object_unref0 (_data_->model);
 
2684
                        _g_free0 (_data_->search_string);
 
2685
                        if (_data_->_state_ == 0) {
 
2686
                                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2687
                        } else {
 
2688
                                g_simple_async_result_complete (_data_->_async_result);
 
2689
                        }
 
2690
                        g_object_unref (_data_->_async_result);
 
2691
                        return FALSE;
 
2692
                }
 
2693
                _data_->_tmp16_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
 
2694
                _data_->active_sources = _data_->_tmp16_;
 
2695
                _data_->_tmp17_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) _data_->self);
 
2696
                _data_->_tmp18_ = _data_->_tmp17_;
 
2697
                _data_->_tmp19_ = _data_->_tmp18_->options;
 
2698
                {
 
2699
                        _data_->opt_collection = _data_->_tmp19_;
 
2700
                        for (_data_->opt_it = _data_->opt_collection; _data_->opt_it != NULL; _data_->opt_it = _data_->opt_it->next) {
 
2701
                                _data_->_tmp20_ = _g_object_ref0 ((UnityFilterOption*) _data_->opt_it->data);
 
2702
                                _data_->opt = _data_->_tmp20_;
 
2703
                                {
 
2704
                                        _data_->_tmp21_ = _data_->opt;
 
2705
                                        _data_->_tmp22_ = unity_filter_option_get_id (_data_->_tmp21_);
 
2706
                                        _data_->_tmp23_ = _data_->_tmp22_;
 
2707
                                        _data_->_tmp24_ = FALSE;
 
2708
                                        _data_->_tmp24_ = unity_video_lens_remote_video_scope_source_activated (_data_->self, _data_->_tmp23_);
 
2709
                                        if (_data_->_tmp24_) {
 
2710
                                                _data_->_tmp25_ = _data_->active_sources;
 
2711
                                                _data_->_tmp26_ = _data_->opt;
 
2712
                                                _data_->_tmp27_ = unity_filter_option_get_id (_data_->_tmp26_);
 
2713
                                                _data_->_tmp28_ = _data_->_tmp27_;
 
2714
                                                gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp25_, _data_->_tmp28_);
 
2715
                                        }
 
2716
                                        _g_object_unref0 (_data_->opt);
 
2717
                                }
 
2718
                        }
 
2719
                }
 
2720
                _data_->_tmp29_ = _data_->active_sources;
 
2721
                _data_->_tmp30_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp29_);
 
2722
                _data_->_tmp31_ = _data_->_tmp30_;
 
2723
                _data_->_tmp32_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) _data_->self);
 
2724
                _data_->_tmp33_ = _data_->_tmp32_;
 
2725
                _data_->_tmp34_ = _data_->_tmp33_->options;
 
2726
                _data_->_tmp35_ = 0U;
 
2727
                _data_->_tmp35_ = g_list_length (_data_->_tmp34_);
 
2728
                if (((guint) _data_->_tmp31_) == _data_->_tmp35_) {
 
2729
                        _data_->_tmp36_ = _data_->active_sources;
 
2730
                        gee_abstract_collection_clear ((GeeAbstractCollection*) _data_->_tmp36_);
 
2731
                }
 
2732
                _data_->_tmp37_ = _data_->search_type;
 
2733
                if (_data_->_tmp37_ == UNITY_SEARCH_TYPE_DEFAULT) {
 
2734
                        _data_->_tmp38_ = _data_->active_sources;
 
2735
                        _data_->_tmp39_ = FALSE;
 
2736
                        _data_->_tmp39_ = unity_video_lens_remote_video_scope_at_least_one_source_is_on (_data_->self, _data_->_tmp38_);
 
2737
                        if (_data_->_tmp39_) {
 
2738
                                {
 
2739
                                        _data_->_tmp40_ = _data_->search_string;
 
2740
                                        _data_->_tmp41_ = _data_->search;
 
2741
                                        _data_->_tmp42_ = _data_->active_sources;
 
2742
                                        _data_->_tmp43_ = _data_->cancellable;
 
2743
                                        _data_->_state_ = 1;
 
2744
                                        unity_video_lens_remote_video_scope_perform_search (_data_->self, _data_->_tmp40_, _data_->_tmp41_, _data_->_tmp42_, _data_->_tmp43_, unity_video_lens_remote_video_scope_update_search_async_ready, _data_);
 
2745
                                        return FALSE;
 
2746
                                        _state_1:
 
2747
                                        unity_video_lens_remote_video_scope_perform_search_finish (_data_->self, _data_->_res_, &_data_->_inner_error_);
 
2748
                                        if (_data_->_inner_error_ != NULL) {
 
2749
                                                goto __catch9_g_error;
 
2750
                                        }
 
2751
                                }
 
2752
                                goto __finally9;
 
2753
                                __catch9_g_error:
 
2754
                                {
 
2755
                                        _data_->e = _data_->_inner_error_;
 
2756
                                        _data_->_inner_error_ = NULL;
 
2757
                                        _data_->_tmp44_ = _data_->e;
 
2758
                                        _data_->_tmp45_ = _data_->_tmp44_->message;
 
2759
                                        g_warning ("remote-scope.vala:505: Search interrupted: %s", _data_->_tmp45_);
 
2760
                                        _g_error_free0 (_data_->e);
 
2761
                                }
 
2762
                                __finally9:
 
2763
                                if (_data_->_inner_error_ != NULL) {
 
2764
                                        _g_object_unref0 (_data_->active_sources);
 
2765
                                        _g_object_unref0 (_data_->model);
 
2766
                                        _g_free0 (_data_->search_string);
 
2767
                                        goto __catch8_g_error;
 
2768
                                }
 
2769
                        }
 
2770
                }
 
2771
                _data_->_tmp46_ = _data_->search;
 
2772
                g_signal_emit_by_name (_data_->_tmp46_, "finished");
 
2773
                _g_object_unref0 (_data_->active_sources);
 
2774
                _g_object_unref0 (_data_->model);
 
2775
                _g_free0 (_data_->search_string);
 
2776
        }
 
2777
        goto __finally8;
 
2778
        __catch8_g_error:
 
2779
        {
 
2780
                _data_->_vala1_e = _data_->_inner_error_;
 
2781
                _data_->_inner_error_ = NULL;
 
2782
                _data_->_tmp47_ = _data_->_vala1_e;
 
2783
                _data_->_tmp48_ = _data_->_tmp47_->message;
 
2784
                g_warning ("remote-scope.vala:515: Error getting result from youku: %s(Failed to S" \
 
2785
"earch video from Youku)!", _data_->_tmp48_);
 
2786
                _g_error_free0 (_data_->_vala1_e);
 
2787
        }
 
2788
        __finally8:
 
2789
        if (_data_->_inner_error_ != NULL) {
 
2790
                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);
 
2791
                g_clear_error (&_data_->_inner_error_);
 
2792
                return FALSE;
 
2793
        }
 
2794
        if (_data_->_state_ == 0) {
 
2795
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
2796
        } else {
 
2797
                g_simple_async_result_complete (_data_->_async_result);
 
2798
        }
 
2799
        g_object_unref (_data_->_async_result);
 
2800
        return FALSE;
 
2801
}
 
2802
 
 
2803
 
 
2804
static gboolean unity_video_lens_remote_video_scope_source_activated (UnityVideoLensRemoteVideoScope* self, const gchar* id) {
 
2805
        gboolean result = FALSE;
 
2806
        UnityOptionsFilter* _tmp0_;
 
2807
        UnityOptionsFilter* _tmp1_;
 
2808
        const gchar* _tmp2_;
 
2809
        UnityFilterOption* _tmp3_ = NULL;
 
2810
        UnityFilterOption* _tmp4_;
 
2811
        gboolean _tmp5_;
 
2812
        gboolean _tmp6_;
 
2813
        gboolean _tmp7_;
 
2814
        gboolean active;
 
2815
        UnityOptionsFilter* _tmp8_;
 
2816
        UnityOptionsFilter* _tmp9_;
 
2817
        gboolean _tmp10_;
 
2818
        gboolean _tmp11_;
 
2819
        gboolean filtering;
 
2820
        gboolean _tmp12_ = FALSE;
 
2821
        gboolean _tmp13_ = FALSE;
 
2822
        gboolean _tmp14_;
 
2823
        gboolean _tmp16_;
 
2824
        gboolean _tmp21_;
 
2825
        g_return_val_if_fail (self != NULL, FALSE);
 
2826
        g_return_val_if_fail (id != NULL, FALSE);
 
2827
        _tmp0_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
2828
        _tmp1_ = _tmp0_;
 
2829
        _tmp2_ = id;
 
2830
        _tmp3_ = unity_options_filter_get_option (_tmp1_, _tmp2_);
 
2831
        _tmp4_ = _tmp3_;
 
2832
        _tmp5_ = unity_filter_option_get_active (_tmp4_);
 
2833
        _tmp6_ = _tmp5_;
 
2834
        _tmp7_ = _tmp6_;
 
2835
        _g_object_unref0 (_tmp4_);
 
2836
        active = _tmp7_;
 
2837
        _tmp8_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
2838
        _tmp9_ = _tmp8_;
 
2839
        _tmp10_ = unity_filter_get_filtering ((UnityFilter*) _tmp9_);
 
2840
        _tmp11_ = _tmp10_;
 
2841
        filtering = _tmp11_;
 
2842
        _tmp14_ = active;
 
2843
        if (_tmp14_) {
 
2844
                gboolean _tmp15_;
 
2845
                _tmp15_ = filtering;
 
2846
                _tmp13_ = _tmp15_;
 
2847
        } else {
 
2848
                _tmp13_ = FALSE;
 
2849
        }
 
2850
        _tmp16_ = _tmp13_;
 
2851
        if (_tmp16_) {
 
2852
                _tmp12_ = TRUE;
 
2853
        } else {
 
2854
                gboolean _tmp17_ = FALSE;
 
2855
                gboolean _tmp18_;
 
2856
                gboolean _tmp20_;
 
2857
                _tmp18_ = active;
 
2858
                if (!_tmp18_) {
 
2859
                        gboolean _tmp19_;
 
2860
                        _tmp19_ = filtering;
 
2861
                        _tmp17_ = !_tmp19_;
 
2862
                } else {
 
2863
                        _tmp17_ = FALSE;
 
2864
                }
 
2865
                _tmp20_ = _tmp17_;
 
2866
                _tmp12_ = _tmp20_;
 
2867
        }
 
2868
        _tmp21_ = _tmp12_;
 
2869
        if (_tmp21_) {
 
2870
                result = TRUE;
 
2871
                return result;
 
2872
        }
 
2873
        result = FALSE;
 
2874
        return result;
 
2875
}
 
2876
 
 
2877
 
 
2878
static gboolean unity_video_lens_remote_video_scope_at_least_one_source_is_on (UnityVideoLensRemoteVideoScope* self, GeeArrayList* active_sources) {
 
2879
        gboolean result = FALSE;
 
2880
        gboolean _tmp0_ = FALSE;
 
2881
        gboolean _tmp1_ = FALSE;
 
2882
        UnityOptionsFilter* _tmp2_;
 
2883
        UnityOptionsFilter* _tmp3_;
 
2884
        gboolean _tmp4_;
 
2885
        gboolean _tmp5_;
 
2886
        gboolean _tmp9_;
 
2887
        gboolean _tmp14_;
 
2888
        g_return_val_if_fail (self != NULL, FALSE);
 
2889
        g_return_val_if_fail (active_sources != NULL, FALSE);
 
2890
        _tmp2_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
2891
        _tmp3_ = _tmp2_;
 
2892
        _tmp4_ = unity_filter_get_filtering ((UnityFilter*) _tmp3_);
 
2893
        _tmp5_ = _tmp4_;
 
2894
        if (_tmp5_) {
 
2895
                GeeArrayList* _tmp6_;
 
2896
                gint _tmp7_;
 
2897
                gint _tmp8_;
 
2898
                _tmp6_ = active_sources;
 
2899
                _tmp7_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp6_);
 
2900
                _tmp8_ = _tmp7_;
 
2901
                _tmp1_ = _tmp8_ > 0;
 
2902
        } else {
 
2903
                _tmp1_ = FALSE;
 
2904
        }
 
2905
        _tmp9_ = _tmp1_;
 
2906
        if (_tmp9_) {
 
2907
                _tmp0_ = TRUE;
 
2908
        } else {
 
2909
                UnityOptionsFilter* _tmp10_;
 
2910
                UnityOptionsFilter* _tmp11_;
 
2911
                gboolean _tmp12_;
 
2912
                gboolean _tmp13_;
 
2913
                _tmp10_ = unity_deprecated_scope_base_get_sources ((UnityDeprecatedScopeBase*) self);
 
2914
                _tmp11_ = _tmp10_;
 
2915
                _tmp12_ = unity_filter_get_filtering ((UnityFilter*) _tmp11_);
 
2916
                _tmp13_ = _tmp12_;
 
2917
                _tmp0_ = !_tmp13_;
 
2918
        }
 
2919
        _tmp14_ = _tmp0_;
 
2920
        result = _tmp14_;
 
2921
        return result;
 
2922
}
 
2923
 
 
2924
 
 
2925
static void unity_video_lens_remote_video_scope_perform_search_data_free (gpointer _data) {
 
2926
        UnityVideoLensRemoteVideoScopePerformSearchData* _data_;
 
2927
        _data_ = _data;
 
2928
        _g_free0 (_data_->search_string);
 
2929
        _g_object_unref0 (_data_->search);
 
2930
        _g_object_unref0 (_data_->active_sources);
 
2931
        _g_object_unref0 (_data_->cancellable);
 
2932
        _g_object_unref0 (_data_->self);
 
2933
        g_slice_free (UnityVideoLensRemoteVideoScopePerformSearchData, _data_);
 
2934
}
 
2935
 
 
2936
 
 
2937
static void unity_video_lens_remote_video_scope_perform_search (UnityVideoLensRemoteVideoScope* self, const gchar* search_string, UnityDeprecatedScopeSearch* search, GeeArrayList* active_sources, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
2938
        UnityVideoLensRemoteVideoScopePerformSearchData* _data_;
 
2939
        UnityVideoLensRemoteVideoScope* _tmp0_;
 
2940
        const gchar* _tmp1_;
 
2941
        gchar* _tmp2_;
 
2942
        UnityDeprecatedScopeSearch* _tmp3_;
 
2943
        UnityDeprecatedScopeSearch* _tmp4_;
 
2944
        GeeArrayList* _tmp5_;
 
2945
        GeeArrayList* _tmp6_;
 
2946
        GCancellable* _tmp7_;
 
2947
        GCancellable* _tmp8_;
 
2948
        _data_ = g_slice_new0 (UnityVideoLensRemoteVideoScopePerformSearchData);
 
2949
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_video_lens_remote_video_scope_perform_search);
 
2950
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_video_lens_remote_video_scope_perform_search_data_free);
 
2951
        _tmp0_ = _g_object_ref0 (self);
 
2952
        _data_->self = _tmp0_;
 
2953
        _tmp1_ = search_string;
 
2954
        _tmp2_ = g_strdup (_tmp1_);
 
2955
        _g_free0 (_data_->search_string);
 
2956
        _data_->search_string = _tmp2_;
 
2957
        _tmp3_ = search;
 
2958
        _tmp4_ = _g_object_ref0 (_tmp3_);
 
2959
        _g_object_unref0 (_data_->search);
 
2960
        _data_->search = _tmp4_;
 
2961
        _tmp5_ = active_sources;
 
2962
        _tmp6_ = _g_object_ref0 (_tmp5_);
 
2963
        _g_object_unref0 (_data_->active_sources);
 
2964
        _data_->active_sources = _tmp6_;
 
2965
        _tmp7_ = cancellable;
 
2966
        _tmp8_ = _g_object_ref0 (_tmp7_);
 
2967
        _g_object_unref0 (_data_->cancellable);
 
2968
        _data_->cancellable = _tmp8_;
 
2969
        unity_video_lens_remote_video_scope_perform_search_co (_data_);
 
2970
}
 
2971
 
 
2972
 
 
2973
static void unity_video_lens_remote_video_scope_perform_search_finish (UnityVideoLensRemoteVideoScope* self, GAsyncResult* _res_, GError** error) {
 
2974
        UnityVideoLensRemoteVideoScopePerformSearchData* _data_;
 
2975
        if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
 
2976
                return;
 
2977
        }
 
2978
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
2979
}
 
2980
 
 
2981
 
 
2982
static Block2Data* block2_data_ref (Block2Data* _data2_) {
 
2983
        g_atomic_int_inc (&_data2_->_ref_count_);
 
2984
        return _data2_;
 
2985
}
 
2986
 
 
2987
 
 
2988
static void block2_data_unref (void * _userdata_) {
 
2989
        Block2Data* _data2_;
 
2990
        _data2_ = (Block2Data*) _userdata_;
 
2991
        if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
 
2992
                UnityVideoLensRemoteVideoScope * self;
 
2993
                self = _data2_->self;
 
2994
                _g_object_unref0 (_data2_->msg);
 
2995
                _g_object_unref0 (self);
 
2996
                g_slice_free (Block2Data, _data2_);
 
2997
        }
 
2998
}
 
2999
 
 
3000
 
 
3001
static void __lambda4_ (Block2Data* _data2_, SoupSession* session_, SoupMessage* msg_) {
 
3002
        UnityVideoLensRemoteVideoScope * self;
 
3003
        SoupMessage* _tmp0_;
 
3004
        SoupMessage* _tmp1_;
 
3005
        self = _data2_->self;
 
3006
        g_return_if_fail (session_ != NULL);
 
3007
        g_return_if_fail (msg_ != NULL);
 
3008
        _tmp0_ = msg_;
 
3009
        _tmp1_ = _g_object_ref0 (_tmp0_);
 
3010
        _g_object_unref0 (_data2_->msg);
 
3011
        _data2_->msg = _tmp1_;
 
3012
        unity_video_lens_remote_video_scope_perform_search_co (_data2_->_async_data_);
 
3013
}
 
3014
 
 
3015
 
 
3016
static void ___lambda4__soup_session_callback (SoupSession* session, SoupMessage* msg, gpointer self) {
 
3017
        __lambda4_ (self, session, msg);
 
3018
}
 
3019
 
 
3020
 
 
3021
static void ___lambda5_ (Block2Data* _data2_) {
 
3022
        UnityVideoLensRemoteVideoScope * self;
 
3023
        SoupSession* _tmp0_;
 
3024
        SoupMessage* _tmp1_;
 
3025
        self = _data2_->self;
 
3026
        _data2_->cancelled = TRUE;
 
3027
        _tmp0_ = self->priv->session;
 
3028
        _tmp1_ = _data2_->msg;
 
3029
        soup_session_cancel_message (_tmp0_, _tmp1_, (guint) SOUP_STATUS_CANCELLED);
 
3030
}
 
3031
 
 
3032
 
 
3033
static void ____lambda5__gfunc (gconstpointer data, gpointer self) {
 
3034
        ___lambda5_ (self);
 
3035
}
 
3036
 
 
3037
 
 
3038
static gboolean _unity_video_lens_remote_video_scope_perform_search_co_gsource_func (gpointer self) {
 
3039
        gboolean result;
 
3040
        result = unity_video_lens_remote_video_scope_perform_search_co (self);
 
3041
        return result;
 
3042
}
 
3043
 
 
3044
 
 
3045
static gboolean unity_video_lens_remote_video_scope_perform_search_co (UnityVideoLensRemoteVideoScopePerformSearchData* _data_) {
 
3046
        switch (_data_->_state_) {
 
3047
                case 0:
 
3048
                goto _state_0;
 
3049
                case 1:
 
3050
                goto _state_1;
 
3051
                case 2:
 
3052
                goto _state_2;
 
3053
                default:
 
3054
                g_assert_not_reached ();
 
3055
        }
 
3056
        _state_0:
 
3057
        _data_->_data2_ = g_slice_new0 (Block2Data);
 
3058
        _data_->_data2_->_ref_count_ = 1;
 
3059
        _data_->_data2_->self = g_object_ref (_data_->self);
 
3060
        _data_->_data2_->_async_data_ = _data_;
 
3061
        _data_->_tmp0_ = _data_->search;
 
3062
        _data_->_tmp1_ = unity_deprecated_scope_search_get_results_model (_data_->_tmp0_);
 
3063
        _data_->_tmp2_ = _data_->_tmp1_;
 
3064
        dee_model_clear ((DeeModel*) _data_->_tmp2_);
 
3065
        _data_->_tmp6_ = _data_->search_string;
 
3066
        if (_data_->_tmp6_ == NULL) {
 
3067
                _data_->_tmp5_ = TRUE;
 
3068
        } else {
 
3069
                _data_->_tmp7_ = _data_->search_string;
 
3070
                _data_->_tmp5_ = g_strcmp0 (_data_->_tmp7_, "") == 0;
 
3071
        }
 
3072
        _data_->_tmp8_ = _data_->_tmp5_;
 
3073
        if (_data_->_tmp8_) {
 
3074
                _data_->_tmp9_ = _data_->active_sources;
 
3075
                _data_->_tmp10_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp9_);
 
3076
                _data_->_tmp11_ = _data_->_tmp10_;
 
3077
                _data_->_tmp4_ = _data_->_tmp11_ == 0;
 
3078
        } else {
 
3079
                _data_->_tmp4_ = FALSE;
 
3080
        }
 
3081
        _data_->_tmp12_ = _data_->_tmp4_;
 
3082
        if (_data_->_tmp12_) {
 
3083
                _data_->_tmp13_ = _data_->self->priv->recommendations;
 
3084
                _data_->_tmp14_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp13_);
 
3085
                _data_->_tmp15_ = _data_->_tmp14_;
 
3086
                _data_->_tmp3_ = _data_->_tmp15_ > 0;
 
3087
        } else {
 
3088
                _data_->_tmp3_ = FALSE;
 
3089
        }
 
3090
        _data_->_tmp16_ = _data_->_tmp3_;
 
3091
        if (_data_->_tmp16_) {
 
3092
                _data_->_tmp17_ = g_date_time_new_now_utc ();
 
3093
                _data_->time = _data_->_tmp17_;
 
3094
                _data_->_tmp18_ = _data_->time;
 
3095
                _data_->_tmp19_ = 0LL;
 
3096
                _data_->_tmp19_ = g_date_time_to_unix (_data_->_tmp18_);
 
3097
                _data_->_tmp20_ = _data_->self->priv->recommendations_last_update;
 
3098
                _data_->_tmp21_ = unity_video_lens_remote_video_scope_REFRESH_INTERVAL;
 
3099
                if ((_data_->_tmp19_ - _data_->_tmp20_) < ((gint64) _data_->_tmp21_)) {
 
3100
                        g_debug ("remote-scope.vala:550: Updating search results with recommendations");
 
3101
                        _data_->_tmp22_ = _data_->search;
 
3102
                        _data_->_tmp23_ = unity_deprecated_scope_search_get_results_model (_data_->_tmp22_);
 
3103
                        _data_->_tmp24_ = _data_->_tmp23_;
 
3104
                        _data_->_tmp25_ = _data_->self->priv->recommendations;
 
3105
                        unity_video_lens_remote_video_scope_update_results_model (_data_->self, (DeeModel*) _data_->_tmp24_, _data_->_tmp25_);
 
3106
                        _g_date_time_unref0 (_data_->time);
 
3107
                        block2_data_unref (_data_->_data2_);
 
3108
                        _data_->_data2_ = NULL;
 
3109
                        if (_data_->_state_ == 0) {
 
3110
                                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
3111
                        } else {
 
3112
                                g_simple_async_result_complete (_data_->_async_result);
 
3113
                        }
 
3114
                        g_object_unref (_data_->_async_result);
 
3115
                        return FALSE;
 
3116
                }
 
3117
                _g_date_time_unref0 (_data_->time);
 
3118
        }
 
3119
        _data_->_tmp26_ = _data_->search_string;
 
3120
        _data_->_tmp27_ = _data_->active_sources;
 
3121
        _data_->_tmp28_ = NULL;
 
3122
        _data_->_tmp28_ = unity_video_lens_ubuntu_video_search_build_search_uri (_data_->_tmp26_, _data_->_tmp27_);
 
3123
        _data_->url = _data_->_tmp28_;
 
3124
        _data_->_tmp29_ = _data_->url;
 
3125
        g_debug ("remote-scope.vala:557: Querying the server: %s", _data_->_tmp29_);
 
3126
        _data_->_tmp32_ = _data_->search_string;
 
3127
        if (_data_->_tmp32_ == NULL) {
 
3128
                _data_->_tmp31_ = TRUE;
 
3129
        } else {
 
3130
                _data_->_tmp33_ = _data_->search_string;
 
3131
                _data_->_tmp31_ = g_strcmp0 (_data_->_tmp33_, "") == 0;
 
3132
        }
 
3133
        _data_->_tmp34_ = _data_->_tmp31_;
 
3134
        if (_data_->_tmp34_) {
 
3135
                _data_->_tmp30_ = TRUE;
 
3136
        } else {
 
3137
                _data_->_tmp35_ = _data_->active_sources;
 
3138
                _data_->_tmp36_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp35_);
 
3139
                _data_->_tmp37_ = _data_->_tmp36_;
 
3140
                _data_->_tmp30_ = _data_->_tmp37_ == 0;
 
3141
        }
 
3142
        _data_->_tmp38_ = _data_->_tmp30_;
 
3143
        _data_->is_treat_yourself = _data_->_tmp38_;
 
3144
        _data_->_tmp39_ = _data_->url;
 
3145
        _data_->_tmp40_ = soup_message_new ("GET", _data_->_tmp39_);
 
3146
        _data_->_data2_->msg = _data_->_tmp40_;
 
3147
        _data_->_tmp41_ = _data_->self->priv->session;
 
3148
        _data_->_tmp42_ = _data_->_data2_->msg;
 
3149
        _data_->_tmp43_ = _g_object_ref0 (_data_->_tmp42_);
 
3150
        soup_session_queue_message (_data_->_tmp41_, _data_->_tmp43_, ___lambda4__soup_session_callback, _data_->_data2_);
 
3151
        _data_->_data2_->cancelled = FALSE;
 
3152
        _data_->cancel_id = (gulong) 0;
 
3153
        _data_->_tmp44_ = _data_->cancellable;
 
3154
        if (_data_->_tmp44_ != NULL) {
 
3155
                _data_->_tmp45_ = _data_->cancellable;
 
3156
                _data_->_tmp46_ = 0UL;
 
3157
                _data_->_tmp46_ = g_cancellable_connect (_data_->_tmp45_, (GCallback) ____lambda5__gfunc, block2_data_ref (_data_->_data2_), block2_data_unref);
 
3158
                _data_->cancel_id = _data_->_tmp46_;
 
3159
        }
 
3160
        _data_->_state_ = 1;
 
3161
        return FALSE;
 
3162
        _state_1:
 
3163
        ;
 
3164
        _data_->_tmp47_ = _data_->_data2_->cancelled;
 
3165
        if (_data_->_tmp47_) {
 
3166
                g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_video_lens_remote_video_scope_perform_search_co_gsource_func, _data_, NULL);
 
3167
                _data_->_state_ = 2;
 
3168
                return FALSE;
 
3169
                _state_2:
 
3170
                ;
 
3171
                _data_->_tmp48_ = _data_->cancellable;
 
3172
                _data_->_tmp49_ = _data_->cancel_id;
 
3173
                g_cancellable_disconnect (_data_->_tmp48_, _data_->_tmp49_);
 
3174
                _data_->_tmp50_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
 
3175
                _data_->_inner_error_ = _data_->_tmp50_;
 
3176
                g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
 
3177
                g_error_free (_data_->_inner_error_);
 
3178
                _g_free0 (_data_->url);
 
3179
                block2_data_unref (_data_->_data2_);
 
3180
                _data_->_data2_ = NULL;
 
3181
                if (_data_->_state_ == 0) {
 
3182
                        g_simple_async_result_complete_in_idle (_data_->_async_result);
 
3183
                } else {
 
3184
                        g_simple_async_result_complete (_data_->_async_result);
 
3185
                }
 
3186
                g_object_unref (_data_->_async_result);
 
3187
                return FALSE;
 
3188
        }
 
3189
        _data_->_tmp51_ = _data_->cancellable;
 
3190
        if (_data_->_tmp51_ != NULL) {
 
3191
                _data_->_tmp52_ = _data_->cancellable;
 
3192
                _data_->_tmp53_ = _data_->cancel_id;
 
3193
                g_cancellable_disconnect (_data_->_tmp52_, _data_->_tmp53_);
 
3194
        }
 
3195
        _data_->_tmp54_ = _data_->_data2_->msg;
 
3196
        _data_->_tmp55_ = _data_->is_treat_yourself;
 
3197
        _data_->_tmp56_ = NULL;
 
3198
        _data_->_tmp56_ = unity_video_lens_remote_video_scope_handle_search_response (_data_->self, _data_->_tmp54_, _data_->_tmp55_);
 
3199
        _data_->results = _data_->_tmp56_;
 
3200
        _data_->_tmp57_ = _data_->results;
 
3201
        if (_data_->_tmp57_ != NULL) {
 
3202
                _data_->_tmp59_ = _data_->search_string;
 
3203
                if (_data_->_tmp59_ == NULL) {
 
3204
                        _data_->_tmp58_ = TRUE;
 
3205
                } else {
 
3206
                        _data_->_tmp61_ = _data_->search_string;
 
3207
                        _data_->_tmp62_ = NULL;
 
3208
                        _data_->_tmp62_ = string_strip (_data_->_tmp61_);
 
3209
                        _data_->_tmp63_ = _data_->_tmp62_;
 
3210
                        _data_->_tmp64_ = g_strcmp0 (_data_->_tmp63_, "") == 0;
 
3211
                        _g_free0 (_data_->_tmp63_);
 
3212
                        if (_data_->_tmp64_) {
 
3213
                                _data_->_tmp65_ = _data_->active_sources;
 
3214
                                _data_->_tmp66_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp65_);
 
3215
                                _data_->_tmp67_ = _data_->_tmp66_;
 
3216
                                _data_->_tmp60_ = _data_->_tmp67_ == 0;
 
3217
                        } else {
 
3218
                                _data_->_tmp60_ = FALSE;
 
3219
                        }
 
3220
                        _data_->_tmp68_ = _data_->_tmp60_;
 
3221
                        _data_->_tmp58_ = _data_->_tmp68_;
 
3222
                }
 
3223
                _data_->_tmp69_ = _data_->_tmp58_;
 
3224
                if (_data_->_tmp69_) {
 
3225
                        g_debug ("remote-scope.vala:603: Empty search, updating recommendations");
 
3226
                        _data_->_tmp70_ = g_date_time_new_now_utc ();
 
3227
                        _data_->_vala1_time = _data_->_tmp70_;
 
3228
                        _data_->_tmp71_ = _data_->results;
 
3229
                        _data_->_tmp72_ = _g_object_ref0 (_data_->_tmp71_);
 
3230
                        _g_object_unref0 (_data_->self->priv->recommendations);
 
3231
                        _data_->self->priv->recommendations = _data_->_tmp72_;
 
3232
                        _data_->_tmp73_ = _data_->_vala1_time;
 
3233
                        _data_->_tmp74_ = 0LL;
 
3234
                        _data_->_tmp74_ = g_date_time_to_unix (_data_->_tmp73_);
 
3235
                        _data_->self->priv->recommendations_last_update = _data_->_tmp74_;
 
3236
                        _g_date_time_unref0 (_data_->_vala1_time);
 
3237
                }
 
3238
                _data_->_tmp75_ = _data_->search;
 
3239
                _data_->_tmp76_ = unity_deprecated_scope_search_get_results_model (_data_->_tmp75_);
 
3240
                _data_->_tmp77_ = _data_->_tmp76_;
 
3241
                _data_->_tmp78_ = _data_->results;
 
3242
                unity_video_lens_remote_video_scope_update_results_model (_data_->self, (DeeModel*) _data_->_tmp77_, _data_->_tmp78_);
 
3243
        }
 
3244
        _g_object_unref0 (_data_->results);
 
3245
        _g_free0 (_data_->url);
 
3246
        block2_data_unref (_data_->_data2_);
 
3247
        _data_->_data2_ = NULL;
 
3248
        if (_data_->_state_ == 0) {
 
3249
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
3250
        } else {
 
3251
                g_simple_async_result_complete (_data_->_async_result);
 
3252
        }
 
3253
        g_object_unref (_data_->_async_result);
 
3254
        return FALSE;
 
3255
}
 
3256
 
 
3257
 
 
3258
static GVariant* _variant_new1 (const gchar* value) {
 
3259
        return g_variant_ref_sink (g_variant_new_string (value));
 
3260
}
 
3261
 
 
3262
 
 
3263
static GVariant* _variant_new2 (gboolean value) {
 
3264
        return g_variant_ref_sink (g_variant_new_boolean (value));
 
3265
}
 
3266
 
 
3267
 
 
3268
static void unity_video_lens_remote_video_scope_update_results_model (UnityVideoLensRemoteVideoScope* self, DeeModel* model, GeeArrayList* results) {
 
3269
        g_return_if_fail (self != NULL);
 
3270
        g_return_if_fail (model != NULL);
 
3271
        g_return_if_fail (results != NULL);
 
3272
        {
 
3273
                GeeArrayList* _tmp0_;
 
3274
                GeeArrayList* _tmp1_;
 
3275
                GeeArrayList* _video_list;
 
3276
                GeeArrayList* _tmp2_;
 
3277
                gint _tmp3_;
 
3278
                gint _tmp4_;
 
3279
                gint _video_size;
 
3280
                gint _video_index;
 
3281
                _tmp0_ = results;
 
3282
                _tmp1_ = _g_object_ref0 (_tmp0_);
 
3283
                _video_list = _tmp1_;
 
3284
                _tmp2_ = _video_list;
 
3285
                _tmp3_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp2_);
 
3286
                _tmp4_ = _tmp3_;
 
3287
                _video_size = _tmp4_;
 
3288
                _video_index = -1;
 
3289
                while (TRUE) {
 
3290
                        gint _tmp5_;
 
3291
                        gint _tmp6_;
 
3292
                        gint _tmp7_;
 
3293
                        GeeArrayList* _tmp8_;
 
3294
                        gint _tmp9_;
 
3295
                        gpointer _tmp10_ = NULL;
 
3296
                        UnityVideoLensRemoteVideoFile* video;
 
3297
                        UnityVideoLensRemoteVideoFile* _tmp11_;
 
3298
                        const gchar* _tmp12_;
 
3299
                        gboolean _tmp13_ = FALSE;
 
3300
                        _tmp5_ = _video_index;
 
3301
                        _video_index = _tmp5_ + 1;
 
3302
                        _tmp6_ = _video_index;
 
3303
                        _tmp7_ = _video_size;
 
3304
                        if (!(_tmp6_ < _tmp7_)) {
 
3305
                                break;
 
3306
                        }
 
3307
                        _tmp8_ = _video_list;
 
3308
                        _tmp9_ = _video_index;
 
3309
                        _tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _tmp9_);
 
3310
                        video = (UnityVideoLensRemoteVideoFile*) _tmp10_;
 
3311
                        _tmp11_ = video;
 
3312
                        _tmp12_ = (*_tmp11_).uri;
 
3313
                        _tmp13_ = g_str_has_prefix (_tmp12_, "http");
 
3314
                        if (_tmp13_) {
 
3315
                                UnityVideoLensRemoteVideoFile* _tmp14_;
 
3316
                                const gchar* _tmp15_;
 
3317
                                UnityVideoLensRemoteVideoFile* _tmp16_;
 
3318
                                const gchar* _tmp17_;
 
3319
                                UnityVideoLensRemoteVideoFile* _tmp18_;
 
3320
                                const gchar* _tmp19_;
 
3321
                                UnityVideoLensRemoteUri* _tmp20_;
 
3322
                                UnityVideoLensRemoteUri* fake_uri;
 
3323
                                UnityVideoLensRemoteUri* _tmp21_;
 
3324
                                UnityVideoLensRemoteVideoFile* _tmp22_;
 
3325
                                const gchar* _tmp23_;
 
3326
                                gchar* _tmp24_;
 
3327
                                gchar* result_icon;
 
3328
                                gboolean _tmp25_ = FALSE;
 
3329
                                gboolean _tmp26_ = FALSE;
 
3330
                                UnityVideoLensRemoteVideoFile* _tmp27_;
 
3331
                                gint _tmp28_;
 
3332
                                gint _tmp29_;
 
3333
                                gboolean _tmp32_;
 
3334
                                gboolean _tmp35_;
 
3335
                                const gchar* _tmp49_;
 
3336
                                GVariant* _tmp50_;
 
3337
                                UnityVideoLensRemoteVideoFile* _tmp51_;
 
3338
                                gint _tmp52_;
 
3339
                                gint _tmp53_;
 
3340
                                GVariant* _tmp54_;
 
3341
                                GVariant* _tmp55_;
 
3342
                                GVariant* _tmp56_;
 
3343
                                GVariant* _tmp57_;
 
3344
                                GVariant* _tmp58_;
 
3345
                                GVariant* realcat;
 
3346
                                const GVariantType* _tmp59_;
 
3347
                                const GVariantType* _tmp60_ = NULL;
 
3348
                                GVariant* _tmp61_;
 
3349
                                GVariant* _tmp62_;
 
3350
                                GVariant** _tmp63_ = NULL;
 
3351
                                GVariant** _tmp64_;
 
3352
                                gint _tmp64__length1;
 
3353
                                GVariant* _tmp65_;
 
3354
                                GVariant* _tmp66_;
 
3355
                                GVariant* metadata;
 
3356
                                DeeModel* _tmp67_;
 
3357
                                UnityVideoLensRemoteUri* _tmp68_;
 
3358
                                gchar* _tmp69_ = NULL;
 
3359
                                gchar* _tmp70_;
 
3360
                                const gchar* _tmp71_;
 
3361
                                UnityVideoLensRemoteVideoFile* _tmp72_;
 
3362
                                gint _tmp73_;
 
3363
                                UnityVideoLensRemoteVideoFile* _tmp74_;
 
3364
                                const gchar* _tmp75_;
 
3365
                                UnityVideoLensRemoteVideoFile* _tmp76_;
 
3366
                                const gchar* _tmp77_;
 
3367
                                UnityVideoLensRemoteVideoFile* _tmp78_;
 
3368
                                const gchar* _tmp79_;
 
3369
                                GVariant* _tmp80_;
 
3370
                                _tmp14_ = video;
 
3371
                                _tmp15_ = (*_tmp14_).uri;
 
3372
                                _tmp16_ = video;
 
3373
                                _tmp17_ = (*_tmp16_).title;
 
3374
                                _tmp18_ = video;
 
3375
                                _tmp19_ = (*_tmp18_).icon;
 
3376
                                _tmp20_ = unity_video_lens_remote_uri_new (_tmp15_, _tmp17_, _tmp19_, "video.details_uri");
 
3377
                                fake_uri = _tmp20_;
 
3378
                                _tmp21_ = fake_uri;
 
3379
                                if (_tmp21_ == NULL) {
 
3380
                                        g_warning ("remote-scope.vala:623: fake_uri is null");
 
3381
                                }
 
3382
                                _tmp22_ = video;
 
3383
                                _tmp23_ = (*_tmp22_).icon;
 
3384
                                _tmp24_ = g_strdup (_tmp23_);
 
3385
                                result_icon = _tmp24_;
 
3386
                                _tmp27_ = video;
 
3387
                                _tmp28_ = (*_tmp27_).category;
 
3388
                                _tmp29_ = unity_video_lens_CAT_INDEX_MORE;
 
3389
                                if (_tmp28_ == _tmp29_) {
 
3390
                                        UnityVideoLensRemoteVideoFile* _tmp30_;
 
3391
                                        const gchar* _tmp31_;
 
3392
                                        _tmp30_ = video;
 
3393
                                        _tmp31_ = (*_tmp30_).price;
 
3394
                                        _tmp26_ = _tmp31_ != NULL;
 
3395
                                } else {
 
3396
                                        _tmp26_ = FALSE;
 
3397
                                }
 
3398
                                _tmp32_ = _tmp26_;
 
3399
                                if (_tmp32_) {
 
3400
                                        UnityVideoLensRemoteVideoFile* _tmp33_;
 
3401
                                        const gchar* _tmp34_;
 
3402
                                        _tmp33_ = video;
 
3403
                                        _tmp34_ = (*_tmp33_).price;
 
3404
                                        _tmp25_ = g_strcmp0 (_tmp34_, "") != 0;
 
3405
                                } else {
 
3406
                                        _tmp25_ = FALSE;
 
3407
                                }
 
3408
                                _tmp35_ = _tmp25_;
 
3409
                                if (_tmp35_) {
 
3410
                                        const gchar* _tmp36_;
 
3411
                                        GFile* _tmp37_ = NULL;
 
3412
                                        GFile* _tmp38_;
 
3413
                                        GFileIcon* _tmp39_;
 
3414
                                        GFileIcon* _tmp40_;
 
3415
                                        UnityAnnotatedIcon* _tmp41_;
 
3416
                                        UnityAnnotatedIcon* _tmp42_;
 
3417
                                        UnityAnnotatedIcon* anno_icon;
 
3418
                                        UnityAnnotatedIcon* _tmp43_;
 
3419
                                        UnityAnnotatedIcon* _tmp44_;
 
3420
                                        UnityVideoLensRemoteVideoFile* _tmp45_;
 
3421
                                        const gchar* _tmp46_;
 
3422
                                        UnityAnnotatedIcon* _tmp47_;
 
3423
                                        gchar* _tmp48_ = NULL;
 
3424
                                        _tmp36_ = result_icon;
 
3425
                                        _tmp37_ = g_file_new_for_uri (_tmp36_);
 
3426
                                        _tmp38_ = _tmp37_;
 
3427
                                        _tmp39_ = (GFileIcon*) g_file_icon_new (_tmp38_);
 
3428
                                        _tmp40_ = _tmp39_;
 
3429
                                        _tmp41_ = unity_annotated_icon_new ((GIcon*) _tmp40_);
 
3430
                                        _tmp42_ = _tmp41_;
 
3431
                                        _g_object_unref0 (_tmp40_);
 
3432
                                        _g_object_unref0 (_tmp38_);
 
3433
                                        anno_icon = _tmp42_;
 
3434
                                        _tmp43_ = anno_icon;
 
3435
                                        unity_annotated_icon_set_category (_tmp43_, UNITY_CATEGORY_TYPE_MOVIE);
 
3436
                                        _tmp44_ = anno_icon;
 
3437
                                        _tmp45_ = video;
 
3438
                                        _tmp46_ = (*_tmp45_).price;
 
3439
                                        unity_annotated_icon_set_ribbon (_tmp44_, _tmp46_);
 
3440
                                        _tmp47_ = anno_icon;
 
3441
                                        _tmp48_ = unity_annotated_icon_to_string (_tmp47_);
 
3442
                                        _g_free0 (result_icon);
 
3443
                                        result_icon = _tmp48_;
 
3444
                                        _g_object_unref0 (anno_icon);
 
3445
                                }
 
3446
                                _tmp49_ = unity_video_lens_remote_video_scope_PREVIEW_ON_LMB;
 
3447
                                _tmp50_ = _variant_new1 (_tmp49_);
 
3448
                                _tmp51_ = video;
 
3449
                                _tmp52_ = (*_tmp51_).category;
 
3450
                                _tmp53_ = unity_video_lens_CAT_INDEX_MORE;
 
3451
                                _tmp54_ = _variant_new2 (_tmp52_ == _tmp53_);
 
3452
                                _tmp55_ = g_variant_new_variant (_tmp54_);
 
3453
                                g_variant_ref_sink (_tmp55_);
 
3454
                                _tmp56_ = _tmp55_;
 
3455
                                _tmp57_ = g_variant_new_dict_entry (_tmp50_, _tmp56_);
 
3456
                                g_variant_ref_sink (_tmp57_);
 
3457
                                _tmp58_ = _tmp57_;
 
3458
                                _g_variant_unref0 (_tmp56_);
 
3459
                                realcat = _tmp58_;
 
3460
                                _tmp59_ = G_VARIANT_TYPE_VARDICT;
 
3461
                                _tmp60_ = g_variant_type_element (_tmp59_);
 
3462
                                _tmp61_ = realcat;
 
3463
                                _tmp62_ = _g_variant_ref0 (_tmp61_);
 
3464
                                _tmp63_ = g_new0 (GVariant*, 1 + 1);
 
3465
                                _tmp63_[0] = _tmp62_;
 
3466
                                _tmp64_ = _tmp63_;
 
3467
                                _tmp64__length1 = 1;
 
3468
                                _tmp65_ = g_variant_new_array (_tmp60_, _tmp64_, 1);
 
3469
                                g_variant_ref_sink (_tmp65_);
 
3470
                                _tmp66_ = _tmp65_;
 
3471
                                _tmp64_ = (_vala_array_free (_tmp64_, _tmp64__length1, (GDestroyNotify) g_variant_unref), NULL);
 
3472
                                metadata = _tmp66_;
 
3473
                                _tmp67_ = model;
 
3474
                                _tmp68_ = fake_uri;
 
3475
                                _tmp69_ = unity_video_lens_remote_uri_to_rawuri (_tmp68_);
 
3476
                                _tmp70_ = _tmp69_;
 
3477
                                _tmp71_ = result_icon;
 
3478
                                _tmp72_ = video;
 
3479
                                _tmp73_ = (*_tmp72_).category;
 
3480
                                _tmp74_ = video;
 
3481
                                _tmp75_ = (*_tmp74_).title;
 
3482
                                _tmp76_ = video;
 
3483
                                _tmp77_ = (*_tmp76_).comment;
 
3484
                                _tmp78_ = video;
 
3485
                                _tmp79_ = (*_tmp78_).uri;
 
3486
                                _tmp80_ = metadata;
 
3487
                                dee_model_append (_tmp67_, _tmp70_, _tmp71_, _tmp73_, UNITY_RESULT_TYPE_DEFAULT, "text/html", _tmp75_, _tmp77_, _tmp79_, _tmp80_, NULL);
 
3488
                                _g_free0 (_tmp70_);
 
3489
                                _g_variant_unref0 (metadata);
 
3490
                                _g_variant_unref0 (realcat);
 
3491
                                _g_free0 (result_icon);
 
3492
                                _unity_video_lens_remote_uri_unref0 (fake_uri);
 
3493
                        }
 
3494
                        _unity_video_lens_remote_video_file_free0 (video);
 
3495
                }
 
3496
                _g_object_unref0 (_video_list);
 
3497
        }
 
3498
}
 
3499
 
 
3500
 
 
3501
static gpointer _g_ptr_array_ref0 (gpointer self) {
 
3502
        return self ? g_ptr_array_ref (self) : NULL;
 
3503
}
 
3504
 
 
3505
 
 
3506
static void unity_video_lens_remote_video_scope_zeitgeist_init (UnityVideoLensRemoteVideoScope* self, GError** error) {
 
3507
        ZeitgeistDataSourceRegistry* _tmp0_;
 
3508
        GPtrArray* _tmp1_;
 
3509
        GPtrArray* templates;
 
3510
        ZeitgeistEvent* _tmp2_;
 
3511
        ZeitgeistEvent* ev;
 
3512
        GObject* _tmp3_ = NULL;
 
3513
        GPtrArray* _tmp4_;
 
3514
        ZeitgeistDataSource* _tmp5_;
 
3515
        ZeitgeistDataSource* data_source;
 
3516
        ZeitgeistDataSourceRegistry* _tmp6_;
 
3517
        ZeitgeistDataSource* _tmp7_;
 
3518
        g_return_if_fail (self != NULL);
 
3519
        _tmp0_ = zeitgeist_data_source_registry_new ();
 
3520
        _g_object_unref0 (self->priv->zg_sources);
 
3521
        self->priv->zg_sources = _tmp0_;
 
3522
        _tmp1_ = g_ptr_array_sized_new ((guint) 1);
 
3523
        templates = _tmp1_;
 
3524
        _tmp2_ = zeitgeist_event_new_full (ZEITGEIST_ZG_ACCESS_EVENT, ZEITGEIST_ZG_USER_ACTIVITY, "lens://unity-lens-video", NULL);
 
3525
        g_object_ref_sink (_tmp2_);
 
3526
        ev = _tmp2_;
 
3527
        _tmp3_ = g_object_ref (G_TYPE_CHECK_INSTANCE_TYPE (ev, G_TYPE_OBJECT) ? ((GObject*) ev) : NULL);
 
3528
        g_ptr_array_add (templates, _tmp3_);
 
3529
        _tmp4_ = _g_ptr_array_ref0 (templates);
 
3530
        _tmp5_ = zeitgeist_data_source_new_full ("98898", "Unity Video Lens", "", _tmp4_);
 
3531
        g_object_ref_sink (_tmp5_);
 
3532
        data_source = _tmp5_;
 
3533
        _tmp6_ = self->priv->zg_sources;
 
3534
        _tmp7_ = _g_object_ref0 (data_source);
 
3535
        zeitgeist_data_source_registry_register_data_source (_tmp6_, _tmp7_, NULL, NULL, NULL);
 
3536
        _g_object_unref0 (data_source);
 
3537
        _g_object_unref0 (ev);
 
3538
        _g_ptr_array_unref0 (templates);
 
3539
}
 
3540
 
 
3541
 
 
3542
static void unity_video_lens_remote_video_scope_zeitgeist_insert_event (UnityVideoLensRemoteVideoScope* self, const gchar* uri, const gchar* title, const gchar* icon) {
 
3543
        const gchar* _tmp0_;
 
3544
        const gchar* _tmp1_;
 
3545
        const gchar* _tmp2_;
 
3546
        const gchar* _tmp3_;
 
3547
        ZeitgeistSubject* _tmp4_;
 
3548
        ZeitgeistSubject* subject;
 
3549
        ZeitgeistEvent* _tmp5_;
 
3550
        ZeitgeistEvent* event;
 
3551
        GPtrArray* _tmp6_;
 
3552
        GPtrArray* ev_array;
 
3553
        GObject* _tmp7_ = NULL;
 
3554
        ZeitgeistLog* _tmp8_ = NULL;
 
3555
        GPtrArray* _tmp9_;
 
3556
        g_return_if_fail (self != NULL);
 
3557
        g_return_if_fail (uri != NULL);
 
3558
        g_return_if_fail (title != NULL);
 
3559
        g_return_if_fail (icon != NULL);
 
3560
        _tmp0_ = uri;
 
3561
        _tmp1_ = uri;
 
3562
        _tmp2_ = title;
 
3563
        _tmp3_ = icon;
 
3564
        _tmp4_ = zeitgeist_subject_new_full (_tmp0_, ZEITGEIST_NFO_VIDEO, ZEITGEIST_NFO_REMOTE_DATA_OBJECT, "", _tmp1_, _tmp2_, _tmp3_);
 
3565
        g_object_ref_sink (_tmp4_);
 
3566
        subject = _tmp4_;
 
3567
        _tmp5_ = zeitgeist_event_new_full (ZEITGEIST_ZG_ACCESS_EVENT, ZEITGEIST_ZG_USER_ACTIVITY, "lens://unity-lens-video", NULL);
 
3568
        g_object_ref_sink (_tmp5_);
 
3569
        event = _tmp5_;
 
3570
        zeitgeist_event_add_subject (event, subject);
 
3571
        _tmp6_ = g_ptr_array_sized_new ((guint) 1);
 
3572
        ev_array = _tmp6_;
 
3573
        _tmp7_ = g_object_ref (G_TYPE_CHECK_INSTANCE_TYPE (event, G_TYPE_OBJECT) ? ((GObject*) event) : NULL);
 
3574
        g_ptr_array_add (ev_array, _tmp7_);
 
3575
        _tmp8_ = zeitgeist_log_get_default ();
 
3576
        _tmp9_ = _g_ptr_array_ref0 (ev_array);
 
3577
        zeitgeist_log_insert_events_from_ptrarray (_tmp8_, _tmp9_, NULL, NULL, NULL);
 
3578
        _g_ptr_array_unref0 (ev_array);
 
3579
        _g_object_unref0 (event);
 
3580
        _g_object_unref0 (subject);
 
3581
}
 
3582
 
 
3583
 
 
3584
static void unity_video_lens_remote_video_scope_class_init (UnityVideoLensRemoteVideoScopeClass * klass) {
 
3585
        gchar* _tmp0_;
 
3586
        gchar* _tmp1_;
 
3587
        unity_video_lens_remote_video_scope_parent_class = g_type_class_peek_parent (klass);
 
3588
        g_type_class_add_private (klass, sizeof (UnityVideoLensRemoteVideoScopePrivate));
 
3589
        G_OBJECT_CLASS (klass)->constructed = unity_video_lens_remote_video_scope_real_constructed;
 
3590
        UNITY_DEPRECATED_SCOPE_CLASS (klass)->activate_result = unity_video_lens_remote_video_scope_real_activate_result;
 
3591
        UNITY_DEPRECATED_SCOPE_CLASS (klass)->activate_result_finish = unity_video_lens_remote_video_scope_real_activate_result_finish;
 
3592
        UNITY_DEPRECATED_SCOPE_CLASS (klass)->preview_result = unity_video_lens_remote_video_scope_real_preview_result;
 
3593
        UNITY_DEPRECATED_SCOPE_CLASS (klass)->preview_result_finish = unity_video_lens_remote_video_scope_real_preview_result_finish;
 
3594
        G_OBJECT_CLASS (klass)->finalize = unity_video_lens_remote_video_scope_finalize;
 
3595
        _tmp0_ = g_strdup ("Unknown");
 
3596
        unity_video_lens_remote_video_scope_IS_IN_CHINA = _tmp0_;
 
3597
        _tmp1_ = g_strdup ("lmb-preview");
 
3598
        unity_video_lens_remote_video_scope_PREVIEW_ON_LMB = _tmp1_;
 
3599
}
 
3600
 
 
3601
 
 
3602
static void unity_video_lens_remote_video_scope_instance_init (UnityVideoLensRemoteVideoScope * self) {
 
3603
        UnityPreferencesManager* _tmp0_ = NULL;
 
3604
        self->priv = UNITY_VIDEO_LENS_REMOTE_VIDEO_SCOPE_GET_PRIVATE (self);
 
3605
        _tmp0_ = unity_preferences_manager_get_default ();
 
3606
        self->priv->preferences = _tmp0_;
 
3607
        self->priv->recommendations_last_update = (gint64) 0;
 
3608
}
 
3609
 
 
3610
 
 
3611
static void unity_video_lens_remote_video_scope_finalize (GObject* obj) {
 
3612
        UnityVideoLensRemoteVideoScope * self;
 
3613
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_VIDEO_LENS_TYPE_REMOTE_VIDEO_SCOPE, UnityVideoLensRemoteVideoScope);
 
3614
        _g_object_unref0 (self->priv->session);
 
3615
        _g_object_unref0 (self->priv->preferences);
 
3616
        _g_object_unref0 (self->priv->recommendations);
 
3617
        _g_object_unref0 (self->priv->zg_sources);
 
3618
        G_OBJECT_CLASS (unity_video_lens_remote_video_scope_parent_class)->finalize (obj);
 
3619
}
 
3620
 
 
3621
 
 
3622
GType unity_video_lens_remote_video_scope_get_type (void) {
 
3623
        static volatile gsize unity_video_lens_remote_video_scope_type_id__volatile = 0;
 
3624
        if (g_once_init_enter (&unity_video_lens_remote_video_scope_type_id__volatile)) {
 
3625
                static const GTypeInfo g_define_type_info = { sizeof (UnityVideoLensRemoteVideoScopeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_video_lens_remote_video_scope_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityVideoLensRemoteVideoScope), 0, (GInstanceInitFunc) unity_video_lens_remote_video_scope_instance_init, NULL };
 
3626
                GType unity_video_lens_remote_video_scope_type_id;
 
3627
                unity_video_lens_remote_video_scope_type_id = g_type_register_static (UNITY_TYPE_DEPRECATED_SCOPE, "UnityVideoLensRemoteVideoScope", &g_define_type_info, 0);
 
3628
                g_once_init_leave (&unity_video_lens_remote_video_scope_type_id__volatile, unity_video_lens_remote_video_scope_type_id);
 
3629
        }
 
3630
        return unity_video_lens_remote_video_scope_type_id__volatile;
 
3631
}
 
3632
 
 
3633
 
 
3634
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
3635
        if ((array != NULL) && (destroy_func != NULL)) {
 
3636
                int i;
 
3637
                for (i = 0; i < array_length; i = i + 1) {
 
3638
                        if (((gpointer*) array)[i] != NULL) {
 
3639
                                destroy_func (((gpointer*) array)[i]);
 
3640
                        }
 
3641
                }
 
3642
        }
 
3643
}
 
3644
 
 
3645
 
 
3646
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
3647
        _vala_array_destroy (array, array_length, destroy_func);
 
3648
        g_free (array);
 
3649
}
 
3650
 
 
3651
 
 
3652