summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_im.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-06-06 18:40:40 +0000
committerBenny Prijono <bennylp@teluu.com>2006-06-06 18:40:40 +0000
commit8db4ef281d67eee2ebeac22a31bc1961e96d78b2 (patch)
treeb910ef526c864da15ab3d05840fc78ff8c6c7608 /pjsip/src/pjsua-lib/pjsua_im.c
parent40d75a0cb404fc0bafa20934e992befd0eab673b (diff)
Another huge chunks of modifications in PJSUA API, too many things to mention!
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@492 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_im.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_im.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_im.c b/pjsip/src/pjsua-lib/pjsua_im.c
index efd8cbf6..807f2fac 100644
--- a/pjsip/src/pjsua-lib/pjsua_im.c
+++ b/pjsip/src/pjsua-lib/pjsua_im.c
@@ -185,6 +185,7 @@ static pj_bool_t im_on_rx_request(pjsip_rx_data *rdata)
{
pj_str_t from, to;
pjsip_accept_hdr *accept_hdr;
+ pjsip_contact_hdr *contact_hdr;
pjsip_msg *msg;
pj_status_t status;
@@ -221,11 +222,23 @@ static pj_bool_t im_on_rx_request(pjsip_rx_data *rdata)
status = pjsip_endpt_respond( pjsua.endpt, NULL, rdata, 200, NULL,
NULL, NULL, NULL);
- /* Build the From text. */
+ /* For the source URI, we use Contact header if present, since
+ * Contact header contains the port number information. If this is
+ * not available, then use From header.
+ */
from.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
- from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
- rdata->msg_info.from->uri,
- from.ptr, PJSIP_MAX_URL_SIZE);
+ contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg,
+ PJSIP_H_CONTACT, NULL);
+ if (contact_hdr) {
+ from.slen = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR,
+ contact_hdr->uri,
+ from.ptr, PJSIP_MAX_URL_SIZE);
+ } else {
+ from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
+ rdata->msg_info.from->uri,
+ from.ptr, PJSIP_MAX_URL_SIZE);
+ }
+
if (from.slen < 1)
from = pj_str("<--URI is too long-->");
@@ -336,6 +349,7 @@ PJ_DEF(pj_status_t) pjsua_im_send(int acc_index, const pj_str_t *dst_uri,
PJ_DEF(pj_status_t) pjsua_im_typing(int acc_index, const pj_str_t *dst_uri,
pj_bool_t is_typing)
{
+ const pj_str_t STR_CONTACT = { "Contact", 7 };
pjsip_tx_data *tdata;
pj_status_t status;
@@ -350,6 +364,18 @@ PJ_DEF(pj_status_t) pjsua_im_typing(int acc_index, const pj_str_t *dst_uri,
}
+ /* Add accept header. */
+ pjsip_msg_add_hdr( tdata->msg,
+ (pjsip_hdr*)pjsua_im_create_accept(tdata->pool));
+
+
+ /* Add contact. */
+ pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
+ pjsip_generic_string_hdr_create(tdata->pool,
+ &STR_CONTACT,
+ &pjsua.config.acc_config[acc_index].contact));
+
+
/* Create "application/im-iscomposing+xml" msg body. */
tdata->msg->body = pjsip_iscomposing_create_body( tdata->pool, is_typing,
NULL, NULL, -1);