/soc/2013/ankitkv/gobjectification: 66018273528a: Refactored bon...

Ankit Vani a at nevitus.org
Sun Sep 15 10:14:02 EDT 2013


Changeset: 66018273528a7aff524d4c4e7ffe37ebf445a133
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-15 19:09 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/66018273528a

Description:

Refactored bonjour, gg, irc to use the new protocol interfaces

diffstat:

 libpurple/protocols/bonjour/bonjour.c |  53 +++++++++++++++-----
 libpurple/protocols/gg/gg.c           |  77 ++++++++++++++++++++++--------
 libpurple/protocols/irc/irc.c         |  87 +++++++++++++++++++++++++---------
 3 files changed, 158 insertions(+), 59 deletions(-)

diffs (297 lines):

diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -664,35 +664,60 @@ bonjour_protocol_init(PurpleProtocol *pr
 static void
 bonjour_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login            = bonjour_login;
+	klass->close_connection = bonjour_close;
+	klass->status_types     = bonjour_status_types;
+	klass->list_icon        = bonjour_list_icon;
 }
 
 static void
 bonjour_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
-	client_iface->list_icon            = bonjour_list_icon;
 	client_iface->status_text          = bonjour_status_text;
 	client_iface->tooltip_text         = bonjour_tooltip_text;
-	client_iface->status_types         = bonjour_status_types;
-	client_iface->login                = bonjour_login;
-	client_iface->close                = bonjour_close;
-	client_iface->send_im              = bonjour_send_im;
-	client_iface->set_status           = bonjour_set_status;
-	client_iface->add_buddy            = bonjour_fake_add_buddy;
-	client_iface->remove_buddy         = bonjour_remove_buddy;
-	client_iface->group_buddy          = bonjour_group_buddy;
-	client_iface->rename_group         = bonjour_rename_group;
 	client_iface->convo_closed         = bonjour_convo_closed;
-	client_iface->set_buddy_icon       = bonjour_set_buddy_icon;
-	client_iface->can_receive_file     = bonjour_can_receive_file;
-	client_iface->send_file            = bonjour_send_file;
-	client_iface->new_xfer             = bonjour_new_xfer;
 	client_iface->get_max_message_size = bonjour_get_max_message_size;
 }
 
+static void
+bonjour_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+	server_iface->add_buddy      = bonjour_fake_add_buddy;
+	server_iface->remove_buddy   = bonjour_remove_buddy;
+	server_iface->group_buddy    = bonjour_group_buddy;
+	server_iface->rename_group   = bonjour_rename_group;
+	server_iface->set_buddy_icon = bonjour_set_buddy_icon;
+	server_iface->set_status     = bonjour_set_status;
+}
+
+static void
+bonjour_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+	im_iface->send = bonjour_send_im;
+}
+
+static void
+bonjour_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+	xfer_iface->can_receive = bonjour_can_receive_file;
+	xfer_iface->send        = bonjour_send_file;
+	xfer_iface->new_xfer    = bonjour_new_xfer;
+}
+
 PURPLE_DEFINE_TYPE_EXTENDED(
 	BonjourProtocol, bonjour_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
 		                              bonjour_protocol_client_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+		                              bonjour_protocol_server_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+		                              bonjour_protocol_im_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+		                              bonjour_protocol_xfer_iface_init)
 );
 
 static PurplePluginInfo *
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -1445,49 +1445,82 @@ ggp_protocol_init(PurpleProtocol *protoc
 static void
 ggp_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login            = ggp_login;
+	klass->close_connection = ggp_close;
+	klass->status_types     = ggp_status_types;
+	klass->list_icon        = ggp_list_icon;
 }
 
 static void
 ggp_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
 	client_iface->get_actions            = ggp_get_actions;
-	client_iface->list_icon              = ggp_list_icon;
 	client_iface->list_emblem            = ggp_list_emblem;
 	client_iface->status_text            = ggp_status_buddy_text;
 	client_iface->tooltip_text           = ggp_tooltip_text;
-	client_iface->status_types           = ggp_status_types;
 	client_iface->blist_node_menu        = ggp_blist_node_menu;
-	client_iface->chat_info              = ggp_chat_info;
-	client_iface->login                  = ggp_login;
-	client_iface->close                  = ggp_close;
-	client_iface->send_im                = ggp_send_im;
-	client_iface->send_typing            = ggp_send_typing;
-	client_iface->get_info               = ggp_pubdir_get_info_protocol;
-	client_iface->set_status             = ggp_status_set_purplestatus;
-	client_iface->add_buddy              = ggp_add_buddy;
-	client_iface->remove_buddy           = ggp_remove_buddy;
-	client_iface->add_deny               = ggp_add_deny;
-	client_iface->rem_deny               = ggp_rem_deny;
-	client_iface->join_chat              = ggp_join_chat;
-	client_iface->get_chat_name          = ggp_get_chat_name;
-	client_iface->chat_send              = ggp_chat_send;
-	client_iface->keepalive              = ggp_keepalive;
-	client_iface->register_user          = ggp_account_register;
-	client_iface->alias_buddy            = ggp_roster_alias_buddy;
-	client_iface->group_buddy            = ggp_roster_group_buddy;
-	client_iface->rename_group           = ggp_roster_rename_group;
 	client_iface->buddy_free             = ggp_buddy_free;
 	client_iface->normalize              = ggp_normalize;
