[gnome-software/wip/temp/ubuntu-xenial-rebased: 253/326] Fix parsing of snapd response
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased: 253/326] Fix parsing of snapd response
- Date: Fri, 29 Apr 2016 10:08:37 +0000 (UTC)
commit c0884aa307835bc2a88055d13dc6fccf8fa3750b
Author: William Hua <william hua canonical com>
Date: Sun Apr 17 15:58:53 2016 -0400
Fix parsing of snapd response
src/plugins/gs-plugin-snappy.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snappy.c b/src/plugins/gs-plugin-snappy.c
index 282f9d2..5cbdf6a 100644
--- a/src/plugins/gs-plugin-snappy.c
+++ b/src/plugins/gs-plugin-snappy.c
@@ -170,8 +170,10 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
g_autoptr (GString) path = NULL;
g_autofree gchar *reason_phrase = NULL, *response_type = NULL, *response = NULL;
g_autoptr(JsonParser) parser = NULL;
- JsonObject *root, *result, *packages;
- GList *package_list, *link;
+ JsonObject *root;
+ JsonArray *result;
+ GList *snaps;
+ GList *i;
socket = open_snapd_socket (error);
if (!socket)
@@ -209,16 +211,18 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
parser = parse_result (response, response_type, error);
if (parser == NULL)
return FALSE;
+
root = json_node_get_object (json_parser_get_root (parser));
- result = json_object_get_object_member (root, "result");
- packages = json_object_get_object_member (result, "snaps");
- package_list = json_object_get_members (packages);
- for (link = package_list; link; link = link->next) {
- const gchar *id = link->data;
- JsonObject *package;
+ result = json_object_get_array_member (root, "result");
+ snaps = json_array_get_elements (result);
+
+ for (i = snaps; i != NULL; i = i->next) {
+ JsonObject *package = json_node_get_object (i->data);
g_autoptr(GsApp) app = NULL;
+ const gchar *id;
+
+ id = json_object_get_string_member (package, "name");
- package = json_object_get_object_member (packages, id);
if (filter_func != NULL && !filter_func (id, package, user_data))
continue;
@@ -272,6 +276,8 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
g_autoptr(SoupMessage) message = NULL;
g_autoptr(GdkPixbufLoader) loader = NULL;
+ g_list_free (snaps);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]