gobjectification.conversation: e2083369: IRC compiles.

sadrul at pidgin.im sadrul at pidgin.im
Sat Jul 24 23:55:38 EDT 2010


----------------------------------------------------------------------
Revision: e2083369c97cc5cdb95ba1c199a503f3fa59f0ca
Parent:   366b859dc4699232c6b986e97239425529feceac
Author:   sadrul at pidgin.im
Date:     07/24/10 23:46:57
Branch:   im.pidgin.gobjectification.conversation
URL: http://d.pidgin.im/viewmtn/revision/info/e2083369c97cc5cdb95ba1c199a503f3fa59f0ca

Changelog: 

IRC compiles.

Changes against parent 366b859dc4699232c6b986e97239425529feceac

  patched  libpurple/protocols/irc/cmds.c
  patched  libpurple/protocols/irc/irc.c
  patched  libpurple/protocols/irc/msgs.c
  patched  libpurple/protocols/irc/parse.c

-------------- next part --------------
============================================================
--- libpurple/protocols/irc/irc.c	915392f81a4ee924cb2afabbb08fe3ce12e36254
+++ libpurple/protocols/irc/irc.c	9bbd5a744629bea2828611ddec795646daee81f5
@@ -722,7 +722,7 @@ static void irc_chat_invite(PurpleConnec
 static void irc_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name)
 {
 	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
-	PurpleConversation *convo = purple_find_chat(gc, id);
+	PurpleConversation *convo = purple_conversations_find_muc(gc, id);
 	const char *args[2];
 
 	if (!convo) {
@@ -738,7 +738,7 @@ static void irc_chat_leave (PurpleConnec
 static void irc_chat_leave (PurpleConnection *gc, int id)
 {
 	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
-	PurpleConversation *convo = purple_find_chat(gc, id);
+	PurpleConversation *convo = purple_conversations_find_muc(gc, id);
 	const char *args[2];
 
 	if (!convo)
@@ -753,7 +753,7 @@ static int irc_chat_send(PurpleConnectio
 static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags)
 {
 	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
-	PurpleConversation *convo = purple_find_chat(gc, id);
+	PurpleConversation *convo = purple_conversations_find_muc(gc, id);
 	const char *args[2];
 	char *tmp;
 
@@ -807,7 +807,7 @@ static void irc_chat_set_topic(PurpleCon
 	struct irc_conn *irc;
 
 	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
-	name = purple_conversation_get_name(purple_find_chat(gc, id));
+	name = purple_conversation_get_name(purple_conversations_find_muc(gc, id));
 
 	if (name == NULL)
 		return;
============================================================
--- libpurple/protocols/irc/cmds.c	cae378b6e58993aa5289177141456187cd6b9360
+++ libpurple/protocols/irc/cmds.c	1488728c8a89dcab58773042b964e779567e650d
@@ -34,17 +34,14 @@ int irc_cmd_default(struct irc_conn *irc
 
 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
 {
-	PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, target, irc->account);
+	PurpleConversation *convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, target);
 	char *buf;
 
 	if (!convo)
 		return 1;
 
 	buf = g_strdup_printf(_("Unknown command: %s"), cmd);
-	if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_IM)
-		purple_conv_im_write(PURPLE_CONV_IM(convo), "", buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
-	else
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+	purple_conversation_write_message(convo, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG);
 	g_free(buf);
 
 	return 1;
@@ -132,20 +129,21 @@ int irc_cmd_ctcp_action(struct irc_conn 
 	g_free(newargs[1]);
 	g_free(newargs);
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, target, irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, target);
 	if (convo) {
 		escaped = g_markup_escape_text(args[0], -1);
 		action = g_strdup_printf("/me %s", escaped);
 		g_free(escaped);
 		if (action[strlen(action) - 1] == '\n')
 			action[strlen(action) - 1] = '\0';
-		if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT)
-			serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)),
+		if (PURPLE_IS_MUC(convo))
+			serv_got_chat_in(gc, purple_muc_get_id(PURPLE_MUC(convo)),
 			                 purple_connection_get_display_name(gc),
 			                 PURPLE_MESSAGE_SEND, action, time(NULL));
 		else
-			purple_conv_im_write(PURPLE_CONV_IM(convo), purple_connection_get_display_name(gc),
-			                     action, PURPLE_MESSAGE_SEND, time(NULL));
+			purple_conversation_write(convo,
+					purple_message_new(purple_connection_get_display_name(gc), NULL,
+			                     action, PURPLE_MESSAGE_SEND, time(NULL)));
 		g_free(action);
 	}
 
@@ -205,7 +203,7 @@ int irc_cmd_kick(struct irc_conn *irc, c
 	if (!args || !args[0])
 		return 0;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, target, irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, target);
 	if (!convo)
 		return 0;
 
@@ -452,14 +450,15 @@ int irc_cmd_query(struct irc_conn *irc, 
 	if (!args || !args[0])
 		return 0;
 
-	convo = purple_conversation_new(PURPLE_CONV_TYPE_IM, irc->account, args[0]);
+	convo = PURPLE_CONVERSATION(purple_im_new(irc->account, args[0]));
 	purple_conversation_present(convo);
 
 	if (args[1]) {
 		gc = purple_account_get_connection(irc->account);
 		irc_cmd_privmsg(irc, cmd, target, args);
-		purple_conv_im_write(PURPLE_CONV_IM(convo), purple_connection_get_display_name(gc),
-			      args[1], PURPLE_MESSAGE_SEND, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(purple_connection_get_display_name(gc), NULL,
+			      args[1], PURPLE_MESSAGE_SEND, time(NULL)));
 	}
 
 	return 0;
@@ -522,12 +521,12 @@ int irc_cmd_topic(struct irc_conn *irc, 
 	if (!args)
 		return 0;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, target, irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, target);
 	if (!convo)
 		return 0;
 
 	if (!args[0]) {
-		topic = purple_conv_chat_get_topic (PURPLE_CONV_CHAT(convo));
+		topic = purple_muc_get_topic(PURPLE_MUC(convo));
 
 		if (topic) {
 			char *tmp, *tmp2;
@@ -538,7 +537,9 @@ int irc_cmd_topic(struct irc_conn *irc, 
 			g_free(tmp2);
 		} else
 			buf = g_strdup(_("No topic is set"));
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), target, buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(target, NULL, buf,
+					PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)));
 		g_free(buf);
 
 		return 0;
============================================================
--- libpurple/protocols/irc/msgs.c	d42d10698876a4b49d9c17257a5fa3672bf77e4f
+++ libpurple/protocols/irc/msgs.c	d5f056431a0bd58118b283b60bcf27b26b8225c5
@@ -176,8 +176,11 @@ void irc_msg_away(struct irc_conn *irc, 
 
 	gc = purple_account_get_connection(irc->account);
 	if (gc) {
+		PurpleMessage *message;
 		msg = g_markup_escape_text(args[2], -1);
-		serv_got_im(gc, args[1], msg, PURPLE_MESSAGE_AUTO_RESP, time(NULL));
+		message  = purple_message_new(args[1], NULL, msg, PURPLE_MESSAGE_AUTO_RESP, time(NULL));
+		if (!purple_im_new_with_receive(purple_connection_get_account(gc), message))
+			purple_message_free(message);
 		g_free(msg);
 	}
 }
@@ -199,8 +202,7 @@ void irc_msg_ban(struct irc_conn *irc, c
 	if (!args || !args[0] || !args[1])
 		return;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
-						      args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 
 	if (!strcmp(name, "367")) {
 		char *msg = NULL;
@@ -219,9 +221,7 @@ void irc_msg_ban(struct irc_conn *irc, c
 			msg = g_strdup_printf(_("Ban on %s"), args[2]);
 		}
 		if (convo) {
-			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg,
-			                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
-			                       time(NULL));
+			purple_conversation_write_message(convo, msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG);
 		} else {
 			purple_debug_info("irc", "%s\n", msg);
 		}
@@ -230,10 +230,8 @@ void irc_msg_ban(struct irc_conn *irc, c
 		if (!convo)
 			return;
 		/* End of ban list */
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "",
-		                       _("End of ban list"),
-		                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
-		                       time(NULL));
+		purple_conversation_write_message(convo, _("End of ban list"),
+				PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG);
 	}
 }
 
@@ -258,16 +256,14 @@ void irc_msg_banfull(struct irc_conn *ir
 	if (!args || !args[0] || !args[1] || !args[2])
 		return;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 	if (!convo)
 		return;
 
 	nick = g_markup_escape_text(args[2], -1);
 	buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick);
 	g_free(nick);
-	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf,
-			     PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
-			     time(NULL));
+	purple_conversation_write_message(convo, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG);
 	g_free(buf);
 }
 
