/soc/2013/ankitkv/gobjectification: 3edd164b6a1a: Merged soc.201...

Ankit Vani a at nevitus.org
Sat Aug 31 13:49:28 EDT 2013


Changeset: 3edd164b6a1ae0a358d25b4d0f8fc2638060a099
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-31 23:12 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3edd164b6a1a

Description:

Merged soc.2013.gobjectification branch

diffstat:

 libpurple/connection.c                  |  10 ----------
 libpurple/connection.h                  |  12 ------------
 libpurple/conversation.c                |  21 +++++++++++++++++++++
 libpurple/conversation.h                |  12 ++++++++++++
 libpurple/protocol.c                    |   6 +++---
 libpurple/protocol.h                    |  18 +++++++++++-------
 libpurple/protocols/bonjour/bonjour.c   |   8 +++-----
 libpurple/protocols/gg/gg.c             |   6 +++---
 libpurple/protocols/irc/irc.c           |   7 ++++---
 libpurple/protocols/msn/msn.c           |   6 +++---
 libpurple/protocols/novell/novell.c     |   6 +++---
 libpurple/protocols/oscar/libicq.c      |   6 +++---
 libpurple/protocols/oscar/oscar.c       |   6 +++---
 libpurple/protocols/oscar/oscarcommon.h |   2 +-
 libpurple/protocols/yahoo/libymsg.c     |   7 +++----
 libpurple/protocols/yahoo/libymsg.h     |   2 +-
 16 files changed, 74 insertions(+), 61 deletions(-)

diffs (truncated from 317 to 300 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -555,16 +555,6 @@ void purple_connection_update_last_recei
 	priv->last_received = time(NULL);
 }
 
-gsize
-purple_connection_get_max_message_size(PurpleConnection *gc)
-{
-	PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
-
-	g_return_val_if_fail(priv != NULL, 0);
-
-	return purple_protocol_iface_get_max_message_size(priv->protocol, gc);
-}
-
 /**************************************************************************
  * GBoxed code
  **************************************************************************/
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -464,18 +464,6 @@ purple_connection_error_is_fatal (Purple
  */
 void purple_connection_update_last_received(PurpleConnection *gc);
 
-/**
- * Gets the maximum message size in bytes 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/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -886,6 +886,27 @@ purple_conversation_do_command(PurpleCon
 	return (status == PURPLE_CMD_STATUS_OK);
 }
 
+gssize
+purple_conversation_get_max_message_size(PurpleConversation *conv)
+{
+	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
+
+	g_return_val_if_fail(conv != NULL, 0);
+
+	prpl = purple_connection_get_prpl(
+		purple_conversation_get_connection(conv));
+	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(conv);
+}
+
 /**************************************************************************
  * GObject code
  **************************************************************************/
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -619,6 +619,18 @@ GList * purple_conversation_get_extended
 gboolean purple_conversation_do_command(PurpleConversation *conv,
 		const gchar *cmdline, const gchar *markup, gchar **error);
 
+/**
+ * Gets the maximum message size in bytes for the conversation.
+ *
+ * @see PurplePluginProtocolInfo#get_max_message_size
+ *
+ * @param conv The conversation to query.
+ *
+ * @return Maximum message size, 0 if unspecified, -1 for infinite.
+ */
+gssize
+purple_conversation_get_max_message_size(PurpleConversation *conv);
+
 /*@}*/
 
 /**************************************************************************/
diff --git a/libpurple/protocol.c b/libpurple/protocol.c
--- a/libpurple/protocol.c
+++ b/libpurple/protocol.c
@@ -723,10 +723,10 @@ purple_protocol_iface_get_public_alias(P
 	                     failure_cb);
 }
 
-gsize
+gssize
 purple_protocol_iface_get_max_message_size(PurpleProtocol *protocol,
-                                           PurpleConnection *gc)
+                                           PurpleConversation *conv)
 {
-	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, 0, get_max_message_size, gc);
+	DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, 0, get_max_message_size, conv);
 }
 
diff --git a/libpurple/protocol.h b/libpurple/protocol.h
--- a/libpurple/protocol.h
+++ b/libpurple/protocol.h
@@ -508,8 +508,10 @@ struct _PurpleProtocolInterface
 	                         PurpleGetPublicAliasFailureCallback failure_cb);
 
 	/**
-	 * Gets the maximum message size in bytes for the protocol. It may
-	 * depend on connection-specific variables (like protocol version).
+	 * Gets the maximum message size in bytes for the conversation.
+	 *
+	 * It may depend on connection-specific or conversation-specific
+	 * variables, like channel or buddy's name length.
 	 *
 	 * This value is intended for plaintext message, the exact value may be
 	 * lower because of:
@@ -517,10 +519,12 @@ struct _PurpleProtocolInterface
 	 *  - 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.
+	 * @param conv The conversation to query, or NULL to get safe minimum
+	 *             for the protocol.
+	 *
+	 * @return     Maximum message size, 0 if unspecified, -1 for infinite.
 	 */
