/soc/2013/ankitkv/gobjectification: 49872e1ec30e: Defined the ne...

Ankit Vani a at nevitus.org
Sat Sep 14 08:56:39 EDT 2013


Changeset: 49872e1ec30ef22a5c9371265d746b1a517d09f6
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-14 18:26 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/49872e1ec30e

Description:

Defined the new interface functions

diffstat:

 libpurple/protocol.c |  1108 +++++++++++++++++++++++++++++++++----------------
 libpurple/protocol.h |     2 +-
 2 files changed, 742 insertions(+), 368 deletions(-)

diffs (truncated from 1309 to 300 lines):

diff --git a/libpurple/protocol.c b/libpurple/protocol.c
--- a/libpurple/protocol.c
+++ b/libpurple/protocol.c
@@ -26,9 +26,8 @@
 static GObjectClass *parent_class;
 
 /**************************************************************************
- * Protocol Class API
+ * Protocol Object API
  **************************************************************************/
-
 const char *
 purple_protocol_get_id(const PurpleProtocol *protocol)
 {
@@ -138,7 +137,6 @@ purple_protocol_override(PurpleProtocol 
 /**************************************************************************
  * GObject stuff
  **************************************************************************/
-
 static void
 purple_protocol_init(GTypeInstance *instance, gpointer klass)
 {
@@ -220,104 +218,23 @@ purple_protocol_get_type(void)
 	return type;
 }
 
-GType
-purple_protocol_iface_get_type(void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY(type == 0)) {
-		static const GTypeInfo info = {
-			.class_size = sizeof(PurpleProtocolInterface),
-		};
-
-		type = g_type_register_static(G_TYPE_INTERFACE,
-		                              "PurpleProtocolInterface", &info, 0);
-	}
-
-	return type;
-}
-
 /**************************************************************************
- * Protocol Interface API
+ * Protocol Class API
  **************************************************************************/
-
 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
-	PurpleProtocolInterface *iface = PURPLE_PROTOCOL_GET_INTERFACE(protocol); \
-	g_return_if_fail(iface != NULL); \
-	if (iface->funcname) \
-		iface->funcname(__VA_ARGS__);
+	PurpleProtocolClass *klass = PURPLE_PROTOCOL_GET_CLASS(protocol); \
+	g_return_if_fail(klass != NULL); \
+	if (klass->funcname) \
+		klass->funcname(__VA_ARGS__);
 
 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
-	PurpleProtocolInterface *iface = PURPLE_PROTOCOL_GET_INTERFACE(protocol); \
-	g_return_val_if_fail(iface != NULL, defaultreturn); \
-	if (iface->funcname) \
-		return iface->funcname(__VA_ARGS__); \
+	PurpleProtocolClass *klass = PURPLE_PROTOCOL_GET_CLASS(protocol); \
+	g_return_val_if_fail(klass != NULL, defaultreturn); \
+	if (klass->funcname) \
+		return klass->funcname(__VA_ARGS__); \
 	else \
 		return defaultreturn;
 
-GList *
-purple_protocol_client_iface_get_actions(PurpleProtocol *protocol,
-                                  PurpleConnection *gc)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, get_actions, gc);
-}
-
-const char *
-purple_protocol_class_list_icon(PurpleProtocol *protocol,
-                                PurpleAccount *account, PurpleBuddy *buddy)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, list_icon, account, buddy);
-}
-
-const char *
-purple_protocol_client_iface_list_emblem(PurpleProtocol *protocol, PurpleBuddy *buddy)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, list_emblem, buddy);
-}
-
-char *
-purple_protocol_client_iface_status_text(PurpleProtocol *protocol, PurpleBuddy *buddy)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, status_text, buddy);
-}
-
-void
-purple_protocol_client_iface_tooltip_text(PurpleProtocol *protocol, PurpleBuddy *buddy,
-                                   PurpleNotifyUserInfo *user_info,
-                                   gboolean full)
-{
-	DEFINE_PROTOCOL_FUNC(protocol, tooltip_text, buddy, user_info, full);
-}
-
-GList *
-purple_protocol_class_status_types(PurpleProtocol *protocol,
-                                   PurpleAccount *account)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, status_types, account);
-}
-
-GList *
-purple_protocol_client_iface_blist_node_menu(PurpleProtocol *protocol,
-                                      PurpleBlistNode *node)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, blist_node_menu, node);
-}
-
-GList *
-purple_protocol_chat_iface_info(PurpleProtocol *protocol, PurpleConnection *gc)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, chat_info, gc);
-}
-
-GHashTable *
-purple_protocol_chat_iface_info_defaults(PurpleProtocol *protocol,
-                                         PurpleConnection *gc,
-                                         const char *chat_name)
-{
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, chat_info_defaults, gc,
-	                                 chat_name);
-}
-
 void
 purple_protocol_class_login(PurpleProtocol *protocol, PurpleAccount *account)
 {
@@ -325,429 +242,886 @@ purple_protocol_class_login(PurpleProtoc
 }
 
 void
-purple_protocol_class_close_connection(PurpleProtocol *protocol, PurpleConnection *gc)
+purple_protocol_class_close_connection(PurpleProtocol *protocol,
+		PurpleConnection *gc)
 {
-	DEFINE_PROTOCOL_FUNC(protocol, close, gc);
+	DEFINE_PROTOCOL_FUNC(protocol, close_connection, gc);
 }
 
-int 
-purple_protocol_im_iface_send(PurpleProtocol *protocol, PurpleConnection *gc, 
-                              const char *who, const char *message,
-                              PurpleMessageFlags flags)
+GList *
+purple_protocol_class_status_types(PurpleProtocol *protocol,
+		PurpleAccount *account)
 {
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, 0, send_im, gc, who, message,
-	                                 flags);
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, status_types, account);
+}
+
+const char *
+purple_protocol_class_list_icon(PurpleProtocol *protocol,
+		PurpleAccount *account, PurpleBuddy *buddy)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, list_icon, account, buddy);
+}
+
+#undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
+#undef DEFINE_PROTOCOL_FUNC
+
+/**************************************************************************
+ * Protocol Client Interface API
+ **************************************************************************/
+#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
+	PurpleProtocolClientIface *client_iface = \
+		PURPLE_PROTOCOL_GET_CLIENT_IFACE(protocol); \
+	g_return_if_fail(client_iface != NULL); \
+	if (client_iface->funcname) \
+		client_iface->funcname(__VA_ARGS__);
+
+#define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
+	PurpleProtocolClientIface *client_iface = \
+		PURPLE_PROTOCOL_GET_CLIENT_IFACE(protocol); \
+	g_return_val_if_fail(client_iface != NULL, defaultreturn); \
+	if (client_iface->funcname) \
+		return client_iface->funcname(__VA_ARGS__); \
+	else \
+		return defaultreturn;
+
+GType
+purple_protocol_client_iface_get_type(void)
+{
+	static GType type = 0;
+
+	if (G_UNLIKELY(type == 0)) {
+		static const GTypeInfo info = {
+			.class_size = sizeof(PurpleProtocolClientIface),
+		};
+
+		type = g_type_register_static(G_TYPE_INTERFACE,
+				"PurpleProtocolClientIface", &info, 0);
+	}
+	return type;
+}
+
+GList *
+purple_protocol_client_iface_get_actions(PurpleProtocol *protocol,
+		PurpleConnection *gc)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, get_actions, gc);
+}
+
+const char *
+purple_protocol_client_iface_list_emblem(PurpleProtocol *protocol,
+		PurpleBuddy *buddy)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, list_emblem, buddy);
+}
+
+char *
+purple_protocol_client_iface_status_text(PurpleProtocol *protocol,
+		PurpleBuddy *buddy)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, status_text, buddy);
 }
 
 void
