added a session.select(name) function to access select of a session.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1653 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 17 years ago
parent 609995aa79
commit 101d7f9f97

@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (C) 2009 TelTech Systems
* Copyright (C) 2009 IPTEGO GmbH
*
* This file is part of SEMS, a free SIP media server.
*

@ -29,6 +29,7 @@
#include "PyDSMSession.h"
#include "log.h"
#include "DSMSession.h"
#include "AmSession.h"
extern "C" {
@ -75,6 +76,42 @@ extern "C" {
return PyString_FromString(sess->var[varname].c_str());
}
static PyObject* mod_py_getselect(PyObject*, PyObject* args)
{
char *varname;
if(!PyArg_ParseTuple(args,"s",&varname))
return NULL;
GET_SESS_PTR;
string res;
AmSession* sc_sess = dynamic_cast<AmSession*>(sess);
if (NULL == sc_sess) {
ERROR("Not possible to cast to session object.\n");
return NULL;
}
if (!strcmp("local_tag", varname))
res = sc_sess->getLocalTag();
else if (!strcmp("user", varname))
res = sc_sess->dlg.user;
else if (!strcmp("domain", varname))
res = sc_sess->dlg.domain;
else if (!strcmp("remote_tag", varname))
res = sc_sess->getRemoteTag();
else if (!strcmp("callid", varname))
res = sc_sess->getCallID();
else if (!strcmp("local_uri", varname))
res = sc_sess->dlg.local_uri;
else if (!strcmp("remote_uri", varname))
res = sc_sess->dlg.remote_uri;
DBG("returning '%s'\n", res.c_str());
return PyString_FromString(res.c_str());
}
static PyObject* mod_py_seterror(PyObject*, PyObject* args)
{
int errno;
@ -301,6 +338,7 @@ extern "C" {
PyMethodDef session_methods[] = {
{"setvar", (PyCFunction)mod_py_setvar, METH_VARARGS,"set a session's variable"},
{"var", (PyCFunction)mod_py_getvar, METH_VARARGS,"get a session's variable"},
{"select", (PyCFunction)mod_py_getselect, METH_VARARGS,"get a session's select"},
{"setError", (PyCFunction)mod_py_seterror, METH_VARARGS,"set error (errno)"},
{"playPrompt", (PyCFunction)playPrompt, METH_VARARGS,"play a prompt"},

@ -142,6 +142,9 @@ FUNCTIONS
recordFile(string name)
start recording to a file
select(string name)
get a session's select
setError(int errno)
set error (errno)

Loading…
Cancel
Save