PageRenderTime 13ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/linux_crash_logger/llcrashloggerlinux.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 145 lines | 99 code | 20 blank | 26 comment | 10 complexity | c91803c43c5ddcc13d6f846e1e8d0454 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcrashloggerlinux.cpp
  3. * @brief Linux crash logger implementation
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llcrashloggerlinux.h"
  27. #include <iostream>
  28. #include "linden_common.h"
  29. #include "indra_constants.h" // CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
  30. #include "llerror.h"
  31. #include "llfile.h"
  32. #include "lltimer.h"
  33. #include "llstring.h"
  34. #include "lldir.h"
  35. #include "llsdserialize.h"
  36. #if LL_GTK
  37. # include "gtk/gtk.h"
  38. #endif // LL_GTK
  39. #define MAX_LOADSTRING 100
  40. // These need to be localized.
  41. static const char dialog_text[] =
  42. "Second Life appears to have crashed or frozen last time it ran.\n"
  43. "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"
  44. "\n"
  45. "Send crash report?";
  46. static const char dialog_title[] =
  47. "Second Life Crash Logger";
  48. #if LL_GTK
  49. static void response_callback (GtkDialog *dialog,
  50. gint arg1,
  51. gpointer user_data)
  52. {
  53. gint *response = (gint*)user_data;
  54. *response = arg1;
  55. gtk_widget_destroy(GTK_WIDGET(dialog));
  56. gtk_main_quit();
  57. }
  58. #endif // LL_GTK
  59. static BOOL do_ask_dialog(void)
  60. {
  61. #if LL_GTK
  62. gtk_disable_setlocale();
  63. if (!gtk_init_check(NULL, NULL)) {
  64. llinfos << "Could not initialize GTK for 'ask to send crash report' dialog; not sending report." << llendl;
  65. return FALSE;
  66. }
  67. GtkWidget *win = NULL;
  68. GtkDialogFlags flags = GTK_DIALOG_MODAL;
  69. GtkMessageType messagetype = GTK_MESSAGE_QUESTION;
  70. GtkButtonsType buttons = GTK_BUTTONS_YES_NO;
  71. gint response = GTK_RESPONSE_NONE;
  72. win = gtk_message_dialog_new(NULL,
  73. flags, messagetype, buttons,
  74. "%s", dialog_text);
  75. gtk_window_set_type_hint(GTK_WINDOW(win),
  76. GDK_WINDOW_TYPE_HINT_DIALOG);
  77. gtk_window_set_title(GTK_WINDOW(win), dialog_title);
  78. g_signal_connect (win,
  79. "response",
  80. G_CALLBACK (response_callback),
  81. &response);
  82. gtk_widget_show_all (win);
  83. gtk_main();
  84. return (GTK_RESPONSE_OK == response ||
  85. GTK_RESPONSE_YES == response ||
  86. GTK_RESPONSE_APPLY == response);
  87. #else
  88. return FALSE;
  89. #endif // LL_GTK
  90. }
  91. LLCrashLoggerLinux::LLCrashLoggerLinux(void)
  92. {
  93. }
  94. LLCrashLoggerLinux::~LLCrashLoggerLinux(void)
  95. {
  96. }
  97. void LLCrashLoggerLinux::gatherPlatformSpecificFiles()
  98. {
  99. }
  100. bool LLCrashLoggerLinux::mainLoop()
  101. {
  102. bool send_logs = true;
  103. if(CRASH_BEHAVIOR_ASK == getCrashBehavior())
  104. {
  105. send_logs = do_ask_dialog();
  106. }
  107. else if(CRASH_BEHAVIOR_NEVER_SEND == getCrashBehavior())
  108. {
  109. send_logs = false;
  110. }
  111. if(send_logs)
  112. {
  113. sendCrashLogs();
  114. }
  115. return true;
  116. }
  117. bool LLCrashLoggerLinux::cleanup()
  118. {
  119. commonCleanup();
  120. return true;
  121. }
  122. void LLCrashLoggerLinux::updateApplication(const std::string& message)
  123. {
  124. LLCrashLogger::updateApplication(message);
  125. }