/soc/2013/ankitkv/gobjectification: f14347f38e3b: Refactor the r...
Ankit Vani
a at nevitus.org
Fri Jun 28 14:45:07 EDT 2013
Changeset: f14347f38e3b1fe907426b41460b577e5f27fa69
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-29 00:14 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f14347f38e3b
Description:
Refactor the remaining pidgin to use the GObject conversation API
diffstat:
pidgin/gtkdialogs.c | 12 +++++-----
pidgin/gtkimhtmltoolbar.c | 2 +-
pidgin/gtkmedia.c | 4 +-
pidgin/gtknotify.c | 7 ++---
pidgin/gtkpounce.c | 10 ++++----
pidgin/gtksound.c | 40 ++++++++++++++++------------------
pidgin/gtkutils.c | 4 +-
pidgin/gtkwebviewtoolbar.c | 2 +-
pidgin/plugins/perl/common/GtkConv.xs | 4 +-
9 files changed, 41 insertions(+), 44 deletions(-)
diffs (253 lines):
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -952,18 +952,18 @@ pidgin_dialogs_im(void)
void
pidgin_dialogs_im_with_user(PurpleAccount *account, const char *username)
{
- PurpleConversation *conv;
+ PurpleIMConversation *im;
g_return_if_fail(account != NULL);
g_return_if_fail(username != NULL);
- conv = purple_conversations_find_im_with_account(username, account);
+ im = purple_conversations_find_im_with_account(username, account);
- if (conv == NULL)
- conv = purple_im_conversation_new(account, username);
+ if (im == NULL)
+ im = purple_im_conversation_new(account, username);
- pidgin_conv_attach_to_conversation(conv);
- purple_conversation_present(conv);
+ pidgin_conv_attach_to_conversation(PURPLE_CONVERSATION(im));
+ purple_conversation_present(PURPLE_CONVERSATION(im));
}
static gboolean
diff --git a/pidgin/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c
--- a/pidgin/gtkimhtmltoolbar.c
+++ b/pidgin/gtkimhtmltoolbar.c
@@ -1600,7 +1600,7 @@ void gtk_imhtmltoolbar_switch_active_con
/* gray out attention button on protocols that don't support it
for the time being it is always disabled for chats */
gtk_widget_set_sensitive(toolbar->attention,
- conv && prpl && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM &&
+ conv && prpl && PURPLE_IS_IM_CONVERSATION(conv) &&
PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention != NULL);
}
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -523,7 +523,7 @@ static void
pidgin_media_emit_message(PidginMedia *gtkmedia, const char *msg)
{
PurpleConversation *conv = purple_conversations_find_with_account(
- PURPLE_CONV_TYPE_ANY, gtkmedia->priv->screenname,
+ gtkmedia->priv->screenname,
purple_media_get_account(gtkmedia->priv->media));
if (conv != NULL)
purple_conversation_write(conv, NULL, msg,
@@ -596,7 +596,7 @@ static void
pidgin_media_error_cb(PidginMedia *media, const char *error, PidginMedia *gtkmedia)
{
PurpleConversation *conv = purple_conversations_find_with_account(
- PURPLE_CONV_TYPE_ANY, gtkmedia->priv->screenname,
+ gtkmedia->priv->screenname,
purple_media_get_account(gtkmedia->priv->media));
if (conv != NULL)
purple_conversation_write(conv, NULL, error,
diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c
--- a/pidgin/gtknotify.c
+++ b/pidgin/gtknotify.c
@@ -192,11 +192,10 @@ open_im_foreach(GtkTreeModel *model, Gtk
-1);
if (pounce_data != NULL) {
- PurpleConversation *conv;
+ PurpleIMConversation *im;
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
- pounce_data->account, pounce_data->pouncee);
- purple_conversation_present(conv);
+ im = purple_im_conversation_new(pounce_data->account, pounce_data->pouncee);
+ purple_conversation_present(PURPLE_CONVERSATION(im));
}
}
diff --git a/pidgin/gtkpounce.c b/pidgin/gtkpounce.c
--- a/pidgin/gtkpounce.c
+++ b/pidgin/gtkpounce.c
@@ -1412,7 +1412,7 @@ pidgin_pounces_manager_hide(void)
static void
pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
{
- PurpleConversation *conv;
+ PurpleIMConversation *im;
PurpleAccount *account;
PurpleBuddy *buddy;
const char *pouncee;
@@ -1487,12 +1487,12 @@ pounce_cb(PurplePounce *pounce, PurplePo
if (message != NULL)
{
- conv = purple_conversations_find_im_with_account(pouncee, account);
+ im = purple_conversations_find_im_with_account(pouncee, account);
- if (conv == NULL)
- conv = purple_im_conversation_new(account, pouncee);
+ if (im == NULL)
+ im = purple_im_conversation_new(account, pouncee);
- purple_conversation_write(conv, NULL, message,
+ purple_conversation_write(PURPLE_CONVERSATION(im), NULL, message,
PURPLE_MESSAGE_SEND, time(NULL));
serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
diff --git a/pidgin/gtksound.c b/pidgin/gtksound.c
--- a/pidgin/gtksound.c
+++ b/pidgin/gtksound.c
@@ -85,19 +85,19 @@ unmute_login_sounds_cb(gpointer data)
}
static gboolean
-chat_nick_matches_name(PurpleConversation *conv, const char *aname)
+chat_nick_matches_name(PurpleChatConversation *chat, const char *aname)
{
- PurpleChatConversation *chat = NULL;
char *nick = NULL;
char *name = NULL;
gboolean ret = FALSE;
- chat = purple_conversation_get_chat_data(conv);
if (chat==NULL)
return ret;
- nick = g_strdup(purple_normalize(purple_conversation_get_account(conv), purple_chat_conversation_get_nick(chat)));
- name = g_strdup(purple_normalize(purple_conversation_get_account(conv), aname));
+ nick = g_strdup(purple_normalize(purple_conversation_get_account(
+ PURPLE_CONVERSATION(chat)), purple_chat_conversation_get_nick(chat)));
+ name = g_strdup(purple_normalize(purple_conversation_get_account(
+ PURPLE_CONVERSATION(chat)), aname));
if (g_utf8_collate(nick, name) == 0)
ret = TRUE;
@@ -158,26 +158,26 @@ static void
im_msg_sent_cb(PurpleAccount *account, const char *receiver,
const char *message, PurpleSoundEventID event)
{
- PurpleConversation *conv = purple_conversations_find_with_account(
- PURPLE_CONV_TYPE_IM, receiver, account);
+ PurpleConversation *conv = PURPLE_CONVERSATION(
+ purple_conversations_find_im_with_account(receiver, account));
play_conv_event(conv, event);
}
static void
-chat_buddy_join_cb(PurpleConversation *conv, const char *name,
+chat_buddy_join_cb(PurpleChatConversation *chat, const char *name,
PurpleChatConversationBuddyFlags flags, gboolean new_arrival,
PurpleSoundEventID event)
{
- if (new_arrival && !chat_nick_matches_name(conv, name))
- play_conv_event(conv, event);
+ if (new_arrival && !chat_nick_matches_name(chat, name))
+ play_conv_event(PURPLE_CONVERSATION(chat), event);
}
static void
-chat_buddy_left_cb(PurpleConversation *conv, const char *name,
+chat_buddy_left_cb(PurpleChatConversation *chat, const char *name,
const char *reason, PurpleSoundEventID event)
{
- if (!chat_nick_matches_name(conv, name))
- play_conv_event(conv, event);
+ if (!chat_nick_matches_name(chat, name))
+ play_conv_event(PURPLE_CONVERSATION(chat), event);
}
static void
@@ -188,28 +188,26 @@ chat_msg_sent_cb(PurpleAccount *account,
PurpleConversation *conv = NULL;
if (conn!=NULL)
- conv = purple_conversations_find_chat(conn,id);
+ conv = PURPLE_CONVERSATION(purple_conversations_find_chat(conn,id));
play_conv_event(conv, event);
}
static void
chat_msg_received_cb(PurpleAccount *account, char *sender,
- char *message, PurpleConversation *conv,
+ char *message, PurpleChatConversation *chat,
PurpleMessageFlags flags, PurpleSoundEventID event)
{
- PurpleChatConversation *chat;
-
+ PurpleConversation *conv = PURPLE_CONVERSATION(chat);
if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY)
return;
- chat = purple_conversation_get_chat_data(conv);
- g_return_if_fail(chat != NULL);
+ g_return_if_fail(conv != NULL);
- if (purple_chat_conversation_is_user_ignored(chat, sender))
+ if (purple_chat_conversation_is_ignored_user(chat, sender))
return;
- if (chat_nick_matches_name(conv, sender))
+ if (chat_nick_matches_name(chat, sender))
return;
if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, purple_chat_conversation_get_nick(chat)))
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -1393,7 +1393,7 @@ static void dnd_image_ok_callback(_DndDa
serv_send_file(purple_account_get_connection(data->account), data->who, data->filename);
break;
case DND_IM_IMAGE:
- conv = purple_im_conversation_new(data->account, data->who);
+ conv = PURPLE_CONVERSATION(purple_im_conversation_new(data->account, data->who));
gtkconv = PIDGIN_CONVERSATION(conv);
if (!g_file_get_contents(data->filename, &filedata, &size,
@@ -1573,7 +1573,7 @@ pidgin_dnd_file_manage(GtkSelectionData
PidginConversation *gtkconv;
case PURPLE_DESKTOP_ITEM_TYPE_LINK:
- conv = purple_im_conversation_new(account, who);
+ conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, who));
gtkconv = PIDGIN_CONVERSATION(conv);
gtk_webview_insert_link(GTK_WEBVIEW(gtkconv->entry),
purple_desktop_item_get_string(item, "URL"),
diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -1618,7 +1618,7 @@ gtk_webviewtoolbar_switch_active_convers
/* gray out attention button on protocols that don't support it
for the time being it is always disabled for chats */
gtk_action_set_sensitive(priv->attention,
- conv && prpl && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM &&
+ conv && prpl && PURPLE_IS_IM_CONVERSATION(conv) &&
PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention != NULL);
}
diff --git a/pidgin/plugins/perl/common/GtkConv.xs b/pidgin/plugins/perl/common/GtkConv.xs
--- a/pidgin/plugins/perl/common/GtkConv.xs
+++ b/pidgin/plugins/perl/common/GtkConv.xs
@@ -4,8 +4,8 @@ MODULE = Pidgin::Conversation PACKAGE =
PROTOTYPES: ENABLE
void
-pidgin_conv_update_buddy_icon(conv)
- Purple::Conversation conv
+pidgin_conv_update_buddy_icon(im)
+ Purple::IMConversation im
void
pidgin_conv_switch_active_conversation(conv)
More information about the Commits
mailing list