/soc/2013/ankitkv/gobjectification: ed3ee92d5092: Refactored msn...

Ankit Vani a at nevitus.org
Sun Sep 15 14:21:53 EDT 2013


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

Description:

Refactored msn, mxit, myspace, novell to use the new protocol interfaces

diffstat:

 libpurple/protocols/msn/msn.c         |  115 +++++++++++++++++++++++---------
 libpurple/protocols/mxit/mxit.c       |  120 ++++++++++++++++++++++-----------
 libpurple/protocols/myspace/myspace.c |   73 ++++++++++++++-----
 libpurple/protocols/novell/novell.c   |   83 ++++++++++++++++-------
 4 files changed, 272 insertions(+), 119 deletions(-)

diffs (truncated from 515 to 300 lines):

diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2922,59 +2922,108 @@ msn_protocol_init(PurpleProtocol *protoc
 static void
 msn_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login        = msn_login;
+	klass->close        = msn_close;
+	klass->status_types = msn_status_types;
+	klass->list_icon    = msn_list_icon;
 }
 
 static void
 msn_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
 	client_iface->get_actions            = msn_get_actions;
-	client_iface->list_icon              = msn_list_icon;
 	client_iface->list_emblem            = msn_list_emblems;
 	client_iface->status_text            = msn_status_text;
 	client_iface->tooltip_text           = msn_tooltip_text;
-	client_iface->status_types           = msn_status_types;
 	client_iface->blist_node_menu        = msn_blist_node_menu;
-	client_iface->login                  = msn_login;
-	client_iface->close                  = msn_close;
-	client_iface->send_im                = msn_send_im;
-	client_iface->send_typing            = msn_send_typing;
-	client_iface->get_info               = msn_get_info;
-	client_iface->set_status             = msn_set_status;
-	client_iface->set_idle               = msn_set_idle;
-	client_iface->add_buddy              = msn_add_buddy;
-	client_iface->remove_buddy           = msn_rem_buddy;
-	client_iface->add_permit             = msn_add_permit;
-	client_iface->add_deny               = msn_add_deny;
-	client_iface->rem_permit             = msn_rem_permit;
-	client_iface->rem_deny               = msn_rem_deny;
-	client_iface->set_permit_deny        = msn_set_permit_deny;
-	client_iface->chat_invite            = msn_chat_invite;
-	client_iface->chat_leave             = msn_chat_leave;
-	client_iface->chat_send              = msn_chat_send;
-	client_iface->keepalive              = msn_keepalive;
-	client_iface->alias_buddy            = msn_alias_buddy;
-	client_iface->group_buddy            = msn_group_buddy;
-	client_iface->rename_group           = msn_rename_group;
 	client_iface->convo_closed           = msn_convo_closed;
 	client_iface->normalize              = msn_normalize;
-	client_iface->set_buddy_icon         = msn_set_buddy_icon;
-	client_iface->remove_group           = msn_remove_group;
-	client_iface->can_receive_file       = msn_can_receive_file;
-	client_iface->send_file              = msn_send_file;
-	client_iface->new_xfer               = msn_new_xfer;
 	client_iface->offline_message        = msn_offline_message;
-	client_iface->send_attention         = msn_send_attention;
-	client_iface->get_attention_types    = msn_attention_types;
 	client_iface->get_account_text_table = msn_get_account_text_table;
-	client_iface->set_public_alias       = msn_set_public_alias;
-	client_iface->get_public_alias       = msn_get_public_alias;
 	client_iface->get_max_message_size   = msn_get_max_message_size;
 }
 
