Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 06e1e0ab98898582c876a8be34ecb5e9 > files > 243

capisuite-0.4.5-5mdv2010.0.i586.rpm

<!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&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;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 &lt;<a class="el" href="idlescript_8h-source.html">idlescript.h</a>&gt;</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>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a0">IdleScript</a> (ostream &amp;<a class="el" href="classPythonScript.html#p3">debug</a>, unsigned short <a class="el" href="classPythonScript.html#p5">debug_level</a>, ostream &amp;<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">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a1">~IdleScript</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructor. Destruct object.  <a href="#a1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a2">requestTerminate</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">terminate thread  <a href="#a2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#a3">activate</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#d0">run</a> (void)  throw ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</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 *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r0">py_state</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r1">idlescript</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r2">idlescript_interval</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r3">capi</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r4">active</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#r5">thread_handle</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</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 *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#n0">idlescript_exec_handler</a> (void *)</td></tr>

<tr><td class="mdescLeft">&nbsp;</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&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classIdleScript.html#n1">idlescript_cleanup_handler</a> (void *)</td></tr>

<tr><td class="mdescLeft">&nbsp;</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 &amp; 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">(&nbsp;</td>
          <td class="md" nowrap valign="top">ostream &amp;&nbsp;</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&nbsp;</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 &amp;&nbsp;</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> *&nbsp;</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&nbsp;</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&nbsp;</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 *&nbsp;</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 *&nbsp;</td>
          <td class="mdname" nowrap> <em>cStringIO</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</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>
      &nbsp;
    </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>&nbsp;</td><td>stream for debugging info </td></tr>
    <tr><td></td><td valign=top><em>debug_level</em>&nbsp;</td><td>verbosity level for debug messages </td></tr>
    <tr><td></td><td valign=top><em>error</em>&nbsp;</td><td>stream for error messages </td></tr>
    <tr><td></td><td valign=top><em>capi</em>&nbsp;</td><td>reference to <a class="el" href="classCapi.html">Capi</a> object </td></tr>
    <tr><td></td><td valign=top><em>idlescript</em>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </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">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </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">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </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">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</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>
      &nbsp;
    </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">(&nbsp;</td>
          <td class="md" nowrap valign="top">void *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [friend]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </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-&gt;<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">(&nbsp;</td>
          <td class="md" nowrap valign="top">void *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [friend]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Thread exec handler for IdleScript class. 
<p>
This is a handler which will call this-&gt;<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>
      &nbsp;
    </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>
      &nbsp;
    </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>
      &nbsp;
    </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>
      &nbsp;
    </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>
      &nbsp;
    </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>
      &nbsp;
    </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>