pidgin.next.minor: f00a8560: Use up the last padding for PurplePlugin...

sadrul at pidgin.im sadrul at pidgin.im
Mon May 5 03:00:44 EDT 2008


-----------------------------------------------------------------
Revision: f00a8560ccde5ca23be0911c55f8914f49e80c41
Ancestor: d2b411c3bdf299282e63ddaf7dd798f86b2993c8
Author: sadrul at pidgin.im
Date: 2008-05-05T06:19:46
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/f00a8560ccde5ca23be0911c55f8914f49e80c41

Modified files:
        libpurple/protocols/bonjour/bonjour.c
        libpurple/protocols/gg/gg.c libpurple/protocols/irc/irc.c
        libpurple/protocols/jabber/libxmpp.c
        libpurple/protocols/msn/msn.c
        libpurple/protocols/msnp9/msn.c
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/novell/novell.c
        libpurple/protocols/oscar/libaim.c
        libpurple/protocols/oscar/libicq.c
        libpurple/protocols/qq/qq.c libpurple/protocols/silc/silc.c
        libpurple/protocols/silc10/silc.c
        libpurple/protocols/simple/simple.c
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/zephyr/zephyr.c libpurple/prpl.h

ChangeLog: 

Use up the last padding for PurplePluginProtocolInfo in a way that allows
adding newer functions without causing any major version bump. This is
based on the changes from the .vv branch. I changed the
PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro a little so it can be used for the
old as well as the new functions. Someone should confirm this looks OK.


-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/bonjour.c	193d7ec7ffc3265767b73922ece594d556189bef
+++ libpurple/protocols/bonjour/bonjour.c	13245405017177d9885cae94bda3cf90bf6b5208
@@ -487,7 +487,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/gg/gg.c	ae21312c0c934120c4d590de681dfa9dff9c29b8
+++ libpurple/protocols/gg/gg.c	dafe006e5617133688c37cce4726f0addba6c361
@@ -2152,7 +2152,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 /* }}} */
 
