mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user