<!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: BootstrapStatus.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 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a> » <a class="el" href="dir_67a2ce25601334632bdc5ef4a72c0f17.html">torcontrol</a> </div> </div> <div class="contents"> <h1>BootstrapStatus.cpp</h1><a href="_bootstrap_status_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 BootstrapStatus.cpp</span> <a name="l00013"></a>00013 <span class="comment">** \version $Id: BootstrapStatus.cpp 3735 2009-04-28 20:28:01Z edmanm $</span> <a name="l00014"></a>00014 <span class="comment">** \brief Describes the Tor software's current bootstrapping status</span> <a name="l00015"></a>00015 <span class="comment">*/</span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="_bootstrap_status_8h.html">BootstrapStatus.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <a name="l00020"></a><a class="code" href="class_bootstrap_status.html#a30c9ef16f324dd3216d44e6bbf75ab7c">00020</a> <a class="code" href="class_bootstrap_status.html#a30c9ef16f324dd3216d44e6bbf75ab7c">BootstrapStatus::BootstrapStatus</a>() <a name="l00021"></a>00021 { <a name="l00022"></a>00022 <a class="code" href="class_bootstrap_status.html#a576ae3a7345fc9f8467f56ce7d2fa1d5">_severity</a> = <a class="code" href="namespacetc.html#abb893107129c283d2eb0238e46eb3d4ca114a8cbfb65f91a0a4fe6e0d1bfbc796">tc::UnrecognizedSeverity</a>; <a name="l00023"></a>00023 <a class="code" href="class_bootstrap_status.html#a3c900f6e99d2124f34d044f1dacbf5fc">_reason</a> = <a class="code" href="namespacetc.html#aa91b304576e66914f8090e682d499340a47b36534d7e8c669a9edddbc020b41c0">tc::UnrecognizedReason</a>; <a name="l00024"></a>00024 <a class="code" href="class_bootstrap_status.html#a4e96a7adfb744da009cab38293d54a74">_status</a> = <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca47592c3e11304b7aa182ad184ebb7aed">UnrecognizedStatus</a>; <a name="l00025"></a>00025 <a class="code" href="class_bootstrap_status.html#a6049ec33e3ab164c47d0af2272bf96dd">_action</a> = <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379ac423617f2b2404b9342cc400a85c937e">UnrecognizedRecommendation</a>; <a name="l00026"></a>00026 <a class="code" href="class_bootstrap_status.html#a6330eaff884e9a5563f7c54daebfe1ee">_percentComplete</a> = -1; <a name="l00027"></a>00027 } <a name="l00028"></a>00028 <span class="comment"></span> <a name="l00029"></a>00029 <span class="comment">/** Constructor. */</span> <a name="l00030"></a><a class="code" href="class_bootstrap_status.html#a3ce8f3a618ac406c1f1d0ee1f8c6b266">00030</a> <a class="code" href="class_bootstrap_status.html#a30c9ef16f324dd3216d44e6bbf75ab7c">BootstrapStatus::BootstrapStatus</a>(<a class="code" href="namespacetc.html#abb893107129c283d2eb0238e46eb3d4c">tc::Severity</a> severity, <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07c">Status</a> status, <a name="l00031"></a>00031 <span class="keywordtype">int</span> percentComplete, <a name="l00032"></a>00032 <span class="keyword">const</span> QString &description, <a name="l00033"></a>00033 <span class="keyword">const</span> QString &warning, <a name="l00034"></a>00034 <a class="code" href="namespacetc.html#aa91b304576e66914f8090e682d499340">tc::ConnectionStatusReason</a> reason, <a name="l00035"></a>00035 <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379">Recommendation</a> action) <a name="l00036"></a>00036 { <a name="l00037"></a>00037 <a class="code" href="class_bootstrap_status.html#a576ae3a7345fc9f8467f56ce7d2fa1d5">_severity</a> = severity; <a name="l00038"></a>00038 <a class="code" href="class_bootstrap_status.html#a4e96a7adfb744da009cab38293d54a74">_status</a> = status; <a name="l00039"></a>00039 <a class="code" href="class_bootstrap_status.html#a6330eaff884e9a5563f7c54daebfe1ee">_percentComplete</a> = qBound(0, percentComplete, 100); <a name="l00040"></a>00040 <a class="code" href="class_bootstrap_status.html#aa7546c499d68d9c27d4fab9c24350901">_description</a> = description; <a name="l00041"></a>00041 <a class="code" href="class_bootstrap_status.html#ac6c27c4cbf91e7b11e541f06abe047da">_warning</a> = warning; <a name="l00042"></a>00042 <a class="code" href="class_bootstrap_status.html#a3c900f6e99d2124f34d044f1dacbf5fc">_reason</a> = reason; <a name="l00043"></a>00043 <a class="code" href="class_bootstrap_status.html#a6049ec33e3ab164c47d0af2272bf96dd">_action</a> = action; <a name="l00044"></a>00044 } <a name="l00045"></a>00045 <span class="comment"></span> <a name="l00046"></a>00046 <span class="comment">/** Converts a string TAG value to a BootstrapStatus enum value. */</span> <a name="l00047"></a>00047 <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07c">BootstrapStatus::Status</a> <a name="l00048"></a><a class="code" href="class_bootstrap_status.html#a0e878a9a8ca87d06c565f3511bc1dd66">00048</a> <a class="code" href="class_bootstrap_status.html#a0e878a9a8ca87d06c565f3511bc1dd66">BootstrapStatus::statusFromString</a>(<span class="keyword">const</span> QString &str) <a name="l00049"></a>00049 { <a name="l00050"></a>00050 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"CONN_DIR"</span>, Qt::CaseInsensitive)) <a name="l00051"></a>00051 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca2862f2ba521d70bc06f84c18a7218154">ConnectingToDirMirror</a>; <a name="l00052"></a>00052 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"HANDSHAKE_DIR"</span>, Qt::CaseInsensitive)) <a name="l00053"></a>00053 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca2bcc13d893ffbd2669fb65d9c0e9a487">HandshakingWithDirMirror</a>; <a name="l00054"></a>00054 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"ONEHOP_CREATE"</span>, Qt::CaseInsensitive)) <a name="l00055"></a>00055 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca0642fb0582453b611a696a141720a2be">CreatingOneHopCircuit</a>; <a name="l00056"></a>00056 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"REQUESTING_STATUS"</span>, Qt::CaseInsensitive)) <a name="l00057"></a>00057 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca2010f508d843698b616d1b58406a2317">RequestingNetworkStatus</a>; <a name="l00058"></a>00058 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"LOADING_STATUS"</span>, Qt::CaseInsensitive)) <a name="l00059"></a>00059 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07caa42d7c854a5f6d9a06819049aa14f48b">LoadingNetworkStatus</a>; <a name="l00060"></a>00060 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"LOADING_KEYS"</span>, Qt::CaseInsensitive)) <a name="l00061"></a>00061 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07caea9083e377e8bcf1e865ec39c73ed51a">LoadingAuthorityCertificates</a>; <a name="l00062"></a>00062 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"REQUESTING_DESCRIPTORS"</span>, Qt::CaseInsensitive)) <a name="l00063"></a>00063 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca324fa30665efc9fd3072d052dd045f5e">RequestingDescriptors</a>; <a name="l00064"></a>00064 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"LOADING_DESCRIPTORS"</span>, Qt::CaseInsensitive)) <a name="l00065"></a>00065 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07caa7966c5713f72191165b5baf1f62ae0c">LoadingDescriptors</a>; <a name="l00066"></a>00066 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"CONN_OR"</span>, Qt::CaseInsensitive)) <a name="l00067"></a>00067 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca85945314be06d1e2c98ae9ba0dc8a875">ConnectingToEntryGuard</a>; <a name="l00068"></a>00068 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"HANDSHAKE_OR"</span>, Qt::CaseInsensitive)) <a name="l00069"></a>00069 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca4795ecadfe4df263654c1617116c2def">HandshakingWithEntryGuard</a>; <a name="l00070"></a>00070 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"CIRCUIT_CREATE"</span>, Qt::CaseInsensitive)) <a name="l00071"></a>00071 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07cad3ef48a5ffbec3c4e5ad7369a405d6df">EstablishingCircuit</a>; <a name="l00072"></a>00072 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"DONE"</span>, Qt::CaseInsensitive)) <a name="l00073"></a>00073 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca3ed55e3a430a43b666c881c2e277b882">BootstrappingDone</a>; <a name="l00074"></a>00074 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca47592c3e11304b7aa182ad184ebb7aed">UnrecognizedStatus</a>; <a name="l00075"></a>00075 } <a name="l00076"></a>00076 <span class="comment"></span> <a name="l00077"></a>00077 <span class="comment">/** Returns the action that the Tor software recommended be taken in response</span> <a name="l00078"></a>00078 <span class="comment"> * to this bootstrap status. */</span> <a name="l00079"></a>00079 <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379">BootstrapStatus::Recommendation</a> <a name="l00080"></a><a class="code" href="class_bootstrap_status.html#a4bd91a88d99ad7157520e0d4c9b9fdf2">00080</a> <a class="code" href="class_bootstrap_status.html#a4bd91a88d99ad7157520e0d4c9b9fdf2">BootstrapStatus::actionFromString</a>(<span class="keyword">const</span> QString &str) <a name="l00081"></a>00081 { <a name="l00082"></a>00082 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"WARN"</span>, Qt::CaseInsensitive)) <a name="l00083"></a>00083 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379a9d1e73c819925426bc6d66d602a2cfc1">RecommendWarn</a>; <a name="l00084"></a>00084 <span class="keywordflow">if</span> (!str.compare(<span class="stringliteral">"IGNORE"</span>, Qt::CaseInsensitive)) <a name="l00085"></a>00085 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379a064682bacf9c31b563e1790c011b65bd">RecommendIgnore</a>; <a name="l00086"></a>00086 <span class="keywordflow">return</span> <a class="code" href="class_bootstrap_status.html#ac3041b0d23ad064b535fe1b7c2775379ac423617f2b2404b9342cc400a85c937e">UnrecognizedRecommendation</a>; <a name="l00087"></a>00087 } <a name="l00088"></a>00088 <span class="comment"></span> <a name="l00089"></a>00089 <span class="comment">/** Returns true if this object represents a valid bootstrap status phase. */</span> <a name="l00090"></a>00090 <span class="keywordtype">bool</span> <a name="l00091"></a><a class="code" href="class_bootstrap_status.html#a32190fbb16214f74e7d68d4527d6ef2a">00091</a> <a class="code" href="class_bootstrap_status.html#a32190fbb16214f74e7d68d4527d6ef2a">BootstrapStatus::isValid</a>()<span class="keyword"> const</span> <a name="l00092"></a>00092 <span class="keyword"></span>{ <a name="l00093"></a>00093 <span class="keywordflow">return</span> (<a class="code" href="class_bootstrap_status.html#a576ae3a7345fc9f8467f56ce7d2fa1d5">_severity</a> != <a class="code" href="namespacetc.html#abb893107129c283d2eb0238e46eb3d4ca114a8cbfb65f91a0a4fe6e0d1bfbc796">tc::UnrecognizedSeverity</a> <a name="l00094"></a>00094 && <a class="code" href="class_bootstrap_status.html#a4e96a7adfb744da009cab38293d54a74">_status</a> != <a class="code" href="class_bootstrap_status.html#a5bbbece8d729bd2e788bb9f427b9e07ca47592c3e11304b7aa182ad184ebb7aed">UnrecognizedStatus</a> <a name="l00095"></a>00095 && <a class="code" href="class_bootstrap_status.html#a6330eaff884e9a5563f7c54daebfe1ee">_percentComplete</a> >= 0); <a name="l00096"></a>00096 } <a name="l00097"></a>00097 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>