2008-10-09 [colin] 3.6.0cvs21
[claws.git] / src / crash.c
index cad916b06561e4de25ed6ffe4c748ad46fd5a0b1..b98102eeeac01d98f55b4a76163930e0602678b4 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ * Copyright (C) 2002 by the Claws Mail Team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
 #      include <gnu/libc-version.h>
 #endif
 
-#ifdef SIGTERM
 #include "main.h"
-#endif
-#include "sylpheed.h"
+#include "claws.h"
 #include "crash.h"
 #include "utils.h"
 #include "filesel.h"
@@ -57,7 +55,7 @@
 #include "prefs_common.h"
 
 /*
- * NOTE: the crash dialog is called when sylpheed is not 
+ * NOTE: the crash dialog is called when claws is not 
  * initialized, so do not assume settings are available.
  * for example, loading / creating pixmaps seems not 
  * to be possible.
@@ -82,7 +80,7 @@ static void            crash_cleanup_exit             (void);
 
 /***/
 
-static const gchar *DEBUG_SCRIPT = "bt\nkill\nq";
+static const gchar *DEBUG_SCRIPT = "thread all apply\nbt full\nkill\nq";
 
 /***/
 
@@ -139,7 +137,7 @@ void crash_main(const char *arg)
        tokens = g_strsplit(arg, ",", 0);
 
        pid = atol(tokens[0]);
-       text = g_strdup_printf(_("Sylpheed process (%ld) received signal %ld"),
+       text = g_strdup_printf(_("Claws Mail process (%ld) received signal %ld"),
                               pid, atol(tokens[1]));
 
        output = g_string_new("");     
@@ -148,7 +146,6 @@ void crash_main(const char *arg)
        /*
         * try to get the settings
         */
-       prefs_common_init();
        prefs_common_read_config();
 
        crash_dialog_show(text, output->str);
@@ -181,10 +178,12 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
        GtkWidget *button4;
        GtkWidget *button5;
        gchar     *crash_report;
+       GtkTextBuffer *buffer;
+       GtkTextIter iter;
 
-       window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       window1 = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "crash");
        gtk_container_set_border_width(GTK_CONTAINER(window1), 5);
-       gtk_window_set_title(GTK_WINDOW(window1), _("Sylpheed has crashed"));
+       gtk_window_set_title(GTK_WINDOW(window1), _("Claws Mail has crashed"));
        gtk_window_set_position(GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
        gtk_window_set_modal(GTK_WINDOW(window1), TRUE);
        gtk_window_set_default_size(GTK_WINDOW(window1), 460, 272);
@@ -216,21 +215,30 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
                                       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
-       text1 = gtk_text_new(NULL, NULL);
-       gtk_text_set_editable((text1), FALSE);
+       text1 = gtk_text_view_new();
+       gtk_text_view_set_editable(GTK_TEXT_VIEW(text1), FALSE);
        gtk_widget_show(text1);
        gtk_container_add(GTK_CONTAINER(scrolledwindow1), text1);
        
        crash_report = g_strdup_printf(
-               "Sylpheed version %s\nGTK+ version %d.%d.%d\nFeatures:%s\nOperating system: %s\nC Library: %s\n--\n%s",
+               "Claws Mail version %s\n"
+               "GTK+ version %d.%d.%d / GLib %d.%d.%d\n"
+               "Locale: %s (charset: %s)\n"
+               "Features:%s\n"
+               "Operating system: %s\n"
+               "C Library: %s\n--\n%s",
                VERSION,
                gtk_major_version, gtk_minor_version, gtk_micro_version,
+               glib_major_version, glib_minor_version, glib_micro_version,
+               conv_get_current_locale(), conv_get_locale_charset_str(),
                get_compiled_in_features(),
                get_operating_system(),
                get_lib_version(),
                debug_output);
 
-       gtk_text_insert((text1), NULL, NULL, NULL, crash_report, -1);
+       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text1));
+       gtk_text_buffer_get_start_iter(buffer, &iter);
+       gtk_text_buffer_insert(buffer, &iter, crash_report, -1);
 
        hbuttonbox3 = gtk_hbutton_box_new();
        gtk_widget_show(hbuttonbox3);
