[asterisk-commits] qwell: trunk r89041 - in /trunk: channels/ include/asterisk/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 6 12:44:20 CST 2007


Author: qwell
Date: Tue Nov  6 12:44:19 2007
New Revision: 89041

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89041
Log:
Allow gtalk and jingle to use TLS connections again.

Closes issue #9972

Modified:
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_jingle.c
    trunk/include/asterisk/jabber.h
    trunk/res/res_jabber.c

Modified: trunk/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=89041&r1=89040&r2=89041
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Tue Nov  6 12:44:19 2007
@@ -436,7 +436,7 @@
 	iks_insert_node(gtalk, transport);
 	iks_insert_node(dcodecs, payload_telephone);
 
-	iks_send(client->connection->p, iq);
+	ast_aji_send(client->connection, iq);
 	iks_delete(payload_telephone);
 	iks_delete(transport);
 	iks_delete(dcodecs);
@@ -473,7 +473,7 @@
 	iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
 	iks_insert_node(iq,session);
 	iks_insert_node(session,transport);
-	iks_send(p->parent->connection->p, iq);
+	ast_aji_send(p->parent->connection, iq);
 	iks_delete(transport);
 	iks_delete(session);
 	iks_delete(iq);
@@ -570,7 +570,7 @@
 				iks_insert_node(response, error);
 			}
 		}
-		iks_send(client->connection->p, response);
+		ast_aji_send(client->connection, response);
 		if (reason)
 			iks_delete(reason);
 		if (error)
@@ -830,7 +830,7 @@
 			iks_insert_attrib(candidate, "type", "relay");
 		iks_insert_attrib(candidate, "network", "0");
 		iks_insert_attrib(candidate, "generation", "0");
-		iks_send(c->p, iq);
+		ast_aji_send(c, iq);
 	}
 	p->laststun = 0;
 
@@ -1036,7 +1036,7 @@
 			iks_insert_attrib(session, "initiator", p->initiator ? p->us : p->them);
 			iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
 			iks_insert_node(request, session);
-			iks_send(client->connection->p, request);
+			ast_aji_send(client->connection, request);
 			iks_delete(session);
 			res = 0;
 		}
@@ -1274,7 +1274,7 @@
 	iks_insert_attrib(receipt, "from", from);
 	iks_insert_attrib(receipt, "to", iks_find_attrib(pak->x, "from"));
 	iks_insert_attrib(receipt, "id", iks_find_attrib(pak->x, "id"));
-	iks_send(c->p, receipt);
+	ast_aji_send(c, receipt);
 	iks_delete(receipt);
 
 	return 1;
@@ -1447,7 +1447,7 @@
 	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_END || duration != 0) {
 		iks_insert_attrib(dtmf, "action", "button-up");
 	}
-	iks_send(client->connection->p, iq);
+	ast_aji_send(client->connection, iq);
 	iks_delete(iq);
 	iks_delete(gtalk);
 	iks_delete(dtmf);

Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?view=diff&rev=89041&r1=89040&r2=89041
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Tue Nov  6 12:44:19 2007
@@ -372,7 +372,7 @@
 		iks_insert_node(dcodecs, payload_audio);
 		iks_insert_node(dcodecs, payload_cn);
 
-		iks_send(c->p, iq);
+		ast_aji_send(c, iq);
 		iks_delete(payload_red);
 		iks_delete(payload_audio);
 		iks_delete(payload_cn);
@@ -473,7 +473,7 @@
 				iks_insert_node(response, error);
 			}
 		}
-		iks_send(client->connection->p, response);
+		ast_aji_send(client->connection, response);
 		if (reason)
 			iks_delete(reason);
 		if (error)
@@ -729,7 +729,7 @@
 		}
 		iks_insert_attrib(candidate, "ufrag", tmp->ufrag);
 
-		iks_send(c->p, iq);
+		ast_aji_send(c, iq);
 	}
 	p->laststun = 0;
 
@@ -915,7 +915,7 @@
 
 			iks_insert_node(iq, jingle);
 
-			iks_send(client->connection->p, iq);
+			ast_aji_send(client->connection, iq);
 			iks_delete(jingle);
 			res = 0;
 		}
@@ -1124,7 +1124,7 @@
 	iks_insert_attrib(receipt, "from", c->jid->full);
 	iks_insert_attrib(receipt, "to", iks_find_attrib(pak->x, "from"));
 	iks_insert_attrib(receipt, "id", iks_find_attrib(pak->x, "id"));
