/soc/2013/ankitkv/gobjectification: 164cbd1113d4: Refactored sam...

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


Changeset: 164cbd1113d446fbe3e02778b20c7e8a969b23b0
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 00:32 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/164cbd1113d4

Description:

Refactored sametime, silc, simple to use the new protocol interfaces

diffstat:

 libpurple/protocols/sametime/sametime.c |  132 +++++++++++++++++++++----------
 libpurple/protocols/silc/silc.c         |  103 +++++++++++++++++-------
 libpurple/protocols/simple/simple.c     |   37 +++++---
 3 files changed, 184 insertions(+), 88 deletions(-)

diffs (truncated from 332 to 300 lines):

diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -5660,61 +5660,107 @@ mw_protocol_init(PurpleProtocol *protoco
 static void
 mw_protocol_class_init(PurpleProtocolClass *klass)
 {
+  klass->login        = mw_protocol_login;
+  klass->close        = mw_protocol_close;
+  klass->status_types = mw_protocol_status_types;
+  klass->list_icon    = mw_protocol_list_icon;
 }
 
 
 static void
 mw_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
-  client_iface->get_actions        = mw_protocol_get_actions;
-  client_iface->list_icon          = mw_protocol_list_icon;
-  client_iface->list_emblem        = mw_protocol_list_emblem;
-  client_iface->status_text        = mw_protocol_status_text;
-  client_iface->tooltip_text       = mw_protocol_tooltip_text;
-  client_iface->status_types       = mw_protocol_status_types;
-  client_iface->blist_node_menu    = mw_protocol_blist_node_menu;
-  client_iface->chat_info          = mw_protocol_chat_info;
-  client_iface->chat_info_defaults = mw_protocol_chat_info_defaults;
-  client_iface->login              = mw_protocol_login;
-  client_iface->close              = mw_protocol_close;
-  client_iface->send_im            = mw_protocol_send_im;
-  client_iface->send_typing        = mw_protocol_send_typing;
-  client_iface->get_info           = mw_protocol_get_info;
-  client_iface->set_status         = mw_protocol_set_status;
-  client_iface->set_idle           = mw_protocol_set_idle;
-  client_iface->add_buddy          = mw_protocol_add_buddy;
-  client_iface->add_buddies        = mw_protocol_add_buddies;
-  client_iface->remove_buddy       = mw_protocol_remove_buddy;
-  client_iface->add_permit         = mw_protocol_add_permit;
-  client_iface->add_deny           = mw_protocol_add_deny;
-  client_iface->rem_permit         = mw_protocol_rem_permit;
-  client_iface->rem_deny           = mw_protocol_rem_deny;
-  client_iface->set_permit_deny    = mw_protocol_set_permit_deny;
-  client_iface->join_chat          = mw_protocol_join_chat;
-  client_iface->reject_chat        = mw_protocol_reject_chat;
-  client_iface->get_chat_name      = mw_protocol_get_chat_name;
-  client_iface->chat_invite        = mw_protocol_chat_invite;
-  client_iface->chat_leave         = mw_protocol_chat_leave;
-  client_iface->chat_whisper       = mw_protocol_chat_whisper;
-  client_iface->chat_send          = mw_protocol_chat_send;
-  client_iface->keepalive          = mw_protocol_keepalive;
-  client_iface->alias_buddy        = mw_protocol_alias_buddy;
-  client_iface->group_buddy        = mw_protocol_group_buddy;
-  client_iface->rename_group       = mw_protocol_rename_group;
-  client_iface->buddy_free         = mw_protocol_buddy_free;
-  client_iface->convo_closed       = mw_protocol_convo_closed;
-  client_iface->normalize          = mw_protocol_normalize;
-  client_iface->remove_group       = mw_protocol_remove_group;
-  client_iface->can_receive_file   = mw_protocol_can_receive_file;
-  client_iface->send_file          = mw_protocol_send_file;
-  client_iface->new_xfer           = mw_protocol_new_xfer;
+  client_iface->get_actions     = mw_protocol_get_actions;
+  client_iface->list_emblem     = mw_protocol_list_emblem;
+  client_iface->status_text     = mw_protocol_status_text;
+  client_iface->tooltip_text    = mw_protocol_tooltip_text;
+  client_iface->blist_node_menu = mw_protocol_blist_node_menu;
+  client_iface->buddy_free      = mw_protocol_buddy_free;
+  client_iface->convo_closed    = mw_protocol_convo_closed;
+  client_iface->normalize       = mw_protocol_normalize;
+}
+
+
+static void
+mw_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+  server_iface->get_info     = mw_protocol_get_info;
+  server_iface->set_status   = mw_protocol_set_status;
+  server_iface->set_idle     = mw_protocol_set_idle;
+  server_iface->add_buddy    = mw_protocol_add_buddy;
+  server_iface->add_buddies  = mw_protocol_add_buddies;
+  server_iface->remove_buddy = mw_protocol_remove_buddy;
+  server_iface->keepalive    = mw_protocol_keepalive;
+  server_iface->alias_buddy  = mw_protocol_alias_buddy;
+  server_iface->group_buddy  = mw_protocol_group_buddy;
+  server_iface->rename_group = mw_protocol_rename_group;
+  server_iface->remove_group = mw_protocol_remove_group;
+}
+
+
+static void
+mw_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+  im_iface->send        = mw_protocol_send_im;
+  im_iface->send_typing = mw_protocol_send_typing;
+}
+
+
+static void
+mw_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+  chat_iface->info          = mw_protocol_chat_info;
+  chat_iface->info_defaults = mw_protocol_chat_info_defaults;
+  chat_iface->join          = mw_protocol_join_chat;
+  chat_iface->reject        = mw_protocol_reject_chat;
+  chat_iface->get_name      = mw_protocol_get_chat_name;
+  chat_iface->invite        = mw_protocol_chat_invite;
+  chat_iface->leave         = mw_protocol_chat_leave;
+  chat_iface->whisper       = mw_protocol_chat_whisper;
+  chat_iface->send          = mw_protocol_chat_send;
+}
+
+
+static void
+mw_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
+{
+  privacy_iface->add_permit      = mw_protocol_add_permit;
+  privacy_iface->add_deny        = mw_protocol_add_deny;
+  privacy_iface->rem_permit      = mw_protocol_rem_permit;
+  privacy_iface->rem_deny        = mw_protocol_rem_deny;
+  privacy_iface->set_permit_deny = mw_protocol_set_permit_deny;
+}
+
+
+static void
+mw_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+  xfer_iface->can_receive = mw_protocol_can_receive_file;
+  xfer_iface->send        = mw_protocol_send_file;
+  xfer_iface->new_xfer    = mw_protocol_new_xfer;
 }
 
 
 PURPLE_DEFINE_TYPE_EXTENDED(
   mwProtocol, mw_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
   PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
-  	                                mw_protocol_client_iface_init)
+                                    mw_protocol_client_iface_init)
+
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+                                    mw_protocol_server_iface_init)
+
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+                                    mw_protocol_im_iface_init)
+
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+                                    mw_protocol_chat_iface_init)
+
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
+                                    mw_protocol_privacy_iface_init)
+
+  PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+                                    mw_protocol_xfer_iface_init)
 );
 
 
