Blame SOURCES/0171-plugins-port-reporters-to-add_reported_to_entry.patch

562801
From eeae29b92017d42b7be967b0a67a4db24bafa80e Mon Sep 17 00:00:00 2001
562801
From: Jakub Filak <jfilak@redhat.com>
562801
Date: Mon, 19 Oct 2015 14:24:52 +0200
562801
Subject: [PATCH] plugins: port reporters to add_reported_to_entry
562801
562801
This commit should make the code less fragile. There is no need for this
562801
commit, however I plan to make the '.label' member configurable through
562801
environment variables.
562801
562801
Signed-off-by: Jakub Filak <jfilak@redhat.com>
562801
562801
Conflicts:
562801
	src/plugins/reporter-mantisbt.c
562801
---
562801
 src/lib/ureport.c                 | 21 ++++++++++++---------
562801
 src/plugins/reporter-bugzilla.c   |  7 ++++---
562801
 src/plugins/reporter-kerneloops.c |  6 +++---
562801
 src/plugins/reporter-mailx.c      |  7 ++++---
562801
 src/plugins/reporter-print.c      |  7 ++++---
562801
 src/plugins/reporter-rhtsupport.c | 12 +++++-------
562801
 6 files changed, 32 insertions(+), 28 deletions(-)
562801
562801
diff --git a/src/lib/ureport.c b/src/lib/ureport.c
562801
index ebeaa8b..f89fe62 100644
562801
--- a/src/lib/ureport.c
562801
+++ b/src/lib/ureport.c
562801
@@ -644,15 +644,18 @@ ureport_server_response_save_in_dump_dir(struct ureport_server_response *resp,
562801
 
562801
     if (resp->urr_bthash)
562801
     {
562801
-        char *msg = xasprintf("uReport: BTHASH=%s", resp->urr_bthash);
562801
-        add_reported_to(dd, msg);
562801
-        free(msg);
562801
-
562801
-        char *report_url = ureport_server_response_get_report_url(resp, config);
562801
-        msg = xasprintf("ABRT Server: URL=%s", report_url);
562801
-        add_reported_to(dd, msg);
562801
-        free(msg);
562801
-        free(report_url);
562801
+        {
562801
+            report_result_t rr = { .label = (char *)"uReport" };
562801
+            rr.bthash = resp->urr_bthash;
562801
+            add_reported_to_entry(dd, &rr);
562801
+        }
562801
+
562801
+        {
562801
+            report_result_t rr = { .label = (char *)"ABRT Server" };
562801
+            rr.url = ureport_server_response_get_report_url(resp, config);
562801
+            add_reported_to_entry(dd, &rr);
562801
+            free(rr.url);
562801
+        }
562801
     }
562801
 
562801
     if (resp->urr_reported_to_list)
562801
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
562801
index 097924e..d11fadf 100644
562801
--- a/src/plugins/reporter-bugzilla.c
562801
+++ b/src/plugins/reporter-bugzilla.c
562801
@@ -1351,9 +1351,10 @@ int main(int argc, char **argv)
562801
     struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
562801
     if (dd)
562801
     {
562801
-        char *msg = xasprintf("Bugzilla: URL=%s/show_bug.cgi?id=%u", rhbz.b_bugzilla_url, bz->bi_id);
562801
-        add_reported_to(dd, msg);
562801
-        free(msg);
562801
+        report_result_t rr = { .label = (char *)"Bugzilla" };
562801
+        rr.url = xasprintf("%s/show_bug.cgi?id=%u", rhbz.b_bugzilla_url, bz->bi_id);
562801
+        add_reported_to_entry(dd, &rr);
562801
+        free(rr.url);
562801
         dd_close(dd);
562801
     }
562801
 
562801
diff --git a/src/plugins/reporter-kerneloops.c b/src/plugins/reporter-kerneloops.c
562801
index d312459..895f755 100644
562801
--- a/src/plugins/reporter-kerneloops.c
562801
+++ b/src/plugins/reporter-kerneloops.c
562801
@@ -118,9 +118,9 @@ static void report_to_kerneloops(
562801
     struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
562801
     if (dd)
562801
     {
562801
-        char *msg = xasprintf("kerneloops: URL=%s", submitURL);
562801
-        add_reported_to(dd, msg);
562801
-        free(msg);
562801
+        report_result_t rr = { .label = (char *)"kerneloops" };
562801
+        rr.url = (char *)submitURL;
562801
+        add_reported_to_entry(dd, &rr);
562801
         dd_close(dd);
562801
     }
562801
 
562801
diff --git a/src/plugins/reporter-mailx.c b/src/plugins/reporter-mailx.c
562801
index 92e78a4..54dc82e 100644
562801
--- a/src/plugins/reporter-mailx.c
562801
+++ b/src/plugins/reporter-mailx.c
562801
@@ -149,9 +149,10 @@ static void create_and_send_email(
562801
         struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
562801
         if (dd)
562801
         {
562801
-            char *msg = xasprintf("email: URL=mailto:%s", email_to);
562801
-            add_reported_to(dd, msg);
562801
-            free(msg);
562801
+            report_result_t rr = { .label = (char *)"email" };
562801
+            rr.url = xasprintf("mailto:%s", email_to);
562801
+            add_reported_to_entry(dd, &rr);
562801
+            free(rr.url);
562801
             dd_close(dd);
562801
         }
562801
     }
562801
diff --git a/src/plugins/reporter-print.c b/src/plugins/reporter-print.c
562801
index 0c67a3c..90ed4c3 100644
562801
--- a/src/plugins/reporter-print.c
562801
+++ b/src/plugins/reporter-print.c
562801
@@ -134,9 +134,10 @@ int main(int argc, char **argv)
562801
             struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
562801
             if (dd)
562801
             {
562801
-                char *msg = xasprintf("file: URL=file://%s", output_file);
562801
-                add_reported_to(dd, msg);
562801
-                free(msg);
562801
+                report_result_t rr = { .label = (char *)"file" };
562801
+                rr.url = xasprintf("file://%s", output_file);
562801
+                add_reported_to_entry(dd, &rr);
562801
+                free(rr.url);
562801
                 dd_close(dd);
562801
             }
562801
         }
562801
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
562801
index add0d6b..90988fc 100644
562801
--- a/src/plugins/reporter-rhtsupport.c
562801
+++ b/src/plugins/reporter-rhtsupport.c
562801
@@ -734,13 +734,11 @@ int main(int argc, char **argv)
562801
         struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
562801
         if (dd)
562801
         {
562801
-            char *msg = xasprintf("RHTSupport: TIME=%s URL=%s%s%s",
562801
-                    iso_date_string(NULL),
562801
-                    result->url,
562801
-                    result->msg ? " MSG=" : "", result->msg ? result->msg : ""
562801
-            );
562801
-            add_reported_to(dd, msg);
562801
-            free(msg);
562801
+            struct report_result rr = { .label = (char *)"RHTSupport" };
562801
+            rr.url = result->url;
562801
+            rr.msg = result->msg;
562801
+            time(&rr.timestamp);
562801
+            add_reported_to_entry(dd, &rr);
562801
             dd_close(dd);
562801
             if (result->msg)
562801
                 log("%s", result->msg);
562801
-- 
562801
1.8.3.1
562801