From 5284b6727fa056e0d19d8967571554fd2a7703d1 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Thu, 6 Jan 2022 17:53:41 +0100 Subject: [PATCH] Add a source URL type --- docs/xml/metainfo-component.xml | 9 +++++++++ qt/component.cpp | 4 ++++ qt/component.h | 1 + src/as-enums.c | 4 ++++ src/as-enums.h | 1 + tests/test-xmldata.c | 2 ++ tests/test-yamldata.c | 4 +++- 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/xml/metainfo-component.xml b/docs/xml/metainfo-component.xml index 2707ac41..a0c0c0e2 100644 --- a/docs/xml/metainfo-component.xml +++ b/docs/xml/metainfo-component.xml @@ -362,6 +362,15 @@ + + + source + + + Should provide a web link to the source code. + + + diff --git a/qt/component.cpp b/qt/component.cpp index d0a335ac..b07ad39c 100644 --- a/qt/component.cpp +++ b/qt/component.cpp @@ -139,6 +139,9 @@ Component::UrlKind Component::stringToUrlKind(const QString& urlKindString) { if (urlKindString == QLatin1String("contact")) { return UrlKindContact; } + if (urlKindString == QLatin1String("source")) { + return UrlKindSource; + } return UrlKindUnknown; } @@ -150,6 +153,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(UrlKindMap, urlKindMap, ({ { Component::UrlKindFaq, QLatin1String("faq") }, { Component::UrlKindHelp, QLatin1String("help") }, { Component::UrlKindHomepage, QLatin1String("homepage") }, + { Component::UrlKindSource, QLatin1String("source") }, { Component::UrlKindUnknown, QLatin1String("unknown") }, })); diff --git a/qt/component.h b/qt/component.h index e8bda49a..909e52ad 100644 --- a/qt/component.h +++ b/qt/component.h @@ -88,6 +88,7 @@ class APPSTREAMQT_EXPORT Component { UrlKindDonation, UrlTranslate, UrlKindContact + UrlKindSource }; Q_ENUM(UrlKind) diff --git a/src/as-enums.c b/src/as-enums.c index 4ef2914c..f0d0d92a 100644 --- a/src/as-enums.c +++ b/src/as-enums.c @@ -91,6 +91,8 @@ as_url_kind_to_string (AsUrlKind url_kind) return "translate"; if (url_kind == AS_URL_KIND_CONTACT) return "contact"; + if (url_kind == AS_URL_KIND_SOURCE) + return "source"; return "unknown"; } @@ -119,6 +121,8 @@ as_url_kind_from_string (const gchar *url_kind) return AS_URL_KIND_TRANSLATE; if (g_strcmp0 (url_kind, "contact") == 0) return AS_URL_KIND_CONTACT; + if (g_strcmp0 (url_kind, "source") == 0) + return AS_URL_KIND_SOURCE; return AS_URL_KIND_UNKNOWN; } diff --git a/src/as-enums.h b/src/as-enums.h index 697eccea..9e5d7690 100644 --- a/src/as-enums.h +++ b/src/as-enums.h @@ -93,6 +93,7 @@ typedef enum { AS_URL_KIND_DONATION, AS_URL_KIND_TRANSLATE, AS_URL_KIND_CONTACT, + AS_URL_KIND_SOURCE, /*< private >*/ AS_URL_KIND_LAST } AsUrlKind; diff --git a/tests/test-xmldata.c b/tests/test-xmldata.c index 22426ec4..0a6946e4 100644 --- a/tests/test-xmldata.c +++ b/tests/test-xmldata.c @@ -660,6 +660,7 @@ test_xml_read_url (void) " https://example.org/faq\n" " https://example.org/donate\n" " https://example.org/contact\n" + " https://example.org/source\n" "\n"; cpt = as_xml_test_read_data (xmldata_languages, AS_FORMAT_STYLE_METAINFO); @@ -669,6 +670,7 @@ test_xml_read_url (void) g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_FAQ), ==, "https://example.org/faq"); g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_DONATION), ==, "https://example.org/donate"); g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_CONTACT), ==, "https://example.org/contact"); + g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_SOURCE), ==, "https://example.org/source"); } /** diff --git a/tests/test-yamldata.c b/tests/test-yamldata.c index f7c880ac..1f8c36ff 100644 --- a/tests/test-yamldata.c +++ b/tests/test-yamldata.c @@ -526,7 +526,8 @@ test_yaml_read_url (void) " homepage: https://example.org\n" " faq: https://example.org/faq\n" " donation: https://example.org/donate\n" - " contact: https://example.org/contact\n"; + " contact: https://example.org/contact\n" + " source: https://example.org/source\n"; cpt = as_yaml_test_read_data (yamldata_urls, NULL); g_assert_cmpstr (as_component_get_id (cpt), ==, "org.example.Test"); @@ -535,6 +536,7 @@ test_yaml_read_url (void) g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_FAQ), ==, "https://example.org/faq"); g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_DONATION), ==, "https://example.org/donate"); g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_CONTACT), ==, "https://example.org/contact"); + g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_SOURCE), ==, "https://example.org/source"); } /**