/soc/2013/ankitkv/gobjectification: 90fa70aa7e28: Refactored the...
Ankit Vani
a at nevitus.org
Sun Jun 23 12:15:45 EDT 2013
Changeset: 90fa70aa7e28730ccfe7693c55e65a49d321de6f
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-23 21:45 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/90fa70aa7e28
Description:
Refactored the jabber protocol to use GObject-based PurpleConversation
diffstat:
libpurple/protocols/jabber/chat.c | 16 +++---
libpurple/protocols/jabber/chat.h | 6 +-
libpurple/protocols/jabber/jabber.c | 30 +++++-----
libpurple/protocols/jabber/libfacebook.c | 6 +-
libpurple/protocols/jabber/libgtalk.c | 6 +-
libpurple/protocols/jabber/libxmpp.c | 6 +-
libpurple/protocols/jabber/message.c | 85 ++++++++++++++-----------------
libpurple/protocols/jabber/presence.c | 25 ++++----
8 files changed, 85 insertions(+), 95 deletions(-)
diffs (truncated from 547 to 300 lines):
diff --git a/libpurple/protocols/jabber/chat.c b/libpurple/protocols/jabber/chat.c
--- a/libpurple/protocols/jabber/chat.c
+++ b/libpurple/protocols/jabber/chat.c
@@ -138,16 +138,16 @@ JabberChat *jabber_chat_find_by_id(Jabbe
return chat;
}
-JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv)
+JabberChat *jabber_chat_find_by_conv(PurpleChatConversation *conv)
{
- PurpleAccount *account = purple_conversation_get_account(conv);
+ PurpleAccount *account = purple_conversation_get_account(PURPLE_CONVERSATION(conv));
PurpleConnection *gc = purple_account_get_connection(account);
JabberStream *js;
int id;
if (!gc)
return NULL;
js = purple_connection_get_protocol_data(gc);
- id = purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv));
+ id = purple_chat_conversation_get_id(conv);
return jabber_chat_find_by_id(js, id);
}
@@ -451,9 +451,9 @@ void jabber_chat_free(JabberChat *chat)
g_free(chat);
}
-gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name)
+gboolean jabber_chat_find_buddy(PurpleChatConversation *conv, const char *name)
{
- return purple_chat_conversation_find_user(PURPLE_CONV_CHAT(conv), name);
+ return purple_chat_conversation_find_user(conv, name);
}
char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who)
@@ -753,7 +753,7 @@ gboolean jabber_chat_change_nick(JabberC
int priority;
if(!chat->muc) {
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(chat->conv), "",
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "",
_("Nick changing not supported in non-MUC chatrooms"),
PURPLE_MESSAGE_SYSTEM, time(NULL));
return FALSE;
@@ -1072,7 +1072,7 @@ jabber_chat_affiliation_list_cb(JabberSt
buf = g_string_append_len(buf, _("No users found"), -1);
}
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(chat->conv), "", buf->str,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", buf->str,
PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
g_string_free(buf, TRUE);
@@ -1167,7 +1167,7 @@ static void jabber_chat_role_list_cb(Jab
buf = g_string_append_len(buf, _("No users found"), -1);
}
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(chat->conv), "", buf->str,
+ purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", buf->str,
PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
g_string_free(buf, TRUE);
diff --git a/libpurple/protocols/jabber/chat.h b/libpurple/protocols/jabber/chat.h
--- a/libpurple/protocols/jabber/chat.h
+++ b/libpurple/protocols/jabber/chat.h
@@ -45,7 +45,7 @@ typedef struct _JabberChat {
char *handle;
GHashTable *components;
int id;
- PurpleConversation *conv;
+ PurpleChatConversation *conv;
gboolean muc;
gboolean xhtml;
PurpleRequestType config_dialog_type;
@@ -77,10 +77,10 @@ void jabber_chat_join(PurpleConnection *
JabberChat *jabber_chat_find(JabberStream *js, const char *room,
const char *server);
JabberChat *jabber_chat_find_by_id(JabberStream *js, int id);
-JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv);
+JabberChat *jabber_chat_find_by_conv(PurpleChatConversation *conv);
void jabber_chat_destroy(JabberChat *chat);
void jabber_chat_free(JabberChat *chat);
-gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name);
+gboolean jabber_chat_find_buddy(PurpleChatConversation *conv, const char *name);
void jabber_chat_invite(PurpleConnection *gc, int id, const char *message,
const char *name);
void jabber_chat_leave(PurpleConnection *gc, int id);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2827,7 +2827,7 @@ char *jabber_parse_error(JabberStream *j
static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat)
return PURPLE_CMD_RET_FAILED;
@@ -2839,7 +2839,7 @@ static PurpleCmdRet jabber_cmd_chat_conf
static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat)
return PURPLE_CMD_RET_FAILED;
@@ -2851,7 +2851,7 @@ static PurpleCmdRet jabber_cmd_chat_regi
static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat)
return PURPLE_CMD_RET_FAILED;
@@ -2859,7 +2859,7 @@ static PurpleCmdRet jabber_cmd_chat_topi
if (args && args[0] && *args[0])
jabber_chat_change_topic(chat, args[0]);
else {
- const char *cur = purple_chat_conversation_get_topic(PURPLE_CONV_CHAT(conv));
+ const char *cur = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(conv));
char *buf, *tmp, *tmp2;
if (cur) {
@@ -2870,7 +2870,7 @@ static PurpleCmdRet jabber_cmd_chat_topi
g_free(tmp2);
} else
buf = g_strdup(_("No topic is set"));
- purple_chat_conversation_write_message(PURPLE_CONV_CHAT(conv), "", buf,
+ purple_conversation_write_message(conv, "", buf,
PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
g_free(buf);
}
@@ -2881,7 +2881,7 @@ static PurpleCmdRet jabber_cmd_chat_topi
static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if(!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
@@ -2900,7 +2900,7 @@ static PurpleCmdRet jabber_cmd_chat_nick
static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat)
return PURPLE_CMD_RET_FAILED;
@@ -2912,7 +2912,7 @@ static PurpleCmdRet jabber_cmd_chat_part
static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if(!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
@@ -2928,7 +2928,7 @@ static PurpleCmdRet jabber_cmd_chat_ban(
static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
@@ -2964,7 +2964,7 @@ static PurpleCmdRet jabber_cmd_chat_affi
static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if (!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
@@ -3003,7 +3003,7 @@ static PurpleCmdRet jabber_cmd_chat_invi
return PURPLE_CMD_RET_FAILED;
jabber_chat_invite(purple_conversation_get_connection(conv),
- purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), args[1] ? args[1] : "",
+ purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)), args[1] ? args[1] : "",
args[0]);
return PURPLE_CMD_RET_OK;
@@ -3012,7 +3012,7 @@ static PurpleCmdRet jabber_cmd_chat_invi
static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
GHashTable *components;
JabberID *jid = NULL;
const char *room = NULL, *server = NULL, *handle = NULL;
@@ -3059,7 +3059,7 @@ static PurpleCmdRet jabber_cmd_chat_join
static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
if(!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
@@ -3075,7 +3075,7 @@ static PurpleCmdRet jabber_cmd_chat_kick
static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberChat *chat = jabber_chat_find_by_conv(conv);
+ JabberChat *chat = jabber_chat_find_by_conv(PURPLE_CHAT_CONVERSATION(conv));
char *who;
if (!chat)
@@ -3175,7 +3175,7 @@ static PurpleCmdRet jabber_cmd_buzz(Purp
if (!args || !args[0]) {
/* use the buddy from conversation, if it's a one-to-one conversation */
- if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
+ if (PURPLE_IS_IM_CONVERSATION(conv)) {
who = purple_conversation_get_name(conv);
} else {
return PURPLE_CMD_RET_FAILED;
diff --git a/libpurple/protocols/jabber/libfacebook.c b/libpurple/protocols/jabber/libfacebook.c
--- a/libpurple/protocols/jabber/libfacebook.c
+++ b/libpurple/protocols/jabber/libfacebook.c
@@ -229,11 +229,11 @@ static gboolean xmpp_uri_handler(const c
if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
char *body = g_hash_table_lookup(params, "body");
if (user && *user) {
- PurpleConversation *conv =
+ PurpleIMConversation *im =
purple_im_conversation_new(acct, user);
- purple_conversation_present(conv);
+ purple_conversation_present(PURPLE_CONVERSATION(im));
if (body && *body)
- purple_conv_send_confirm(conv, body);
+ purple_conversation_send_confirm(PURPLE_CONVERSATION(im), body);
}
} else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
char *name = g_hash_table_lookup(params, "name");
diff --git a/libpurple/protocols/jabber/libgtalk.c b/libpurple/protocols/jabber/libgtalk.c
--- a/libpurple/protocols/jabber/libgtalk.c
+++ b/libpurple/protocols/jabber/libgtalk.c
@@ -229,11 +229,11 @@ static gboolean xmpp_uri_handler(const c
if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
char *body = g_hash_table_lookup(params, "body");
if (user && *user) {
- PurpleConversation *conv =
+ PurpleIMConversation *im =
purple_im_conversation_new(acct, user);
- purple_conversation_present(conv);
+ purple_conversation_present(PURPLE_CONVERSATION(im));
if (body && *body)
- purple_conv_send_confirm(conv, body);
+ purple_conversation_send_confirm(PURPLE_CONVERSATION(im), body);
}
} else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
char *name = g_hash_table_lookup(params, "name");
diff --git a/libpurple/protocols/jabber/libxmpp.c b/libpurple/protocols/jabber/libxmpp.c
--- a/libpurple/protocols/jabber/libxmpp.c
+++ b/libpurple/protocols/jabber/libxmpp.c
@@ -223,11 +223,11 @@ static gboolean xmpp_uri_handler(const c
if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
char *body = g_hash_table_lookup(params, "body");
if (user && *user) {
- PurpleConversation *conv =
+ PurpleIMConversation *im =
purple_im_conversation_new(acct, user);
- purple_conversation_present(conv);
+ purple_conversation_present(PURPLE_CONVERSATION(im));
if (body && *body)
- purple_conv_send_confirm(conv, body);
+ purple_conversation_send_confirm(PURPLE_CONVERSATION(im), body);
}
} else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
char *name = g_hash_table_lookup(params, "name");
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -83,9 +83,9 @@ static void handle_chat(JabberMessage *j
} else if(JM_STATE_PAUSED == jm->chat_state) {
serv_got_typing(gc, jm->from, 0, PURPLE_IM_CONVERSATION_TYPED);
} else if(JM_STATE_GONE == jm->chat_state) {
- PurpleConversation *conv = purple_conversations_find_with_account(PURPLE_CONV_TYPE_IM,
+ PurpleIMConversation *im = purple_conversations_find_im_with_account(
jm->from, account);
- if (conv && jid->node && jid->domain) {
+ if (im && jid->node && jid->domain) {
char buf[256];
PurpleBuddy *buddy;
@@ -105,7 +105,7 @@ static void handle_chat(JabberMessage *j
/* At some point when we restructure PurpleConversation,
* this should be able to be implemented by removing the
* user from the conversation like we do with chats now. */
- purple_conversation_write(conv, "", buf,
+ purple_conversation_write(PURPLE_CONVERSATION(im), "", buf,
More information about the Commits
mailing list