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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 9 12:15:21 CDT 2014


Author: mmichelson
Date: Wed Jul  9 12:15:15 2014
New Revision: 418227

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418227
Log:
Get rid of some of the hard-coded RLMI values.

* resource name
* resource state


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=418227&r1=418226&r2=418227
==============================================================================
--- team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c Wed Jul  9 12:15:15 2014
@@ -410,6 +410,8 @@
 	int body_changed;
 	/*! The current state of the subscription */
 	pjsip_evsub_state subscription_state;
+	/*! For lists, the current version to place in the RLMI body */
+	unsigned int version;
 	/*! Name of resource being subscribed to */
 	char resource[0];
 };
@@ -1441,29 +1443,26 @@
 	return res;
 }
 
-static void add_rlmi_resource(pj_pool_t *pool, pj_xml_node *rlmi, const char *cid)
+static void add_rlmi_resource(pj_pool_t *pool, pj_xml_node *rlmi, const char *cid,
+		const char *resource_name, const char *resource_uri, pjsip_evsub_state state)
 {
 	pj_xml_node *resource;
 	pj_xml_node *name;
 	pj_xml_node *instance;
-	char uri[PJSIP_MAX_URL_SIZE];
 	char id[AST_UUID_STR_LEN];
 
 	resource = ast_sip_presence_xml_create_node(pool, rlmi, "resource");
 	name = ast_sip_presence_xml_create_node(pool, resource, "name");
 	instance = ast_sip_presence_xml_create_node(pool, resource, "instance");
 
-	/* XXX Hardcoding a resource URI for the moment. */
-	ast_copy_string(uri, "johndoe at example.org", sizeof(uri));
-	ast_sip_presence_xml_create_attr(pool, resource, "uri", uri);
-
-	/* XXX This is hardcoded too! */
-	pj_strdup2(pool, &name->content, "CAT-URINE");
+	ast_sip_presence_xml_create_attr(pool, resource, "uri", resource_uri);
+
+	pj_strdup2(pool, &name->content, resource_name);
 
 	ast_uuid_generate_str(id, sizeof(id));
 	ast_sip_presence_xml_create_attr(pool, instance, "id", id);
-	/* XXX More hardcodedness */
-	ast_sip_presence_xml_create_attr(pool, instance, "state", "active");
+	ast_sip_presence_xml_create_attr(pool, instance, "state",
+			state == PJSIP_EVSUB_STATE_TERMINATED ? "terminated" : "active");
 	ast_sip_presence_xml_create_attr(pool, instance, "cid", ast_strip_quoted(ast_strdupa(cid), "<", ">"));
 }
 
@@ -1488,8 +1487,8 @@
 	ast_sip_subscription_get_local_uri(sub, uri, sizeof(uri));
 	ast_sip_presence_xml_create_attr(pool, rlmi, "uri", uri);
 
-	/* XXX Hardcoding RLMI version and fullState  attributes for the moment. */
-	snprintf(version_str, sizeof(version_str), "%u", 0);
+	/* XXX Hardcoding RLMI fullState attribute for the moment. */
+	snprintf(version_str, sizeof(version_str), "%u", sub->version++);
 	ast_sip_presence_xml_create_attr(pool, rlmi, "version", version_str);
 	ast_sip_presence_xml_create_attr(pool, rlmi, "fullState", "true");
 
@@ -1497,7 +1496,10 @@
 	pj_strdup2(pool, &name->content, ast_sip_subscription_get_resource_name(sub));
 
 	for (i = 0; i < AST_VECTOR_SIZE(cids); ++i) {
-		add_rlmi_resource(pool, rlmi, AST_VECTOR_GET(cids, i));
+		/* XXX Using a hardcoded URI for the moment */
+		add_rlmi_resource(pool, rlmi, AST_VECTOR_GET(cids, i),
+				AST_VECTOR_GET(&sub->children, i)->resource, "sip:johndoe at example.org",
+				AST_VECTOR_GET(&sub->children, i)->subscription_state);
 	}
 
 	return rlmi;




More information about the asterisk-commits mailing list