mirror of https://github.com/sipwise/sems.git
- py_sems is aimed at integrating as much functionnalities from the core as possible into python driven applications (not necessarily IVRs), in a more easy way. The classes can then just be used as in C++. - this plug-in uses the sip4 package included in debian. Please refer to http://www.riverbankcomputing.co.uk/sip/ for more informations on the binding generator. Please note that you do not need it, if you just want to compile SEMS. You will need it first if you want to generate more classes. git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@220 8eb893ce-cfd4-0310-b710-fb5ebe64c474sayer/1.4-spce2.6
parent
981487f4f5
commit
e97f7c8067
@ -0,0 +1,598 @@
|
||||
/*
|
||||
* $Id: Ivr.cpp,v 1.26.2.1 2005/09/02 13:47:46 rco Exp $
|
||||
* Copyright (C) 2002-2003 Fhg Fokus
|
||||
*
|
||||
* This file is part of sems, a free SIP media server.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#include "IvrDialogBase.h"
|
||||
//#include "IvrSipDialog.h"
|
||||
#include "IvrAudio.h"
|
||||
#include "Ivr.h"
|
||||
|
||||
#include "AmConfigReader.h"
|
||||
#include "AmConfig.h"
|
||||
#include "log.h"
|
||||
#include "AmApi.h"
|
||||
#include "AmUtils.h"
|
||||
#include "AmSessionScheduler.h"
|
||||
//#include "AmSessionTimer.h"
|
||||
#include "AmPlugIn.h"
|
||||
|
||||
#include "sip/sipAPIpy_ivr.h"
|
||||
#include "sip/sippy_ivrIvrDialog.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <regex.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <set>
|
||||
using std::set;
|
||||
|
||||
|
||||
#define PYFILE_REGEX "(.+)\\.(py|pyc|pyo)$"
|
||||
|
||||
|
||||
EXPORT_SESSION_FACTORY(IvrFactory,MOD_NAME);
|
||||
|
||||
PyMODINIT_FUNC initpy_ivr();
|
||||
|
||||
struct PythonGIL
|
||||
{
|
||||
PyGILState_STATE gst;
|
||||
|
||||
PythonGIL() { gst = PyGILState_Ensure(); }
|
||||
~PythonGIL(){ PyGILState_Release(gst); }
|
||||
};
|
||||
|
||||
|
||||
// This must be the first declaration of every
|
||||
// function using Python C-API.
|
||||
// But this is not necessary in function which
|
||||
// will get called from Python
|
||||
#define PYLOCK PythonGIL _py_gil
|
||||
|
||||
extern "C" {
|
||||
|
||||
static PyObject* ivr_log(PyObject*, PyObject* args)
|
||||
{
|
||||
int level;
|
||||
char *msg;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"is",&level,&msg))
|
||||
return NULL;
|
||||
|
||||
if((level)<=log_level) {
|
||||
|
||||
//if(level == L_ERR)
|
||||
//assert(0);
|
||||
|
||||
if(log_stderr)
|
||||
log_print( level, msg );
|
||||
else {
|
||||
switch(level){
|
||||
case L_ERR:
|
||||
syslog(LOG_ERR | L_FAC, "Error: %s", msg);
|
||||
break;
|
||||
case L_WARN:
|
||||
syslog(LOG_WARNING | L_FAC, "Warning: %s", msg);
|
||||
break;
|
||||
case L_INFO:
|
||||
syslog(LOG_INFO | L_FAC, "Info: %s", msg);
|
||||
break;
|
||||
case L_DBG:
|
||||
syslog(LOG_DEBUG | L_FAC, "Debug: %s", msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* ivr_getHeader(PyObject*, PyObject* args)
|
||||
{
|
||||
char* headers;
|
||||
char* header_name;
|
||||
if(!PyArg_ParseTuple(args,"ss",&headers,&header_name))
|
||||
return NULL;
|
||||
|
||||
string res = getHeader(headers,header_name);
|
||||
return PyString_FromString(res.c_str());
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef ivr_methods[] = {
|
||||
{"log", (PyCFunction)ivr_log, METH_VARARGS,"Log a message using Sems' logging system"},
|
||||
{"getHeader", (PyCFunction)ivr_getHeader, METH_VARARGS,"Python getHeader wrapper"},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
}
|
||||
|
||||
IvrFactory::IvrFactory(const string& _app_name)
|
||||
: AmSessionFactory(_app_name),
|
||||
user_timer_fact(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void IvrFactory::setScriptPath(const string& path)
|
||||
{
|
||||
string python_path = script_path = path;
|
||||
|
||||
|
||||
if(python_path.length()){
|
||||
|
||||
python_path = AmConfig::PlugInPath + ":" + python_path;
|
||||
}
|
||||
else
|
||||
python_path = AmConfig::PlugInPath;
|
||||
|
||||
char* old_path=0;
|
||||
if((old_path = getenv("PYTHONPATH")) != 0)
|
||||
if(strlen(old_path))
|
||||
python_path += ":" + string(old_path);
|
||||
|
||||
DBG("setting PYTHONPATH to: '%s'\n",python_path.c_str());
|
||||
setenv("PYTHONPATH",python_path.c_str(),1);
|
||||
|
||||
}
|
||||
|
||||
void IvrFactory::import_object(PyObject* m, char* name, PyTypeObject* type)
|
||||
{
|
||||
if (PyType_Ready(type) < 0){
|
||||
ERROR("PyType_Ready failed !\n");
|
||||
return;
|
||||
}
|
||||
Py_INCREF(type);
|
||||
PyModule_AddObject(m, name, (PyObject *)type);
|
||||
}
|
||||
|
||||
void IvrFactory::import_ivr_builtins()
|
||||
{
|
||||
// ivr module - start
|
||||
PyImport_AddModule("ivr");
|
||||
ivr_module = Py_InitModule("ivr",ivr_methods);
|
||||
|
||||
// IvrSipDialog (= AmSipDialog)
|
||||
//import_object(ivr_module, "IvrSipDialog", &IvrSipDialogType);
|
||||
|
||||
// IvrDialogBase
|
||||
//import_object(ivr_module,"IvrDialogBase",&IvrDialogBaseType);
|
||||
|
||||
|
||||
// IvrAudioFile
|
||||
import_object(ivr_module,"IvrAudioFile",&IvrAudioFileType);
|
||||
|
||||
PyModule_AddIntConstant(ivr_module, "AUDIO_READ",AUDIO_READ);
|
||||
PyModule_AddIntConstant(ivr_module, "AUDIO_WRITE",AUDIO_WRITE);
|
||||
// ivr module - end
|
||||
|
||||
// add log level for the log module
|
||||
PyModule_AddIntConstant(ivr_module, "SEMS_LOG_LEVEL",log_level);
|
||||
|
||||
import_module("log");
|
||||
initpy_ivr();
|
||||
}
|
||||
|
||||
void IvrFactory::import_module(const char* modname)
|
||||
{
|
||||
PyObject* py_mod_name = PyString_FromString(modname);
|
||||
PyObject* py_mod = PyImport_Import(py_mod_name);
|
||||
Py_DECREF(py_mod_name);
|
||||
|
||||
if(!py_mod){
|
||||
PyErr_Print();
|
||||
ERROR("IvrFactory: could not find python module '%s'.\n",modname);
|
||||
ERROR("IvrFactory: please check your installation.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void IvrFactory::init_python_interpreter()
|
||||
{
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
import_ivr_builtins();
|
||||
PyEval_ReleaseLock();
|
||||
}
|
||||
|
||||
IvrDialog* IvrFactory::newDlg(const string& name)
|
||||
{
|
||||
PYLOCK;
|
||||
|
||||
map<string,IvrScriptDesc>::iterator mod_it = mod_reg.find(name);
|
||||
if(mod_it == mod_reg.end()){
|
||||
ERROR("Unknown script name '%s'\n", name.c_str());
|
||||
throw AmSession::Exception(500,"Unknown Application");
|
||||
}
|
||||
|
||||
IvrScriptDesc& mod_desc = mod_it->second;
|
||||
|
||||
AmDynInvoke* user_timer = user_timer_fact->getInstance();
|
||||
if(!user_timer){
|
||||
ERROR("could not get a user timer reference\n");
|
||||
throw AmSession::Exception(500,"could not get a user timer reference");
|
||||
}
|
||||
|
||||
PyObject* dlg_inst = PyObject_Call(mod_desc.dlg_class,PyTuple_New(0),NULL);
|
||||
if(!dlg_inst){
|
||||
|
||||
PyErr_Print();
|
||||
ERROR("IvrFactory: while loading \"%s\": could not create instance\n",
|
||||
name.c_str());
|
||||
throw AmSession::Exception(500,"Internal error in IVR plug-in.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int err=0;
|
||||
IvrDialog* dlg = (IvrDialog*)sipForceConvertTo_IvrDialog(dlg_inst,&err);
|
||||
if(!dlg || err){
|
||||
|
||||
PyErr_Print();
|
||||
ERROR("IvrFactory: while loading \"%s\": could not retrieve IvrDialog ptr.\n",
|
||||
name.c_str());
|
||||
throw AmSession::Exception(500,"Internal error in IVR plug-in.");
|
||||
Py_DECREF(dlg_inst);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// take the ownership over dlg
|
||||
sipTransfer(dlg_inst,1);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
bool IvrFactory::loadScript(const string& path)
|
||||
{
|
||||
PYLOCK;
|
||||
|
||||
PyObject *modName,*mod,*dict, *dlg_class, *config=NULL;
|
||||
|
||||
modName = PyString_FromString(path.c_str());
|
||||
mod = PyImport_Import(modName);
|
||||
|
||||
AmConfigReader cfg;
|
||||
string cfg_file = add2path(AmConfig::ModConfigPath,1,(path + ".conf").c_str());
|
||||
|
||||
Py_DECREF(modName);
|
||||
|
||||
if(!mod){
|
||||
PyErr_Print();
|
||||
WARN("IvrFactory: Failed to load \"%s\"\n", path.c_str());
|
||||
|
||||
dict = PyImport_GetModuleDict();
|
||||
Py_INCREF(dict);
|
||||
PyDict_DelItemString(dict,path.c_str());
|
||||
Py_DECREF(dict);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
dict = PyModule_GetDict(mod);
|
||||
dlg_class = PyDict_GetItemString(dict, "IvrScript");
|
||||
|
||||
if(!dlg_class){
|
||||
|
||||
PyErr_Print();
|
||||
WARN("IvrFactory: class IvrDialog not found in \"%s\"\n", path.c_str());
|
||||
goto error1;
|
||||
}
|
||||
|
||||
Py_INCREF(dlg_class);
|
||||
|
||||
if(!PyObject_IsSubclass(dlg_class,(PyObject *)sipClass_IvrDialog)){
|
||||
|
||||
WARN("IvrFactory: in \"%s\": IvrScript is not a "
|
||||
"subtype of IvrDialog\n", path.c_str());
|
||||
|
||||
goto error2;
|
||||
}
|
||||
|
||||
if(cfg.loadFile(cfg_file)){
|
||||
ERROR("could not load config file at %s\n",cfg_file.c_str());
|
||||
goto error2;
|
||||
}
|
||||
|
||||
config = PyDict_New();
|
||||
if(!config){
|
||||
ERROR("could not allocate new dict for config\n");
|
||||
goto error2;
|
||||
}
|
||||
|
||||
for(map<string,string>::const_iterator it = cfg.begin();
|
||||
it != cfg.end(); it++){
|
||||
|
||||
PyDict_SetItem(config,
|
||||
PyString_FromString(it->first.c_str()),
|
||||
PyString_FromString(it->second.c_str()));
|
||||
}
|
||||
|
||||
PyObject_SetAttrString(mod,"config",config);
|
||||
|
||||
mod_reg.insert(make_pair(path,
|
||||
IvrScriptDesc(mod,dlg_class)));
|
||||
|
||||
return true;
|
||||
|
||||
error2:
|
||||
Py_DECREF(dlg_class);
|
||||
error1:
|
||||
Py_DECREF(mod);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads python script path and default script file from configuration file
|
||||
*/
|
||||
int IvrFactory::onLoad()
|
||||
{
|
||||
user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
|
||||
if(!user_timer_fact){
|
||||
|
||||
ERROR("could not load user_timer from session_timer plug-in\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
AmConfigReader cfg;
|
||||
|
||||
if(cfg.loadFile(add2path(AmConfig::ModConfigPath,1,MOD_NAME ".conf")))
|
||||
return -1;
|
||||
|
||||
// get application specific global parameters
|
||||
configureModule(cfg);
|
||||
|
||||
setScriptPath(cfg.getParameter("script_path"));
|
||||
init_python_interpreter();
|
||||
|
||||
DBG("** IVR compile time configuration:\n");
|
||||
DBG("** built with PYTHON support.\n");
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
DBG("** Text-To-Speech enabled\n");
|
||||
#else
|
||||
DBG("** Text-To-Speech disabled\n");
|
||||
#endif
|
||||
|
||||
DBG("** IVR run time configuration:\n");
|
||||
DBG("** script path: \'%s\'\n", script_path.c_str());
|
||||
|
||||
regex_t reg;
|
||||
if(regcomp(®,PYFILE_REGEX,REG_EXTENDED)){
|
||||
ERROR("while compiling regular expression\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIR* dir = opendir(script_path.c_str());
|
||||
if(!dir){
|
||||
regfree(®);
|
||||
ERROR("Ivr: script pre-loader (%s): %s\n",
|
||||
script_path.c_str(),strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
DBG("directory '%s' opened\n",script_path.c_str());
|
||||
|
||||
set<string> unique_entries;
|
||||
regmatch_t pmatch[2];
|
||||
|
||||
struct dirent* entry=0;
|
||||
while((entry = readdir(dir)) != NULL){
|
||||
|
||||
if(!regexec(®,entry->d_name,2,pmatch,0)){
|
||||
|
||||
string name(entry->d_name + pmatch[1].rm_so,
|
||||
pmatch[1].rm_eo - pmatch[1].rm_so);
|
||||
|
||||
unique_entries.insert(name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
regfree(®);
|
||||
|
||||
AmPlugIn* plugin = AmPlugIn::instance();
|
||||
for(set<string>::iterator it = unique_entries.begin();
|
||||
it != unique_entries.end(); it++) {
|
||||
|
||||
if(loadScript(*it)){
|
||||
bool res = plugin->registerFactory4App(*it,this);
|
||||
if(res)
|
||||
INFO("Application script registered: %s.\n",
|
||||
it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // don't stop sems from starting up
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a script using user name from URI.
|
||||
* Note: there is no default script.
|
||||
*/
|
||||
AmSession* IvrFactory::onInvite(const AmSipRequest& req)
|
||||
{
|
||||
if(req.cmd != MOD_NAME)
|
||||
return newDlg(req.cmd);
|
||||
else
|
||||
return newDlg(req.user);
|
||||
}
|
||||
|
||||
IvrDialog::IvrDialog()
|
||||
: py_mod(NULL),
|
||||
py_dlg(NULL),
|
||||
playlist(this),
|
||||
user_timer(NULL)
|
||||
{
|
||||
sip_relay_only = false;
|
||||
}
|
||||
|
||||
IvrDialog::IvrDialog(AmDynInvoke* user_timer)
|
||||
: py_mod(NULL),
|
||||
py_dlg(NULL),
|
||||
playlist(this),
|
||||
user_timer(user_timer)
|
||||
{
|
||||
sip_relay_only = false;
|
||||
}
|
||||
|
||||
IvrDialog::~IvrDialog()
|
||||
{
|
||||
DBG("IvrDialog::~IvrDialog()\n");
|
||||
|
||||
PYLOCK;
|
||||
Py_XDECREF(py_mod);
|
||||
Py_XDECREF(py_dlg);
|
||||
}
|
||||
|
||||
void IvrDialog::setPyPtrs(PyObject *mod, PyObject *dlg)
|
||||
{
|
||||
assert(py_mod = mod);
|
||||
assert(py_dlg = dlg);
|
||||
Py_INCREF(py_mod);
|
||||
Py_INCREF(py_dlg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
type_error(const char *msg)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
null_error(void)
|
||||
{
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"null argument to internal routine");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyObject_VaCallMethod(PyObject *o, char *name, char *format, va_list va)
|
||||
{
|
||||
PyObject *args, *func = 0, *retval;
|
||||
|
||||
if (o == NULL || name == NULL)
|
||||
return null_error();
|
||||
|
||||
func = PyObject_GetAttrString(o, name);
|
||||
if (func == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func))
|
||||
return type_error("call of non-callable attribute");
|
||||
|
||||
if (format && *format) {
|
||||
args = Py_VaBuildValue(format, va);
|
||||
}
|
||||
else
|
||||
args = PyTuple_New(0);
|
||||
|
||||
if (!args)
|
||||
return NULL;
|
||||
|
||||
if (!PyTuple_Check(args)) {
|
||||
PyObject *a;
|
||||
|
||||
a = PyTuple_New(1);
|
||||
if (a == NULL)
|
||||
return NULL;
|
||||
if (PyTuple_SetItem(a, 0, args) < 0)
|
||||
return NULL;
|
||||
args = a;
|
||||
}
|
||||
|
||||
retval = PyObject_Call(func, args, NULL);
|
||||
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(func);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool IvrDialog::callPyEventHandler(char* name, char* fmt, ...)
|
||||
{
|
||||
bool ret=false;
|
||||
va_list va;
|
||||
|
||||
PYLOCK;
|
||||
|
||||
va_start(va, fmt);
|
||||
PyObject* o = PyObject_VaCallMethod(py_dlg,name,fmt,va);
|
||||
va_end(va);
|
||||
|
||||
if(!o) {
|
||||
|
||||
if(PyErr_ExceptionMatches(PyExc_AttributeError)){
|
||||
|
||||
DBG("method %s is not implemented, trying default one\n",name);
|
||||
return true;
|
||||
}
|
||||
|
||||
PyErr_Print();
|
||||
}
|
||||
else {
|
||||
if(o && PyBool_Check(o) && (o == Py_True)) {
|
||||
|
||||
ret = true;
|
||||
}
|
||||
|
||||
Py_DECREF(o);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void IvrDialog::onSessionStart(const AmSipRequest& req)
|
||||
{
|
||||
DBG("IvrDialog::onSessionStart\n");
|
||||
setInOut(&playlist,&playlist);
|
||||
AmB2BCallerSession::onSessionStart(req);
|
||||
}
|
||||
|
||||
void IvrDialog::process(AmEvent* event)
|
||||
{
|
||||
DBG("IvrDialog::process\n");
|
||||
|
||||
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
|
||||
if(audio_event && audio_event->event_id == AmAudioEvent::noAudio){
|
||||
|
||||
callPyEventHandler("onEmptyQueue", NULL);
|
||||
event->processed = true;
|
||||
}
|
||||
|
||||
AmPluginEvent* plugin_event = dynamic_cast<AmPluginEvent*>(event);
|
||||
if(plugin_event && plugin_event->name == "timer_timeout") {
|
||||
|
||||
callPyEventHandler("onTimer", "i", plugin_event->data.get(0).asInt());
|
||||
event->processed = true;
|
||||
}
|
||||
|
||||
if (!event->processed)
|
||||
AmB2BCallerSession::process(event);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* $Id: Ivr.h,v 1.15.2.1 2005/09/02 13:47:46 rco Exp $
|
||||
* Copyright (C) 2002-2003 Fhg Fokus
|
||||
*
|
||||
* This file is part of sems, a free SIP media server.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _IVR_H_
|
||||
#define _IVR_H_
|
||||
|
||||
#define MOD_NAME "ivr"
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "AmB2BSession.h"
|
||||
#include "AmPlaylist.h"
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
#include "flite.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
class IvrDialog;
|
||||
|
||||
struct IvrScriptDesc
|
||||
{
|
||||
PyObject* mod;
|
||||
PyObject* dlg_class;
|
||||
|
||||
IvrScriptDesc()
|
||||
: mod(0),
|
||||
dlg_class(0)
|
||||
{}
|
||||
|
||||
IvrScriptDesc(const IvrScriptDesc& d)
|
||||
: mod(d.mod),
|
||||
dlg_class(d.dlg_class)
|
||||
{}
|
||||
|
||||
IvrScriptDesc(PyObject* mod,
|
||||
PyObject* dlg_class)
|
||||
: mod(mod),
|
||||
dlg_class(dlg_class)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
class IvrFactory: public AmSessionFactory
|
||||
{
|
||||
PyObject* ivr_module;
|
||||
string script_path;
|
||||
string default_script;
|
||||
|
||||
map<string,IvrScriptDesc> mod_reg;
|
||||
|
||||
AmDynInvokeFactory* user_timer_fact;
|
||||
|
||||
void init_python_interpreter();
|
||||
void import_ivr_builtins();
|
||||
|
||||
void import_module(const char* modname);
|
||||
void import_object(PyObject* m,
|
||||
char* name,
|
||||
PyTypeObject* type);
|
||||
|
||||
/** @return true if everything ok */
|
||||
bool loadScript(const string& path);
|
||||
|
||||
void setScriptPath(const string& path);
|
||||
bool checkCfg();
|
||||
|
||||
IvrDialog* newDlg(const string& name);
|
||||
|
||||
public:
|
||||
IvrFactory(const string& _app_name);
|
||||
|
||||
int onLoad();
|
||||
AmSession* onInvite(const AmSipRequest& req);
|
||||
};
|
||||
|
||||
|
||||
class IvrDialog : public AmB2BCallerSession
|
||||
{
|
||||
PyObject *py_mod;
|
||||
PyObject *py_dlg;
|
||||
|
||||
bool callPyEventHandler(char* name, char* fmt, ...);
|
||||
|
||||
void process(AmEvent* event);
|
||||
|
||||
public:
|
||||
AmDynInvoke* user_timer;
|
||||
AmPlaylist playlist;
|
||||
|
||||
IvrDialog();
|
||||
IvrDialog(AmDynInvoke* user_timer);
|
||||
~IvrDialog();
|
||||
|
||||
// must be called before everything else.
|
||||
void setPyPtrs(PyObject *mod, PyObject *dlg);
|
||||
|
||||
void onSessionStart(const AmSipRequest& req);
|
||||
/* void onBye(const AmSipRequest& req); */
|
||||
/* void onDtmf(int event, int duration_msec); */
|
||||
|
||||
/* void onOtherBye(const AmSipRequest& req); */
|
||||
/* void onOtherReply(const AmSipReply& r); */
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,321 @@
|
||||
#include "IvrAudio.h"
|
||||
#include "AmAudio.h"
|
||||
#include "AmSession.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
|
||||
#define TTS_CACHE_PATH "/tmp/"
|
||||
extern "C" cst_voice *register_cmu_us_kal();
|
||||
|
||||
#endif //ivr_with_tts
|
||||
|
||||
|
||||
static PyObject* IvrAudioFile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
DBG("---------- IvrAudioFile_alloc -----------\n");
|
||||
IvrAudioFile *self;
|
||||
|
||||
self = (IvrAudioFile *)type->tp_alloc(type, 0);
|
||||
|
||||
if (self != NULL) {
|
||||
|
||||
self->af = new AmAudioFile();
|
||||
if(!self->af){
|
||||
Py_DECREF(self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
flite_init();
|
||||
self->tts_voice = register_cmu_us_kal();
|
||||
self->filename = new string();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static void IvrAudioFile_dealloc(IvrAudioFile* self)
|
||||
{
|
||||
DBG("---------- IvrAudioFile_dealloc -----------\n");
|
||||
delete self->af;
|
||||
self->af = NULL;
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
if(self->del_file && !self->filename->empty())
|
||||
unlink(self->filename->c_str());
|
||||
delete self->filename;
|
||||
#endif
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_open(IvrAudioFile* self, PyObject* args)
|
||||
{
|
||||
int ivr_open_mode;
|
||||
char* filename;
|
||||
bool is_tmp;
|
||||
PyObject* py_is_tmp = NULL;
|
||||
AmAudioFile::OpenMode open_mode;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"si|O",&filename,&ivr_open_mode,&py_is_tmp))
|
||||
return NULL;
|
||||
|
||||
switch(ivr_open_mode){
|
||||
case AUDIO_READ:
|
||||
open_mode = AmAudioFile::Read;
|
||||
break;
|
||||
case AUDIO_WRITE:
|
||||
open_mode = AmAudioFile::Write;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,"Unknown open mode");
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if((py_is_tmp == NULL) || (py_is_tmp == Py_False))
|
||||
is_tmp = false;
|
||||
else if(py_is_tmp == Py_True)
|
||||
is_tmp = true;
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,"third parameter should be of type PyBool");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->af->open(filename,open_mode,is_tmp)){
|
||||
PyErr_SetString(PyExc_IOError,"Could not open file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_fpopen(IvrAudioFile* self, PyObject* args)
|
||||
{
|
||||
int ivr_open_mode;
|
||||
char* filename;
|
||||
PyObject* py_file = NULL;
|
||||
AmAudioFile::OpenMode open_mode;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"siO",&filename,&ivr_open_mode,&py_file))
|
||||
return NULL;
|
||||
|
||||
switch(ivr_open_mode){
|
||||
case AUDIO_READ:
|
||||
open_mode = AmAudioFile::Read;
|
||||
break;
|
||||
case AUDIO_WRITE:
|
||||
open_mode = AmAudioFile::Write;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,"Unknown open mode");
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
FILE* fp = PyFile_AsFile(py_file);
|
||||
if(!fp){
|
||||
PyErr_SetString(PyExc_IOError,"Could not get FILE pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->af->fpopen(filename,open_mode,fp)){
|
||||
PyErr_SetString(PyExc_IOError,"Could not open file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_rewind(IvrAudioFile* self, PyObject* args)
|
||||
{
|
||||
self->af->rewind();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
static PyObject* IvrAudioFile_tts(PyObject* cls, PyObject* args)
|
||||
{
|
||||
char* text;
|
||||
if(!PyArg_ParseTuple(args,"s",&text))
|
||||
return NULL;
|
||||
|
||||
PyObject* constr_args = Py_BuildValue("(O)",Py_None);
|
||||
PyObject* tts_file = PyObject_CallObject(cls,constr_args);
|
||||
Py_DECREF(constr_args);
|
||||
|
||||
if(tts_file == NULL){
|
||||
PyErr_Print();
|
||||
PyErr_SetString(PyExc_RuntimeError,"could not create new IvrAudioFile object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IvrAudioFile* self = (IvrAudioFile*)tts_file;
|
||||
|
||||
*self->filename = string(TTS_CACHE_PATH) + AmSession::getNewId() + string(".wav");
|
||||
self->del_file = true;
|
||||
flite_text_to_speech(text,self->tts_voice,self->filename->c_str());
|
||||
|
||||
if(self->af->open(self->filename->c_str(),AmAudioFile::Read)){
|
||||
Py_DECREF(tts_file);
|
||||
PyErr_SetString(PyExc_IOError,"could not open TTS file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tts_file;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject* IvrAudioFile_close(IvrAudioFile* self, PyObject*)
|
||||
{
|
||||
self->af->close();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_getDataSize(IvrAudioFile* self, PyObject*)
|
||||
{
|
||||
return PyInt_FromLong(self->af->getDataSize());
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_setRecordTime(IvrAudioFile* self, PyObject* args)
|
||||
{
|
||||
int rec_time;
|
||||
if(!PyArg_ParseTuple(args,"i",&rec_time))
|
||||
return NULL;
|
||||
|
||||
self->af->setRecordTime(rec_time);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* IvrAudioFile_exportRaw(IvrAudioFile* self, PyObject*)
|
||||
{
|
||||
if(self->af->getMode() == AmAudioFile::Write)
|
||||
self->af->on_close();
|
||||
|
||||
self->af->rewind();
|
||||
|
||||
return PyFile_FromFile(self->af->getfp(),"","rwb",NULL);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef IvrAudioFile_methods[] = {
|
||||
{"open", (PyCFunction)IvrAudioFile_open, METH_VARARGS,
|
||||
"open the audio file"
|
||||
},
|
||||
{"fpopen", (PyCFunction)IvrAudioFile_fpopen, METH_VARARGS,
|
||||
"open the audio file"
|
||||
},
|
||||
{"close", (PyCFunction)IvrAudioFile_close, METH_NOARGS,
|
||||
"close the audio file"
|
||||
},
|
||||
{"rewind", (PyCFunction)IvrAudioFile_rewind, METH_NOARGS,
|
||||
"rewind the audio file"
|
||||
},
|
||||
{"getDataSize", (PyCFunction)IvrAudioFile_getDataSize, METH_NOARGS,
|
||||
"returns the recorded data size"
|
||||
},
|
||||
{"setRecordTime", (PyCFunction)IvrAudioFile_setRecordTime, METH_VARARGS,
|
||||
"set the maximum record time in millisecond"
|
||||
},
|
||||
{"exportRaw", (PyCFunction)IvrAudioFile_exportRaw, METH_NOARGS,
|
||||
"creates a new Python file with the actual file"
|
||||
" and eventually flushes headers (audio->on_stop)"
|
||||
},
|
||||
#ifdef IVR_WITH_TTS
|
||||
{"tts", (PyCFunction)IvrAudioFile_tts, METH_CLASS | METH_VARARGS,
|
||||
"text to speech"
|
||||
},
|
||||
#endif
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
||||
static PyObject* IvrAudioFile_getloop(IvrAudioFile* self, void*)
|
||||
{
|
||||
PyObject* loop = self->af->loop.get() ? Py_True : Py_False;
|
||||
Py_INCREF(loop);
|
||||
return loop;
|
||||
}
|
||||
|
||||
static int IvrAudioFile_setloop(IvrAudioFile* self, PyObject* value, void*)
|
||||
{
|
||||
if (value == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(value == Py_True)
|
||||
self->af->loop.set(true);
|
||||
|
||||
else if(value == Py_False)
|
||||
self->af->loop.set(false);
|
||||
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The first attribute value must be a boolean");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyGetSetDef IvrAudioFile_getseters[] = {
|
||||
{"loop",
|
||||
(getter)IvrAudioFile_getloop, (setter)IvrAudioFile_setloop,
|
||||
"repeat mode",
|
||||
NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
PyTypeObject IvrAudioFileType = {
|
||||
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"ivr.IvrAudioFile", /*tp_name*/
|
||||
sizeof(IvrAudioFile), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)IvrAudioFile_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
0, /*tp_call*/
|
||||
0, /*tp_str*/
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||
"An audio file", /*tp_doc*/
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
IvrAudioFile_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
IvrAudioFile_getseters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
IvrAudioFile_new, /* tp_new */
|
||||
};
|
||||
@ -0,0 +1,33 @@
|
||||
#ifndef IvrAudio_h
|
||||
#define IvrAudio_h
|
||||
|
||||
// Python stuff
|
||||
#include <Python.h>
|
||||
#include "structmember.h"
|
||||
|
||||
#include "AmAudio.h"
|
||||
|
||||
#define AUDIO_READ 1
|
||||
#define AUDIO_WRITE 2
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
#include "flite.h"
|
||||
#endif
|
||||
|
||||
// Data definition
|
||||
typedef struct {
|
||||
|
||||
PyObject_HEAD
|
||||
AmAudioFile* af;
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
cst_voice* tts_voice;
|
||||
string* filename;
|
||||
bool del_file;
|
||||
#endif
|
||||
|
||||
} IvrAudioFile;
|
||||
|
||||
extern PyTypeObject IvrAudioFileType;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,95 @@
|
||||
plug_in_name = py_sems
|
||||
|
||||
COREPATH ?=../../core
|
||||
|
||||
SCRIPT = Python
|
||||
TTS = y
|
||||
|
||||
#
|
||||
# Python specific
|
||||
# (no need to change this if you want to use perl)
|
||||
#
|
||||
# PYTHON_VERSION might also be 2.2 -- except for the use of GIL
|
||||
# do a ls /usr/include/python2.3/Python.h to see if it's there
|
||||
PY_VER = 2.3
|
||||
# adjust to point to python include path
|
||||
# can also be /usr/include/python$(PY_VER)
|
||||
# look for Python.h in the specified path
|
||||
# Python prefix is what you configured python with
|
||||
# if you built from source (e.g. ./configure --with-prefix=/usr/local)
|
||||
# on debian it's often /usr, on SuSE and FreeBSD /usr/local
|
||||
PYTHON_PREFIX = /usr
|
||||
PYTHON_DIR = $(PYTHON_PREFIX)/include/python$(PY_VER)
|
||||
PYTHON_LIBDIR = $(PYTHON_PREFIX)/lib/python$(PY_VER)
|
||||
|
||||
# put used Python modules from lib-dynload here, e.g. time, mysql, _cvs.so etc.
|
||||
PYTHON_DYNLOAD_MODULES = $(wildcard $(PYTHON_LIBDIR)/lib-dynload/*.so) \
|
||||
$(wildcard $(PYTHON_LIBDIR)/site-packages/*.so)
|
||||
PYTHON_module_cflags = -I$(PYTHON_DIR)
|
||||
PYTHON_module_ldflags = -Xlinker --export-dynamic \
|
||||
-L$(PYTHON_LIBDIR)/config \
|
||||
-lpython$(PY_VER) $(wildcard sip/*.o)
|
||||
#\
|
||||
#$(PYTHON_DYNLOAD_MODULES)
|
||||
|
||||
ifeq ($(TTS), y)
|
||||
#
|
||||
# flite text to speech
|
||||
#
|
||||
# uncomment the next lines if you want to have flite text-to-speech (ivr.say("Hello there"); )
|
||||
FLITE_DIR = /usr/src/flite-1.2-release
|
||||
ALT_FLITE_DIR = /usr/include/flite
|
||||
IVR_TTS_module_ldflags = -L$(FLITE_DIR)/lib -lm -lflite_cmu_us_kal -lflite_usenglish \
|
||||
-lflite_cmulex -lflite
|
||||
IVR_TTS_module_cflags = -I$(FLITE_DIR)/include -I$(ALT_FLITE_DIR) -DIVR_WITH_TTS
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES = -I$(FLITE_DIR)/lang/usenglish
|
||||
|
||||
# On FreeBSD, remove the following flags: -ldl -lpthread
|
||||
module_ldflags = -ldl -lpthread -lutil -lm \
|
||||
$(PYTHON_module_ldflags) \
|
||||
$(IVR_TTS_module_ldflags)
|
||||
|
||||
# for perl support:
|
||||
# -DIVR_PERL `perl -MExtUtils::Embed -e ccopts `
|
||||
# for flite text-to-speech support -DIVR_WITH_TTS
|
||||
module_cflags = \
|
||||
$(PYTHON_module_cflags) \
|
||||
$(IVR_TTS_module_cflags) \
|
||||
$(PERL_module_cflags) \
|
||||
$(module_additional_cflags)
|
||||
|
||||
extra_target = python_files
|
||||
extra_install = install_python_files
|
||||
|
||||
py_src = $(notdir $(wildcard py/*.py))
|
||||
py_obj = $(py_src:.py=.pyc)
|
||||
|
||||
|
||||
ifeq (all,$(MAKECMDGOALS))
|
||||
.PHONY: python_files
|
||||
python_files:
|
||||
python$(PY_VER) py_comp -l -q py &&\
|
||||
cp py/*.pyc $(COREPATH)/lib
|
||||
|
||||
endif
|
||||
|
||||
ifeq (module_package,$(MAKECMDGOALS))
|
||||
python_files:
|
||||
python$(PY_VER) py_comp -l -q py
|
||||
|
||||
endif
|
||||
|
||||
include $(COREPATH)/plug-in/Makefile.app_module
|
||||
|
||||
.PHONY: install_python_files
|
||||
install_python_files: $(modules-prefix)/$(modules-dir)
|
||||
echo "Installing Python object files..."
|
||||
for f in $(py_obj) ; do \
|
||||
if [ -n "py/$$f" ]; then \
|
||||
$(INSTALL-TOUCH) $(modules-prefix)/$(modules-dir)/$$f; \
|
||||
$(INSTALL-MODULES) py/$$f $(modules-prefix)/$(modules-dir)/$$f; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
@ -0,0 +1,595 @@
|
||||
/*
|
||||
* $Id: PySems.cpp,v 1.26.2.1 2005/09/02 13:47:46 rco Exp $
|
||||
* Copyright (C) 2002-2003 Fhg Fokus
|
||||
*
|
||||
* This file is part of sems, a free SIP media server.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "PySemsAudio.h"
|
||||
#include "PySems.h"
|
||||
|
||||
#include "AmConfigReader.h"
|
||||
#include "AmConfig.h"
|
||||
#include "log.h"
|
||||
#include "AmApi.h"
|
||||
#include "AmUtils.h"
|
||||
#include "AmSessionScheduler.h"
|
||||
#include "AmPlugIn.h"
|
||||
|
||||
#include "sip/sipAPIpy_sems.h"
|
||||
#include "sip/sippy_semsPySemsDialog.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <regex.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <set>
|
||||
using std::set;
|
||||
|
||||
|
||||
#define PYFILE_REGEX "(.+)\\.(py|pyc|pyo)$"
|
||||
|
||||
|
||||
EXPORT_SESSION_FACTORY(PySemsFactory,MOD_NAME);
|
||||
|
||||
PyMODINIT_FUNC initpy_sems();
|
||||
|
||||
struct PythonGIL
|
||||
{
|
||||
PyGILState_STATE gst;
|
||||
|
||||
PythonGIL() { gst = PyGILState_Ensure(); }
|
||||
~PythonGIL(){ PyGILState_Release(gst); }
|
||||
};
|
||||
|
||||
|
||||
// This must be the first declaration of every
|
||||
// function using Python C-API.
|
||||
// But this is not necessary in function which
|
||||
// will get called from Python
|
||||
#define PYLOCK PythonGIL _py_gil
|
||||
|
||||
extern "C" {
|
||||
|
||||
static PyObject* ivr_log(PyObject*, PyObject* args)
|
||||
{
|
||||
int level;
|
||||
char *msg;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"is",&level,&msg))
|
||||
return NULL;
|
||||
|
||||
if((level)<=log_level) {
|
||||
|
||||
//if(level == L_ERR)
|
||||
//assert(0);
|
||||
|
||||
if(log_stderr)
|
||||
log_print( level, msg );
|
||||
else {
|
||||
switch(level){
|
||||
case L_ERR:
|
||||
syslog(LOG_ERR | L_FAC, "Error: %s", msg);
|
||||
break;
|
||||
case L_WARN:
|
||||
syslog(LOG_WARNING | L_FAC, "Warning: %s", msg);
|
||||
break;
|
||||
case L_INFO:
|
||||
syslog(LOG_INFO | L_FAC, "Info: %s", msg);
|
||||
break;
|
||||
case L_DBG:
|
||||
syslog(LOG_DEBUG | L_FAC, "Debug: %s", msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* ivr_getHeader(PyObject*, PyObject* args)
|
||||
{
|
||||
char* headers;
|
||||
char* header_name;
|
||||
if(!PyArg_ParseTuple(args,"ss",&headers,&header_name))
|
||||
return NULL;
|
||||
|
||||
string res = getHeader(headers,header_name);
|
||||
return PyString_FromString(res.c_str());
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef ivr_methods[] = {
|
||||
{"log", (PyCFunction)ivr_log, METH_VARARGS,"Log a message using Sems' logging system"},
|
||||
{"getHeader", (PyCFunction)ivr_getHeader, METH_VARARGS,"Python getHeader wrapper"},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
}
|
||||
|
||||
PySemsFactory::PySemsFactory(const string& _app_name)
|
||||
: AmSessionFactory(_app_name),
|
||||
user_timer_fact(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void PySemsFactory::setScriptPath(const string& path)
|
||||
{
|
||||
string python_path = script_path = path;
|
||||
|
||||
|
||||
if(python_path.length()){
|
||||
|
||||
python_path = AmConfig::PlugInPath + ":" + python_path;
|
||||
}
|
||||
else
|
||||
python_path = AmConfig::PlugInPath;
|
||||
|
||||
char* old_path=0;
|
||||
if((old_path = getenv("PYTHONPATH")) != 0)
|
||||
if(strlen(old_path))
|
||||
python_path += ":" + string(old_path);
|
||||
|
||||
DBG("setting PYTHONPATH to: '%s'\n",python_path.c_str());
|
||||
setenv("PYTHONPATH",python_path.c_str(),1);
|
||||
|
||||
}
|
||||
|
||||
void PySemsFactory::import_object(PyObject* m, char* name, PyTypeObject* type)
|
||||
{
|
||||
if (PyType_Ready(type) < 0){
|
||||
ERROR("PyType_Ready failed !\n");
|
||||
return;
|
||||
}
|
||||
Py_INCREF(type);
|
||||
PyModule_AddObject(m, name, (PyObject *)type);
|
||||
}
|
||||
|
||||
void PySemsFactory::import_ivr_builtins()
|
||||
{
|
||||
// ivr module - start
|
||||
PyImport_AddModule("ivr");
|
||||
ivr_module = Py_InitModule("ivr",ivr_methods);
|
||||
|
||||
// PySemsSipDialog (= AmSipDialog)
|
||||
//import_object(ivr_module, "PySemsSipDialog", &PySemsSipDialogType);
|
||||
|
||||
// PySemsDialogBase
|
||||
//import_object(ivr_module,"PySemsDialogBase",&PySemsDialogBaseType);
|
||||
|
||||
|
||||
// PySemsAudioFile
|
||||
import_object(ivr_module,"PySemsAudioFile",&PySemsAudioFileType);
|
||||
|
||||
PyModule_AddIntConstant(ivr_module, "AUDIO_READ",AUDIO_READ);
|
||||
PyModule_AddIntConstant(ivr_module, "AUDIO_WRITE",AUDIO_WRITE);
|
||||
// ivr module - end
|
||||
|
||||
// add log level for the log module
|
||||
PyModule_AddIntConstant(ivr_module, "SEMS_LOG_LEVEL",log_level);
|
||||
|
||||
import_module("log");
|
||||
initpy_sems();
|
||||
}
|
||||
|
||||
void PySemsFactory::import_module(const char* modname)
|
||||
{
|
||||
PyObject* py_mod_name = PyString_FromString(modname);
|
||||
PyObject* py_mod = PyImport_Import(py_mod_name);
|
||||
Py_DECREF(py_mod_name);
|
||||
|
||||
if(!py_mod){
|
||||
PyErr_Print();
|
||||
ERROR("PySemsFactory: could not find python module '%s'.\n",modname);
|
||||
ERROR("PySemsFactory: please check your installation.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PySemsFactory::init_python_interpreter()
|
||||
{
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
import_ivr_builtins();
|
||||
PyEval_ReleaseLock();
|
||||
}
|
||||
|
||||
PySemsDialog* PySemsFactory::newDlg(const string& name)
|
||||
{
|
||||
PYLOCK;
|
||||
|
||||
map<string,PySemsScriptDesc>::iterator mod_it = mod_reg.find(name);
|
||||
if(mod_it == mod_reg.end()){
|
||||
ERROR("Unknown script name '%s'\n", name.c_str());
|
||||
throw AmSession::Exception(500,"Unknown Application");
|
||||
}
|
||||
|
||||
PySemsScriptDesc& mod_desc = mod_it->second;
|
||||
|
||||
AmDynInvoke* user_timer = user_timer_fact->getInstance();
|
||||
if(!user_timer){
|
||||
ERROR("could not get a user timer reference\n");
|
||||
throw AmSession::Exception(500,"could not get a user timer reference");
|
||||
}
|
||||
|
||||
PyObject* dlg_inst = PyObject_Call(mod_desc.dlg_class,PyTuple_New(0),NULL);
|
||||
if(!dlg_inst){
|
||||
|
||||
PyErr_Print();
|
||||
ERROR("PySemsFactory: while loading \"%s\": could not create instance\n",
|
||||
name.c_str());
|
||||
throw AmSession::Exception(500,"Internal error in IVR plug-in.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int err=0;
|
||||
PySemsDialog* dlg = (PySemsDialog*)sipForceConvertTo_PySemsDialog(dlg_inst,&err);
|
||||
if(!dlg || err){
|
||||
|
||||
PyErr_Print();
|
||||
ERROR("PySemsFactory: while loading \"%s\": could not retrieve PySemsDialog ptr.\n",
|
||||
name.c_str());
|
||||
throw AmSession::Exception(500,"Internal error in IVR plug-in.");
|
||||
Py_DECREF(dlg_inst);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// take the ownership over dlg
|
||||
sipTransfer(dlg_inst,1);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
bool PySemsFactory::loadScript(const string& path)
|
||||
{
|
||||
PYLOCK;
|
||||
|
||||
PyObject *modName,*mod,*dict, *dlg_class, *config=NULL;
|
||||
|
||||
modName = PyString_FromString(path.c_str());
|
||||
mod = PyImport_Import(modName);
|
||||
|
||||
AmConfigReader cfg;
|
||||
string cfg_file = add2path(AmConfig::ModConfigPath,1,(path + ".conf").c_str());
|
||||
|
||||
Py_DECREF(modName);
|
||||
|
||||
if(!mod){
|
||||
PyErr_Print();
|
||||
WARN("PySemsFactory: Failed to load \"%s\"\n", path.c_str());
|
||||
|
||||
dict = PyImport_GetModuleDict();
|
||||
Py_INCREF(dict);
|
||||
PyDict_DelItemString(dict,path.c_str());
|
||||
Py_DECREF(dict);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
dict = PyModule_GetDict(mod);
|
||||
dlg_class = PyDict_GetItemString(dict, "PySemsScript");
|
||||
|
||||
if(!dlg_class){
|
||||
|
||||
PyErr_Print();
|
||||
WARN("PySemsFactory: class PySemsDialog not found in \"%s\"\n", path.c_str());
|
||||
goto error1;
|
||||
}
|
||||
|
||||
Py_INCREF(dlg_class);
|
||||
|
||||
if(!PyObject_IsSubclass(dlg_class,(PyObject *)sipClass_PySemsDialog)){
|
||||
|
||||
WARN("PySemsFactory: in \"%s\": PySemsScript is not a "
|
||||
"subtype of PySemsDialog\n", path.c_str());
|
||||
|
||||
goto error2;
|
||||
}
|
||||
|
||||
if(cfg.loadFile(cfg_file)){
|
||||
ERROR("could not load config file at %s\n",cfg_file.c_str());
|
||||
goto error2;
|
||||
}
|
||||
|
||||
config = PyDict_New();
|
||||
if(!config){
|
||||
ERROR("could not allocate new dict for config\n");
|
||||
goto error2;
|
||||
}
|
||||
|
||||
for(map<string,string>::const_iterator it = cfg.begin();
|
||||
it != cfg.end(); it++){
|
||||
|
||||
PyDict_SetItem(config,
|
||||
PyString_FromString(it->first.c_str()),
|
||||
PyString_FromString(it->second.c_str()));
|
||||
}
|
||||
|
||||
PyObject_SetAttrString(mod,"config",config);
|
||||
|
||||
mod_reg.insert(make_pair(path,
|
||||
PySemsScriptDesc(mod,dlg_class)));
|
||||
|
||||
return true;
|
||||
|
||||
error2:
|
||||
Py_DECREF(dlg_class);
|
||||
error1:
|
||||
Py_DECREF(mod);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads python script path and default script file from configuration file
|
||||
*/
|
||||
int PySemsFactory::onLoad()
|
||||
{
|
||||
user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
|
||||
if(!user_timer_fact){
|
||||
|
||||
ERROR("could not load user_timer from session_timer plug-in\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
AmConfigReader cfg;
|
||||
|
||||
if(cfg.loadFile(add2path(AmConfig::ModConfigPath,1,MOD_NAME ".conf")))
|
||||
return -1;
|
||||
|
||||
// get application specific global parameters
|
||||
configureModule(cfg);
|
||||
|
||||
setScriptPath(cfg.getParameter("script_path"));
|
||||
init_python_interpreter();
|
||||
|
||||
DBG("** IVR compile time configuration:\n");
|
||||
DBG("** built with PYTHON support.\n");
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
DBG("** Text-To-Speech enabled\n");
|
||||
#else
|
||||
DBG("** Text-To-Speech disabled\n");
|
||||
#endif
|
||||
|
||||
DBG("** IVR run time configuration:\n");
|
||||
DBG("** script path: \'%s\'\n", script_path.c_str());
|
||||
|
||||
regex_t reg;
|
||||
if(regcomp(®,PYFILE_REGEX,REG_EXTENDED)){
|
||||
ERROR("while compiling regular expression\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIR* dir = opendir(script_path.c_str());
|
||||
if(!dir){
|
||||
regfree(®);
|
||||
ERROR("PySems: script pre-loader (%s): %s\n",
|
||||
script_path.c_str(),strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
DBG("directory '%s' opened\n",script_path.c_str());
|
||||
|
||||
set<string> unique_entries;
|
||||
regmatch_t pmatch[2];
|
||||
|
||||
struct dirent* entry=0;
|
||||
while((entry = readdir(dir)) != NULL){
|
||||
|
||||
if(!regexec(®,entry->d_name,2,pmatch,0)){
|
||||
|
||||
string name(entry->d_name + pmatch[1].rm_so,
|
||||
pmatch[1].rm_eo - pmatch[1].rm_so);
|
||||
|
||||
unique_entries.insert(name);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
regfree(®);
|
||||
|
||||
AmPlugIn* plugin = AmPlugIn::instance();
|
||||
for(set<string>::iterator it = unique_entries.begin();
|
||||
it != unique_entries.end(); it++) {
|
||||
|
||||
if(loadScript(*it)){
|
||||
bool res = plugin->registerFactory4App(*it,this);
|
||||
if(res)
|
||||
INFO("Application script registered: %s.\n",
|
||||
it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // don't stop sems from starting up
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a script using user name from URI.
|
||||
* Note: there is no default script.
|
||||
*/
|
||||
AmSession* PySemsFactory::onInvite(const AmSipRequest& req)
|
||||
{
|
||||
if(req.cmd != MOD_NAME)
|
||||
return newDlg(req.cmd);
|
||||
else
|
||||
return newDlg(req.user);
|
||||
}
|
||||
|
||||
PySemsDialog::PySemsDialog()
|
||||
: py_mod(NULL),
|
||||
py_dlg(NULL),
|
||||
playlist(this),
|
||||
user_timer(NULL)
|
||||
{
|
||||
sip_relay_only = false;
|
||||
}
|
||||
|
||||
PySemsDialog::PySemsDialog(AmDynInvoke* user_timer)
|
||||
: py_mod(NULL),
|
||||
py_dlg(NULL),
|
||||
playlist(this),
|
||||
user_timer(user_timer)
|
||||
{
|
||||
sip_relay_only = false;
|
||||
}
|
||||
|
||||
PySemsDialog::~PySemsDialog()
|
||||
{
|
||||
DBG("PySemsDialog::~PySemsDialog()\n");
|
||||
|
||||
PYLOCK;
|
||||
Py_XDECREF(py_mod);
|
||||
Py_XDECREF(py_dlg);
|
||||
}
|
||||
|
||||
void PySemsDialog::setPyPtrs(PyObject *mod, PyObject *dlg)
|
||||
{
|
||||
assert(py_mod = mod);
|
||||
assert(py_dlg = dlg);
|
||||
Py_INCREF(py_mod);
|
||||
Py_INCREF(py_dlg);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
type_error(const char *msg)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
null_error(void)
|
||||
{
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"null argument to internal routine");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyObject_VaCallMethod(PyObject *o, char *name, char *format, va_list va)
|
||||
{
|
||||
PyObject *args, *func = 0, *retval;
|
||||
|
||||
if (o == NULL || name == NULL)
|
||||
return null_error();
|
||||
|
||||
func = PyObject_GetAttrString(o, name);
|
||||
if (func == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func))
|
||||
return type_error("call of non-callable attribute");
|
||||
|
||||
if (format && *format) {
|
||||
args = Py_VaBuildValue(format, va);
|
||||
}
|
||||
else
|
||||
args = PyTuple_New(0);
|
||||
|
||||
if (!args)
|
||||
return NULL;
|
||||
|
||||
if (!PyTuple_Check(args)) {
|
||||
PyObject *a;
|
||||
|
||||
a = PyTuple_New(1);
|
||||
if (a == NULL)
|
||||
return NULL;
|
||||
if (PyTuple_SetItem(a, 0, args) < 0)
|
||||
return NULL;
|
||||
args = a;
|
||||
}
|
||||
|
||||
retval = PyObject_Call(func, args, NULL);
|
||||
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(func);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool PySemsDialog::callPyEventHandler(char* name, char* fmt, ...)
|
||||
{
|
||||
bool ret=false;
|
||||
va_list va;
|
||||
|
||||
PYLOCK;
|
||||
|
||||
va_start(va, fmt);
|
||||
PyObject* o = PyObject_VaCallMethod(py_dlg,name,fmt,va);
|
||||
va_end(va);
|
||||
|
||||
if(!o) {
|
||||
|
||||
if(PyErr_ExceptionMatches(PyExc_AttributeError)){
|
||||
|
||||
DBG("method %s is not implemented, trying default one\n",name);
|
||||
return true;
|
||||
}
|
||||
|
||||
PyErr_Print();
|
||||
}
|
||||
else {
|
||||
if(o && PyBool_Check(o) && (o == Py_True)) {
|
||||
|
||||
ret = true;
|
||||
}
|
||||
|
||||
Py_DECREF(o);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PySemsDialog::onSessionStart(const AmSipRequest& req)
|
||||
{
|
||||
DBG("PySemsDialog::onSessionStart\n");
|
||||
setInOut(&playlist,&playlist);
|
||||
AmB2BCallerSession::onSessionStart(req);
|
||||
}
|
||||
|
||||
void PySemsDialog::process(AmEvent* event)
|
||||
{
|
||||
DBG("PySemsDialog::process\n");
|
||||
|
||||
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
|
||||
if(audio_event && audio_event->event_id == AmAudioEvent::noAudio){
|
||||
|
||||
callPyEventHandler("onEmptyQueue", NULL);
|
||||
event->processed = true;
|
||||
}
|
||||
|
||||
AmPluginEvent* plugin_event = dynamic_cast<AmPluginEvent*>(event);
|
||||
if(plugin_event && plugin_event->name == "timer_timeout") {
|
||||
|
||||
callPyEventHandler("onTimer", "i", plugin_event->data.get(0).asInt());
|
||||
event->processed = true;
|
||||
}
|
||||
|
||||
if (!event->processed)
|
||||
AmB2BCallerSession::process(event);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* $Id: PySems.h,v 1.15.2.1 2005/09/02 13:47:46 rco Exp $
|
||||
* Copyright (C) 2002-2003 Fhg Fokus
|
||||
*
|
||||
* This file is part of sems, a free SIP media server.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _IVR_H_
|
||||
#define _IVR_H_
|
||||
|
||||
#define MOD_NAME "ivr"
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "AmB2BSession.h"
|
||||
#include "AmPlaylist.h"
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
#include "flite.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
class PySemsDialog;
|
||||
|
||||
struct PySemsScriptDesc
|
||||
{
|
||||
PyObject* mod;
|
||||
PyObject* dlg_class;
|
||||
|
||||
PySemsScriptDesc()
|
||||
: mod(0),
|
||||
dlg_class(0)
|
||||
{}
|
||||
|
||||
PySemsScriptDesc(const PySemsScriptDesc& d)
|
||||
: mod(d.mod),
|
||||
dlg_class(d.dlg_class)
|
||||
{}
|
||||
|
||||
PySemsScriptDesc(PyObject* mod,
|
||||
PyObject* dlg_class)
|
||||
: mod(mod),
|
||||
dlg_class(dlg_class)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
class PySemsFactory: public AmSessionFactory
|
||||
{
|
||||
PyObject* ivr_module;
|
||||
string script_path;
|
||||
string default_script;
|
||||
|
||||
map<string,PySemsScriptDesc> mod_reg;
|
||||
|
||||
AmDynInvokeFactory* user_timer_fact;
|
||||
|
||||
void init_python_interpreter();
|
||||
void import_ivr_builtins();
|
||||
|
||||
void import_module(const char* modname);
|
||||
void import_object(PyObject* m,
|
||||
char* name,
|
||||
PyTypeObject* type);
|
||||
|
||||
/** @return true if everything ok */
|
||||
bool loadScript(const string& path);
|
||||
|
||||
void setScriptPath(const string& path);
|
||||
bool checkCfg();
|
||||
|
||||
PySemsDialog* newDlg(const string& name);
|
||||
|
||||
public:
|
||||
PySemsFactory(const string& _app_name);
|
||||
|
||||
int onLoad();
|
||||
AmSession* onInvite(const AmSipRequest& req);
|
||||
};
|
||||
|
||||
|
||||
class PySemsDialog : public AmB2BCallerSession
|
||||
{
|
||||
PyObject *py_mod;
|
||||
PyObject *py_dlg;
|
||||
|
||||
bool callPyEventHandler(char* name, char* fmt, ...);
|
||||
|
||||
void process(AmEvent* event);
|
||||
|
||||
public:
|
||||
AmDynInvoke* user_timer;
|
||||
AmPlaylist playlist;
|
||||
|
||||
PySemsDialog();
|
||||
PySemsDialog(AmDynInvoke* user_timer);
|
||||
~PySemsDialog();
|
||||
|
||||
// must be called before everything else.
|
||||
void setPyPtrs(PyObject *mod, PyObject *dlg);
|
||||
|
||||
void onSessionStart(const AmSipRequest& req);
|
||||
/* void onBye(const AmSipRequest& req); */
|
||||
/* void onDtmf(int event, int duration_msec); */
|
||||
|
||||
/* void onOtherBye(const AmSipRequest& req); */
|
||||
/* void onOtherReply(const AmSipReply& r); */
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,321 @@
|
||||
#include "PySemsAudio.h"
|
||||
#include "AmAudio.h"
|
||||
#include "AmSession.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
|
||||
#define TTS_CACHE_PATH "/tmp/"
|
||||
extern "C" cst_voice *register_cmu_us_kal();
|
||||
|
||||
#endif //ivr_with_tts
|
||||
|
||||
|
||||
static PyObject* PySemsAudioFile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
DBG("---------- PySemsAudioFile_alloc -----------\n");
|
||||
PySemsAudioFile *self;
|
||||
|
||||
self = (PySemsAudioFile *)type->tp_alloc(type, 0);
|
||||
|
||||
if (self != NULL) {
|
||||
|
||||
self->af = new AmAudioFile();
|
||||
if(!self->af){
|
||||
Py_DECREF(self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
flite_init();
|
||||
self->tts_voice = register_cmu_us_kal();
|
||||
self->filename = new string();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static void PySemsAudioFile_dealloc(PySemsAudioFile* self)
|
||||
{
|
||||
DBG("---------- PySemsAudioFile_dealloc -----------\n");
|
||||
delete self->af;
|
||||
self->af = NULL;
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
if(self->del_file && !self->filename->empty())
|
||||
unlink(self->filename->c_str());
|
||||
delete self->filename;
|
||||
#endif
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_open(PySemsAudioFile* self, PyObject* args)
|
||||
{
|
||||
int ivr_open_mode;
|
||||
char* filename;
|
||||
bool is_tmp;
|
||||
PyObject* py_is_tmp = NULL;
|
||||
AmAudioFile::OpenMode open_mode;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"si|O",&filename,&ivr_open_mode,&py_is_tmp))
|
||||
return NULL;
|
||||
|
||||
switch(ivr_open_mode){
|
||||
case AUDIO_READ:
|
||||
open_mode = AmAudioFile::Read;
|
||||
break;
|
||||
case AUDIO_WRITE:
|
||||
open_mode = AmAudioFile::Write;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,"Unknown open mode");
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if((py_is_tmp == NULL) || (py_is_tmp == Py_False))
|
||||
is_tmp = false;
|
||||
else if(py_is_tmp == Py_True)
|
||||
is_tmp = true;
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,"third parameter should be of type PyBool");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->af->open(filename,open_mode,is_tmp)){
|
||||
PyErr_SetString(PyExc_IOError,"Could not open file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_fpopen(PySemsAudioFile* self, PyObject* args)
|
||||
{
|
||||
int ivr_open_mode;
|
||||
char* filename;
|
||||
PyObject* py_file = NULL;
|
||||
AmAudioFile::OpenMode open_mode;
|
||||
|
||||
if(!PyArg_ParseTuple(args,"siO",&filename,&ivr_open_mode,&py_file))
|
||||
return NULL;
|
||||
|
||||
switch(ivr_open_mode){
|
||||
case AUDIO_READ:
|
||||
open_mode = AmAudioFile::Read;
|
||||
break;
|
||||
case AUDIO_WRITE:
|
||||
open_mode = AmAudioFile::Write;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,"Unknown open mode");
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
FILE* fp = PyFile_AsFile(py_file);
|
||||
if(!fp){
|
||||
PyErr_SetString(PyExc_IOError,"Could not get FILE pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->af->fpopen(filename,open_mode,fp)){
|
||||
PyErr_SetString(PyExc_IOError,"Could not open file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_rewind(PySemsAudioFile* self, PyObject* args)
|
||||
{
|
||||
self->af->rewind();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
static PyObject* PySemsAudioFile_tts(PyObject* cls, PyObject* args)
|
||||
{
|
||||
char* text;
|
||||
if(!PyArg_ParseTuple(args,"s",&text))
|
||||
return NULL;
|
||||
|
||||
PyObject* constr_args = Py_BuildValue("(O)",Py_None);
|
||||
PyObject* tts_file = PyObject_CallObject(cls,constr_args);
|
||||
Py_DECREF(constr_args);
|
||||
|
||||
if(tts_file == NULL){
|
||||
PyErr_Print();
|
||||
PyErr_SetString(PyExc_RuntimeError,"could not create new PySemsAudioFile object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PySemsAudioFile* self = (PySemsAudioFile*)tts_file;
|
||||
|
||||
*self->filename = string(TTS_CACHE_PATH) + AmSession::getNewId() + string(".wav");
|
||||
self->del_file = true;
|
||||
flite_text_to_speech(text,self->tts_voice,self->filename->c_str());
|
||||
|
||||
if(self->af->open(self->filename->c_str(),AmAudioFile::Read)){
|
||||
Py_DECREF(tts_file);
|
||||
PyErr_SetString(PyExc_IOError,"could not open TTS file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tts_file;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject* PySemsAudioFile_close(PySemsAudioFile* self, PyObject*)
|
||||
{
|
||||
self->af->close();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_getDataSize(PySemsAudioFile* self, PyObject*)
|
||||
{
|
||||
return PyInt_FromLong(self->af->getDataSize());
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_setRecordTime(PySemsAudioFile* self, PyObject* args)
|
||||
{
|
||||
int rec_time;
|
||||
if(!PyArg_ParseTuple(args,"i",&rec_time))
|
||||
return NULL;
|
||||
|
||||
self->af->setRecordTime(rec_time);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject* PySemsAudioFile_exportRaw(PySemsAudioFile* self, PyObject*)
|
||||
{
|
||||
if(self->af->getMode() == AmAudioFile::Write)
|
||||
self->af->on_close();
|
||||
|
||||
self->af->rewind();
|
||||
|
||||
return PyFile_FromFile(self->af->getfp(),"","rwb",NULL);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef PySemsAudioFile_methods[] = {
|
||||
{"open", (PyCFunction)PySemsAudioFile_open, METH_VARARGS,
|
||||
"open the audio file"
|
||||
},
|
||||
{"fpopen", (PyCFunction)PySemsAudioFile_fpopen, METH_VARARGS,
|
||||
"open the audio file"
|
||||
},
|
||||
{"close", (PyCFunction)PySemsAudioFile_close, METH_NOARGS,
|
||||
"close the audio file"
|
||||
},
|
||||
{"rewind", (PyCFunction)PySemsAudioFile_rewind, METH_NOARGS,
|
||||
"rewind the audio file"
|
||||
},
|
||||
{"getDataSize", (PyCFunction)PySemsAudioFile_getDataSize, METH_NOARGS,
|
||||
"returns the recorded data size"
|
||||
},
|
||||
{"setRecordTime", (PyCFunction)PySemsAudioFile_setRecordTime, METH_VARARGS,
|
||||
"set the maximum record time in millisecond"
|
||||
},
|
||||
{"exportRaw", (PyCFunction)PySemsAudioFile_exportRaw, METH_NOARGS,
|
||||
"creates a new Python file with the actual file"
|
||||
" and eventually flushes headers (audio->on_stop)"
|
||||
},
|
||||
#ifdef IVR_WITH_TTS
|
||||
{"tts", (PyCFunction)PySemsAudioFile_tts, METH_CLASS | METH_VARARGS,
|
||||
"text to speech"
|
||||
},
|
||||
#endif
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
||||
static PyObject* PySemsAudioFile_getloop(PySemsAudioFile* self, void*)
|
||||
{
|
||||
PyObject* loop = self->af->loop.get() ? Py_True : Py_False;
|
||||
Py_INCREF(loop);
|
||||
return loop;
|
||||
}
|
||||
|
||||
static int PySemsAudioFile_setloop(PySemsAudioFile* self, PyObject* value, void*)
|
||||
{
|
||||
if (value == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(value == Py_True)
|
||||
self->af->loop.set(true);
|
||||
|
||||
else if(value == Py_False)
|
||||
self->af->loop.set(false);
|
||||
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The first attribute value must be a boolean");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyGetSetDef PySemsAudioFile_getseters[] = {
|
||||
{"loop",
|
||||
(getter)PySemsAudioFile_getloop, (setter)PySemsAudioFile_setloop,
|
||||
"repeat mode",
|
||||
NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
PyTypeObject PySemsAudioFileType = {
|
||||
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"ivr.PySemsAudioFile", /*tp_name*/
|
||||
sizeof(PySemsAudioFile), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)PySemsAudioFile_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
0, /*tp_call*/
|
||||
0, /*tp_str*/
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
0, /*tp_as_buffer*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||
"An audio file", /*tp_doc*/
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
PySemsAudioFile_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
PySemsAudioFile_getseters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
PySemsAudioFile_new, /* tp_new */
|
||||
};
|
||||
@ -0,0 +1,33 @@
|
||||
#ifndef PySemsAudio_h
|
||||
#define PySemsAudio_h
|
||||
|
||||
// Python stuff
|
||||
#include <Python.h>
|
||||
#include "structmember.h"
|
||||
|
||||
#include "AmAudio.h"
|
||||
|
||||
#define AUDIO_READ 1
|
||||
#define AUDIO_WRITE 2
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
#include "flite.h"
|
||||
#endif
|
||||
|
||||
// Data definition
|
||||
typedef struct {
|
||||
|
||||
PyObject_HEAD
|
||||
AmAudioFile* af;
|
||||
|
||||
#ifdef IVR_WITH_TTS
|
||||
cst_voice* tts_voice;
|
||||
string* filename;
|
||||
bool del_file;
|
||||
#endif
|
||||
|
||||
} PySemsAudioFile;
|
||||
|
||||
extern PyTypeObject PySemsAudioFileType;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,5 @@
|
||||
IVR module
|
||||
|
||||
The Documentation for the IVR module moved to docs directory of the
|
||||
answer_machine root ( ../../docs/IVR_Documentation.txt ).
|
||||
|
||||
@ -0,0 +1 @@
|
||||
script_path=/usr/lib/sems/ivr/
|
||||
@ -0,0 +1,59 @@
|
||||
import py_sems
|
||||
import sys
|
||||
|
||||
# These are the same as in log.h
|
||||
L_ERR = 0
|
||||
L_WARN = 1
|
||||
L_INFO = 2
|
||||
L_DBG = 3
|
||||
|
||||
def log(level, msg, args):
|
||||
|
||||
if args != None:
|
||||
tmp_msg = msg % args
|
||||
else:
|
||||
tmp_msg = msg
|
||||
|
||||
ivr.log(level,"Ivr-Python: " + tmp_msg + "\n")
|
||||
|
||||
|
||||
def error(msg, args=None):
|
||||
log(L_ERR, msg, args)
|
||||
|
||||
def warn(msg, args=None):
|
||||
log(L_WARN, msg, args)
|
||||
|
||||
def info(msg, args=None):
|
||||
log(L_INFO, msg, args)
|
||||
|
||||
def debug(msg, args=None):
|
||||
log(L_DBG, msg, args)
|
||||
|
||||
|
||||
def stacktrace(tb):
|
||||
|
||||
if tb: last_file = stacktrace(tb.tb_next)
|
||||
else: return
|
||||
|
||||
f = tb.tb_frame.f_code.co_filename
|
||||
line = tb.tb_frame.f_lineno
|
||||
|
||||
if f != last_file:
|
||||
error('File ' + `f` + ': line ' + `line`)
|
||||
else:
|
||||
error(', line ' + `line`)
|
||||
return f
|
||||
|
||||
|
||||
def log_excepthook(exception, value, tb):
|
||||
|
||||
error('********** Ivr-Python exception report ****************')
|
||||
error(str(exception) + ' raised: ' + str(value))
|
||||
stacktrace(tb)
|
||||
error('********** end of Ivr-Python exception report *********')
|
||||
|
||||
|
||||
|
||||
# init code
|
||||
sys.excepthook = log_excepthook
|
||||
debug("Python-Ivr logging started")
|
||||
@ -0,0 +1,2 @@
|
||||
import compileall
|
||||
compileall.main()
|
||||
@ -0,0 +1,71 @@
|
||||
|
||||
class AmSipDialog
|
||||
{
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "../../../core/AmSipDialog.h"
|
||||
%End
|
||||
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
|
||||
Disconnected=0,
|
||||
Pending,
|
||||
Connected,
|
||||
Disconnecting
|
||||
};
|
||||
|
||||
string user; // local user
|
||||
string domain; // local domain
|
||||
string sip_ip; // destination IP of first received message
|
||||
string sip_port; // optional: SIP port
|
||||
|
||||
string local_uri; // local uri
|
||||
string remote_uri; // remote uri
|
||||
|
||||
string contact_uri; // pre-calculated contact uri
|
||||
|
||||
string callid;
|
||||
string remote_tag;
|
||||
string local_tag;
|
||||
|
||||
string remote_party; // To/From
|
||||
string local_party; // To/From
|
||||
|
||||
string next_hop; // next_hop for t_uac_dlg
|
||||
|
||||
int cseq; // CSeq for next request
|
||||
|
||||
string getRoute(); // record routing
|
||||
void setRoute(const string& /* n_route */);
|
||||
|
||||
bool getUACTransPending();
|
||||
int getStatus();
|
||||
string getContactHdr();
|
||||
|
||||
void updateStatus(const AmSipRequest& /* req */);
|
||||
void updateStatus(const AmSipReply& /* reply */);
|
||||
|
||||
int reply(const AmSipRequest& /* req */,
|
||||
unsigned int /* code */,
|
||||
const string& /* reason */,
|
||||
const string& /* content_type */,
|
||||
const string& /* body */,
|
||||
const string& /* hdrs */);
|
||||
|
||||
int sendRequest(const string& /* method */,
|
||||
const string& /* content_type */,
|
||||
const string& /* body */,
|
||||
const string& /* hdrs */);
|
||||
|
||||
int bye();
|
||||
|
||||
int cancel();
|
||||
|
||||
int update(const string& /* hdrs */);
|
||||
|
||||
int reinvite(const string& /* hdrs */,
|
||||
const string& /* content_type */,
|
||||
const string& /* body */);
|
||||
};
|
||||
@ -0,0 +1,27 @@
|
||||
|
||||
struct AmSipReply
|
||||
{
|
||||
private:
|
||||
%TypeHeaderCode
|
||||
#include "../../../core/AmSipReply.h"
|
||||
%End
|
||||
|
||||
|
||||
public:
|
||||
|
||||
unsigned int code;
|
||||
string reason;
|
||||
string next_request_uri;
|
||||
string next_hop;
|
||||
string route;
|
||||
string hdrs;
|
||||
string body;
|
||||
|
||||
// Parsed from the hdrs
|
||||
// string callid;
|
||||
string remote_tag;
|
||||
string local_tag;
|
||||
unsigned int cseq;
|
||||
|
||||
AmSipReply();
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
|
||||
class AmSipRequest
|
||||
{
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "../../../core/AmSipRequest.h"
|
||||
%End
|
||||
|
||||
public:
|
||||
string cmd;
|
||||
|
||||
string method;
|
||||
string user;
|
||||
string domain;
|
||||
string dstip; // IP where Ser received the message
|
||||
string port; // Ser's SIP port
|
||||
string r_uri;
|
||||
string from_uri;
|
||||
string from;
|
||||
string to;
|
||||
string callid;
|
||||
string from_tag;
|
||||
string to_tag;
|
||||
|
||||
unsigned int cseq;
|
||||
|
||||
string hdrs;
|
||||
string body;
|
||||
|
||||
string route; // record routing
|
||||
string next_hop; // next_hop for t_uac_dlg
|
||||
|
||||
string key; // transaction key to be used in t_reply
|
||||
};
|
||||
|
||||
string getHeader(const string& /* hdrs */,const string& /* hdr_name */);
|
||||
@ -0,0 +1,20 @@
|
||||
|
||||
COREPATH ?=../../../core
|
||||
|
||||
PY_VER = 2.3
|
||||
SIP_FILES = $(wildcard *.sip)
|
||||
|
||||
.PHONY: all
|
||||
all: py_sems.so
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(MAKE) -f Makefile.gen clean; \
|
||||
rm -f *.cpp *.h *.sbf *~
|
||||
|
||||
Makefile.gen: configure.py $(SIP_FILES)
|
||||
python$(VER) configure.py
|
||||
|
||||
py_sems.so: Makefile.gen $(SIP_FILES)
|
||||
$(MAKE) -f Makefile.gen COREPATH=$(COREPATH)
|
||||
@ -0,0 +1,47 @@
|
||||
TARGET = py_sems.so
|
||||
OFILES = sippy_semscmodule.o sippy_semsPySemsDialog.o sippy_semsAmSipDialog.o sippy_semsAmSipReply.o sippy_semsAmSipRequest.o sippy_semsstring.o
|
||||
HFILES = sipAPIpy_sems.h sippy_semsPySemsDialog.h sippy_semsAmSipDialog.h sippy_semsAmSipReply.h sippy_semsAmSipRequest.h sippy_semsstring.h
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
LINK = g++
|
||||
CPPFLAGS = -I. -I$(COREPATH) -I/usr/include/python2.3
|
||||
CFLAGS = -pipe -fPIC -O2 -w
|
||||
CXXFLAGS = -Wall -Wno-reorder -pipe -fPIC -O2 -w
|
||||
LFLAGS = -shared
|
||||
LIBS =
|
||||
.SUFFIXES: .c .o .cpp .cc .cxx .C
|
||||
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
|
||||
|
||||
.cc.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
|
||||
|
||||
.C.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
||||
|
||||
$(TARGET): $(OFILES)
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
|
||||
|
||||
$(OFILES): $(HFILES)
|
||||
|
||||
install: $(TARGET)
|
||||
@test -d $(DESTDIR)/usr/lib/python2.3/site-packages || mkdir -p $(DESTDIR)/usr/lib/python2.3/site-packages
|
||||
cp -f $(TARGET) $(DESTDIR)/usr/lib/python2.3/site-packages/$(TARGET)
|
||||
|
||||
clean:
|
||||
-rm -f $(TARGET)
|
||||
-rm -f sippy_semscmodule.o
|
||||
-rm -f sippy_semsPySemsDialog.o
|
||||
-rm -f sippy_semsAmSipDialog.o
|
||||
-rm -f sippy_semsAmSipReply.o
|
||||
-rm -f sippy_semsAmSipRequest.o
|
||||
-rm -f sippy_semsstring.o
|
||||
@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
class PySemsDialog
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "../PySems.h"
|
||||
%End
|
||||
|
||||
public:
|
||||
|
||||
AmSipDialog dlg;
|
||||
|
||||
PySemsDialog();
|
||||
~PySemsDialog();
|
||||
|
||||
int acceptAudio(const string& /* body */,
|
||||
const string& /* hdrs */,
|
||||
string* /Out/ /* sdp_reply */);
|
||||
|
||||
void setStopped();
|
||||
|
||||
virtual void onInvite(const AmSipRequest& /* req */);
|
||||
virtual void onSessionStart(const AmSipRequest& /* req */);
|
||||
virtual void onBye(const AmSipRequest& /* req */);
|
||||
virtual void onCancel();
|
||||
|
||||
virtual void onDtmf(int /* event */, int /* duration_msec */);
|
||||
|
||||
virtual void onOtherBye(const AmSipRequest& /* req */);
|
||||
virtual void onOtherReply(const AmSipReply& /* r */);
|
||||
|
||||
private:
|
||||
PySemsDialog(const PySemsDialog&);
|
||||
};
|
||||
@ -0,0 +1,22 @@
|
||||
import os
|
||||
import sipconfig
|
||||
|
||||
# The name of the SIP build file generated by SIP and used by the build
|
||||
# system.
|
||||
build_file = "py_sems.sbf"
|
||||
|
||||
# Get the SIP configuration information.
|
||||
config = sipconfig.Configuration()
|
||||
|
||||
# Run SIP to generate the code.
|
||||
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "py_sems.sip"]))
|
||||
|
||||
# Create the Makefile.
|
||||
makefile = sipconfig.SIPModuleMakefile(config, build_file, makefile="Makefile.gen")
|
||||
|
||||
makefile.extra_cxxflags = ["-Wall -Wno-reorder"]
|
||||
makefile.extra_include_dirs = ["$(COREPATH)"]
|
||||
makefile._warnings = 0
|
||||
|
||||
# Generate the Makefile itself.
|
||||
makefile.generate()
|
||||
@ -0,0 +1,3 @@
|
||||
target = py_sems
|
||||
sources = sippy_semscmodule.cpp sippy_semsPySemsDialog.cpp sippy_semsAmSipDialog.cpp sippy_semsAmSipReply.cpp sippy_semsAmSipRequest.cpp sippy_semsstring.cpp
|
||||
headers = sipAPIpy_sems.h sippy_semsPySemsDialog.h sippy_semsAmSipDialog.h sippy_semsAmSipReply.h sippy_semsAmSipRequest.h sippy_semsstring.h
|
||||
@ -0,0 +1,7 @@
|
||||
%Module py_sems 0
|
||||
|
||||
%Include string.sip
|
||||
%Include AmSipRequest.sip
|
||||
%Include AmSipReply.sip
|
||||
%Include AmSipDialog.sip
|
||||
%Include PySemsDialog.sip
|
||||
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Internal module API header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsAPI_H
|
||||
#define _py_semsAPI_H
|
||||
|
||||
|
||||
#include <sip.h>
|
||||
|
||||
|
||||
/*
|
||||
* Convenient names to refer to the names of classes defined in this module.
|
||||
* These are part of the public API.
|
||||
*/
|
||||
|
||||
#define sipName_PySemsDialog sipNm_py_sems_PySemsDialog
|
||||
#define sipName_AmSipDialog sipNm_py_sems_AmSipDialog
|
||||
#define sipName_AmSipReply sipNm_py_sems_AmSipReply
|
||||
#define sipName_AmSipRequest sipNm_py_sems_AmSipRequest
|
||||
|
||||
|
||||
/* Convenient names to call the SIP API. */
|
||||
#define sipConvertFromSliceObject(o,len,start,stop,step,slen) PySlice_GetIndicesEx((PySliceObject *)(o),(len),(start),(stop),(step),(slen))
|
||||
#define sipIsSubClassInstance(o,wt) PyObject_TypeCheck((o),(PyTypeObject *)(wt))
|
||||
|
||||
#define sipMapStringToClass sipAPI_py_sems -> api_map_string_to_class
|
||||
#define sipMapIntToClass sipAPI_py_sems -> api_map_int_to_class
|
||||
#define sipMalloc sipAPI_py_sems -> api_malloc
|
||||
#define sipFree sipAPI_py_sems -> api_free
|
||||
#define sipBuildResult sipAPI_py_sems -> api_build_result
|
||||
#define sipCallMethod sipAPI_py_sems -> api_call_method
|
||||
#define sipParseResult sipAPI_py_sems -> api_parse_result
|
||||
#define sipParseArgs sipAPI_py_sems -> api_parse_args
|
||||
#define sipCommonCtor sipAPI_py_sems -> api_common_ctor
|
||||
#define sipCommonDtor sipAPI_py_sems -> api_common_dtor
|
||||
#define sipConvertFromSequenceIndex sipAPI_py_sems -> api_convert_from_sequence_index
|
||||
#define sipConvertFromVoidPtr sipAPI_py_sems -> api_convert_from_void_ptr
|
||||
#define sipConvertToCpp sipAPI_py_sems -> api_convert_to_cpp
|
||||
#define sipConvertToVoidPtr sipAPI_py_sems -> api_convert_to_void_ptr
|
||||
#define sipNoCtor sipAPI_py_sems -> api_no_ctor
|
||||
#define sipNoFunction sipAPI_py_sems -> api_no_function
|
||||
#define sipNoMethod sipAPI_py_sems -> api_no_method
|
||||
#define sipBadClass sipAPI_py_sems -> api_bad_class
|
||||
#define sipBadSetType sipAPI_py_sems -> api_bad_set_type
|
||||
#define sipBadCatcherResult sipAPI_py_sems -> api_bad_catcher_result
|
||||
#define sipTrace sipAPI_py_sems -> api_trace
|
||||
#define sipTransfer sipAPI_py_sems -> api_transfer
|
||||
#define sipGetWrapper sipAPI_py_sems -> api_get_wrapper
|
||||
#define sipGetCppPtr sipAPI_py_sems -> api_get_cpp_ptr
|
||||
#define sipGetComplexCppPtr sipAPI_py_sems -> api_get_complex_cpp_ptr
|
||||
#define sipIsPyMethod sipAPI_py_sems -> api_is_py_method
|
||||
#define sipMapCppToSelf sipAPI_py_sems -> api_map_cpp_to_self
|
||||
#define sipMapCppToSelfSubClass sipAPI_py_sems -> api_map_cpp_to_self_sub_class
|
||||
#define sipNewCppToSelf sipAPI_py_sems -> api_new_cpp_to_self
|
||||
#define sipNewCppToSelfSubClass sipAPI_py_sems -> api_new_cpp_to_self_sub_class
|
||||
#define sipCallHook sipAPI_py_sems -> api_call_hook
|
||||
#define sipStartThread sipAPI_py_sems -> api_start_thread
|
||||
#define sipEndThread sipAPI_py_sems -> api_end_thread
|
||||
#define sipEmitSignal sipAPI_py_sems -> api_emit_signal
|
||||
#define sipEmitToSlot sipAPI_py_sems -> api_emit_to_slot
|
||||
#define sipConnectRx sipAPI_py_sems -> api_connect_rx
|
||||
#define sipDisconnectRx sipAPI_py_sems -> api_disconnect_rx
|
||||
#define sipGetSender sipAPI_py_sems -> api_get_sender
|
||||
#define sipRaiseUnknownException sipAPI_py_sems -> api_raise_unknown_exception
|
||||
#define sipRaiseClassException sipAPI_py_sems -> api_raise_class_exception
|
||||
#define sipRaiseSubClassException sipAPI_py_sems -> api_raise_sub_class_exception
|
||||
#define sipBadLengthForSlice sipAPI_py_sems -> api_bad_length_for_slice
|
||||
#define sipClassName sipAPI_py_sems -> api_class_name
|
||||
#define sipAddClassInstance sipAPI_py_sems -> api_add_class_instance
|
||||
|
||||
|
||||
/* The strings used by this module. */
|
||||
extern char sipNm_py_sems_onOtherReply[];
|
||||
extern char sipNm_py_sems_onOtherBye[];
|
||||
extern char sipNm_py_sems_onDtmf[];
|
||||
extern char sipNm_py_sems_onCancel[];
|
||||
extern char sipNm_py_sems_onBye[];
|
||||
extern char sipNm_py_sems_onSessionStart[];
|
||||
extern char sipNm_py_sems_onInvite[];
|
||||
extern char sipNm_py_sems_setStopped[];
|
||||
extern char sipNm_py_sems_acceptAudio[];
|
||||
extern char sipNm_py_sems_dlg[];
|
||||
extern char sipNm_py_sems_PySemsDialog[];
|
||||
extern char sipNm_py_sems_reinvite[];
|
||||
extern char sipNm_py_sems_update[];
|
||||
extern char sipNm_py_sems_cancel[];
|
||||
extern char sipNm_py_sems_bye[];
|
||||
extern char sipNm_py_sems_sendRequest[];
|
||||
extern char sipNm_py_sems_reply[];
|
||||
extern char sipNm_py_sems_updateStatus[];
|
||||
extern char sipNm_py_sems_getContactHdr[];
|
||||
extern char sipNm_py_sems_getStatus[];
|
||||
extern char sipNm_py_sems_getUACTransPending[];
|
||||
extern char sipNm_py_sems_setRoute[];
|
||||
extern char sipNm_py_sems_getRoute[];
|
||||
extern char sipNm_py_sems_local_party[];
|
||||
extern char sipNm_py_sems_remote_party[];
|
||||
extern char sipNm_py_sems_contact_uri[];
|
||||
extern char sipNm_py_sems_remote_uri[];
|
||||
extern char sipNm_py_sems_local_uri[];
|
||||
extern char sipNm_py_sems_sip_port[];
|
||||
extern char sipNm_py_sems_sip_ip[];
|
||||
extern char sipNm_py_sems_Disconnecting[];
|
||||
extern char sipNm_py_sems_Connected[];
|
||||
extern char sipNm_py_sems_Pending[];
|
||||
extern char sipNm_py_sems_Disconnected[];
|
||||
extern char sipNm_py_sems_AmSipDialog[];
|
||||
extern char sipNm_py_sems_local_tag[];
|
||||
extern char sipNm_py_sems_remote_tag[];
|
||||
extern char sipNm_py_sems_next_request_uri[];
|
||||
extern char sipNm_py_sems_reason[];
|
||||
extern char sipNm_py_sems_code[];
|
||||
extern char sipNm_py_sems_AmSipReply[];
|
||||
extern char sipNm_py_sems_getHeader[];
|
||||
extern char sipNm_py_sems_key[];
|
||||
extern char sipNm_py_sems_next_hop[];
|
||||
extern char sipNm_py_sems_route[];
|
||||
extern char sipNm_py_sems_body[];
|
||||
extern char sipNm_py_sems_hdrs[];
|
||||
extern char sipNm_py_sems_cseq[];
|
||||
extern char sipNm_py_sems_to_tag[];
|
||||
extern char sipNm_py_sems_from_tag[];
|
||||
extern char sipNm_py_sems_callid[];
|
||||
extern char sipNm_py_sems_to[];
|
||||
extern char sipNm_py_sems_from[];
|
||||
extern char sipNm_py_sems_from_uri[];
|
||||
extern char sipNm_py_sems_r_uri[];
|
||||
extern char sipNm_py_sems_port[];
|
||||
extern char sipNm_py_sems_dstip[];
|
||||
extern char sipNm_py_sems_domain[];
|
||||
extern char sipNm_py_sems_user[];
|
||||
extern char sipNm_py_sems_method[];
|
||||
extern char sipNm_py_sems_cmd[];
|
||||
extern char sipNm_py_sems_AmSipRequest[];
|
||||
extern char sipNm_py_sems_string[];
|
||||
|
||||
|
||||
/* The SIP API, this module's API and the APIs of any imported modules. */
|
||||
extern const sipAPIDef *sipAPI_py_sems;
|
||||
extern sipExportedModuleDef sipModuleAPI_py_sems;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,972 @@
|
||||
/*
|
||||
* Interface wrapper code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
#include "sippy_semsAmSipDialog.h"
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_getRoute(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
string *sipRes;
|
||||
|
||||
sipRes = new string(sipCpp -> AmSipDialog::getRoute());
|
||||
|
||||
PyObject *sipResObj = sipConvertFrom_string(sipRes);
|
||||
delete sipRes;
|
||||
|
||||
return sipResObj;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_getRoute);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_setRoute(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipConvertTo_string,&a0,&a0IsTemp))
|
||||
{
|
||||
sipCpp -> AmSipDialog::setRoute(*a0);
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_setRoute);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_getUACTransPending(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
bool sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::getUACTransPending();
|
||||
|
||||
return PyBool_FromLong(sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_getUACTransPending);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_getStatus(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::getStatus();
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_getStatus);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_getContactHdr(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
string *sipRes;
|
||||
|
||||
sipRes = new string(sipCpp -> AmSipDialog::getContactHdr());
|
||||
|
||||
PyObject *sipResObj = sipConvertFrom_string(sipRes);
|
||||
delete sipRes;
|
||||
|
||||
return sipResObj;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_getContactHdr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_updateStatus(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp -> AmSipDialog::updateStatus(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const AmSipReply * a0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipClass_AmSipReply,&a0))
|
||||
{
|
||||
sipCpp -> AmSipDialog::updateStatus(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_updateStatus);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_reply(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
unsigned a1;
|
||||
const string * a2;
|
||||
int a2IsTemp = 0;
|
||||
const string * a3;
|
||||
int a3IsTemp = 0;
|
||||
const string * a4;
|
||||
int a4IsTemp = 0;
|
||||
const string * a5;
|
||||
int a5IsTemp = 0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1iM1M1M1M1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipClass_AmSipRequest,&a0,&a1,sipConvertTo_string,&a2,&a2IsTemp,sipConvertTo_string,&a3,&a3IsTemp,sipConvertTo_string,&a4,&a4IsTemp,sipConvertTo_string,&a5,&a5IsTemp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::reply(*a0,a1,*a2,*a3,*a4,*a5);
|
||||
|
||||
if (a2IsTemp)
|
||||
delete const_cast<string *>(a2);
|
||||
|
||||
if (a3IsTemp)
|
||||
delete const_cast<string *>(a3);
|
||||
|
||||
if (a4IsTemp)
|
||||
delete const_cast<string *>(a4);
|
||||
|
||||
if (a5IsTemp)
|
||||
delete const_cast<string *>(a5);
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_reply);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_sendRequest(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
const string * a1;
|
||||
int a1IsTemp = 0;
|
||||
const string * a2;
|
||||
int a2IsTemp = 0;
|
||||
const string * a3;
|
||||
int a3IsTemp = 0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1M1M1M1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipConvertTo_string,&a0,&a0IsTemp,sipConvertTo_string,&a1,&a1IsTemp,sipConvertTo_string,&a2,&a2IsTemp,sipConvertTo_string,&a3,&a3IsTemp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::sendRequest(*a0,*a1,*a2,*a3);
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
if (a1IsTemp)
|
||||
delete const_cast<string *>(a1);
|
||||
|
||||
if (a2IsTemp)
|
||||
delete const_cast<string *>(a2);
|
||||
|
||||
if (a3IsTemp)
|
||||
delete const_cast<string *>(a3);
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_sendRequest);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_bye(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::bye();
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_bye);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_cancel(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_AmSipDialog,&sipCpp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::cancel();
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_cancel);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_update(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipConvertTo_string,&a0,&a0IsTemp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::update(*a0);
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_update);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_AmSipDialog_reinvite(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
const string * a1;
|
||||
int a1IsTemp = 0;
|
||||
const string * a2;
|
||||
int a2IsTemp = 0;
|
||||
AmSipDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1M1M1",sipSelf,sipClass_AmSipDialog,&sipCpp,sipConvertTo_string,&a0,&a0IsTemp,sipConvertTo_string,&a1,&a1IsTemp,sipConvertTo_string,&a2,&a2IsTemp))
|
||||
{
|
||||
int sipRes;
|
||||
|
||||
sipRes = sipCpp -> AmSipDialog::reinvite(*a0,*a1,*a2);
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
if (a1IsTemp)
|
||||
delete const_cast<string *>(a1);
|
||||
|
||||
if (a2IsTemp)
|
||||
delete const_cast<string *>(a2);
|
||||
|
||||
return PyInt_FromLong((long)sipRes);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_AmSipDialog,sipNm_py_sems_reinvite);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Cast a pointer to a type somewhere in its superclass hierarchy. */
|
||||
static void *cast_AmSipDialog(void *ptr,sipWrapperType *targetClass)
|
||||
{
|
||||
if (targetClass == sipClass_AmSipDialog)
|
||||
return ptr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void dealloc_AmSipDialog(sipWrapper *sipSelf)
|
||||
{
|
||||
if (sipIsPyOwned(sipSelf))
|
||||
{
|
||||
delete reinterpret_cast<AmSipDialog *>(sipSelf -> u.cppPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *init_AmSipDialog(sipWrapper *,PyObject *sipArgs,int *)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
AmSipDialog *sipCpp = 0;
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,""))
|
||||
{
|
||||
sipCpp = new AmSipDialog();
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
const AmSipDialog * a0;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"J1",sipClass_AmSipDialog,&a0))
|
||||
{
|
||||
sipCpp = new AmSipDialog(*a0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
sipNoCtor(sipArgsParsed,sipNm_py_sems_AmSipDialog);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sipCpp;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_cseq(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = sipCpp -> cseq;
|
||||
|
||||
valobj = PyInt_FromLong((long)val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = (int)PyInt_AsLong(valobj);
|
||||
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_cseq);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> cseq = val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_next_hop(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> next_hop;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_next_hop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> next_hop = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_local_party(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> local_party;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_local_party);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> local_party = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_remote_party(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> remote_party;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_remote_party);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> remote_party = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_local_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> local_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_local_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> local_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_remote_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> remote_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_remote_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> remote_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_callid(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> callid;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_callid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> callid = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_contact_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> contact_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_contact_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> contact_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_remote_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> remote_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_remote_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> remote_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_local_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> local_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_local_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> local_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_sip_port(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> sip_port;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_sip_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> sip_port = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_sip_ip(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> sip_ip;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_sip_ip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> sip_ip = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_domain(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> domain;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_domain);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> domain = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipDialog_user(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipDialog *sipCpp = reinterpret_cast<AmSipDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> user;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipDialog,sipNm_py_sems_user);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> user = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyMethodDef variables_AmSipDialog[] = {
|
||||
{sipNm_py_sems_cseq, var_AmSipDialog_cseq, 0, NULL},
|
||||
{sipNm_py_sems_next_hop, var_AmSipDialog_next_hop, 0, NULL},
|
||||
{sipNm_py_sems_local_party, var_AmSipDialog_local_party, 0, NULL},
|
||||
{sipNm_py_sems_remote_party, var_AmSipDialog_remote_party, 0, NULL},
|
||||
{sipNm_py_sems_local_tag, var_AmSipDialog_local_tag, 0, NULL},
|
||||
{sipNm_py_sems_remote_tag, var_AmSipDialog_remote_tag, 0, NULL},
|
||||
{sipNm_py_sems_callid, var_AmSipDialog_callid, 0, NULL},
|
||||
{sipNm_py_sems_contact_uri, var_AmSipDialog_contact_uri, 0, NULL},
|
||||
{sipNm_py_sems_remote_uri, var_AmSipDialog_remote_uri, 0, NULL},
|
||||
{sipNm_py_sems_local_uri, var_AmSipDialog_local_uri, 0, NULL},
|
||||
{sipNm_py_sems_sip_port, var_AmSipDialog_sip_port, 0, NULL},
|
||||
{sipNm_py_sems_sip_ip, var_AmSipDialog_sip_ip, 0, NULL},
|
||||
{sipNm_py_sems_domain, var_AmSipDialog_domain, 0, NULL},
|
||||
{sipNm_py_sems_user, var_AmSipDialog_user, 0, NULL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static void *forceConvertTo_AmSipDialog(PyObject *valobj,int *iserrp)
|
||||
{
|
||||
if (*iserrp || valobj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (valobj == Py_None || sipIsSubClassInstance(valobj,sipClass_AmSipDialog))
|
||||
return sipConvertToCpp(valobj,sipClass_AmSipDialog,iserrp);
|
||||
|
||||
sipBadClass(sipNm_py_sems_AmSipDialog);
|
||||
|
||||
*iserrp = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef methods_AmSipDialog[] = {
|
||||
{sipNm_py_sems_bye, meth_AmSipDialog_bye, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_cancel, meth_AmSipDialog_cancel, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_getContactHdr, meth_AmSipDialog_getContactHdr, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_getRoute, meth_AmSipDialog_getRoute, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_getStatus, meth_AmSipDialog_getStatus, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_getUACTransPending, meth_AmSipDialog_getUACTransPending, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_reinvite, meth_AmSipDialog_reinvite, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_reply, meth_AmSipDialog_reply, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_sendRequest, meth_AmSipDialog_sendRequest, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_setRoute, meth_AmSipDialog_setRoute, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_update, meth_AmSipDialog_update, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_updateStatus, meth_AmSipDialog_updateStatus, METH_VARARGS, NULL}
|
||||
};
|
||||
|
||||
static sipEnumValueInstanceDef enums_AmSipDialog[] = {
|
||||
{sipNm_py_sems_Connected, AmSipDialog::Connected},
|
||||
{sipNm_py_sems_Disconnected, AmSipDialog::Disconnected},
|
||||
{sipNm_py_sems_Disconnecting, AmSipDialog::Disconnecting},
|
||||
{sipNm_py_sems_Pending, AmSipDialog::Pending}
|
||||
};
|
||||
|
||||
|
||||
/* The main type data structure. */
|
||||
sipTypeDef sipType_AmSipDialog = {
|
||||
0,
|
||||
"py_sems.AmSipDialog",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
12, methods_AmSipDialog,
|
||||
4, enums_AmSipDialog,
|
||||
variables_AmSipDialog,
|
||||
init_AmSipDialog,
|
||||
dealloc_AmSipDialog,
|
||||
cast_AmSipDialog,
|
||||
forceConvertTo_AmSipDialog,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Interface header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsAmSipDialog_h
|
||||
#define _py_semsAmSipDialog_h
|
||||
|
||||
#line 6 "AmSipDialog.sip"
|
||||
#include "../../../core/AmSipDialog.h"
|
||||
#line 13 "sippy_semsAmSipDialog.h"
|
||||
|
||||
#include "sippy_semsstring.h"
|
||||
#include "sippy_semsAmSipRequest.h"
|
||||
#include "sippy_semsAmSipReply.h"
|
||||
|
||||
|
||||
#define sipClass_AmSipDialog sipModuleAPI_py_sems.em_types[1]
|
||||
#define sipCast_AmSipDialog sipType_AmSipDialog.td_cast
|
||||
#define sipForceConvertTo_AmSipDialog sipType_AmSipDialog.td_fcto
|
||||
|
||||
extern sipTypeDef sipType_AmSipDialog;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,439 @@
|
||||
/*
|
||||
* Interface wrapper code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
#include "sippy_semsAmSipReply.h"
|
||||
|
||||
|
||||
/* Cast a pointer to a type somewhere in its superclass hierarchy. */
|
||||
static void *cast_AmSipReply(void *ptr,sipWrapperType *targetClass)
|
||||
{
|
||||
if (targetClass == sipClass_AmSipReply)
|
||||
return ptr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void dealloc_AmSipReply(sipWrapper *sipSelf)
|
||||
{
|
||||
if (sipIsPyOwned(sipSelf))
|
||||
{
|
||||
delete reinterpret_cast<AmSipReply *>(sipSelf -> u.cppPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *init_AmSipReply(sipWrapper *,PyObject *sipArgs,int *)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
AmSipReply *sipCpp = 0;
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,""))
|
||||
{
|
||||
sipCpp = new AmSipReply();
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
const AmSipReply * a0;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"J1",sipClass_AmSipReply,&a0))
|
||||
{
|
||||
sipCpp = new AmSipReply(*a0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
sipNoCtor(sipArgsParsed,sipNm_py_sems_AmSipReply);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sipCpp;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_cseq(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
unsigned val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = sipCpp -> cseq;
|
||||
|
||||
valobj = PyInt_FromLong((long)val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = (unsigned)PyInt_AsLong(valobj);
|
||||
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_cseq);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> cseq = val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_local_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> local_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_local_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> local_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_remote_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> remote_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_remote_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> remote_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_body(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> body;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_body);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> body = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_hdrs(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> hdrs;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_hdrs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> hdrs = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_route(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> route;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_route);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> route = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_next_hop(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> next_hop;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_next_hop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> next_hop = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_next_request_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> next_request_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_next_request_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> next_request_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_reason(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> reason;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_reason);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> reason = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipReply_code(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
unsigned val;
|
||||
AmSipReply *sipCpp = reinterpret_cast<AmSipReply *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipReply));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = sipCpp -> code;
|
||||
|
||||
valobj = PyInt_FromLong((long)val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = (unsigned)PyInt_AsLong(valobj);
|
||||
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipReply,sipNm_py_sems_code);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> code = val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyMethodDef variables_AmSipReply[] = {
|
||||
{sipNm_py_sems_cseq, var_AmSipReply_cseq, 0, NULL},
|
||||
{sipNm_py_sems_local_tag, var_AmSipReply_local_tag, 0, NULL},
|
||||
{sipNm_py_sems_remote_tag, var_AmSipReply_remote_tag, 0, NULL},
|
||||
{sipNm_py_sems_body, var_AmSipReply_body, 0, NULL},
|
||||
{sipNm_py_sems_hdrs, var_AmSipReply_hdrs, 0, NULL},
|
||||
{sipNm_py_sems_route, var_AmSipReply_route, 0, NULL},
|
||||
{sipNm_py_sems_next_hop, var_AmSipReply_next_hop, 0, NULL},
|
||||
{sipNm_py_sems_next_request_uri, var_AmSipReply_next_request_uri, 0, NULL},
|
||||
{sipNm_py_sems_reason, var_AmSipReply_reason, 0, NULL},
|
||||
{sipNm_py_sems_code, var_AmSipReply_code, 0, NULL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static void *forceConvertTo_AmSipReply(PyObject *valobj,int *iserrp)
|
||||
{
|
||||
if (*iserrp || valobj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (valobj == Py_None || sipIsSubClassInstance(valobj,sipClass_AmSipReply))
|
||||
return sipConvertToCpp(valobj,sipClass_AmSipReply,iserrp);
|
||||
|
||||
sipBadClass(sipNm_py_sems_AmSipReply);
|
||||
|
||||
*iserrp = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The main type data structure. */
|
||||
sipTypeDef sipType_AmSipReply = {
|
||||
0,
|
||||
"py_sems.AmSipReply",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
variables_AmSipReply,
|
||||
init_AmSipReply,
|
||||
dealloc_AmSipReply,
|
||||
cast_AmSipReply,
|
||||
forceConvertTo_AmSipReply,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Interface header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsAmSipReply_h
|
||||
#define _py_semsAmSipReply_h
|
||||
|
||||
#line 6 "AmSipReply.sip"
|
||||
#include "../../../core/AmSipReply.h"
|
||||
#line 13 "sippy_semsAmSipReply.h"
|
||||
|
||||
#include "sippy_semsstring.h"
|
||||
|
||||
|
||||
#define sipClass_AmSipReply sipModuleAPI_py_sems.em_types[2]
|
||||
#define sipCast_AmSipReply sipType_AmSipReply.td_cast
|
||||
#define sipForceConvertTo_AmSipReply sipType_AmSipReply.td_fcto
|
||||
|
||||
extern sipTypeDef sipType_AmSipReply;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,746 @@
|
||||
/*
|
||||
* Interface wrapper code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
#include "sippy_semsAmSipRequest.h"
|
||||
|
||||
|
||||
/* Cast a pointer to a type somewhere in its superclass hierarchy. */
|
||||
static void *cast_AmSipRequest(void *ptr,sipWrapperType *targetClass)
|
||||
{
|
||||
if (targetClass == sipClass_AmSipRequest)
|
||||
return ptr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void dealloc_AmSipRequest(sipWrapper *sipSelf)
|
||||
{
|
||||
if (sipIsPyOwned(sipSelf))
|
||||
{
|
||||
delete reinterpret_cast<AmSipRequest *>(sipSelf -> u.cppPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *init_AmSipRequest(sipWrapper *,PyObject *sipArgs,int *)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
AmSipRequest *sipCpp = 0;
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,""))
|
||||
{
|
||||
sipCpp = new AmSipRequest();
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"J1",sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp = new AmSipRequest(*a0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
sipNoCtor(sipArgsParsed,sipNm_py_sems_AmSipRequest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sipCpp;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_key(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> key;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> key = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_next_hop(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> next_hop;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_next_hop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> next_hop = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_route(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> route;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_route);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> route = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_body(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> body;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_body);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> body = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_hdrs(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> hdrs;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_hdrs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> hdrs = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_cseq(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
unsigned val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = sipCpp -> cseq;
|
||||
|
||||
valobj = PyInt_FromLong((long)val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = (unsigned)PyInt_AsLong(valobj);
|
||||
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_cseq);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> cseq = val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_to_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> to_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_to_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> to_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_from_tag(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> from_tag;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_from_tag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> from_tag = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_callid(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> callid;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_callid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> callid = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_to(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> to;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_to);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> to = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_from(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> from;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_from);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> from = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_from_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> from_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_from_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> from_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_r_uri(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> r_uri;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_r_uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> r_uri = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_port(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> port;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> port = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_dstip(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> dstip;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_dstip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> dstip = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_domain(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> domain;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_domain);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> domain = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_user(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> user;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_user);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> user = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_method(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> method;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_method);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> method = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_AmSipRequest_cmd(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
string *val;
|
||||
AmSipRequest *sipCpp = reinterpret_cast<AmSipRequest *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_AmSipRequest));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> cmd;
|
||||
|
||||
valobj = sipConvertFrom_string(val);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<string *>(sipForceConvertTo_string(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_AmSipRequest,sipNm_py_sems_cmd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> cmd = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyMethodDef variables_AmSipRequest[] = {
|
||||
{sipNm_py_sems_key, var_AmSipRequest_key, 0, NULL},
|
||||
{sipNm_py_sems_next_hop, var_AmSipRequest_next_hop, 0, NULL},
|
||||
{sipNm_py_sems_route, var_AmSipRequest_route, 0, NULL},
|
||||
{sipNm_py_sems_body, var_AmSipRequest_body, 0, NULL},
|
||||
{sipNm_py_sems_hdrs, var_AmSipRequest_hdrs, 0, NULL},
|
||||
{sipNm_py_sems_cseq, var_AmSipRequest_cseq, 0, NULL},
|
||||
{sipNm_py_sems_to_tag, var_AmSipRequest_to_tag, 0, NULL},
|
||||
{sipNm_py_sems_from_tag, var_AmSipRequest_from_tag, 0, NULL},
|
||||
{sipNm_py_sems_callid, var_AmSipRequest_callid, 0, NULL},
|
||||
{sipNm_py_sems_to, var_AmSipRequest_to, 0, NULL},
|
||||
{sipNm_py_sems_from, var_AmSipRequest_from, 0, NULL},
|
||||
{sipNm_py_sems_from_uri, var_AmSipRequest_from_uri, 0, NULL},
|
||||
{sipNm_py_sems_r_uri, var_AmSipRequest_r_uri, 0, NULL},
|
||||
{sipNm_py_sems_port, var_AmSipRequest_port, 0, NULL},
|
||||
{sipNm_py_sems_dstip, var_AmSipRequest_dstip, 0, NULL},
|
||||
{sipNm_py_sems_domain, var_AmSipRequest_domain, 0, NULL},
|
||||
{sipNm_py_sems_user, var_AmSipRequest_user, 0, NULL},
|
||||
{sipNm_py_sems_method, var_AmSipRequest_method, 0, NULL},
|
||||
{sipNm_py_sems_cmd, var_AmSipRequest_cmd, 0, NULL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static void *forceConvertTo_AmSipRequest(PyObject *valobj,int *iserrp)
|
||||
{
|
||||
if (*iserrp || valobj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (valobj == Py_None || sipIsSubClassInstance(valobj,sipClass_AmSipRequest))
|
||||
return sipConvertToCpp(valobj,sipClass_AmSipRequest,iserrp);
|
||||
|
||||
sipBadClass(sipNm_py_sems_AmSipRequest);
|
||||
|
||||
*iserrp = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The main type data structure. */
|
||||
sipTypeDef sipType_AmSipRequest = {
|
||||
0,
|
||||
"py_sems.AmSipRequest",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
variables_AmSipRequest,
|
||||
init_AmSipRequest,
|
||||
dealloc_AmSipRequest,
|
||||
cast_AmSipRequest,
|
||||
forceConvertTo_AmSipRequest,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Interface header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsAmSipRequest_h
|
||||
#define _py_semsAmSipRequest_h
|
||||
|
||||
#line 6 "AmSipRequest.sip"
|
||||
#include "../../../core/AmSipRequest.h"
|
||||
#line 13 "sippy_semsAmSipRequest.h"
|
||||
|
||||
#include "sippy_semsstring.h"
|
||||
|
||||
|
||||
#define sipClass_AmSipRequest sipModuleAPI_py_sems.em_types[3]
|
||||
#define sipCast_AmSipRequest sipType_AmSipRequest.td_cast
|
||||
#define sipForceConvertTo_AmSipRequest sipType_AmSipRequest.td_fcto
|
||||
|
||||
extern sipTypeDef sipType_AmSipRequest;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Interface wrapper code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
#include "sippy_semsPySemsDialog.h"
|
||||
|
||||
sipPySemsDialog::sipPySemsDialog(): PySemsDialog(), sipPySelf(0)
|
||||
{
|
||||
sipCommonCtor(sipPyMethods,7);
|
||||
}
|
||||
|
||||
sipPySemsDialog::~sipPySemsDialog()
|
||||
{
|
||||
sipCommonDtor(sipPySelf);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onInvite(const AmSipRequest& a0)
|
||||
{
|
||||
extern void sipVH_py_sems_1(sip_gilstate_t,PyObject *,const AmSipRequest&);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[0],sipPySelf,NULL,sipNm_py_sems_onInvite);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onInvite(a0);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_1(sipGILState,meth,a0);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onSessionStart(const AmSipRequest& a0)
|
||||
{
|
||||
extern void sipVH_py_sems_1(sip_gilstate_t,PyObject *,const AmSipRequest&);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[1],sipPySelf,NULL,sipNm_py_sems_onSessionStart);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onSessionStart(a0);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_1(sipGILState,meth,a0);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onBye(const AmSipRequest& a0)
|
||||
{
|
||||
extern void sipVH_py_sems_1(sip_gilstate_t,PyObject *,const AmSipRequest&);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[2],sipPySelf,NULL,sipNm_py_sems_onBye);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onBye(a0);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_1(sipGILState,meth,a0);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onCancel()
|
||||
{
|
||||
extern void sipVH_py_sems_3(sip_gilstate_t,PyObject *);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[3],sipPySelf,NULL,sipNm_py_sems_onCancel);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onCancel();
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_3(sipGILState,meth);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onDtmf(int a0,int a1)
|
||||
{
|
||||
extern void sipVH_py_sems_2(sip_gilstate_t,PyObject *,int,int);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[4],sipPySelf,NULL,sipNm_py_sems_onDtmf);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onDtmf(a0,a1);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_2(sipGILState,meth,a0,a1);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onOtherBye(const AmSipRequest& a0)
|
||||
{
|
||||
extern void sipVH_py_sems_1(sip_gilstate_t,PyObject *,const AmSipRequest&);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[5],sipPySelf,NULL,sipNm_py_sems_onOtherBye);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onOtherBye(a0);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_1(sipGILState,meth,a0);
|
||||
}
|
||||
|
||||
void sipPySemsDialog::onOtherReply(const AmSipReply& a0)
|
||||
{
|
||||
extern void sipVH_py_sems_0(sip_gilstate_t,PyObject *,const AmSipReply&);
|
||||
|
||||
sip_gilstate_t sipGILState;
|
||||
PyObject *meth;
|
||||
|
||||
meth = sipIsPyMethod(&sipGILState,&sipPyMethods[6],sipPySelf,NULL,sipNm_py_sems_onOtherReply);
|
||||
|
||||
if (!meth)
|
||||
{
|
||||
PySemsDialog::onOtherReply(a0);
|
||||
return;
|
||||
}
|
||||
|
||||
sipVH_py_sems_0(sipGILState,meth,a0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_acceptAudio(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
const string * a1;
|
||||
int a1IsTemp = 0;
|
||||
string * a2;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1M1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipConvertTo_string,&a0,&a0IsTemp,sipConvertTo_string,&a1,&a1IsTemp))
|
||||
{
|
||||
int sipRes;
|
||||
a2 = new string();
|
||||
|
||||
sipRes = sipCpp -> PySemsDialog::acceptAudio(*a0,*a1,a2);
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
if (a1IsTemp)
|
||||
delete const_cast<string *>(a1);
|
||||
|
||||
return sipBuildResult(0,"(iT)",sipRes,a2,sipConvertFrom_string);
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_acceptAudio);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_setStopped(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_PySemsDialog,&sipCpp))
|
||||
{
|
||||
sipCpp -> PySemsDialog::setStopped();
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_setStopped);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onInvite(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onInvite(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onInvite);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onSessionStart(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onSessionStart(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onSessionStart);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onBye(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onBye(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onBye);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onCancel(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"m",sipSelf,sipClass_PySemsDialog,&sipCpp))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onCancel();
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onCancel);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onDtmf(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
int a0;
|
||||
int a1;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mii",sipSelf,sipClass_PySemsDialog,&sipCpp,&a0,&a1))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onDtmf(a0,a1);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onDtmf);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onOtherBye(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipRequest * a0;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipClass_AmSipRequest,&a0))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onOtherBye(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onOtherBye);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *meth_PySemsDialog_onOtherReply(PyObject *sipSelf,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const AmSipReply * a0;
|
||||
PySemsDialog *sipCpp;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"mJ1",sipSelf,sipClass_PySemsDialog,&sipCpp,sipClass_AmSipReply,&a0))
|
||||
{
|
||||
sipCpp -> PySemsDialog::onOtherReply(*a0);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoMethod(sipArgsParsed,sipNm_py_sems_PySemsDialog,sipNm_py_sems_onOtherReply);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Cast a pointer to a type somewhere in its superclass hierarchy. */
|
||||
static void *cast_PySemsDialog(void *ptr,sipWrapperType *targetClass)
|
||||
{
|
||||
if (targetClass == sipClass_PySemsDialog)
|
||||
return ptr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void dealloc_PySemsDialog(sipWrapper *sipSelf)
|
||||
{
|
||||
if (!sipIsSimple(sipSelf))
|
||||
reinterpret_cast<sipPySemsDialog *>(sipSelf -> u.cppPtr) -> sipPySelf = NULL;
|
||||
|
||||
if (sipIsPyOwned(sipSelf))
|
||||
{
|
||||
if (!sipIsSimple(sipSelf))
|
||||
delete reinterpret_cast<sipPySemsDialog *>(sipSelf -> u.cppPtr);
|
||||
else
|
||||
delete reinterpret_cast<PySemsDialog *>(sipSelf -> u.cppPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *init_PySemsDialog(sipWrapper *sipSelf,PyObject *sipArgs,int *)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
sipPySemsDialog *sipCpp = 0;
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,""))
|
||||
{
|
||||
sipCpp = new sipPySemsDialog();
|
||||
}
|
||||
}
|
||||
|
||||
if (!sipCpp)
|
||||
{
|
||||
sipNoCtor(sipArgsParsed,sipNm_py_sems_PySemsDialog);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sipCpp -> sipPySelf = sipSelf;
|
||||
|
||||
return sipCpp;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *var_PySemsDialog_dlg(PyObject *sipSelf,PyObject *valobj)
|
||||
{
|
||||
int iserr = 0;
|
||||
AmSipDialog *val;
|
||||
PySemsDialog *sipCpp = reinterpret_cast<PySemsDialog *>(sipGetCppPtr((sipWrapper *)sipSelf,sipClass_PySemsDialog));
|
||||
|
||||
if (!sipCpp)
|
||||
return NULL;
|
||||
|
||||
if (valobj == NULL)
|
||||
{
|
||||
val = &sipCpp -> dlg;
|
||||
|
||||
valobj = sipMapCppToSelf(val,sipClass_AmSipDialog);
|
||||
|
||||
return valobj;
|
||||
}
|
||||
|
||||
val = reinterpret_cast<AmSipDialog *>(sipForceConvertTo_AmSipDialog(valobj,&iserr));
|
||||
|
||||
if (iserr)
|
||||
{
|
||||
sipBadSetType(sipNm_py_sems_PySemsDialog,sipNm_py_sems_dlg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sipCpp -> dlg = *val;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyMethodDef variables_PySemsDialog[] = {
|
||||
{sipNm_py_sems_dlg, var_PySemsDialog_dlg, 0, NULL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
static void *forceConvertTo_PySemsDialog(PyObject *valobj,int *iserrp)
|
||||
{
|
||||
if (*iserrp || valobj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (valobj == Py_None || sipIsSubClassInstance(valobj,sipClass_PySemsDialog))
|
||||
return sipConvertToCpp(valobj,sipClass_PySemsDialog,iserrp);
|
||||
|
||||
sipBadClass(sipNm_py_sems_PySemsDialog);
|
||||
|
||||
*iserrp = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef methods_PySemsDialog[] = {
|
||||
{sipNm_py_sems_acceptAudio, meth_PySemsDialog_acceptAudio, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onBye, meth_PySemsDialog_onBye, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onCancel, meth_PySemsDialog_onCancel, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onDtmf, meth_PySemsDialog_onDtmf, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onInvite, meth_PySemsDialog_onInvite, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onOtherBye, meth_PySemsDialog_onOtherBye, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onOtherReply, meth_PySemsDialog_onOtherReply, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_onSessionStart, meth_PySemsDialog_onSessionStart, METH_VARARGS, NULL},
|
||||
{sipNm_py_sems_setStopped, meth_PySemsDialog_setStopped, METH_VARARGS, NULL}
|
||||
};
|
||||
|
||||
|
||||
/* The main type data structure. */
|
||||
sipTypeDef sipType_PySemsDialog = {
|
||||
0,
|
||||
"py_sems.PySemsDialog",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
9, methods_PySemsDialog,
|
||||
0, 0,
|
||||
variables_PySemsDialog,
|
||||
init_PySemsDialog,
|
||||
dealloc_PySemsDialog,
|
||||
cast_PySemsDialog,
|
||||
forceConvertTo_PySemsDialog,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Interface header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsPySemsDialog_h
|
||||
#define _py_semsPySemsDialog_h
|
||||
|
||||
#line 6 "PySemsDialog.sip"
|
||||
#include "../PySems.h"
|
||||
#line 13 "sippy_semsPySemsDialog.h"
|
||||
|
||||
#include "sippy_semsAmSipDialog.h"
|
||||
#include "sippy_semsAmSipReply.h"
|
||||
#include "sippy_semsAmSipRequest.h"
|
||||
#include "sippy_semsstring.h"
|
||||
|
||||
|
||||
#define sipClass_PySemsDialog sipModuleAPI_py_sems.em_types[0]
|
||||
#define sipCast_PySemsDialog sipType_PySemsDialog.td_cast
|
||||
#define sipForceConvertTo_PySemsDialog sipType_PySemsDialog.td_fcto
|
||||
|
||||
extern sipTypeDef sipType_PySemsDialog;
|
||||
|
||||
|
||||
class sipPySemsDialog : public PySemsDialog
|
||||
{
|
||||
public:
|
||||
sipPySemsDialog();
|
||||
virtual ~sipPySemsDialog();
|
||||
|
||||
/*
|
||||
* There is a public method for every virtual method visible from
|
||||
* this class.
|
||||
*/
|
||||
void onInvite(const AmSipRequest&);
|
||||
void onSessionStart(const AmSipRequest&);
|
||||
void onBye(const AmSipRequest&);
|
||||
void onCancel();
|
||||
void onDtmf(int,int);
|
||||
void onOtherBye(const AmSipRequest&);
|
||||
void onOtherReply(const AmSipReply&);
|
||||
|
||||
sipWrapper *sipPySelf;
|
||||
|
||||
private:
|
||||
sipPySemsDialog(const sipPySemsDialog &);
|
||||
sipPySemsDialog &operator = (const sipPySemsDialog &);
|
||||
|
||||
sipMethodCache sipPyMethods[7];
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Module code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
|
||||
#include "sippy_semsPySemsDialog.h"
|
||||
#include "sippy_semsAmSipDialog.h"
|
||||
#include "sippy_semsAmSipReply.h"
|
||||
#include "sippy_semsAmSipRequest.h"
|
||||
#include "sippy_semsstring.h"
|
||||
|
||||
|
||||
|
||||
/* Define the strings used by this module. */
|
||||
char sipNm_py_sems_onOtherReply[] = "onOtherReply";
|
||||
char sipNm_py_sems_onOtherBye[] = "onOtherBye";
|
||||
char sipNm_py_sems_onDtmf[] = "onDtmf";
|
||||
char sipNm_py_sems_onCancel[] = "onCancel";
|
||||
char sipNm_py_sems_onBye[] = "onBye";
|
||||
char sipNm_py_sems_onSessionStart[] = "onSessionStart";
|
||||
char sipNm_py_sems_onInvite[] = "onInvite";
|
||||
char sipNm_py_sems_setStopped[] = "setStopped";
|
||||
char sipNm_py_sems_acceptAudio[] = "acceptAudio";
|
||||
char sipNm_py_sems_dlg[] = "dlg";
|
||||
char sipNm_py_sems_PySemsDialog[] = "PySemsDialog";
|
||||
char sipNm_py_sems_reinvite[] = "reinvite";
|
||||
char sipNm_py_sems_update[] = "update";
|
||||
char sipNm_py_sems_cancel[] = "cancel";
|
||||
char sipNm_py_sems_bye[] = "bye";
|
||||
char sipNm_py_sems_sendRequest[] = "sendRequest";
|
||||
char sipNm_py_sems_reply[] = "reply";
|
||||
char sipNm_py_sems_updateStatus[] = "updateStatus";
|
||||
char sipNm_py_sems_getContactHdr[] = "getContactHdr";
|
||||
char sipNm_py_sems_getStatus[] = "getStatus";
|
||||
char sipNm_py_sems_getUACTransPending[] = "getUACTransPending";
|
||||
char sipNm_py_sems_setRoute[] = "setRoute";
|
||||
char sipNm_py_sems_getRoute[] = "getRoute";
|
||||
char sipNm_py_sems_local_party[] = "local_party";
|
||||
char sipNm_py_sems_remote_party[] = "remote_party";
|
||||
char sipNm_py_sems_contact_uri[] = "contact_uri";
|
||||
char sipNm_py_sems_remote_uri[] = "remote_uri";
|
||||
char sipNm_py_sems_local_uri[] = "local_uri";
|
||||
char sipNm_py_sems_sip_port[] = "sip_port";
|
||||
char sipNm_py_sems_sip_ip[] = "sip_ip";
|
||||
char sipNm_py_sems_Disconnecting[] = "Disconnecting";
|
||||
char sipNm_py_sems_Connected[] = "Connected";
|
||||
char sipNm_py_sems_Pending[] = "Pending";
|
||||
char sipNm_py_sems_Disconnected[] = "Disconnected";
|
||||
char sipNm_py_sems_AmSipDialog[] = "AmSipDialog";
|
||||
char sipNm_py_sems_local_tag[] = "local_tag";
|
||||
char sipNm_py_sems_remote_tag[] = "remote_tag";
|
||||
char sipNm_py_sems_next_request_uri[] = "next_request_uri";
|
||||
char sipNm_py_sems_reason[] = "reason";
|
||||
char sipNm_py_sems_code[] = "code";
|
||||
char sipNm_py_sems_AmSipReply[] = "AmSipReply";
|
||||
char sipNm_py_sems_getHeader[] = "getHeader";
|
||||
char sipNm_py_sems_key[] = "key";
|
||||
char sipNm_py_sems_next_hop[] = "next_hop";
|
||||
char sipNm_py_sems_route[] = "route";
|
||||
char sipNm_py_sems_body[] = "body";
|
||||
char sipNm_py_sems_hdrs[] = "hdrs";
|
||||
char sipNm_py_sems_cseq[] = "cseq";
|
||||
char sipNm_py_sems_to_tag[] = "to_tag";
|
||||
char sipNm_py_sems_from_tag[] = "from_tag";
|
||||
char sipNm_py_sems_callid[] = "callid";
|
||||
char sipNm_py_sems_to[] = "to";
|
||||
char sipNm_py_sems_from[] = "from";
|
||||
char sipNm_py_sems_from_uri[] = "from_uri";
|
||||
char sipNm_py_sems_r_uri[] = "r_uri";
|
||||
char sipNm_py_sems_port[] = "port";
|
||||
char sipNm_py_sems_dstip[] = "dstip";
|
||||
char sipNm_py_sems_domain[] = "domain";
|
||||
char sipNm_py_sems_user[] = "user";
|
||||
char sipNm_py_sems_method[] = "method";
|
||||
char sipNm_py_sems_cmd[] = "cmd";
|
||||
char sipNm_py_sems_AmSipRequest[] = "AmSipRequest";
|
||||
char sipNm_py_sems_string[] = "string";
|
||||
|
||||
void sipVH_py_sems_0(sip_gilstate_t sipGILState,PyObject *sipMethod,const AmSipReply& a0)
|
||||
{
|
||||
PyObject *sipResObj = sipCallMethod(0,sipMethod,"O",const_cast<AmSipReply *>(&a0),sipClass_AmSipReply);
|
||||
|
||||
if (!sipResObj || sipParseResult(0,sipMethod,sipResObj,"Z") < 0)
|
||||
PyErr_Print();
|
||||
|
||||
Py_XDECREF(sipResObj);
|
||||
Py_DECREF(sipMethod);
|
||||
|
||||
SIP_RELEASE_GIL(sipGILState)
|
||||
}
|
||||
|
||||
void sipVH_py_sems_1(sip_gilstate_t sipGILState,PyObject *sipMethod,const AmSipRequest& a0)
|
||||
{
|
||||
PyObject *sipResObj = sipCallMethod(0,sipMethod,"O",const_cast<AmSipRequest *>(&a0),sipClass_AmSipRequest);
|
||||
|
||||
if (!sipResObj || sipParseResult(0,sipMethod,sipResObj,"Z") < 0)
|
||||
PyErr_Print();
|
||||
|
||||
Py_XDECREF(sipResObj);
|
||||
Py_DECREF(sipMethod);
|
||||
|
||||
SIP_RELEASE_GIL(sipGILState)
|
||||
}
|
||||
|
||||
void sipVH_py_sems_2(sip_gilstate_t sipGILState,PyObject *sipMethod,int a0,int a1)
|
||||
{
|
||||
PyObject *sipResObj = sipCallMethod(0,sipMethod,"ii",a0,a1);
|
||||
|
||||
if (!sipResObj || sipParseResult(0,sipMethod,sipResObj,"Z") < 0)
|
||||
PyErr_Print();
|
||||
|
||||
Py_XDECREF(sipResObj);
|
||||
Py_DECREF(sipMethod);
|
||||
|
||||
SIP_RELEASE_GIL(sipGILState)
|
||||
}
|
||||
|
||||
void sipVH_py_sems_3(sip_gilstate_t sipGILState,PyObject *sipMethod)
|
||||
{
|
||||
PyObject *sipResObj = sipCallMethod(0,sipMethod,"");
|
||||
|
||||
if (!sipResObj || sipParseResult(0,sipMethod,sipResObj,"Z") < 0)
|
||||
PyErr_Print();
|
||||
|
||||
Py_XDECREF(sipResObj);
|
||||
Py_DECREF(sipMethod);
|
||||
|
||||
SIP_RELEASE_GIL(sipGILState)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *func_getHeader(PyObject *,PyObject *sipArgs)
|
||||
{
|
||||
int sipArgsParsed = 0;
|
||||
|
||||
{
|
||||
const string * a0;
|
||||
int a0IsTemp = 0;
|
||||
const string * a1;
|
||||
int a1IsTemp = 0;
|
||||
|
||||
if (sipParseArgs(&sipArgsParsed,sipArgs,"M1M1",sipConvertTo_string,&a0,&a0IsTemp,sipConvertTo_string,&a1,&a1IsTemp))
|
||||
{
|
||||
string *sipRes;
|
||||
|
||||
sipRes = new string(getHeader(*a0,*a1));
|
||||
|
||||
if (a0IsTemp)
|
||||
delete const_cast<string *>(a0);
|
||||
|
||||
if (a1IsTemp)
|
||||
delete const_cast<string *>(a1);
|
||||
|
||||
PyObject *sipResObj = sipConvertFrom_string(sipRes);
|
||||
delete sipRes;
|
||||
|
||||
return sipResObj;
|
||||
}
|
||||
}
|
||||
|
||||
/* Raise an exception if the arguments couldn't be parsed. */
|
||||
sipNoFunction(sipArgsParsed,sipNm_py_sems_getHeader);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This defines each class in this module. The values are replaced by the
|
||||
* proper Python types during the export process.
|
||||
*/
|
||||
static sipWrapperType *typesTable[] = {
|
||||
(sipWrapperType *)&sipType_PySemsDialog,
|
||||
(sipWrapperType *)&sipType_AmSipDialog,
|
||||
(sipWrapperType *)&sipType_AmSipReply,
|
||||
(sipWrapperType *)&sipType_AmSipRequest,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
/* This defines each mapped type in this module. */
|
||||
static sipMappedTypeDef *mappedTypesTable[] = {
|
||||
&sipMappedType_string,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* This defines the virtual handlers that this module implements and can be
|
||||
* used by other modules.
|
||||
*/
|
||||
static sipVirtHandlerFunc virtHandlersTable[] = {
|
||||
(sipVirtHandlerFunc)sipVH_py_sems_0,
|
||||
(sipVirtHandlerFunc)sipVH_py_sems_1,
|
||||
(sipVirtHandlerFunc)sipVH_py_sems_2,
|
||||
(sipVirtHandlerFunc)sipVH_py_sems_3,
|
||||
};
|
||||
|
||||
|
||||
/* This defines this module. */
|
||||
sipExportedModuleDef sipModuleAPI_py_sems = {
|
||||
NULL,
|
||||
"py_sems",
|
||||
0,
|
||||
NULL,
|
||||
-1,
|
||||
typesTable,
|
||||
mappedTypesTable,
|
||||
virtHandlersTable,
|
||||
NULL,
|
||||
{NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* The SIP API and the APIs of any imported modules. */
|
||||
const sipAPIDef *sipAPI_py_sems;
|
||||
|
||||
|
||||
/* The Python module initialisation function. */
|
||||
PyMODINIT_FUNC initpy_sems()
|
||||
{
|
||||
static PyMethodDef methods[] = {
|
||||
{sipNm_py_sems_getHeader, func_getHeader, METH_VARARGS, NULL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Initialise the module. */
|
||||
PyObject *mod = Py_InitModule(sipModuleAPI_py_sems.em_name,methods);
|
||||
PyObject *mdict = PyModule_GetDict(mod);
|
||||
|
||||
/* Import the SIP module and get it's API. */
|
||||
PyObject *sipmod = PyImport_ImportModule("sip");
|
||||
|
||||
if (sipmod == NULL)
|
||||
return;
|
||||
|
||||
PyObject *capiobj = PyDict_GetItemString(PyModule_GetDict(sipmod),"_C_API");
|
||||
|
||||
if (capiobj == NULL || !PyCObject_Check(capiobj))
|
||||
return;
|
||||
|
||||
sipAPI_py_sems = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(capiobj));
|
||||
|
||||
/* Export the module and publish it's API. */
|
||||
if (sipAPI_py_sems -> api_export_module(&sipModuleAPI_py_sems,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,mdict) < 0)
|
||||
return;
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Interface wrapper code.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#include "sipAPIpy_sems.h"
|
||||
#include "sippy_semsstring.h"
|
||||
|
||||
|
||||
|
||||
static int convertTo_string(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr)
|
||||
{
|
||||
string **sipCppPtr = reinterpret_cast<string **>(sipCppPtrV);
|
||||
|
||||
#line 14 "string.sip"
|
||||
// Allow a Python string whenever a string is expected.
|
||||
if (sipIsErr == NULL)
|
||||
return PyString_Check(sipPy);
|
||||
if (sipPy == Py_None) {
|
||||
*sipCppPtr = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (PyString_Check(sipPy)) {
|
||||
*sipCppPtr = new std::string(PyString_AS_STRING(sipPy));
|
||||
return 0;
|
||||
}
|
||||
*sipCppPtr = (std::string *)sipForceConvertTo_string(sipPy,sipIsErr);
|
||||
return 1;
|
||||
#line 31 "sippy_semsstring.cpp"
|
||||
}
|
||||
|
||||
|
||||
static void *forceConvertTo_string(PyObject *valobj,int *iserrp)
|
||||
{
|
||||
if (*iserrp || valobj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (convertTo_string(valobj,NULL,NULL))
|
||||
{
|
||||
void *val;
|
||||
|
||||
convertTo_string(valobj,&val,iserrp);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
sipBadClass(sipNm_py_sems_string);
|
||||
|
||||
*iserrp = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *convertFrom_string(void *sipCppV)
|
||||
{
|
||||
string *sipCpp = reinterpret_cast<string *>(sipCppV);
|
||||
|
||||
#line 9 "string.sip"
|
||||
const char *s = sipCpp->c_str();
|
||||
return PyString_FromString(s);
|
||||
#line 64 "sippy_semsstring.cpp"
|
||||
}
|
||||
|
||||
|
||||
sipMappedTypeDef sipMappedType_string = {
|
||||
forceConvertTo_string,
|
||||
convertTo_string,
|
||||
convertFrom_string
|
||||
};
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Interface header file.
|
||||
*
|
||||
* Generated by SIP 4.1.1 (4.1.1-255) on Fri Feb 9 10:28:23 2007
|
||||
*/
|
||||
|
||||
#ifndef _py_semsstring_h
|
||||
#define _py_semsstring_h
|
||||
|
||||
|
||||
|
||||
#line 4 "string.sip"
|
||||
#include <string>
|
||||
using std::string;
|
||||
#line 16 "sippy_semsstring.h"
|
||||
|
||||
|
||||
#define sipForceConvertTo_string sipMappedType_string.mt_fcto
|
||||
#define sipConvertTo_string sipMappedType_string.mt_cto
|
||||
#define sipConvertFrom_string sipMappedType_string.mt_cfrom
|
||||
|
||||
extern sipMappedTypeDef sipMappedType_string;
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,29 @@
|
||||
%MappedType string
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <string>
|
||||
using std::string;
|
||||
%End
|
||||
|
||||
%ConvertFromTypeCode
|
||||
const char *s = sipCpp->c_str();
|
||||
return PyString_FromString(s);
|
||||
%End
|
||||
|
||||
%ConvertToTypeCode
|
||||
// Allow a Python string whenever a string is expected.
|
||||
if (sipIsErr == NULL)
|
||||
return PyString_Check(sipPy);
|
||||
if (sipPy == Py_None) {
|
||||
*sipCppPtr = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (PyString_Check(sipPy)) {
|
||||
*sipCppPtr = new std::string(PyString_AS_STRING(sipPy));
|
||||
return 0;
|
||||
}
|
||||
*sipCppPtr = (std::string *)sipForceConvertTo_string(sipPy,sipIsErr);
|
||||
return 1;
|
||||
%End
|
||||
};
|
||||
|
||||
Loading…
Reference in new issue