-	iks_send(c->p, receipt);
+	ast_aji_send(c, receipt);
 	iks_delete(receipt);
 
 	return 1;
@@ -1287,7 +1287,7 @@
 	} else if (ast->dtmff.frametype == AST_FRAME_DTMF_END || duration != 0) {
 		iks_insert_attrib(dtmf, "action", "button-up");
 	}
-	iks_send(client->connection->p, iq);
+	ast_aji_send(client->connection, iq);
 	iks_delete(iq);
 	iks_delete(jingle);
 	iks_delete(dtmf);
@@ -1354,7 +1354,7 @@
 	iks_insert_node(jingle, content);
 	iks_insert_node(iq, jingle);
 
-	iks_send(client->p, iq);
+	ast_aji_send(client, iq);
 
 	iks_delete(iq);
 	iks_delete(jingle);

Modified: trunk/include/asterisk/jabber.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/jabber.h?view=diff&rev=89041&r1=89040&r2=89041
==============================================================================
--- trunk/include/asterisk/jabber.h (original)
+++ trunk/include/asterisk/jabber.h Tue Nov  6 12:44:19 2007
@@ -181,8 +181,10 @@
 	ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
 };
 
-/*! Send jabber message from connected client to jabber URI */
-int ast_aji_send(struct aji_client *client, const char *address, const char *message);
+/* !Send XML stanza over the established XMPP connection */
+int ast_aji_send(struct aji_client *client, iks *x);
+/*! Send jabber chat message from connected client to jabber URI */
+int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message);
 /*! Disconnect jabber client */
 int ast_aji_disconnect(struct aji_client *client);
 int ast_aji_check_roster(void);

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?view=diff&rev=89041&r1=89040&r2=89041
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue Nov  6 12:44:19 2007
@@ -80,7 +80,6 @@
 static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, int timeout);
 static int aji_recv(struct aji_client *client, int timeout);
 static int aji_send_header(struct aji_client *client, const char *to);
-static int aji_send(struct aji_client *client, iks *x);
 static int aji_send_raw(struct aji_client *client, const char *xmlstr);
 static void aji_log_hook(void *data, const char *xmpp, size_t size, int is_incoming);
 static int aji_start_sasl(struct aji_client *client, enum ikssasltype type, char *username, char *pass);
@@ -502,7 +501,7 @@
 		return -1;
 	}
 	if (strchr(args.recipient, '@') && !ast_strlen_zero(args.message))
-		ast_aji_send(client, args.recipient, args.message);
+		ast_aji_send_chat(client, args.recipient, args.message);
 	return 0;
 }
 
@@ -714,7 +713,7 @@
  * \param x the XMPP packet to send
  * \return IKS_OK on success, any other value on failure
  */
-static int aji_send(struct aji_client *client, iks *x)
+int ast_aji_send(struct aji_client *client, iks *x)
 {
 	return aji_send_raw(client, iks_string(iks_stack(x), x));
 }
@@ -818,7 +817,7 @@
 	snprintf(s, len, "%c%s%c%s", 0, username, 0, pass);
 	ast_base64encode(base64, (const unsigned char *) s, len, (len + 2) * 4 / 3);
 	iks_insert_cdata(x, base64, 0);
-	aji_send(client, x);
+	ast_aji_send(client, x);
 	iks_delete(x);
 
 	return IKS_OK;
@@ -870,7 +869,7 @@
 					iks_insert_attrib(auth, "id", client->mid);
 					iks_insert_attrib(auth, "to", client->jid->server);
 					ast_aji_increment_mid(client->mid);
-					aji_send(client, auth);
+					ast_aji_send(client, auth);
 					iks_delete(auth);
 				} else
 					ast_log(LOG_ERROR, "Out of memory.\n");
