]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/debugrpt/debugrpt.cpp
Renewed makefiles after reverting run-time lib change
[wxWidgets.git] / samples / debugrpt / debugrpt.cpp
index 4328075b74e49088bc4d61dcdaa77cf3d0b9f260..456bf020c9062440ab222b13d874fe906cf8b4aa 100644 (file)
     #error "This sample can't be built without wxUSE_DEBUGREPORT"
 #endif // wxUSE_DEBUGREPORT
 
+#if !wxUSE_ON_FATAL_EXCEPTION
+    #error "This sample can't be built without wxUSE_ON_FATAL_EXCEPTION"
+#endif // wxUSE_ON_FATAL_EXCEPTION
+
 // ----------------------------------------------------------------------------
 // custom debug reporting class
 // ----------------------------------------------------------------------------
 
-// this is your custom debug reporter, you will probably want to parse the XML
-// document in OnServerReply() instead of just dumping it as I do
+// this is your custom debug reporter: it will use curl program (which should
+// be available) to upload the crash report to the given URL (which should be
+// set up by you)
 class MyDebugReport : public wxDebugReportUpload
 {
 public:
@@ -46,6 +51,9 @@ public:
     }
 
 protected:
+    // this is called with the contents of the server response: you will
+    // probably want to parse the XML document in OnServerReply() instead of
+    // just dumping it as I do
     virtual bool OnServerReply(const wxArrayString& reply)
     {
         if ( reply.IsEmpty() )
@@ -68,6 +76,32 @@ protected:
     }
 };
 
+// another possibility would be to build email library from contrib and use
+// this class, after uncommenting it:
+#if 0
+
+#include "wx/net/email.h"
+
+class MyDebugReport : public wxDebugReportCompress
+{
+public:
+    virtual bool DoProcess()
+    {
+        if ( !wxDebugReportCompress::DoProcess() )
+            return false;
+        wxMailMessage msg(GetReportName() + _T(" crash report"),
+                          _T("vadim@wxwindows.org"),
+                          wxEmptyString, // mail body
+                          wxEmptyString, // from address
+                          GetCompressedFileName(),
+                          _T("crashreport.zip"));
+
+        return wxEmail::Send(msg);
+    }
+};
+
+#endif // 0
+
 // ----------------------------------------------------------------------------
 // helper functions
 // ----------------------------------------------------------------------------
@@ -135,7 +169,7 @@ public:
             case wxNO:
                 // example of manually generated report, this could be also
                 // used in wxApp::OnAssert()
-                GenerateReport(wxDebugReport::Context_Curent);
+                GenerateReport(wxDebugReport::Context_Current);
                 break;
 
             case wxCANCEL:
@@ -172,6 +206,14 @@ public:
 
         report.AddFile(fn.GetFullName(), _T("timestamp of this report"));
 
+        // can also add an existing file directly, it will be copied
+        // automatically
+#ifdef __WXMSW__
+        report.AddFile(_T("c:\\autoexec.bat"), _T("DOS startup file"));
+#else
+        report.AddFile(_T("/etc/motd"), _T("Message of the day"));
+#endif
+
         // calling Show() is not mandatory, but is more polite
         if ( wxDebugReportPreviewStd().Show(report) )
         {