-purple_protocol_server_iface_set_info(PurpleProtocol *protocol, PurpleConnection *gc,
-                               const char *info)
+purple_protocol_client_iface_tooltip_text(PurpleProtocol *protocol,
+		PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
+{
+	DEFINE_PROTOCOL_FUNC(protocol, tooltip_text, buddy, user_info, full);
+}
+
+GList *
+purple_protocol_client_iface_blist_node_menu(PurpleProtocol *protocol,
+		PurpleBlistNode *node)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, blist_node_menu, node);
+}
+
+void
+purple_protocol_client_iface_buddy_free(PurpleProtocol *protocol,
+		PurpleBuddy *buddy)
+{
+	DEFINE_PROTOCOL_FUNC(protocol, buddy_free, buddy);
+}
+
+void
+purple_protocol_client_iface_convo_closed(PurpleProtocol *protocol,
+		PurpleConnection *gc, const char *who)
+{
+	DEFINE_PROTOCOL_FUNC(protocol, convo_closed, gc, who);
+}
+
+const char *
+purple_protocol_client_iface_normalize(PurpleProtocol *protocol,
+		const PurpleAccount *account, const char *who)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, normalize, account, who);
+}
+
+PurpleChat *
+purple_protocol_client_iface_find_blist_chat(PurpleProtocol *protocol,
+		PurpleAccount *account, const char *name)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, find_blist_chat, account,
+			name);
+}
+
+gboolean
+purple_protocol_client_iface_offline_message(PurpleProtocol *protocol,
+		const PurpleBuddy *buddy)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, FALSE, offline_message, buddy);
+}
+
+GHashTable *
+purple_protocol_client_iface_get_account_text_table(PurpleProtocol *protocol,
+		PurpleAccount *account)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, get_account_text_table,
+			account);
+}
+
+PurpleMood *
+purple_protocol_client_iface_get_moods(PurpleProtocol *protocol,
+		PurpleAccount *account)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, get_moods, account);
+}
+
+gssize
+purple_protocol_client_iface_get_max_message_size(PurpleProtocol *protocol,
+		PurpleConversation *conv)
+{
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, 0, get_max_message_size, conv);
+}



More information about the Commits mailing list