@@ -272,7 +280,7 @@ static GtkWidget *crash_dialog_show(const gchar *text, const gchar *debug_output
 
 
 /*!
- *\brief       create debugger script file in sylpheed directory.
+ *\brief       create debugger script file in claws directory.
  *             all the other options (creating temp files) looked too 
  *             convoluted.
  */
@@ -292,11 +300,12 @@ static void crash_save_crash_log(GtkButton *button, const gchar *text)
        time_t timer;
        struct tm *lt;
        char buf[100];
+       struct tm buft;
        gchar *filename;
 
        timer = time(NULL);
-       lt = localtime(&timer);
-       strftime(buf, sizeof buf, "sylpheed-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
+       lt = localtime_r(&timer, &buft);
+       strftime(buf, sizeof buf, "claws-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
        if (NULL != (filename = filesel_select_file_save(_("Save crash information"), buf))
        &&  *filename)
                str_write_to_file(text, filename);
@@ -304,15 +313,15 @@ static void crash_save_crash_log(GtkButton *button, const gchar *text)
 }
 
 /*!
- *\brief       create bug report (goes to Sylpheed Claws bug tracker)  
+ *\brief       create bug report (goes to Claws Mail bug tracker)      
  */
 static void crash_create_bug_report(GtkButton *button, const gchar *data)
 {
-       open_uri(CLAWS_BUGZILLA_URI, prefs_common.uri_cmd);
+       open_uri(BUGZILLA_URI, prefs_common_get_uri_cmd());
 }
 
 /*!
- *\brief       launches debugger and attaches it to crashed sylpheed
+ *\brief       launches debugger and attaches it to crashed claws
  */
 static void crash_debug(unsigned long crash_pid, 
                        gchar *exe_image,
@@ -332,7 +341,7 @@ static void crash_debug(unsigned long crash_pid,
                setuid(getuid());
 
                /*
-                * setup debugger to attach to crashed sylpheed
+                * setup debugger to attach to crashed claws
                 */
                *argptr++ = "gdb"; 
                *argptr++ = "--nw";
@@ -352,7 +361,7 @@ static void crash_debug(unsigned long crash_pid,
                dup(choutput[1]);
                close(choutput[0]);
                if (-1 == execvp("gdb", argp)) 
-                       puts("error execvp\n");
+                       g_print("error execvp\n");
        } else {
                char buf[100];
                int r;
@@ -363,7 +372,7 @@ static void crash_debug(unsigned long crash_pid,
                 * make it non blocking
                 */
                if (-1 == fcntl(choutput[0], F_SETFL, O_NONBLOCK))
-                       puts("set to non blocking failed\n");
+                       g_print("set to non blocking failed\n");
 
                /*
                 * get the output
@@ -394,26 +403,20 @@ static void crash_debug(unsigned long crash_pid,
 static const gchar *get_compiled_in_features(void)
 {
        return g_strdup_printf("%s",
-#if HAVE_GDK_IMLIB
-                  " gdk_imlib"
-#endif
-#if HAVE_GDK_PIXBUF
-                  " gdk-pixbuf"
-#endif
 #if USE_THREADS
                   " gthread"
 #endif
 #if INET6
                   " IPv6"
 #endif
-#if HAVE_LIBCOMPFACE
-                  " libcompface"
+#if HAVE_ICONV
+                  " iconv"
 #endif
-#if HAVE_LIBJCONV
-                  " libjconv"
+#if HAVE_LIBCOMPFACE
+                  " compface"
 #endif
-#if USE_OPENSSL
-                  " OpenSSL"
+#if USE_GNUTLS
+                  " GnuTLS"
 #endif
 #if USE_LDAP
                   " LDAP"
@@ -421,8 +424,17 @@ static const gchar *get_compiled_in_features(void)
 #if USE_JPILOT
                   " JPilot"
 #endif
-#if USE_ASPELL
+#if USE_ENCHANT
                   " GNU/aspell"
+#endif
+#if HAVE_LIBETPAN
+                  " libetpan"
+#endif
+#if USE_GNOMEPRINT
+                  " libgnomeprint"
+#endif
+#if HAVE_LIBSM
+                  " libSM"
 #endif
        "");
 }
@@ -465,11 +477,11 @@ static const gchar *get_operating_system(void)
 
 /*!
  *\brief       see if the crash dialog is allowed (because some
- *             developers may prefer to run sylpheed under gdb...)
+ *             developers may prefer to run claws-mail under gdb...)
  */
 static gboolean is_crash_dialog_allowed(void)
 {
-       return !getenv("SYLPHEED_NO_CRASH");
+       return !getenv("CLAWS_NO_CRASH");
 }
 
 /*!
@@ -524,7 +536,7 @@ static void crash_handler(int sig)
                args[3] = buf;
                args[4] = NULL;
 
-               chdir(sylpheed_get_startup_dir());
+               chdir(claws_get_startup_dir());
                setgid(getgid());
                setuid(getuid());
                execvp(argv0, args);
@@ -543,9 +555,8 @@ static void crash_handler(int sig)
  */
 static void crash_cleanup_exit(void)
 {
-       extern gchar *get_socket_name(void);
-       const char *filename = get_socket_name();
-       unlink(filename);
+       const char *filename = claws_get_socket_name();
+       claws_unlink(filename);
 }
 
 #endif