-	gsize (*get_max_message_size)(PurpleConnection *gc);
+	gssize (*get_max_message_size)(PurpleConversation *conv);
 };
 
 /**
@@ -986,8 +990,8 @@ void purple_protocol_iface_get_public_al
                                 PurpleGetPublicAliasFailureCallback failure_cb);
 
 /** @copydoc  _PurpleProtocolInterface::get_max_message_size */
-gsize purple_protocol_iface_get_max_message_size(PurpleProtocol *,
-                                                 PurpleConnection *gc);
+gssize purple_protocol_iface_get_max_message_size(PurpleProtocol *,
+                                                  PurpleConversation *conv);
 
 /*@}*/
 
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,12 +471,10 @@ bonjour_can_receive_file(PurpleConnectio
 	return (buddy != NULL && purple_buddy_get_protocol_data(buddy) != NULL);
 }
 
-static gsize
-bonjour_get_max_message_size(PurpleConnection *gc)
+static gssize
+bonjour_get_max_message_size(PurpleConversation *conv)
 {
-	/* It looks, like the message length is practically unlimited (I've
-	 * tried 5MB). */
-	return 0;
+	return -1; /* 5MB successfully tested. */
 }
 
 #ifdef WIN32
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,10 +1370,10 @@ static GHashTable * ggp_get_account_text
 	return table;
 }
 
-static gsize
-ggp_get_max_message_size(PurpleConnection *gc)
+static gssize
+ggp_get_max_message_size(PurpleConversation *conv)
 {
-	/* it may depend on protocol version or other factors - check it */
+	/* TODO: it may depend on protocol version or other factors */
 	return 1232;
 }
 
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,10 +915,11 @@ static void irc_keepalive(PurpleConnecti
 		irc_cmd_ping(irc, NULL, NULL, NULL);
 }
 
-static gsize
-irc_get_max_message_size(PurpleConnection *gc)
+static gssize
+irc_get_max_message_size(PurpleConversation *conv)
 {
-	/* got from pidgin-otr */
+	/* TODO: this static value is got from pidgin-otr, but it depends on
+	 * some factors, for example IRC channel name. */
 	return 417;
 }
 
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
@@ -2867,10 +2867,10 @@ static gboolean msn_uri_handler(const ch
 	return FALSE;
 }
 
-static gsize
-msn_get_max_message_size(PurpleConnection *gc)
+static gssize
+msn_get_max_message_size(PurpleConversation *conv)
 {
-	/* pidgin-otr says: 1409 */
+	/* XXX: pidgin-otr says 1409. Verify and document it. */
 	return 1525 - strlen(VERSION);
 }
 
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
@@ -3477,10 +3477,10 @@ novell_keepalive(PurpleConnection *gc)
 	_check_for_disconnect(user, rc);
 }
 
-static gsize
-novell_get_max_message_size(PurpleConnection *gc)
+static gssize
+novell_get_max_message_size(PurpleConversation *conv)
 {
-	/* got from pidgin-otr */
+	/* XXX: got from pidgin-otr - verify and document it */
 	return 1792;
 }
 
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
@@ -42,10 +42,10 @@ icq_get_account_text_table(PurpleAccount
 	return table;
 }
 
-static gsize
-icq_get_max_message_size(PurpleConnection *gc)
+static gssize
+icq_get_max_message_size(PurpleConversation *conv)
 {
-	/* got from pidgin-otr */
+	/* XXX: got from pidgin-otr - verify and document it */
 	return 2346;
 }
 
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -5434,10 +5434,10 @@ oscar_offline_message(const PurpleBuddy 
 	return TRUE;
 }
 
-gsize
-oscar_get_max_message_size(PurpleConnection *gc)
+gssize
+oscar_get_max_message_size(PurpleConversation *conv)
 {
-	/* got from pidgin-otr */
+	/* XXX: got from pidgin-otr - verify and document it */
 	return 2343;
 }
 
diff --git a/libpurple/protocols/oscar/oscarcommon.h b/libpurple/protocols/oscar/oscarcommon.h
--- a/libpurple/protocols/oscar/oscarcommon.h
+++ b/libpurple/protocols/oscar/oscarcommon.h
@@ -102,7 +102,7 @@ gboolean oscar_can_receive_file(PurpleCo
 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);
+gssize oscar_get_max_message_size(PurpleConversation *conv);
 GList *oscar_get_actions(PurpleConnection *gc);
 const gchar *oscar_get_login_server(gboolean is_icq, gboolean use_ssl);
 gboolean oscar_uri_handler(const char *proto, const char *cmd, GHashTable *params);
diff --git a/libpurple/protocols/yahoo/libymsg.c b/libpurple/protocols/yahoo/libymsg.c
--- a/libpurple/protocols/yahoo/libymsg.c
+++ b/libpurple/protocols/yahoo/libymsg.c
@@ -5130,9 +5130,8 @@ GList *yahoo_attention_types(PurpleAccou
 	return list;
 }
 
-gsize
-yahoo_get_max_message_size(PurpleConnection *gc)
+gssize
+yahoo_get_max_message_size(PurpleConversation *conv)



More information about the Commits mailing list