Mercurial > pidgin.yaz
changeset 32493:743bb6b1aa30
Move struct_size to the beginning of the struct. Even if we don't
rewrite this somehow (as a GObject or otherwise), it really belongs at
the start.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 03 Sep 2011 23:30:40 +0000 |
parents | cd1d9e04c587 |
children | 3a19c7068b53 |
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/mxit/mxit.c libpurple/protocols/myspace/myspace.c libpurple/protocols/novell/novell.c libpurple/protocols/null/nullprpl.c libpurple/protocols/oscar/libaim.c libpurple/protocols/oscar/libicq.c libpurple/protocols/sametime/sametime.c libpurple/protocols/simple/simple.c libpurple/protocols/yahoo/libyahoo.c libpurple/protocols/yahoo/libyahoojp.c libpurple/protocols/zephyr/zephyr.c libpurple/prpl.h |
diffstat | 17 files changed, 39 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Sat Sep 03 23:30:40 2011 +0000 @@ -484,6 +484,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_NO_PASSWORD, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -549,7 +550,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/gg/gg.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/gg/gg.c Sat Sep 03 23:30:40 2011 +0000 @@ -2655,6 +2655,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_IM_IMAGE, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -2720,7 +2721,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* can_do_media */
--- a/libpurple/protocols/irc/irc.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/irc/irc.c Sat Sep 03 23:30:40 2011 +0000 @@ -917,6 +917,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_SLASH_COMMANDS_NATIVE, NULL, /* user_splits */ @@ -983,7 +984,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/jabber/libxmpp.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Sat Sep 03 23:30:40 2011 +0000 @@ -53,6 +53,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK | #ifdef HAVE_CYRUS_SASL OPT_PROTO_PASSWORD_OPTIONAL | @@ -122,8 +123,6 @@ jabber_unregister_account, /* unregister_user */ jabber_send_attention, /* send_attention */ jabber_attention_types, /* attention_types */ - - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ jabber_initiate_media, /* initiate_media */ jabber_get_media_caps, /* get_media_caps */
--- a/libpurple/protocols/msn/msn.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/msn/msn.c Sat Sep 03 23:30:40 2011 +0000 @@ -2930,6 +2930,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_MAIL_CHECK|OPT_PROTO_INVITE_MESSAGE, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -2995,7 +2996,6 @@ NULL, /* unregister_user */ msn_send_attention, /* send_attention */ msn_attention_types, /* attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ msn_get_account_text_table, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/mxit/mxit.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/mxit/mxit.c Sat Sep 03 23:30:40 2011 +0000 @@ -668,6 +668,7 @@ /*========================================================================================================================*/ static PurplePluginProtocolInfo proto_info = { + sizeof( PurplePluginProtocolInfo ), /* struct_size */ OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE, /* options */ NULL, /* user_splits */ NULL, /* protocol_options */ @@ -740,7 +741,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* attention_types */ - sizeof( PurplePluginProtocolInfo ), /* struct_size */ mxit_get_text_table, /* get_account_text_table */ mxit_media_initiate, /* initiate_media */ mxit_media_caps, /* get_media_caps */
--- a/libpurple/protocols/myspace/myspace.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/myspace/myspace.c Sat Sep 03 23:30:40 2011 +0000 @@ -3007,6 +3007,7 @@ * Callbacks called by Purple, to access this plugin. */ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ /* options */ OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ | OPT_PROTO_MAIL_CHECK, @@ -3076,7 +3077,6 @@ NULL, /* unregister_user */ msim_send_attention, /* send_attention */ msim_attention_types, /* attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ msim_get_account_text_table, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/novell/novell.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/novell/novell.c Sat Sep 03 23:30:40 2011 +0000 @@ -3474,6 +3474,7 @@ } static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ 0, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -3539,7 +3540,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/null/nullprpl.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/null/nullprpl.c Sat Sep 03 23:30:40 2011 +0000 @@ -1052,6 +1052,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC, /* options */ NULL, /* user_splits, initialized in nullprpl_init() */ NULL, /* protocol_options, initialized in nullprpl_init() */ @@ -1125,7 +1126,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/oscar/libaim.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/oscar/libaim.c Sat Sep 03 23:30:40 2011 +0000 @@ -29,6 +29,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -94,7 +95,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/oscar/libicq.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/oscar/libicq.c Sat Sep 03 23:30:40 2011 +0000 @@ -38,6 +38,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -103,8 +104,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - - sizeof(PurplePluginProtocolInfo), /* struct_size */ icq_get_account_text_table, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* can_do_media */
--- a/libpurple/protocols/sametime/sametime.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/sametime/sametime.c Sat Sep 03 23:30:40 2011 +0000 @@ -5154,6 +5154,7 @@ static PurplePluginProtocolInfo mw_prpl_info = { + .struct_size = sizeof(PurplePluginProtocolInfo), .options = OPT_PROTO_IM_IMAGE, .user_splits = NULL, /*< set in mw_plugin_init */ .protocol_options = NULL, /*< set in mw_plugin_init */ @@ -5213,8 +5214,7 @@ .new_xfer = mw_prpl_new_xfer, .offline_message = NULL, .whiteboard_prpl_ops = NULL, - .send_raw = NULL, - .struct_size = sizeof(PurplePluginProtocolInfo) + .send_raw = NULL };
--- a/libpurple/protocols/simple/simple.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/simple/simple.c Sat Sep 03 23:30:40 2011 +0000 @@ -2046,6 +2046,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ 0, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -2111,7 +2112,6 @@ NULL, /* unregister_user */ NULL, /* send_attention */ NULL, /* get_attention_types */ - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/yahoo/libyahoo.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/yahoo/libyahoo.c Sat Sep 03 23:30:40 2011 +0000 @@ -194,6 +194,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -257,11 +258,8 @@ NULL, /* send_raw */ NULL, /* roomlist_room_serialize */ NULL, /* unregister_user */ - yahoo_send_attention, yahoo_attention_types, - - sizeof(PurplePluginProtocolInfo), /* struct_size */ yahoo_get_account_text_table, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/yahoo/libyahoojp.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/yahoo/libyahoojp.c Sat Sep 03 23:30:40 2011 +0000 @@ -90,6 +90,7 @@ static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, NULL, /* user_splits */ NULL, /* protocol_options */ @@ -157,7 +158,6 @@ yahoo_send_attention, yahoo_attention_types, - sizeof(PurplePluginProtocolInfo), /* struct_size */ yahoojp_get_account_text_table, /* get_account_text_table */ NULL, /* initiate_media */ NULL, /* get_media_caps */
--- a/libpurple/protocols/zephyr/zephyr.c Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Sat Sep 03 23:30:40 2011 +0000 @@ -2853,6 +2853,7 @@ static PurplePlugin *my_protocol = NULL; static PurplePluginProtocolInfo prpl_info = { + sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, NULL, /* ??? user_splits */ NULL, /* ??? protocol_options */ @@ -2919,7 +2920,6 @@ NULL, NULL, NULL, - sizeof(PurplePluginProtocolInfo), /* struct_size */ NULL, /* get_account_text_table */ NULL, /* initate_media */ NULL, /* get_media_caps */
--- a/libpurple/prpl.h Sat Sep 03 23:13:11 2011 +0000 +++ b/libpurple/prpl.h Sat Sep 03 23:30:40 2011 +0000 @@ -205,6 +205,27 @@ */ struct _PurplePluginProtocolInfo { + /** + * 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. + */ + PurpleProtocolOptions options; /**< Protocol options. */ GList *user_splits; /**< A GList of PurpleAccountUserSplit */ @@ -517,27 +538,6 @@ gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); GList *(*get_attention_types)(PurpleAccount *acct); - /** - * 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. - */ - /** This allows protocols to specify additional strings to be used for * various purposes. The idea is to stuff a bunch of strings in this hash * table instead of expanding the struct for every addition. This hash @@ -618,8 +618,7 @@ }; #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)) && \ + (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size && \ prpl->member != NULL)