/soc/2013/ankitkv/gobjectification: 24f9c085897a: Finished split...

Ankit Vani a at nevitus.org
Sat Sep 14 05:49:39 EDT 2013


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

Description:

Finished splitting up the protocol interface

diffstat:

 libpurple/protocol.h |  763 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 467 insertions(+), 296 deletions(-)

diffs (truncated from 1092 to 300 lines):

diff --git a/libpurple/protocol.h b/libpurple/protocol.h
--- a/libpurple/protocol.h
+++ b/libpurple/protocol.h
@@ -1,5 +1,5 @@
 /**
- * @file protocol.h Protocol object and interface API
+ * @file protocol.h Protocol object and interfaces API
  * @ingroup core
  */
 
@@ -27,43 +27,18 @@
 #ifndef _PURPLE_PROTOCOL_H_
 #define _PURPLE_PROTOCOL_H_
 
-#define PURPLE_TYPE_PROTOCOL                (purple_protocol_get_type())
-#define PURPLE_PROTOCOL(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocol))
-#define PURPLE_PROTOCOL_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
-#define PURPLE_IS_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL))
-#define PURPLE_IS_PROTOCOL_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PROTOCOL))
-#define PURPLE_PROTOCOL_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
-
-#define PURPLE_TYPE_PROTOCOL_INTERFACE      (purple_protocol_iface_get_type())
-#define PURPLE_IS_PROTOCOL_INTERFACE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_INTERFACE))
-#define PURPLE_PROTOCOL_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), PURPLE_TYPE_PROTOCOL_INTERFACE, PurpleProtocolInterface))
+#define PURPLE_TYPE_PROTOCOL            (purple_protocol_get_type())
+#define PURPLE_PROTOCOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocol))
+#define PURPLE_PROTOCOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
+#define PURPLE_IS_PROTOCOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL))
+#define PURPLE_IS_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PROTOCOL))
+#define PURPLE_PROTOCOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
 
 /** @copydoc _PurpleProtocol */
 typedef struct _PurpleProtocol PurpleProtocol;
 /** @copydoc _PurpleProtocolClass */
 typedef struct _PurpleProtocolClass PurpleProtocolClass;
 
-/** @copydoc _PurpleProtocolClientInterface */
-typedef struct _PurpleProtocolClientInterface PurpleProtocolClientInterface;
-/** @copydoc _PurpleProtocolServerInterface */
-typedef struct _PurpleProtocolServerInterface PurpleProtocolServerInterface;
-/** @copydoc _PurpleProtocolIMInterface */
-typedef struct _PurpleProtocolIMInterface PurpleProtocolIMInterface;
-/** @copydoc _PurpleProtocolChatInterface */
-typedef struct _PurpleProtocolChatInterface PurpleProtocolChatInterface;
-/** @copydoc _PurpleProtocolPrivacyInterface */
-typedef struct _PurpleProtocolPrivacyInterface PurpleProtocolPrivacyInterface;
-/** @copydoc _PurpleProtocolXferInterface */
-typedef struct _PurpleProtocolXferInterface PurpleProtocolXferInterface;
-/** @copydoc _PurpleProtocolRoomlistInterface */
-typedef struct _PurpleProtocolRoomlistInterface PurpleProtocolRoomlistInterface;
-/** @copydoc _PurpleProtocolAttentionInterface */
-typedef struct _PurpleProtocolAttentionInterface PurpleProtocolAttentionInterface;
-/** @copydoc _PurpleProtocolMediaInterface */
-typedef struct _PurpleProtocolMediaInterface PurpleProtocolMediaInterface;
-/** @copydoc _PurpleProtocolFactoryInterface */
-typedef struct _PurpleProtocolFactoryInterface PurpleProtocolFactoryInterface;
-
 #include "account.h"
 #include "accountopt.h"
 #include "buddyicon.h"
@@ -138,7 +113,7 @@ struct _PurpleProtocolClass
 	/**
 	 * Close connection with the server.
 	 */
-	void (*close)(PurpleConnection *);
+	void (*close_connection)(PurpleConnection *);
 
 	/**
 	 * Returns a list of #PurpleStatusType which exist for this account;
@@ -160,12 +135,20 @@ struct _PurpleProtocolClass
 	void (*_purple_reserved4)(void);
 };
 
+#define PURPLE_TYPE_PROTOCOL_CLIENT_IFACE     (purple_protocol_client_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_CLIENT_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_CLIENT_IFACE))
+#define PURPLE_PROTOCOL_GET_CLIENT_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_CLIENT_IFACE, \
+                                               PurpleProtocolClientIface))
+
+/** @copydoc _PurpleProtocolClientIface */
+typedef struct _PurpleProtocolClientIface PurpleProtocolClientIface;
+
 /**
  * The protocol client interface.
  *
  * This interface provides a gateway between purple and the protocol.
  */
