[gnome-software] Parse the AppStream <project_group> tag



commit 0d37ad5a4dec389b1f01db942af10dbff1ec6af8
Author: Richard Hughes <richard hughsie com>
Date:   Thu Sep 19 11:58:36 2013 +0100

    Parse the AppStream <project_group> tag

 src/plugins/appstream-app.c   |   22 ++++++++++++++++++++++
 src/plugins/appstream-app.h   |    4 ++++
 src/plugins/appstream-cache.c |   17 +++++++++++++++++
 3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/appstream-app.c b/src/plugins/appstream-app.c
index 36c0127..b0802ea 100644
--- a/src/plugins/appstream-app.c
+++ b/src/plugins/appstream-app.c
@@ -37,6 +37,7 @@ struct AppstreamApp
        gchar                   *description;
        guint                    description_value;
        gchar                   *url;
+       gchar                   *project_group;
        gchar                   *icon;
        AppstreamAppIconKind     icon_kind;
        GPtrArray               *appcategories;
@@ -79,6 +80,7 @@ appstream_app_free (AppstreamApp *app)
        g_free (app->id);
        g_free (app->pkgname);
        g_free (app->url);
+       g_free (app->project_group);
        g_free (app->icon);
        g_free (app->name);
        g_free (app->summary);
@@ -174,6 +176,15 @@ appstream_app_get_url (AppstreamApp *app)
 }
 
 /**
+ * appstream_app_get_project_group:
+ */
+const gchar *
+appstream_app_get_project_group (AppstreamApp *app)
+{
+       return app->project_group;
+}
+
+/**
  * appstream_app_get_description:
  */
 const gchar *
@@ -295,6 +306,17 @@ appstream_app_set_url (AppstreamApp *app,
 }
 
 /**
+ * appstream_app_set_project_group:
+ */
+void
+appstream_app_set_project_group (AppstreamApp *app,
+                                const gchar *project_group,
+                                gsize length)
+{
+       app->project_group = g_strndup (project_group, length);
+}
+
+/**
  * appstream_app_set_description:
  */
 void
diff --git a/src/plugins/appstream-app.h b/src/plugins/appstream-app.h
index 03c0569..e845233 100644
--- a/src/plugins/appstream-app.h
+++ b/src/plugins/appstream-app.h
@@ -42,6 +42,7 @@ const gchar   *appstream_app_get_id                   (AppstreamApp   *app);
 const gchar    *appstream_app_get_pkgname              (AppstreamApp   *app);
 const gchar    *appstream_app_get_name                 (AppstreamApp   *app);
 const gchar    *appstream_app_get_summary              (AppstreamApp   *app);
+const gchar    *appstream_app_get_project_group        (AppstreamApp   *app);
 const gchar    *appstream_app_get_url                  (AppstreamApp   *app);
 const gchar    *appstream_app_get_description          (AppstreamApp   *app);
 const gchar    *appstream_app_get_icon                 (AppstreamApp   *app);
@@ -66,6 +67,9 @@ void           appstream_app_set_summary              (AppstreamApp   *app,
 void            appstream_app_set_url                  (AppstreamApp   *app,
                                                         const gchar    *summary,
                                                         gsize           length);
+void            appstream_app_set_project_group        (AppstreamApp   *app,
+                                                        const gchar    *project_group,
+                                                        gsize           length);
 void            appstream_app_set_description          (AppstreamApp   *app,
                                                         const gchar    *lang,
                                                         const gchar    *description,
diff --git a/src/plugins/appstream-cache.c b/src/plugins/appstream-cache.c
index e114a5b..e6bb2de 100644
--- a/src/plugins/appstream-cache.c
+++ b/src/plugins/appstream-cache.c
@@ -42,6 +42,7 @@ typedef enum {
        APPSTREAM_CACHE_SECTION_APPCATEGORY,
        APPSTREAM_CACHE_SECTION_KEYWORDS,
        APPSTREAM_CACHE_SECTION_KEYWORD,
+       APPSTREAM_CACHE_SECTION_PROJECT_GROUP,
        APPSTREAM_CACHE_SECTION_LAST
 } AppstreamCacheSection;
 
@@ -125,6 +126,8 @@ appstream_cache_selection_from_string (const gchar *element_name)
                return APPSTREAM_CACHE_SECTION_NAME;
        if (g_strcmp0 (element_name, "summary") == 0)
                return APPSTREAM_CACHE_SECTION_SUMMARY;
+       if (g_strcmp0 (element_name, "project_group") == 0)
+               return APPSTREAM_CACHE_SECTION_PROJECT_GROUP;
        if (g_strcmp0 (element_name, "url") == 0)
                return APPSTREAM_CACHE_SECTION_URL;
        if (g_strcmp0 (element_name, "description") == 0)
@@ -160,6 +163,8 @@ appstream_cache_selection_to_string (AppstreamCacheSection section)
                return "name";
        if (section == APPSTREAM_CACHE_SECTION_SUMMARY)
                return "summary";
+       if (section == APPSTREAM_CACHE_SECTION_PROJECT_GROUP)
+               return "project_group";
        if (section == APPSTREAM_CACHE_SECTION_URL)
                return "url";
        if (section == APPSTREAM_CACHE_SECTION_DESCRIPTION)
@@ -260,6 +265,7 @@ appstream_cache_start_element_cb (GMarkupParseContext *context,
        case APPSTREAM_CACHE_SECTION_ID:
        case APPSTREAM_CACHE_SECTION_PKGNAME:
        case APPSTREAM_CACHE_SECTION_URL:
+       case APPSTREAM_CACHE_SECTION_PROJECT_GROUP:
                if (helper->item_temp == NULL ||
                    helper->section != APPSTREAM_CACHE_SECTION_APPLICATION) {
                        g_set_error (error,
@@ -354,6 +360,7 @@ appstream_cache_end_element_cb (GMarkupParseContext *context,
                break;
        case APPSTREAM_CACHE_SECTION_NAME:
        case APPSTREAM_CACHE_SECTION_SUMMARY:
+       case APPSTREAM_CACHE_SECTION_PROJECT_GROUP:
        case APPSTREAM_CACHE_SECTION_DESCRIPTION:
                helper->section = APPSTREAM_CACHE_SECTION_APPLICATION;
                g_free (helper->lang_temp);
@@ -448,6 +455,16 @@ appstream_cache_text_cb (GMarkupParseContext *context,
                }
                appstream_app_set_summary (helper->item_temp, helper->lang_temp, text, text_len);
                break;
+       case APPSTREAM_CACHE_SECTION_PROJECT_GROUP:
+               if (helper->item_temp == NULL) {
+                       g_set_error_literal (error,
+                                            APPSTREAM_CACHE_ERROR,
+                                            APPSTREAM_CACHE_ERROR_FAILED,
+                                            "item_temp project_group invalid");
+                       return;
+               }
+               appstream_app_set_project_group (helper->item_temp, text, text_len);
+               break;
        case APPSTREAM_CACHE_SECTION_URL:
                if (helper->item_temp == NULL ||
                    appstream_app_get_url (helper->item_temp) != NULL) {



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