/pidgin/main: 4461d5c1e61c: Extend prpl with max message length ...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Mon Aug 26 11:21:35 EDT 2013
Changeset: 4461d5c1e61c6df539fb6fc48d9fc5547ae1f904
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-08-26 17:21 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/4461d5c1e61c
Description:
Extend prpl with max message length callback
diffstat:
libpurple/connection.c | 20 ++++++++++++++++++++
libpurple/connection.h | 12 ++++++++++++
libpurple/protocols/bonjour/bonjour.c | 11 ++++++++++-
libpurple/protocols/gg/gg.c | 10 +++++++++-
libpurple/protocols/irc/irc.c | 10 +++++++++-
libpurple/protocols/jabber/libfacebook.c | 3 ++-
libpurple/protocols/jabber/libgtalk.c | 3 ++-
libpurple/protocols/jabber/libxmpp.c | 3 ++-
libpurple/protocols/msn/msn.c | 9 ++++++++-
libpurple/protocols/mxit/mxit.c | 3 ++-
libpurple/protocols/myspace/myspace.c | 3 ++-
libpurple/protocols/novell/novell.c | 10 +++++++++-
libpurple/protocols/null/nullprpl.c | 3 ++-
libpurple/protocols/oscar/libaim.c | 3 ++-
libpurple/protocols/oscar/libicq.c | 10 +++++++++-
libpurple/protocols/oscar/oscar.c | 7 +++++++
libpurple/protocols/oscar/oscarcommon.h | 1 +
libpurple/protocols/sametime/sametime.c | 1 +
libpurple/protocols/silc/silc.c | 3 ++-
libpurple/protocols/simple/simple.c | 3 ++-
libpurple/protocols/yahoo/libyahoo.c | 3 ++-
libpurple/protocols/yahoo/libyahoojp.c | 3 ++-
libpurple/protocols/yahoo/libymsg.c | 6 ++++++
libpurple/protocols/yahoo/libymsg.h | 1 +
libpurple/protocols/zephyr/zephyr.c | 3 ++-
libpurple/prpl.h | 15 +++++++++++++++
26 files changed, 141 insertions(+), 18 deletions(-)
diffs (truncated from 457 to 300 lines):
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -631,6 +631,26 @@ void purple_connection_update_last_recei
gc->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);
+}
+
void
purple_connections_disconnect_all(void)
{
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -452,6 +452,18 @@ purple_connection_error_is_fatal (Purple
*/
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);
+
/*@}*/
/**************************************************************************/
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -470,6 +470,14 @@ bonjour_can_receive_file(PurpleConnectio
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;
+}
+
static gboolean
plugin_unload(PurplePlugin *plugin)
{
@@ -555,7 +563,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* get_media_caps */
NULL, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ bonjour_get_max_message_size /* get_max_message_size */
};
static PurplePluginInfo info =
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -1369,6 +1369,13 @@ static GHashTable * ggp_get_account_text
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 PurplePluginProtocolInfo prpl_info =
{
sizeof(PurplePluginProtocolInfo), /* struct_size */
@@ -1441,7 +1448,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* can_do_media */
NULL, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ ggp_get_max_message_size /* get_max_message_size */
};
static gboolean ggp_load(PurplePlugin *plugin);
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -911,6 +911,13 @@ static void irc_keepalive(PurpleConnecti
irc_cmd_ping(irc, NULL, NULL, NULL);
}
+static gsize
+irc_get_max_message_size(PurpleConnection *gc)
+{
+ /* got from pidgin-otr */
+ return 417;
+}
+
static PurplePluginProtocolInfo prpl_info =
{
sizeof(PurplePluginProtocolInfo), /* struct_size */
@@ -984,7 +991,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* get_media_caps */
NULL, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ irc_get_max_message_size /* get_max_message_size */
};
static gboolean load_plugin (PurplePlugin *plugin) {
diff --git a/libpurple/protocols/jabber/libfacebook.c b/libpurple/protocols/jabber/libfacebook.c
--- a/libpurple/protocols/jabber/libfacebook.c
+++ b/libpurple/protocols/jabber/libfacebook.c
@@ -133,7 +133,8 @@ static PurplePluginProtocolInfo prpl_inf
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 gboolean load_plugin(PurplePlugin *plugin)
diff --git a/libpurple/protocols/jabber/libgtalk.c b/libpurple/protocols/jabber/libgtalk.c
--- a/libpurple/protocols/jabber/libgtalk.c
+++ b/libpurple/protocols/jabber/libgtalk.c
@@ -133,7 +133,8 @@ static PurplePluginProtocolInfo prpl_inf
jabber_get_media_caps, /* get_media_caps */
jabber_get_moods, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ NULL /* get_max_message_size */
};
static gboolean load_plugin(PurplePlugin *plugin)
diff --git a/libpurple/protocols/jabber/libxmpp.c b/libpurple/protocols/jabber/libxmpp.c
--- a/libpurple/protocols/jabber/libxmpp.c
+++ b/libpurple/protocols/jabber/libxmpp.c
@@ -127,7 +127,8 @@ static PurplePluginProtocolInfo prpl_inf
jabber_get_media_caps, /* get_media_caps */
jabber_get_moods, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ NULL /* get_max_message_size */
};
static gboolean load_plugin(PurplePlugin *plugin)
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2882,6 +2882,12 @@ static gboolean msn_uri_handler(const ch
return FALSE;
}
+static gsize
+msn_get_max_message_size(PurpleConnection *gc)
+{
+ /* pidgin-otr says: 1409 */
+ return 1525 - strlen(VERSION);
+}
static PurplePluginProtocolInfo prpl_info =
{
@@ -2955,7 +2961,8 @@ static PurplePluginProtocolInfo prpl_inf
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 info =
diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -793,7 +793,8 @@ static PurplePluginProtocolInfo proto_in
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 */
};
diff --git a/libpurple/protocols/myspace/myspace.c b/libpurple/protocols/myspace/myspace.c
--- a/libpurple/protocols/myspace/myspace.c
+++ b/libpurple/protocols/myspace/myspace.c
@@ -3080,7 +3080,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* get_media_caps */
NULL, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
+ NULL, /* get_public_alias */
+ NULL /* get_max_message_size */
};
/**
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -3465,6 +3465,13 @@ novell_keepalive(PurpleConnection *gc)
_check_for_disconnect(user, rc);
}
+static gsize
+novell_get_max_message_size(PurpleConnection *gc)
+{
+ /* got from pidgin-otr */
+ return 1792;
+}
+
static PurplePluginProtocolInfo prpl_info = {
sizeof(PurplePluginProtocolInfo), /* struct_size */
0,
@@ -3536,7 +3543,8 @@ static PurplePluginProtocolInfo prpl_inf
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 info = {
diff --git a/libpurple/protocols/null/nullprpl.c b/libpurple/protocols/null/nullprpl.c
--- a/libpurple/protocols/null/nullprpl.c
+++ b/libpurple/protocols/null/nullprpl.c
@@ -1130,7 +1130,8 @@ static PurplePluginProtocolInfo prpl_inf
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 void nullprpl_init(PurplePlugin *plugin)
diff --git a/libpurple/protocols/oscar/libaim.c b/libpurple/protocols/oscar/libaim.c
--- a/libpurple/protocols/oscar/libaim.c
+++ b/libpurple/protocols/oscar/libaim.c
@@ -99,7 +99,8 @@ static PurplePluginProtocolInfo prpl_inf
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 info =
diff --git a/libpurple/protocols/oscar/libicq.c b/libpurple/protocols/oscar/libicq.c
--- a/libpurple/protocols/oscar/libicq.c
+++ b/libpurple/protocols/oscar/libicq.c
@@ -36,6 +36,13 @@ icq_get_account_text_table(PurpleAccount
return table;
}
+static gsize
+icq_get_max_message_size(PurpleConnection *gc)
+{
+ /* got from pidgin-otr */
+ return 2346;
+}
+
static PurplePluginProtocolInfo prpl_info =
{
sizeof(PurplePluginProtocolInfo), /* struct_size */
@@ -108,7 +115,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* can_do_media */
oscar_get_purple_moods, /* get_moods */
NULL, /* set_public_alias */
- NULL /* get_public_alias */
More information about the Commits
mailing list