summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Gnatenko <i.gnatenko.brain@gmail.com>2014-07-20 14:54:38 +0400
committerIgor Gnatenko <i.gnatenko.brain@gmail.com>2014-07-20 22:58:01 +0400
commite450137ca5aa358066e72960ffbb25dcb2c4a404 (patch)
tree6f9aa355ad23d55c418c3171f685f91a3c343de6
parentd6137413460da4fd5afe389d0ea4bc7ffda8c35f (diff)
downloadappstream-glib-wip/fedora_maintainer_v2.tar.gz
client/as-util: add Fedora point-of-contact to htmlwip/fedora_maintainer_v2
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
-rw-r--r--client/as-util.c15
-rw-r--r--configure.ac1
-rw-r--r--contrib/libappstream-glib.spec.in1
-rw-r--r--libappstream-glib/Makefile.am2
-rw-r--r--libappstream-glib/as-utils.c60
-rw-r--r--libappstream-glib/as-utils.h1
6 files changed, 80 insertions, 0 deletions
diff --git a/client/as-util.c b/client/as-util.c
index 4ce91b3..1ae6e58 100644
--- a/client/as-util.c
+++ b/client/as-util.c
@@ -1085,6 +1085,7 @@ as_util_status_html_write_app (AsApp *app, GString *html)
AsScreenshot *ss;
const gchar *pkgname;
gchar *tmp;
+ gchar *poc;
guint i;
guint j;
const gchar *important_md[] = { "DistroMetadata",
@@ -1173,6 +1174,20 @@ as_util_status_html_write_app (AsApp *app, GString *html)
}
g_free (tmp);
+ /* point of contact */
+ tmp = as_util_status_html_join (as_app_get_pkgnames (app));
+ if (tmp != NULL) {
+ pkgname = g_ptr_array_index (as_app_get_pkgnames(app), 0);
+ poc = as_utils_get_fedora_maintainer_for_pkg (pkgname);
+ if (poc != NULL) {
+ g_string_append_printf (html, "<tr><td class=\"alt\">%s</td><td>"
+ "<a href=\"https://admin.fedoraproject.org/accounts/view/%s\">"
+ "<code>%s</code></a></td></tr>\n",
+ "Point of contact", poc, poc);
+ }
+ }
+ g_free (tmp);
+
/* categories */
tmp = as_util_status_html_join (as_app_get_categories (app));
if (tmp != NULL) {
diff --git a/configure.ac b/configure.ac
index aa0612b..3af4a32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,7 @@ AM_CONDITIONAL(HAVE_GPERF, [test x$GPERF != xno])
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16.1 gio-2.0 gobject-2.0 gthread-2.0 gio-unix-2.0 gmodule-2.0)
PKG_CHECK_MODULES(LIBARCHIVE, libarchive)
PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.24)
+PKG_CHECK_MODULES(JSONGLIB, json-glib-1.0)
PKG_CHECK_MODULES(GDKPIXBUF, gdk-pixbuf-2.0 >= 2.14 gtk+-3.0)
PKG_CHECK_MODULES(SQLITE, sqlite3)
PKG_CHECK_MODULES(FREETYPE, pango fontconfig freetype2 >= 9.10.0)
diff --git a/contrib/libappstream-glib.spec.in b/contrib/libappstream-glib.spec.in
index 3a22c5f..83117ec 100644
--- a/contrib/libappstream-glib.spec.in
+++ b/contrib/libappstream-glib.spec.in
@@ -16,6 +16,7 @@ BuildRequires: gobject-introspection-devel
BuildRequires: gperf
BuildRequires: libarchive-devel
BuildRequires: libsoup-devel
+BuildRequires: json-glib-devel
BuildRequires: gdk-pixbuf2-devel
BuildRequires: gettext
BuildRequires: intltool
diff --git a/libappstream-glib/Makefile.am b/libappstream-glib/Makefile.am
index 43f0981..8fe1040 100644
--- a/libappstream-glib/Makefile.am
+++ b/libappstream-glib/Makefile.am
@@ -8,6 +8,7 @@ endif
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(GDKPIXBUF_CFLAGS) \
+ $(JSONGLIB_CFLAGS) \
$(SOUP_CFLAGS) \
-I$(top_srcdir)/libappstream-glib \
-I$(top_builddir)/libappstream-glib \
@@ -104,6 +105,7 @@ CLEANFILES = $(BUILT_SOURCES)
libappstream_glib_la_LIBADD = \
$(GLIB_LIBS) \
$(GDKPIXBUF_LIBS) \
+ $(JSONGLIB_LIBS) \
$(SOUP_LIBS)
libappstream_glib_la_LDFLAGS = \
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 9bc92c9..a850fc0 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -35,6 +35,7 @@
#include <fnmatch.h>
#include <string.h>
#include <libsoup/soup.h>
+#include <json-glib/json-glib.h>
#include "as-cleanup.h"
#include "as-enums.h"
@@ -422,6 +423,65 @@ as_utils_check_url_exists (const gchar *url, guint timeout, GError **error)
}
/**
+ * as_utils_get_fedora_maintainer_for_pkg:
+ * @pkgname: the name of package to get maintainer.
+ *
+ * Get Fedora Project maintainer (FAS name) of specified package using PkgDB.
+ *
+ * Returns: (transfer full): a string with maintainer FAS name
+ *
+ * Since: 0.2.4
+ **/
+gchar *
+as_utils_get_fedora_maintainer_for_pkg (const gchar *pkgname)
+{
+ _cleanup_object_unref_ SoupMessage *msg = NULL;
+ _cleanup_object_unref_ SoupSession *session = NULL;
+ _cleanup_uri_unref_ SoupURI *base_uri = NULL;
+ _cleanup_object_unref_ JsonParser *parser = NULL;
+ _cleanup_object_unref_ JsonReader *reader = NULL;
+ GInputStream *pkgdb;
+ const gchar *url;
+ const gchar *poc;
+ guint timeout = 30;
+
+ url = g_strdup_printf (
+ "https://admin.fedoraproject.org/pkgdb/api/package/%s?acls=0&branches=master",
+ pkgname);
+ base_uri = soup_uri_new (url);
+ if (as_utils_check_url_exists (url, timeout, NULL)) {
+ msg = soup_message_new_from_uri (SOUP_METHOD_GET, base_uri);
+ session = soup_session_sync_new_with_options (SOUP_SESSION_USER_AGENT,
+ "libappstream-glib",
+ SOUP_SESSION_TIMEOUT,
+ timeout,
+ NULL);
+ pkgdb = soup_session_send (session, msg, NULL, NULL);
+ parser = json_parser_new ();
+ if (json_parser_load_from_stream (parser, pkgdb, NULL, NULL)) {
+ reader = json_reader_new (NULL);
+
+ json_reader_set_root (reader, json_parser_get_root (parser));
+
+ json_reader_read_member (reader, "packages");
+ json_reader_read_element (reader, 0);
+ json_reader_read_member (reader, "point_of_contact");
+
+ poc = json_reader_get_string_value (reader);
+
+ json_reader_end_member (reader);
+ json_reader_end_element (reader);
+ json_reader_end_member (reader);
+
+ if (poc) {
+ return (gchar *) poc;
+ }
+ }
+ }
+ return NULL;
+}
+
+/**
* as_pixbuf_box_blur_private:
**/
static void
diff --git a/libappstream-glib/as-utils.h b/libappstream-glib/as-utils.h
index 3fe76fe..2d28cd4 100644
--- a/libappstream-glib/as-utils.h
+++ b/libappstream-glib/as-utils.h
@@ -40,6 +40,7 @@ gchar **as_utils_spdx_license_tokenize (const gchar *license);
gboolean as_utils_check_url_exists (const gchar *url,
guint timeout,
GError **error);
+gchar *as_utils_get_fedora_maintainer_for_pkg (const gchar *pkgname);
G_END_DECLS