Sophie

Sophie

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

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: main.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_695ba8f8357372e02d38c40b3c6dbe81.html">vidalia</a>
  </div>
</div>
<div class="contents">
<h1>vidalia/main.cpp</h1><a href="vidalia_2main_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 main.cpp</span>
<a name="l00013"></a>00013 <span class="comment">** \version $Id: main.cpp 4062 2009-08-21 03:42:25Z edmanm $</span>
<a name="l00014"></a>00014 <span class="comment">** \brief Main Vidalia entry point</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="config_8h.html">config.h</a>&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="_vidalia_8h.html">Vidalia.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="_main_window_8h.html">MainWindow.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="_v_message_box_8h.html">VMessageBox.h</a>&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#if defined(USE_BREAKPAD)</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="_crash_reporter_8h.html">CrashReporter.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#endif</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="procutil_8h.html">procutil.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="stringutil_8h.html">stringutil.h</a>&quot;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;QObject&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#if defined(Q_OS_WIN32)</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#include &lt;QSysInfo&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#endif</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#if defined(HAVE_SIGNAL_H)</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include &lt;signal.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#if defined(USE_BREAKPAD)</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="keywordtype">void</span>
<a name="l00038"></a>00038 setup_crash_reporter()
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040   <span class="comment">/* Set the crash reporting application used to submit minidumps. On Windows,</span>
<a name="l00041"></a>00041 <span class="comment">   * crashreporter.exe is assumed to live in the same directory as vidalia.exe.</span>
<a name="l00042"></a>00042 <span class="comment">   */</span>
<a name="l00043"></a>00043 <span class="preprocessor">#if defined(Q_OS_WIN32)</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>  QString crashReporter = Vidalia::applicationDirPath() + <span class="stringliteral">&quot;\\crashreporter.exe&quot;</span>;
<a name="l00045"></a>00045 <span class="preprocessor">#elif defined(Q_OS_MAC)</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>  QString crashReporter = Vidalia::applicationDirPath() + <span class="stringliteral">&quot;/CrashReporter.app&quot;</span>;
<a name="l00047"></a>00047 <span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (! QFileInfo(crashReporter).isExecutable()) {
<a name="l00049"></a>00049     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Unable to find crash reporting application. Crash reporting will &quot;</span>
<a name="l00050"></a>00050           <span class="stringliteral">&quot;be unavailable.&quot;</span>);
<a name="l00051"></a>00051     <span class="keywordflow">return</span>;
<a name="l00052"></a>00052   }
<a name="l00053"></a>00053   <span class="keywordflow">if</span> (! <a class="code" href="namespace_crash_reporter.html#a2abd2ccfcc795446372a6e01bb49711b">CrashReporter::set_crash_reporter</a>(crashReporter)) {
<a name="l00054"></a>00054     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Vidalia found the crash reporting application, but the path is &quot;</span>
<a name="l00055"></a>00055           <span class="stringliteral">&quot;longer than your platform supports. Skipping crash reporting.&quot;</span>);
<a name="l00056"></a>00056     <span class="keywordflow">return</span>;
<a name="l00057"></a>00057   }
<a name="l00058"></a>00058 
<a name="l00059"></a>00059   <span class="comment">/* Set the Vidalia executable and options used to restart Vidalia after a </span>
<a name="l00060"></a>00060 <span class="comment">   * crash. We strip off the first argument in Vidalia::arguments(), since</span>
<a name="l00061"></a>00061 <span class="comment">   * it&#39;s the application name again anyway. */</span>
<a name="l00062"></a>00062   <a class="code" href="namespace_crash_reporter.html#ac9f4cdac9b824b9d9f44fa3c9b6151d8">CrashReporter::set_restart_options</a>(Vidalia::applicationFilePath(),
<a name="l00063"></a>00063                                      Vidalia::arguments().mid(1));
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   <span class="comment">/* Set the build version that gets saved with a minidump. */</span>
<a name="l00066"></a>00066   <a class="code" href="namespace_crash_reporter.html#a1eca6858cc79eb2d3b50ea0eba54c851">CrashReporter::set_build_version</a>(<a class="code" href="config_8h.html#afa2c3301e77e3b461ba5e9c2701fb0bf">VIDALIA_VERSION</a>);
<a name="l00067"></a>00067 
<a name="l00068"></a>00068   <span class="comment">/* Install the exception handler and give it the location to which Breakpad</span>
<a name="l00069"></a>00069 <span class="comment">   * should write its minidumps. */</span>
<a name="l00070"></a>00070   QString dumpPath = <a class="code" href="class_vidalia.html#a5c923ad28bb9f02299f5c4d3c6c2bde0">Vidalia::dataDirectory</a>() + <span class="stringliteral">&quot;/crashreports&quot;</span>;
<a name="l00071"></a>00071   <span class="keywordflow">if</span> (! <a class="code" href="namespace_crash_reporter.html#a4cb74d71fc0972d3fdded194edf5ef6f">CrashReporter::install_exception_handler</a>(dumpPath)) {
<a name="l00072"></a>00072     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Unable to setup Breakpad exception handler. Crash reporting &quot;</span>
<a name="l00073"></a>00073           <span class="stringliteral">&quot;will be unavailable.&quot;</span>);
<a name="l00074"></a>00074   } <span class="keywordflow">else</span> {
<a name="l00075"></a>00075     <a class="code" href="_vidalia_8h.html#a7743cb328f470aa8f382716fbcf61daa">vInfo</a>(<span class="stringliteral">&quot;Installed Breakpad exception handler.&quot;</span>);
<a name="l00076"></a>00076   }
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078 <span class="preprocessor">#endif</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span>
<a name="l00080"></a>00080 <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span>
<a name="l00081"></a><a class="code" href="vidalia_2main_8cpp.html#a3b527c56ed133ee6815bfbc625e757af">00081</a> <a class="code" href="vidalia_2main_8cpp.html#a3b527c56ed133ee6815bfbc625e757af">signal_handler</a>(<span class="keywordtype">int</span> signal)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 <span class="preprocessor">#ifdef HAVE_SIGNAL_H</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (signal == SIGINT || signal == SIGTERM)
<a name="l00085"></a>00085     <a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;quit();
<a name="l00086"></a>00086 <span class="preprocessor">#endif</span>
<a name="l00087"></a>00087 <span class="preprocessor"></span>}
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="keywordtype">void</span>
<a name="l00090"></a><a class="code" href="vidalia_2main_8cpp.html#aa44876cd498e51d156ba445b3ec15b2b">00090</a> <a class="code" href="vidalia_2main_8cpp.html#aa44876cd498e51d156ba445b3ec15b2b">install_signal_handler</a>()
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 <span class="preprocessor">#if defined(HAVE_SIGACTION)</span>
<a name="l00093"></a>00093 <span class="preprocessor"></span>  <span class="keyword">struct </span>sigaction action;
<a name="l00094"></a>00094 
<a name="l00095"></a>00095   sigemptyset(&amp;action.sa_mask);
<a name="l00096"></a>00096   action.sa_handler = <a class="code" href="vidalia_2main_8cpp.html#a3b527c56ed133ee6815bfbc625e757af">signal_handler</a>;
<a name="l00097"></a>00097   action.sa_flags   = 0;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099   <span class="keywordflow">if</span> (sigaction(SIGINT,  &amp;action, NULL) &lt; 0)
<a name="l00100"></a>00100     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Failed to install SIGINT handler.&quot;</span>);
<a name="l00101"></a>00101   <span class="keywordflow">if</span> (sigaction(SIGTERM, &amp;action, NULL) &lt; 0)
<a name="l00102"></a>00102     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Failed to install SIGTERM handler.&quot;</span>);
<a name="l00103"></a>00103 <span class="preprocessor">#elif defined(HAVE_SIGNAL)</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (signal(SIGINT, <a class="code" href="vidalia_2main_8cpp.html#a3b527c56ed133ee6815bfbc625e757af">signal_handler</a>) == SIG_ERR)
<a name="l00105"></a>00105     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Failed to install SIGINT handler.&quot;</span>);
<a name="l00106"></a>00106   <span class="keywordflow">if</span> (signal(SIGTERM, <a class="code" href="vidalia_2main_8cpp.html#a3b527c56ed133ee6815bfbc625e757af">signal_handler</a>) == SIG_ERR)
<a name="l00107"></a>00107     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Failed to install SIGTERM handler.&quot;</span>);
<a name="l00108"></a>00108 <span class="preprocessor">#endif</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span>}
<a name="l00110"></a>00110 <span class="comment"></span>
<a name="l00111"></a>00111 <span class="comment">/** Returns true if there is already another Vidalia process running. */</span>
<a name="l00112"></a>00112 <span class="keywordtype">bool</span>
<a name="l00113"></a><a class="code" href="vidalia_2main_8cpp.html#ab3dd46a7e87b8e019c7d7671a16db178">00113</a> <a class="code" href="vidalia_2main_8cpp.html#ab3dd46a7e87b8e019c7d7671a16db178">is_vidalia_running</a>(<span class="keyword">const</span> QString &amp;pidfile)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115   <span class="comment">/* Read the pidfile and find out if that process still exists */</span>
<a name="l00116"></a>00116   qint64 pid = <a class="code" href="procutil_8cpp.html#a57687226d89c6ea7588b7faf64b38aa0">read_pidfile</a>(pidfile);
<a name="l00117"></a>00117   <span class="keywordflow">if</span> (pid &gt; 0) {
<a name="l00118"></a>00118 <span class="preprocessor">#if defined(Q_OS_WIN32)</span>
<a name="l00119"></a>00119 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (QSysInfo::WindowsVersion == QSysInfo::WV_NT) {
<a name="l00120"></a>00120       <span class="comment">/* We currently can&#39;t get a list of running processes on Windows NT, so</span>
<a name="l00121"></a>00121 <span class="comment">       * be pessimistic and assume the existence of a nonzero pidfile means</span>
<a name="l00122"></a>00122 <span class="comment">       * Vidalia is running. */</span>
<a name="l00123"></a>00123       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00124"></a>00124     } <span class="keywordflow">else</span>
<a name="l00125"></a>00125       <span class="keywordflow">return</span> (<a class="code" href="procutil_8cpp.html#af5b803a9d74a53d365aa058283187202">is_process_running</a>(pid));
<a name="l00126"></a>00126 <span class="preprocessor">#else</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span>    <span class="keywordflow">return</span> (<a class="code" href="procutil_8cpp.html#af5b803a9d74a53d365aa058283187202">is_process_running</a>(pid));
<a name="l00128"></a>00128 <span class="preprocessor">#endif</span>
<a name="l00129"></a>00129 <span class="preprocessor"></span>  }
<a name="l00130"></a>00130   <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 <span class="comment"></span>
<a name="l00133"></a>00133 <span class="comment">/** Main application entry point. */</span>
<a name="l00134"></a>00134 <span class="keywordtype">int</span>
<a name="l00135"></a><a class="code" href="vidalia_2main_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">00135</a> <a class="code" href="_c_make_c_x_x_compiler_id_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137   Q_INIT_RESOURCE(vidalia);
<a name="l00138"></a>00138   QStringList args = <a class="code" href="stringutil_8cpp.html#aeff472cf5de3a95aa5190d35ffd9661c">char_array_to_stringlist</a>(argv+1, argc-1);
<a name="l00139"></a>00139  
<a name="l00140"></a>00140   <span class="comment">/* Construct the application object. Qt strips any command-line arguments</span>
<a name="l00141"></a>00141 <span class="comment">   * that it recognizes in argv, so we&#39;ll pass a stringlist of the original</span>
<a name="l00142"></a>00142 <span class="comment">   * list of command-line arguments too. */</span>
<a name="l00143"></a>00143   <a class="code" href="class_vidalia.html">Vidalia</a> vidalia(args, argc, argv);
<a name="l00144"></a>00144   <a class="code" href="_vidalia_8h.html#a61e4319b31bbbc7eb1a5724b487be75f">vNotice</a>(<span class="stringliteral">&quot;Vidalia %1 using Qt %2&quot;</span>).arg(<a class="code" href="class_vidalia.html#ab99f86525d7a293c034de37472a01a1e">Vidalia::version</a>())
<a name="l00145"></a>00145                                    .arg(QT_VERSION_STR);
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 <span class="preprocessor">#if defined(USE_BREAKPAD)</span>
<a name="l00148"></a>00148 <span class="preprocessor"></span>  <span class="comment">/* Set up the crash reporting application and exception handlers. */</span>
<a name="l00149"></a>00149   setup_crash_reporter();
<a name="l00150"></a>00150 <span class="preprocessor">#endif</span>
<a name="l00151"></a>00151 <span class="preprocessor"></span><span class="preprocessor">#if defined(USE_MARBLE) &amp;&amp; defined(Q_OS_WIN32)</span>
<a name="l00152"></a>00152 <span class="preprocessor"></span>  <a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;addLibraryPath(<a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;applicationDirPath() + <span class="stringliteral">&quot;/plugins/qt&quot;</span>);
<a name="l00153"></a>00153 <span class="preprocessor">#endif</span>
<a name="l00154"></a>00154 <span class="preprocessor"></span>
<a name="l00155"></a>00155   <span class="comment">/* Install a signal handler to clean up properly after a catching a </span>
<a name="l00156"></a>00156 <span class="comment">   * SIGINT or SIGTERM. */</span>
<a name="l00157"></a>00157   <a class="code" href="vidalia_2main_8cpp.html#aa44876cd498e51d156ba445b3ec15b2b">install_signal_handler</a>();
<a name="l00158"></a>00158 
<a name="l00159"></a>00159   <span class="comment">/* Validate any command-line arguments, or show usage message box, if</span>
<a name="l00160"></a>00160 <span class="comment">   * necessary. */</span>
<a name="l00161"></a>00161   QString errmsg;
<a name="l00162"></a>00162   <span class="keywordflow">if</span> (vidalia.<a class="code" href="class_vidalia.html#ab1a2d5c9fd604562f0435b3fb16ffa20">showUsage</a>()) {
<a name="l00163"></a>00163     <a class="code" href="class_vidalia.html#a91714485213f3c32be4ea7fc672196f5">Vidalia::showUsageMessageBox</a>();
<a name="l00164"></a>00164     <span class="keywordflow">return</span> 0;
<a name="l00165"></a>00165   } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!vidalia.<a class="code" href="class_vidalia.html#af38b9b24bfc6c705790eafd1aabe4dd3">validateArguments</a>(errmsg)) {
<a name="l00166"></a>00166     <a class="code" href="_vidalia_8h.html#a6d72eb09a4436f16d625eeb407801596">vError</a>(<span class="stringliteral">&quot;Unable to apply command-line arguments: %1&quot;</span>).arg(errmsg);
<a name="l00167"></a>00167     <a class="code" href="class_v_message_box.html#a4967bd8c77b7539360160964ed5154e7">VMessageBox::critical</a>(0,
<a name="l00168"></a>00168       <a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;translate(<span class="stringliteral">&quot;Vidalia&quot;</span>,
<a name="l00169"></a>00169         QT_TRANSLATE_NOOP(<span class="stringliteral">&quot;Vidalia&quot;</span>, <span class="stringliteral">&quot;Invalid Argument&quot;</span>)), errmsg,
<a name="l00170"></a>00170       <a class="code" href="class_v_message_box.html#ad9a3aafc6d9076268b6b4b6b1357fe0aafc0d4bb792dca848f92d28e60dec4fe4">VMessageBox::Ok</a>);
<a name="l00171"></a>00171     <span class="keywordflow">return</span> 1;
<a name="l00172"></a>00172   }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174   <span class="comment">/* Check if Vidalia is already running. */</span>
<a name="l00175"></a>00175   QString pidfile = vidalia.<a class="code" href="class_vidalia.html#a7ae15b11700701975272ee7ed919608a">pidFile</a>();
<a name="l00176"></a>00176   <span class="keywordflow">if</span> (<a class="code" href="vidalia_2main_8cpp.html#ab3dd46a7e87b8e019c7d7671a16db178">is_vidalia_running</a>(pidfile)) {
<a name="l00177"></a>00177     <a class="code" href="_vidalia_8h.html#a6d8c1ad992d06eece6f19b8246219779">vWarn</a>(<span class="stringliteral">&quot;Detected another process with pid %1. Is Vidalia already running?&quot;</span>)
<a name="l00178"></a>00178                                                                .arg(<a class="code" href="procutil_8cpp.html#a9815ed5d861a404567963345f845594d">get_pid</a>());
<a name="l00179"></a>00179     <span class="comment">/* Let the user know another Vidalia is running and we are going to exit</span>
<a name="l00180"></a>00180 <span class="comment">     * now. */</span>
<a name="l00181"></a>00181     <span class="keywordtype">int</span> ret = <a class="code" href="class_v_message_box.html#a4967bd8c77b7539360160964ed5154e7">VMessageBox::critical</a>(0, 
<a name="l00182"></a>00182                 <a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;translate(<span class="stringliteral">&quot;Vidalia&quot;</span>,
<a name="l00183"></a>00183                   QT_TRANSLATE_NOOP(<span class="stringliteral">&quot;Vidalia&quot;</span>, <span class="stringliteral">&quot;Vidalia is already running&quot;</span>)),
<a name="l00184"></a>00184                 <a class="code" href="_vidalia_8h.html#aef0a1c1e9430e6b86892ae28b1577294">vApp</a>-&gt;translate(<span class="stringliteral">&quot;Vidalia&quot;</span>,
<a name="l00185"></a>00185                   QT_TRANSLATE_NOOP(<span class="stringliteral">&quot;Vidalia&quot;</span>, 
<a name="l00186"></a>00186                     <span class="stringliteral">&quot;Another Vidalia process is possibly already running. &quot;</span>
<a name="l00187"></a>00187                     <span class="stringliteral">&quot;If there really is not another Vidalia process running, &quot;</span>
<a name="l00188"></a>00188                     <span class="stringliteral">&quot;you can choose to continue anyway.\n\n&quot;</span>
<a name="l00189"></a>00189                     <span class="stringliteral">&quot;Would you like to continue starting Vidalia?&quot;</span>)),
<a name="l00190"></a>00190                 <a class="code" href="class_v_message_box.html#ad9a3aafc6d9076268b6b4b6b1357fe0aab1c7c6bed0ef690b9fdda7fdb96771fe">VMessageBox::Continue</a>, <a class="code" href="class_v_message_box.html#ad9a3aafc6d9076268b6b4b6b1357fe0aa040699bf336710b612071815492258df">VMessageBox::Quit</a>|VMessageBox::Default);
<a name="l00191"></a>00191     <span class="keywordflow">if</span> (ret != <a class="code" href="class_v_message_box.html#ad9a3aafc6d9076268b6b4b6b1357fe0aab1c7c6bed0ef690b9fdda7fdb96771fe">VMessageBox::Continue</a>) {
<a name="l00192"></a>00192       <span class="comment">/* Don&#39;t start a second instance of Vidalia */</span>
<a name="l00193"></a>00193       <a class="code" href="_vidalia_8h.html#a6d72eb09a4436f16d625eeb407801596">vError</a>(<span class="stringliteral">&quot;Exiting duplicate Vidalia process.&quot;</span>);
<a name="l00194"></a>00194       <span class="keywordflow">return</span> 1;
<a name="l00195"></a>00195     }
<a name="l00196"></a>00196   }
<a name="l00197"></a>00197   <a class="code" href="procutil_8cpp.html#a6100070763002248ce43a0a185619010">write_pidfile</a>(pidfile);
<a name="l00198"></a>00198 
<a name="l00199"></a>00199   <span class="comment">/* Since we don&#39;t have a visible main window, if we were to display a</span>
<a name="l00200"></a>00200 <span class="comment">   * QMessageBox (for example, to display an error when starting or stopping</span>
<a name="l00201"></a>00201 <span class="comment">   * Tor) then the application would exit when that message box was closed.</span>
<a name="l00202"></a>00202 <span class="comment">   * Setting quitOnLastWindowClosed to false fixes this behavior. */</span>
<a name="l00203"></a>00203   Vidalia::setQuitOnLastWindowClosed(<span class="keyword">false</span>);
<a name="l00204"></a>00204 
<a name="l00205"></a>00205   <span class="comment">/* Create an instance of the main window  */</span>
<a name="l00206"></a>00206   <a class="code" href="class_main_window.html">MainWindow</a> mainWin;
<a name="l00207"></a>00207 
<a name="l00208"></a>00208   <span class="comment">/* Run Vidalia */</span>
<a name="l00209"></a>00209   <span class="keywordtype">int</span> ret = vidalia.<a class="code" href="class_vidalia.html#a3f758f16af3bb276827bd88b6d7077f5">run</a>();
<a name="l00210"></a>00210 
<a name="l00211"></a>00211   <span class="comment">/* Vidalia exited, so cleanup our pidfile and return */</span>
<a name="l00212"></a>00212   QFile::remove(pidfile);
<a name="l00213"></a>00213   <a class="code" href="_vidalia_8h.html#a61e4319b31bbbc7eb1a5724b487be75f">vNotice</a>(<span class="stringliteral">&quot;Vidalia is exiting cleanly (return code %1).&quot;</span>).arg(ret);
<a name="l00214"></a>00214 
<a name="l00215"></a>00215 <span class="preprocessor">#if defined(USE_BREAKPAD)</span>
<a name="l00216"></a>00216 <span class="preprocessor"></span>  <a class="code" href="_vidalia_8h.html#a7743cb328f470aa8f382716fbcf61daa">vInfo</a>(<span class="stringliteral">&quot;Removing Breakpad exception handler.&quot;</span>);
<a name="l00217"></a>00217   <a class="code" href="namespace_crash_reporter.html#a8c3f2a5d31dbc36bd7081e45394d09ec">CrashReporter::remove_exception_handler</a>();
<a name="l00218"></a>00218 <span class="preprocessor">#endif</span>
<a name="l00219"></a>00219 <span class="preprocessor"></span>
<a name="l00220"></a>00220   <span class="keywordflow">return</span> ret;
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 
</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>