[gnome-software/wip/libappstream: 159/159] Some preliminary attempt to get GS working with libas again



commit e0761b6e08ada9a2695b55c96894590c0632f485
Author: Matthias Klumpp <matthias tenstral net>
Date:   Thu Jul 31 22:35:17 2014 +0200

    Some preliminary attempt to get GS working with libas again

 configure.ac                         |    4 +-
 src/gs-app.h                         |    3 +-
 src/plugins/Makefile.am              |   14 ++++++------
 src/plugins/as-dummy.h               |   35 +++++++++++++++++++++++++++++
 src/plugins/gs-plugin-libappstream.c |   40 ++++++++++++---------------------
 5 files changed, 61 insertions(+), 35 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 62f3a28..2137b33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,10 +59,10 @@ GLIB_GSETTINGS
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.13.1 gio-unix-2.0)
+PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.12.1 gio-unix-2.0)
 PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= 0.8.12)
 PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.2.4)
-PKG_CHECK_MODULES(LIBAPPSTREAM, appstream >= 0.6.2)
+PKG_CHECK_MODULES(LIBAPPSTREAM, appstream >= 0.7.0)
 PKG_CHECK_MODULES(SQLITE, sqlite3)
 PKG_CHECK_MODULES(SOUP, libsoup-2.4)
 PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
diff --git a/src/gs-app.h b/src/gs-app.h
index 3c64f04..2b6bd6f 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -24,7 +24,8 @@
 
 #include <glib-object.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
-#include <appstream-glib.h>
+#include <appstream.h>
+#include "plugins/as-dummy.h"
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 8434699..1d88a08 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -20,9 +20,9 @@ AM_CPPFLAGS =                                         \
        -DTESTDATADIR=\""$(top_srcdir)/data/tests"\"    \
        -I$(top_srcdir)/src
 
-noinst_LTLIBRARIES =                                   \
-       libgs_plugin_dummy.la                           \
-       libgs_plugin_self_test.la
+#noinst_LTLIBRARIES =                                  \
+#      libgs_plugin_dummy.la                           \
+#      libgs_plugin_self_test.la
 
 plugindir = $(libdir)/gs-plugins-${GS_PLUGIN_API_VERSION}
 plugin_LTLIBRARIES =                                   \
@@ -46,10 +46,10 @@ plugin_LTLIBRARIES =                                        \
        libgs_plugin_packagekit-history.la              \
        libgs_plugin_packagekit.la
 
-libgs_plugin_dummy_la_SOURCES = gs-plugin-dummy.c
-libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_dummy_la_LDFLAGS = -module -avoid-version
-libgs_plugin_dummy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
+#libgs_plugin_dummy_la_SOURCES = gs-plugin-dummy.c
+#libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
+#libgs_plugin_dummy_la_LDFLAGS = -module -avoid-version
+#libgs_plugin_dummy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
 
 libgs_plugin_fedora_tagger_ratings_la_SOURCES = gs-plugin-fedora-tagger-ratings.c
 libgs_plugin_fedora_tagger_ratings_la_LIBADD = $(GS_PLUGIN_LIBS) $(SOUP_LIBS) $(SQLITE_LIBS)
diff --git a/src/plugins/as-dummy.h b/src/plugins/as-dummy.h
new file mode 100644
index 0000000..aef2b67
--- /dev/null
+++ b/src/plugins/as-dummy.h
@@ -0,0 +1,35 @@
+
+
+#ifndef __GS_ASDUMMY_H
+#define __GS_ASDUMMY_H
+
+#define AsIdKind AsComponentKind
+
+/**
+ * AsAppState:
+ * @AS_APP_STATE_UNKNOWN:                      Unknown state
+ * @AS_APP_STATE_INSTALLED:                    Application is installed
+ * @AS_APP_STATE_AVAILABLE:                    Application is available
+ * @AS_APP_STATE_AVAILABLE_LOCAL:              Application is locally available as a file
+ * @AS_APP_STATE_UPDATABLE:                    Application is installed and updatable
+ * @AS_APP_STATE_UNAVAILABLE:                  Application is referenced, but not available
+ * @AS_APP_STATE_QUEUED_FOR_INSTALL:           Application is queued for install
+ * @AS_APP_STATE_INSTALLING:                   Application is being installed
+ * @AS_APP_STATE_REMOVING:                     Application is being removed
+ *
+ * The application state.
+ **/
+typedef enum {
+       AS_APP_STATE_UNKNOWN,                           /* Since: 0.2.2 */
+       AS_APP_STATE_INSTALLED,                         /* Since: 0.2.2 */
+       AS_APP_STATE_AVAILABLE,                         /* Since: 0.2.2 */
+       AS_APP_STATE_AVAILABLE_LOCAL,                   /* Since: 0.2.2 */
+       AS_APP_STATE_UPDATABLE,                         /* Since: 0.2.2 */
+       AS_APP_STATE_UNAVAILABLE,                       /* Since: 0.2.2 */
+       AS_APP_STATE_QUEUED_FOR_INSTALL,                /* Since: 0.2.2 */
+       AS_APP_STATE_INSTALLING,                        /* Since: 0.2.2 */
+       AS_APP_STATE_REMOVING,                          /* Since: 0.2.2 */
+       AS_APP_STATE_LAST
+} AsAppState;
+
+#endif
diff --git a/src/plugins/gs-plugin-libappstream.c b/src/plugins/gs-plugin-libappstream.c
index c4f778f..cbcaf02 100644
--- a/src/plugins/gs-plugin-libappstream.c
+++ b/src/plugins/gs-plugin-libappstream.c
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
+ * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
  * Copyright (C) 2014 Matthias Klumpp <matthias tenstral net>
  *
  * Licensed under the GNU General Public License Version 2
