Skip to content

Commit

Permalink
Implement ticket #982: Support for SIP Message Summary/Message Waitin…
Browse files Browse the repository at this point in the history
…g Indication (MWI, RFC 3842)

 - PJSIP-SIMPLE:
    - implement MWI
 - PJSUA-LIB:
    - added "mwi_enabled" flag in account config
    - added "on_mwi_info" callback
 - pjsua app:
    - added "--mwi" option to enable MWI on account
    - added simple callback to log the NOTIFY message
 - other:
     - added SIPp scenario files to simulate UAS side
 - build:
     - added MWI support on VS6, VS2005, MMP, and Makefile


git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2968 74dad513-b988-da41-8d7b-12977e46ad98
  • Loading branch information
bennylp committed Oct 26, 2009
1 parent 610973a commit 4dd961b
Show file tree
Hide file tree
Showing 16 changed files with 1,678 additions and 314 deletions.
1 change: 1 addition & 0 deletions build.symbian/pjsip_simple.mmp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SOURCE errno.c
SOURCE evsub.c
SOURCE evsub_msg.c
SOURCE iscomposing.c
SOURCE mwi.c
SOURCE pidf.c
SOURCE presence.c
SOURCE presence_body.c
Expand Down
47 changes: 46 additions & 1 deletion pjsip-apps/src/pjsua/pjsua_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static void usage(void)
puts (" --username=string Set authentication username");
puts (" --password=string Set authentication password");
puts (" --publish Send presence PUBLISH for this account");
puts (" --mwi Subscribe to message summary/waiting indication");
puts (" --use-100rel Require reliable provisional response (100rel)");
puts (" --use-timer Require SIP session timers");
puts (" --timer-se=N Session timers expiration period, in secs (def:1800)");
Expand Down Expand Up @@ -483,7 +484,7 @@ static pj_status_t parse_args(int argc, char *argv[],
OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT,
OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS,
OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
OPT_NAMESERVER, OPT_STUN_SRV,
OPT_MWI, OPT_NAMESERVER, OPT_STUN_SRV,
OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
OPT_AUTO_ANSWER, OPT_AUTO_PLAY, OPT_AUTO_PLAY_HANGUP, OPT_AUTO_LOOP,
OPT_AUTO_CONF, OPT_CLOCK_RATE, OPT_SND_CLOCK_RATE, OPT_STEREO,
Expand Down Expand Up @@ -535,6 +536,7 @@ static pj_status_t parse_args(int argc, char *argv[],
{ "registrar", 1, 0, OPT_REGISTRAR},
{ "reg-timeout",1, 0, OPT_REG_TIMEOUT},
{ "publish", 0, 0, OPT_PUBLISH},
{ "mwi", 0, 0, OPT_MWI},
{ "use-100rel", 0, 0, OPT_100REL},
{ "use-ims", 0, 0, OPT_USE_IMS},
{ "id", 1, 0, OPT_ID},
Expand Down Expand Up @@ -833,6 +835,10 @@ static pj_status_t parse_args(int argc, char *argv[],
cur_acc->publish_enabled = PJ_TRUE;
break;

case OPT_MWI: /* mwi */
cur_acc->mwi_enabled = PJ_TRUE;
break;

case OPT_100REL: /** 100rel */
cur_acc->require_100rel = PJ_TRUE;
cfg->cfg.require_100rel = PJ_TRUE;
Expand Down Expand Up @@ -1550,6 +1556,13 @@ static void write_account_settings(int acc_index, pj_str_t *result)
pj_strcat2(result, line);
}

/* Publish */
if (acc_cfg->publish_enabled)
pj_strcat2(result, "--publish\n");

/* MWI */
if (acc_cfg->mwi_enabled)
pj_strcat2(result, "--mwi\n");
}


Expand Down Expand Up @@ -2742,6 +2755,37 @@ static void on_nat_detect(const pj_stun_nat_detect_result *res)
}


/*
* MWI indication
*/
static void on_mwi_info(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info)
{
pj_str_t body;

PJ_LOG(3,(THIS_FILE, "Received MWI for acc %d:", acc_id));

if (mwi_info->rdata->msg_info.ctype) {
const pjsip_ctype_hdr *ctype = mwi_info->rdata->msg_info.ctype;

PJ_LOG(3,(THIS_FILE, " Content-Type: %.*s/%.*s",
(int)ctype->media.type.slen,
ctype->media.type.ptr,
(int)ctype->media.subtype.slen,
ctype->media.subtype.ptr));
}

if (!mwi_info->rdata->msg_info.msg->body) {
PJ_LOG(3,(THIS_FILE, " no message body"));
return;
}

body.ptr = mwi_info->rdata->msg_info.msg->body->data;
body.slen = mwi_info->rdata->msg_info.msg->body->len;

PJ_LOG(3,(THIS_FILE, " Body:\n%.*s", (int)body.slen, body.ptr));
}


/*
* Print buddy list.
*/
Expand Down Expand Up @@ -4337,6 +4381,7 @@ pj_status_t app_init(int argc, char *argv[])
app_config.cfg.cb.on_call_transfer_status = &on_call_transfer_status;
app_config.cfg.cb.on_call_replaced = &on_call_replaced;
app_config.cfg.cb.on_nat_detect = &on_nat_detect;
app_config.cfg.cb.on_mwi_info = &on_mwi_info;

/* Set sound device latency */
if (app_config.capture_lat > 0)
Expand Down
2 changes: 1 addition & 1 deletion pjsip/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export PJSIP_UA_CFLAGS += $(_CFLAGS)
export PJSIP_SIMPLE_SRCDIR = ../src/pjsip-simple
export PJSIP_SIMPLE_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
errno.o evsub.o evsub_msg.o iscomposing.o \
pidf.o presence.o presence_body.o publishc.o \
mwi.o pidf.o presence.o presence_body.o publishc.o \
rpid.o xpidf.o
export PJSIP_SIMPLE_CFLAGS += $(_CFLAGS)

Expand Down
Loading

0 comments on commit 4dd961b

Please sign in to comment.