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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
|
<!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: IdleScript 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>IdleScript Class Reference</h1>Implements calling of python script in regular intervals for user defined activity (e.g. sending faxes).
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="idlescript_8h-source.html">idlescript.h</a>></code>
<p>
<p>Inheritance diagram for IdleScript:
<p><center><img src="classIdleScript.png" usemap="#IdleScript_map" border="0" alt=""></center>
<map name="IdleScript_map">
<area href="classPythonScript.html" alt="PythonScript" shape="rect" coords="0,0,84,24">
</map>
<a href="classIdleScript-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="classIdleScript.html#a0">IdleScript</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="classCapi.html">Capi</a> *<a class="el" href="classIdleScript.html#r3">capi</a>, string <a class="el" href="classIdleScript.html#r1">idlescript</a>, int <a class="el" href="classIdleScript.html#r2">idlescript_interval</a>, PyThreadState *<a class="el" href="classIdleScript.html#r0">py_state</a>, 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 a 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="classIdleScript.html#a1">~IdleScript</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. Destruct object. <a href="#a1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a2">requestTerminate</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">terminate thread <a href="#a2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a3">activate</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">reactivate the script execution in the case it was deactivated by too much errors <a href="#a3"></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="classIdleScript.html#d0">run</a> (void) throw ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread body. Calls the python function idle(). <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>PyThreadState * </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r0">py_state</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">py_state of the main python interpreter used for <a class="el" href="classIdleScript.html#d0">run()</a>. <a href="#r0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>string </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r1">idlescript</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">name of the python script which is called at regular intervals <a href="#r1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r2">idlescript_interval</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">interval between subsequent executions of idle script <a href="#r2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="classCapi.html">Capi</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r3">capi</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">reference to <a class="el" href="classCapi.html">Capi</a> object <a href="#r3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r4">active</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">used to disable IdleScript in case of too much errors <a href="#r4"></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="classIdleScript.html#r5">thread_handle</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">handle for the created pthread thread <a href="#r5"></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="classIdleScript.html#n0">idlescript_exec_handler</a> (void *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread exec handler for IdleScript 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="classIdleScript.html#n1">idlescript_cleanup_handler</a> (void *)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread clean handler for IdleScript class. <a href="#n1"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Implements calling of python script in regular intervals for user defined activity (e.g. sending faxes).
<p>
Executes a given idle script at regular intervals thus giving the user the ability to do arbitrary things. The main use is surely initiating outgoing calls, e.g. to send faxes.<p>
It creates one new thread which will execute the idle script over and over...<p>
If the script fails too often, it's deactivated. After fixing the script, it can be reactivated with <a class="el" href="classIdleScript.html#a3">activate()</a>.<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="IdleScript::IdleScript" ></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"> IdleScript::IdleScript </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="classCapi.html">Capi</a> * </td>
<td class="mdname" nowrap> <em>capi</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>string </td>
<td class="mdname" nowrap> <em>idlescript</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>int </td>
<td class="mdname" nowrap> <em>idlescript_interval</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>PyThreadState * </td>
<td class="mdname" nowrap> <em>py_state</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 a 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>capi</em> </td><td>reference to <a class="el" href="classCapi.html">Capi</a> object </td></tr>
<tr><td></td><td valign=top><em>idlescript</em> </td><td>file name of the python script to use as incoming script </td></tr>
<tr><td></td><td valign=top><em>idlescript_interval</em> </td><td>interval between two subsequent calls to the idle script in seconds </td></tr>
<tr><td></td><td valign=top><em>py_state</em> </td><td>thread state of the main python interpreter which must be initialized an Py_SaveThread()'d before. </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="IdleScript::~IdleScript" ></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"> IdleScript::~<a class="el" href="classIdleScript.html">IdleScript</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.
<p>
</td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a3" doxytag="IdleScript::activate" ></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 IdleScript::activate </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></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
reactivate the script execution in the case it was deactivated by too much errors
<p>
</td>
</tr>
</table>
<a class="anchor" name="a2" doxytag="IdleScript::requestTerminate" ></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 IdleScript::requestTerminate </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></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
terminate thread
<p>
</td>
</tr>
</table>
<a class="anchor" name="d0" doxytag="IdleScript::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 IdleScript::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 idle().
<p>
The read Python idle script must provide a function named idle with the following signature:<p>
def idle(capi): # function body<p>
The parameters given to the python function are:<ul>
<li>capi: reference to the capi providing the interface to the ISDN hardware (meeded for the call_*() function class)</li></ul>
<p>
The script is responsible for clearing each call it initiates, even in the exception handlers!<p>
If the call is disconnected by the other party, the Python exception CallGoneError is raised and should be caught by the script (don't forget to call disconnect() there).<p>
If the script produces too much errors in a row, it will be deactivated. Use <a class="el" href="classIdleScript.html#a3">activate()</a> to re-enable.<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="IdleScript::idlescript_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 idlescript_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 IdleScript 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="IdleScript::idlescript_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* idlescript_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 IdleScript class.
<p>
This is a handler which will call this-><a class="el" href="classIdleScript.html#d0">run()</a> for the use in pthread_create(). It will also register idlescript_cleanup_handler </td>
</tr>
</table>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="r4" doxytag="IdleScript::active" ></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"> bool <a class="el" href="classIdleScript.html#r4">IdleScript::active</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
used to disable IdleScript in case of too much errors
<p>
</td>
</tr>
</table>
<a class="anchor" name="r3" doxytag="IdleScript::capi" ></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="classCapi.html">Capi</a>* <a class="el" href="classIdleScript.html#r3">IdleScript::capi</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
reference to <a class="el" href="classCapi.html">Capi</a> object
<p>
</td>
</tr>
</table>
<a class="anchor" name="r1" doxytag="IdleScript::idlescript" ></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"> string <a class="el" href="classIdleScript.html#r1">IdleScript::idlescript</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
name of the python script which is called at regular intervals
<p>
</td>
</tr>
</table>
<a class="anchor" name="r2" doxytag="IdleScript::idlescript_interval" ></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"> int <a class="el" href="classIdleScript.html#r2">IdleScript::idlescript_interval</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
interval between subsequent executions of idle script
<p>
</td>
</tr>
</table>
<a class="anchor" name="r0" doxytag="IdleScript::py_state" ></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"> PyThreadState* <a class="el" href="classIdleScript.html#r0">IdleScript::py_state</a><code> [private]</code> </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
py_state of the main python interpreter used for <a class="el" href="classIdleScript.html#d0">run()</a>.
<p>
</td>
</tr>
</table>
<a class="anchor" name="r5" doxytag="IdleScript::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="classIdleScript.html#r5">IdleScript::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="idlescript_8h-source.html">idlescript.h</a><li>idlescript.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>
|