2005-01-17 [thorsten] 1.0.0cvs1
[claws.git] / src / crash.c
index 3bcf5e0ffdd93c788748ae8e6b8aa1293204ebee..57266bcb80dd24b78864ab8ec425735dcf32922a 100644 (file)
 #      include <config.h>
 #endif
 
+#ifdef CRASH_DIALOG
+
+#include "defs.h"
+
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include <errno.h>
 #include <fcntl.h>
@@ -39,6 +45,9 @@
 #      include <gnu/libc-version.h>
 #endif
 
+#ifdef SIGTERM
+#include "main.h"
+#endif
 #include "intl.h"
 #include "crash.h"
 #include "utils.h"
 #include "version.h"
 #include "prefs_common.h"
 
-#if 0
-#include "gtkutils.h"
-#include "pixmaps/notice_error.xpm"
-#endif
-
 /*
- * NOTE 1: the crash dialog is called when sylpheed is not 
+ * NOTE: the crash dialog is called when sylpheed is not 
  * initialized, so do not assume settings are available.
  * for example, loading / creating pixmaps seems not 
  * to be possible.
@@ -62,7 +66,7 @@
 
 static GtkWidget       *crash_dialog_show              (const gchar *text, 
                                                         const gchar *debug_output);
-static gboolean                 crash_create_debugger_file     (void);
+static void             crash_create_debugger_file     (void);
 static void             crash_save_crash_log           (GtkButton *, const gchar *);
 static void             crash_create_bug_report        (GtkButton *, const gchar *);
 static void             crash_debug                    (unsigned long crash_pid, 
@@ -86,7 +90,7 @@ static const gchar *DEBUG_SCRIPT = "bt\nkill\nq";
  */
 void crash_install_handlers(void)
 {
-#if HAVE_GDB
+#if CRASH_DIALOG 
        sigset_t mask;
 
        if (!is_crash_dialog_allowed()) return;
@@ -114,7 +118,7 @@ void crash_install_handlers(void)
 #endif
 
        sigprocmask(SIG_UNBLOCK, &mask, 0);
-#endif /* HAVE_GDB */  
+#endif /* CRASH_DIALOG */      
 }
 
 /***/
@@ -124,12 +128,11 @@ void crash_install_handlers(void)
  */
 void crash_main(const char *arg) 
 {
-#if HAVE_GDB
+#if CRASH_DIALOG 
        gchar *text;
        gchar **tokens;
        unsigned long pid;
        GString *output;
-       extern gchar *startup_dir;
 
        crash_create_debugger_file();
        tokens = g_strsplit(arg, ",", 0);
@@ -151,11 +154,16 @@ void crash_main(const char *arg)
        g_string_free(output, TRUE);
        g_free(text);
        g_strfreev(tokens);
-#endif /* HAVE_GDB */  
+#endif /* CRASH_DIALOG */      
 }
 
 /*!
- *\brief       (can't get pixmap working, so discarding it)
+ *\brief       show crash dialog
+ *
+ *\param       text Description
+ *\param       debug_output Output text by gdb
+ *
+ *\return      GtkWidget * Dialog widget
  */
 static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output)
 {
@@ -171,9 +179,6 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
        GtkWidget *button3;
        GtkWidget *button4;
        GtkWidget *button5;
-       GtkWidget *pixwid;
-       GdkPixmap *pix;
-       GdkBitmap *msk;
        gchar     *crash_report;
 
        window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -193,13 +198,6 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
        gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4);
 
-#if 0
-       PIXMAP_CREATE(window1, pix, msk, notice_error_xpm);
-       pixwid = gtk_pixmap_new(pix, msk);
-       gtk_widget_show(pixwid);
-       gtk_box_pack_start(GTK_BOX(hbox1), pixwid, TRUE, TRUE, 0);
-#endif 
-
        label1 = gtk_label_new
            (g_strdup_printf(_("%s.\nPlease file a bug report and include the information below."), text));
        gtk_widget_show(label1);
@@ -279,7 +277,7 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
  *             all the other options (creating temp files) looked too 
  *             convoluted.
  */
-static gboolean crash_create_debugger_file(void)
+static void crash_create_debugger_file(void)
 {
        gchar *filespec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, DEBUGGERRC, NULL);
        
@@ -299,11 +297,10 @@ static void crash_save_crash_log(GtkButton *button, const gchar *text)
 
        timer = time(NULL);
        lt = localtime(&timer);
-       strftime(buf, sizeof buf, "sylpheed-crash-log-%y-%m-%d-%H-%M-%S.txt", lt);
+       strftime(buf, sizeof buf, "sylpheed-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
        if (NULL != (filename = filesel_select_file(_("Save crash information"), buf))
        &&  *filename)
                str_write_to_file(text, filename);
-       g_free(filename);       
 }
 
 /*!
@@ -311,8 +308,7 @@ static void crash_save_crash_log(GtkButton *button, const gchar *text)
  */
 static void crash_create_bug_report(GtkButton *button, const gchar *data)
 {
-       open_uri("http://sourceforge.net/tracker/?func=add&group_id=25528&atid=384598",
-                prefs_common.uri_cmd);
+       open_uri(CLAWS_BUGZILLA_URI, prefs_common.uri_cmd);
 }
 
 /*!
@@ -346,7 +342,7 @@ static void crash_debug(unsigned long crash_pid,
                *argptr++ = "-x";
                *argptr++ = filespec;
                *argptr++ = exe_image;
-               *argptr++ = g_strdup_printf("%d", crash_pid);
+               *argptr++ = g_strdup_printf("%ld", crash_pid);
                *argptr   = NULL;
 
                /*
@@ -416,11 +412,8 @@ static const gchar *get_compiled_in_features(void)
 #if HAVE_LIBJCONV
                   " libjconv"
 #endif
-#if USE_GPGME
-                  " GPGME"
-#endif
-#if USE_SSL
-                  " SSL"
+#if USE_OPENSSL
+                  " OpenSSL"
 #endif
 #if USE_LDAP
                   " LDAP"
@@ -428,8 +421,8 @@ static const gchar *get_compiled_in_features(void)
 #if USE_JPILOT
                   " JPilot"
 #endif
-#if USE_PSPELL
-                  " pspell"
+#if USE_ASPELL
+                  " GNU/aspell"
 #endif
        "");
 }
@@ -489,10 +482,9 @@ static void crash_handler(int sig)
        static volatile unsigned long crashed_ = 0;
 
        /*
-        * let's hope startup_dir and argv0 aren't trashed.
+        * let's hope argv0 aren't trashed.
         * both are defined in main.c.
         */
-       extern gchar *startup_dir;
        extern gchar *argv0;
 
 
@@ -504,6 +496,11 @@ static void crash_handler(int sig)
 
        crashed_++;
 
+#ifdef SIGTERM
+       if (sig == SIGTERM) 
+               clean_quit(NULL);
+#endif
+
        /*
         * gnome ungrabs focus, and flushes gdk. mmmh, good idea.
         */
@@ -523,11 +520,11 @@ static void crash_handler(int sig)
                args[0] = argv0; 
                args[1] = "--debug";
                args[2] = "--crash";
-               sprintf(buf, "%ld,%d,%s", getppid(), sig, argv0);
+               sprintf(buf, "%d,%d,%s", getppid(), sig, argv0);
                args[3] = buf;
                args[4] = NULL;
 
-               chdir(startup_dir);
+               chdir(sylpheed_get_startup_dir());
                setgid(getgid());
                setuid(getuid());
                execvp(argv0, args);
@@ -551,3 +548,4 @@ static void crash_cleanup_exit(void)
        unlink(filename);
 }
 
+#endif