@@ -896,7 +895,7 @@
 							if (auth) {
 								iks_insert_attrib(auth, "id", client->mid);
 								ast_aji_increment_mid(client->mid);
-								aji_send(client, auth);
+								ast_aji_send(client, auth);
 								iks_delete(auth);
 							} else {
 								ast_log(LOG_ERROR, "Out of memory.\n");
@@ -909,7 +908,7 @@
 							if (auth) {
 								iks_insert_attrib(auth, "id", "auth");
 								ast_aji_increment_mid(client->mid);
-								aji_send(client, auth);
+								ast_aji_send(client, auth);
 								iks_delete(auth);
 							} else {
 								ast_log(LOG_ERROR, "Out of memory.\n");
@@ -1040,7 +1039,7 @@
 			iks_insert_attrib(iq, "to", pak->from->full);
 			iks_insert_attrib(iq, "id", pak->id);
 			iks_insert_attrib(iq, "type", "result");
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 
 			iks_insert_attrib(presence, "from", client->jid->full);
 			iks_insert_attrib(presence, "to", pak->from->partial);
@@ -1049,7 +1048,7 @@
 			iks_insert_attrib(presence, "type", "subscribe");
 			iks_insert_attrib(x, "xmlns", "vcard-temp:x:update");
 			iks_insert_node(presence, x);
-			aji_send(client, presence); 
+			ast_aji_send(client, presence); 
 		}
 	} else {
 		ast_log(LOG_ERROR, "Out of memory.\n");
@@ -1099,7 +1098,7 @@
 			iks_insert_node(iq, query);
 			iks_insert_node(iq, error);
 			iks_insert_node(error, notacceptable);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1126,7 +1125,7 @@
 			iks_insert_cdata(instructions, explain, 0);
 			iks_insert_node(iq, query);
 			iks_insert_node(query, instructions);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1170,7 +1169,7 @@
 
 			iks_insert_node(iq, query);
 			iks_insert_node(query, item);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1199,7 +1198,7 @@
 
 			iks_insert_node(iq, query);
 			iks_insert_node(query, confirm);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1226,7 +1225,7 @@
 			iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands");
 			iks_insert_node(iq, query);
 			iks_insert_node(query, feature);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1287,7 +1286,7 @@
 			iks_insert_node(query, ident);
 			iks_insert_node(query, google);
 			iks_insert_node(query, disco);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else
 			ast_log(LOG_ERROR, "Out of Memory.\n");
 		if (iq)
@@ -1374,7 +1373,7 @@
 			iks_insert_node(query, version);
 			iks_insert_node(query, vcard);
 			iks_insert_node(query, search);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1418,7 +1417,7 @@
 			iks_insert_attrib(confirm, "jid", client->user);
 			iks_insert_node(iq, query);
 			iks_insert_node(query, confirm);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1445,7 +1444,7 @@
 			iks_insert_attrib(feature, "var", "http://jabber.org/protocol/commands");
 			iks_insert_node(iq, query);
 			iks_insert_node(query, feature);
-			aji_send(client, iq);
+			ast_aji_send(client, iq);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1686,7 +1685,7 @@
 				ast_aji_increment_mid(client->mid);
 				iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
 				iks_insert_node(iq, query);
-				aji_send(client, iq);
+				ast_aji_send(client, iq);
 				
 			} else
 				ast_log(LOG_ERROR, "Out of memory.\n");
@@ -1750,7 +1749,7 @@
 				iks_insert_attrib(presence, "id", pak->id);
 			iks_insert_cdata(status, "Asterisk has approved subscription", 0);
 			iks_insert_node(presence, status);
-			aji_send(client, presence);
+			ast_aji_send(client, presence);
 		} else
 			ast_log(LOG_ERROR, "Unable to allocate nodes\n");
 		if (presence)
@@ -1787,7 +1786,7 @@
  * \param message
  * \return 1.
  */
-int ast_aji_send(struct aji_client *client, const char *address, const char *message)
+int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message)
 {
 	int res = 0;
 	iks *message_packet = NULL;
@@ -1795,7 +1794,7 @@
 		message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message);
 		if (message_packet) {
 			iks_insert_attrib(message_packet, "from", client->jid->full);
-			res = aji_send(client, message_packet);
+			res = ast_aji_send(client, message_packet);
 		} else {
 			ast_log(LOG_ERROR, "Out of memory.\n");
 		}
@@ -1824,7 +1823,7 @@
 		iks_insert_attrib(iq, "to", server);
 		iks_insert_attrib(iq, "id", client->mid);
 		ast_aji_increment_mid(client->mid);
-		aji_send(client, iq);
+		ast_aji_send(client, iq);
 	} else 
 		ast_log(LOG_ERROR, "Out of memory.\n");
 	return res;
@@ -1846,10 +1845,10 @@
 		iks_insert_cdata(priority, "0", 1);
 		iks_insert_attrib(presence, "to", room);
 		iks_insert_node(presence, priority);
