/pidgin/main: 0e8bb1df9718: Update internal libgadu to 1.12.0

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon Jun 16 17:01:57 EDT 2014


Changeset: 0e8bb1df971889308ea53ff26527f58556b6bbaa
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-06-16 23:01 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/0e8bb1df9718

Description:

Update internal libgadu to 1.12.0

diffstat:

 ChangeLog                             |    2 +-
 configure.ac                          |    6 +-
 libpurple/protocols/gg/lib/config.h   |    6 +-
 libpurple/protocols/gg/lib/dcc7.c     |    2 +-
 libpurple/protocols/gg/lib/fileio.h   |    6 +
 libpurple/protocols/gg/lib/handlers.c |   26 +++-
 libpurple/protocols/gg/lib/internal.h |   28 +++++-
 libpurple/protocols/gg/lib/libgadu.c  |  160 ++++++++++++++++++++++++++-------
 libpurple/protocols/gg/lib/libgadu.h  |    2 +-
 libpurple/protocols/gg/lib/resolver.c |    6 +-
 libpurple/protocols/gg/lib/resolver.h |    1 +
 11 files changed, 193 insertions(+), 52 deletions(-)

diffs (truncated from 538 to 300 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,7 +13,7 @@ version 2.10.10 (?/?/?):
 	* Fix build against Python 3. (Ed Catmur) (#15969)
 
 	Gadu-Gadu:
-	* Updated internal libgadu to version 1.12.0-rc2.
+	* Updated internal libgadu to version 1.12.0.
 
 	IRC:
 	* Fix a possible leak of unencrypted data when using /me command
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1035,7 +1035,7 @@ else
 	gadu_manual_check="no"
 fi
 if test "x$gadu_manual_check" = "xno"; then
-	PKG_CHECK_MODULES(GADU, [libgadu >= 1.11.0], [
+	PKG_CHECK_MODULES(GADU, [libgadu >= 1.12.0], [
 		gadu_includes="yes"
 		gadu_libs="yes"
 	], [
@@ -1069,7 +1069,7 @@ if test "x$gadu_libs" = "xyes"; then
 	]])], [
 		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libgadu.h>]], [[
 #if GG_DEFAULT_PROTOCOL_VERSION < 0x2e
-#error "Your libgadu version is too old. libpurple requires 1.11.0 or higher."
+#error "Your libgadu version is too old. libpurple requires 1.12.0 or higher."
 #endif
 		]])], [
 			AC_MSG_RESULT(yes)
@@ -1080,7 +1080,7 @@ if test "x$gadu_libs" = "xyes"; then
 			echo
 			echo
 			echo "Your supplied copy of libgadu is too old."
-			echo "Install version 1.11.0 or newer."
+			echo "Install version 1.12.0 or newer."
 			echo "Then rerun this ./configure"
 			echo
 			echo "Falling back to using our own copy of libgadu"
diff --git a/libpurple/protocols/gg/lib/config.h b/libpurple/protocols/gg/lib/config.h
--- a/libpurple/protocols/gg/lib/config.h
+++ b/libpurple/protocols/gg/lib/config.h
@@ -5,7 +5,7 @@
 /* libpurple's config */
 #include <config.h>
 
-#define GG_LIBGADU_VERSION "1.12.0-rc2"
+#define GG_LIBGADU_VERSION "1.12.0"
 
 /* Defined if libgadu was compiled for bigendian machine. */
 #undef GG_CONFIG_BIGENDIAN
@@ -87,3 +87,7 @@
 
 /* Defined if libgadu uses system defalt trusted CAs. */
 #define GG_CONFIG_SSL_SYSTEM_TRUST
+
+/* Defined if libgadu is GPL compliant (was not linked with OpenSSL or any
+   other non-GPL compliant library support). */
+#define GG_CONFIG_IS_GPL_COMPLIANT
diff --git a/libpurple/protocols/gg/lib/dcc7.c b/libpurple/protocols/gg/lib/dcc7.c
--- a/libpurple/protocols/gg/lib/dcc7.c
+++ b/libpurple/protocols/gg/lib/dcc7.c
@@ -1540,7 +1540,7 @@ struct gg_event *gg_dcc7_watch_fd(struct
 
 			if (gg_fix32(pkt->magic) != GG_DCC7_RELAY_REPLY ||
 				gg_fix32(pkt->rcount) < 1 ||
-				gg_fix32(pkt->rcount > 256) ||
+				gg_fix32(pkt->rcount) > 256 ||
 				gg_fix32(pkt->len) < sizeof(*pkt) +
 				gg_fix32(pkt->rcount) * sizeof(srv))
 			{
diff --git a/libpurple/protocols/gg/lib/fileio.h b/libpurple/protocols/gg/lib/fileio.h
--- a/libpurple/protocols/gg/lib/fileio.h
+++ b/libpurple/protocols/gg/lib/fileio.h
@@ -34,11 +34,17 @@
 #ifdef _WIN32
 #  include <io.h>
 #  define gg_file_close _close
+#  undef lseek
 #  define lseek _lseek
+#  undef open
 #  define open _open
+#  undef read
 #  define read _read
+#  undef stat
 #  define stat _stat
+#  undef fstat
 #  define fstat _fstat
+#  undef write
 #  define write _write
 #  define S_IRWXO 0
 #  define S_IRWXG 0
diff --git a/libpurple/protocols/gg/lib/handlers.c b/libpurple/protocols/gg/lib/handlers.c
--- a/libpurple/protocols/gg/lib/handlers.c
+++ b/libpurple/protocols/gg/lib/handlers.c
@@ -405,6 +405,7 @@ static int gg_session_handle_login_faile
 static int gg_session_handle_send_msg_ack(struct gg_session *gs, uint32_t type,
 	const char *ptr, size_t len, struct gg_event *ge)
 {
+	struct gg_session_private *p = gs->private_data;
 	const struct gg_send_msg_ack *s = (const struct gg_send_msg_ack*) ptr;
 
 	gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received a message ack\n");
@@ -414,6 +415,10 @@ static int gg_session_handle_send_msg_ac
 	ge->event.ack.recipient = gg_fix32(s->recipient);
 	ge->event.ack.seq = gg_fix32(s->seq);
 
+	if (ge->event.ack.seq == 0 && p->imgout_waiting_ack > 0)
+		p->imgout_waiting_ack--;
+	gg_image_sendout(gs);
+
 	return 0;
 }
 
@@ -423,6 +428,7 @@ static int gg_session_handle_send_msg_ac
 static int gg_session_handle_send_msg_ack_110(struct gg_session *gs,
 	uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
 {
+	struct gg_session_private *p = gs->private_data;
 	GG110MessageAck *msg = gg110_message_ack__unpack(NULL, len, (uint8_t*)ptr);
 	size_t i;
 
@@ -435,11 +441,11 @@ static int gg_session_handle_send_msg_ac
 		 */
 		gg_debug_session(gs, GG_DEBUG_MISC | GG_DEBUG_WARNING,
 			"// gg_session_handle_send_msg_ack_110() magic dummy1 "
-			"value 0x4000");
+			"value 0x4000\n");
 	} else if (msg->dummy1 != 0) {
 		gg_debug_session(gs, GG_DEBUG_MISC | GG_DEBUG_WARNING,
 			"// gg_session_handle_send_msg_ack_110() unknown dummy1 "
-			"value: %x", msg->dummy1);
+			"value: %x\n", msg->dummy1);
 	}
 
 	gg_debug_session(gs, GG_DEBUG_VERBOSE,
@@ -466,6 +472,10 @@ static int gg_session_handle_send_msg_ac
 
 	gg110_message_ack__free_unpacked(msg, NULL);
 
+	if (msg->seq == 0 && p->imgout_waiting_ack > 0)
+		p->imgout_waiting_ack--;
+	gg_image_sendout(gs);
+
 	return 0;
 }
 
@@ -1388,13 +1398,13 @@ static int gg_session_handle_recv_msg_11
 		if (msg->data.len < sizeof(struct gg_msg_image_reply)) {
 			gg_debug_session(gs, GG_DEBUG_ERROR,
 				"// gg_session_handle_recv_msg_110() "
-				"packet too small\n");
-			return -1;
+				"packet too small (%" GG_SIZE_FMT " < %"
+				GG_SIZE_FMT ")\n", msg->data.len,
+				sizeof(struct gg_msg_image_reply));
+		} else {
+			gg_image_queue_parse(ge, (char *)msg->data.data,
+				msg->data.len, gs, sender, type);
 		}
-
-		gg_image_queue_parse(ge, (char *)msg->data.data, msg->data.len,
-			gs, sender, type);
-
 		gg110_recv_message__free_unpacked(msg, NULL);
 		return gg_ack_110(gs, GG110_ACK__TYPE__MSG, seq, ge);
 	}
