From 5ed292db40fb2b12eb020c44990d84c3058aee2e Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Mon, 3 Mar 2008 21:31:47 +0000 Subject: [PATCH] function to modify invite_req git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@766 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- apps/ivr/IvrDialogBase.cpp | 26 ++++++++++++++++++++++++-- apps/ivr/IvrSipRequest.cpp | 21 ++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/apps/ivr/IvrDialogBase.cpp b/apps/ivr/IvrDialogBase.cpp index 9ad3b560..e7b2d77d 100644 --- a/apps/ivr/IvrDialogBase.cpp +++ b/apps/ivr/IvrDialogBase.cpp @@ -5,6 +5,7 @@ #include "Ivr.h" #include "IvrSipDialog.h" +#include "IvrSipRequest.h" #include "AmMediaProcessor.h" @@ -13,6 +14,7 @@ typedef struct { PyObject_HEAD PyObject* dialog; + PyObject* invite_req; IvrDialog* p_dlg; } IvrDialogBase; @@ -44,13 +46,22 @@ static PyObject* IvrDialogBase_new(PyTypeObject *type, PyObject *args, PyObject // initialize self.dialog self->dialog = IvrSipDialog_FromPtr(&self->p_dlg->dlg); - if(!self->dialog){ PyErr_Print(); ERROR("IvrDialogBase: while creating IvrSipDialog instance\n"); Py_DECREF(self); return NULL; } + + // initialize self.invite_req + self->invite_req = IvrSipRequest_FromPtr(self->p_dlg->getInviteReq()); + if(!self->invite_req){ + PyErr_Print(); + ERROR("IvrDialogBase: while creating IvrSipRequest instance for invite_req\n"); + Py_DECREF(self); + return NULL; + } + } DBG("IvrDialogBase_new\n"); @@ -442,6 +453,13 @@ static PyObject* IvrDialogBase_removeTimers(IvrDialogBase* self, PyObject* args) return Py_None; } +static PyObject* +IvrDialogBase_getinvite_req(IvrDialogBase *self, void *closure) +{ + Py_INCREF(self->invite_req); + return self->invite_req; +} + static PyObject* IvrDialogBase_getdialog(IvrDialogBase *self, void *closure) { @@ -570,7 +588,11 @@ static PyMethodDef IvrDialogBase_methods[] = { static PyGetSetDef IvrDialogBase_getset[] = { {"dialog", (getter)IvrDialogBase_getdialog, NULL, - "the dialog class", + "the dialog property", + NULL}, + {"invite_req", + (getter)IvrDialogBase_getinvite_req, NULL, + "the initial invite request", NULL}, {NULL} /* Sentinel */ }; diff --git a/apps/ivr/IvrSipRequest.cpp b/apps/ivr/IvrSipRequest.cpp index eb642ef7..dc724554 100644 --- a/apps/ivr/IvrSipRequest.cpp +++ b/apps/ivr/IvrSipRequest.cpp @@ -93,7 +93,9 @@ def_IvrSipRequest_GETTER(IvrSipRequest_getnext_hop, next_hop) def_IvrSipRequest_GETTER(IvrSipRequest_getbody, body) +def_IvrSipRequest_GETTER(IvrSipRequest_gethdrs, hdrs) +#undef def_IvrSipRequest_GETTER // static PyObject* // IvrSipRequest_getuser(IvrSipRequest *self, void *closure) // { @@ -106,6 +108,22 @@ IvrSipRequest_getcseq(IvrSipRequest *self, void *closure) return PyInt_FromLong(self->p_req->cseq); } +#define def_IvrSipRequest_SETTER(setter_name, attr) \ + static int \ + setter_name(IvrSipRequest *self, PyObject* value, void *closure) \ + { \ + char* text; \ + if(!PyArg_Parse(value,"s",&text)) \ + return -1; \ + \ + self->p_req->attr = text; \ + return 0; \ + } + +def_IvrSipRequest_SETTER(IvrSipRequest_sethdrs, hdrs) + +#undef def_IvrSipRequest_SETTER + static PyGetSetDef IvrSipRequest_getset[] = { {"method", (getter)IvrSipRequest_getmethod, NULL, "method", NULL}, {"user", (getter)IvrSipRequest_getuser, NULL, "local user", NULL}, @@ -125,7 +143,8 @@ static PyGetSetDef IvrSipRequest_getset[] = { {"route", (getter)IvrSipRequest_getroute, NULL, "record routing", NULL}, {"next_hop", (getter)IvrSipRequest_getnext_hop, NULL, "next_hop for t_uac_dlg", NULL}, {"cseq", (getter)IvrSipRequest_getcseq, NULL, "CSeq for next request", NULL}, - {"body", (getter)IvrSipRequest_getbody, NULL, "CSeq for next request", NULL}, + {"body", (getter)IvrSipRequest_getbody, NULL, "Body", NULL}, + {"hdrs", (getter)IvrSipRequest_gethdrs, (setter)IvrSipRequest_sethdrs, "Additional headers", NULL}, {NULL} /* Sentinel */ };