@@ -279,13 +275,13 @@ void irc_msg_chanmode(struct irc_conn *i
 	if (!args || !args[1] || !args[2])
 		return;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 	if (!convo)	/* XXX punt on channels we are not in for now */
 		return;
 
 	escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL;
 	buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : "");
-	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+	purple_conversation_write_message(convo, buf, PURPLE_MESSAGE_SYSTEM);
 	g_free(escaped);
 	g_free(buf);
 
@@ -460,7 +456,7 @@ void irc_msg_topic(struct irc_conn *irc,
 		topic = irc_mirc2txt (args[2]);
 	}
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chan, irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, chan);
 	if (!convo) {
 		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan);
 		g_free(topic);
@@ -472,28 +468,29 @@ void irc_msg_topic(struct irc_conn *irc,
 	tmp2 = purple_markup_linkify(tmp);
 	g_free(tmp);
 	if (!strcmp(name, "topic")) {
-		const char *current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(convo));
+		const char *current_topic = purple_muc_get_topic(PURPLE_MUC(convo));
 		if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0))
 		{
 			char *nick_esc;
 			nick = irc_mask_nick(from);
 			nick_esc = g_markup_escape_text(nick, -1);
-			purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), nick, topic);
+			purple_muc_set_topic(PURPLE_MUC(convo), nick, topic, 0);
 			if (*tmp2)
 				msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2);
 			else
 				msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc);
 			g_free(nick_esc);
 			g_free(nick);
