[asterisk-commits] mmichelson: branch mmichelson/rls-rlmi r419628 - /team/mmichelson/rls-rlmi/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 25 16:57:06 CDT 2014


Author: mmichelson
Date: Fri Jul 25 16:57:00 2014
New Revision: 419628

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419628
Log:
Fix generation of full state notifications on state changes.


Modified:
    team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c?view=diff&rev=419628&r1=419627&r2=419628
==============================================================================
--- team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c Fri Jul 25 16:57:00 2014
@@ -633,6 +633,7 @@
  */
 struct tree_node {
 	AST_VECTOR(, struct tree_node *) children;
+	unsigned int full_state;
 	char resource[0];
 };
 
@@ -672,10 +673,11 @@
  *
  * \param resource The name of the resource for this tree node.
  * \param visited The vector of resources that have been visited.
+ * \param if allocating a list, indicate whether full state is requested in notifications.
  * \retval NULL Allocation failure.
  * \retval non-NULL The newly-allocated tree_node
  */
-static struct tree_node *tree_node_alloc(const char *resource, struct resources *visited)
+static struct tree_node *tree_node_alloc(const char *resource, struct resources *visited, unsigned int full_state)
 {
 	struct tree_node *node;
 
@@ -686,6 +688,7 @@
 
 	strcpy(node->resource, resource);
 	AST_VECTOR_INIT(&node->children, 4);
+	node->full_state = full_state;
 
 	if (visited) {
 		AST_VECTOR_APPEND(visited, resource);
@@ -777,7 +780,7 @@
 		if (!child_list) {
 			int resp = handler->notifier->new_subscribe(endpoint, resource);
 			if (PJSIP_IS_STATUS_IN_CLASS(resp, 200)) {
-				current = tree_node_alloc(resource, visited);
+				current = tree_node_alloc(resource, visited, 0);
 				if (!current) {
 					ast_debug(1, "Subscription to leaf resource %s was successful, but encountered"
 							"allocation error afterwards\n", resource);
@@ -792,7 +795,7 @@
 			}
 		} else {
 			ast_debug(1, "Resource %s (child of %s) is a list\n", resource, parent->resource);
-			current = tree_node_alloc(resource, visited);
+			current = tree_node_alloc(resource, visited, child_list->full_state);
 			if (!current) {
 				ast_debug(1, "Cannot build children of resource %s due to allocation failure\n", resource);
 				continue;
@@ -875,14 +878,14 @@
 	list = retrieve_resource_list(resource, handler->event_name);
 	if (!list) {
 		ast_debug(1, "Subscription to resource %s is not to a list\n", resource);
-		tree->root = tree_node_alloc(resource, NULL);
+		tree->root = tree_node_alloc(resource, NULL, 0);
 		return handler->notifier->new_subscribe(endpoint, resource);
 	}
 
 	ast_debug(1, "Subscription to resource %s is a list\n", resource);
 	AST_VECTOR_INIT(&visited, AST_VECTOR_SIZE(&list->items));
 
-	tree->root = tree_node_alloc(resource, &visited);
+	tree->root = tree_node_alloc(resource, &visited, list->full_state);
 	tree->notification_batch_interval = list->notification_batch_interval;
 
 	build_node_children(endpoint, handler, list, tree->root, &visited);
@@ -1028,6 +1031,7 @@
 		return NULL;
 	}
 
+	sub->full_state = current->full_state;
 	sub->body_generator = generator;
 
 	for (i = 0; i < AST_VECTOR_SIZE(&current->children); ++i) {
@@ -1637,7 +1641,7 @@
  * \return The multipart part representing the RLMI body
  */
 static pjsip_multipart_part *build_rlmi_body(pj_pool_t *pool, struct ast_sip_subscription *sub,
-		struct body_part_list *body_parts, int full_state)
+		struct body_part_list *body_parts, unsigned int full_state)
 {
 	static const pj_str_t rlmi_type = { "application", 11 };
 	static const pj_str_t rlmi_subtype = { "rlmi+xml", 8 };
@@ -1683,7 +1687,7 @@
 }
 
 static pjsip_msg_body *generate_notify_body(pj_pool_t *pool, struct ast_sip_subscription *root,
-		int force_full_state);
+		unsigned int force_full_state);
 
 /*!
  * \brief Destroy a list of body parts
@@ -1734,7 +1738,7 @@
  * \param use_full_state Unused locally, but may be passed to other functions
  */
 static void build_body_part(pj_pool_t *pool, struct ast_sip_subscription *sub,
-		struct body_part_list *parts, int use_full_state)
+		struct body_part_list *parts, unsigned int use_full_state)
 {
 	struct body_part *bp;
 	pjsip_msg_body *body;
@@ -1798,13 +1802,13 @@
  * \return The generated multipart/related body
  */
 static pjsip_msg_body *generate_list_body(pj_pool_t *pool, struct ast_sip_subscription *sub,
-		int force_full_state)
+		unsigned int force_full_state)
 {
 	int i;
 	pjsip_multipart_part *rlmi_part;
 	pjsip_msg_body *multipart;
 	struct body_part_list body_parts;
-	int use_full_state = force_full_state ? 1 : sub->full_state;
+	unsigned int use_full_state = force_full_state ? 1 : sub->full_state;
 
 	AST_VECTOR_INIT(&body_parts, AST_VECTOR_SIZE(&sub->children));
 
@@ -1833,7 +1837,7 @@
  * \param force_full_state If true, ignore resource list settings and send a full state notification
  */
 static pjsip_msg_body *generate_notify_body(pj_pool_t *pool, struct ast_sip_subscription *root,
-		int force_full_state)
+		unsigned int force_full_state)
 {
 	pjsip_msg_body *body;
 
@@ -1884,7 +1888,7 @@
  * \retval 0 Success
  * \retval non-zero Failure
  */
-static int send_notify(struct sip_subscription_tree *sub_tree, int force_full_state)
+static int send_notify(struct sip_subscription_tree *sub_tree, unsigned int force_full_state)
 {
 	pjsip_evsub *evsub = sub_tree->evsub;
 	pjsip_tx_data *tdata;
@@ -3227,8 +3231,8 @@
 			OPT_NOOP_T, 0, 0);
 	ast_sorcery_object_field_register(sorcery, "resource_list", "event", "",
 			OPT_CHAR_ARRAY_T, 1, CHARFLDSET(struct resource_list, event));
-	ast_sorcery_object_field_register(sorcery, "resource_list", "full_state", "0",
-			OPT_BOOL_T, 0, FLDSET(struct resource_list, full_state));
+	ast_sorcery_object_field_register(sorcery, "resource_list", "full_state", "no",
+			OPT_BOOL_T, 1, FLDSET(struct resource_list, full_state));
 	ast_sorcery_object_field_register(sorcery, "resource_list", "notification_batch_interval",
 			"0", OPT_UINT_T, 0, FLDSET(struct resource_list, notification_batch_interval));
 	ast_sorcery_object_field_register_custom(sorcery, "resource_list", "list_item",




More information about the asterisk-commits mailing list