make ValueTransfer easier to understand
[LibreOffice.git] / include / desktop / crashreport.hxx
blob403e3117117d0837abad7ed6bb934eb5b680514e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_DESKTOP_CRASHREPORT_HXX
11 #define INCLUDED_DESKTOP_CRASHREPORT_HXX
13 #include <desktop/dllapi.h>
15 #include <rtl/ustring.hxx>
16 #include <osl/mutex.hxx>
18 #include <config_features.h>
20 // vector not sort the entries
21 #include <memory>
22 #include <vector>
23 #include <deque>
24 #include <string>
26 namespace google_breakpad
28 class ExceptionHandler;
31 /**
32 * Provides access to the crash reporter service.
34 * Valid keys are:
35 * * AdapterVendorId
36 * * AdapterDeviceId
39 class
40 #if HAVE_FEATURE_BREAKPAD
41 // MSVC 2013 has undefined symbols for inline functions if it's exported
42 CRASHREPORT_DLLPUBLIC
43 #endif
44 /*class*/ CrashReporter
46 public:
47 typedef enum {AddItem, Write, Create} tAddKeyHandling;
48 #if HAVE_FEATURE_BREAKPAD
49 static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling);
51 static void installExceptionHandler();
52 static void removeExceptionHandler();
54 static void setActiveSfxObjectName(const OUString& rActiveSfxObjectName);
55 static OUString getActiveSfxObjectName();
57 static void logUnoCommand(const OUString& rUnoCommand);
58 static OUString getLoggedUnoCommands();
60 static bool crashReportInfoExists();
62 static bool readSendConfig(std::string& response);
64 static bool IsDumpEnable();
66 private:
67 static osl::Mutex maMutex;
68 static osl::Mutex maActiveSfxObjectNameMutex;
69 static osl::Mutex maUnoLogCmdMutex;
70 static bool mbInit;
71 typedef struct _mpair
73 OUString first;
74 OUString second;
75 _mpair(const OUString& First, const OUString& Second)
77 first = First;
78 second = Second;
80 } mpair;
82 typedef std::vector<mpair> vmaKeyValues;
83 static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded
84 typedef std::deque<OUString> vmaloggedUnoCommands;
85 static vmaloggedUnoCommands maloggedUnoCommands;
86 static OUString msActiveSfxObjectName;
88 static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler;
90 static std::string getIniFileName();
91 static void writeCommonInfo();
92 static void writeSystemInfo();
93 static void writeToFile(std::ios_base::openmode Openmode);
94 // when we create the ExceptionHandler we have no access to the user
95 // profile yet, so update when we have access
96 static void updateMinidumpLocation();
98 #else
99 // Add dummy methods for the non-breakpad case. That allows us to use
100 // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
101 // // everywhere we want to log something to the crash report system.
102 inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {};
103 inline static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString& /*rActiveSfxObjectName*/) {};
104 inline static OUString getActiveSfxObjectName()
106 return OUString();
108 inline static void logUnoCommand(SAL_UNUSED_PARAMETER const OUString& /*rUnoCommand*/) {};
109 inline static OUString getLoggedUnoCommands()
111 return OUString();
113 #endif // HAVE_FEATURE_BREAKPAD
116 #endif // INCLUDED_DESKTOP_CRASHREPORT_HXX
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */