Vidalia 0.2.12
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file CrashReportUploader.h 00013 ** \brief Uploads a minidump file and any extra information to a crash 00014 ** reporting server. 00015 */ 00016 00017 #ifndef _CRASHREPORTUPLOADER_H 00018 #define _CRASHREPORTUPLOADER_H 00019 00020 #include <QObject> 00021 #include <QHttp> 00022 #include <QMap> 00023 00024 class QUrl; 00025 class QString; 00026 class QByteArray; 00027 00028 00029 class CrashReportUploader : public QObject 00030 { 00031 Q_OBJECT 00032 00033 public: 00034 /** Default constructor. 00035 */ 00036 CrashReportUploader(QObject *parent = 0); 00037 00038 /** Starts uploading <b>minidump</b> to <b>serverUrl</b> and returns 00039 * immediately. <b>minidumpId</b> is the minidump GUID generated by 00040 * the exception handler and used for the minidump's filename. The 00041 * optional <b>parameters</b> can be used to pass additional form fields 00042 * to the crash reporting server. 00043 */ 00044 void uploadMinidump(const QUrl &serverUrl, 00045 const QString &minidumpId, 00046 const QByteArray &minidump, 00047 const QMap<QString,QString> ¶meters); 00048 00049 public slots: 00050 /** Cancels a pending minidump upload. 00051 */ 00052 void cancel(); 00053 00054 signals: 00055 /** Emitted when the underlying QHttp object posts data to the server. 00056 * <b>done</b> indicates how many bytes out of <b>total</b> 00057 * have been sent so far. 00058 */ 00059 void uploadProgress(int done, int total); 00060 00061 /** Emitted when the status of the POST request changes. <b>status</b> 00062 * describes the new current state of the request. 00063 */ 00064 void statusChanged(const QString &status); 00065 00066 /** Emitted when the previous minidump upload completes successfully. 00067 */ 00068 void uploadFinished(); 00069 00070 /** Emitted when the previous crash report upload fails. The QString 00071 * <b>error</b> is a human-readable string describing the error 00072 * encountered. 00073 */ 00074 void uploadFailed(const QString &error); 00075 00076 private slots: 00077 /** Called when the state of the underlying QHttp object changes. A 00078 * statusChanged() signal is emitted with the appropriate text 00079 * describing the new state of the POST request. 00080 */ 00081 void httpStateChanged(int state); 00082 00083 /** Called when the underlying QHttp object used to upload the minidump 00084 * completes. <b>error</b> is set to false if the upload was 00085 * successful, or true if the upload failed. If <b>id</b> does not 00086 * match the request ID previously returned by QHttp::get(), then the 00087 * signal is ignored since it is the result of a close() or abort() 00088 * request. 00089 */ 00090 void httpRequestFinished(int id, bool error); 00091 00092 private: 00093 /** Generates a "random" 8-byte multipart boundary marker encoded into 00094 * 16 hex characters. 00095 */ 00096 QString generateBoundaryMarker() const; 00097 00098 /** Unique numeric identifier of the current minidump upload POST request. 00099 */ 00100 int _requestId; 00101 00102 /** Object used to POST a minidump to the crash server and read the 00103 * response. 00104 */ 00105 QHttp *_http; 00106 }; 00107 00108 #endif 00109