[svn-commits] branch mogorman/asterisk-xmpp r19933 - /team/mogorman/asterisk-xmpp/res/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Apr 13 14:51:57 MST 2006


Author: mogorman
Date: Thu Apr 13 16:51:57 2006
New Revision: 19933

URL: http://svn.digium.com/view/asterisk?rev=19933&view=rev
Log:
make the output pretty...

Modified:
    team/mogorman/asterisk-xmpp/res/res_jabber.c

Modified: team/mogorman/asterisk-xmpp/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_jabber.c?rev=19933&r1=19932&r2=19933&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_jabber.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_jabber.c Thu Apr 13 16:51:57 2006
@@ -370,7 +370,7 @@
 						}
 					}
 				} else if (!strcmp("failure",iks_name(node))) {
-					  ast_verbose("JABBER: encryption failure.\n");
+					  ast_log(LOG_ERROR, "JABBER: encryption failure. possible bad password.\n");
 				} else if (!strcmp("success",iks_name(node))) {
 					client->authorized=1;
 					iks_send_header(client->p,client->jid->server);
@@ -378,12 +378,12 @@
 				break;
 			}
 			case IKS_NODE_ERROR: {
-				ast_verbose("JABBER: Node Error\n");
+				ast_log(LOG_ERROR,"JABBER: Node Error\n");
 				return IKS_HOOK;
 				break;
 			}
 			case IKS_NODE_STOP: {
-				ast_verbose("JABBER: Disconnected\n");
+				ast_log(LOG_WARNING,"JABBER: Disconnected\n");
 				return IKS_HOOK;
 				break;
 			}
