[asterisk-commits] oej: branch 1.4 r55483 - /branches/1.4/res/res_jabber.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 19 14:12:56 MST 2007


Author: oej
Date: Mon Feb 19 15:12:55 2007
New Revision: 55483

URL: http://svn.digium.com/view/asterisk?view=rev&rev=55483
Log:
- Not sending arguments to an application is not "out of memory"
- Making error messages a bit more clear

Modified:
    branches/1.4/res/res_jabber.c

Modified: branches/1.4/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_jabber.c?view=diff&rev=55483&r1=55482&r2=55483
==============================================================================
--- branches/1.4/res/res_jabber.c (original)
+++ branches/1.4/res/res_jabber.c Mon Feb 19 15:12:55 2007
@@ -339,23 +339,23 @@
 	char *s = NULL, *sender = NULL, *jid = NULL, *screenname = NULL, *resource = NULL, *variable = NULL;
 	int stat = 7;
 	char status[2];
-	if (data) {
-		s = ast_strdupa((char *) data);
-		if (s) {
-			sender = strsep(&s, "|");
-			if (sender && (sender[0] != '\0')) {
-				jid = strsep(&s, "|");
-				if (jid && (jid[0] != '\0')) {
-					variable = s;
-				} else {
-					ast_log(LOG_ERROR, "Bad arguments\n");
-					return -1;
-				}
+
+	if (!data) {
+		ast_log(LOG_ERROR, "This application requires arguments.\n");
+		return 0;
+	}
+	s = ast_strdupa((char *) data);
+	if (s) {
+		sender = strsep(&s, "|");
+		if (sender && (sender[0] != '\0')) {
+			jid = strsep(&s, "|");
+			if (jid && (jid[0] != '\0')) {
+				variable = s;
+			} else {
+				ast_log(LOG_ERROR, "Bad arguments\n");
+				return -1;
 			}
 		}
-	} else {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
 	}
 
 	if(!strchr(jid, '/')) {
@@ -366,25 +366,23 @@
 	}
 	client = ast_aji_get_client(sender);
 	if (!client) {
-		ast_log(LOG_WARNING, "Could not find Connection.\n");
+		ast_log(LOG_WARNING, "Could not find sender connection: %s\n", sender);
 		return -1;
 	}
 	if(!&client->buddies) {
-		ast_log(LOG_WARNING, "No buddies for connection.\n");
+		ast_log(LOG_WARNING, "No buddies for connection : %s\n", sender);
 		return -1;
 	}
-	buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, (resource)?screenname:jid);
+	buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, resource ? screenname: jid);
 	if (!buddy) {
-		ast_log(LOG_WARNING, "Could not find Buddy in list.\n");
+		ast_log(LOG_WARNING, "Could not find buddy in list : %s\n", resource ? screenname : jid);
 		return -1;
 	}
 	r = aji_find_resource(buddy, resource);
-	if(!r && buddy->resources) {
+	if(!r && buddy->resources) 
 		r = buddy->resources;
-	}
-	if(!r){
+	if(!r)
 		ast_log(LOG_NOTICE, "Resource %s of buddy %s not found \n", resource, screenname);
-	}
 	stat = r->status;
 	sprintf(status, "%d", stat);
 	pbx_builtin_setvar_helper(chan, variable, status);
@@ -403,8 +401,8 @@
 	char *s = NULL, *sender = NULL, *recipient = NULL, *message = NULL;
 
 	if (!data) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
+		ast_log(LOG_ERROR, "This application requires arguments.\n");
+		return 0;
 	}
 	s = ast_strdupa((char *) data);
 	if (s) {
@@ -414,13 +412,13 @@
 			if (recipient && (recipient[0] != '\0')) {
 				message = s;
 			} else {
-				ast_log(LOG_ERROR, "Bad arguments \n");
+				ast_log(LOG_ERROR, "Bad arguments: %s\n", (char *) data);
 				return -1;
 			}
 		}
 	}
 	if (!(client = ast_aji_get_client(sender))) {
-		ast_log(LOG_WARNING, "Could not find Sender.\n");
+		ast_log(LOG_WARNING, "Could not find sender connection: %s\n", sender);
 		return -1;
 	}
 	if (strchr(recipient, '@') && message)



More information about the asterisk-commits mailing list