[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r362265 - /team/mmichelson/t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 17 09:54:52 CDT 2012


Author: mmichelson
Date: Tue Apr 17 09:54:48 2012
New Revision: 362265

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362265
Log:
Make Suggested changes from review 1850.

* Enhance documentation for CLI command "presencestate change".
* Check for potential errors from the parse_data() function.
* Print message indicating no CustomPresence entries were found
  if no entries exist when issuing CLI command "presencestate list".


Modified:
    team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c

Modified: team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c?view=diff&rev=362265&r1=362264&r2=362265
==============================================================================
--- team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c (original)
+++ team/mmichelson/trunk-digiumphones/funcs/func_presencestate.c Tue Apr 17 09:54:48 2012
@@ -299,6 +299,10 @@
 	        "---\n");
 
 	db_entry = db_tree = ast_db_gettree(astdb_family, NULL);
+	if (!db_entry) {
+		ast_cli(a->fd, "No custom presence states defined\n");
+		return CLI_SUCCESS;
+	}
 	for (; db_entry; db_entry = db_entry->next) {
 		const char *object_name = strrchr(db_entry->key, '/') + 1;
 		char state_info[1301];
@@ -308,7 +312,10 @@
 		char *options;
 
 		ast_copy_string(state_info, db_entry->data, sizeof(state_info));
-		parse_data(state_info, &state, &subtype, &message, &options);
+		if (parse_data(state_info, &state, &subtype, &message, &options)) {
+			ast_log(LOG_WARNING, "Invalid CustomPresence entry %s encountered\n", db_entry->data);
+			continue;
+		}
 
 		if (object_name <= (const char *) 1) {
 			continue;
@@ -350,14 +357,18 @@
 	case CLI_INIT:
 		e->command = "presencestate change";
 		e->usage =
-			"Usage: presencestate change <entity> <state>\n"
+			"Usage: presencestate change <entity> <state>[,<subtype>[,message[,options]]]\n"
 			"       Change a custom presence to a new state.\n"
 			"       The possible values for the state are:\n"
 			"NOT_SET | UNAVAILABLE | AVAILABLE | AWAY | XA | CHAT | DND\n"
+			"Optionally, a custom subtype and message may be provided, along with any options\n"
+			"accepted by func_presencestate. If the subtype or message provided contain spaces,\n"
+			"be sure to enclose the data in quotation marks (\"\")\n"
 			"\n"
 			"Examples:\n"
 			"       presencestate change CustomPresence:mystate1 AWAY\n"
 			"       presencestate change CustomPresence:mystate1 AVAILABLE\n"
+			"       presencestate change CustomPresence:mystate1 \"Away,upstairs,eating lunch\"\n"
 			"       \n";
 		return NULL;
 	case CLI_GENERATE:
@@ -735,7 +746,10 @@
 			continue;
 		}
 		ast_copy_string(state_info, db_entry->data, sizeof(state_info));
-		parse_data(state_info, &state, &subtype, &message, &options);
+		if (parse_data(state_info, &state, &subtype, &message, &options)) {
+			ast_log(LOG_WARNING, "Invalid CustomPresence entry %s encountered\n", db_entry->data);
+			continue;
+		}
 		ast_presence_state_changed(state, subtype, message, "CustomPresence:%s", dev_name);
 	}
 	ast_db_freetree(db_tree);




More information about the asterisk-commits mailing list