+static void
+msn_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+	server_iface->get_info         = msn_get_info;
+	server_iface->set_status       = msn_set_status;
+	server_iface->set_idle         = msn_set_idle;
+	server_iface->add_buddy        = msn_add_buddy;
+	server_iface->remove_buddy     = msn_rem_buddy;
+	server_iface->keepalive        = msn_keepalive;
+	server_iface->alias_buddy      = msn_alias_buddy;
+	server_iface->group_buddy      = msn_group_buddy;
+	server_iface->rename_group     = msn_rename_group;
+	server_iface->set_buddy_icon   = msn_set_buddy_icon;
+	server_iface->remove_group     = msn_remove_group;
+	server_iface->set_public_alias = msn_set_public_alias;
+	server_iface->get_public_alias = msn_get_public_alias;
+}
+
+static void
+msn_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+	im_iface->send        = msn_send_im;
+	im_iface->send_typing = msn_send_typing;
+}
+
+static void
+msn_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+	chat_iface->invite = msn_chat_invite;
+	chat_iface->leave  = msn_chat_leave;
+	chat_iface->send   = msn_chat_send;
+}
+
+static void
+msn_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
+{
+	privacy_iface->add_permit      = msn_add_permit;
+	privacy_iface->add_deny        = msn_add_deny;
+	privacy_iface->rem_permit      = msn_rem_permit;
+	privacy_iface->rem_deny        = msn_rem_deny;
+	privacy_iface->set_permit_deny = msn_set_permit_deny;
+}
+
+static void
+msn_protocol_attention_iface_init(PurpleProtocolAttentionIface *attention_iface)
+{
+	attention_iface->send      = msn_send_attention;
+	attention_iface->get_types = msn_attention_types;
+}
+
+static void
+msn_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+	xfer_iface->can_receive = msn_can_receive_file;
+	xfer_iface->send        = msn_send_file;
+	xfer_iface->new_xfer    = msn_new_xfer;
+}
+
 PURPLE_DEFINE_TYPE_EXTENDED(
 	MsnProtocol, msn_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
-		                              msn_protocol_client_iface_init)
+	                                  msn_protocol_client_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+	                                  msn_protocol_server_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+	                                  msn_protocol_im_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+	                                  msn_protocol_chat_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
+	                                  msn_protocol_privacy_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE,
+	                                  msn_protocol_attention_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+	                                  msn_protocol_xfer_iface_init)
 );
 
 static PurplePluginInfo *
diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -757,72 +757,112 @@ mxit_protocol_init( PurpleProtocol *prot
 
 
 /*------------------------------------------------------------------------
- * Initializing the MXit class.
- *
- *  @param klass	The MXit class
- */
+ * Initializing the MXit class and interfaces.                          */
+
+
 static void
 mxit_protocol_class_init( PurpleProtocolClass *klass )
 {
+	klass->login        = mxit_login;			/* [login.c] */
+	klass->close        = mxit_close;
+	klass->status_types = mxit_status_types;	/* [roster.c] */
+	klass->list_icon    = mxit_list_icon;
 }
 
 
-/*------------------------------------------------------------------------
- * Initializing the MXit protocol interface.
- *
- *  @param iface	The protocol interface
- */
 static void
 mxit_protocol_client_iface_init( PurpleProtocolClientIface *client_iface )
 {
 	client_iface->get_actions            = mxit_get_actions;	/* [actions.c] */
-	client_iface->list_icon              = mxit_list_icon;
 	client_iface->list_emblem            = mxit_list_emblem;
 	client_iface->status_text            = mxit_status_text;
 	client_iface->tooltip_text           = mxit_tooltip;
-	client_iface->status_types           = mxit_status_types;	/* [roster.c] */
 	client_iface->blist_node_menu        = mxit_blist_menu;
-	client_iface->chat_info              = mxit_chat_info;		/* [multimx.c] */
-	client_iface->chat_info_defaults     = mxit_chat_info_defaults;
-	client_iface->login                  = mxit_login;			/* [login.c] */
-	client_iface->close                  = mxit_close;
-	client_iface->send_im                = mxit_send_im;
-	client_iface->send_typing            = mxit_send_typing;
-	client_iface->get_info               = mxit_get_info;
-	client_iface->set_status             = mxit_set_status;
-	client_iface->add_buddy              = mxit_add_buddy;		/* [roster.c] */
-	client_iface->remove_buddy           = mxit_remove_buddy;	/* [roster.c] */
-	client_iface->join_chat              = mxit_chat_join;		/* [multimx.c] */
-	client_iface->reject_chat            = mxit_chat_reject;	/* [multimx.c] */
-	client_iface->get_chat_name          = mxit_chat_name;		/* [multimx.c] */
-	client_iface->chat_invite            = mxit_chat_invite;	/* [multimx.c] */
-	client_iface->chat_leave             = mxit_chat_leave;	/* [multimx.c] */
-	client_iface->chat_send              = mxit_chat_send;		/* [multimx.c] */
-	client_iface->keepalive              = mxit_keepalive;
-	client_iface->register_user          = mxit_register;
-	client_iface->alias_buddy            = mxit_buddy_alias;	/* [roster.c] */
-	client_iface->group_buddy            = mxit_buddy_group;	/* [roster.c] */
-	client_iface->rename_group           = mxit_rename_group;	/* [roster.c] */
 	client_iface->buddy_free             = mxit_free_buddy;
-	client_iface->set_buddy_icon         = mxit_set_buddy_icon;
-	client_iface->can_receive_file       = mxit_xfer_enabled;	/* [filexfer.c] */
-	client_iface->send_file              = mxit_xfer_tx;		/* [filexfer.c] */
-	client_iface->new_xfer               = mxit_xfer_new;		/* [filexfer.c] */
 	client_iface->offline_message        = mxit_offline_message;
 	client_iface->get_account_text_table = mxit_get_text_table;
-	client_iface->initiate_media         = mxit_media_initiate;
-	client_iface->get_media_caps         = mxit_media_caps;
 	client_iface->get_moods              = mxit_get_moods;
+}
+
+
+static void
+mxit_protocol_server_iface_init( PurpleProtocolServerIface *server_iface )
+{
+	server_iface->register_user  = mxit_register;
+	server_iface->get_info       = mxit_get_info;
+	server_iface->set_status     = mxit_set_status;
+	server_iface->add_buddy      = mxit_add_buddy;		/* [roster.c] */
+	server_iface->remove_buddy   = mxit_remove_buddy;	/* [roster.c] */
+	server_iface->keepalive      = mxit_keepalive;
+	server_iface->alias_buddy    = mxit_buddy_alias;	/* [roster.c] */
+	server_iface->group_buddy    = mxit_buddy_group;	/* [roster.c] */
+	server_iface->rename_group   = mxit_rename_group;	/* [roster.c] */
+	server_iface->set_buddy_icon = mxit_set_buddy_icon;
 
 	/* TODO: Add function to move all contacts out of this group (cmd=30 - remove group)? */
-	client_iface->remove_group       = NULL;
+	server_iface->remove_group       = NULL;
+}
+
+
+static void
+mxit_protocol_im_iface_init( PurpleProtocolIMIface *im_iface )
+{
+	im_iface->send        = mxit_send_im;
+	im_iface->send_typing = mxit_send_typing;
+}
+
+
+static void
+mxit_protocol_chat_iface_init( PurpleProtocolChatIface *chat_iface )
+{
+	chat_iface->info          = mxit_chat_info;		/* [multimx.c] */
+	chat_iface->info_defaults = mxit_chat_info_defaults;
+	chat_iface->join          = mxit_chat_join;		/* [multimx.c] */
+	chat_iface->reject        = mxit_chat_reject;	/* [multimx.c] */
+	chat_iface->get_name      = mxit_chat_name;		/* [multimx.c] */
+	chat_iface->invite        = mxit_chat_invite;	/* [multimx.c] */
+	chat_iface->leave         = mxit_chat_leave;	/* [multimx.c] */
+	chat_iface->send          = mxit_chat_send;		/* [multimx.c] */
+}
+
+
+static void
+mxit_protocol_media_iface_init( PurpleProtocolMediaIface *media_iface )
+{
+	media_iface->initiate_session = mxit_media_initiate;
+	media_iface->get_caps         = mxit_media_caps;
+}
+
+
+static void
+mxit_protocol_xfer_iface_init( PurpleProtocolXferIface *xfer_iface )
+{
+	xfer_iface->can_receive = mxit_xfer_enabled;	/* [filexfer.c] */
+	xfer_iface->send        = mxit_xfer_tx;		/* [filexfer.c] */
+	xfer_iface->new_xfer    = mxit_xfer_new;		/* [filexfer.c] */
 }
 
 
 PURPLE_DEFINE_TYPE_EXTENDED(
 	MXitProtocol, mxit_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
-		                              mxit_protocol_client_iface_init )
+	                                   mxit_protocol_client_iface_init )
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+	                                   mxit_protocol_server_iface_init )
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_IM_IFACE,
+	                                   mxit_protocol_im_iface_init )
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+	                                   mxit_protocol_chat_iface_init )
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_MEDIA_IFACE,
+	                                   mxit_protocol_media_iface_init )
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+	                                   mxit_protocol_xfer_iface_init )
 );
 



More information about the Commits mailing list