1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>CapiSuite: IncomingScript Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div>
<h1>IncomingScript Class Reference</h1>Incoming call handling. One object for each incoming call is created.
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="incomingscript_8h-source.html">incomingscript.h</a>></code>
<p>
<p>Inheritance diagram for IncomingScript:
<p><center><img src="classIncomingScript.png" usemap="#IncomingScript_map" border="0" alt=""></center>
<map name="IncomingScript_map">
<area href="classPythonScript.html" alt="PythonScript" shape="rect" coords="0,0,95,24">
</map>
<a href="classIncomingScript-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#a0">IncomingScript</a> (ostream &<a class="el" href="classPythonScript.html#p3">debug</a>, unsigned short <a class="el" href="classPythonScript.html#p5">debug_level</a>, ostream &<a class="el" href="classPythonScript.html#p4">error</a>, <a class="el" href="classConnection.html">Connection</a> *<a class="el" href="classIncomingScript.html#r0">conn</a>, string incoming_script, PycStringIO_CAPI *<a class="el" href="classPythonScript.html#p6">cStringIO</a>) throw (ApplicationError)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. Create Object and start detached thread. <a href="#a0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#a1">~IncomingScript</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. Destruct object and assure the call is disconnected. <a href="#a1"></a><br></td></tr>
<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#d0">run</a> (void) throw ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread body. Calls the python function callIncoming() which will handle the call. <a href="#d0"></a><br></td></tr>
<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="classConnection.html">Connection</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#r0">conn</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">reference to according connection object <a href="#r0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>pthread_t </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#r1">thread_handle</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">handle for the created pthread thread <a href="#r1"></a><br></td></tr>
<tr><td colspan=2><br><h2>Friends</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void * </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#n0">incomingscript_exec_handler</a> (void *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread exec handler for IncomingScript class. <a href="#n0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="classIncomingScript.html#n1">incomingscript_cleanup_handler</a> (void *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread clean handler for IncomingScript class. <a href="#n1"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Incoming call handling. One object for each incoming call is created.
<p>
IncomingScript handels an incoming connection. For each connection, one object of it is created by FlowControl. It mainly creates a new thread with an own python subinterpreter, initializes the capisuitemodule, and calls <a class="el" href="classIncomingScript.html#d0">run()</a> of <a class="el" href="classPythonScript.html">PythonScript</a> which will execute the defined function in the script.<p>
<dl compact><dt><b>Author:</b></dt><dd>Gernot Hillier </dd></dl>
<p>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="a0" doxytag="IncomingScript::IncomingScript" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> IncomingScript::IncomingScript </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">ostream & </td>
<td class="mdname" nowrap> <em>debug</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>unsigned short </td>
<td class="mdname" nowrap> <em>debug_level</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>ostream & </td>
<td class="mdname" nowrap> <em>error</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap><a class="el" href="classConnection.html">Connection</a> * </td>
<td class="mdname" nowrap> <em>conn</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>string </td>
<td class="mdname" nowrap> <em>incoming_script</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>PycStringIO_CAPI * </td>
<td class="mdname" nowrap> <em>cStringIO</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"> throw (<a class="el" href="classApplicationError.html">ApplicationError</a>)</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Constructor. Create Object and start detached thread.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>debug</em> </td><td>stream for debugging info </td></tr>
<tr><td></td><td valign=top><em>debug_level</em> </td><td>verbosity level for debug messages </td></tr>
<tr><td></td><td valign=top><em>error</em> </td><td>stream for error messages </td></tr>
<tr><td></td><td valign=top><em>conn</em> </td><td>reference to according connection (disconnected if error occurs) </td></tr>
<tr><td></td><td valign=top><em>incoming_script</em> </td><td>file name of the python script to use as incoming script </td></tr>
<tr><td></td><td valign=top><em>cStringIO</em> </td><td>pointer to the Python cStringIO C API </td></tr>
</table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign=top><em>ApplicationError</em> </td><td>Thrown if thread can't be started</td></tr>
</table>
</dl>
</td>
</tr>
</table>
<a class="anchor" name="a1" doxytag="IncomingScript::~IncomingScript" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> IncomingScript::~<a class="el" href="classIncomingScript.html">IncomingScript</a> </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Destructor. Destruct object and assure the call is disconnected.
<p>
</td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="d0" doxytag="IncomingScript::run" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void IncomingScript::run </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap> throw ()<code> [private, virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Thread body. Calls the python function callIncoming() which will handle the call.
<p>
Create python sub-interpreter, read script for incoming calls,<p>
The read Python script for incoming calls must provide a function named callIncoming with the following signature:<p>
def callIncoming(call, service, callingParty, calledParty): # function body<p>
The parameters given to the python function are:<ul>
<li>call: reference to the incoming call. Must be given to all capisuite-provided python functions as first parameter.</li><li>service (integer): service as signalled by ISDN, set to one of the SERVICE_* constants defined in capisuitemodule_init</li><li>callingParty (string): the number of the calling party (source of the call)</li><li>calledParty (string): the number of the called party (destination of the call)</li></ul>
<p>
At the moment callIncoming() is called, the call is waiting for an answer, so the first thing the script must do is to call connect_*() or reject(). It must also disconnect the call in any case (even in the exception handlers!) before finishing using disconnect().<p>
If the call is disconnected by the other party, the Python exception CallGoneError is raised and should be caught by the script (but even there you must call disconnect()).<p>
The python global lock will be acquired while the function runs.
<p>
Reimplemented from <a class="el" href="classPythonScript.html#b0">PythonScript</a>.
<p>
</td>
</tr>
</table>
<hr><h2>Friends And Related Function Documentation</h2>
<a class="anchor" name="n1" doxytag="IncomingScript::incomingscript_cleanup_handler" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void incomingscript_cleanup_handler </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void * </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [friend]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Thread clean handler for IncomingScript class.
<p>
This is a handler which is called by pthreads at cleanup. It will call this-><a class="el" href="classPythonScript.html#b1">final()</a>. </td>
</tr>
</table>
<a class="anchor" name="n0" doxytag="IncomingScript::incomingscript_exec_handler" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void* incomingscript_exec_handler </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void * </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [friend]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Thread exec handler for IncomingScript class.
<p>
This is a handler which will call this-><a class="el" href="classIncomingScript.html#d0">run()</a> for the use in pthread_create(). It will also register incomingscript_cleanup_handler </td>
</tr>
</table>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="r0" doxytag="IncomingScript::conn" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="classConnection.html">Connection</a>* <a class="el" href="classIncomingScript.html#r0">IncomingScript::conn</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
reference to according connection object
<p>
</td>
</tr>
</table>
<a class="anchor" name="r1" doxytag="IncomingScript::thread_handle" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> pthread_t <a class="el" href="classIncomingScript.html#r1">IncomingScript::thread_handle</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
handle for the created pthread thread
<p>
</td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="incomingscript_8h-source.html">incomingscript.h</a><li>incomingscript.cpp</ul>
<hr size="1"><address style="align: right;"><small>Generated on Sun Nov 28 14:37:45 2004 for CapiSuite by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|