Changeset 3021 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Nov 20, 2009 11:33:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r3019 r3021 102 102 unsigned auto_answer; 103 103 unsigned duration; 104 pj_bool_t unsolicited_mwi;105 104 106 105 #ifdef STEREO_DEMO … … 146 145 static pj_status_t create_ipv6_media_transports(void); 147 146 pj_status_t app_destroy(void); 148 static void enable_unsolicited_mwi(void);149 147 150 148 static void ringback_start(pjsua_call_id call_id); … … 197 195 puts (" --publish Send presence PUBLISH for this account"); 198 196 puts (" --mwi Subscribe to message summary/waiting indication"); 199 puts (" --unsolicited-mwi Handle unsolicited MWI requests");200 197 puts (" --use-100rel Require reliable provisional response (100rel)"); 201 198 puts (" --use-timer Require SIP session timers"); … … 488 485 OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, 489 486 OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 490 OPT_MWI, OPT_ UNSOLICITED_MWI, OPT_NAMESERVER, OPT_STUN_SRV,487 OPT_MWI, OPT_NAMESERVER, OPT_STUN_SRV, 491 488 OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 492 489 OPT_AUTO_ANSWER, OPT_AUTO_PLAY, OPT_AUTO_PLAY_HANGUP, OPT_AUTO_LOOP, … … 541 538 { "publish", 0, 0, OPT_PUBLISH}, 542 539 { "mwi", 0, 0, OPT_MWI}, 543 { "unsolicited-mwi", 0, 0, OPT_UNSOLICITED_MWI},544 540 { "use-100rel", 0, 0, OPT_100REL}, 545 541 { "use-ims", 0, 0, OPT_USE_IMS}, … … 844 840 break; 845 841 846 case OPT_UNSOLICITED_MWI:847 cfg->unsolicited_mwi = PJ_TRUE;848 break;849 850 842 case OPT_100REL: /** 100rel */ 851 843 cur_acc->require_100rel = PJ_TRUE; … … 1999 1991 { 2000 1992 pj_strcat2(&cfg, "--use-compact-form\n"); 2001 }2002 2003 if (config->unsolicited_mwi) {2004 pj_strcat2(&cfg, "--unsolicited-mwi\n");2005 1993 } 2006 1994 … … 4408 4396 return status; 4409 4397 4410 /* Initialize unsolicited MWI */4411 if (app_config.unsolicited_mwi)4412 enable_unsolicited_mwi();4413 4414 4398 /* Initialize our module to handle otherwise unhandled request */ 4415 4399 status = pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), … … 5016 5000 } 5017 5001 5018 /*****************************************************************************5019 * Asterisk unsolicited MWI module5020 */5021 static pj_bool_t mwi_on_rx_request(pjsip_rx_data *rdata)5022 {5023 pjsip_msg *msg = rdata->msg_info.msg;5024 pj_str_t EVENT_HDR = { "Event", 5 };5025 pj_str_t MWI = { "message-summary", 15 };5026 pjsip_event_hdr *eh;5027 pj_str_t body;5028 5029 if (pjsip_method_cmp(&msg->line.req.method, &pjsip_notify_method)!=0) {5030 /* Only interested with NOTIFY request */5031 return PJ_FALSE;5032 }5033 5034 eh = (pjsip_event_hdr*) pjsip_msg_find_hdr_by_name(msg, &EVENT_HDR, NULL);5035 if (!eh) {5036 /* Something wrong with the request, it has no Event hdr */5037 return PJ_FALSE;5038 }5039 5040 if (pj_stricmp(&eh->event_type, &MWI) != 0) {5041 /* Not MWI event */5042 return PJ_FALSE;5043 }5044 5045 /* Got unsolicited MWI request, respond with 200/OK first */5046 pjsip_endpt_respond(pjsua_get_pjsip_endpt(), NULL, rdata, 200, NULL,5047 NULL, NULL, NULL);5048 5049 5050 PJ_LOG(3,(THIS_FILE, "Received MWI info:"));5051 5052 if (rdata->msg_info.ctype) {5053 const pjsip_ctype_hdr *ctype = rdata->msg_info.ctype;5054 5055 PJ_LOG(3,(THIS_FILE, " Content-Type: %.*s/%.*s",5056 (int)ctype->media.type.slen,5057 ctype->media.type.ptr,5058 (int)ctype->media.subtype.slen,5059 ctype->media.subtype.ptr));5060 }5061 5062 if (!rdata->msg_info.msg->body) {5063 PJ_LOG(3,(THIS_FILE, " no message body"));5064 return PJ_TRUE;5065 }5066 5067 body.ptr = rdata->msg_info.msg->body->data;5068 body.slen = rdata->msg_info.msg->body->len;5069 5070 PJ_LOG(3,(THIS_FILE, " Body:\n%.*s", (int)body.slen, body.ptr));5071 5072 return PJ_TRUE;5073 }5074 5075 /* The module instance. */5076 static pjsip_module pjsua_mwi_mod =5077 {5078 NULL, NULL, /* prev, next. */5079 { "mod-unsolicited-mwi", 19 }, /* Name. */5080 -1, /* Id */5081 PJSIP_MOD_PRIORITY_UA_PROXY_LAYER-1,/* Priority */5082 NULL, /* load() */5083 NULL, /* start() */5084 NULL, /* stop() */5085 NULL, /* unload() */5086 &mwi_on_rx_request, /* on_rx_request() */5087 NULL, /* on_rx_response() */5088 NULL, /* on_tx_request. */5089 NULL, /* on_tx_response() */5090 NULL, /* on_tsx_state() */5091 };5092 5093 static void enable_unsolicited_mwi(void)5094 {5095 pj_status_t status;5096 5097 status = pjsip_endpt_register_module(pjsua_get_pjsip_endpt(),5098 &pjsua_mwi_mod);5099 if (status != PJ_SUCCESS)5100 pjsua_perror(THIS_FILE, "Error registering MWI module", status);5101 }5102
Note: See TracChangeset
for help on using the changeset viewer.