Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > 9601c7beb4ff23e834bfa171795ed560 > files > 99

vidalia-0.2.9-1mdv2010.1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Vidalia: CrashReportDialog.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_038e8b3624109884d464700e800a8093.html">crashreporter</a>
  </div>
</div>
<div class="contents">
<h1>CrashReportDialog.cpp</h1><a href="_crash_report_dialog_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">**  This file is part of Vidalia, and is subject to the license terms in the</span>
<a name="l00003"></a>00003 <span class="comment">**  LICENSE file, found in the top level directory of this distribution. If you</span>
<a name="l00004"></a>00004 <span class="comment">**  did not receive the LICENSE file with this file, you may obtain it from the</span>
<a name="l00005"></a>00005 <span class="comment">**  Vidalia source package distributed by the Vidalia Project at</span>
<a name="l00006"></a>00006 <span class="comment">**  http://www.vidalia-project.net/. No part of Vidalia, including this file,</span>
<a name="l00007"></a>00007 <span class="comment">**  may be copied, modified, propagated, or distributed except according to the</span>
<a name="l00008"></a>00008 <span class="comment">**  terms described in the LICENSE file.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">/*</span>
<a name="l00012"></a>00012 <span class="comment">** \file CrashReportDialog.cpp</span>
<a name="l00013"></a>00013 <span class="comment">** \version $Id$</span>
<a name="l00014"></a>00014 <span class="comment">** \brief Dialog that asks the user whether they would like to</span>
<a name="l00015"></a>00015 <span class="comment">** submit the crash report, along with optional additional details</span>
<a name="l00016"></a>00016 <span class="comment">** about what they were doing at the time of the crash.</span>
<a name="l00017"></a>00017 <span class="comment">*/</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="_crash_report_dialog_8h.html">CrashReportDialog.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="_crash_report_uploader_8h.html">CrashReportUploader.h</a>&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="_upload_progress_dialog_8h.html">UploadProgressDialog.h</a>&quot;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="stringutil_8h.html">stringutil.h</a>&quot;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;QProcess&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;QPushButton&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;QMessageBox&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;QFileInfo&gt;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="class_crash_report_dialog.html#a3d67299fbdae910617db35ef37d29a2a">00031</a> <a class="code" href="class_crash_report_dialog.html#a3d67299fbdae910617db35ef37d29a2a">CrashReportDialog::CrashReportDialog</a>(QWidget *parent)
<a name="l00032"></a>00032   : QDialog(parent)
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034   <a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.setupUi(<span class="keyword">this</span>);
<a name="l00035"></a>00035 
<a name="l00036"></a>00036   <span class="comment">/* Tweak the text displayed on the buttons at the bottom of the dialog */</span>
<a name="l00037"></a>00037   QPushButton *btn;
<a name="l00038"></a>00038   btn = <a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.buttonBox-&gt;button(QDialogButtonBox::Ok);
<a name="l00039"></a>00039   btn-&gt;setText(tr(<span class="stringliteral">&quot;Restart Vidalia&quot;</span>));
<a name="l00040"></a>00040 
<a name="l00041"></a>00041   btn = <a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.buttonBox-&gt;button(QDialogButtonBox::Cancel);
<a name="l00042"></a>00042   btn-&gt;setText(tr(<span class="stringliteral">&quot;Don&#39;t Restart&quot;</span>));
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="keywordtype">void</span>
<a name="l00046"></a><a class="code" href="class_crash_report_dialog.html#a06d533cf39f3b2665e4784aa3bca3a17">00046</a> <a class="code" href="class_crash_report_dialog.html#a06d533cf39f3b2665e4784aa3bca3a17">CrashReportDialog::setCrashAnnotations</a>(<span class="keyword">const</span> QHash&lt;QString,QString&gt; &amp;annotations)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048   <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a> = annotations;
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="keywordtype">void</span>
<a name="l00052"></a><a class="code" href="class_crash_report_dialog.html#a8ea6147e516b2f7b8581aacb1f0031ed">00052</a> <a class="code" href="class_crash_report_dialog.html#a8ea6147e516b2f7b8581aacb1f0031ed">CrashReportDialog::setMinidump</a>(<span class="keyword">const</span> QString &amp;<span class="keywordtype">id</span>, <span class="keyword">const</span> QByteArray &amp;minidump)
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054   <a class="code" href="class_crash_report_dialog.html#a1149ed801ec10e3d2530728b19edd7b5">_minidump</a> = minidump;
<a name="l00055"></a>00055   <a class="code" href="class_crash_report_dialog.html#ae74201384edd6a53de9a5fe2790898be">_minidumpId</a> = id;
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keywordtype">void</span>
<a name="l00059"></a><a class="code" href="class_crash_report_dialog.html#abf04b9d915ec2db9c2e5428ab95040f3">00059</a> <a class="code" href="class_crash_report_dialog.html#abf04b9d915ec2db9c2e5428ab95040f3">CrashReportDialog::submitCrashReport</a>()
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061   <a class="code" href="class_crash_report_uploader.html">CrashReportUploader</a> *uploader = <span class="keyword">new</span> <a class="code" href="class_crash_report_uploader.html">CrashReportUploader</a>();
<a name="l00062"></a>00062   <a class="code" href="class_upload_progress_dialog.html">UploadProgressDialog</a> *progressDialog = <span class="keyword">new</span> <a class="code" href="class_upload_progress_dialog.html">UploadProgressDialog</a>(<span class="keyword">this</span>);
<a name="l00063"></a>00063   QMap&lt;QString,QString&gt; parameters;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   connect(uploader, SIGNAL(statusChanged(QString)),
<a name="l00066"></a>00066           progressDialog, SLOT(setStatus(QString)));
<a name="l00067"></a>00067   connect(uploader, SIGNAL(uploadProgress(<span class="keywordtype">int</span>, <span class="keywordtype">int</span>)),
<a name="l00068"></a>00068           progressDialog, SLOT(setUploadProgress(<span class="keywordtype">int</span>, <span class="keywordtype">int</span>)));
<a name="l00069"></a>00069   connect(uploader, SIGNAL(uploadFinished()),
<a name="l00070"></a>00070           progressDialog, SLOT(<a class="code" href="class_crash_report_dialog.html#af866c82cd9f0c58b1c61ebae47af4dd1">accept</a>()));
<a name="l00071"></a>00071   connect(uploader, SIGNAL(uploadFailed(QString)),
<a name="l00072"></a>00072           progressDialog, SLOT(uploadFailed(QString)));
<a name="l00073"></a>00073 
<a name="l00074"></a>00074   <span class="comment">/* Set up the form fields that will be uploaded with the minidump */</span>
<a name="l00075"></a>00075   QString comments = <a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.textDetails-&gt;toPlainText();
<a name="l00076"></a>00076   <span class="keywordflow">if</span> (! comments.isEmpty())
<a name="l00077"></a>00077     parameters.insert(<span class="stringliteral">&quot;Comments&quot;</span>, comments);
<a name="l00078"></a>00078   parameters.insert(<span class="stringliteral">&quot;ProductName&quot;</span>, <span class="stringliteral">&quot;Vidalia&quot;</span>);
<a name="l00079"></a>00079   parameters.insert(<span class="stringliteral">&quot;Vendor&quot;</span>, <span class="stringliteral">&quot;Vidalia&quot;</span>);
<a name="l00080"></a>00080   parameters.insert(<span class="stringliteral">&quot;Version&quot;</span>, <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a>.value(<span class="stringliteral">&quot;BuildVersion&quot;</span>));
<a name="l00081"></a>00081   parameters.insert(<span class="stringliteral">&quot;CrashTime&quot;</span>, <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a>.value(<span class="stringliteral">&quot;CrashTime&quot;</span>));
<a name="l00082"></a>00082   parameters.insert(<span class="stringliteral">&quot;StartupTime&quot;</span>, <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a>.value(<span class="stringliteral">&quot;StartupTime&quot;</span>));
<a name="l00083"></a>00083 
<a name="l00084"></a>00084   <span class="comment">/* Start the upload (returns immediately) */</span>
<a name="l00085"></a>00085   uploader-&gt;<a class="code" href="class_crash_report_uploader.html#a4a1eceee25004e7d3b18d7831a503607">uploadMinidump</a>(QUrl(<span class="stringliteral">&quot;https://crashes.vidalia-project.net/submit&quot;</span>),
<a name="l00086"></a>00086                            <a class="code" href="class_crash_report_dialog.html#ae74201384edd6a53de9a5fe2790898be">_minidumpId</a>, <a class="code" href="class_crash_report_dialog.html#a1149ed801ec10e3d2530728b19edd7b5">_minidump</a>, parameters);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088   <span class="comment">/* Displays a modal progress dialog showing the progress of the upload. This</span>
<a name="l00089"></a>00089 <span class="comment">   * will return when either the upload completes or the user hits &quot;Cancel&quot;. */</span>
<a name="l00090"></a>00090   <span class="keywordflow">if</span> (progressDialog-&gt;exec() == QDialog::Rejected)
<a name="l00091"></a>00091     uploader-&gt;<a class="code" href="class_crash_report_uploader.html#a4490b2043602a1983ad2b684b29434f6">cancel</a>(); <span class="comment">/* User clicked &quot;Cancel&quot; */</span>
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   <span class="keyword">delete</span> uploader;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 <span class="keywordtype">void</span>
<a name="l00097"></a><a class="code" href="class_crash_report_dialog.html#af866c82cd9f0c58b1c61ebae47af4dd1">00097</a> <a class="code" href="class_crash_report_dialog.html#af866c82cd9f0c58b1c61ebae47af4dd1">CrashReportDialog::accept</a>()
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099   <span class="comment">/* Upload the crash report, unless the user opted out */</span>
<a name="l00100"></a>00100   <span class="keywordflow">if</span> (<a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.chkSubmitCrashReport-&gt;isChecked())
<a name="l00101"></a>00101     <a class="code" href="class_crash_report_dialog.html#abf04b9d915ec2db9c2e5428ab95040f3">submitCrashReport</a>();
<a name="l00102"></a>00102 
<a name="l00103"></a>00103   <span class="comment">/* Attempt to restart Vidalia with the saved arguments */</span>
<a name="l00104"></a>00104   QString exe  = <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a>.value(<span class="stringliteral">&quot;RestartExecutable&quot;</span>);
<a name="l00105"></a>00105   QString args = <a class="code" href="class_crash_report_dialog.html#a2b0ed8abb09cca203c9976e6716dc1c5">_annotations</a>.value(<span class="stringliteral">&quot;RestartExecutableArgs&quot;</span>);
<a name="l00106"></a>00106   QStringList argList = <a class="code" href="stringutil_8cpp.html#af8d2b1877609953a0b67d43665b773b4">string_parse_arguments</a>(args);
<a name="l00107"></a>00107   <span class="keywordflow">if</span> (! QProcess::startDetached(exe, argList, QFileInfo(exe).absolutePath())) {
<a name="l00108"></a>00108     QMessageBox dlg(QMessageBox::Warning, tr(<span class="stringliteral">&quot;Unable to restart Vidalia&quot;</span>),
<a name="l00109"></a>00109                     tr(<span class="stringliteral">&quot;We were unable to automatically restart Vidalia. &quot;</span>
<a name="l00110"></a>00110                        <span class="stringliteral">&quot;Please restart Vidalia manually.&quot;</span>),
<a name="l00111"></a>00111                     QMessageBox::Ok, <span class="keyword">this</span>);
<a name="l00112"></a>00112     dlg.exec();
<a name="l00113"></a>00113   }
<a name="l00114"></a>00114 
<a name="l00115"></a>00115   <span class="comment">/* Close the dialog */</span>
<a name="l00116"></a>00116   <a class="code" href="class_crash_report_dialog.html#af866c82cd9f0c58b1c61ebae47af4dd1">QDialog::accept</a>();
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 <span class="keywordtype">void</span>
<a name="l00120"></a><a class="code" href="class_crash_report_dialog.html#a29eb3a0077d94675a9c4fc3bca849478">00120</a> <a class="code" href="class_crash_report_dialog.html#a29eb3a0077d94675a9c4fc3bca849478">CrashReportDialog::reject</a>()
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122   <span class="comment">/* Upload the crash report, unless the user opted out */</span>
<a name="l00123"></a>00123   <span class="keywordflow">if</span> (<a class="code" href="class_crash_report_dialog.html#adfa26d7ffa031417c077616219d3ea3f">ui</a>.chkSubmitCrashReport-&gt;isChecked())
<a name="l00124"></a>00124     <a class="code" href="class_crash_report_dialog.html#abf04b9d915ec2db9c2e5428ab95040f3">submitCrashReport</a>();
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="comment">/* Close this dialog without restarting Vidalia */</span>
<a name="l00127"></a>00127   <a class="code" href="class_crash_report_dialog.html#a29eb3a0077d94675a9c4fc3bca849478">QDialog::reject</a>();
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>