[gnome-software] Add the 'featured' action to gnome-software-cmd



commit 56a7d678325d67e410f84227c6c9a5f34155cfd5
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jan 22 09:52:40 2014 +0000

    Add the 'featured' action to gnome-software-cmd
    
    This allows us to profile and debug this action.

 src/gs-cmd.c                |   13 ++++++++++++
 src/gs-plugin-loader-sync.c |   45 +++++++++++++++++++++++++++++++++++++++++++
 src/gs-plugin-loader-sync.h |    4 +++
 3 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 93b120e..1133259 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -303,6 +303,19 @@ main (int argc, char **argv)
                                break;
                        }
                }
+       } else if (argc == 2 && g_strcmp0 (argv[1], "featured") == 0) {
+               for (i = 0; i < repeat; i++) {
+                       if (list != NULL)
+                               gs_plugin_list_free (list);
+                       list = gs_plugin_loader_get_featured (plugin_loader,
+                                                             refine_flags,
+                                                             NULL,
+                                                             &error);
+                       if (list == NULL) {
+                               ret = FALSE;
+                               break;
+                       }
+               }
        } else if (argc == 2 && g_strcmp0 (argv[1], "get-categories") == 0) {
                for (i = 0; i < repeat; i++) {
                        if (list != NULL)
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index cff110a..74ada43 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -237,6 +237,51 @@ gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
 }
 
 static void
+gs_plugin_loader_get_featured_finish_sync (GsPluginLoader *plugin_loader,
+                                         GAsyncResult *res,
+                                         GsPluginLoaderHelper *helper)
+{
+       helper->list = gs_plugin_loader_get_featured_finish (plugin_loader,
+                                                            res,
+                                                            helper->error);
+       g_main_loop_quit (helper->loop);
+}
+
+/**
+ * gs_plugin_loader_get_featured:
+ **/
+GList *
+gs_plugin_loader_get_featured (GsPluginLoader *plugin_loader,
+                              GsPluginRefineFlags flags,
+                              GCancellable *cancellable,
+                              GError **error)
+{
+       GsPluginLoaderHelper helper;
+
+       /* create temp object */
+       helper.context = g_main_context_new ();
+       helper.loop = g_main_loop_new (helper.context, FALSE);
+       helper.error = error;
+
+       g_main_context_push_thread_default (helper.context);
+
+       /* run async method */
+       gs_plugin_loader_get_featured_async (plugin_loader,
+                                            flags,
+                                            cancellable,
+                                            (GAsyncReadyCallback) gs_plugin_loader_get_featured_finish_sync,
+                                            &helper);
+       g_main_loop_run (helper.loop);
+
+       g_main_context_pop_thread_default (helper.context);
+
+       g_main_loop_unref (helper.loop);
+       g_main_context_unref (helper.context);
+
+       return helper.list;
+}
+
+static void
 gs_plugin_loader_get_categories_finish_sync (GsPluginLoader *plugin_loader,
                                             GAsyncResult *res,
                                             GsPluginLoaderHelper *helper)
diff --git a/src/gs-plugin-loader-sync.h b/src/gs-plugin-loader-sync.h
index 6f47489..187983f 100644
--- a/src/gs-plugin-loader-sync.h
+++ b/src/gs-plugin-loader-sync.h
@@ -45,6 +45,10 @@ GList                *gs_plugin_loader_get_popular           (GsPluginLoader 
*plugin_loader,
                                                         GsPluginRefineFlags flags,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+GList          *gs_plugin_loader_get_featured          (GsPluginLoader *plugin_loader,
+                                                        GsPluginRefineFlags flags,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 GList          *gs_plugin_loader_get_categories        (GsPluginLoader *plugin_loader,
                                                         GsPluginRefineFlags flags,
                                                         GCancellable   *cancellable,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]