@@ -24,6 +25,8 @@
 #include <locale.h>
 #include <appstream.h>
 
+#include "as-dummy.h"
+
 #include <gs-plugin.h>
 #include <gs-plugin-loader.h>
 
@@ -135,14 +138,11 @@ out:
 static void
 gs_plugin_refine_add_screenshots (GsApp *app, AsComponent *item)
 {
-       AsImage *im;
        AsScreenshot *ss;
        AsScreenshotKind ss_kind;
        GPtrArray *images_as;
        GPtrArray *screenshots_as;
-       GsScreenshot *screenshot;
        guint i;
-       guint j;
 
        /* do we have any to add */
        screenshots_as = as_component_get_screenshots (item);
@@ -165,21 +165,7 @@ gs_plugin_refine_add_screenshots (GsApp *app, AsComponent *item)
                if (ss_kind == AS_SCREENSHOT_KIND_UNKNOWN)
                        continue;
 
-               /* create a new application screenshot and add each image */
-               screenshot = gs_screenshot_new ();
-               gs_screenshot_set_is_default (screenshot,
-                                             ss_kind == AS_SCREENSHOT_KIND_DEFAULT);
-               gs_screenshot_set_caption (screenshot,
-                                          as_screenshot_get_caption (ss));
-               for (j = 0; j < images_as->len; j++) {
-                       im = g_ptr_array_index (images_as, j);
-                       gs_screenshot_add_image (screenshot,
-                                                as_image_get_url (im),
-                                                as_image_get_width (im),
-                                                as_image_get_height (im));
-               }
-               gs_app_add_screenshot (app, screenshot);
-               g_object_unref (screenshot);
+               gs_app_add_screenshot (app, ss);
        }
 }
 
@@ -205,8 +191,8 @@ gs_plugin_refine_item (GsPlugin *plugin,
        }
 
        /* FIXME: This looks like a hack... Need to learn how to properly set app states */
-       if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN)
-               gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+       if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
+               gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
 
        /* set id */
        gs_app_set_id (app, as_component_get_id (item));
@@ -230,13 +216,13 @@ gs_plugin_refine_item (GsPlugin *plugin,
        /* add urls */
        urls = as_component_get_urls (item);
        if (g_hash_table_size (urls) > 0 &&
-           gs_app_get_url (app, GS_APP_URL_KIND_HOMEPAGE) == NULL) {
+           gs_app_get_url (app, AS_URL_KIND_HOMEPAGE) == NULL) {
                GList *keys;
                GList *l;
                keys = g_hash_table_get_keys (urls);
                for (l = keys; l != NULL; l = l->next) {
                        gs_app_set_url (app,
-                                       l->data,
+                                       as_url_kind_from_string (l->data),
                                        g_hash_table_lookup (urls, l->data));
                }
                g_list_free (keys);
@@ -304,7 +290,11 @@ gs_plugin_refine_item (GsPlugin *plugin,
        /* set package names */
        pkgs = gs_app_get_sources (app);
        if (pkgs->len == 0) {
-               g_ptr_array_add (pkgs, g_strdup (as_component_get_pkgname (item)));
+               guint i;
+               gchar **pkg_names = as_component_get_pkgnames (item);
+               for (i = 0; pkg_names[i] != NULL; i++) {
+                       g_ptr_array_add (pkgs, g_strdup (pkg_names[i]));
+               }
        }
 
        /* set screenshots */
@@ -422,7 +412,7 @@ gs_plugin_add_search (GsPlugin *plugin,
        /* search categories for the search term */
        gs_profile_start (plugin->profile, "appstream::search");
        term = g_strjoinv (",", values);
-       array = as_database_find_components_by_str (plugin->priv->db, term, NULL);
+       array = as_database_find_components_by_term (plugin->priv->db, term, NULL);
 
        if ((array == NULL) || (array->len == 0)) {
                g_set_error (error,
@@ -559,7 +549,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
        }
 
        /* quick-find the applications */
-       array = as_database_find_components_by_str (plugin->priv->db, "", search_id1);
+       array = as_database_find_components_by_term (plugin->priv->db, "", search_id1);
        if ((array == NULL) || (array->len == 0)) {
                g_set_error (error,
                             GS_PLUGIN_LOADER_ERROR,


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