[gnome-software] Support the AppStream <project_license> tag



commit 64f78289f9f59e8ffcf27b07e9b4fad1ba35b115
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 25 15:17:53 2014 +0000

    Support the AppStream <project_license> tag
    
    This is renamed from the original confusing <licence> tag.

 src/plugins/appstream-app.c       |   20 ++++++++++----------
 src/plugins/appstream-app.h       |    6 +++---
 src/plugins/appstream-cache.c     |   12 ++++++------
 src/plugins/appstream-common.c    |   10 ++++++----
 src/plugins/appstream-common.h    |    2 +-
 src/plugins/gs-plugin-appdata.c   |    2 +-
 src/plugins/gs-plugin-appstream.c |    4 ++--
 7 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/src/plugins/appstream-app.c b/src/plugins/appstream-app.c
index 08a933f..0774243 100644
--- a/src/plugins/appstream-app.c
+++ b/src/plugins/appstream-app.c
@@ -41,7 +41,7 @@ struct AppstreamApp
        gchar                   *description;
        gchar                   *description_lang;
        GHashTable              *urls;
-       gchar                   *licence;
+       gchar                   *project_license;
        gchar                   *project_group;
        gchar                   *icon;
        AppstreamAppIconKind     icon_kind;
@@ -83,7 +83,7 @@ appstream_app_free (AppstreamApp *app)
        g_free (app->id);
        g_ptr_array_unref (app->pkgnames);
        g_hash_table_unref (app->urls);
-       g_free (app->licence);
+       g_free (app->project_license);
        g_free (app->project_group);
        g_free (app->icon);
        g_free (app->name);
@@ -212,12 +212,12 @@ appstream_app_get_keywords (AppstreamApp *app)
 }
 
 /**
- * appstream_app_get_licence:
+ * appstream_app_get_project_license:
  */
 const gchar *
-appstream_app_get_licence (AppstreamApp *app)
+appstream_app_get_project_license (AppstreamApp *app)
 {
-       return app->licence;
+       return app->project_license;
 }
 
 /**
@@ -398,14 +398,14 @@ appstream_app_add_url (AppstreamApp *app,
 }
 
 /**
- * appstream_app_set_licence:
+ * appstream_app_set_project_license:
  */
 void
-appstream_app_set_licence (AppstreamApp *app,
-                          const gchar *licence,
-                          gsize length)
+appstream_app_set_project_license (AppstreamApp *app,
+                                  const gchar *project_license,
+                                  gsize length)
 {
-       app->licence = g_strndup (licence, length);
+       app->project_license = g_strndup (project_license, length);
 }
 
 /**
diff --git a/src/plugins/appstream-app.h b/src/plugins/appstream-app.h
index eb1b2c6..c6f43bd 100644
--- a/src/plugins/appstream-app.h
+++ b/src/plugins/appstream-app.h
@@ -60,7 +60,7 @@ const gchar   *appstream_app_get_summary              (AppstreamApp   *app);
 const gchar    *appstream_app_get_project_group        (AppstreamApp   *app);
 GHashTable     *appstream_app_get_urls                 (AppstreamApp   *app);
 GPtrArray      *appstream_app_get_keywords             (AppstreamApp   *app);
-const gchar    *appstream_app_get_licence              (AppstreamApp   *app);
+const gchar    *appstream_app_get_project_license      (AppstreamApp   *app);
 const gchar    *appstream_app_get_description          (AppstreamApp   *app);
 const gchar    *appstream_app_get_icon                 (AppstreamApp   *app);
 gboolean        appstream_app_has_category             (AppstreamApp   *app,
@@ -90,8 +90,8 @@ void           appstream_app_add_url                  (AppstreamApp   *app,
                                                         const gchar    *kind,
                                                         const gchar    *summary,
                                                         gsize           length);
-void            appstream_app_set_licence              (AppstreamApp   *app,
-                                                        const gchar    *licence,
+void            appstream_app_set_project_license      (AppstreamApp   *app,
+                                                        const gchar    *project_license,
                                                         gsize           length);
 void            appstream_app_set_project_group        (AppstreamApp   *app,
                                                         const gchar    *project_group,
diff --git a/src/plugins/appstream-cache.c b/src/plugins/appstream-cache.c
index 99b328c..112a12d 100644
--- a/src/plugins/appstream-cache.c
+++ b/src/plugins/appstream-cache.c
@@ -384,7 +384,7 @@ appstream_cache_start_element_cb (GMarkupParseContext *context,
                        helper->url_type_temp = g_strdup ("homepage");
                break;
        case APPSTREAM_TAG_PKGNAME:
-       case APPSTREAM_TAG_LICENCE:
+       case APPSTREAM_TAG_PROJECT_LICENSE:
        case APPSTREAM_TAG_PROJECT_GROUP:
                if (helper->item_temp == NULL ||
                    helper->tag != APPSTREAM_TAG_APPLICATION) {
@@ -570,7 +570,7 @@ appstream_cache_end_element_cb (GMarkupParseContext *context,
        case APPSTREAM_TAG_COMPULSORY_FOR_DESKTOP:
        case APPSTREAM_TAG_KEYWORDS:
        case APPSTREAM_TAG_MIMETYPES:
-       case APPSTREAM_TAG_LICENCE:
+       case APPSTREAM_TAG_PROJECT_LICENSE:
        case APPSTREAM_TAG_ICON:
                helper->tag = APPSTREAM_TAG_APPLICATION;
                break;
@@ -733,16 +733,16 @@ appstream_cache_text_cb (GMarkupParseContext *context,
                                       helper->url_type_temp,
                                       text, text_len);
                break;
-       case APPSTREAM_TAG_LICENCE:
+       case APPSTREAM_TAG_PROJECT_LICENSE:
                if (helper->item_temp == NULL ||
-                   appstream_app_get_licence (helper->item_temp) != NULL) {
+                   appstream_app_get_project_license (helper->item_temp) != NULL) {
                        g_set_error_literal (error,
                                             APPSTREAM_CACHE_ERROR,
                                             APPSTREAM_CACHE_ERROR_FAILED,
-                                            "item_temp licence invalid");
+                                            "item_temp license invalid");
                        return;
                }
-               appstream_app_set_licence (helper->item_temp, text, text_len);
+               appstream_app_set_project_license (helper->item_temp, text, text_len);
                break;
        case APPSTREAM_TAG_DESCRIPTION:
                appstream_markup_add_content (helper->markup, text, text_len);
diff --git a/src/plugins/appstream-common.c b/src/plugins/appstream-common.c
index a84aa1d..549efbd 100644
--- a/src/plugins/appstream-common.c
+++ b/src/plugins/appstream-common.c
@@ -64,8 +64,10 @@ appstream_tag_from_string (const gchar *element_name)
                return APPSTREAM_TAG_MIMETYPES;
        if (g_strcmp0 (element_name, "mimetype") == 0)
                return APPSTREAM_TAG_MIMETYPE;
-       if (g_strcmp0 (element_name, "licence") == 0)
-               return APPSTREAM_TAG_LICENCE;
+       if (g_strcmp0 (element_name, "licence") == 0) /* the deprecated name */
+               return APPSTREAM_TAG_PROJECT_LICENSE;
+       if (g_strcmp0 (element_name, "project_license") == 0)
+               return APPSTREAM_TAG_PROJECT_LICENSE;
        if (g_strcmp0 (element_name, "screenshots") == 0)
                return APPSTREAM_TAG_SCREENSHOTS;
        if (g_strcmp0 (element_name, "screenshot") == 0)
