/soc/2013/ankitkv/gobjectification: 64870de1db58: Refactored roo...
Ankit Vani
a at nevitus.org
Mon Jul 29 11:33:03 EDT 2013
Changeset: 64870de1db58781123d5e0332ef20b4330fe668f
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-29 21:02 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/64870de1db58
Description:
Refactored roomlist, server, sslconn, whiteboard to use the initial GObject plugin API
diffstat:
libpurple/roomlist.c | 18 +---------
libpurple/server.c | 83 +++++++++++++------------------------------------
libpurple/sslconn.c | 6 ++-
libpurple/util.c | 2 +-
libpurple/whiteboard.c | 3 +-
5 files changed, 31 insertions(+), 81 deletions(-)
diffs (truncated from 406 to 300 lines):
diff --git a/libpurple/roomlist.c b/libpurple/roomlist.c
--- a/libpurple/roomlist.c
+++ b/libpurple/roomlist.c
@@ -207,16 +207,12 @@ void purple_roomlist_room_add(PurpleRoom
PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc)
{
- PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
g_return_val_if_fail(gc != NULL, NULL);
g_return_val_if_fail(PURPLE_CONNECTION_IS_CONNECTED(gc), NULL);
- prpl = purple_connection_get_protocol_info(gc);
-
- if(prpl != NULL)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if(prpl_info && prpl_info->roomlist_get_list)
return prpl_info->roomlist_get_list(gc);
@@ -226,7 +222,6 @@ PurpleRoomlist *purple_roomlist_get_list
void purple_roomlist_cancel_get_list(PurpleRoomlist *list)
{
- PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc;
@@ -237,10 +232,7 @@ void purple_roomlist_cancel_get_list(Pur
g_return_if_fail(gc != NULL);
if(gc)
- prpl = purple_connection_get_protocol_info(gc);
-
- if(prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if(prpl_info && prpl_info->roomlist_cancel)
prpl_info->roomlist_cancel(list);
@@ -248,7 +240,6 @@ void purple_roomlist_cancel_get_list(Pur
void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category)
{
- PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc;
@@ -260,10 +251,7 @@ void purple_roomlist_expand_category(Pur
g_return_if_fail(gc != NULL);
if(gc)
- prpl = purple_connection_get_protocol_info(gc);
-
- if(prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if(prpl_info && prpl_info->roomlist_expand_category)
prpl_info->roomlist_expand_category(list, category);
diff --git a/libpurple/server.c b/libpurple/server.c
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -43,12 +43,10 @@
unsigned int
serv_send_typing(PurpleConnection *gc, const char *name, PurpleIMTypingState state)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->send_typing)
return prpl_info->send_typing(gc, name, state);
@@ -122,18 +120,15 @@ int serv_send_im(PurpleConnection *gc, c
PurpleIMConversation *im = NULL;
PurpleAccount *account = NULL;
PurplePresence *presence = NULL;
- PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
int val = -EINVAL;
const gchar *auto_reply_pref = NULL;
g_return_val_if_fail(gc != NULL, val);
- prpl = purple_connection_get_protocol_info(gc);
+ prpl_info = purple_connection_get_protocol_info(gc);
- g_return_val_if_fail(prpl != NULL, val);
-
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ g_return_val_if_fail(prpl_info != NULL, val);
account = purple_connection_get_account(gc);
presence = purple_account_get_presence(account);
@@ -165,12 +160,10 @@ int serv_send_im(PurpleConnection *gc, c
void serv_get_info(PurpleConnection *gc, const char *name)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->get_info)
prpl_info->get_info(gc, name);
@@ -179,13 +172,11 @@ void serv_get_info(PurpleConnection *gc,
void serv_set_info(PurpleConnection *gc, const char *info)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
PurpleAccount *account;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->set_info) {
account = purple_connection_get_account(gc);
@@ -209,7 +200,6 @@ void serv_alias_buddy(PurpleBuddy *b)
{
PurpleAccount *account;
PurpleConnection *gc;
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (b) {
@@ -219,8 +209,7 @@ void serv_alias_buddy(PurpleBuddy *b)
gc = purple_account_get_connection(account);
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->alias_buddy)
prpl_info->alias_buddy(gc,
@@ -302,16 +291,16 @@ purple_serv_got_private_alias(PurpleConn
PurpleAttentionType *purple_get_attention_type_from_code(PurpleAccount *account, guint type_code)
{
- PurplePlugin *prpl;
+ PurplePluginProtocolInfo *prpl_info;
PurpleAttentionType* attn;
GList *(*get_attention_types)(PurpleAccount *);
g_return_val_if_fail(account != NULL, NULL);
- prpl = purple_find_protocol_info(purple_account_get_protocol_id(account));
+ prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account));
/* Lookup the attention type in the protocol's attention_types list, if any. */
- get_attention_types = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->get_attention_types;
+ get_attention_types = prpl_info->get_attention_types;
if (get_attention_types) {
GList *attention_types;
@@ -336,7 +325,6 @@ void serv_move_buddy(PurpleBuddy *b, Pur
{
PurpleAccount *account;
PurpleConnection *gc;
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
g_return_if_fail(b != NULL);
@@ -347,8 +335,7 @@ void serv_move_buddy(PurpleBuddy *b, Pur
gc = purple_account_get_connection(account);
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->group_buddy)
prpl_info->group_buddy(gc, purple_buddy_get_name(b),
@@ -359,12 +346,10 @@ void serv_move_buddy(PurpleBuddy *b, Pur
void serv_add_permit(PurpleConnection *gc, const char *name)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->add_permit)
prpl_info->add_permit(gc, name);
@@ -373,12 +358,10 @@ void serv_add_permit(PurpleConnection *g
void serv_add_deny(PurpleConnection *gc, const char *name)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->add_deny)
prpl_info->add_deny(gc, name);
@@ -387,12 +370,10 @@ void serv_add_deny(PurpleConnection *gc,
void serv_rem_permit(PurpleConnection *gc, const char *name)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->rem_permit)
prpl_info->rem_permit(gc, name);
@@ -401,12 +382,10 @@ void serv_rem_permit(PurpleConnection *g
void serv_rem_deny(PurpleConnection *gc, const char *name)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->rem_deny)
prpl_info->rem_deny(gc, name);
@@ -415,12 +394,10 @@ void serv_rem_deny(PurpleConnection *gc,
void serv_set_permit_deny(PurpleConnection *gc)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
/*
* this is called when either you import a buddy list, and make lots
@@ -435,12 +412,10 @@ void serv_set_permit_deny(PurpleConnecti
void serv_join_chat(PurpleConnection *gc, GHashTable *data)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->join_chat)
prpl_info->join_chat(gc, data);
@@ -450,12 +425,10 @@ void serv_join_chat(PurpleConnection *gc
void serv_reject_chat(PurpleConnection *gc, GHashTable *data)
{
- PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
if (gc) {
- prpl = purple_connection_get_protocol_info(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info->reject_chat)
prpl_info->reject_chat(gc, data);
@@ -464,7 +437,6 @@ void serv_reject_chat(PurpleConnection *
void serv_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name)
{
- PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleChatConversation *chat;
char *buffy = message && *message ? g_strdup(message) : NULL;
@@ -475,10 +447,7 @@ void serv_chat_invite(PurpleConnection *
return;
if(gc)
- prpl = purple_connection_get_protocol_info(gc);
-
- if(prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ prpl_info = purple_connection_get_protocol_info(gc);
More information about the Commits
mailing list