]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/bootstrap.cxx
Update image-server logic.
[flightgear.git] / src / Main / bootstrap.cxx
index fe988d7e34f37552406b16ab6a82934b5fb15324..326401a7573b3e556d4f93d43de53af31d470afa 100644 (file)
@@ -60,6 +60,7 @@ using std::endl;
 
 #include <Viewer/fgviewer.hxx>
 #include "main.hxx"
+#include <Include/version.h>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <GUI/MessageBox.hxx>
@@ -70,6 +71,13 @@ using std::endl;
     #include <GUI/CocoaHelpers.h> // for transformToForegroundApp
 #endif
 
+#if defined(HAVE_CRASHRPT)
+       #include <CrashRpt.h>
+
+bool global_crashRptEnabled = false;
+
+#endif
+
 std::string homedir;
 std::string hostname;
 
@@ -176,6 +184,50 @@ int main ( int argc, char **argv )
 #endif
     _bootstrap_OSInit = 0;
 
+#if defined(HAVE_CRASHRPT)
+       // Define CrashRpt configuration parameters
+       CR_INSTALL_INFO info;  
+       memset(&info, 0, sizeof(CR_INSTALL_INFO));  
+       info.cb = sizeof(CR_INSTALL_INFO);    
+       info.pszAppName = "FlightGear";
+       info.pszAppVersion = FLIGHTGEAR_VERSION;
+       info.pszEmailSubject = "FlightGear " FLIGHTGEAR_VERSION " crash report";
+       info.pszEmailTo = "fgcrash@goneabitbursar.com";
+       info.pszUrl = "http://fgfs.goneabitbursar.com/crashreporter/crashrpt.php";
+       info.uPriorities[CR_HTTP] = 3; 
+       info.uPriorities[CR_SMTP] = 2;  
+       info.uPriorities[CR_SMAPI] = 1;
+
+       // Install all available exception handlers
+       info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;
+  
+       // Restart the app on crash 
+       info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; 
+
+       // automatically install handlers for all threads
+       info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS;
+
+       // Define the Privacy Policy URL 
+       info.pszPrivacyPolicyURL = "http://flightgear.org/crash-privacypolicy.html"; 
+  
+       // Install crash reporting
+       int nResult = crInstall(&info);    
+       if(nResult!=0) {
+               char buf[1024];
+               crGetLastErrorMsg(buf, 1024);
+               flightgear::modalMessageBox("CrashRpt setup failed", 
+                       "Failed to setup crash-reporting engine, check the installation is not damaged.",
+                       buf);
+       } else {
+               global_crashRptEnabled = true;
+
+               crAddProperty("hudson-build-id", HUDSON_BUILD_ID);
+               char buf[16];
+               ::snprintf(buf, 16, "%d", HUDSON_BUILD_NUMBER);
+               crAddProperty("hudson-build-number", buf);
+       }
+#endif
+
 #if defined(__FreeBSD__)
     // Ignore floating-point exceptions on FreeBSD
     signal(SIGFPE, SIG_IGN); 
@@ -224,8 +276,7 @@ int main ( int argc, char **argv )
             fgviewerMain(argc, argv);
         else
             fgMainInit(argc, argv);
-            
-        
+           
     } catch (const sg_throwable &t) {
         std::string info;
         if (std::strlen(t.getOrigin()) != 0)
@@ -245,6 +296,10 @@ int main ( int argc, char **argv )
             perror("Possible cause");
     }
 
+#if defined(HAVE_CRASHRPT)
+       crUninstall();
+#endif
+
     return 0;
 }