/soc/2013/ankitkv/gobjectification: 3feba564faed: Refactored lib...

Ankit Vani a at nevitus.org
Sat Jun 22 07:50:23 EDT 2013


Changeset: 3feba564faed4f6f86303698fe44ab6448e4c898
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-22 17:20 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3feba564faed

Description:

Refactored libpurple/plugins/perl to use GObject-based PurpleConversation API

diffstat:

 libpurple/conversation.h                      |   19 +-
 libpurple/conversationtypes.h                 |   15 +
 libpurple/plugins/perl/common/Conversation.xs |  319 +++++++++++--------------
 libpurple/plugins/perl/common/Server.xs       |   12 +-
 libpurple/plugins/perl/common/typemap         |    1 +
 5 files changed, 167 insertions(+), 199 deletions(-)

diffs (truncated from 660 to 300 lines):

diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -100,21 +100,6 @@ typedef enum /*< flags >*/
 	PURPLE_CONVERSATION_MESSAGE_INVISIBLE   = 0x8000  /**< Message should not be displayed */
 } PurpleConversationMessageFlags;
 
-/**
- * Flags applicable to users in Chats.
- */
-typedef enum /*< flags >*/
-{
-	PURPLE_CHAT_CONVERSATION_BUDDY_NONE     = 0x0000, /**< No flags                     */
-	PURPLE_CHAT_CONVERSATION_BUDDY_VOICE    = 0x0001, /**< Voiced user or "Participant" */
-	PURPLE_CHAT_CONVERSATION_BUDDY_HALFOP   = 0x0002, /**< Half-op                      */
-	PURPLE_CHAT_CONVERSATION_BUDDY_OP       = 0x0004, /**< Channel Op or Moderator      */
-	PURPLE_CHAT_CONVERSATION_BUDDY_FOUNDER  = 0x0008, /**< Channel Founder              */
-	PURPLE_CHAT_CONVERSATION_BUDDY_TYPING   = 0x0010, /**< Currently typing             */
-	PURPLE_CHAT_CONVERSATION_BUDDY_AWAY     = 0x0020  /**< Currently away.              */
-
-} PurpleChatConversationBuddyFlags;
-
 #include "account.h"
 #include "buddyicon.h"
 #include "log.h"
@@ -268,8 +253,8 @@ G_BEGIN_DECLS
  *
  * @return The new conversation.
  */
