diff options
author | Joshua Colp <jcolp@digium.com> | 2014-07-07 16:08:47 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2014-07-07 16:08:47 +0000 |
commit | 534ffd8481341da6c7539163d7f575e98173cae0 (patch) | |
tree | 8e3544fd1d29ea55ba15063a865db97f8e3d0138 /res/res_pjsip_exten_state.c | |
parent | d4b436d0ea766d51d7743a874df441d40fdcd226 (diff) |
res_pjsip_dialog_info_body_generator: Add dialog-info+xml support for presence.
This module implements dialog-info+xml for the purposes of presence. This means
that phones such as Grandstreams can now subscribe to receive presence information
for an extension.
ASTERISK-21443 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3705/
........
Merged revisions 418116 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418117 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_exten_state.c')
-rw-r--r-- | res/res_pjsip_exten_state.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c index cb39026ca..55bd90ee0 100644 --- a/res/res_pjsip_exten_state.c +++ b/res/res_pjsip_exten_state.c @@ -66,6 +66,7 @@ struct exten_state_subscription { }; #define DEFAULT_PRESENCE_BODY "application/pidf+xml" +#define DEFAULT_DIALOG_BODY "application/dialog-info+xml" static void subscription_shutdown(struct ast_sip_subscription *sub); static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource); @@ -88,6 +89,14 @@ struct ast_sip_subscription_handler presence_handler = { .notifier = &presence_notifier, }; +struct ast_sip_subscription_handler dialog_handler = { + .event_name = "dialog", + .accept = { DEFAULT_DIALOG_BODY, }, + .subscription_shutdown = subscription_shutdown, + .to_ami = to_ami, + .notifier = &presence_notifier, +}; + static void exten_state_subscription_destructor(void *obj) { struct exten_state_subscription *sub = obj; @@ -158,6 +167,7 @@ static void send_notify(struct exten_state_subscription *exten_state_sub) exten_state_sub->exten, &subtype, &message), .presence_subtype = subtype, .presence_message = message, + .sub = exten_state_sub->sip_sub, .user_agent = exten_state_sub->user_agent }; @@ -250,6 +260,8 @@ static int notify_task(void *obj) task_data->exten_state_data.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "exten_state", 1024, 1024); + task_data->exten_state_data.sub = task_data->exten_state_sub->sip_sub; + ast_sip_subscription_notify(task_data->exten_state_sub->sip_sub, &task_data->exten_state_data, task_data->terminate); @@ -439,11 +451,20 @@ static int load_module(void) presence_handler.event_name); return AST_MODULE_LOAD_DECLINE; } + + if (ast_sip_register_subscription_handler(&dialog_handler)) { + ast_log(LOG_WARNING, "Unable to register subscription handler %s\n", + dialog_handler.event_name); + ast_sip_unregister_subscription_handler(&presence_handler); + return AST_MODULE_LOAD_DECLINE; + } + return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { + ast_sip_unregister_subscription_handler(&dialog_handler); ast_sip_unregister_subscription_handler(&presence_handler); return 0; } |