diff libpurple/protocols/bonjour/jabber.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 71b017348c39
children 7ade887fd3f6
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c	Mon Mar 19 06:11:46 2007 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Mon Mar 19 07:01:17 2007 +0000
@@ -1,7 +1,7 @@
 /*
- * gaim - Bonjour Protocol Plugin
+ * purple - Bonjour Protocol Plugin
  *
- * Gaim is the legal property of its developers, whose names are too numerous
+ * Purple is the legal property of its developers, whose names are too numerous
  * to list here.  Please refer to the COPYRIGHT file distributed with this
  * source distribution.
  *
@@ -46,7 +46,7 @@
 #include "buddy.h"
 
 static gint
-_connect_to_buddy(GaimBuddy *gb)
+_connect_to_buddy(PurpleBuddy *gb)
 {
 	gint socket_fd;
 	gint retorno = 0;
@@ -62,7 +62,7 @@
 
 	retorno = connect(socket_fd, (struct sockaddr*)&buddy_address, sizeof(struct sockaddr));
 	if (retorno == -1) {
-		gaim_debug_warning("bonjour", "connect error: %s\n", strerror(errno));
+		purple_debug_warning("bonjour", "connect error: %s\n", strerror(errno));
 	}
 	fcntl(socket_fd, F_SETFL, O_NONBLOCK);
 
@@ -71,7 +71,7 @@
 
 #if 0 /* this isn't used anywhere... */
 static const char *
