Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > 9601c7beb4ff23e834bfa171795ed560 > files > 373

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: UPNPControlThread.h 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>&nbsp;&raquo;&nbsp;<a class="el" href="dir_738aec08306f4b898e01f7a551299457.html">config</a>
  </div>
</div>
<div class="contents">
<h1>UPNPControlThread.h</h1><a href="_u_p_n_p_control_thread_8h.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 </span>
<a name="l00004"></a>00004 <span class="comment">**  you did not receive the LICENSE file with this file, you may obtain it</span>
<a name="l00005"></a>00005 <span class="comment">**  from the 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</span>
<a name="l00008"></a>00008 <span class="comment">**  the 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 UPNPControlThread.h</span>
<a name="l00013"></a>00013 <span class="comment">** \version $Id: UPNPControlThread.h 3735 2009-04-28 20:28:01Z edmanm $</span>
<a name="l00014"></a>00014 <span class="comment">** \brief Thread for configuring UPnP in the background</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef _UPNPCONTROLTHREAD_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _UPNPCONTROLTHREAD_H</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="_u_p_n_p_control_8h.html">UPNPControl.h</a>&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a><a class="code" href="_u_p_n_p_control_thread_8h.html#a661d5ce429e3f95980ed1aee0db1c38b">00022</a> <span class="preprocessor">#define STATICLIB</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="miniwget_8h.html">miniupnpc/miniwget.h</a>&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;<a class="code" href="miniupnpc_8h.html">miniupnpc/miniupnpc.h</a>&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;<a class="code" href="upnpcommands_8h.html">miniupnpc/upnpcommands.h</a>&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#undef STATICLIB</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;QThread&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;QMutex&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;QWaitCondition&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;QTime&gt;</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="class_u_p_n_p_control_thread.html">00034</a> <span class="keyword">class </span><a class="code" href="class_u_p_n_p_control_thread.html">UPNPControlThread</a> : <span class="keyword">public</span> QThread
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036   Q_OBJECT
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00039"></a>00039 <span class="comment">  /** Specifies the number of milliseconds to wait for devices to respond</span>
<a name="l00040"></a>00040 <span class="comment">   * when attempting to discover UPnP-enabled IGDs. */</span>
<a name="l00041"></a><a class="code" href="class_u_p_n_p_control_thread.html#afd5cb7c165c3094a209905ec860f750b">00041</a>   <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="class_u_p_n_p_control_thread.html#afd5cb7c165c3094a209905ec860f750b">UPNPCONTROL_DISCOVER_TIMEOUT</a> = 2000;
<a name="l00042"></a>00042 <span class="comment"></span>
<a name="l00043"></a>00043 <span class="comment">  /** Constructor. &lt;b&gt;control&lt;/b&gt; will be used for retrieving the desired port</span>
<a name="l00044"></a>00044 <span class="comment">   * forwarding state. */</span>
<a name="l00045"></a>00045   <a class="code" href="class_u_p_n_p_control_thread.html#acad904d9162fd36ba3c8a70fe4da324c">UPNPControlThread</a>(<a class="code" href="class_u_p_n_p_control.html">UPNPControl</a> *control);<span class="comment"></span>
<a name="l00046"></a>00046 <span class="comment">  /** Destructor. The UPnP control thread must be stopped prior to destroying</span>
<a name="l00047"></a>00047 <span class="comment">   * this object. */</span>
<a name="l00048"></a>00048   <a class="code" href="class_u_p_n_p_control_thread.html#acc42a0954f37bf112dc007a0271151ac">~UPNPControlThread</a>();<span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">  /** Terminates the UPnP control thread&#39;s run() loop. */</span>
<a name="l00050"></a>00050   <span class="keywordtype">void</span> <a class="code" href="class_u_p_n_p_control_thread.html#a40f18f372042ea896ea1b84327baa715">stop</a>();<span class="comment"></span>
<a name="l00051"></a>00051 <span class="comment">  /** Wakes up the UPnP control thread&#39;s run() loop. */</span>
<a name="l00052"></a>00052   <span class="keywordtype">void</span> <a class="code" href="class_u_p_n_p_control_thread.html#a6b124158f9496b2da905c405aba7c321">wakeup</a>();
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="keyword">protected</span>:<span class="comment"></span>
<a name="l00055"></a>00055 <span class="comment">  /** Thread entry point. The thread has a main loop that periodically wakes</span>
<a name="l00056"></a>00056 <span class="comment">   * up  and updates the configured port mappings. Upon exiting, all port</span>
<a name="l00057"></a>00057 <span class="comment">   * mappings will be removed. */</span>
<a name="l00058"></a>00058   <span class="keywordtype">void</span> <a class="code" href="class_u_p_n_p_control_thread.html#a560bf065dce3594ace3e94652c2d9520">run</a>();
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <span class="keyword">private</span>:<span class="comment"></span>
<a name="l00061"></a>00061 <span class="comment">  /** Sets up port forwarding according the previously-configured desired</span>
<a name="l00062"></a>00062 <span class="comment">   * state. The desired state is set using UPNPControl&#39;s setDesiredState()</span>
<a name="l00063"></a>00063 <span class="comment">   * method. */</span>
<a name="l00064"></a>00064   <span class="keywordtype">void</span> <a class="code" href="class_u_p_n_p_control_thread.html#a3412310f08298f82325f19e0bdc12981">configurePorts</a>();<span class="comment"></span>
<a name="l00065"></a>00065 <span class="comment">  /** Discovers UPnP-enabled IGDs on the network.  This method will block for</span>
<a name="l00066"></a>00066 <span class="comment">   * UPNPCONTROL_DISCOVER_TIMEOUT milliseconds. */</span>
<a name="l00067"></a>00067   <a class="code" href="class_u_p_n_p_control.html#a8a2e746cc9e991fec8b724f7a388b7c5">UPNPControl::UPNPError</a> <a class="code" href="class_u_p_n_p_control_thread.html#a840da06b35dcd6e583fa65490d88945a">initializeUPNP</a>();<span class="comment"></span>
<a name="l00068"></a>00068 <span class="comment">  /** Updates the port mapping for &lt;b&gt;oldPort&lt;/b&gt;, changing it to </span>
<a name="l00069"></a>00069 <span class="comment">   * &lt;b&gt;newPort&lt;/b&gt;. */</span>
<a name="l00070"></a>00070   <a class="code" href="class_u_p_n_p_control.html#a8a2e746cc9e991fec8b724f7a388b7c5">UPNPControl::UPNPError</a> <a class="code" href="class_u_p_n_p_control_thread.html#aaad47cb205ea1b45bbc267e97419e4c1">updatePort</a>(quint16 oldPort, quint16 newPort);<span class="comment"></span>
<a name="l00071"></a>00071 <span class="comment">  /** Adds a port forwarding mapping from external:&lt;b&gt;port&lt;/b&gt; to</span>
<a name="l00072"></a>00072 <span class="comment">   * internal:&lt;b&gt;port&lt;/b&gt;. Returns 0 on success, or non-zero on failure. */</span>
<a name="l00073"></a>00073   <a class="code" href="class_u_p_n_p_control.html#a8a2e746cc9e991fec8b724f7a388b7c5">UPNPControl::UPNPError</a> <a class="code" href="class_u_p_n_p_control_thread.html#acc3fb03ce1dda74e428483bac5402e98">forwardPort</a>(quint16 port);<span class="comment"></span>
<a name="l00074"></a>00074 <span class="comment">  /** Removes the port mapping for &lt;b&gt;port&lt;/b&gt;. Returns 0 on success or</span>
<a name="l00075"></a>00075 <span class="comment">   * non-zero on failure. */</span>
<a name="l00076"></a>00076   <a class="code" href="class_u_p_n_p_control.html#a8a2e746cc9e991fec8b724f7a388b7c5">UPNPControl::UPNPError</a> <a class="code" href="class_u_p_n_p_control_thread.html#a2bfca0a2a124dd59bf0e956cfbd78236">disablePort</a>(quint16 port);
<a name="l00077"></a>00077   
<a name="l00078"></a><a class="code" href="class_u_p_n_p_control_thread.html#a39fbdaefb515dcffe17e9ed438e55c7d">00078</a>   QTime <a class="code" href="class_u_p_n_p_control_thread.html#a39fbdaefb515dcffe17e9ed438e55c7d">_upnpInitialized</a>; <span class="comment">/**&lt; Time at which the UPnP state was last set. */</span>
<a name="l00079"></a><a class="code" href="class_u_p_n_p_control_thread.html#a7cbbca00753124e024d94dc36817efcc">00079</a>   <span class="keywordtype">bool</span> <a class="code" href="class_u_p_n_p_control_thread.html#a7cbbca00753124e024d94dc36817efcc">_keepRunning</a>; <span class="comment">/**&lt; True if the control thread should keep running. */</span>
<a name="l00080"></a><a class="code" href="class_u_p_n_p_control_thread.html#a7744c692a5de456ad50ee5398596904f">00080</a>   <a class="code" href="class_u_p_n_p_control.html">UPNPControl</a> *<a class="code" href="class_u_p_n_p_control_thread.html#a7744c692a5de456ad50ee5398596904f">_control</a>; <span class="comment">/**&lt; Stores desired UPnP state. */</span>
<a name="l00081"></a><a class="code" href="class_u_p_n_p_control_thread.html#a8da604675c8f83bb128e99b1aa2bc01c">00081</a>   QWaitCondition *<a class="code" href="class_u_p_n_p_control_thread.html#a8da604675c8f83bb128e99b1aa2bc01c">_waitCondition</a>; <span class="comment">/**&lt; Used to wake up the control thread. */</span>
<a name="l00082"></a><a class="code" href="class_u_p_n_p_control_thread.html#a5fc252e710ed3fb0d3de063dbcb5db10">00082</a>   QMutex *<a class="code" href="class_u_p_n_p_control_thread.html#a5fc252e710ed3fb0d3de063dbcb5db10">_waitMutex</a>; <span class="comment">/**&lt; Mutex around shared variables. */</span>
<a name="l00083"></a><a class="code" href="class_u_p_n_p_control_thread.html#a0d64471e8e9215d1a615bfe19447f243">00083</a>   quint16 <a class="code" href="class_u_p_n_p_control_thread.html#a0d64471e8e9215d1a615bfe19447f243">_dirPort</a>; <span class="comment">/**&lt; Desired DirPort. */</span>
<a name="l00084"></a><a class="code" href="class_u_p_n_p_control_thread.html#a769087f3a8017571000cbedac9f60d83">00084</a>   quint16 <a class="code" href="class_u_p_n_p_control_thread.html#a769087f3a8017571000cbedac9f60d83">_orPort</a>; <span class="comment">/**&lt; Desired ORPort. */</span>
<a name="l00085"></a>00085 
<a name="l00086"></a>00086   <span class="comment">/* Used by miniupnpc library */</span>
<a name="l00087"></a><a class="code" href="class_u_p_n_p_control_thread.html#a56621e32dadda028eed5d3e3eb1d81fb">00087</a>   <span class="keyword">struct </span><a class="code" href="struct_u_p_n_p_urls.html">UPNPUrls</a> <a class="code" href="class_u_p_n_p_control_thread.html#a56621e32dadda028eed5d3e3eb1d81fb">urls</a>;
<a name="l00088"></a><a class="code" href="class_u_p_n_p_control_thread.html#a3a51955cb4f8ba06586189d7d73949d3">00088</a>   <span class="keyword">struct </span><a class="code" href="struct_i_g_ddatas.html">IGDdatas</a> <a class="code" href="class_u_p_n_p_control_thread.html#a3a51955cb4f8ba06586189d7d73949d3">data</a>;
<a name="l00089"></a><a class="code" href="class_u_p_n_p_control_thread.html#aba93cc78abe19f5b045784f1e8f28d66">00089</a>   <span class="keywordtype">char</span> <a class="code" href="class_u_p_n_p_control_thread.html#aba93cc78abe19f5b045784f1e8f28d66">lanaddr</a>[16];
<a name="l00090"></a>00090 };
<a name="l00091"></a>00091 <span class="preprocessor">#endif </span>
<a name="l00092"></a>00092 <span class="preprocessor"></span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:55 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>