/soc/2013/ankitkv/gobjectification: ebe6b2a60305: Changed all ar...

Ankit Vani a at nevitus.org
Sun Jun 23 10:48:37 EDT 2013


Changeset: ebe6b2a60305214e14ab9208799bbd4cf9056b1e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-23 20:18 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/ebe6b2a60305

Description:

Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
This provides for better compile-time checking.
* Changed the return type for serv_got_joined_chat to PurpleChatConversation *
* Wherever possible, used the subclass objects instead of PurpleConversation in protocols bonjour, gg and irc

diffstat:

 libpurple/conversations.h                     |    6 +-
 libpurple/conversationtypes.h                 |    4 +-
 libpurple/plugins/offlinemsg.c                |    2 +-
 libpurple/plugins/perl/common/Conversation.xs |   10 +-
 libpurple/plugins/perl/common/Server.xs       |    2 +-
 libpurple/plugins/psychic.c                   |   14 +-
 libpurple/plugins/statenotify.c               |    9 +-
 libpurple/plugins/tcl/tcl_cmds.c              |    4 +-
 libpurple/protocols/bonjour/jabber.c          |   14 +-
 libpurple/protocols/gg/confer.c               |   11 +-
 libpurple/protocols/gg/confer.h               |    2 +-
 libpurple/protocols/gg/gg.c                   |   32 ++--
 libpurple/protocols/gg/image.c                |    4 +-
 libpurple/protocols/gg/pubdir-prpl.c          |    4 +-
 libpurple/protocols/irc/cmds.c                |   26 ++--
 libpurple/protocols/irc/irc.c                 |    9 +-
 libpurple/protocols/irc/msgs.c                |  168 ++++++++++++-------------
 libpurple/server.c                            |   17 +-
 libpurple/server.h                            |    2 +-
 19 files changed, 167 insertions(+), 173 deletions(-)

diffs (truncated from 1151 to 300 lines):

diff --git a/libpurple/conversations.h b/libpurple/conversations.h
--- a/libpurple/conversations.h
+++ b/libpurple/conversations.h
@@ -80,7 +80,7 @@ PurpleConversation *purple_conversations
  *
  * @return The conversation if found, or @c NULL otherwise.
  */
