/soc/2013/ankitkv/gobjectification: 39a42632a4c8: Refactored jab...
Ankit Vani
a at nevitus.org
Sun Sep 15 10:14:03 EDT 2013
Changeset: 39a42632a4c8824447dc401e1e51c805d3f11c82
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-15 19:41 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/39a42632a4c8
Description:
Refactored jabber to use the new protocol interfaces
diffstat:
libpurple/protocols/jabber/facebook.c | 79 +++++++++++----
libpurple/protocols/jabber/gtalk.c | 14 +-
libpurple/protocols/jabber/jabber.c | 169 +++++++++++++++++++++++----------
3 files changed, 183 insertions(+), 79 deletions(-)
diffs (truncated from 318 to 300 lines):
diff --git a/libpurple/protocols/jabber/facebook.c b/libpurple/protocols/jabber/facebook.c
--- a/libpurple/protocols/jabber/facebook.c
+++ b/libpurple/protocols/jabber/facebook.c
@@ -104,35 +104,74 @@ facebook_protocol_init(PurpleProtocol *p
static void
facebook_protocol_class_init(PurpleProtocolClass *klass)
{
+ klass->list_icon = facebook_list_icon;
}
static void
facebook_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
{
- client_iface->list_icon = facebook_list_icon;
+ client_iface->get_moods = NULL;
+}
- /* disable xmpp functions not available for facebook */
- client_iface->add_buddy = NULL;
- client_iface->remove_buddy = NULL;
- client_iface->add_deny = NULL;
- client_iface->rem_deny = NULL;
- client_iface->register_user = NULL;
- client_iface->alias_buddy = NULL;
- client_iface->group_buddy = NULL;
- client_iface->rename_group = NULL;
- client_iface->can_receive_file = NULL;
- client_iface->send_file = NULL;
- client_iface->new_xfer = NULL;
- client_iface->unregister_user = NULL;
- client_iface->send_attention = NULL;
- client_iface->get_attention_types = NULL;
- client_iface->initiate_media = NULL;
- client_iface->get_media_caps = NULL;
- client_iface->get_moods = NULL;
+static void
+facebook_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+ server_iface->register_user = NULL;
+ server_iface->unregister_user = NULL;
+ server_iface->add_buddy = NULL;
+ server_iface->remove_buddy = NULL;
+ server_iface->alias_buddy = NULL;
+ server_iface->group_buddy = NULL;
+ server_iface->rename_group = NULL;
+}
+
+static void
+facebook_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
+{
+ privacy_iface->add_deny = NULL;
+ privacy_iface->rem_deny = NULL;
+}
+
+static void
+facebook_protocol_attention_iface_init(PurpleProtocolAttentionIface *attention_iface)
+{
+ attention_iface->send = NULL;
+ attention_iface->get_types = NULL;
+}
+
+static void
+facebook_protocol_media_iface_init(PurpleProtocolMediaIface *media_iface)
+{
+ media_iface->initiate_session = NULL;
+ media_iface->get_caps = NULL;
+}
+
+static void
+facebook_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+ xfer_iface->can_receive = NULL;
+ xfer_iface->send = NULL;
+ xfer_iface->new_xfer = NULL;
}
PURPLE_DEFINE_TYPE_EXTENDED(
FacebookProtocol, facebook_protocol, JABBER_TYPE_PROTOCOL, 0,
+
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
- facebook_protocol_client_iface_init)
+ facebook_protocol_client_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+ facebook_protocol_server_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
+ facebook_protocol_privacy_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE,
+ facebook_protocol_attention_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_MEDIA_IFACE,
+ facebook_protocol_media_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ facebook_protocol_xfer_iface_init)
);
diff --git a/libpurple/protocols/jabber/gtalk.c b/libpurple/protocols/jabber/gtalk.c
--- a/libpurple/protocols/jabber/gtalk.c
+++ b/libpurple/protocols/jabber/gtalk.c
@@ -112,20 +112,20 @@ gtalk_protocol_init(PurpleProtocol *prot
static void
gtalk_protocol_class_init(PurpleProtocolClass *klass)
{
+ klass->list_icon = gtalk_list_icon;
}
static void
-gtalk_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
+gtalk_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
{
- client_iface->list_icon = gtalk_list_icon;
-
/* disable xmpp functions not available for gtalk */
- client_iface->register_user = NULL;
- client_iface->unregister_user = NULL;
+ server_iface->register_user = NULL;
+ server_iface->unregister_user = NULL;
}
PURPLE_DEFINE_TYPE_EXTENDED(
GTalkProtocol, gtalk_protocol, JABBER_TYPE_PROTOCOL, 0,
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
- gtalk_protocol_client_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+ gtalk_protocol_server_iface_init)
);
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
@@ -4151,68 +4151,133 @@ jabber_protocol_init(PurpleProtocol *pro
static void
jabber_protocol_class_init(PurpleProtocolClass *klass)
{
+ klass->login = jabber_login;
+ klass->close = jabber_close;
+ klass->status_types = jabber_status_types;
+ klass->list_icon = jabber_list_icon;
}
static void
jabber_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
{
- client_iface->get_actions = jabber_get_actions;
- client_iface->list_icon = jabber_list_icon;
- client_iface->list_emblem = jabber_list_emblem;
- client_iface->status_text = jabber_status_text;
- client_iface->tooltip_text = jabber_tooltip_text;
- client_iface->status_types = jabber_status_types;
- client_iface->blist_node_menu = jabber_blist_node_menu;
- client_iface->chat_info = jabber_chat_info;
- client_iface->chat_info_defaults = jabber_chat_info_defaults;
- client_iface->login = jabber_login;
- client_iface->close = jabber_close;
- client_iface->send_im = jabber_message_send_im;
- client_iface->set_info = jabber_set_info;
- client_iface->send_typing = jabber_send_typing;
- client_iface->get_info = jabber_buddy_get_info;
- client_iface->set_status = jabber_set_status;
- client_iface->set_idle = jabber_idle_set;
- client_iface->add_buddy = jabber_roster_add_buddy;
- client_iface->remove_buddy = jabber_roster_remove_buddy;
- client_iface->add_deny = jabber_add_deny;
- client_iface->rem_deny = jabber_rem_deny;
- client_iface->join_chat = jabber_chat_join;
- client_iface->get_chat_name = jabber_get_chat_name;
- client_iface->chat_invite = jabber_chat_invite;
- client_iface->chat_leave = jabber_chat_leave;
- client_iface->chat_send = jabber_message_send_chat;
- client_iface->keepalive = jabber_keepalive;
- client_iface->register_user = jabber_register_account;
- client_iface->unregister_user = jabber_unregister_account;
- client_iface->alias_buddy = jabber_roster_alias_change;
- client_iface->group_buddy = jabber_roster_group_change;
- client_iface->rename_group = jabber_roster_group_rename;
- client_iface->convo_closed = jabber_convo_closed;
- client_iface->normalize = jabber_normalize;
- client_iface->set_buddy_icon = jabber_set_buddy_icon;
- client_iface->get_cuser_real_name = jabber_chat_user_real_name;
- client_iface->set_chat_topic = jabber_chat_set_topic;
- client_iface->find_blist_chat = jabber_find_blist_chat;
- client_iface->roomlist_get_list = jabber_roomlist_get_list;
- client_iface->roomlist_cancel = jabber_roomlist_cancel;
- client_iface->can_receive_file = jabber_can_receive_file;
- client_iface->send_file = jabber_si_xfer_send;
- client_iface->new_xfer = jabber_si_new_xfer;
- client_iface->offline_message = jabber_offline_message;
- client_iface->send_raw = jabber_protocol_send_raw;
- client_iface->roomlist_room_serialize = jabber_roomlist_room_serialize;
- client_iface->send_attention = jabber_send_attention;
- client_iface->get_attention_types = jabber_attention_types;
- client_iface->initiate_media = jabber_initiate_media;
- client_iface->get_media_caps = jabber_get_media_caps;
- client_iface->get_moods = jabber_get_moods;
+ client_iface->get_actions = jabber_get_actions;
+ client_iface->list_emblem = jabber_list_emblem;
+ client_iface->status_text = jabber_status_text;
+ client_iface->tooltip_text = jabber_tooltip_text;
+ client_iface->blist_node_menu = jabber_blist_node_menu;
+ client_iface->convo_closed = jabber_convo_closed;
+ client_iface->normalize = jabber_normalize;
+ client_iface->find_blist_chat = jabber_find_blist_chat;
+ client_iface->offline_message = jabber_offline_message;
+ client_iface->get_moods = jabber_get_moods;
+}
+
+static void
+jabber_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+ server_iface->register_user = jabber_register_account;
+ server_iface->unregister_user = jabber_unregister_account;
+ server_iface->set_info = jabber_set_info;
+ server_iface->get_info = jabber_buddy_get_info;
+ server_iface->set_status = jabber_set_status;
+ server_iface->set_idle = jabber_idle_set;
+ server_iface->add_buddy = jabber_roster_add_buddy;
+ server_iface->remove_buddy = jabber_roster_remove_buddy;
+ server_iface->keepalive = jabber_keepalive;
+ server_iface->alias_buddy = jabber_roster_alias_change;
+ server_iface->group_buddy = jabber_roster_group_change;
+ server_iface->rename_group = jabber_roster_group_rename;
+ server_iface->set_buddy_icon = jabber_set_buddy_icon;
+ server_iface->send_raw = jabber_protocol_send_raw;
+}
+
+static void
+jabber_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+ im_iface->send = jabber_message_send_im;
+ im_iface->send_typing = jabber_send_typing;
+}
+
+static void
+jabber_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+ chat_iface->info = jabber_chat_info;
+ chat_iface->info_defaults = jabber_chat_info_defaults;
+ chat_iface->join = jabber_chat_join;
+ chat_iface->get_name = jabber_get_chat_name;
+ chat_iface->invite = jabber_chat_invite;
+ chat_iface->leave = jabber_chat_leave;
+ chat_iface->send = jabber_message_send_chat;
+ chat_iface->get_user_real_name = jabber_chat_user_real_name;
+ chat_iface->set_topic = jabber_chat_set_topic;
+}
+
+static void
+jabber_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
+{
+ privacy_iface->add_deny = jabber_add_deny;
+ privacy_iface->rem_deny = jabber_rem_deny;
+}
+
+static void
+jabber_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface)
+{
+ roomlist_iface->get_list = jabber_roomlist_get_list;
+ roomlist_iface->cancel = jabber_roomlist_cancel;
+ roomlist_iface->room_serialize = jabber_roomlist_room_serialize;
+}
+
+static void
+jabber_protocol_attention_iface_init(PurpleProtocolAttentionIface *attention_iface)
+{
+ attention_iface->send = jabber_send_attention;
+ attention_iface->get_types = jabber_attention_types;
+}
+
+static void
+jabber_protocol_media_iface_init(PurpleProtocolMediaIface *media_iface)
+{
+ media_iface->initiate_session = jabber_initiate_media;
+ media_iface->get_caps = jabber_get_media_caps;
+}
+
+static void
+jabber_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+ xfer_iface->can_receive = jabber_can_receive_file;
+ xfer_iface->send = jabber_si_xfer_send;
+ xfer_iface->new_xfer = jabber_si_new_xfer;
}
PURPLE_DEFINE_TYPE_EXTENDED(
JabberProtocol, jabber_protocol, PURPLE_TYPE_PROTOCOL, G_TYPE_FLAG_ABSTRACT,
+
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
- jabber_protocol_client_iface_init)
+ jabber_protocol_client_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+ jabber_protocol_server_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+ jabber_protocol_im_iface_init)
+
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+ jabber_protocol_chat_iface_init)
More information about the Commits
mailing list