summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-12-11 11:03:21 +0000
committerBenny Prijono <bennylp@teluu.com>2008-12-11 11:03:21 +0000
commite0c99c6af3297030d0618cadbcb2067672fd2c1e (patch)
tree6d0d27342e1f2fa38ff6812e9a0579a25c2678f3
parenteb5756d2c401568e24c448776cc1a914b57b80b0 (diff)
Ticket #681: Bugs in sending and receiving instant messages in Python wrapper (thanks Johan Risberg for the patches)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2374 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/python/_pjsua.c4
-rw-r--r--pjsip-apps/src/python/pjsua.py29
2 files changed, 29 insertions, 4 deletions
diff --git a/pjsip-apps/src/python/_pjsua.c b/pjsip-apps/src/python/_pjsua.c
index 77c4bb73..a84796fa 100644
--- a/pjsip-apps/src/python/_pjsua.c
+++ b/pjsip-apps/src/python/_pjsua.c
@@ -2137,6 +2137,8 @@ static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs)
to = PyString_ToPJ(pTo);
content = PyString_ToPJ(pContent);
+ pjsua_msg_data_init(&msg_data);
+
if (pMsgData != Py_None) {
PyObj_pjsua_msg_data *omd;
@@ -2179,6 +2181,8 @@ static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs)
to = PyString_ToPJ(pTo);
+ pjsua_msg_data_init(&msg_data);
+
if (pMsgData != Py_None) {
PyObj_pjsua_msg_data *omd;
diff --git a/pjsip-apps/src/python/pjsua.py b/pjsip-apps/src/python/pjsua.py
index 8c573695..90dad86b 100644
--- a/pjsip-apps/src/python/pjsua.py
+++ b/pjsip-apps/src/python/pjsua.py
@@ -1672,7 +1672,28 @@ class Call:
err = _pjsua.call_send_request(self._id, method, msg_data)
self._lib()._err_check("send_request()", self, err)
+ def send_pager(self, text, im_id=0, content_type="text/plain",
+ hdr_list=None):
+ """Send instant message inside a call.
+ Keyword arguments:
+ text -- Instant message to be sent
+ im_id -- Optional instant message ID to identify this
+ instant message when delivery status callback
+ is called.
+ content_type -- MIME type identifying the instant message
+ hdr_list -- Optional list of headers to be sent with the
+ request.
+
+ """
+ lck = self._lib().auto_lock()
+ err = _pjsua.call_send_im(self._id, \
+ content_type, text, \
+ Lib._create_msg_data(hdr_list), \
+ im_id)
+ self._lib()._err_check("send_pager()", self, err)
+
+
class BuddyInfo:
"""This class contains information about Buddy. Application may
retrieve this information by calling Buddy.info().
@@ -2084,7 +2105,7 @@ class Lib:
while self._quit != 2 and loop < 400:
self.handle_events(5)
loop = loop + 1
- time.sleep(0.050)
+ time.sleep(0.050)
_pjsua.destroy()
_lib = None
@@ -2664,7 +2685,7 @@ class Lib:
def _cb_on_pager(self, call_id, from_uri, to_uri, contact, mime_type,
body, acc_id):
call = None
- if call_id == -1:
+ if call_id != -1:
call = self._lookup_call(call_id)
if call:
call._cb.on_pager(mime_type, body)
@@ -2679,7 +2700,7 @@ class Lib:
def _cb_on_pager_status(self, call_id, to_uri, body, user_data,
code, reason, acc_id):
call = None
- if call_id == -1:
+ if call_id != -1:
call = self._lookup_call(call_id)
if call:
call._cb.on_pager_status(body, user_data, code, reason)
@@ -2694,7 +2715,7 @@ class Lib:
def _cb_on_typing(self, call_id, from_uri, to_uri, contact, is_typing,
acc_id):
call = None
- if call_id == -1:
+ if call_id != -1:
call = self._lookup_call(call_id)
if call:
call._cb.on_typing(is_typing)