-PurpleConversation *purple_conversations_find_im_with_account(const char *name,
+PurpleIMConversation *purple_conversations_find_im_with_account(const char *name,
 		const PurpleAccount *account);
 
 /** TODO chats
@@ -91,7 +91,7 @@ PurpleConversation *purple_conversations
  *
  * @return The conversation if found, or @c NULL otherwise.
  */
-PurpleConversation *purple_conversations_find_chat_with_account(const char *name,
+PurpleChatConversation *purple_conversations_find_chat_with_account(const char *name,
 		const PurpleAccount *account);
 
 /**
@@ -102,7 +102,7 @@ PurpleConversation *purple_conversations
  *
  * @return The chat conversation.
  */
-PurpleConversation *purple_conversations_find_chat(const PurpleConnection *gc, int id);
+PurpleChatConversation *purple_conversations_find_chat(const PurpleConnection *gc, int id);
 
 /**
  * Sets the default conversation UI operations structure.
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -211,7 +211,7 @@ GType purple_im_conversation_get_type(vo
  *
  * @return The new conversation.
  */
-PurpleConversation *purple_im_conversation_new(PurpleAccount *account,
+PurpleIMConversation *purple_im_conversation_new(PurpleAccount *account,
 		const char *name);
 
 /**
@@ -383,7 +383,7 @@ GType purple_chat_conversation_get_type(
  *
  * @return The new conversation.
  */
-PurpleConversation *purple_chat_conversation_new(PurpleAccount *account,
+PurpleChatConversation *purple_chat_conversation_new(PurpleAccount *account,
 		const char *name);
 
 /**
diff --git a/libpurple/plugins/offlinemsg.c b/libpurple/plugins/offlinemsg.c
--- a/libpurple/plugins/offlinemsg.c
+++ b/libpurple/plugins/offlinemsg.c
@@ -137,7 +137,7 @@ sending_msg_cb(PurpleAccount *account, c
 		return;
 	}
 
-	conv = purple_conversations_find_im_with_account(who, account);
+	conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(who, account));
 
 	if (!conv)
 		return;
diff --git a/libpurple/plugins/perl/common/Conversation.xs b/libpurple/plugins/perl/common/Conversation.xs
--- a/libpurple/plugins/perl/common/Conversation.xs
+++ b/libpurple/plugins/perl/common/Conversation.xs
@@ -85,7 +85,7 @@ PROTOTYPES: ENABLE
 Purple::Handle
 purple_conversations_get_handle()
 
-Purple::Conversation
+Purple::ChatConversation
 purple_conversations_find_chat(gc, id)
 	Purple::Connection gc
 	int id
@@ -122,12 +122,12 @@ purple_conversations_find_with_account(n
 	const char *name
 	Purple::Account account
 
-Purple::Conversation
+Purple::ChatConversation
 purple_conversations_find_chat_with_account(name, account)
 	const char *name
 	Purple::Account account
 
-Purple::Conversation
+Purple::IMConversation
 purple_conversations_find_im_with_account(name, account)
 	const char *name
 	Purple::Account account
@@ -234,7 +234,7 @@ purple_conversation_do_command(conv, cmd
 MODULE = Purple::Conversation  PACKAGE = Purple::IMConversation  PREFIX = purple_im_conversation_
 PROTOTYPES: ENABLE
 
-Purple::Conversation
+Purple::IMConversation
 purple_im_conversation_new(class, account, name)
 	Purple::Account account
 	const char *name
@@ -317,7 +317,7 @@ purple_conversation_custom_smiley_close(
 MODULE = Purple::Conversation  PACKAGE = Purple::ChatConversation  PREFIX = purple_chat_conversation_
 PROTOTYPES: ENABLE
 
-Purple::Conversation
+Purple::ChatConversation
 purple_chat_conversation_new(class, account, name)
 	Purple::Account account
 	const char *name
diff --git a/libpurple/plugins/perl/common/Server.xs b/libpurple/plugins/perl/common/Server.xs
--- a/libpurple/plugins/perl/common/Server.xs
+++ b/libpurple/plugins/perl/common/Server.xs
@@ -104,7 +104,7 @@ serv_got_im(gc, who, msg, imflags, mtime
 	Purple::MessageFlags imflags
 	time_t mtime
 
-Purple::Conversation
+Purple::ChatConversation
 serv_got_joined_chat(gc, id, name)
 	Purple::Connection gc
 	int id
diff --git a/libpurple/plugins/psychic.c b/libpurple/plugins/psychic.c
--- a/libpurple/plugins/psychic.c
+++ b/libpurple/plugins/psychic.c
@@ -33,7 +33,7 @@
 
 static void
 buddy_typing_cb(PurpleAccount *acct, const char *name, void *data) {
-  PurpleConversation *gconv;
+  PurpleIMConversation *im;
 
   if(purple_prefs_get_bool(PREF_STATUS) &&
      ! purple_status_is_available(purple_account_get_active_status(acct))) {
@@ -52,13 +52,13 @@ buddy_typing_cb(PurpleAccount *acct, con
     return;
   }
 
-  gconv = purple_conversations_find_im_with_account(name, acct);
-  if(! gconv) {
+  im = purple_conversations_find_im_with_account(name, acct);
+  if(! im) {
     purple_debug_info("psychic", "no previous conversation exists\n");
-    gconv = purple_im_conversation_new(acct, name);
+    im = purple_im_conversation_new(acct, name);
 
     if(purple_prefs_get_bool(PREF_RAISE)) {
-      purple_conversation_present(gconv);
+      purple_conversation_present(PURPLE_CONVERSATION(im));
     }
 
     if(purple_prefs_get_bool(PREF_NOTICE)) {
@@ -67,14 +67,14 @@ buddy_typing_cb(PurpleAccount *acct, con
 	 translate it literally.  If you can't find a fitting cultural
 	 reference in your language, consider translating something
 	 like this instead: "You feel a new message coming." */
-      purple_conversation_write(gconv, NULL,
+      purple_conversation_write(PURPLE_CONVERSATION(im), NULL,
 			      _("You feel a disturbance in the force..."),
 			      PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_ACTIVE_ONLY,
 			      time(NULL));
     }
 
     /* Necessary because we may be creating a new conversation window. */
-    purple_im_conversation_set_typing_state(PURPLE_IM_CONVERSATION(gconv), PURPLE_IM_CONVERSATION_TYPING);
+    purple_im_conversation_set_typing_state(im, PURPLE_IM_CONVERSATION_TYPING);
   }
 }
 
diff --git a/libpurple/plugins/statenotify.c b/libpurple/plugins/statenotify.c
--- a/libpurple/plugins/statenotify.c
+++ b/libpurple/plugins/statenotify.c
@@ -16,7 +16,7 @@ static void
 write_status(PurpleBuddy *buddy, const char *message)
 {
 	PurpleAccount *account = NULL;
-	PurpleConversation *conv;
+	PurpleIMConversation *im;
 	const char *who;
 	char buf[256];
 	char *escaped;
@@ -25,11 +25,10 @@ write_status(PurpleBuddy *buddy, const c
 	account = purple_buddy_get_account(buddy);
 	buddy_name = purple_buddy_get_name(buddy);
 
-	conv = purple_conversations_find_im_with_account(buddy_name, account);
+	im = purple_conversations_find_im_with_account(buddy_name, account);
 
-	if (conv == NULL)
+	if (im == NULL)
 		return;
-	g_return_if_fail(PURPLE_IS_IM_CONVERSATION(conv));
 
 	/* Prevent duplicate notifications for buddies in multiple groups */
 	if (buddy != purple_find_buddy(account, buddy_name))
@@ -41,7 +40,7 @@ write_status(PurpleBuddy *buddy, const c
 	g_snprintf(buf, sizeof(buf), message, escaped);
 	g_free(escaped);
 
-	purple_conversation_write_message(conv, NULL, buf,
+	purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, buf,
 			PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY | PURPLE_MESSAGE_NO_LINKIFY,
 			time(NULL));
 }
diff --git a/libpurple/plugins/tcl/tcl_cmds.c b/libpurple/plugins/tcl/tcl_cmds.c
--- a/libpurple/plugins/tcl/tcl_cmds.c
+++ b/libpurple/plugins/tcl/tcl_cmds.c
@@ -851,9 +851,9 @@ int tcl_cmd_conversation(ClientData unus
 		if ((account = tcl_validate_account(objv[argsused++], interp)) == NULL)
 			return TCL_ERROR;
 		if (is_chat)
-			convo = purple_chat_conversation_new(account, Tcl_GetString(objv[argsused]));
+			convo = PURPLE_CONVERSATION(purple_chat_conversation_new(account, Tcl_GetString(objv[argsused])));
 		else
-			convo = purple_im_conversation_new(account, Tcl_GetString(objv[argsused]));
+			convo = PURPLE_CONVERSATION(purple_im_conversation_new(account, Tcl_GetString(objv[argsused])));
 		Tcl_SetObjResult(interp, purple_tcl_ref_new(PurpleTclRefConversation, convo));
 		break;
 	case CMD_CONV_WRITE:
diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -302,7 +302,7 @@ static void
 
 		account = purple_buddy_get_account(pb);
 
-		conv = purple_conversations_find_im_with_account(bb->name, account);
+		conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
 				  _("Unable to send message."),
@@ -348,7 +348,7 @@ static gint
 
 		account = purple_buddy_get_account(pb);
 
-		conv = purple_conversations_find_im_with_account(bb->name, account);
+		conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
 				  _("Unable to send message."),
@@ -485,7 +485,7 @@ static void
 		purple_debug_error("bonjour", "Error starting stream with buddy %s at %s error: %s\n",
 				   bname ? bname : "(unknown)", bconv->ip, err ? err : "(null)");
 
-		conv = purple_conversations_find_im_with_account(bname, bconv->account);
+		conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
 				  _("Unable to send the message, the conversation couldn't be started."),
@@ -550,7 +550,7 @@ static gboolean bonjour_jabber_send_stre
 
 		if (bconv->pb) {
 			PurpleConversation *conv;
-			conv = purple_conversations_find_im_with_account(bname, bconv->account);
+			conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
 			if (conv != NULL)
 				purple_conversation_write(conv, NULL,
 					  _("Unable to send the message, the conversation couldn't be started."),
@@ -595,7 +595,7 @@ void bonjour_jabber_stream_started(Bonjo
 
 		if (bconv->pb) {
 			PurpleConversation *conv;
-			conv = purple_conversations_find_im_with_account(bname, bconv->account);
+			conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
 			if (conv != NULL)
 				purple_conversation_write(conv, NULL,
 					  _("Unable to send the message, the conversation couldn't be started."),
@@ -872,7 +872,7 @@ static void
 
 		purple_debug_error("bonjour", "No more addresses for buddy %s. Aborting", purple_buddy_get_name(pb));
 
-		conv = purple_conversations_find_im_with_account(bb->name, account);
+		conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
 				  _("Unable to send the message, the conversation couldn't be started."),
@@ -893,7 +893,7 @@ static void
 
 		account = purple_buddy_get_account(pb);
 
-		conv = purple_conversations_find_im_with_account(bb->name, account);
+		conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
 				  _("Unable to send the message, the conversation couldn't be started."),
diff --git a/libpurple/protocols/gg/confer.c b/libpurple/protocols/gg/confer.c
--- a/libpurple/protocols/gg/confer.c
+++ b/libpurple/protocols/gg/confer.c
@@ -27,7 +27,7 @@
 #include "confer.h"
 
 /* PurpleConversation *ggp_confer_find_by_name(PurpleConnection *gc, const gchar *name) {{{ */
-PurpleConversation *ggp_confer_find_by_name(PurpleConnection *gc, const gchar *name)
+PurpleChatConversation *ggp_confer_find_by_name(PurpleConnection *gc, const gchar *name)
 {
 	g_return_val_if_fail(gc   != NULL, NULL);
 	g_return_val_if_fail(name != NULL, NULL);
@@ -41,7 +41,7 @@ PurpleConversation *ggp_confer_find_by_n
 void ggp_confer_participants_add_uin(PurpleConnection *gc, const gchar *chat_name,
 							 const uin_t uin)
 {
-	PurpleConversation *conv;



More information about the Commits mailing list