<!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>