Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a contact URL type #209

Merged
merged 1 commit into from Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -281,6 +281,19 @@
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>contact</term>
<listitem>
<para>
URLs of this type should allow the user to contact the developer.
</para>
</para>
This could be an email address (mailto link), a webpage (e.g. an online
form or a page describing how to contact the developer) or some other valid URL.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
@@ -123,12 +123,16 @@ Component::UrlKind Component::stringToUrlKind(const QString& urlKindString) {
if (urlKindString == QLatin1String("donation")) {
return UrlKindDonation;
}
if (urlKindString == QLatin1String("contact")) {
return UrlKindContact;
}
return UrlKindUnknown;
}

typedef QHash<Component::UrlKind, QString> UrlKindMap;
Q_GLOBAL_STATIC_WITH_ARGS(UrlKindMap, urlKindMap, ({
{ Component::UrlKindBugtracker, QLatin1String("bugtracker") },
{ Component::UrlKindContact, QLatin1String("contact") },
{ Component::UrlKindDonation, QLatin1String("donation") },
{ Component::UrlKindFaq, QLatin1String("faq") },
{ Component::UrlKindHelp, QLatin1String("help") },
@@ -79,6 +79,7 @@ Q_GADGET
UrlKindUnknown,
UrlKindHomepage,
UrlKindBugtracker,
UrlKindConact,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo ;-)
But I can fix that after merging

UrlKindFaq,
UrlKindHelp,
UrlKindDonation,
@@ -49,6 +49,8 @@ as_url_kind_to_string (AsUrlKind url_kind)
return "donation";
if (url_kind == AS_URL_KIND_TRANSLATE)
return "translate";
if (url_kind == AS_URL_KIND_CONTACT)
return "contact";
return "unknown";
}

@@ -75,6 +77,8 @@ as_url_kind_from_string (const gchar *url_kind)
return AS_URL_KIND_DONATION;
if (g_strcmp0 (url_kind, "translate") == 0)
return AS_URL_KIND_TRANSLATE;
if (g_strcmp0 (url_kind, "contact") == 0)
return AS_URL_KIND_CONTACT;
return AS_URL_KIND_UNKNOWN;
}

@@ -44,6 +44,7 @@ G_BEGIN_DECLS
* @AS_URL_KIND_HELP: Help manual
* @AS_URL_KIND_DONATION: Page with information about how to donate to the project
* @AS_URL_KIND_TRANSLATE: Page with instructions on how to translate the project / submit translations.
* @AS_URL_KIND_CONTACT: Contact the developers
*
* The URL type.
**/
@@ -55,6 +56,7 @@ typedef enum {
AS_URL_KIND_HELP,
AS_URL_KIND_DONATION,
AS_URL_KIND_TRANSLATE,
AS_URL_KIND_CONTACT,
/*< private >*/
AS_URL_KIND_LAST
} AsUrlKind;
@@ -506,6 +506,7 @@ test_xml_read_url (void)
" <url type=\"homepage\">https://example.org</url>\n"
" <url type=\"faq\">https://example.org/faq</url>\n"
" <url type=\"donation\">https://example.org/donate</url>\n"
" <url type=\"contact\">https://example.org/contact</url>\n"
"</component>\n";

cpt = as_xml_test_read_data (xmldata_languages, AS_FORMAT_STYLE_METAINFO);
@@ -514,6 +515,7 @@ test_xml_read_url (void)
g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_HOMEPAGE), ==, "https://example.org");
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");
}

/**
@@ -482,14 +482,16 @@ test_yaml_read_url (void)
"Url:\n"
" homepage: https://example.org\n"
" faq: https://example.org/faq\n"
" donation: https://example.org/donate\n";
" donation: https://example.org/donate\n"
" contact: https://example.org/contact\n";

cpt = as_yaml_test_read_data (yamldata_urls, NULL);
g_assert_cmpstr (as_component_get_id (cpt), ==, "org.example.Test");

g_assert_cmpstr (as_component_get_url (cpt, AS_URL_KIND_HOMEPAGE), ==, "https://example.org");
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");
}

/**