-	client_iface->set_buddy_icon         = ggp_avatar_own_set;
 	client_iface->offline_message        = ggp_offline_message;
 	client_iface->get_account_text_table = ggp_get_account_text_table;
 	client_iface->get_max_message_size   = ggp_get_max_message_size;
 }
 
+static void
+ggp_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+	server_iface->register_user  = ggp_account_register;
+	server_iface->get_info       = ggp_pubdir_get_info_protocol;
+	server_iface->set_status     = ggp_status_set_purplestatus;
+	server_iface->add_buddy      = ggp_add_buddy;
+	server_iface->remove_buddy   = ggp_remove_buddy;
+	server_iface->keepalive      = ggp_keepalive;
+	server_iface->alias_buddy    = ggp_roster_alias_buddy;
+	server_iface->group_buddy    = ggp_roster_group_buddy;
+	server_iface->rename_group   = ggp_roster_rename_group;
+	server_iface->set_buddy_icon = ggp_avatar_own_set;
+}
+
+static void
+ggp_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+	im_iface->send        = ggp_send_im;
+	im_iface->send_typing = ggp_send_typing;
+}
+
+static void
+ggp_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+	chat_iface->info     = ggp_chat_info;
+	chat_iface->join     = ggp_join_chat;
+	chat_iface->get_name = ggp_get_chat_name;
+	chat_iface->send     = ggp_chat_send;
+}
+
+static void
+ggp_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
+{
+	privacy_iface->add_deny = ggp_add_deny;
+	privacy_iface->rem_deny = ggp_rem_deny;
+}
+
 PURPLE_DEFINE_TYPE_EXTENDED(
 	GGPProtocol, ggp_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
 		                              ggp_protocol_client_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+		                              ggp_protocol_server_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+		                              ggp_protocol_im_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+		                              ggp_protocol_chat_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
+		                              ggp_protocol_privacy_iface_init)
 );
 
 static PurplePluginInfo *
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -974,43 +974,84 @@ irc_protocol_init(PurpleProtocol *protoc
 static void
 irc_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login            = irc_login;
+	klass->close_connection = irc_close;
+	klass->status_types     = irc_status_types;
+	klass->list_icon        = irc_blist_icon;
 }
 
 static void
 irc_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
 	client_iface->get_actions          = irc_get_actions;
-	client_iface->list_icon            = irc_blist_icon;
-	client_iface->status_types         = irc_status_types;
-	client_iface->chat_info            = irc_chat_join_info;
-	client_iface->chat_info_defaults   = irc_chat_info_defaults;
-	client_iface->login                = irc_login;
-	client_iface->close                = irc_close;
-	client_iface->send_im              = irc_im_send;
-	client_iface->get_info             = irc_get_info;
-	client_iface->set_status           = irc_set_status;
-	client_iface->add_buddy            = irc_add_buddy;
-	client_iface->remove_buddy         = irc_remove_buddy;
-	client_iface->join_chat            = irc_chat_join;
-	client_iface->get_chat_name        = irc_get_chat_name;
-	client_iface->chat_invite          = irc_chat_invite;
-	client_iface->chat_leave           = irc_chat_leave;
-	client_iface->chat_send            = irc_chat_send;
-	client_iface->keepalive            = irc_keepalive;
 	client_iface->normalize            = purple_normalize_nocase;
-	client_iface->set_chat_topic       = irc_chat_set_topic;
-	client_iface->roomlist_get_list    = irc_roomlist_get_list;
-	client_iface->roomlist_cancel      = irc_roomlist_cancel;
-	client_iface->send_file            = irc_dccsend_send_file;
-	client_iface->new_xfer             = irc_dccsend_new_xfer;
-	client_iface->send_raw             = irc_send_raw;
 	client_iface->get_max_message_size = irc_get_max_message_size;
 }
 
+static void
+irc_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+	server_iface->set_status   = irc_set_status;
+	server_iface->get_info     = irc_get_info;
+	server_iface->add_buddy    = irc_add_buddy;
+	server_iface->remove_buddy = irc_remove_buddy;
+	server_iface->keepalive    = irc_keepalive;
+	server_iface->send_raw     = irc_send_raw;
+}
+
+static void
+irc_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+	im_iface->send = irc_im_send;
+}
+
+static void
+irc_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+	chat_iface->info          = irc_chat_join_info;
+	chat_iface->info_defaults = irc_chat_info_defaults;
+	chat_iface->join          = irc_chat_join;
+	chat_iface->get_name      = irc_get_chat_name;
+	chat_iface->invite        = irc_chat_invite;
+	chat_iface->leave         = irc_chat_leave;
+	chat_iface->send          = irc_chat_send;
+	chat_iface->set_topic     = irc_chat_set_topic;
+}
+
+static void
+irc_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface)
+{
+	roomlist_iface->get_list = irc_roomlist_get_list;
+	roomlist_iface->cancel   = irc_roomlist_cancel;
+}
+
+static void
+irc_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+	xfer_iface->send     = irc_dccsend_send_file;
+	xfer_iface->new_xfer = irc_dccsend_new_xfer;
+}
+
 PURPLE_DEFINE_TYPE_EXTENDED(
 	IRCProtocol, irc_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
 		                              irc_protocol_client_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+		                              irc_protocol_server_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+		                              irc_protocol_im_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+		                              irc_protocol_chat_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
+		                              irc_protocol_roomlist_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+		                              irc_protocol_xfer_iface_init)
 );
 
 static PurplePluginInfo *



More information about the Commits mailing list