-		res = aji_send(client, presence);
+		res = ast_aji_send(client, presence);
 		iks_insert_cdata(priority, "5", 1);
 		iks_insert_attrib(presence, "to", room);
-		res = aji_send(client, presence);
+		res = ast_aji_send(client, presence);
 	} else 
 		ast_log(LOG_ERROR, "Out of memory.\n");
 	if (presence)
@@ -1884,7 +1883,7 @@
 		iks_insert_attrib(namespace, "jid", room);
 		iks_insert_node(invite, body);
 		iks_insert_node(invite, namespace);
-		res = aji_send(client, invite);
+		res = ast_aji_send(client, invite);
 	} else 
 		ast_log(LOG_ERROR, "Out of memory.\n");
 	if (body)
@@ -1997,7 +1996,7 @@
 		iks_insert_attrib(send, "id", client->mid);
 		ast_aji_increment_mid(client->mid);
 		iks_insert_attrib(send, "from", client->user);
-		res = aji_send(client, send);
+		res = ast_aji_send(client, send);
 	} else 
 		ast_log(LOG_ERROR, "Out of memory.\n");
 
@@ -2042,7 +2041,7 @@
 		iks_insert_node(regiq, regquery);
 		iks_insert_node(regquery, reguser);
 		iks_insert_node(regquery, regpass);
-		res = aji_send(client, regiq);
+		res = ast_aji_send(client, regiq);
 	} else
 		ast_log(LOG_ERROR, "Out of memory.\n");
 	if (regiq)
@@ -2079,10 +2078,10 @@
 			/* For an aji_buddy, both AUTOPRUNE and AUTOREGISTER will never
 			 * be called at the same time */
 			if (ast_test_flag(iterator, AJI_AUTOPRUNE)) {
-				res = aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
+				res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
 						"GoodBye your status is no longer needed by Asterisk the Open Source PBX"
 						" so I am no longer subscribing to your presence.\n"));
-				res = aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
+				res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
 						"GoodBye you are no longer in the asterisk config file so I am removing"
 						" your access to my presence.\n"));
 				iks_insert_attrib(removeiq, "from", client->jid->full); 
@@ -2090,9 +2089,9 @@
 				iks_insert_attrib(removequery, "xmlns", "jabber:iq:roster");
 				iks_insert_attrib(removeitem, "jid", iterator->name);
 				iks_insert_attrib(removeitem, "subscription", "remove");
-				res = aji_send(client, removeiq);
+				res = ast_aji_send(client, removeiq);
 			} else if (ast_test_flag(iterator, AJI_AUTOREGISTER)) {
-				res = aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name, 
+				res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name, 
 						"Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
 				ast_clear_flag(iterator, AJI_AUTOREGISTER);
 			}
@@ -2220,7 +2219,7 @@
 	if(roster) {
 		iks_insert_attrib(roster, "id", "roster");
 		aji_set_presence(client, NULL, client->jid->full, client->status, client->statusmessage);
-		aji_send(client, roster);
+		ast_aji_send(client, roster);
 	}
 	if (roster)
 		iks_delete(roster);
@@ -2329,7 +2328,7 @@
 		iks_insert_attrib(cnode, "ext", "voice-v1");
 		iks_insert_attrib(cnode, "xmlns", "http://jabber.org/protocol/caps");
 		iks_insert_node(presence, cnode);
-		res = aji_send(client, presence);
+		res = ast_aji_send(client, presence);
 	} else
 		ast_log(LOG_ERROR, "Out of memory.\n");
 	if (cnode)
@@ -2540,7 +2539,7 @@
 	}
 
 	/* XXX Does Matt really want everyone to use his personal address for tests? */ /* XXX yes he does */
-	ast_aji_send(client, "mogorman at astjab.org", "blahblah");
+	ast_aji_send_chat(client, "mogorman at astjab.org", "blahblah");
 	ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, {
 		ASTOBJ_RDLOCK(iterator);
 		ast_verbose("User: %s\n", iterator->name);
@@ -2932,7 +2931,7 @@
 		return 0;
 	}	
 	if (strchr(screenname, '@') && message){
-		ast_aji_send(client, screenname, message);	
+		ast_aji_send_chat(client, screenname, message);	
 		if (!ast_strlen_zero(id))
 			astman_append(s, "ActionID: %s\r\n",id);
 		astman_append(s, "Response: Success\r\n");




More information about the asterisk-commits mailing list