/soc/2013/ankitkv/gobjectification: 53b5e1b31031: Refactored nov...

Ankit Vani a at nevitus.org
Sun Jun 23 16:09:02 EDT 2013


Changeset: 53b5e1b31031b79eec0a75468541f8946e5db3b2
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-24 01:38 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/53b5e1b31031

Description:

Refactored novell and oscar protocols to use GObject conversation API

diffstat:

 libpurple/protocols/novell/novell.c |  59 +++++++++++++++++-----------------
 libpurple/protocols/oscar/odc.c     |  19 +++++-----
 libpurple/protocols/oscar/oscar.c   |  63 ++++++++++++++++++------------------
 libpurple/protocols/oscar/oscar.h   |   2 +-
 libpurple/protocols/oscar/peer.c    |  28 ++++++++--------
 5 files changed, 86 insertions(+), 85 deletions(-)

diffs (truncated from 570 to 300 lines):

diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -216,9 +216,8 @@ static void
 		if (user_record) {
 
 			/* Set the title for the conversation */
-			/* XXX - Should this be PURPLE_CONV_TYPE_IM? */
-			gconv =	purple_conversations_find_with_account(PURPLE_CONV_TYPE_ANY,
-														nm_user_record_get_display_id(user_record),
+			/* XXX - Should this be find_im_with_account? */
+			gconv =	purple_conversations_find_with_account(nm_user_record_get_display_id(user_record),
 														(PurpleAccount *) user->client_data);
 			if (gconv) {
 
@@ -653,7 +652,7 @@ static void
 _join_conf_resp_cb(NMUser * user, NMERR_T ret_code,
 				   gpointer resp_data, gpointer user_data)
 {
-	PurpleConversation *chat;
+	PurpleChatConversation *chat;
 	PurpleConnection *gc;
 	NMUserRecord *ur;
 	NMConference *conference = user_data;
@@ -677,7 +676,7 @@ static void
 				ur = nm_conference_get_participant(conference, i);
 				if (ur) {
 					name = nm_user_record_get_display_id(ur);
-					purple_chat_conversation_add_user(PURPLE_CONV_CHAT(chat), name, NULL,
+					purple_chat_conversation_add_user(chat, name, NULL,
 											PURPLE_CHAT_CONVERSATION_BUDDY_NONE, TRUE);
 				}
 			}
@@ -984,7 +983,7 @@ static void
 		for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
 			conference = cnode->data;
 			if (conference && (chat = nm_conference_get_data(conference))) {
-				if (purple_chat_conversation_get_id(PURPLE_CONV_CHAT(chat)) == id) {
+				if (purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(chat)) == id) {
 					rc = nm_send_conference_invite(user, conference, user_record,
 												   NULL, _sendinvite_resp_cb, NULL);
 					_check_for_disconnect(user, rc);
@@ -1623,7 +1622,7 @@ static void
 
 	NMUser *user;
 	const char *conf_name;
-	PurpleConversation *chat = NULL;
+	PurpleChatConversation *chat = NULL;
 	NMUserRecord *user_record;
 	NMConference *conference;
 
@@ -1775,7 +1774,7 @@ static void
 {
 	NMUserRecord *user_record = NULL;
 	NMContact *contact = NULL;
-	PurpleConversation *gconv;
+	PurpleIMConversation *im;
 	NMConference *conference;
 	PurpleMessageFlags flags;
 	char *text = NULL;
@@ -1785,7 +1784,7 @@ static void
 	conference = nm_event_get_conference(event);
 	if (conference) {
 
-		PurpleConversation *chat = nm_conference_get_data(conference);
+		PurpleChatConversation *chat = nm_conference_get_data(conference);
 
 		/* Is this a single person 'conversation' or a conference? */
 		if (chat == NULL && nm_conference_get_participant_count(conference) == 1) {
@@ -1802,16 +1801,16 @@ static void
 							text, flags,
 							nm_event_get_gmt(event));
 
-				gconv =	purple_conversations_find_with_account(PURPLE_CONV_TYPE_IM,
+				im = purple_conversations_find_im_with_account(
 					nm_user_record_get_display_id(user_record),
 					(PurpleAccount *) user->client_data);
-				if (gconv) {
+				if (im) {
 
 					contact = nm_find_contact(user, nm_event_get_source(event));
 					if (contact) {
 
-						purple_conversation_set_title(
-							gconv, nm_contact_get_display_name(contact));
+						purple_conversation_set_title(PURPLE_CONVERSATION(im),
+							nm_contact_get_display_name(contact));
 
 
 					} else {
@@ -1822,7 +1821,7 @@ static void
 						if (name == NULL)
 							name = nm_user_record_get_userid(user_record);
 
-						purple_conversation_set_title(gconv, name);
+						purple_conversation_set_title(PURPLE_CONVERSATION(im), name);
 					}
 
 				}
@@ -1853,7 +1852,7 @@ static void
 				}
 
 				serv_got_chat_in(purple_account_get_connection(user->client_data),
-								 purple_chat_conversation_get_id(PURPLE_CONV_CHAT(chat)),
+								 purple_chat_conversation_get_id(chat),
 								 name, 0, text, nm_event_get_gmt(event));
 			}
 		}
@@ -1865,7 +1864,7 @@ static void
 static void
 _evt_conference_left(NMUser * user, NMEvent * event)
 {
-	PurpleConversation *chat;
+	PurpleChatConversation *chat;
 	NMConference *conference;
 
 	conference = nm_event_get_conference(event);
@@ -1876,7 +1875,7 @@ static void
 												   nm_event_get_source(event));
 
 			if (ur)
-				purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(chat),
+				purple_chat_conversation_remove_user(chat,
 										   nm_user_record_get_display_id(ur),
 										   NULL);
 		}
@@ -1953,7 +1952,7 @@ static void
 static void
 _evt_conference_joined(NMUser * user, NMEvent * event)
 {
-	PurpleConversation *chat = NULL;
+	PurpleChatConversation *chat = NULL;
 	PurpleConnection *gc;
 	NMConference *conference = NULL;
 	NMUserRecord *ur = NULL;
@@ -1978,7 +1977,7 @@ static void
 					nm_conference_set_data(conference, (gpointer) chat);
 
 					name = nm_user_record_get_display_id(ur);
-					purple_chat_conversation_add_user(PURPLE_CONV_CHAT(chat), name, NULL,
+					purple_chat_conversation_add_user(chat, name, NULL,
 											PURPLE_CHAT_CONVERSATION_BUDDY_NONE, TRUE);
 
 				}
@@ -1989,8 +1988,8 @@ static void
 			ur = nm_find_user_record(user, nm_event_get_source(event));
 			if (ur) {
 				name = nm_user_record_get_display_id(ur);
-				if (!purple_chat_conversation_find_user(PURPLE_CONV_CHAT(chat), name)) {
-					purple_chat_conversation_add_user(PURPLE_CONV_CHAT(chat), name, NULL,
+				if (!purple_chat_conversation_find_user(chat, name)) {
+					purple_chat_conversation_add_user(chat, name, NULL,
 											PURPLE_CHAT_CONVERSATION_BUDDY_NONE, TRUE);
 				}
 			}
@@ -2089,8 +2088,7 @@ static void
 	if (ur) {
 		/* XXX - Should this be PURPLE_CONV_TYPE_IM? */
 		gconv =
-			purple_conversations_find_with_account(PURPLE_CONV_TYPE_ANY,
-												nm_user_record_get_display_id(ur),
+			purple_conversations_find_with_account(nm_user_record_get_display_id(ur),
 												user->client_data);
 		if (gconv) {
 			const char *name = nm_user_record_get_full_name(ur);
@@ -2404,7 +2402,7 @@ novell_chat_leave(PurpleConnection * gc,
 {
 	NMConference *conference;
 	NMUser *user;
-	PurpleConversation *chat;
+	PurpleChatConversation *chat;
 	GSList *cnode;
 	NMERR_T rc = NM_OK;
 
@@ -2418,7 +2416,7 @@ novell_chat_leave(PurpleConnection * gc,
 	for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
 		conference = cnode->data;
 		if (conference && (chat = nm_conference_get_data(conference))) {
-			if (purple_chat_conversation_get_id(PURPLE_CONV_CHAT(chat)) == id) {
+			if (purple_chat_conversation_get_id(chat) == id) {
 				rc = nm_send_leave_conference(user, conference, NULL, NULL);
 				_check_for_disconnect(user, rc);
 				break;
@@ -2435,7 +2433,7 @@ novell_chat_invite(PurpleConnection *gc,
 {
 	NMConference *conference;
 	NMUser *user;
-	PurpleConversation *chat;
+	PurpleChatConversation *chat;
 	GSList *cnode;
 	NMERR_T rc = NM_OK;
 	NMUserRecord *user_record = NULL;
@@ -2457,7 +2455,7 @@ novell_chat_invite(PurpleConnection *gc,
 	for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
 		conference = cnode->data;
 		if (conference && (chat = nm_conference_get_data(conference))) {
-			if (purple_chat_conversation_get_id(PURPLE_CONV_CHAT(chat)) == id) {
+			if (purple_chat_conversation_get_id(chat) == id) {
 				rc = nm_send_conference_invite(user, conference, user_record,
 											   message, _sendinvite_resp_cb, NULL);
 				_check_for_disconnect(user, rc);
@@ -2471,7 +2469,7 @@ static int
 novell_chat_send(PurpleConnection * gc, int id, const char *text, PurpleMessageFlags flags)
 {
 	NMConference *conference;
-	PurpleConversation *chat;
+	PurpleChatConversation *chat;
 	GSList *cnode;
 	NMMessage *message;
 	NMUser *user;
@@ -2493,7 +2491,7 @@ novell_chat_send(PurpleConnection * gc, 
 	for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
 		conference = cnode->data;
 		if (conference && (chat = nm_conference_get_data(conference))) {
-			if (purple_chat_conversation_get_id(PURPLE_CONV_CHAT(chat)) == id) {
+			if (purple_chat_conversation_get_id(chat) == id) {
 
 				nm_message_set_conference(message, conference);
 
@@ -2537,7 +2535,8 @@ novell_chat_send(PurpleConnection * gc, 
 	if (chat) {
 		str = g_strdup(_("This conference has been closed."
 						 " No more messages can be sent."));
-		purple_conversation_write(chat, NULL, str, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write(PURPLE_CONVERSATION(chat), NULL, str,
+				PURPLE_MESSAGE_SYSTEM, time(NULL));
 		g_free(str);
 	}
 
diff --git a/libpurple/protocols/oscar/odc.c b/libpurple/protocols/oscar/odc.c
--- a/libpurple/protocols/oscar/odc.c
+++ b/libpurple/protocols/oscar/odc.c
@@ -60,11 +60,12 @@ peer_odc_close(PeerConnection *conn)
 	if (tmp != NULL)
 	{
 		PurpleAccount *account;
-		PurpleConversation *conv;
+		PurpleIMConversation *im;
 
 		account = purple_connection_get_account(conn->od->gc);
-		conv = purple_im_conversation_new(account, conn->bn);
-		purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		im = purple_im_conversation_new(account, conn->bn);
+		purple_conversation_write(PURPLE_CONVERSATION(im), NULL, tmp,
+				PURPLE_MESSAGE_SYSTEM, time(NULL));
 		g_free(tmp);
 	}
 
@@ -524,7 +525,7 @@ peer_odc_recv_frame(PeerConnection *conn
 		 */
 
 		PurpleAccount *account;
-		PurpleConversation *conv;
+		PurpleIMConversation *im;
 
 		if (conn->flags & PEER_CONNECTION_FLAG_IS_INCOMING)
 		{
@@ -565,8 +566,8 @@ peer_odc_recv_frame(PeerConnection *conn
 
 		/* Tell the local user that we are connected */
 		account = purple_connection_get_account(gc);
-		conv = purple_im_conversation_new(account, conn->bn);
-		purple_conversation_write(conv, NULL, _("Direct IM established"),
+		im = purple_im_conversation_new(account, conn->bn);
+		purple_conversation_write(PURPLE_CONVERSATION(im), NULL, _("Direct IM established"),
 				PURPLE_MESSAGE_SYSTEM, time(NULL));
 	}
 
@@ -601,7 +602,7 @@ peer_odc_recv_frame(PeerConnection *conn
 		{
 			gchar *tmp, *size1, *size2;
 			PurpleAccount *account;
-			PurpleConversation *conv;
+			PurpleIMConversation *im;
 
 			size1 = purple_str_size_to_units(frame->payload.len);
 			size2 = purple_str_size_to_units(DIRECTIM_MAX_FILESIZE);
@@ -610,8 +611,8 @@ peer_odc_recv_frame(PeerConnection *conn
 			g_free(size2);
 
 			account = purple_connection_get_account(conn->od->gc);
-			conv = purple_im_conversation_new(account, conn->bn);
-			purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
+			im = purple_im_conversation_new(account, conn->bn);
+			purple_conversation_write(PURPLE_CONVERSATION(im), NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
 			g_free(tmp);
 
 			peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -98,8 +98,8 @@ static int purple_parse_misses     (Osca
 static int purple_parse_clientauto (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_motd       (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_chatnav_info     (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int purple_chat_conversation_join        (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int purple_chat_conversation_leave       (OscarData *, FlapConnection *, FlapFrame *, ...);
+static int purple_chat_conversation_join (OscarData *, FlapConnection *, FlapFrame *, ...);
+static int purple_chat_conversation_left (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_chat_conversation_info_update (OscarData *, FlapConnection *, FlapFrame *, ...);



More information about the Commits mailing list