diff --git a/libpurple/protocols/silc/silc.c b/libpurple/protocols/silc/silc.c
--- a/libpurple/protocols/silc/silc.c
+++ b/libpurple/protocols/silc/silc.c
@@ -2213,47 +2213,88 @@ silcpurple_protocol_init(PurpleProtocol 
 static void
 silcpurple_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login        = silcpurple_login;
+	klass->close        = silcpurple_close;
+	klass->status_types = silcpurple_away_states;
+	klass->list_icon    = silcpurple_list_icon;
 }
 
 static void
 silcpurple_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
 {
-	client_iface->get_actions        = silcpurple_get_actions;
-	client_iface->list_icon          = silcpurple_list_icon;
-	client_iface->status_text        = silcpurple_status_text;
-	client_iface->tooltip_text       = silcpurple_tooltip_text;
-	client_iface->status_types       = silcpurple_away_states;
-	client_iface->blist_node_menu    = silcpurple_blist_node_menu;
-	client_iface->chat_info          = silcpurple_chat_info;
-	client_iface->chat_info_defaults = silcpurple_chat_info_defaults;
-	client_iface->login              = silcpurple_login;
-	client_iface->close              = silcpurple_close;
-	client_iface->send_im            = silcpurple_send_im;
-	client_iface->set_info           = silcpurple_set_info;
-	client_iface->get_info           = silcpurple_get_info;
-	client_iface->set_status         = silcpurple_set_status;
-	client_iface->set_idle           = silcpurple_idle_set;
-	client_iface->change_passwd      = silcpurple_change_passwd;
-	client_iface->add_buddy          = silcpurple_add_buddy;
-	client_iface->remove_buddy       = silcpurple_remove_buddy;
-	client_iface->join_chat          = silcpurple_chat_join;
-	client_iface->get_chat_name      = silcpurple_get_chat_name;
-	client_iface->chat_invite        = silcpurple_chat_invite;
-	client_iface->chat_leave         = silcpurple_chat_leave;
-	client_iface->chat_send          = silcpurple_chat_send;
-	client_iface->keepalive          = silcpurple_keepalive;
-	client_iface->set_buddy_icon     = silcpurple_buddy_set_icon;
-	client_iface->set_chat_topic     = silcpurple_chat_set_topic;
-	client_iface->roomlist_get_list  = silcpurple_roomlist_get_list;
-	client_iface->roomlist_cancel    = silcpurple_roomlist_cancel;
-	client_iface->send_file          = silcpurple_ftp_send_file;
-	client_iface->new_xfer           = silcpurple_ftp_new_xfer;
+	client_iface->get_actions     = silcpurple_get_actions;
+	client_iface->status_text     = silcpurple_status_text;
+	client_iface->tooltip_text    = silcpurple_tooltip_text;
+	client_iface->blist_node_menu = silcpurple_blist_node_menu;
+}
+
+static void
+silcpurple_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
+{
+	server_iface->set_info       = silcpurple_set_info;
+	server_iface->get_info       = silcpurple_get_info;
+	server_iface->set_status     = silcpurple_set_status;
+	server_iface->set_idle       = silcpurple_idle_set;
+	server_iface->change_passwd  = silcpurple_change_passwd;
+	server_iface->add_buddy      = silcpurple_add_buddy;
+	server_iface->remove_buddy   = silcpurple_remove_buddy;
+	server_iface->keepalive      = silcpurple_keepalive;
+	server_iface->set_buddy_icon = silcpurple_buddy_set_icon;
+}
+
+static void
+silcpurple_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
+{
+	im_iface->send = silcpurple_send_im;
+}
+
+static void
+silcpurple_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface)
+{
+	chat_iface->info          = silcpurple_chat_info;
+	chat_iface->info_defaults = silcpurple_chat_info_defaults;
+	chat_iface->join          = silcpurple_chat_join;
+	chat_iface->get_name      = silcpurple_get_chat_name;
+	chat_iface->invite        = silcpurple_chat_invite;
+	chat_iface->leave         = silcpurple_chat_leave;
+	chat_iface->send          = silcpurple_chat_send;
+	chat_iface->set_topic     = silcpurple_chat_set_topic;
+}
+
+static void
+silcpurple_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface)
+{
+	roomlist_iface->get_list = silcpurple_roomlist_get_list;
+	roomlist_iface->cancel   = silcpurple_roomlist_cancel;
+}
+
+static void
+silcpurple_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+{
+	xfer_iface->send     = silcpurple_ftp_send_file;
+	xfer_iface->new_xfer = silcpurple_ftp_new_xfer;
 }
 
 PURPLE_DEFINE_TYPE_EXTENDED(
 	SilcProtocol, silcpurple_protocol, PURPLE_TYPE_PROTOCOL, 0,
+
 	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE,
-		                              silcpurple_protocol_client_iface_init)
+	                                  silcpurple_protocol_client_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE,
+	                                  silcpurple_protocol_server_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
+	                                  silcpurple_protocol_im_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE,
+	                                  silcpurple_protocol_chat_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
+	                                  silcpurple_protocol_roomlist_iface_init)
+
+	PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+	                                  silcpurple_protocol_xfer_iface_init)
 );
 
 static PurplePluginInfo *
diff --git a/libpurple/protocols/simple/simple.c b/libpurple/protocols/simple/simple.c
--- a/libpurple/protocols/simple/simple.c
+++ b/libpurple/protocols/simple/simple.c
@@ -2081,28 +2081,37 @@ simple_protocol_init(PurpleProtocol *pro
 static void
 simple_protocol_class_init(PurpleProtocolClass *klass)
 {
+	klass->login        = simple_login;
+	klass->close        = simple_close;
+	klass->status_types = simple_status_types;
+	klass->list_icon    = simple_list_icon;
 }
 
 static void
-simple_protocol_client_iface_init(PurpleProtocolClientIface *client_iface)
+simple_protocol_server_iface_init(PurpleProtocolServerIface *server_iface)
 {
-	client_iface->list_icon    = simple_list_icon;
-	client_iface->status_types = simple_status_types;
-	client_iface->login        = simple_login;
-	client_iface->close        = simple_close;
-	client_iface->send_im      = simple_im_send;
-	client_iface->send_typing  = simple_typing;



More information about the Commits mailing list