~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/core/crashreporting.h

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of Clementine.
 
2
   Copyright 2010, David Sansome <me@davidsansome.com>
 
3
 
 
4
   Clementine is free software: you can redistribute it and/or modify
 
5
   it under the terms of the GNU General Public License as published by
 
6
   the Free Software Foundation, either version 3 of the License, or
 
7
   (at your option) any later version.
 
8
 
 
9
   Clementine is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with Clementine.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
#ifndef CRASHREPORTING_H
 
19
#define CRASHREPORTING_H
 
20
 
 
21
#include <QObject>
 
22
 
 
23
#include <boost/scoped_ptr.hpp>
 
24
 
 
25
class QFile;
 
26
class QNetworkAccessManager;
 
27
class QProgressDialog;
 
28
 
 
29
namespace google_breakpad {
 
30
  class ExceptionHandler;
 
31
}
 
32
 
 
33
 
 
34
// Wraps google_breakpad::ExceptionHandler - while an instance of this class
 
35
// is alive crashes will be handled.
 
36
class CrashReporting {
 
37
public:
 
38
  CrashReporting();
 
39
  ~CrashReporting();
 
40
 
 
41
  // If the commandline contains the --send-crash-report option, the user will
 
42
  // be prompted to send the crash report and the function will return true
 
43
  // (in which case the caller should exit the program).  Otherwise the function
 
44
  // returns false.
 
45
  static bool SendCrashReport(int argc, char** argv);
 
46
 
 
47
  // If this is set then the application is exec'd again with
 
48
  // --send-crash-report when a crash happens.
 
49
  static void SetApplicationPath(const QString& path);
 
50
 
 
51
private:
 
52
  // Prints the message to stdout without using libc.
 
53
  static void Print(const char* message);
 
54
 
 
55
  // Breakpad callback.
 
56
  static bool Handler(const char* dump_path,
 
57
                      const char* minidump_id,
 
58
                      void* context,
 
59
                      bool succeeded);
 
60
 
 
61
private:
 
62
  Q_DISABLE_COPY(CrashReporting);
 
63
 
 
64
  static const char* kSendCrashReportOption;
 
65
  static char* sPath;
 
66
 
 
67
  boost::scoped_ptr<google_breakpad::ExceptionHandler> handler_;
 
68
};
 
69
 
 
70
 
 
71
// Asks the user if he wants to send a crash report, and displays a progress
 
72
// dialog while uploading it if he does.
 
73
class CrashSender : public QObject {
 
74
  Q_OBJECT
 
75
 
 
76
public:
 
77
  CrashSender(const QString& path);
 
78
 
 
79
  // Returns false if the user doesn't want to send the crash report (caller
 
80
  // should exit), or true if he does (caller should start the Qt event loop).
 
81
  bool Start();
 
82
 
 
83
private slots:
 
84
  void RedirectFinished();
 
85
  void UploadProgress(qint64 bytes);
 
86
 
 
87
private:
 
88
  static const char* kUploadURL;
 
89
 
 
90
  QNetworkAccessManager* network_;
 
91
 
 
92
  QString path_;
 
93
  QFile* file_;
 
94
  QProgressDialog* progress_;
 
95
};
 
96
 
 
97
#endif // CRASHREPORTING_H