/soc/2013/ankitkv/gobjectification: a04c721bebf1: Refactored acc...
Ankit Vani
a at nevitus.org
Mon Jun 24 04:18:56 EDT 2013
Changeset: a04c721bebf19c193bdadd0643f6c3074f9015d7
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-24 13:42 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/a04c721bebf1
Description:
Refactored accounts, blist, cmds and connection to use the GObject conversation API
diffstat:
libpurple/accounts.c | 2 +-
libpurple/blist.c | 24 ++++++++++++------------
libpurple/buddyicon.c | 24 ++++++++++++------------
libpurple/cmds.c | 16 ++++++----------
libpurple/connection.c | 4 ++--
libpurple/connection.h | 3 +--
6 files changed, 34 insertions(+), 39 deletions(-)
diffs (228 lines):
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -701,7 +701,7 @@ purple_accounts_delete(PurpleAccount *ac
PurpleConversation *conv = iter->data;
iter = iter->next;
if (purple_conversation_get_account(conv) == account)
- purple_conversation_destroy(conv);
+ g_object_unref(conv);
}
/* Remove this account's pounces */
diff --git a/libpurple/blist.c b/libpurple/blist.c
--- a/libpurple/blist.c
+++ b/libpurple/blist.c
@@ -1002,7 +1002,7 @@ purple_strings_are_different(const char
void purple_blist_alias_contact(PurpleContact *contact, const char *alias)
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
- PurpleConversation *conv;
+ PurpleIMConversation *im;
PurpleBlistNode *bnode;
char *old_alias;
char *new_alias = NULL;
@@ -1036,10 +1036,10 @@ void purple_blist_alias_contact(PurpleCo
{
PurpleBuddy *buddy = (PurpleBuddy *)bnode;
- conv = purple_conversations_find_im_with_account(buddy->name,
+ im = purple_conversations_find_im_with_account(buddy->name,
buddy->account);
- if (conv)
- purple_conversation_autoset_title(conv);
+ if (im)
+ purple_conversation_autoset_title(PURPLE_CONVERSATION(im));
}
purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
@@ -1086,7 +1086,7 @@ void purple_blist_alias_chat(PurpleChat
void purple_blist_alias_buddy(PurpleBuddy *buddy, const char *alias)
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
- PurpleConversation *conv;
+ PurpleIMConversation *im;
char *old_alias;
char *new_alias = NULL;
@@ -1115,10 +1115,10 @@ void purple_blist_alias_buddy(PurpleBudd
if (ops && ops->update)
ops->update(purplebuddylist, (PurpleBlistNode *)buddy);
- conv = purple_conversations_find_im_with_account(buddy->name,
+ im = purple_conversations_find_im_with_account(buddy->name,
buddy->account);
- if (conv)
- purple_conversation_autoset_title(conv);
+ if (im)
+ purple_conversation_autoset_title(PURPLE_CONVERSATION(im));
purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
buddy, old_alias);
@@ -1128,7 +1128,7 @@ void purple_blist_alias_buddy(PurpleBudd
void purple_blist_server_alias_buddy(PurpleBuddy *buddy, const char *alias)
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
- PurpleConversation *conv;
+ PurpleIMConversation *im;
char *old_alias;
char *new_alias = NULL;
@@ -1157,10 +1157,10 @@ void purple_blist_server_alias_buddy(Pur
if (ops && ops->update)
ops->update(purplebuddylist, (PurpleBlistNode *)buddy);
- conv = purple_conversations_find_im_with_account(buddy->name,
+ im = purple_conversations_find_im_with_account(buddy->name,
buddy->account);
- if (conv)
- purple_conversation_autoset_title(conv);
+ if (im)
+ purple_conversation_autoset_title(PURPLE_CONVERSATION(im));
purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
buddy, old_alias);
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -371,7 +371,7 @@ purple_buddy_icon_unref(PurpleBuddyIcon
void
purple_buddy_icon_update(PurpleBuddyIcon *icon)
{
- PurpleConversation *conv;
+ PurpleIMConversation *im;
PurpleAccount *account;
const char *username;
PurpleBuddyIcon *icon_to_set;
@@ -432,10 +432,10 @@ purple_buddy_icon_update(PurpleBuddyIcon
buddies = g_slist_delete_link(buddies, buddies);
}
- conv = purple_conversations_find_im_with_account(username, account);
+ im = purple_conversations_find_im_with_account(username, account);
- if (conv != NULL)
- purple_im_conversation_set_icon(PURPLE_CONV_IM(conv), icon_to_set);
+ if (im != NULL)
+ purple_im_conversation_set_icon(im, icon_to_set);
/* icon's refcount was incremented above */
purple_buddy_icon_unref(icon);
@@ -877,16 +877,16 @@ purple_buddy_icons_node_set_custom_icon(
child = purple_blist_node_get_sibling_next(child))
{
PurpleBuddy *buddy;
- PurpleConversation *conv;
+ PurpleIMConversation *im;
if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
continue;
buddy = (PurpleBuddy *)child;
- conv = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy));
- if (conv)
- purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_ICON);
+ im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy));
+ if (im)
+ purple_conversation_update(PURPLE_CONVERSATION(im), PURPLE_CONVERSATION_UPDATE_ICON);
/* Is this call necessary anymore? Can the buddies
* themselves need updating when the custom buddy
@@ -894,11 +894,11 @@ purple_buddy_icons_node_set_custom_icon(
purple_blist_update_node_icon((PurpleBlistNode*)buddy);
}
} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
- PurpleConversation *conv = NULL;
+ PurpleChatConversation *chat = NULL;
- conv = purple_conversations_find_chat_with_account(purple_chat_get_name((PurpleChat*)node), purple_chat_get_account((PurpleChat*)node));
- if (conv) {
- purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_ICON);
+ chat = purple_conversations_find_chat_with_account(purple_chat_get_name((PurpleChat*)node), purple_chat_get_account((PurpleChat*)node));
+ if (chat) {
+ purple_conversation_update(PURPLE_CONVERSATION(chat), PURPLE_CONVERSATION_UPDATE_ICON);
}
}
diff --git a/libpurple/cmds.c b/libpurple/cmds.c
--- a/libpurple/cmds.c
+++ b/libpurple/cmds.c
@@ -202,7 +202,7 @@ PurpleCmdStatus purple_cmd_do_command(Pu
PurpleCmd *c;
GList *l;
gchar *err = NULL;
- gboolean is_im;
+ gboolean is_im = TRUE;
gboolean found = FALSE, tried_cmd = FALSE, right_type = FALSE, right_prpl = FALSE;
const gchar *prpl_id;
gchar **args = NULL;
@@ -212,12 +212,8 @@ PurpleCmdStatus purple_cmd_do_command(Pu
*error = NULL;
prpl_id = purple_account_get_protocol_id(purple_conversation_get_account(conv));
- if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
- is_im = TRUE;
- else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
+ if (PURPLE_IS_CHAT_CONVERSATION(conv))
is_im = FALSE;
- else
- return PURPLE_CMD_STATUS_FAILED;
rest = strchr(cmdline, ' ');
if (rest) {
@@ -311,10 +307,10 @@ GList *purple_cmd_list(PurpleConversatio
for (l = cmds; l; l = l->next) {
c = l->data;
- if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM))
+ if (conv && PURPLE_IS_IM_CONVERSATION(conv))
if (!(c->flags & PURPLE_CMD_FLAG_IM))
continue;
- if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT))
+ if (conv && PURPLE_IS_CHAT_CONVERSATION(conv))
if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
continue;
@@ -343,10 +339,10 @@ GList *purple_cmd_help(PurpleConversatio
if (cmd && !purple_strequal(cmd, c->cmd))
continue;
- if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM))
+ if (conv && PURPLE_IS_IM_CONVERSATION(conv))
if (!(c->flags & PURPLE_CMD_FLAG_IM))
continue;
- if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT))
+ if (conv && PURPLE_IS_CHAT_CONVERSATION(conv))
if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
continue;
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -244,10 +244,10 @@ void
while (gc->buddy_chats)
{
- PurpleConversation *b = gc->buddy_chats->data;
+ PurpleChatConversation *b = gc->buddy_chats->data;
gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
- purple_chat_conversation_left(PURPLE_CONV_CHAT(b));
+ purple_chat_conversation_leave(b);
}
update_keepalive(gc, FALSE);
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -237,8 +237,7 @@ struct _PurpleConnection
char *password; /**< The password used. */
GSList *buddy_chats; /**< A list of active chats
- (#PurpleConversation structs of type
- #PURPLE_CONV_TYPE_CHAT). */
+ (#PurpleChatConversation structs). */
void *proto_data; /**< Protocol-specific data. */
char *display_name; /**< How you appear to other people. */
More information about the Commits
mailing list