Tue, 27 Aug 2013 04:30:39 +0530
Merged soc.2013.gobjectification branch
--- a/libpurple/connection.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/connection.c Tue Aug 27 04:30:39 2013 +0530 @@ -556,6 +556,26 @@ priv->last_received = time(NULL); } +gsize +purple_connection_get_max_message_size(PurpleConnection *gc) +{ + PurplePlugin *prpl; + PurplePluginProtocolInfo *prpl_info; + + g_return_val_if_fail(gc != NULL, 0); + + prpl = purple_connection_get_prpl(gc); + g_return_val_if_fail(prpl != NULL, 0); + + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + g_return_val_if_fail(prpl_info != NULL, 0); + + if (!PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_max_message_size)) + return 0; + + return prpl_info->get_max_message_size(gc); +} + /************************************************************************** * GBoxed code **************************************************************************/
--- a/libpurple/connection.h Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/connection.h Tue Aug 27 04:30:39 2013 +0530 @@ -464,6 +464,18 @@ */ void purple_connection_update_last_received(PurpleConnection *gc); +/** + * Gets the maximum message size for the protocol. It may depend on + * connection-specific variables (like protocol version). + * + * @see PurplePluginProtocolInfo#get_max_message_size + * + * @param gc The connection to query. + * @return Maximum message size, or 0 if unspecified or infinite. + */ +gsize +purple_connection_get_max_message_size(PurpleConnection *gc); + /*@}*/ /**************************************************************************/
--- a/libpurple/protocol.h Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocol.h Tue Aug 27 04:30:39 2013 +0530 @@ -503,6 +503,21 @@ void (*get_public_alias)(PurpleConnection *gc, PurpleGetPublicAliasSuccessCallback success_cb, PurpleGetPublicAliasFailureCallback failure_cb); + + /** + * Gets the maximum message size for the protocol. It may depend on + * connection-specific variables (like protocol version). + * + * This value is intended for plaintext message, the exact value may be + * lower because of: + * - used newlines (some protocols count them as more than one byte), + * - formatting, + * - used special characters. + * + * @param gc The connection to query, or NULL to get safe minimum. + * @return Maximum message size, or 0 if unspecified or infinite. + */ + gsize (*get_max_message_size)(PurpleConnection *gc); }; /** @@ -1116,6 +1131,10 @@ PurpleGetPublicAliasSuccessCallback success_cb, PurpleGetPublicAliasFailureCallback failure_cb); +/** @copydoc _PurpleProtocolInterface::get_max_message_size */ +gsize purple_protocol_iface_get_max_message_size(PurpleProtocol *, + PurpleConnection *gc); + /*@}*/ G_END_DECLS
--- a/libpurple/protocols/bonjour/bonjour.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/bonjour/bonjour.c Tue Aug 27 04:30:39 2013 +0530 @@ -471,6 +471,14 @@ return (buddy != NULL && purple_buddy_get_protocol_data(buddy) != NULL); } +static gsize +bonjour_get_max_message_size(PurpleConnection *gc) +{ + /* It looks, like the message length is practically unlimited (I've + * tried 5MB). */ + return 0; +} + #ifdef WIN32 static gboolean _set_default_name_cb(gpointer data) { @@ -671,23 +679,24 @@ static void bonjour_protocol_interface_init(PurpleProtocolInterface *iface) { - iface->list_icon = bonjour_list_icon; - iface->status_text = bonjour_status_text; - iface->tooltip_text = bonjour_tooltip_text; - iface->status_types = bonjour_status_types; - iface->login = bonjour_login; - iface->close = bonjour_close; - iface->send_im = bonjour_send_im; - iface->set_status = bonjour_set_status; - iface->add_buddy = bonjour_fake_add_buddy; - iface->remove_buddy = bonjour_remove_buddy; - iface->group_buddy = bonjour_group_buddy; - iface->rename_group = bonjour_rename_group; - iface->convo_closed = bonjour_convo_closed; - iface->set_buddy_icon = bonjour_set_buddy_icon; - iface->can_receive_file = bonjour_can_receive_file; - iface->send_file = bonjour_send_file; - iface->new_xfer = bonjour_new_xfer; + iface->list_icon = bonjour_list_icon; + iface->status_text = bonjour_status_text; + iface->tooltip_text = bonjour_tooltip_text; + iface->status_types = bonjour_status_types; + iface->login = bonjour_login; + iface->close = bonjour_close; + iface->send_im = bonjour_send_im; + iface->set_status = bonjour_set_status; + iface->add_buddy = bonjour_fake_add_buddy; + iface->remove_buddy = bonjour_remove_buddy; + iface->group_buddy = bonjour_group_buddy; + iface->rename_group = bonjour_rename_group; + iface->convo_closed = bonjour_convo_closed; + iface->set_buddy_icon = bonjour_set_buddy_icon; + iface->can_receive_file = bonjour_can_receive_file; + iface->send_file = bonjour_send_file; + iface->new_xfer = bonjour_new_xfer; + iface->get_max_message_size = bonjour_get_max_message_size; } static PurplePluginInfo *
--- a/libpurple/protocols/gg/gg.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/gg/gg.c Tue Aug 27 04:30:39 2013 +0530 @@ -1370,6 +1370,13 @@ return table; } +static gsize +ggp_get_max_message_size(PurpleConnection *gc) +{ + /* it may depend on protocol version or other factors - check it */ + return 1232; +} + static void purple_gg_debug_handler(int level, const char * format, va_list args) { PurpleDebugLevel purple_level; char *msg = g_strdup_vprintf(format, args); @@ -1488,6 +1495,7 @@ iface->set_buddy_icon = ggp_avatar_own_set; iface->offline_message = ggp_offline_message; iface->get_account_text_table = ggp_get_account_text_table; + iface->get_max_message_size = ggp_get_max_message_size; } static PurplePluginInfo *
--- a/libpurple/protocols/irc/irc.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/irc/irc.c Tue Aug 27 04:30:39 2013 +0530 @@ -915,6 +915,13 @@ irc_cmd_ping(irc, NULL, NULL, NULL); } +static gsize +irc_get_max_message_size(PurpleConnection *gc) +{ + /* got from pidgin-otr */ + return 417; +} + static void irc_protocol_base_init(IRCProtocolClass *klass) { @@ -981,31 +988,32 @@ static void irc_protocol_interface_init(PurpleProtocolInterface *iface) { - iface->get_actions = irc_get_actions; - iface->list_icon = irc_blist_icon; - iface->status_types = irc_status_types; - iface->chat_info = irc_chat_join_info; - iface->chat_info_defaults = irc_chat_info_defaults; - iface->login = irc_login; - iface->close = irc_close; - iface->send_im = irc_im_send; - iface->get_info = irc_get_info; - iface->set_status = irc_set_status; - iface->add_buddy = irc_add_buddy; - iface->remove_buddy = irc_remove_buddy; - iface->join_chat = irc_chat_join; - iface->get_chat_name = irc_get_chat_name; - iface->chat_invite = irc_chat_invite; - iface->chat_leave = irc_chat_leave; - iface->chat_send = irc_chat_send; - iface->keepalive = irc_keepalive; - iface->normalize = purple_normalize_nocase; - iface->set_chat_topic = irc_chat_set_topic; - iface->roomlist_get_list = irc_roomlist_get_list; - iface->roomlist_cancel = irc_roomlist_cancel; - iface->send_file = irc_dccsend_send_file; - iface->new_xfer = irc_dccsend_new_xfer; - iface->send_raw = irc_send_raw; + iface->get_actions = irc_get_actions; + iface->list_icon = irc_blist_icon; + iface->status_types = irc_status_types; + iface->chat_info = irc_chat_join_info; + iface->chat_info_defaults = irc_chat_info_defaults; + iface->login = irc_login; + iface->close = irc_close; + iface->send_im = irc_im_send; + iface->get_info = irc_get_info; + iface->set_status = irc_set_status; + iface->add_buddy = irc_add_buddy; + iface->remove_buddy = irc_remove_buddy; + iface->join_chat = irc_chat_join; + iface->get_chat_name = irc_get_chat_name; + iface->chat_invite = irc_chat_invite; + iface->chat_leave = irc_chat_leave; + iface->chat_send = irc_chat_send; + iface->keepalive = irc_keepalive; + iface->normalize = purple_normalize_nocase; + iface->set_chat_topic = irc_chat_set_topic; + iface->roomlist_get_list = irc_roomlist_get_list; + iface->roomlist_cancel = irc_roomlist_cancel; + iface->send_file = irc_dccsend_send_file; + iface->new_xfer = irc_dccsend_new_xfer; + iface->send_raw = irc_send_raw; + iface->get_max_message_size = irc_get_max_message_size; } static void irc_protocol_base_finalize(IRCProtocolClass *klass) { }
--- a/libpurple/protocols/msn/msn.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/msn/msn.c Tue Aug 27 04:30:39 2013 +0530 @@ -2865,6 +2865,12 @@ return FALSE; } +static gsize +msn_get_max_message_size(PurpleConnection *gc) +{ + /* pidgin-otr says: 1409 */ + return 1525 - strlen(VERSION); +} static PurpleProtocol protocol = { @@ -2941,7 +2947,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ msn_set_public_alias, /* set_public_alias */ - msn_get_public_alias /* get_public_alias */ + msn_get_public_alias, /* get_public_alias */ + msn_get_max_message_size /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/mxit/mxit.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/mxit/mxit.c Tue Aug 27 04:30:39 2013 +0530 @@ -797,7 +797,8 @@ mxit_media_caps, /* get_media_caps */ mxit_get_moods, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ };
--- a/libpurple/protocols/myspace/myspace.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/myspace/myspace.c Tue Aug 27 04:30:39 2013 +0530 @@ -3169,7 +3169,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ }; #ifdef MSIM_SELF_TEST
--- a/libpurple/protocols/novell/novell.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/novell/novell.c Tue Aug 27 04:30:39 2013 +0530 @@ -3476,6 +3476,13 @@ _check_for_disconnect(user, rc); } +static gsize +novell_get_max_message_size(PurpleConnection *gc) +{ + /* got from pidgin-otr */ + return 1792; +} + static PurpleProtocol protocol = { "prpl-novell", /* id */ "GroupWise", /* name */ @@ -3550,7 +3557,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + novell_get_max_message_size /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/null/nullprpl.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/null/nullprpl.c Tue Aug 27 04:30:39 2013 +0530 @@ -1136,7 +1136,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/oscar/libaim.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/oscar/libaim.c Tue Aug 27 04:30:39 2013 +0530 @@ -104,7 +104,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + oscar_get_max_message_size /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/oscar/libicq.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/oscar/libicq.c Tue Aug 27 04:30:39 2013 +0530 @@ -37,6 +37,13 @@ return table; } +static gsize +icq_get_max_message_size(PurpleConnection *gc) +{ + /* got from pidgin-otr */ + return 2346; +} + static PurpleProtocol protocol = { "prpl-icq", /* id */ @@ -112,7 +119,8 @@ NULL, /* can_do_media */ oscar_get_purple_moods, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + icq_get_max_message_size /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/oscar/oscar.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/oscar/oscar.c Tue Aug 27 04:30:39 2013 +0530 @@ -5434,6 +5434,13 @@ return TRUE; } +gsize +oscar_get_max_message_size(PurpleConnection *gc) +{ + /* got from pidgin-otr */ + return 2343; +} + /* TODO: Find somewhere to put this instead of including it in a bunch of places. * Maybe just change purple_accounts_find() to return anything for the prpl if there is no acct_id. */
--- a/libpurple/protocols/oscar/oscarcommon.h Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/oscar/oscarcommon.h Tue Aug 27 04:30:39 2013 +0530 @@ -102,5 +102,6 @@ void oscar_send_file(PurpleConnection *gc, const char *who, const char *file); PurpleXfer *oscar_new_xfer(PurpleConnection *gc, const char *who); gboolean oscar_offline_message(const PurpleBuddy *buddy); +gsize oscar_get_max_message_size(PurpleConnection *gc); GList *oscar_get_actions(PurpleConnection *gc); void oscar_init(PurpleProtocol *protocol, gboolean is_icq);
--- a/libpurple/protocols/silc/silc.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/silc/silc.c Tue Aug 27 04:30:39 2013 +0530 @@ -2128,7 +2128,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/simple/simple.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/simple/simple.c Tue Aug 27 04:30:39 2013 +0530 @@ -2121,7 +2121,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ }; static PurplePluginInfo *
--- a/libpurple/protocols/yahoo/libyahoo.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/yahoo/libyahoo.c Tue Aug 27 04:30:39 2013 +0530 @@ -261,7 +261,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + yahoo_get_max_message_size }; static PurplePluginInfo *
--- a/libpurple/protocols/yahoo/libyahoojp.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/yahoo/libyahoojp.c Tue Aug 27 04:30:39 2013 +0530 @@ -159,7 +159,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + yahoo_get_max_message_size }; static PurplePluginInfo *
--- a/libpurple/protocols/yahoo/libymsg.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/yahoo/libymsg.c Tue Aug 27 04:30:39 2013 +0530 @@ -5130,3 +5130,9 @@ return list; } +gsize +yahoo_get_max_message_size(PurpleConnection *gc) +{ + /* got from pidgin-otr */ + return 799; +}
--- a/libpurple/protocols/yahoo/libymsg.h Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/yahoo/libymsg.h Tue Aug 27 04:30:39 2013 +0530 @@ -384,6 +384,7 @@ GList *yahoo_get_actions(PurpleConnection *gc); void yahoopurple_register_commands(void); +gsize yahoo_get_max_message_size(PurpleConnection *gc); PurpleCmdRet yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data); PurpleCmdRet yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data);
--- a/libpurple/protocols/zephyr/zephyr.c Tue Aug 27 04:08:20 2013 +0530 +++ b/libpurple/protocols/zephyr/zephyr.c Tue Aug 27 04:30:39 2013 +0530 @@ -2940,7 +2940,8 @@ NULL, /* get_media_caps */ NULL, /* get_moods */ NULL, /* set_public_alias */ - NULL /* get_public_alias */ + NULL, /* get_public_alias */ + NULL /* get_max_message_size */ }; static PurplePluginInfo *plugin_query(GError **error)