@@ -121,8 +123,8 @@ appstream_tag_to_string (AppstreamTag tag)
                return "mimetypes";
        if (tag == APPSTREAM_TAG_MIMETYPE)
                return "mimetype";
-       if (tag == APPSTREAM_TAG_LICENCE)
-               return "licence";
+       if (tag == APPSTREAM_TAG_PROJECT_LICENSE)
+               return "project_license";
        if (tag == APPSTREAM_TAG_SCREENSHOTS)
                return "screenshots";
        if (tag == APPSTREAM_TAG_SCREENSHOT)
diff --git a/src/plugins/appstream-common.h b/src/plugins/appstream-common.h
index 34de7a9..eb2d06c 100644
--- a/src/plugins/appstream-common.h
+++ b/src/plugins/appstream-common.h
@@ -44,7 +44,7 @@ typedef enum {
        APPSTREAM_TAG_MIMETYPES,
        APPSTREAM_TAG_MIMETYPE,
        APPSTREAM_TAG_PROJECT_GROUP,
-       APPSTREAM_TAG_LICENCE,
+       APPSTREAM_TAG_PROJECT_LICENSE,
        APPSTREAM_TAG_SCREENSHOT,
        APPSTREAM_TAG_SCREENSHOTS,
        APPSTREAM_TAG_UPDATECONTACT,
diff --git a/src/plugins/gs-plugin-appdata.c b/src/plugins/gs-plugin-appdata.c
index 9f865dc..ebab477 100644
--- a/src/plugins/gs-plugin-appdata.c
+++ b/src/plugins/gs-plugin-appdata.c
@@ -240,7 +240,7 @@ appdata_parse_text_cb (GMarkupParseContext *context,
        case APPSTREAM_TAG_APPLICATION:
        case APPSTREAM_TAG_APPLICATIONS:
        case APPSTREAM_TAG_ID:
-       case APPSTREAM_TAG_LICENCE:
+       case APPSTREAM_TAG_PROJECT_LICENSE:
        case APPSTREAM_TAG_SCREENSHOTS:
        case APPSTREAM_TAG_UPDATECONTACT:
        case APPSTREAM_TAG_COMPULSORY_FOR_DESKTOP:
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 9c24cbd..2977f06 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -565,8 +565,8 @@ gs_plugin_refine_item (GsPlugin *plugin,
        }
 
        /* set licence */
-       if (appstream_app_get_licence (item) != NULL && gs_app_get_licence (app) == NULL)
-               gs_app_set_licence (app, appstream_app_get_licence (item));
+       if (appstream_app_get_project_license (item) != NULL && gs_app_get_licence (app) == NULL)
+               gs_app_set_licence (app, appstream_app_get_project_license (item));
 
        /* set keywords */
        if (appstream_app_get_keywords (item) != NULL &&


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