-			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+			purple_conversation_write(convo,
+					purple_message_new(from, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)));
 			g_free(msg);
 		}
 	} else {
 		char *chan_esc = g_markup_escape_text(chan, -1);
 		msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2);
 		g_free(chan_esc);
-		purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic);
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_muc_set_topic(PURPLE_MUC(convo), NULL, topic, 0);
+		purple_conversation_write_message(convo, msg, PURPLE_MESSAGE_SYSTEM);
 		g_free(msg);
 	}
 	g_free(tmp2);
@@ -519,7 +516,7 @@ void irc_msg_names(struct irc_conn *irc,
 	PurpleConversation *convo;
 
 	if (!strcmp(name, "366")) {
-		convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account);
+		convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, args[1]);
 		if (!convo) {
 			purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]);
 			g_string_free(irc->names, TRUE);
@@ -529,12 +526,10 @@ void irc_msg_names(struct irc_conn *irc,
 
 		names = cur = g_string_free(irc->names, FALSE);
 		irc->names = NULL;
-		if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) {
+		if (g_object_get_data(G_OBJECT(convo), IRC_NAMES_FLAG)) {
 			msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
-			if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT)
-				purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
-			else
-				purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+			purple_conversation_write_message(convo, msg,
+					PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG);
 			g_free(msg);
 		} else {
 			GList *users = NULL;
@@ -571,7 +566,7 @@ void irc_msg_names(struct irc_conn *irc,
 			if (users != NULL) {
 				GList *l;
 
-				purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE);
+				purple_muc_add_users(PURPLE_MUC(convo), users, NULL, flags, FALSE);
 
 				for (l = users; l != NULL; l = l->next)
 					g_free(l->data);
@@ -580,7 +575,7 @@ void irc_msg_names(struct irc_conn *irc,
 				g_list_free(flags);
 			}
 
-			purple_conversation_set_data(convo, IRC_NAMES_FLAG,
+			g_object_set_data(G_OBJECT(convo), IRC_NAMES_FLAG,
 						   GINT_TO_POINTER(TRUE));
 		}
 		g_free(names);
@@ -657,14 +652,12 @@ void irc_msg_nonick(struct irc_conn *irc
 	PurpleConnection *gc;
 	PurpleConversation *convo;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, args[1]);
 	if (convo) {
-		if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */
-			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"),
-					PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
-		else
-			purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"),
-				      PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(args[1], NULL,
+					PURPLE_IS_MUC(convo) ? _("no such channel") : _("User is not logged in"),
+					PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)));
 	} else {
 		if ((gc = purple_account_get_connection(irc->account)) == NULL)
 			return;
@@ -682,9 +675,11 @@ void irc_msg_nosend(struct irc_conn *irc
 	PurpleConnection *gc;
 	PurpleConversation *convo;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 	if (convo) {
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(args[1], NULL, args[2],
+					PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)));
 	} else {
 		if ((gc = purple_account_get_connection(irc->account)) == NULL)
 			return;
@@ -694,13 +689,15 @@ void irc_msg_notinchan(struct irc_conn *
 
 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
-	PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	PurpleConversation *convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 
 	purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]);
 	if (convo) {
 		/*g_slist_remove(purple_account_get_connection(irc)->buddy_chats, convo);
 		  purple_conversation_set_account(convo, NULL);*/
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(args[1], NULL, args[2],
+					PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)));
 	}
 }
 