============================================================
--- libpurple/protocols/irc/irc.c	123ab56826fab72d4e46f7dfdc7b0d385e4e61e0
+++ libpurple/protocols/irc/irc.c	639a3020e6bee9ce478599c3bb264939c5d65ed3
@@ -905,7 +905,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static gboolean load_plugin (PurplePlugin *plugin) {
============================================================
--- libpurple/protocols/jabber/libxmpp.c	729b8ce49aebaf45713070119f8d54882459a2d9
+++ libpurple/protocols/jabber/libxmpp.c	212c0b80176674a2a28246a348d7d73be6cf44f8
@@ -116,8 +116,7 @@ static PurplePluginProtocolInfo prpl_inf
 	jabber_send_attention,			/* send_attention */
 	jabber_attention_types,			/* attention_types */
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
============================================================
--- libpurple/protocols/msn/msn.c	6ce042f757eef19bfda47427cb21f176131e14bd
+++ libpurple/protocols/msn/msn.c	057e82fed61293c7a02de9257fcd12ceb9e20d2c
@@ -132,7 +132,6 @@ msn_attention_types(PurpleAccount *accou
 	return list;
 }
 
-
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
 {
@@ -2307,8 +2306,7 @@ static PurplePluginProtocolInfo prpl_inf
 	msn_send_attention,                     /* send_attention */
 	msn_attention_types,                    /* attention_types */
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/msnp9/msn.c	bb0278b1641ea4342d88d96c226b19562000c8fe
+++ libpurple/protocols/msnp9/msn.c	745f523b052dd2b2c3166e539832002c6df6e836
@@ -133,7 +133,6 @@ msn_attention_types(PurpleAccount *accou
 	return list;
 }
 
-
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
 {
@@ -2148,8 +2147,7 @@ static PurplePluginProtocolInfo prpl_inf
 	msn_send_attention,                     /* send_attention */
 	msn_attention_types,                    /* attention_types */
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/myspace/myspace.c	2bb03dbf1f14bd88735ed083293d0723f893db82
+++ libpurple/protocols/myspace/myspace.c	4fbe9a01c821b95a906c43c36aa55d7f38045eb0
@@ -3131,14 +3131,15 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                  /* unregister_user */
 	msim_send_attention,   /* send_attention */
 	msim_attention_types,  /* attention_types */
-	NULL                /* _purple_reserved4 */
+
+	sizeof(PurplePluginProtocolInfo),  /* struct_size */
 };
 
 
 
 /** Based on MSN's plugin info comments. */
 static PurplePluginInfo info = {
-	PURPLE_PLUGIN_MAGIC,                                
+	PURPLE_PLUGIN_MAGIC,
 	PURPLE_MAJOR_VERSION,
 	PURPLE_MINOR_VERSION,
 	PURPLE_PLUGIN_PROTOCOL,                           /**< type           */
============================================================
--- libpurple/protocols/novell/novell.c	be1a5a1a8c2aa8c6ab17efbeed0bfd3cf6f61025
+++ libpurple/protocols/novell/novell.c	94c2831474b1518525f963406ee4516e34f0c11a
@@ -3517,7 +3517,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/protocols/oscar/libaim.c	9427c1eafab6f3ca880bd9771314dc0cb96fd90a
+++ libpurple/protocols/oscar/libaim.c	3d4692b5e16532de368166642f44d20b11cbab75
@@ -96,8 +96,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* send_attention */
 	NULL,					/* get_attention_types */
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/oscar/libicq.c	765b900a15379b2ccb970803e961cc64c624be2a
+++ libpurple/protocols/oscar/libicq.c	c2832fe4c3cdf20ce2bf5ee21a6b70a3be4aabb7
@@ -96,8 +96,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* send_attention */
 	NULL,					/* get_attention_types */
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/qq/qq.c	3242aa1932271ecf9adc3daa35993f6d8d1ad1df
+++ libpurple/protocols/qq/qq.c	2ec3f27b766abfc994de6e5f3893f788ab7293ed
@@ -706,7 +706,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/protocols/silc/silc.c	c659c8776178b6d9861c147bd29017d1484161d9
+++ libpurple/protocols/silc/silc.c	e025d0819c9b22cd9b945c29bc0623972814e1ea
@@ -2071,7 +2071,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/silc10/silc.c	c884431c00483ed438d8d10b08a90c2d3599d3d5
+++ libpurple/protocols/silc10/silc.c	0a36b7eff1245d3097a1f24668330b9822311766
@@ -1800,11 +1800,10 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                       /* send_raw */
 	NULL,                       /* roomlist_room_serialize */
 
-	/* padding */
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/simple/simple.c	6f560bba5995648dab064514f7360bdd4b90af32
+++ libpurple/protocols/simple/simple.c	df0f752b93c5362ee704ab32b4fccbcfcab17228
@@ -2052,7 +2052,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 
============================================================
--- libpurple/protocols/yahoo/yahoo.c	f03d8a1b21d1fd393c586bde1769d7b3012af212
+++ libpurple/protocols/yahoo/yahoo.c	87031baac3e3858fca2dca3232ec22d446640bce
@@ -4379,8 +4379,7 @@ static PurplePluginProtocolInfo prpl_inf
 	yahoo_send_attention,
 	yahoo_attention_types,
 
-	/* padding */
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/zephyr/zephyr.c	b282d503470d98f20ea7008e1742ee7721947bd7
+++ libpurple/protocols/zephyr/zephyr.c	7c7efe0bcd099c5ba907777a2467457399cdd6be
@@ -2907,11 +2907,10 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* send_raw */
 	NULL,					/* roomlist_room_serialize */
 
-	/* padding */
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/prpl.h	efd045aa1c1a4a44959d513dbb3aa5dee4d5a5e2
+++ libpurple/prpl.h	a4cb4e4f413855f35d133eaa3e59d7a22bc0ac78
@@ -398,9 +398,34 @@ struct _PurplePluginProtocolInfo
 	gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
 	GList *(*get_attention_types)(PurpleAccount *acct);
 
-	void (*_purple_reserved4)(void);
+	/**
+	 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
+	 * This allows adding more functions to this struct without requiring a major version bump.
+	 */
+	unsigned long struct_size;
+
+	/* NOTE:
+	 * If more functions are added, they should accessed using the following syntax:
+	 *
+	 *		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
+	 *			prpl->new_function(...);
+	 *
+	 * instead of
+	 *
+	 *		if (prpl->new_function != NULL)
+	 *			prpl->new_function(...);
+	 *
+	 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
+	 * functions (e.g. login, send_im etc.) too.
+	 */
 };
 
+#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
+	(((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
+	  || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
+	 prpl->member != NULL)
+
+
 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
 	((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
 


More information about the Commits mailing list