-struct _PurpleProtocolClientInterface
+struct _PurpleProtocolClientIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
@@ -266,12 +249,20 @@ struct _PurpleProtocolClientInterface
 	gssize (*get_max_message_size)(PurpleConversation *conv);
 };
 
+#define PURPLE_TYPE_PROTOCOL_SERVER_IFACE     (purple_protocol_server_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_SERVER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_SERVER_IFACE))
+#define PURPLE_PROTOCOL_GET_SERVER_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_SERVER_IFACE, \
+                                               PurpleProtocolServerIface))
+
+/** @copydoc _PurpleProtocolServerIface */
+typedef struct _PurpleProtocolServerIface PurpleProtocolServerIface;
+
 /**
  * The protocol server interface.
  *
  * This interface provides a gateway between purple and the protocol's server.
  */
-struct _PurpleProtocolServerInterface
+struct _PurpleProtocolServerIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
@@ -388,12 +379,20 @@ struct _PurpleProtocolServerInterface
 	                         PurpleGetPublicAliasFailureCallback failure_cb);
 };
 
+#define PURPLE_TYPE_PROTOCOL_IM_IFACE     (purple_protocol_im_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_IM_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_IM_IFACE))
+#define PURPLE_PROTOCOL_GET_IM_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_IM_IFACE, \
+                                           PurpleProtocolIMIface))
+
+/** @copydoc _PurpleProtocolIMIface */
+typedef struct _PurpleProtocolIMIface PurpleProtocolIMIface;
+
 /**
  * The protocol IM interface.
  *
  * This interface provides callbacks needed by protocols that implement IMs.
  */
-struct _PurpleProtocolIMInterface
+struct _PurpleProtocolIMIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
@@ -407,7 +406,7 @@ struct _PurpleProtocolIMInterface
 	 * errno values, or just big something.  If the message should
 	 * not be echoed to the conversation window, return 0.
 	 */
-	int  (*send_im)(PurpleConnection *, const char *who,
+	int  (*send)(PurpleConnection *, const char *who,
 					const char *message,
 					PurpleMessageFlags flags);
 
@@ -422,12 +421,20 @@ struct _PurpleProtocolIMInterface
 								PurpleIMTypingState state);
 };
 
+#define PURPLE_TYPE_PROTOCOL_CHAT_IFACE     (purple_protocol_chat_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_CHAT_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_CHAT_IFACE))
+#define PURPLE_PROTOCOL_GET_CHAT_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_CHAT_IFACE, \
+                                             PurpleProtocolChatIface))
+
+/** @copydoc _PurpleProtocolChatIface */
+typedef struct _PurpleProtocolChatIface PurpleProtocolChatIface;
+
 /**
  * The protocol chat interface.
  *
  * This interface provides callbacks needed by protocols that implement chats.
  */
-struct _PurpleProtocolChatInterface
+struct _PurpleProtocolChatIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
@@ -439,7 +446,7 @@ struct _PurpleProtocolChatInterface
 	 *
 	 * @return A list of #PurpleProtocolChatEntry structs
 	 */
-	GList *(*chat_info)(PurpleConnection *);
+	GList *(*info)(PurpleConnection *);
 
 	/**
 	 * Returns a hashtable which maps #PurpleProtocolChatEntry struct
@@ -452,7 +459,7 @@ struct _PurpleProtocolChatInterface
 	 * @param chat_name The chat name to be turned into components
 	 * @return Hashtable containing the information extracted from chat_name
 	 */