@@ -711,11 +708,11 @@ void irc_msg_notop(struct irc_conn *irc,
 	if (!args || !args[1] || !args[2])
 		return;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 	if (!convo)
 		return;
 
-	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL));
+	purple_conversation_write_message(convo, args[2], PURPLE_MESSAGE_SYSTEM);
 }
 
 void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -807,15 +804,13 @@ void irc_msg_join(struct irc_conn *irc, 
 		/* We are joining a channel for the first time */
 		serv_got_joined_chat(gc, id++, args[0]);
 		g_free(nick);
-		convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
-							    args[0],
-							    irc->account);
+		convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[0]);
 
 		if (convo == NULL) {
 			purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]);
 			return;
 		}
-		purple_conversation_set_data(convo, IRC_NAMES_FLAG,
+		g_object_set_data(G_OBJECT(convo), IRC_NAMES_FLAG,
 					   GINT_TO_POINTER(FALSE));
 		/* Until purple_conversation_present does something that
 		 * one would expect in Pidgin, this call produces buggy
@@ -824,7 +819,7 @@ void irc_msg_join(struct irc_conn *irc, 
 		return;
 	}
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[0]);
 	if (convo == NULL) {
 		purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]);
 		g_free(nick);
@@ -832,7 +827,7 @@ void irc_msg_join(struct irc_conn *irc, 
 	}
 
 	userhost = irc_mask_userhost(from);
-	purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE);
+	purple_muc_add_user(PURPLE_MUC(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE);
 
 	if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) {
 		ib->flag = TRUE;
@@ -846,7 +841,7 @@ void irc_msg_kick(struct irc_conn *irc, 
 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
-	PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account);
+	PurpleConversation *convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[0]);
 	char *nick = irc_mask_nick(from), *buf;
 
 	if (!gc) {
@@ -862,12 +857,13 @@ void irc_msg_kick(struct irc_conn *irc, 
 
 	if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) {
 		buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(args[0], NULL, buf, PURPLE_MESSAGE_SYSTEM, time(NULL)));
 		g_free(buf);
-		serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
+		serv_got_chat_left(gc, purple_muc_get_id(PURPLE_MUC(convo)));
 	} else {
 		buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]);
-		purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf);
+		purple_muc_remove_user(PURPLE_MUC(convo), args[1], buf);
 		g_free(buf);
 	}
 
@@ -882,7 +878,7 @@ void irc_msg_mode(struct irc_conn *irc, 
 
 	if (*args[0] == '#' || *args[0] == '&') {	/* Channel	*/
 		char *escaped;
-		convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account);
+		convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[0]);
 		if (!convo) {
 			purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]);
 			g_free(nick);
@@ -890,7 +886,8 @@ void irc_msg_mode(struct irc_conn *irc, 
 		}
 		escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL;
 		buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick);
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(args[0], NULL, buf, PURPLE_MESSAGE_SYSTEM, time(NULL)));
 		g_free(escaped);
 		g_free(buf);
 		if(args[2]) {
@@ -909,7 +906,7 @@ void irc_msg_mode(struct irc_conn *irc, 
 				if (!end)
 					end = cur + strlen(cur);
 				user = g_strndup(cur, end - cur);
-				flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user);
+				flags = purple_muc_user_get_flags(PURPLE_MUC(convo), user);
 				newflag = PURPLE_CBFLAGS_NONE;
 				if (*mcur == 'o')
 					newflag = PURPLE_CBFLAGS_OP;
@@ -925,7 +922,7 @@ void irc_msg_mode(struct irc_conn *irc, 
 						flags |= newflag;
 					else
 						flags &= ~newflag;
-					purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(convo), user, flags);
+					purple_muc_user_set_flags(PURPLE_MUC(convo), user, flags);
 				}
 				g_free(user);
 				cur = end;