-_font_size_gaim_to_ichat(int size)
+_font_size_purple_to_ichat(int size)
 {
 	switch (size) {
 		case 1:
@@ -95,7 +95,7 @@
 #endif
 
 static const char *
-_font_size_ichat_to_gaim(int size)
+_font_size_ichat_to_purple(int size)
 {
 	if (size > 24) {
 		return "7";
@@ -114,7 +114,7 @@
 	return "1";
 }
 static void
-_jabber_parse_and_write_message_to_ui(char *message, GaimConnection *connection, GaimBuddy *gb)
+_jabber_parse_and_write_message_to_ui(char *message, PurpleConnection *connection, PurpleBuddy *gb)
 {
 	xmlnode *body_node = NULL;
 	char *body = NULL;
@@ -163,13 +163,13 @@
 				font_size = xmlnode_get_attrib(html_body_font_node, "ABSZ");
 				if (font_size != NULL)
 				{
-					font_size = _font_size_ichat_to_gaim(atoi(font_size));
+					font_size = _font_size_ichat_to_purple(atoi(font_size));
 				}
 				font_color = xmlnode_get_attrib(html_body_font_node, "color");
 				html_body = xmlnode_get_data(html_body_font_node);
 				if (html_body == NULL)
 				{
-					/* This is the kind of formated messages that Gaim creates */
+					/* This is the kind of formated messages that Purple creates */
 					html_body = xmlnode_to_str(html_body_font_node, &garbage);
 				}
 			} else {
@@ -220,14 +220,14 @@
 
 struct _check_buddy_by_address_t {
 	char *address;
-	GaimBuddy **gb;
+	PurpleBuddy **gb;
 	BonjourJabber *bj;
 };
 
 static void
 _check_buddy_by_address(gpointer key, gpointer value, gpointer data)
 {
-	GaimBuddy *gb = (GaimBuddy*)value;
+	PurpleBuddy *gb = (PurpleBuddy*)value;
 	BonjourBuddy *bb;
 	struct _check_buddy_by_address_t *cbba;
 
@@ -235,7 +235,7 @@
 	cbba = data;
 
 	/*
-	 * If the current GaimBuddy's data is not null and the GaimBuddy's account
+	 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account
 	 * is the same as the account requesting the check then continue to determine
 	 * whether the buddies IP matches the target IP.
 	 */
@@ -264,7 +264,7 @@
 
 	if (partial_message_length == -1)
 	{
-		gaim_debug_warning("bonjour", "receive error: %s\n", strerror(errno));
+		purple_debug_warning("bonjour", "receive error: %s\n", strerror(errno));
 		if (total_message_length == 0) {
 			return -1;
 		}
@@ -273,7 +273,7 @@
 	*message = data->str;
 	g_string_free(data, FALSE);
 	if (total_message_length != 0)
-		gaim_debug_info("bonjour", "Receive: -%s- %d bytes\n", *message, total_message_length);
+		purple_debug_info("bonjour", "Receive: -%s- %d bytes\n", *message, total_message_length);
 
 	return total_message_length;
 }
@@ -299,13 +299,13 @@
 }
 
 static void
-_client_socket_handler(gpointer data, gint socket, GaimInputCondition condition)
+_client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition)
 {
 	char *message = NULL;
 	gint message_length;
-	GaimBuddy *gb = (GaimBuddy*)data;
-	GaimAccount *account = gb->account;
-	GaimConversation *conversation;
+	PurpleBuddy *gb = (PurpleBuddy*)data;
+	PurpleAccount *account = gb->account;
+	PurpleConversation *conversation;
 	char *closed_conv_message;
 	BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data;
 	gboolean closed_conversation = FALSE;
@@ -345,7 +345,7 @@
 			/* TODO: This needs to be nonblocking! */
 			if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1)
 			{
-				gaim_debug_error("bonjour", "Unable to start a conversation with %s\n", bb->name);
+				purple_debug_error("bonjour", "Unable to start a conversation with %s\n", bb->name);
 			}
 			else
 			{
@@ -359,20 +359,20 @@
 	 * using a magic string, but xmlnode won't play nice when just
 	 * parsing an end tag
 	 */
-	if (gaim_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) {
+	if (purple_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) {
 		/* Close the socket, clear the watcher and free memory */
 		if (bb->conversation != NULL) {
 			close(bb->conversation->socket);
-			gaim_input_remove(bb->conversation->watcher_id);
+			purple_input_remove(bb->conversation->watcher_id);
 			g_free(bb->conversation->buddy_name);
 			g_free(bb->conversation);
 			bb->conversation = NULL;
 		}
 
 		/* Inform the user that the conversation has been closed */
-		conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, gb->name, account);
+		conversation = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, gb->name, account);
 		closed_conv_message = g_strdup_printf(_("%s has closed the conversation."), gb->name);
-		gaim_conversation_write(conversation, NULL, closed_conv_message, GAIM_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write(conversation, NULL, closed_conv_message, PURPLE_MESSAGE_SYSTEM, time(NULL));
 		g_free(closed_conv_message);
 	} else {
 		/* Parse the message to get the data and send to the ui */
@@ -384,20 +384,20 @@
 }
 
 static void
-_server_socket_handler(gpointer data, int server_socket, GaimInputCondition condition)
+_server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
 {
-	GaimBuddy *gb = NULL;
+	PurpleBuddy *gb = NULL;
 	struct sockaddr_in their_addr; /* connector's address information */
 	socklen_t sin_size = sizeof(struct sockaddr);
 	int client_socket;
 	BonjourBuddy *bb = NULL;
 	BonjourJabber *bj = data;
 	char *address_text = NULL;
-	GaimBuddyList *bl = gaim_get_blist();
+	PurpleBuddyList *bl = purple_get_blist();
 	struct _check_buddy_by_address_t *cbba;
 
 	/* Check that it is a read condition */
-	if (condition != GAIM_INPUT_READ) {
+	if (condition != PURPLE_INPUT_READ) {
 		return;
 	}
 
@@ -417,7 +417,7 @@
 	g_free(cbba);
 	if (gb == NULL)
 	{
-		gaim_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
+		purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
 		close(client_socket);
 		return;
 	}
@@ -439,7 +439,7 @@
 		}
 
 		/* Open a watcher for the client socket */
-		bb->conversation->watcher_id = gaim_input_add(client_socket, GAIM_INPUT_READ,
+		bb->conversation->watcher_id = purple_input_add(client_socket, PURPLE_INPUT_READ,
 													_client_socket_handler, gb);
 	} else {
 		close(client_socket);
@@ -457,16 +457,16 @@
 	/* Open a listening socket for incoming conversations */
 	if ((data->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0)
 	{
-		gaim_debug_error("bonjour", "Cannot open socket: %s\n", strerror(errno));
-		gaim_connection_error(data->account->gc, _("Cannot open socket"));
+		purple_debug_error("bonjour", "Cannot open socket: %s\n", strerror(errno));
+		purple_connection_error(data->account->gc, _("Cannot open socket"));
 		return -1;
 	}
 
 	/* Make the socket reusable */
 	if (setsockopt(data->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0)
 	{
-		gaim_debug_error("bonjour", "Error setting socket options: %s\n", strerror(errno));
-		gaim_connection_error(data->account->gc, _("Error setting socket options"));
+		purple_debug_error("bonjour", "Error setting socket options: %s\n", strerror(errno));
+		purple_connection_error(data->account->gc, _("Error setting socket options"));
 		return -1;
 	}
 
@@ -489,31 +489,31 @@
 	/* On no!  We tried 10 ports and could not bind to ANY of them */
 	if (!bind_successful)
 	{
-		gaim_debug_error("bonjour", "Cannot bind socket: %s\n", strerror(errno));
-		gaim_connection_error(data->account->gc, _("Could not bind socket to port"));
+		purple_debug_error("bonjour", "Cannot bind socket: %s\n", strerror(errno));
+		purple_connection_error(data->account->gc, _("Could not bind socket to port"));
 		return -1;
 	}
 
 	/* Attempt to listen on the bound socket */
 	if (listen(data->socket, 10) != 0)
 	{
-		gaim_debug_error("bonjour", "Cannot listen on socket: %s\n", strerror(errno));
-		gaim_connection_error(data->account->gc, _("Could not listen on socket"));
+		purple_debug_error("bonjour", "Cannot listen on socket: %s\n", strerror(errno));
+		purple_connection_error(data->account->gc, _("Could not listen on socket"));
 		return -1;
 	}
 
 #if 0
 	/* TODO: Why isn't this being used? */
-	data->socket = gaim_network_listen(data->port, SOCK_STREAM);
+	data->socket = purple_network_listen(data->port, SOCK_STREAM);
 
 	if (data->socket == -1)
 	{
-		gaim_debug_error("bonjour", "No se ha podido crear el socket\n");
+		purple_debug_error("bonjour", "No se ha podido crear el socket\n");
 	}
 #endif
 
 	/* Open a watcher in the socket we have just opened */
-	data->watcher_id = gaim_input_add(data->socket, GAIM_INPUT_READ, _server_socket_handler, data);
+	data->watcher_id = purple_input_add(data->socket, PURPLE_INPUT_READ, _server_socket_handler, data);
 
 	return data->port;
 }
@@ -529,14 +529,14 @@
 	xmlnode *message_html_body_node = NULL;
 	xmlnode *message_html_body_font_node = NULL;
 	xmlnode *message_x_node = NULL;
-	GaimBuddy *gb = NULL;
+	PurpleBuddy *gb = NULL;
 	BonjourBuddy *bb = NULL;
-	GaimConversation *conversation = NULL;
+	PurpleConversation *conversation = NULL;
 	char *message_from_ui = NULL;
 	char *stripped_message = NULL;
 	gint ret;
 
-	gb = gaim_find_buddy(data->account, to);
+	gb = purple_find_buddy(data->account, to);
 	if (gb == NULL)
 		/* You can not send a message to an offline buddy */
 		return -10000;
@@ -545,7 +545,7 @@
 
 	/* Enclose the message from the UI within a "font" node */
 	message_body_node = xmlnode_new("body");
-	stripped_message = gaim_markup_strip_html(body);
+	stripped_message = purple_markup_strip_html(body);
 	xmlnode_insert_data(message_body_node, stripped_message, strlen(stripped_message));
 	g_free(stripped_message);
 
@@ -582,8 +582,8 @@
 		bb->conversation->socket = _connect_to_buddy(gb);
 		bb->conversation->stream_started = FALSE;
 		bb->conversation->buddy_name = g_strdup(gb->name);
-		bb->conversation->watcher_id = gaim_input_add(bb->conversation->socket,
-				GAIM_INPUT_READ, _client_socket_handler, gb);
+		bb->conversation->watcher_id = purple_input_add(bb->conversation->socket,
+				PURPLE_INPUT_READ, _client_socket_handler, gb);
 	}
 
 	/* Check if the stream for the conversation has been started */
@@ -592,14 +592,14 @@
 		/* Start the stream */
 		if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1)
 		{
-				gaim_debug_error("bonjour", "Unable to start a conversation\n");
-				gaim_debug_warning("bonjour", "send error: %s\n", strerror(errno));
-				conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, bb->name, data->account);
-				gaim_conversation_write(conversation, NULL, 
+				purple_debug_error("bonjour", "Unable to start a conversation\n");
+				purple_debug_warning("bonjour", "send error: %s\n", strerror(errno));
+				conversation = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, data->account);
+				purple_conversation_write(conversation, NULL, 
 										_("Unable to send the message, the conversation couldn't be started."),
-										GAIM_MESSAGE_SYSTEM, time(NULL));
+										PURPLE_MESSAGE_SYSTEM, time(NULL));
 				close(bb->conversation->socket);
-				gaim_input_remove(bb->conversation->watcher_id);
+				purple_input_remove(bb->conversation->watcher_id);
 
 				/* Free all the data related to the conversation */
 				g_free(bb->conversation->buddy_name);
@@ -623,7 +623,7 @@
 }
 
 void
-bonjour_jabber_close_conversation(BonjourJabber *data, GaimBuddy *gb)
+bonjour_jabber_close_conversation(BonjourJabber *data, PurpleBuddy *gb)
 {
 	BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data;
 
@@ -634,7 +634,7 @@
 
 		/* Close the socket and remove the watcher */
 		close(bb->conversation->socket);
-		gaim_input_remove(bb->conversation->watcher_id);
+		purple_input_remove(bb->conversation->watcher_id);
 
 		/* Free all the data related to the conversation */
 		g_free(bb->conversation->buddy_name);
@@ -646,28 +646,28 @@
 void
 bonjour_jabber_stop(BonjourJabber *data)
 {
-	GaimBuddy *gb = NULL;
+	PurpleBuddy *gb = NULL;
 	BonjourBuddy *bb = NULL;
 	GSList *buddies;
 	GSList *l;
 
 	/* Close the server socket and remove all the watcher */
 	close(data->socket);
-	gaim_input_remove(data->watcher_id);
+	purple_input_remove(data->watcher_id);
 
 	/* Close all the sockets and remove all the watchers after sending end streams */
 	if (data->account->gc != NULL)
 	{
-		buddies = gaim_find_buddies(data->account, data->account->username);
+		buddies = purple_find_buddies(data->account, data->account->username);
 		for (l = buddies; l; l = l->next)
 		{
-			gb = (GaimBuddy*)l->data;
+			gb = (PurpleBuddy*)l->data;
 			bb = (BonjourBuddy*)gb->proto_data;
 			if (bb->conversation != NULL)
 			{
 				send(bb->conversation->socket, STREAM_END, strlen(STREAM_END), 0);
 				close(bb->conversation->socket);
-				gaim_input_remove(bb->conversation->watcher_id);
+				purple_input_remove(bb->conversation->watcher_id);
 			}
 		}
 		g_slist_free(buddies);