@@ -391,14 +391,13 @@
 	} else if (client->state!=AJI_CONNECTED && client->component == AJI_COMPONENT){
 		switch(type) {
 			case IKS_NODE_START:{
-				char buffer2[160], buffer3[320],*handshake;
+				char secret[160], shasum[320],*handshake;
 				switch(client->state) {
 					case AJI_DISCONNECTED:
-						sprintf(buffer2,"%s%s",pak->id,client->password);
-						ast_sha1_hash(buffer3,buffer2);
-						ast_verbose("Oh Really... %s\n",buffer2);
+						sprintf(secret,"%s%s",pak->id,client->password);
+						ast_sha1_hash(shasum,secret);
 						handshake = NULL;
-						asprintf(&handshake, "<handshake>%s</handshake>",buffer3);
+						asprintf(&handshake, "<handshake>%s</handshake>",shasum);
 						if (handshake) {
 							iks_send_raw(client->p,handshake);
 							free(handshake);
@@ -414,7 +413,6 @@
 						break;
 					case AJI_ALMOST:
 						client->state=AJI_CONNECTED;
-						ast_verbose("shazam!\n");
 						break;
 					case AJI_CONNECTING:
 					case AJI_CONNECTED:
@@ -424,17 +422,16 @@
 			}
 	
 			case IKS_NODE_NORMAL:{
-				ast_verbose("MOVE ZIG\n");
 				break;
 			}
 					     
 			case IKS_NODE_ERROR: {
-				ast_verbose("JABBER: Node Error\n");
+				ast_log(LOG_ERROR,"JABBER: Node Error\n");
 				return IKS_HOOK;
 				break;
 			}
 			case IKS_NODE_STOP: {
-				ast_verbose("JABBER: Disconnected\n");
+				ast_log(LOG_WARNING,"JABBER: Disconnected\n");
 				return IKS_HOOK;
 				break;
 			}
@@ -443,24 +440,24 @@
 
 	switch(pak->type) {
 		case IKS_PAK_NONE:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Don't know what to do with you NONE\n");
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Don't know what to do with you NONE\n");
 			break;
 		case IKS_PAK_MESSAGE:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Don't know what to do with you MESSAGE\n");
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Don't know what to do with you MESSAGE\n");
 			break;
 		case IKS_PAK_PRESENCE:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Do know how to handle presence!!\n");
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Do know how to handle presence!!\n");
 			break;
 		case IKS_PAK_S10N:
 			aji_handle_subscribe(client,pak);
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont know S10N subscribe!!\n");
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont know S10N subscribe!!\n");
 			break;
 		case IKS_PAK_IQ:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont have an IQ!!!\n");
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont have an IQ!!!\n");
 			aji_handle_iq(client,node);
 			break;
 		default:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont know %i\n",pak->type );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: I Dont know %i\n",pak->type );
 			break;
 	}
 	
@@ -500,7 +497,6 @@
 
 static int aji_register_query_handler(void *udata,ikspak *pak)
 {
-	int res=0;
 	struct aji_client *client;
 	char *node = NULL;
 
@@ -741,19 +737,19 @@
 	{
 		case IKS_TYPE_SUBSCRIBE:
 			res =iks_send(client->p,iks_make_s10n(IKS_TYPE_SUBSCRIBED,iks_find_attrib(pak->x, "from"),"Asterisk has approved subscription"));
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
 			break;
 		case IKS_TYPE_SUBSCRIBED:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
 			break;
 		case IKS_TYPE_UNSUBSCRIBE:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
 			break;
 		case IKS_TYPE_UNSUBSCRIBED:
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
 			break;
 		default: /*IKS_TYPE_ERROR:*/
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
+			if(option_verbose > 30) ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n",pak->subtype );
 			break;
 	}
 }
@@ -774,7 +770,7 @@
 		if(message_packet)
 			iks_delete(message_packet);
 	} else
-		ast_verbose("JABBER: Not connected can't send\n");
+		ast_log(LOG_WARNING, "JABBER: Not connected can't send\n");
 	return 1;
 }
 
@@ -872,21 +868,20 @@
 	while (res == IKS_OK) {
 		res = iks_recv(client->p,1);
 		if(res==IKS_HOOK) {
-			ast_verbose("JABBER: Got hook event.\n");
+			ast_log(LOG_WARNING,"JABBER: Got hook event.\n");
 			break;
 		}
 		if(res==IKS_NET_TLSFAIL) {
-			ast_verbose("JABBER:  Failure in tls.\n");
+			ast_log(LOG_ERROR,"JABBER:  Failure in tls.\n");
 			break;
 		}
 		client->timeout--;
 		if(client->timeout == 0 && client->state !=AJI_CONNECTED) {
 			res = -1;
-			ast_verbose("JABBER:  Network Timeout\n");
+			ast_log(LOG_WARNING, "JABBER:  Network Timeout\n");
 		}
 		if(res==IKS_NET_RWERR) {
-			ast_verbose("JABBER: socket read error\n");
-			res=IKS_OK;
+			ast_log(LOG_ERROR, "JABBER: socket read error\n");
 		}
 
 	}
@@ -1198,7 +1193,6 @@
 
 	client = ASTOBJ_REF((struct aji_client *) udata);
 
-	ast_verbose(" so long, state %d\n", client->state);
 	
 	switch(client->state)
 	{
@@ -1280,9 +1274,9 @@
 	connected = iks_connect_via(client->p, client->serverhost, client->port, client->server);
 
 	if(connected== IKS_NET_NOCONN)
-		ast_verbose("JABBER ERROR: No Connection");
+		ast_log(LOG_ERROR, "JABBER ERROR: No Connection");
 	if(connected == IKS_NET_NODNS)
-		ast_verbose("JABBER ERROR: No DNS");
+		ast_log(LOG_ERROR, "JABBER ERROR: No DNS");
 	return 1;
 
 failedfilter:
@@ -1313,10 +1307,11 @@
 	iks_set_log_hook(client->p, aji_log_hook);
 	connected =iks_connect_via(client->p, client->server, client->port, client->user);
 
+
 	if(connected== IKS_NET_NOCONN)
-		ast_verbose("JABBER ERROR: No Connection");
+		ast_log(LOG_ERROR, "JABBER ERROR: No Connection");
 	if(connected == IKS_NET_NODNS)
-		ast_verbose("JABBER ERROR: No DNS");
+		ast_log(LOG_ERROR, "JABBER ERROR: No DNS");
 	if(!connected)
 		iks_recv(client->p,30);
 	return 1;
@@ -1330,7 +1325,7 @@
 int ast_aji_disconnect(struct aji_client *client)
 {
 	if(client) {
-		ast_verbose(VERBOSE_PREFIX_3"JABBER: Disconnecting\n");
+		if ( option_verbose > 3) ast_verbose(VERBOSE_PREFIX_3"JABBER: Disconnecting\n");
 		iks_disconnect(client->p);
 		iks_parser_delete(client->p);
 		ASTOBJ_UNREF(client, aji_client_destroy);
@@ -1375,7 +1370,7 @@
 		ASTOBJ_UNLOCK(iterator);
 		}
 		);
-	ast_verbose(VERBOSE_PREFIX_3 "JABBER: Debugging Enabled.\n");
+	if(option_verbose > 3) ast_verbose(VERBOSE_PREFIX_3 "JABBER: Debugging Enabled.\n");
 	return RESULT_SUCCESS;
 
 }
@@ -1393,7 +1388,7 @@
 		ASTOBJ_UNLOCK(iterator);
 		}
 		);
-	ast_verbose(VERBOSE_PREFIX_3 "JABBER: Debugging Disabled\n");
+	if(option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "JABBER: Debugging Disabled\n");
 	return RESULT_SUCCESS;
 
 }
@@ -1654,7 +1649,7 @@
 {
 	ASTOBJ_CONTAINER_TRAVERSE(&clients,1, {
 			ASTOBJ_RDLOCK(iterator);
-			ast_verbose(VERBOSE_PREFIX_3 "JABBER: %s\n",iterator->name);
+				if(option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "JABBER: %s\n",iterator->name);
 				iterator->state=AJI_DISCONNECTED;
 				ast_aji_disconnect(iterator);
 				pthread_join(iterator->thread,NULL);
@@ -1677,7 +1672,7 @@
 
 
 	if(!aji_load_config()) {
-		ast_verbose("JABBER: Failed to load\n");
+		ast_log(LOG_ERROR, "JABBER: Failed to load\n");
 		return 0;
 	} else {
 		ASTOBJ_CONTAINER_TRAVERSE(&clients,1, {



More information about the svn-commits mailing list