[svn-commits] mmichelson: branch mmichelson/rls-config r416663 - /team/mmichelson/rls-confi...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 19 09:46:38 CDT 2014


Author: mmichelson
Date: Thu Jun 19 09:46:26 2014
New Revision: 416663

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416663
Log:
Fix some bugs and improve a couple of things:

* Add SORCERY_OBJECT() to resource_list struct
* Actually load the resource list objects instead of just declaring they exist
* Copy list_item values instead of pointing to garbage
* Actually print the allocated AMI string for resource list details
* Free that string instead of leaking it
* s/ResourceListList/ResourceListDetail/


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

Modified: team/mmichelson/rls-config/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-config/res/res_pjsip_pubsub.c?view=diff&rev=416663&r1=416662&r2=416663
==============================================================================
--- team/mmichelson/rls-config/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-config/res/res_pjsip_pubsub.c Thu Jun 19 09:46:26 2014
@@ -79,9 +79,9 @@
 		<syntax />
 		<description>
 			<para>
-			Provides a listing of all resource lists.  An event <literal>ResourceListList</literal>
+			Provides a listing of all resource lists.  An event <literal>ResourceListDetail</literal>
 			is issued for each resource list object.  Once all detail events are completed a
-			<literal>ResourceListListComplete</literal> event is issued.
+			<literal>ResourceListDetailComplete</literal> event is issued.
                         </para>
 		</description>
 	</manager>
@@ -274,6 +274,7 @@
  * \brief Resource list configuration item
  */
 struct resource_list {
+	SORCERY_OBJECT(details);
 	/*! SIP event package the list uses. */
 	char event[32];
 	/*! Strings representing resources in the list. */
@@ -1901,7 +1902,7 @@
 	struct ast_sip_ami *ami = arg;
 	struct ast_str *buf;
 
-	buf = ast_sip_create_ami_event("ResourceListList", ami);
+	buf = ast_sip_create_ami_event("ResourceListDetail", ami);
 	if (!buf) {
 		return CMP_STOP;
 	}
@@ -1909,7 +1910,9 @@
 	if (ast_sip_sorcery_object_to_ami(list, &buf)) {
 		return CMP_STOP;
 	}
-
+	astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+
+	ast_free(buf);
 	return 0;
 }
 
@@ -1928,12 +1931,12 @@
 	}
 
 	astman_send_listack(s, m, "A listing of resource lists follows, "
-			    "presented as ResourceListList events", "start");
+			    "presented as ResourceListDetail events", "start");
 
 	ao2_callback(lists, OBJ_NODATA, format_ami_resource_lists, &ami);
 
 	astman_append(s,
-		      "Event: ResourceListListComplete\r\n"
+		      "Event: ResourceListDetailComplete\r\n"
 		      "EventList: Complete\r\n"
 		      "ListItems: %d\r\n\r\n", num);
 	return 0;
@@ -1991,6 +1994,11 @@
 static void resource_list_destructor(void *obj)
 {
 	struct resource_list *list = obj;
+	int i;
+	
+	for (i = 0; i < AST_VECTOR_SIZE(&list->items); ++i) {
+		ast_free((char *) AST_VECTOR_GET(&list->items, i));
+	}
 
 	AST_VECTOR_FREE(&list->items);
 }
@@ -2020,7 +2028,7 @@
 	char *item;
 
 	while ((item = strsep(&items, ","))) {
-		if (AST_VECTOR_APPEND(&list->items, item)) {
+		if (AST_VECTOR_APPEND(&list->items, ast_strdup(item))) {
 			return -1;
 		}
 	}
@@ -2058,11 +2066,13 @@
 	ast_sorcery_object_field_register(sorcery, "resource_list", "event", "",
 			OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct resource_list, event));
 	ast_sorcery_object_field_register(sorcery, "resource_list", "full_state", "0",
-			OPT_UINT_T, 0, FLDSET(struct resource_list, full_state));
+			OPT_BOOL_T, 0, 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",
 			"", list_item_handler, list_item_to_str, NULL, 0, 0);
+
+	ast_sorcery_reload_object(sorcery, "resource_list");
 
 	return 0;
 }




More information about the svn-commits mailing list