-	GHashTable *(*chat_info_defaults)(PurpleConnection *,
+	GHashTable *(*info_defaults)(PurpleConnection *,
 									  const char *chat_name);
 
 	/**
@@ -465,7 +472,7 @@ struct _PurpleProtocolChatInterface
 	 *                   an invitation, in which case this matches the
 	 *                   data parameter passed to #serv_got_chat_invite.
 	 */
-	void (*join_chat)(PurpleConnection *, GHashTable *components);
+	void (*join)(PurpleConnection *, GHashTable *components);
 
 	/**
 	 * Called when the user refuses a chat invitation.
@@ -473,7 +480,7 @@ struct _PurpleProtocolChatInterface
 	 * @param components A hashtable containing information required to
 	 *                   join the chat as passed to #serv_got_chat_invite.
 	 */
-	void (*reject_chat)(PurpleConnection *, GHashTable *components);
+	void (*reject)(PurpleConnection *, GHashTable *components);
 
 	/**
 	 * Returns a chat name based on the information in components. Use
@@ -482,7 +489,7 @@ struct _PurpleProtocolChatInterface
 	 *
 	 * @param components A hashtable containing information about the chat.
 	 */
-	char *(*get_chat_name)(GHashTable *components);
+	char *(*get_name)(GHashTable *components);
 
 	/**
 	 * Invite a user to join a chat.
@@ -492,14 +499,14 @@ struct _PurpleProtocolChatInterface
 	 *                is received.
 	 * @param who     The name of the user to send the invation to.
 	 */
-	void (*chat_invite)(PurpleConnection *, int id,
+	void (*invite)(PurpleConnection *, int id,
 						const char *message, const char *who);
 	/**
 	 * Called when the user requests leaving a chat.
 	 *
 	 * @param id The id of the chat to leave
 	 */
-	void (*chat_leave)(PurpleConnection *, int id);
+	void (*leave)(PurpleConnection *, int id);
 
 	/**
 	 * Send a whisper to a user in a chat.
@@ -508,7 +515,7 @@ struct _PurpleProtocolChatInterface
 	 * @param who     The name of the user to send the whisper to.
 	 * @param message The message of the whisper.
 	 */
-	void (*chat_whisper)(PurpleConnection *, int id,
+	void (*whisper)(PurpleConnection *, int id,
 						 const char *who, const char *message);
 
 	/**
@@ -527,7 +534,7 @@ struct _PurpleProtocolChatInterface
 	 * @return 	  A positive number or 0 in case of success,
 	 *                a negative error number in case of failure.
 	 */
-	int  (*chat_send)(PurpleConnection *, int id, const char *message,
+	int  (*send)(PurpleConnection *, int id, const char *message,
 					  PurpleMessageFlags flags);
 
 	/** Gets the real name of a participant in a chat.  For example, on
@@ -539,17 +546,25 @@ struct _PurpleProtocolChatInterface
 	 *  @return    the real name of the participant.  This string must be
 	 *             freed by the caller.
 	 */
-	char *(*get_cuser_real_name)(PurpleConnection *gc, int id, const char *who);
+	char *(*get_user_real_name)(PurpleConnection *gc, int id, const char *who);
 
-	void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
+	void (*set_topic)(PurpleConnection *gc, int id, const char *topic);
 };
 
+#define PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE     (purple_protocol_privacy_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_PRIVACY_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE))
+#define PURPLE_PROTOCOL_GET_PRIVACY_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE, \
+                                                PurpleProtocolPrivacyIface))
+
+/** @copydoc _PurpleProtocolPrivacyIface */
+typedef struct _PurpleProtocolPrivacyIface PurpleProtocolPrivacyIface;
+
 /**
  * The protocol privacy interface.
  *
  * This interface provides privacy callbacks such as to permit/deny users.
  */
-struct _PurpleProtocolPrivacyInterface
+struct _PurpleProtocolPrivacyIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
@@ -561,62 +576,94 @@ struct _PurpleProtocolPrivacyInterface
 	void (*set_permit_deny)(PurpleConnection *);
 };
 
+#define PURPLE_TYPE_PROTOCOL_XFER_IFACE     (purple_protocol_xfer_iface_get_type())
+#define PURPLE_PROTOCOL_HAS_XFER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE))
+#define PURPLE_PROTOCOL_GET_XFER_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE, \
+                                             PurpleProtocolXferIface))
+
+/** @copydoc _PurpleProtocolXferIface */
+typedef struct _PurpleProtocolXferIface PurpleProtocolXferIface;
+
 /**
  * The protocol file transfer interface.
  *
  * This interface provides file transfer callbacks for the protocol.
  */
-struct _PurpleProtocolXferInterface
+struct _PurpleProtocolXferIface
 {
 	/*< private >*/
 	GTypeInterface parent_iface;
 
-	gboolean (*can_receive_file)(PurpleConnection *, const char *who);
-	void (*send_file)(PurpleConnection *, const char *who,



More information about the Commits mailing list