gobjectification: ca1d8ab9: compile irc.

sadrul at pidgin.im sadrul at pidgin.im
Thu Mar 13 04:39:51 EDT 2008


-----------------------------------------------------------------
Revision: ca1d8ab97d6da9057c07f1caf47984b9e4f5f17d
Ancestor: 9d4403263a8d78f5ca131d9331415320f866ee96
Author: sadrul at pidgin.im
Date: 2008-03-13T06:00:24
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/ca1d8ab97d6da9057c07f1caf47984b9e4f5f17d

Modified files:
        libpurple/protocols/irc/dcc_send.c
        libpurple/protocols/irc/irc.c libpurple/protocols/irc/msgs.c
        libpurple/protocols/irc/parse.c

ChangeLog: 

compile irc.

-------------- next part --------------
============================================================
--- libpurple/protocols/irc/dcc_send.c	141d56c9ad3855c495ae5724a638326015d70571
+++ libpurple/protocols/irc/dcc_send.c	4122b0c6742f3853bd945a6246350db41d4b8109
@@ -290,7 +290,7 @@ irc_dccsend_network_listen_cb(int sock, 
 
 	xd = xfer->data;
 	gc = purple_account_get_connection(purple_xfer_get_account(xfer));
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	purple_xfer_unref(xfer);
 
@@ -316,7 +316,7 @@ irc_dccsend_network_listen_cb(int sock, 
 	                         xfer->filename, ntohl(addr.s_addr),
 	                         port, xfer->size);
 
-	irc_cmd_privmsg(gc->proto_data, "msg", NULL, arg);
+	irc_cmd_privmsg(purple_object_get_protocol_data(PURPLE_OBJECT(gc)), "msg", NULL, arg);
 	g_free(tmp);
 }
 
