Send message to dbus once core is processed and once core is submitted
authorWilliam Douglas <william.douglas@linux.intel.com>
Wed, 6 Apr 2011 23:03:50 +0000 (02:03 +0300)
committerWilliam Douglas <william.douglas@linux.intel.com>
Wed, 6 Apr 2011 23:03:50 +0000 (02:03 +0300)
coredump.c
corewatcher.c
corewatcher.h
submit.c

index bd2d403..6652296 100644 (file)
@@ -390,6 +390,7 @@ struct oops *extract_core(char *corefile)
                                continue;
                        free(c2);
                } else {
+                       /* keep going even if asprintf has errors */
                        asprintf(&c1, "%s", line);
                }
        }
@@ -453,6 +454,7 @@ void process_corefile(char *filename)
                        c = strtok(NULL, delim);
                }
                fprintf(stderr, "---[start of coredump]---\n%s\n---[end of coredump]---\n", oops->text);
+               dbus_say_found(oops);
 
                /* try to write coredump text details to text file */
                write_core_detail_file(filename, oops->text);
@@ -463,10 +465,12 @@ void process_corefile(char *filename)
                free(dfile);
                free(oops->filename);
                oops->filename = strdup(newfile);
+       } else {
+               /* backtrace queued only if files have been processed
+                  to avoid putting a new coredump in twice */
+               queue_backtrace(oops);
        }
 
-       queue_backtrace(oops);
-
        free(oops->application);
        free(oops->text);
        free(oops->filename);
index 86c8bbc..82ce15d 100644 (file)
@@ -149,11 +149,9 @@ void dbus_ask_permission(char * detail_file_name)
 }
 
 
-void dbus_say_thanks(struct oops *oops, char *url)
+void dbus_say_thanks(char *url)
 {
        DBusMessage *message;
-       unsigned int crash_id = 0;
-       char *dbus_msg_arg;
 
        if (!bus)
                return;
@@ -165,13 +163,31 @@ void dbus_say_thanks(struct oops *oops, char *url)
                dbus_message_unref(message);
                syslog(LOG_WARNING, "corewatcher.org: oops is posted as %s", url);
        }
+}
+
+void dbus_say_found(struct oops *oops)
+{
+       DBusMessage *message;
+       char detail_filename[8192];
+       char *dbus_msg_arg;
+       char *pid;
+
+       if (!bus || !oops)
+               return;
+
+       if (!(pid = strstr(oops->filename, "."))) {
+               sprintf(detail_filename, "Unknown");
+       } else {
+               snprintf(detail_filename, 8192, "%s%s.txt", core_folder, ++pid);
+       }
 
        message = dbus_message_new_signal("/org/corewatcher/submit/sent",
                        "org.corewatcher.submit.sent", "sent");
-       sscanf(url, "%*[^?]?number=%u", &crash_id);
-       asprintf(&dbus_msg_arg, "crash report #%u\n", crash_id);
+       if ((asprintf(&dbus_msg_arg, "crash report located at: %s\n", detail_filename)) <= 0)
+               return;
        dbus_message_append_args(message, DBUS_TYPE_STRING, &oops->application,
                                          DBUS_TYPE_STRING, &dbus_msg_arg, DBUS_TYPE_INVALID);
+
        dbus_connection_send(bus, message, NULL);
        dbus_message_unref(message);
        free(dbus_msg_arg);
index da73290..b714372 100644 (file)
@@ -49,7 +49,8 @@ extern void read_config_file(char *filename);
 
 extern void ask_permission(void);
 extern void dbus_ask_permission(char * detail_file_name);
-extern void dbus_say_thanks(struct oops *oops, char *url);
+extern void dbus_say_thanks(char *url);
+extern void dbus_say_found(struct oops *oops);
 
 extern int opted_in;
 extern int allow_distro_to_pass_on;
index d03e8df..338f341 100644 (file)
--- a/submit.c
+++ b/submit.c
@@ -268,7 +268,7 @@ void submit_queue_with_url(struct oops *queue, char *wsubmit_url)
                                rename(oops->filename, newfile);
 
                        checksums[submitted++] = oops->checksum;
-                       dbus_say_thanks(oops, result_url);
+                       dbus_say_thanks(result_url);
                }
 
                count++;