@@ -972,8 +969,7 @@ void irc_msg_nick(struct irc_conn *irc, 
 	}
 #endif
 
-	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick,
-						   irc->account);
+	conv = purple_conversations_find(PURPLE_TYPE_IM, irc->account, nick);
 	if (conv != NULL)
 		purple_conversation_set_name(conv, args[0]);
 
@@ -1070,7 +1066,7 @@ void irc_msg_part(struct irc_conn *irc, 
 	 * that I can see.  This catches that. */
 	channel = (args[0][0] == ':') ? &args[0][1] : args[0];
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, channel);
 	if (!convo) {
 		purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel);
 		return;
@@ -1083,12 +1079,13 @@ void irc_msg_part(struct irc_conn *irc, 
 		                      (args[1] && *args[1]) ? ": " : "",
 		                      (escaped && *escaped) ? escaped : "");
 		g_free(escaped);
-		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new(channel, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)));
 		g_free(msg);
-		serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
+		serv_got_chat_left(gc, purple_muc_get_id(PURPLE_MUC(convo)));
 	} else {
 		msg = args[1] ? irc_mirc2txt(args[1]) : NULL;
-		purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, msg);
+		purple_muc_remove_user(PURPLE_MUC(convo), nick, msg);
 		g_free(msg);
 	}
 	g_free(nick);
@@ -1128,13 +1125,11 @@ void irc_msg_pong(struct irc_conn *irc, 
 		msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp);
 	}
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_CONVERSATION, irc->account, parts[0]);
 	g_strfreev(parts);
 	if (convo) {
-		if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT)
-			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
-		else
-			purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write(convo,
+				purple_message_new("PONG", NULL, msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)));
 	} else {
 		gc = purple_account_get_connection(irc->account);
 		if (!gc) {
@@ -1185,11 +1180,14 @@ static void irc_msg_handle_privmsg(struc
 	}
 
 	if (!purple_utf8_strcasecmp(to, purple_connection_get_display_name(gc))) {
-		serv_got_im(gc, nick, msg, 0, time(NULL));
+		PurpleMessage *message = purple_message_new(nick, NULL, msg,
+				PURPLE_MESSAGE_RECV, time(NULL));
+		if (!purple_im_new_with_receive(irc->account, message))
+			purple_message_free(message);
 	} else {
-		convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, irc_nick_skip_mode(irc, to), irc->account);
+		convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, irc_nick_skip_mode(irc, to));
 		if (convo)
-			serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL));
+			serv_got_chat_in(gc, purple_muc_get_id(PURPLE_MUC(convo)), nick, 0, msg, time(NULL));
 		else
 			purple_debug_error("irc", "Got a %s on %s, which does not exist\n",
 			                   notice ? "NOTICE" : "PRIVMSG", to);
@@ -1207,7 +1205,7 @@ void irc_msg_regonly(struct irc_conn *ir
 	if (!args || !args[1] || !args[2] || !gc)
 		return;
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+	convo = purple_conversations_find(PURPLE_TYPE_MUC, irc->account, args[1]);
 	if (convo) {
 		/* This is a channel we're already in; for some reason,
 		 * freenode feels the need to notify us that in some
============================================================
--- libpurple/protocols/irc/parse.c	89afe50925245b065b31bd63459157e29498d901
+++ libpurple/protocols/irc/parse.c	b8b271d7aea59e16b9c2e5268683a6df9cf023a4
@@ -167,7 +167,7 @@ static PurpleCmdRet irc_parse_purple_cmd
 	struct irc_conn *irc;
 	struct _irc_user_cmd *cmdent;
 
-	gc = purple_conversation_get_gc(conv);
+	gc = purple_conversation_get_connection(conv);
 	if (!gc)
 		return PURPLE_CMD_RET_FAILED;
 


More information about the Commits mailing list