============================================================
--- libpurple/protocols/irc/irc.c	68126a987474b36d73e3fc280deae9b391fc20c3
+++ libpurple/protocols/irc/irc.c	7ddad31cbcf27cbfe6f0e3861c7cbe96d8fd2912
@@ -70,11 +70,11 @@ static void irc_view_motd(PurplePluginAc
 	struct irc_conn *irc;
 	char *title;
 
-	if (gc == NULL || gc->proto_data == NULL) {
+	irc = gc ? purple_object_get_protocol_data(PURPLE_OBJECT(gc)) : NULL;
+	if (gc == NULL || irc == NULL) {
 		purple_debug(PURPLE_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n");
 		return;
 	}
-	irc = gc->proto_data;
 	if (irc->motd == NULL) {
 		purple_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"),
 				  _("There is no MOTD associated with this connection."));
@@ -100,7 +100,7 @@ static int irc_send_raw(PurpleConnection
 
 static int irc_send_raw(PurpleConnection *gc, const char *buf, int len)
 {
-	struct irc_conn *irc = (struct irc_conn*)gc->proto_data;
+	struct irc_conn *irc = (struct irc_conn*)purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	return do_send(irc, buf, len);
 }
 
@@ -303,7 +303,8 @@ static void irc_login(PurpleAccount *acc
 	const char *username = purple_account_get_username(account);
 
 	gc = purple_account_get_connection(account);
-	gc->flags |= PURPLE_CONNECTION_FLAGS_NO_NEWLINES;
+	purple_connection_set_flags(gc,
+			purple_connection_get_flags(gc) | PURPLE_CONNECTION_FLAGS_NO_NEWLINES);
 
 	if (strpbrk(username, " \t\v\r\n") != NULL) {
 		purple_connection_error_reason (gc,
@@ -312,7 +313,7 @@ static void irc_login(PurpleAccount *acc
 		return;
 	}
 
-	gc->proto_data = irc = g_new0(struct irc_conn, 1);
+	purple_object_set_protocol_data(PURPLE_OBJECT(gc),irc = g_new0(struct irc_conn, 1));
 	irc->fd = -1;
 	irc->account = account;
 	irc->outbuf = purple_circ_buffer_new(512);
@@ -362,7 +363,7 @@ static gboolean do_login(PurpleConnectio
 	char *buf, *tmp = NULL;
 	char hostname[256];
 	const char *username, *realname;
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	const char *pass = purple_connection_get_password(gc);
 	int ret;
 
@@ -429,7 +430,7 @@ static void irc_login_cb(gpointer data, 
 static void irc_login_cb(gpointer data, gint source, const gchar *error_message)
 {
 	PurpleConnection *gc = data;
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	if (source < 0) {
 		purple_connection_error_reason (gc,
@@ -441,7 +442,7 @@ static void irc_login_cb(gpointer data, 
 	irc->fd = source;
 
 	if (do_login(gc)) {
-		gc->inpa = purple_input_add(irc->fd, PURPLE_INPUT_READ, irc_input_cb, gc);
+		g_object_set(G_OBJECT(gc),"inpa",purple_input_add(irc->fd, PURPLE_INPUT_READ, irc_input_cb, gc),NULL);
 	}
 }
 
@@ -450,7 +451,7 @@ irc_ssl_connect_failure(PurpleSslConnect
 		gpointer data)
 {
 	PurpleConnection *gc = data;
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	irc->gsc = NULL;
 
@@ -459,7 +460,7 @@ static void irc_close(PurpleConnection *
 
 static void irc_close(PurpleConnection *gc)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	if (irc == NULL)
 		return;
@@ -467,8 +468,8 @@ static void irc_close(PurpleConnection *
 	if (irc->gsc || (irc->fd >= 0))
 		irc_cmd_quit(irc, "quit", NULL, NULL);
 
-	if (gc->inpa)
-		purple_input_remove(gc->inpa);
+	if (purple_object_get_int(PURPLE_OBJECT(gc),"inpa"))
+		purple_input_remove(purple_object_get_int(PURPLE_OBJECT(gc),"inpa"));
 
 	g_free(irc->inbuf);
 	if (irc->gsc) {
@@ -497,7 +498,7 @@ static int irc_im_send(PurpleConnection 
 
 static int irc_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	char *plain;
 	const char *args[2];
 
@@ -516,7 +517,7 @@ static void irc_get_info(PurpleConnectio
 
 static void irc_get_info(PurpleConnection *gc, const char *who)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	const char *args[2];
 	args[0] = who;
 	args[1] = NULL;
@@ -531,7 +532,7 @@ static void irc_set_status(PurpleAccount
 	const char *status_id = purple_status_get_id(status);
 
 	g_return_if_fail(gc != NULL);
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	if (!purple_status_is_active(status))
 		return;
@@ -550,7 +551,7 @@ static void irc_add_buddy(PurpleConnecti
 
 static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
-	struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
+	struct irc_conn *irc = (struct irc_conn *)purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
 	ib->name = g_strdup(buddy->name);
 	g_hash_table_insert(irc->buddies, ib->name, ib);
@@ -564,7 +565,7 @@ static void irc_remove_buddy(PurpleConne
 
 static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
-	struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
+	struct irc_conn *irc = (struct irc_conn *)purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	g_hash_table_remove(irc->buddies, buddy->name);
 }
 
@@ -572,7 +573,10 @@ static void read_input(struct irc_conn *
 {
 	char *cur, *end;
 
+#warning FIXME: uncomment!!
+#if 0
 	purple_account_get_connection(irc->account)->last_received = time(NULL);
+#endif
 	irc->inbufused += len;
 	irc->inbuf[irc->inbufused] = '\0';
 
@@ -604,7 +608,7 @@ static void irc_input_cb_ssl(gpointer da
 {
 
 	PurpleConnection *gc = data;
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	int len;
 
 	if(!g_list_find(purple_connections_get_all(), gc)) {
@@ -640,7 +644,7 @@ static void irc_input_cb(gpointer data, 
 static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond)
 {
 	PurpleConnection *gc = data;
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	int len;
 
 	if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
@@ -668,7 +672,7 @@ static void irc_chat_join (PurpleConnect
 
 static void irc_chat_join (PurpleConnection *gc, GHashTable *data)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	const char *args[2];
 
 	args[0] = g_hash_table_lookup(data, "channel");
@@ -682,7 +686,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 = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleConversation *convo = purple_find_chat(gc, id);
 	const char *args[2];
 
@@ -698,7 +702,7 @@ static void irc_chat_leave (PurpleConnec
 
 static void irc_chat_leave (PurpleConnection *gc, int id)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleConversation *convo = purple_find_chat(gc, id);
 	const char *args[2];
 
@@ -713,7 +717,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 = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	PurpleConversation *convo = purple_find_chat(gc, id);
 	const char *args[2];
 	char *tmp;
@@ -767,7 +771,7 @@ static void irc_chat_set_topic(PurpleCon
 	const char *name = NULL;
 	struct irc_conn *irc;
 
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	name = purple_conversation_get_name(purple_find_chat(gc, id));
 
 	if (name == NULL)
@@ -785,7 +789,7 @@ static PurpleRoomlist *irc_roomlist_get_
 	PurpleRoomlistField *f;
 	char *buf;
 
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	if (irc->roomlist)
 		purple_roomlist_unref(irc->roomlist);
@@ -818,7 +822,7 @@ static void irc_roomlist_cancel(PurpleRo
 	if (gc == NULL)
 		return;
 
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	purple_roomlist_set_in_progress(list, FALSE);
 
@@ -830,7 +834,7 @@ static void irc_keepalive(PurpleConnecti
 
 static void irc_keepalive(PurpleConnection *gc)
 {
-	struct irc_conn *irc = gc->proto_data;
+	struct irc_conn *irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 	if ((time(NULL) - irc->recv_time) > PING_TIMEOUT)
 		irc_cmd_ping(irc, NULL, NULL, NULL);
 }
============================================================
--- libpurple/protocols/irc/msgs.c	0cd1476dd24901cd40a3bf3762a7a4a731df3ad0
+++ libpurple/protocols/irc/msgs.c	c19702709382802a6cd64dee682d6423a7710156
@@ -87,7 +87,7 @@ static void irc_connected(struct irc_con
 	/* If we're away then set our away message */
 	status = purple_account_get_active_status(irc->account);
 	if (!purple_status_get_type(status) != PURPLE_STATUS_AVAILABLE) {
-		PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+		PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
 		prpl_info->set_status(irc->account, status);
 	}
 
@@ -890,12 +890,14 @@ void irc_msg_nick(struct irc_conn *irc, 
 		g_free(nick);
 		return;
 	}
-	chats = gc->buddy_chats;
 
 	if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
 		purple_connection_set_display_name(gc, args[0]);
 	}
 
+#warning TODO: Find out what buddy_chats do, and reimplement this stuff
+#if 0
+	chats = gc->buddy_chats;
 	while (chats) {
 		PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data);
 		/* This is ugly ... */
@@ -903,6 +905,7 @@ void irc_msg_nick(struct irc_conn *irc, 
 			purple_conv_chat_rename_user(chat, nick, args[0]);
 		chats = chats->next;
 	}
+#endif
 
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick,
 						   irc->account);
@@ -1135,7 +1138,10 @@ void irc_msg_quit(struct irc_conn *irc, 
 	data[0] = irc_mask_nick(from);
 	data[1] = args[0];
 	/* XXX this should have an API, I shouldn't grab this directly */
+#warning Yeah. Do something here
+#if 0
 	g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data);
+#endif
 
 	if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) {
 		ib->flag = FALSE;
============================================================
--- libpurple/protocols/irc/parse.c	b8c32fdcabe7da81bd6d0de8f2f697cf7caa8bfa
+++ libpurple/protocols/irc/parse.c	8539b617a7682372f016d176def8f3be2e141465
@@ -168,7 +168,7 @@ static PurpleCmdRet irc_parse_purple_cmd
 	if (!gc)
 		return PURPLE_CMD_RET_FAILED;
 
-	irc = gc->proto_data;
+	irc = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
 
 	if ((cmdent = g_hash_table_lookup(irc->cmds, cmd)) == NULL)
 		return PURPLE_CMD_RET_FAILED;


More information about the Commits mailing list