/soc/2013/ankitkv/gobjectification: a323e8b5a090: Refactored sil...
Ankit Vani
a at nevitus.org
Wed Aug 28 06:16:59 EDT 2013
Changeset: a323e8b5a09093055372ba6bd2e38ca8d628d5ae
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-28 15:45 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/a323e8b5a090
Description:
Refactored silc to use the GObjectified conversation API
diffstat:
libpurple/protocols/silc/buddy.c | 12 +-
libpurple/protocols/silc/ops.c | 160 +++++++++++++++++++-------------------
libpurple/protocols/silc/silc.c | 30 +++---
3 files changed, 103 insertions(+), 99 deletions(-)
diffs (truncated from 622 to 300 lines):
diff --git a/libpurple/protocols/silc/buddy.c b/libpurple/protocols/silc/buddy.c
--- a/libpurple/protocols/silc/buddy.c
+++ b/libpurple/protocols/silc/buddy.c
@@ -80,7 +80,7 @@ silcpurple_buddy_keyagr_cb(SilcClient cl
switch (status) {
case SILC_KEY_AGREEMENT_OK:
{
- PurpleConversation *convo;
+ PurpleIMConversation *im;
char tmp[128];
/* Set the private key for this client */
@@ -91,19 +91,19 @@ silcpurple_buddy_keyagr_cb(SilcClient cl
/* Open IM window */
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_IM,
+ im = purple_conversations_find_im_with_account(
client_entry->nickname, sg->account);
- if (convo) {
+ if (im) {
/* we don't have windows in the core anymore...but we may want to
* provide some method for asking the UI to show the window
- purple_conversation_window_show(purple_conversation_get_window(convo));
+ purple_conversation_window_show(purple_conversation_get_window(im));
*/
} else {
- convo = purple_im_conversation_new(sg->account,
+ im = purple_im_conversation_new(sg->account,
client_entry->nickname);
}
g_snprintf(tmp, sizeof(tmp), "%s [private key]", client_entry->nickname);
- purple_conversation_set_title(convo, tmp);
+ purple_conversation_set_title(PURPLE_CONVERSATION(im), tmp);
}
break;
diff --git a/libpurple/protocols/silc/ops.c b/libpurple/protocols/silc/ops.c
--- a/libpurple/protocols/silc/ops.c
+++ b/libpurple/protocols/silc/ops.c
@@ -93,7 +93,7 @@ silcpurple_mime_message(SilcClient clien
const unsigned char *data;
SilcUInt32 data_len;
PurpleMessageFlags cflags = 0;
- PurpleConversation *convo = NULL;
+ PurpleChatConversation *chat = NULL;
SilcBool ret = FALSE;
if (!mime)
@@ -187,7 +187,7 @@ silcpurple_mime_message(SilcClient clien
char tmp[32];
int imgid;
- /* Get channel convo (if message is for channel) */
+ /* Get channel chat (if message is for channel) */
if (key && channel) {
GList *l;
SilcPurplePrvgrp prv;
@@ -195,15 +195,15 @@ silcpurple_mime_message(SilcClient clien
for (l = sg->grps; l; l = l->next)
if (((SilcPurplePrvgrp)l->data)->key == key) {
prv = l->data;
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
prv->channel, sg->account);
break;
}
}
- if (channel && !convo)
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ if (channel && !chat)
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (channel && !convo)
+ if (channel && !chat)
goto out;
imgid = purple_imgstore_new_with_id(g_memdup(data, data_len), data_len, "");
@@ -214,7 +214,7 @@ silcpurple_mime_message(SilcClient clien
imgid);
if (channel)
- serv_got_chat_in(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo)),
+ serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
sender->nickname, cflags,
tmp, time(NULL));
else
@@ -262,7 +262,7 @@ silc_channel_message(SilcClient client,
{
PurpleConnection *gc = client->application;
SilcPurple sg = purple_connection_get_protocol_data(gc);
- PurpleConversation *convo = NULL;
+ PurpleChatConversation *chat = NULL;
char *msg, *tmp;
if (!message)
@@ -275,15 +275,15 @@ silc_channel_message(SilcClient client,
for (l = sg->grps; l; l = l->next)
if (((SilcPurplePrvgrp)l->data)->key == key) {
prv = l->data;
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
prv->channel, sg->account);
break;
}
}
- if (!convo)
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ if (!chat)
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
return;
if (flags & SILC_MESSAGE_FLAG_SIGNED &&
@@ -308,7 +308,7 @@ silc_channel_message(SilcClient client,
tmp = g_markup_escape_text(msg, -1);
/* Send to Purple */
- serv_got_chat_in(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo)),
+ serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
sender->nickname, 0, tmp, time(NULL));
g_free(tmp);
g_free(msg);
@@ -322,7 +322,7 @@ silc_channel_message(SilcClient client,
return;
/* Send to Purple */
- purple_conversation_write(convo, NULL, (const char *)msg,
+ purple_conversation_write(PURPLE_CONVERSATION(chat), NULL, (const char *)msg,
PURPLE_MESSAGE_SYSTEM, time(NULL));
g_free(msg);
return;
@@ -337,7 +337,7 @@ silc_channel_message(SilcClient client,
}
tmp = g_markup_escape_text(msg, -1);
/* Send to Purple */
- serv_got_chat_in(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo)),
+ serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
sender->nickname, 0, tmp, time(NULL));
g_free(salvaged);
g_free(tmp);
@@ -366,7 +366,7 @@ silc_private_message(SilcClient client,
return;
/* XXX - Should this be PURPLE_CONV_TYPE_IM? */
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_ANY,
+ convo = purple_conversations_find_with_account(
sender->nickname, sg->account);
if (flags & SILC_MESSAGE_FLAG_SIGNED &&
@@ -443,7 +443,7 @@ silc_notify(SilcClient client, SilcClien
PurpleConnection *gc = client->application;
SilcPurple sg = purple_connection_get_protocol_data(gc);
PurpleAccount *account = purple_connection_get_account(gc);
- PurpleConversation *convo;
+ PurpleChatConversation *chat;
SilcClientEntry client_entry, client_entry2;
SilcChannelEntry channel;
SilcServerEntry server_entry;
@@ -486,15 +486,15 @@ silc_notify(SilcClient client, SilcClien
if (client_entry == conn->local_entry)
break;
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
break;
/* Join user to channel */
g_snprintf(buf, sizeof(buf), "%s@%s",
client_entry->username, client_entry->hostname);
- purple_chat_conversation_add_user(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_add_user(chat,
client_entry->nickname, buf, PURPLE_CHAT_USER_NONE, TRUE);
break;
@@ -503,13 +503,13 @@ silc_notify(SilcClient client, SilcClien
client_entry = va_arg(va, SilcClientEntry);
channel = va_arg(va, SilcChannelEntry);
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
break;
/* Remove user from channel */
- purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_remove_user(chat,
client_entry->nickname, NULL);
break;
@@ -521,11 +521,11 @@ silc_notify(SilcClient client, SilcClien
/* Remove from all channels */
silc_hash_table_list(client_entry->channels, &htl);
while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
chu->channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
continue;
- purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_remove_user(chat,
client_entry->nickname,
tmp);
}
@@ -541,9 +541,9 @@ silc_notify(SilcClient client, SilcClien
tmp = va_arg(va, char *);
channel = va_arg(va, SilcChannelEntry);
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
break;
if (!tmp)
@@ -558,30 +558,30 @@ silc_notify(SilcClient client, SilcClien
g_snprintf(buf, sizeof(buf),
_("%s has changed the topic of <I>%s</I> to: %s"),
client_entry->nickname, channel->channel_name, tmp2);
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), client_entry->nickname,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname,
buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
- purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_set_topic(chat,
client_entry->nickname, tmp);
} else if (idtype == SILC_ID_SERVER) {
server_entry = (SilcServerEntry)entry;
g_snprintf(buf, sizeof(buf),
_("%s has changed the topic of <I>%s</I> to: %s"),
server_entry->server_name, channel->channel_name, tmp2);
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), server_entry->server_name,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat), server_entry->server_name,
buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
- purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_set_topic(chat,
server_entry->server_name, tmp);
} else if (idtype == SILC_ID_CHANNEL) {
channel = (SilcChannelEntry)entry;
g_snprintf(buf, sizeof(buf),
_("%s has changed the topic of <I>%s</I> to: %s"),
channel->channel_name, channel->channel_name, tmp2);
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), channel->channel_name,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name,
buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
- purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo),
+ purple_chat_conversation_set_topic(chat,
channel->channel_name, tmp);
} else {
- purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), NULL, tmp);
+ purple_chat_conversation_set_topic(chat, NULL, tmp);
}
g_free(tmp2);
@@ -600,12 +600,12 @@ silc_notify(SilcClient client, SilcClien
/* Change nick on all channels */
silc_hash_table_list(client_entry->channels, &htl);
while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
chu->channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
continue;
- if (purple_chat_conversation_has_user(PURPLE_CONV_CHAT(convo), client_entry->nickname))
- purple_chat_conversation_rename_user(PURPLE_CONV_CHAT(convo),
+ if (purple_chat_conversation_has_user(chat, client_entry->nickname))
+ purple_chat_conversation_rename_user(chat,
tmp, name);
}
silc_hash_table_list_reset(&htl);
@@ -623,9 +623,9 @@ silc_notify(SilcClient client, SilcClien
(void)va_arg(va, SilcDList);
channel = va_arg(va, SilcChannelEntry);
- convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT,
+ chat = purple_conversations_find_chat_with_account(
channel->channel_name, sg->account);
- if (!convo)
+ if (!chat)
break;
if (idtype == SILC_ID_CLIENT)
@@ -647,7 +647,7 @@ silc_notify(SilcClient client, SilcClien
_("<I>%s</I> removed all channel <I>%s</I> modes"), name,
channel->channel_name);
}
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), channel->channel_name,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name,
buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
break;
More information about the Commits
mailing list