diff --git a/libpurple/protocols/gg/lib/internal.h b/libpurple/protocols/gg/lib/internal.h
--- a/libpurple/protocols/gg/lib/internal.h
+++ b/libpurple/protocols/gg/lib/internal.h
@@ -27,8 +27,16 @@
 #define GG_DEFAULT_CLIENT_VERSION_110 "11.3.45.10771"
 
 #ifdef _WIN32
-#  define GG_SIZE_FMT "Iu"
-#  define _GG_INT64_MODIFIER "I64"
+#  ifdef __COVERITY__
+#    define GG_SIZE_FMT "lu"
+#    define _GG_INT64_MODIFIER "ll"
+#    undef PRIu64
+#    undef PRIx64
+#    undef PRId64
+#  else
+#    define GG_SIZE_FMT "Iu"
+#    define _GG_INT64_MODIFIER "I64"
+#  endif
 #elif defined(_LP64)
 #  define GG_SIZE_FMT "zu"
 #  define _GG_INT64_MODIFIER "l"
@@ -66,6 +74,8 @@
 	[(condition) ? 1 : -1]; static_assertion_failed_ ## message dummy; \
 	(void)dummy; }
 
+#define GG_IMGOUT_WAITING_MAX 4
+
 struct gg_dcc7_relay {
 	uint32_t addr;
 	uint16_t port;
@@ -98,6 +108,15 @@ struct _gg_eventqueue {
 	gg_eventqueue_t *next;
 };
 
+typedef struct _gg_imgout_queue_t gg_imgout_queue_t;
+struct _gg_imgout_queue_t {
+	struct gg_send_msg msg_hdr;
+	char buf[1910];
+	size_t buf_len;
+
+	gg_imgout_queue_t *next;
+};
+
 struct gg_session_private {
 	gg_compat_t compatibility;
 
@@ -108,6 +127,9 @@ struct gg_session_private {
 	int check_after_queue;
 	int fd_after_queue;
 
+	gg_imgout_queue_t *imgout_queue;
+	int imgout_waiting_ack;
+
 	gg_socket_manager_type_t socket_manager_type;
 	gg_socket_manager_t socket_manager;
 	void *socket_handle;
@@ -164,6 +186,8 @@ struct gg_event *gg_eventqueue_add(struc
 
 void gg_compat_message_ack(struct gg_session *sess, int seq);
 
+void gg_image_sendout(struct gg_session *sess);
+
 void gg_strarr_free(char **strarr);
 char ** gg_strarr_dup(char **strarr);
 
diff --git a/libpurple/protocols/gg/lib/libgadu.c b/libpurple/protocols/gg/lib/libgadu.c
--- a/libpurple/protocols/gg/lib/libgadu.c
+++ b/libpurple/protocols/gg/lib/libgadu.c
@@ -530,6 +530,12 @@ void gg_close(struct gg_session *sess)
 		p->event_queue = next;
 	}
 
+	while (p->imgout_queue) {
+		gg_imgout_queue_t *next = p->imgout_queue->next;
+		free(p->imgout_queue);
+		p->imgout_queue = next;
+	}
+
 	if (p->dummyfds_created) {
 		close(p->dummyfds[0]);
 		close(p->dummyfds[1]);
@@ -985,7 +991,8 @@ struct gg_session *gg_login(const struct
 	} else
 		sess->protocol_version = p->protocol_version;
 
-	sess->client_version = (p->client_version) ? strdup(p->client_version) : NULL;
+	if (p->client_version && strcmp(p->client_version, "-") != 0)
+		sess->client_version = strdup(p->client_version);
 	sess->last_sysmsg = p->last_sysmsg;
 	sess->image_size = p->image_size;
 	sess->pid = -1;
@@ -1510,6 +1517,32 @@ static int gg_send_message_110(struct gg
 	return succ ? seq : -1;
 }
 
+static char *
+gg_message_legacy_text_to_html(const char *src, gg_encoding_t encoding,
+	const unsigned char *format, size_t format_len)
+{
+	size_t len;
+	char *dst;
+
+	if (format == NULL || format_len <= 3) {
+		format = NULL;
+		format_len = 0;
+	} else {
+		format += 3;
+		format_len -= 3;
+	}
+
+	len = gg_message_text_to_html(NULL, src, encoding, format, format_len);
+
+	dst = malloc(len + 1);
+	if (dst == NULL)
+		return NULL;
+
+	gg_message_text_to_html(dst, src, encoding, format, format_len);
+
+	return dst;
+}
+
 /**
  * \internal Wysyła wiadomość.
  *
@@ -1567,6 +1600,21 @@ static int gg_send_message_common(struct
 		recipients_count == 1)
 	{
 		int is_html = (html_message != NULL);
+		char *formatted_msg = NULL;



More information about the Commits mailing list