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

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