[asterisk-commits] mmichelson: branch mmichelson/pub_sub r385592 - /team/mmichelson/pub_sub/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 12 17:30:36 CDT 2013
Author: mmichelson
Date: Fri Apr 12 17:30:33 2013
New Revision: 385592
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385592
Log:
This gets unsolicited MWI working...almost.
The issue here is that the Polycom phone I'm sending the NOTIFY to does not
use the NOTIFY to create a dialog. This means that when we send subsequent
NOTIFYs with to-tags, the Polycom sends a 481 and does not update its message
waiting indicator.
Modified:
team/mmichelson/pub_sub/res/res_sip_mwi.c
Modified: team/mmichelson/pub_sub/res/res_sip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_mwi.c?view=diff&rev=385592&r1=385591&r2=385592
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_mwi.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_mwi.c Fri Apr 12 17:30:33 2013
@@ -229,18 +229,36 @@
reason_str_ptr = &reason_str;
}
/* XXX Not sure if the \r\n is actually necessary */
- ast_str_append(&body, 0, "%d/%d(0/0)\r\n", counter.new_msgs, counter.old_msgs);
+ ast_str_append(&body, 0, "Messages-Waiting: %s\r\n", counter.new_msgs ? "yes" : "no");
+ ast_str_append(&body, 0, "Voice-Message: %d/%d (0/0)\r\n", counter.new_msgs, counter.old_msgs);
pj_cstr(&pj_body, ast_str_buffer(body));
- pjsip_mwi_notify(ast_sip_subscription_get_evsub(sub->sip_sub),
- state,
- NULL,
- reason_str_ptr,
- &mwi_type,
- &pj_body,
- &tdata);
-
- ast_sip_subscription_send_request(sub->sip_sub, tdata);
+ if (sub->is_solicited) {
+ if (pjsip_mwi_notify(ast_sip_subscription_get_evsub(sub->sip_sub),
+ state,
+ NULL,
+ reason_str_ptr,
+ &mwi_type,
+ &pj_body,
+ &tdata) != PJ_SUCCESS) {
+ ast_log(LOG_WARNING, "Unable to create MWI NOTIFY request.\n");
+ }
+ } else {
+ pjsip_msg_body *msg_body;
+ if (pjsip_evsub_notify(ast_sip_subscription_get_evsub(sub->sip_sub),
+ state,
+ NULL,
+ reason_str_ptr,
+ &tdata) != PJ_SUCCESS) {
+ ast_log(LOG_WARNING, "Unable to create MWI NOTIFY request.\n");
+ }
+ msg_body = pjsip_msg_body_create(tdata->pool, &mwi_type.type, &mwi_type.subtype, &pj_body);
+ tdata->msg->body = msg_body;
+ }
+
+ if (ast_sip_subscription_send_request(sub->sip_sub, tdata) != PJ_SUCCESS) {
+ ast_log(LOG_NOTICE, "Unable to send MWI NOTIFY request\n");
+ }
}
static void mwi_subscription_shutdown(struct ast_sip_subscription *sub)
@@ -378,16 +396,27 @@
return 0;
}
+static int serialized_notify(void *userdata)
+{
+ struct mwi_subscription *mwi_sub = userdata;
+
+ send_mwi_notify(mwi_sub, PJSIP_EVSUB_STATE_ACTIVE, NULL);
+ return 0;
+}
+
static void mwi_stasis_cb(void *userdata, struct stasis_subscription *sub,
struct stasis_topic *topic, struct stasis_message *msg)
{
struct mwi_subscription *mwi_sub = userdata;
+
if (stasis_subscription_final_message(sub, msg)) {
ao2_cleanup(mwi_sub);
return;
}
+
if (stasis_mwi_state_type() == stasis_message_type(msg)) {
- send_mwi_notify(mwi_sub, PJSIP_EVSUB_STATE_ACTIVE, NULL);
+ struct ast_taskprocessor *serializer = ast_sip_subscription_get_serializer(mwi_sub->sip_sub);
+ ast_sip_push_task(serializer, serialized_notify, mwi_sub);
}
}
More information about the asterisk-commits
mailing list