1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* Copyright (C) 2012-2014 Richard Hughes <richard@hughsie.com>
5
* Licensed under the GNU General Public License Version 2
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
#include "gs-plugin-loader-sync.h"
27
* gs_plugin_loader_get_app_by_id:
30
gs_plugin_loader_get_app_by_id (GsPluginLoader *plugin_loader,
32
GsPluginRefineFlags flags,
33
GCancellable *cancellable,
39
app = gs_app_new (id);
40
app = gs_plugin_loader_dedupe (plugin_loader, app);
41
ret = gs_plugin_loader_app_refine (plugin_loader, app, flags,
44
g_clear_object (&app);
48
/* tiny helper to help us do the async operation */
52
GMainContext *context;
56
} GsPluginLoaderHelper;
59
gs_plugin_loader_get_installed_finish_sync (GsPluginLoader *plugin_loader,
61
GsPluginLoaderHelper *helper)
63
helper->list = gs_plugin_loader_get_installed_finish (plugin_loader,
66
g_main_loop_quit (helper->loop);
70
* gs_plugin_loader_get_installed:
73
gs_plugin_loader_get_installed (GsPluginLoader *plugin_loader,
74
GsPluginRefineFlags flags,
75
GCancellable *cancellable,
78
GsPluginLoaderHelper helper;
80
/* create temp object */
81
helper.context = g_main_context_new ();
82
helper.loop = g_main_loop_new (helper.context, FALSE);
85
g_main_context_push_thread_default (helper.context);
87
/* run async method */
88
gs_plugin_loader_get_installed_async (plugin_loader,
91
(GAsyncReadyCallback) gs_plugin_loader_get_installed_finish_sync,
93
g_main_loop_run (helper.loop);
95
g_main_context_pop_thread_default (helper.context);
97
g_main_loop_unref (helper.loop);
98
g_main_context_unref (helper.context);
104
gs_plugin_loader_search_finish_sync (GsPluginLoader *plugin_loader,
106
GsPluginLoaderHelper *helper)
108
helper->list = gs_plugin_loader_search_finish (plugin_loader,
111
g_main_loop_quit (helper->loop);
115
* gs_plugin_loader_search:
118
gs_plugin_loader_search (GsPluginLoader *plugin_loader,
120
GsPluginRefineFlags flags,
121
GCancellable *cancellable,
124
GsPluginLoaderHelper helper;
126
/* create temp object */
127
helper.context = g_main_context_new ();
128
helper.loop = g_main_loop_new (helper.context, FALSE);
129
helper.error = error;
131
g_main_context_push_thread_default (helper.context);
133
/* run async method */
134
gs_plugin_loader_search_async (plugin_loader,
138
(GAsyncReadyCallback) gs_plugin_loader_search_finish_sync,
140
g_main_loop_run (helper.loop);
142
g_main_context_pop_thread_default (helper.context);
144
g_main_loop_unref (helper.loop);
145
g_main_context_unref (helper.context);
151
gs_plugin_loader_get_updates_finish_sync (GsPluginLoader *plugin_loader,
153
GsPluginLoaderHelper *helper)
155
helper->list = gs_plugin_loader_get_updates_finish (plugin_loader,
158
g_main_loop_quit (helper->loop);
162
* gs_plugin_loader_get_updates:
165
gs_plugin_loader_get_updates (GsPluginLoader *plugin_loader,
166
GsPluginRefineFlags flags,
167
GCancellable *cancellable,
170
GsPluginLoaderHelper helper;
172
/* create temp object */
173
helper.context = g_main_context_new ();
174
helper.loop = g_main_loop_new (helper.context, FALSE);
175
helper.error = error;
177
g_main_context_push_thread_default (helper.context);
179
/* run async method */
180
gs_plugin_loader_get_updates_async (plugin_loader,
183
(GAsyncReadyCallback) gs_plugin_loader_get_updates_finish_sync,
185
g_main_loop_run (helper.loop);
187
g_main_context_pop_thread_default (helper.context);
189
g_main_loop_unref (helper.loop);
190
g_main_context_unref (helper.context);
196
gs_plugin_loader_get_sources_finish_sync (GsPluginLoader *plugin_loader,
198
GsPluginLoaderHelper *helper)
200
helper->list = gs_plugin_loader_get_sources_finish (plugin_loader,
203
g_main_loop_quit (helper->loop);
207
* gs_plugin_loader_get_sources:
210
gs_plugin_loader_get_sources (GsPluginLoader *plugin_loader,
211
GsPluginRefineFlags flags,
212
GCancellable *cancellable,
215
GsPluginLoaderHelper helper;
217
/* create temp object */
218
helper.context = g_main_context_new ();
219
helper.loop = g_main_loop_new (helper.context, FALSE);
220
helper.error = error;
222
g_main_context_push_thread_default (helper.context);
224
/* run async method */
225
gs_plugin_loader_get_sources_async (plugin_loader,
228
(GAsyncReadyCallback) gs_plugin_loader_get_sources_finish_sync,
230
g_main_loop_run (helper.loop);
232
g_main_context_pop_thread_default (helper.context);
234
g_main_loop_unref (helper.loop);
235
g_main_context_unref (helper.context);
241
gs_plugin_loader_get_popular_finish_sync (GsPluginLoader *plugin_loader,
243
GsPluginLoaderHelper *helper)
245
helper->list = gs_plugin_loader_get_popular_finish (plugin_loader,
248
g_main_loop_quit (helper->loop);
252
* gs_plugin_loader_get_popular:
255
gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
256
GsPluginRefineFlags flags,
257
const gchar *category,
258
const gchar *category_exclude,
259
GCancellable *cancellable,
262
GsPluginLoaderHelper helper;
264
/* create temp object */
265
helper.context = g_main_context_new ();
266
helper.loop = g_main_loop_new (helper.context, FALSE);
267
helper.error = error;
269
g_main_context_push_thread_default (helper.context);
271
/* run async method */
272
gs_plugin_loader_get_popular_async (plugin_loader,
277
(GAsyncReadyCallback) gs_plugin_loader_get_popular_finish_sync,
279
g_main_loop_run (helper.loop);
281
g_main_context_pop_thread_default (helper.context);
283
g_main_loop_unref (helper.loop);
284
g_main_context_unref (helper.context);
290
gs_plugin_loader_get_featured_finish_sync (GsPluginLoader *plugin_loader,
292
GsPluginLoaderHelper *helper)
294
helper->list = gs_plugin_loader_get_featured_finish (plugin_loader,
297
g_main_loop_quit (helper->loop);
301
* gs_plugin_loader_get_featured:
304
gs_plugin_loader_get_featured (GsPluginLoader *plugin_loader,
305
GsPluginRefineFlags flags,
306
GCancellable *cancellable,
309
GsPluginLoaderHelper helper;
311
/* create temp object */
312
helper.context = g_main_context_new ();
313
helper.loop = g_main_loop_new (helper.context, FALSE);
314
helper.error = error;
316
g_main_context_push_thread_default (helper.context);
318
/* run async method */
319
gs_plugin_loader_get_featured_async (plugin_loader,
322
(GAsyncReadyCallback) gs_plugin_loader_get_featured_finish_sync,
324
g_main_loop_run (helper.loop);
326
g_main_context_pop_thread_default (helper.context);
328
g_main_loop_unref (helper.loop);
329
g_main_context_unref (helper.context);
335
gs_plugin_loader_get_categories_finish_sync (GsPluginLoader *plugin_loader,
337
GsPluginLoaderHelper *helper)
339
helper->list = gs_plugin_loader_get_categories_finish (plugin_loader,
342
g_main_loop_quit (helper->loop);
346
* gs_plugin_loader_get_categories:
349
gs_plugin_loader_get_categories (GsPluginLoader *plugin_loader,
350
GsPluginRefineFlags flags,
351
GCancellable *cancellable,
354
GsPluginLoaderHelper helper;
356
/* create temp object */
357
helper.context = g_main_context_new ();
358
helper.loop = g_main_loop_new (helper.context, FALSE);
359
helper.error = error;
361
g_main_context_push_thread_default (helper.context);
363
/* run async method */
364
gs_plugin_loader_get_categories_async (plugin_loader,
367
(GAsyncReadyCallback) gs_plugin_loader_get_categories_finish_sync,
369
g_main_loop_run (helper.loop);
371
g_main_context_pop_thread_default (helper.context);
373
g_main_loop_unref (helper.loop);
374
g_main_context_unref (helper.context);
380
gs_plugin_loader_get_category_apps_finish_sync (GsPluginLoader *plugin_loader,
382
GsPluginLoaderHelper *helper)
384
helper->list = gs_plugin_loader_get_category_apps_finish (plugin_loader,
387
g_main_loop_quit (helper->loop);
391
* gs_plugin_loader_get_category_apps:
394
gs_plugin_loader_get_category_apps (GsPluginLoader *plugin_loader,
395
GsCategory *category,
396
GsPluginRefineFlags flags,
397
GCancellable *cancellable,
400
GsPluginLoaderHelper helper;
402
/* create temp object */
403
helper.context = g_main_context_new ();
404
helper.loop = g_main_loop_new (helper.context, FALSE);
405
helper.error = error;
407
g_main_context_push_thread_default (helper.context);
409
/* run async method */
410
gs_plugin_loader_get_category_apps_async (plugin_loader,
414
(GAsyncReadyCallback) gs_plugin_loader_get_category_apps_finish_sync,
416
g_main_loop_run (helper.loop);
418
g_main_context_pop_thread_default (helper.context);
420
g_main_loop_unref (helper.loop);
421
g_main_context_unref (helper.context);
427
* gs_plugin_loader_app_refine_finish_sync:
430
gs_plugin_loader_app_refine_finish_sync (GsPluginLoader *plugin_loader,
432
GsPluginLoaderHelper *helper)
434
helper->ret = gs_plugin_loader_app_refine_finish (plugin_loader,
437
g_main_loop_quit (helper->loop);
441
* gs_plugin_loader_app_refine:
444
gs_plugin_loader_app_refine (GsPluginLoader *plugin_loader,
446
GsPluginRefineFlags flags,
447
GCancellable *cancellable,
450
GsPluginLoaderHelper helper;
452
/* create temp object */
453
helper.context = g_main_context_new ();
454
helper.loop = g_main_loop_new (helper.context, FALSE);
455
helper.error = error;
457
g_main_context_push_thread_default (helper.context);
459
/* run async method */
460
gs_plugin_loader_app_refine_async (plugin_loader,
464
(GAsyncReadyCallback) gs_plugin_loader_app_refine_finish_sync,
466
g_main_loop_run (helper.loop);
468
g_main_context_pop_thread_default (helper.context);
470
g_main_loop_unref (helper.loop);
471
g_main_context_unref (helper.context);
477
* gs_plugin_loader_app_action_finish_sync:
480
gs_plugin_loader_app_action_finish_sync (GsPluginLoader *plugin_loader,
482
GsPluginLoaderHelper *helper)
484
helper->ret = gs_plugin_loader_app_action_finish (plugin_loader,
487
g_main_loop_quit (helper->loop);
491
* gs_plugin_loader_app_action:
494
gs_plugin_loader_app_action (GsPluginLoader *plugin_loader,
496
GsPluginLoaderAction action,
497
GCancellable *cancellable,
500
GsPluginLoaderHelper helper;
502
/* create temp object */
503
helper.context = g_main_context_new ();
504
helper.loop = g_main_loop_new (helper.context, FALSE);
505
helper.error = error;
507
g_main_context_push_thread_default (helper.context);
509
/* run async method */
510
gs_plugin_loader_app_action_async (plugin_loader,
514
(GAsyncReadyCallback) gs_plugin_loader_app_action_finish_sync,
516
g_main_loop_run (helper.loop);
518
g_main_context_pop_thread_default (helper.context);
520
g_main_loop_unref (helper.loop);
521
g_main_context_unref (helper.context);
527
* gs_plugin_loader_refresh_finish_sync:
530
gs_plugin_loader_refresh_finish_sync (GsPluginLoader *plugin_loader,
532
GsPluginLoaderHelper *helper)
534
helper->ret = gs_plugin_loader_refresh_finish (plugin_loader,
537
g_main_loop_quit (helper->loop);
541
* gs_plugin_loader_refresh:
544
gs_plugin_loader_refresh (GsPluginLoader *plugin_loader,
546
GsPluginRefreshFlags flags,
547
GCancellable *cancellable,
550
GsPluginLoaderHelper helper;
552
/* create temp object */
553
helper.context = g_main_context_new ();
554
helper.loop = g_main_loop_new (helper.context, FALSE);
555
helper.error = error;
557
g_main_context_push_thread_default (helper.context);
559
/* run async method */
560
gs_plugin_loader_refresh_async (plugin_loader,
564
(GAsyncReadyCallback) gs_plugin_loader_refresh_finish_sync,
566
g_main_loop_run (helper.loop);
568
g_main_context_pop_thread_default (helper.context);
570
g_main_loop_unref (helper.loop);
571
g_main_context_unref (helper.context);
577
gs_plugin_loader_filename_to_app_finish_sync (GObject *source_object,
581
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
582
GsPluginLoaderHelper *helper = (GsPluginLoaderHelper *) user_data;
583
helper->app = gs_plugin_loader_filename_to_app_finish (plugin_loader,
586
g_main_loop_quit (helper->loop);
590
* gs_plugin_loader_filename_to_app:
593
gs_plugin_loader_filename_to_app (GsPluginLoader *plugin_loader,
594
const gchar *filename,
595
GsPluginRefineFlags flags,
596
GCancellable *cancellable,
599
GsPluginLoaderHelper helper;
601
/* create temp object */
603
helper.context = g_main_context_new ();
604
helper.loop = g_main_loop_new (helper.context, FALSE);
605
helper.error = error;
607
g_main_context_push_thread_default (helper.context);
609
/* run async method */
610
gs_plugin_loader_filename_to_app_async (plugin_loader,
614
gs_plugin_loader_filename_to_app_finish_sync,
616
g_main_loop_run (helper.loop);
618
g_main_context_pop_thread_default (helper.context);
620
g_main_loop_unref (helper.loop);
621
g_main_context_unref (helper.context);
626
/* vim: set noexpandtab: */