llcrashloggerlinux.cpp

Go to the documentation of this file.
00001 
00032 #include "llcrashloggerlinux.h"
00033 
00034 #include <iostream>
00035 
00036 #include "linden_common.h"
00037 
00038 #include "boost/tokenizer.hpp"
00039 
00040 #include "indra_constants.h"    // CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
00041 #include "llerror.h"
00042 #include "llfile.h"
00043 #include "lltimer.h"
00044 #include "llstring.h"
00045 #include "lldir.h"
00046 #include "llsdserialize.h"
00047 
00048 #if LL_GTK
00049 # include "gtk/gtk.h"
00050 #endif // LL_GTK
00051 
00052 #define MAX_LOADSTRING 100
00053 
00054 // These need to be localized.
00055 static const char dialog_text[] =
00056 "Second Life appears to have crashed or frozen last time it ran.\n"
00057 "This crash reporter collects information about your computer's hardware, operating system, and some Second Life logs, all of which are used for debugging purposes only.\n"
00058 "\n"
00059 "Send crash report?";
00060 
00061 static const char dialog_title[] =
00062 "Second Life Crash Logger";
00063 
00064 #if LL_GTK
00065 static void response_callback (GtkDialog *dialog,
00066                                gint       arg1,
00067                                gpointer   user_data)
00068 {
00069         gint *response = (gint*)user_data;
00070         *response = arg1;
00071         gtk_widget_destroy(GTK_WIDGET(dialog));
00072         gtk_main_quit();
00073 }
00074 #endif // LL_GTK
00075 
00076 static BOOL do_ask_dialog(void)
00077 {
00078 #if LL_GTK
00079         gtk_disable_setlocale();
00080         if (!gtk_init_check(NULL, NULL)) {
00081                 llinfos << "Could not initialize GTK for 'ask to send crash report' dialog; not sending report." << llendl;
00082                 return FALSE;
00083         }
00084         
00085         GtkWidget *win = NULL;
00086         GtkDialogFlags flags = GTK_DIALOG_MODAL;
00087         GtkMessageType messagetype = GTK_MESSAGE_QUESTION;
00088         GtkButtonsType buttons = GTK_BUTTONS_YES_NO;
00089         gint response = GTK_RESPONSE_NONE;
00090 
00091         win = gtk_message_dialog_new(NULL,
00092                                      flags, messagetype, buttons,
00093                                      dialog_text);
00094         gtk_window_set_type_hint(GTK_WINDOW(win),
00095                                  GDK_WINDOW_TYPE_HINT_DIALOG);
00096         gtk_window_set_title(GTK_WINDOW(win), dialog_title);
00097         g_signal_connect (win,
00098                           "response", 
00099                           G_CALLBACK (response_callback),
00100                           &response);
00101         gtk_widget_show_all (win);
00102         gtk_main();
00103 
00104         return (GTK_RESPONSE_OK == response ||
00105                 GTK_RESPONSE_YES == response ||
00106                 GTK_RESPONSE_APPLY == response);
00107 #else
00108         return FALSE;
00109 #endif // LL_GTK
00110 }
00111 
00112 LLCrashLoggerLinux::LLCrashLoggerLinux(void)
00113 {
00114 }
00115 
00116 LLCrashLoggerLinux::~LLCrashLoggerLinux(void)
00117 {
00118 }
00119 
00120 void LLCrashLoggerLinux::gatherPlatformSpecificFiles()
00121 {
00122         mFileMap["CrashLog"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log").c_str();
00123 }
00124 
00125 bool LLCrashLoggerLinux::mainLoop()
00126 {
00127         if(!do_ask_dialog())
00128         {
00129                 return true;
00130         }
00131         sendCrashLogs();
00132         return true;
00133 }
00134 
00135 void LLCrashLoggerLinux::updateApplication(LLString message)
00136 {
00137         LLCrashLogger::updateApplication(message);
00138 }

Generated on Fri May 16 08:31:53 2008 for SecondLife by  doxygen 1.5.5