/soc/2013/ankitkv/gobjectification: 0582190c9382: Merged soc.201...

Ankit Vani a at nevitus.org
Mon Aug 26 19:01:22 EDT 2013


Changeset: 0582190c9382586106ad646275228e9aa6d38b16
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-27 04:30 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/0582190c9382

Description:

Merged soc.2013.gobjectification branch

diffstat:

 libpurple/connection.c                  |  20 +++++++++++
 libpurple/connection.h                  |  12 ++++++
 libpurple/protocol.h                    |  19 ++++++++++
 libpurple/protocols/bonjour/bonjour.c   |  43 ++++++++++++++---------
 libpurple/protocols/gg/gg.c             |   8 ++++
 libpurple/protocols/irc/irc.c           |  58 ++++++++++++++++++--------------
 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/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 +-
 22 files changed, 177 insertions(+), 54 deletions(-)

diffs (truncated from 496 to 300 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -556,6 +556,26 @@ void purple_connection_update_last_recei
 	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
  **************************************************************************/
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -464,6 +464,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/protocol.h b/libpurple/protocol.h
--- a/libpurple/protocol.h
+++ b/libpurple/protocol.h
@@ -503,6 +503,21 @@ struct _PurpleProtocolInterface
 	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 @@ void purple_protocol_iface_get_public_al
                                 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
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
@@ -471,6 +471,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;
+}
+
 #ifdef WIN32
 static gboolean
 _set_default_name_cb(gpointer data) {
@@ -671,23 +679,24 @@ bonjour_protocol_base_finalize(BonjourPr
 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 *
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
@@ -1370,6 +1370,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 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 @@ ggp_protocol_interface_init(PurpleProtoc
 	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 *
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
@@ -915,6 +915,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 void
 irc_protocol_base_init(IRCProtocolClass *klass)
 {
@@ -981,31 +988,32 @@ irc_protocol_base_init(IRCProtocolClass 
 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) { }
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
@@ -2865,6 +2865,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 PurpleProtocol protocol =
 {
@@ -2941,7 +2947,8 @@ static PurpleProtocol protocol =
 	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 *
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
@@ -797,7 +797,8 @@ static PurpleProtocol proto_info = {
 	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
@@ -3169,7 +3169,8 @@ static PurpleProtocol protocol = {
 	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



More information about the Commits mailing list