-PurpleConversation *purple_conversation_new(PurpleAccount *account,
-										const char *name);
+PurpleConversation *purple_conversation_new(GType type, PurpleAccount *account,
+		const char *name);
 
 /** TODO dispose/fnalize
  * Destroys the specified conversation and removes it from the parent
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -56,6 +56,21 @@ typedef enum
 
 } PurpleIMConversationTypingState;
 
+/**
+ * Flags applicable to users in Chats.
+ */
+typedef enum /*< flags >*/
+{
+	PURPLE_CHAT_CONVERSATION_BUDDY_NONE     = 0x0000, /**< No flags                     */
+	PURPLE_CHAT_CONVERSATION_BUDDY_VOICE    = 0x0001, /**< Voiced user or "Participant" */
+	PURPLE_CHAT_CONVERSATION_BUDDY_HALFOP   = 0x0002, /**< Half-op                      */
+	PURPLE_CHAT_CONVERSATION_BUDDY_OP       = 0x0004, /**< Channel Op or Moderator      */
+	PURPLE_CHAT_CONVERSATION_BUDDY_FOUNDER  = 0x0008, /**< Channel Founder              */
+	PURPLE_CHAT_CONVERSATION_BUDDY_TYPING   = 0x0010, /**< Currently typing             */
+	PURPLE_CHAT_CONVERSATION_BUDDY_AWAY     = 0x0020  /**< Currently away.              */
+
+} PurpleChatConversationBuddyFlags;
+
 #include "conversation.h"
 
 /**************************************************************************/
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
@@ -5,23 +5,14 @@ PROTOTYPES: ENABLE
 
 BOOT:
 {
-	HV *type_stash = gv_stashpv("Purple::Conversation::Type", 1);
-	HV *update_stash = gv_stashpv("Purple::Conversation::Update::Type", 1);
-	HV *typing_stash = gv_stashpv("Purple::Conversation::TypingState", 1);
-	HV *flags_stash = gv_stashpv("Purple::Conversation::Flags", 1);
-	HV *cbflags_stash = gv_stashpv("Purple::Conversation::ChatBuddy::Flags", 1);
+	HV *update_stash = gv_stashpv("Purple::Conversation::UpdateType", 1);
+	HV *typing_stash = gv_stashpv("Purple::IMConversation::TypingState", 1);
+	HV *flags_stash = gv_stashpv("Purple::Conversation::MessageFlags", 1);
+	HV *cbflags_stash = gv_stashpv("Purple::ChatConversation::Buddy::Flags", 1);
 
-	static const constiv *civ, type_const_iv[] = {
-#define const_iv(name) {#name, (IV)PURPLE_CONV_TYPE_##name}
-		const_iv(UNKNOWN),
-		const_iv(IM),
-		const_iv(CHAT),
-		const_iv(MISC),
-		const_iv(ANY),
-	};
-	static const constiv update_const_iv[] = {
+	static const constiv *civ, update_const_iv[] = {
 #undef const_iv
-#define const_iv(name) {#name, (IV)PURPLE_CONV_UPDATE_##name}
+#define const_iv(name) {#name, (IV)PURPLE_CONVERSATION_UPDATE_##name}
 		const_iv(ADD),
 		const_iv(REMOVE),
 		const_iv(ACCOUNT),
@@ -41,14 +32,14 @@ BOOT:
 	};
 	static const constiv typing_const_iv[] = {
 #undef const_iv
-#define const_iv(name) {#name, (IV)PURPLE_##name}
+#define const_iv(name) {#name, (IV)PURPLE_IM_CONVERSATION_##name}
 		const_iv(NOT_TYPING),
 		const_iv(TYPING),
 		const_iv(TYPED),
 	};
 	static const constiv flags_const_iv[] = {
 #undef const_iv
-#define const_iv(name) {#name, (IV)PURPLE_MESSAGE_##name}
+#define const_iv(name) {#name, (IV)PURPLE_CONVERSATION_MESSAGE_##name}
 		const_iv(SEND),
 		const_iv(RECV),
 		const_iv(SYSTEM),
@@ -66,7 +57,7 @@ BOOT:
 	};
 	static const constiv cbflags_const_iv[] = {
 #undef const_iv
-#define const_iv(name) {#name, (IV)PURPLE_CBFLAGS_##name}
+#define const_iv(name) {#name, (IV)PURPLE_CHAT_CONVERSATION_BUDDY_##name}
 		const_iv(NONE),
 		const_iv(VOICE),
 		const_iv(HALFOP),
@@ -75,9 +66,6 @@ BOOT:
 		const_iv(TYPING),
 	};
 
-	for (civ = type_const_iv + sizeof(type_const_iv) / sizeof(type_const_iv[0]); civ-- > type_const_iv; )
-		newCONSTSUB(type_stash, (char *)civ->name, newSViv(civ->iv));
-
 	for (civ = update_const_iv + sizeof(update_const_iv) / sizeof(update_const_iv[0]); civ-- > update_const_iv; )
 		newCONSTSUB(update_stash, (char *)civ->name, newSViv(civ->iv));
 
@@ -91,56 +79,53 @@ BOOT:
 		newCONSTSUB(cbflags_stash, (char *)civ->name, newSViv(civ->iv));
 }
 
-void
-purple_get_ims()
-PREINIT:
-	GList *l;
-PPCODE:
-	for (l = purple_get_ims(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
-	}
-
-void
-purple_get_conversations()
-PREINIT:
-	GList *l;
-PPCODE:
-	for (l = purple_get_conversations(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
-	}
-
-void
-purple_get_chats()
-PREINIT:
-	GList *l;
-PPCODE:
-	for (l = purple_get_chats(); l != NULL; l = l->next) {
-		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
-	}
-
-Purple::Conversation
-purple_find_conversation_with_account(type, name, account)
-	Purple::ConversationType type
-	const char *name
-	Purple::Account account
-
 MODULE = Purple::Conversation  PACKAGE = Purple::Conversations  PREFIX = purple_conversations_
 PROTOTYPES: ENABLE
 
 Purple::Handle
 purple_conversations_get_handle()
 
+Purple::ChatConversation
+purple_conversations_find_chat(gc, id)
+	Purple::Connection gc
+	int id
+
+void
+purple_conversations_get_ims()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = purple_conversations_get_ims(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
+	}
+
+void
+purple_conversations_get()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = purple_conversations_get(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
+	}
+
+void
+purple_conversations_get_chats()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = purple_conversations_get_chats(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
+	}
+
+Purple::Conversation
+purple_conversations_find_with_account(type, name, account)
+	GType type
+	const char *name
+	Purple::Account account
+
 MODULE = Purple::Conversation  PACKAGE = Purple::Conversation  PREFIX = purple_conversation_
 PROTOTYPES: ENABLE
 
-void
-purple_conversation_destroy(conv)
-	Purple::Conversation conv
-
-Purple::ConversationType
-purple_conversation_get_type(conv)
-	Purple::Conversation conv
-
 Purple::Account
 purple_conversation_get_account(conv)
 	Purple::Conversation conv
@@ -180,14 +165,6 @@ gboolean
 purple_conversation_is_logging(conv)
 	Purple::Conversation conv
 
-Purple::Conversation::IM
-purple_conversation_get_im_data(conv)
-	Purple::Conversation conv
-
-Purple::Conversation::Chat
-purple_conversation_get_chat_data(conv)
-	Purple::Conversation conv
-
 gpointer
 purple_conversation_get_data(conv, key)
 	Purple::Conversation conv
@@ -204,11 +181,11 @@ purple_conversation_has_focus(conv)
 void
 purple_conversation_update(conv, type)
 	Purple::Conversation conv
-	Purple::ConvUpdateType type
+	Purple::Conversation::UpdateType type
 
 Purple::Conversation
 purple_conversation_new(class, type, account, name)
-	Purple::ConversationType type
+	GType type
 	Purple::Account account
 	const char *name
     C_ARGS:
@@ -224,7 +201,7 @@ purple_conversation_write(conv, who, mes
 	Purple::Conversation conv
 	const char *who
 	const char *message
-	Purple::MessageFlags flags
+	Purple::Conversation::MessageFlags flags
 	time_t mtime
 
 gboolean
@@ -234,132 +211,127 @@ purple_conversation_do_command(conv, cmd
 	const char *markup
 	char **error
 
-MODULE = Purple::Conversation  PACKAGE = Purple::Conversation::IM  PREFIX = purple_conv_im_
+MODULE = Purple::Conversation  PACKAGE = Purple::IMConversation  PREFIX = purple_im_conversation_
 PROTOTYPES: ENABLE
 
-Purple::Conversation
-purple_conv_im_get_conversation(im)
-	Purple::Conversation::IM im
-
 void
-purple_conv_im_set_icon(im, icon)
-	Purple::Conversation::IM im
+purple_im_conversation_set_icon(im, icon)
+	Purple::IMConversation im
 	Purple::Buddy::Icon icon
 
 Purple::Buddy::Icon
-purple_conv_im_get_icon(im)
-	Purple::Conversation::IM im
+purple_im_conversation_get_icon(im)
+	Purple::IMConversation im
 
 void
-purple_conv_im_set_typing_state(im, state)
-	Purple::Conversation::IM im
-	Purple::TypingState state
+purple_im_conversation_set_typing_state(im, state)
+	Purple::IMConversation im
+	Purple::IMConversation::TypingState state
 
-Purple::TypingState
-purple_conv_im_get_typing_state(im)
-	Purple::Conversation::IM im
+Purple::IMConversation::TypingState



More information about the Commits mailing list