[asterisk-commits] file: trunk r418117 - in /trunk: ./ include/asterisk/ res/ res/res_pjsip/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 7 11:08:53 CDT 2014


Author: file
Date: Mon Jul  7 11:08:47 2014
New Revision: 418117

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418117
Log:
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

Added:
    trunk/res/res_pjsip_dialog_info_body_generator.c
      - copied unchanged from r418116, branches/12/res/res_pjsip_dialog_info_body_generator.c
Modified:
    trunk/   (props changed)
    trunk/include/asterisk/res_pjsip_body_generator_types.h
    trunk/include/asterisk/res_pjsip_presence_xml.h
    trunk/res/res_pjsip/presence_xml.c
    trunk/res/res_pjsip_exten_state.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/include/asterisk/res_pjsip_body_generator_types.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_pjsip_body_generator_types.h?view=diff&rev=418117&r1=418116&r2=418117
==============================================================================
--- trunk/include/asterisk/res_pjsip_body_generator_types.h (original)
+++ trunk/include/asterisk/res_pjsip_body_generator_types.h Mon Jul  7 11:08:47 2014
@@ -28,6 +28,7 @@
  * \li application/pidf+xml
  * \li application/xpidf+xml
  * \li application/cpim-pidf+xml
+ * \li application/dialog-info+xml
  */
 struct ast_sip_exten_state_data {
 	/*! The extension of the current state change */
@@ -48,6 +49,8 @@
 	char local[PJSIP_MAX_URL_SIZE];
 	/*! Remote dialog URI */
 	char remote[PJSIP_MAX_URL_SIZE];
+	/*! Optional subscription */
+	struct ast_sip_subscription *sub;
 	/*! Allocation pool */
 	pj_pool_t *pool;
 };

Modified: trunk/include/asterisk/res_pjsip_presence_xml.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_pjsip_presence_xml.h?view=diff&rev=418117&r1=418116&r2=418117
==============================================================================
--- trunk/include/asterisk/res_pjsip_presence_xml.h (original)
+++ trunk/include/asterisk/res_pjsip_presence_xml.h Mon Jul  7 11:08:47 2014
@@ -72,7 +72,7 @@
  * \brief Create XML node
  *
  * \param pool Allocation pool
- * \param parent Node that will be parent to the created node
+ * \param parent Optional node that will be parent to the created node
  * \param name The name for the new node
  * \return The created node
  */

Modified: trunk/res/res_pjsip/presence_xml.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/presence_xml.c?view=diff&rev=418117&r1=418116&r2=418117
==============================================================================
--- trunk/res/res_pjsip/presence_xml.c (original)
+++ trunk/res/res_pjsip/presence_xml.c Mon Jul  7 11:08:47 2014
@@ -152,7 +152,10 @@
 	node->content.ptr = NULL;
 	node->content.slen = 0;
 
-	pj_xml_add_node(parent, node);
+	if (parent) {
+		pj_xml_add_node(parent, node);
+	}
+
 	return node;
 }
 

Modified: trunk/res/res_pjsip_exten_state.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_exten_state.c?view=diff&rev=418117&r1=418116&r2=418117
==============================================================================
--- trunk/res/res_pjsip_exten_state.c (original)
+++ trunk/res/res_pjsip_exten_state.c Mon Jul  7 11:08:47 2014
@@ -66,6 +66,7 @@
 };
 
 #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);
@@ -83,6 +84,14 @@
 struct ast_sip_subscription_handler presence_handler = {
 	.event_name = "presence",
 	.accept = { DEFAULT_PRESENCE_BODY, },
+	.subscription_shutdown = subscription_shutdown,
+	.to_ami = to_ami,
+	.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,
@@ -158,6 +167,7 @@
 							  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
 	};
 
@@ -249,6 +259,8 @@
 	/* Pool allocation has to happen here so that we allocate within a PJLIB thread */
 	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 @@
 			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;
 }




More information about the asterisk-commits mailing list