---
src/plugins/ureport.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index 96c7878..d24d8e7 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -58,6 +58,7 @@ struct ureport_server_response {
const char *value;
const char *message;
const char *bthash;
+ json_object *reported_to_list;
};
/*
@@ -92,6 +93,10 @@ static bool ureport_server_parse_json(json_object *json,
struct ureport_server_r
if (bthash)
out_response->bthash = json_object_get_string(bthash);
+ json_object *reported_to_list = json_object_object_get(json,
"reported_to");
+ if (reported_to_list)
+ out_response->reported_to_list = reported_to_list;
+
return true;
}
@@ -117,6 +122,64 @@ static bool check_response_statuscode(post_state_t
*post_state,
return true;
}
+/* reported_to json element should be a list of structures
+{ "reporter": "Bugzilla",
+ "type": "url",
+ "value": "https://bugzilla.redhat.com/show_bug.cgi?id=XYZ" } */
+static void add_reported_to_from_json_list(struct dump_dir *dd, struct
json_object *list)
+{
+ int i;
+ json_object *list_elem, *struct_elem;
+ const char *reporter, *value, *type;
+ char *reported_to_line, *prefix;
+
+ for (i = 0; i < json_object_array_length(list); ++i)
+ {
+ prefix = NULL;
+ list_elem = json_object_array_get_idx(list, i);
+ if (!list_elem)
+ continue;
+
+ struct_elem = json_object_object_get(list_elem, "reporter");
+ if (!struct_elem)
+ continue;
+
+ reporter = json_object_get_string(struct_elem);
+ if (!reporter)
+ continue;
+
+ struct_elem = json_object_object_get(list_elem, "value");
+ if (!struct_elem)
+ continue;
+
+ value = json_object_get_string(struct_elem);
+ if (!value)
+ continue;
+
+ struct_elem = json_object_object_get(list_elem, "type");
+ if (!struct_elem)
+ continue;
+
+ type = json_object_get_string(struct_elem);
+ if (type)
+ {
+ if (strcasecmp("url", type) == 0)
+ prefix = xstrdup("URL=");
+ else if (strcasecmp("bthash", type) == 0)
+ prefix = xstrdup("BTHASH=");
+ }
+
+ if (!prefix)
+ prefix = xstrdup("");
+
+ reported_to_line = xasprintf("%s: %s%s", reporter, prefix, value);
+ free(prefix);
+
+ add_reported_to(dd, reported_to_line);
+ free(reported_to_line);
+ }
+}
+
int main(int argc, char **argv)
{
abrt_init(argv);
@@ -276,6 +339,10 @@ int main(int argc, char **argv)
char *msg = xasprintf("uReport: BTHASH=%s", response.bthash);
add_reported_to(dd, msg);
free(msg);
+
+ if (response.reported_to_list)
+ add_reported_to_from_json_list(dd,
response.reported_to_list);
+
dd_close(dd);
}
--
1.7.1