[gnome-software] Add a self-test plugin only to be used in the self-test framework



commit 07e59d0573087d00bc3dbf08a300ba4a1bc9ed2a
Author: Richard Hughes <richard hughsie com>
Date:   Mon Sep 2 14:55:30 2013 +0100

    Add a self-test plugin only to be used in the self-test framework
    
    This means we can return all applications witouth fully refining them.

 src/plugins/Makefile.am           |    6 +++
 src/plugins/gs-plugin-self-test.c |   64 +++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 27fb549..de689b9 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -32,6 +32,7 @@ plugin_LTLIBRARIES =                                  \
        libgs_plugin_datadir_filename_local.la          \
        libgs_plugin_desktopdb.la                       \
        libgs_plugin_dummy.la                           \
+       libgs_plugin_self_test.la                       \
        libgs_plugin_hardcoded-descriptions.la          \
        libgs_plugin_hardcoded-featured.la              \
        libgs_plugin_hardcoded-kind.la                  \
@@ -48,6 +49,11 @@ libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_dummy_la_LDFLAGS = -module -avoid-version
 libgs_plugin_dummy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
 
+libgs_plugin_self_test_la_SOURCES = gs-plugin-self-test.c
+libgs_plugin_self_test_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_self_test_la_LDFLAGS = -module -avoid-version
+libgs_plugin_self_test_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+
 libgs_plugin_appstream_la_SOURCES = gs-plugin-appstream.c
 libgs_plugin_appstream_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_appstream_la_LDFLAGS = -module -avoid-version
diff --git a/src/plugins/gs-plugin-self-test.c b/src/plugins/gs-plugin-self-test.c
new file mode 100644
index 0000000..0da1b73
--- /dev/null
+++ b/src/plugins/gs-plugin-self-test.c
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011-2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <gs-plugin.h>
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+       return "self-test";
+}
+
+/**
+ * gs_plugin_get_priority:
+ */
+gdouble
+gs_plugin_get_priority (GsPlugin *plugin)
+{
+       return 1.0f;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+                 GList *list,
+                 GCancellable *cancellable,
+                 GError **error)
+{
+       GsApp *app;
+       GList *l;
+
+       for (l = list; l != NULL; l = l->next) {
+               app = GS_APP (l->data);
+               if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN) {
+                       gs_app_set_state (app, GS_APP_STATE_INSTALLED);
+                       gs_app_set_kind (app, GS_APP_KIND_NORMAL);
+               }
+       }
+       return TRUE;
+}


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