changeset 30977:054309e46786

merge of '2b6c5a292658681aecfbe9f0c7f67cf62cfb28ec' and 'e010a6a5ac862c38a6a99db5b6981a985f9b7fb6'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 28 Nov 2010 08:22:09 +0000
parents 0fa095abebd4 (current diff) 7300259608c9 (diff)
children 2a9327053398
files
diffstat 14 files changed, 160 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 27 19:58:15 2010 +0000
+++ b/ChangeLog	Sun Nov 28 08:22:09 2010 +0000
@@ -1,8 +1,23 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
 version 2.7.8 (??/??/????):
+	General:
+	* Fix the exceptions in purple-remote on Python 2.6+. (Ari Pollak)
+	  (#12151)
+
+	libpurple:
+	* Fix multipart parsing when '=' is included in the boundary for
+	  purple_mime_document_parse. (Jakub Adam) (#11598)
+
+	Gadu-Gadu:
+	* Updated our bundled libgadu and minimum requirement for external
+	  libgadu to 1.9.0. (#12789)
+
 	MSN:
-	* Don't show ourselves in the list of endpoints that can be disconnected.
+	* Stop showing ourselves in the list of endpoints that can be
+	  disconnected.
+	* Allow full-size display names, by not escaping (most) non-English
+	  characters. (#8508)
 
 version 2.7.7 (11/23/2010):
 	General:
--- a/configure.ac	Sat Nov 27 19:58:15 2010 +0000
+++ b/configure.ac	Sun Nov 28 08:22:09 2010 +0000
@@ -1046,7 +1046,7 @@
 	gadu_manual_check="no"
 fi
 if test "x$gadu_manual_check" = "xno"; then
-	PKG_CHECK_MODULES(GADU, [libgadu >= 1.9.0-rc2], [
+	PKG_CHECK_MODULES(GADU, [libgadu >= 1.9.0], [
 		gadu_includes="yes"
 		gadu_libs="yes"
 	], [
--- a/libpurple/mime.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/mime.c	Sun Nov 28 08:22:09 2010 +0000
@@ -436,6 +436,34 @@
 	g_free(bnd);
 }
 
+#define BOUNDARY "boundary="
+static char *
+parse_boundary(const char *ct)
+{
+	char *boundary_begin = g_strstr_len(ct, -1, BOUNDARY);
+	char *boundary_end;
+
+	if (!boundary_begin)
+		return NULL;
+
+	boundary_begin += sizeof(BOUNDARY) - 1;
+
+	if (*boundary_begin == '"') {
+		boundary_end = strchr(++boundary_begin, '"');
+		if (!boundary_end)
+			return NULL;
+	} else {
+		boundary_end = strchr(boundary_begin, ' ');
+		if (!boundary_end) {
+			boundary_end = strchr(boundary_begin, ';');
+			if (!boundary_end)
+				boundary_end = boundary_begin + strlen(boundary_begin);
+		}
+	}
+
+	return g_strndup(boundary_begin, boundary_end - boundary_begin);
+}
+#undef BOUNDARY
 
 PurpleMimeDocument *
 purple_mime_document_parsen(const char *buf, gsize len)
@@ -456,10 +484,11 @@
 
 	{
 		const char *ct = fields_get(&doc->fields, "content-type");
-		if(ct && purple_str_has_prefix(ct, "multipart")) {
-			char *bd = strrchr(ct, '=');
-			if(bd++) {
+		if (ct && purple_str_has_prefix(ct, "multipart")) {
+			char *bd = parse_boundary(ct);
+			if (bd) {
 				doc_parts_load(doc, bd, b, n);
+				g_free(bd);
 			}
 		}
 	}
--- a/libpurple/protocols/gg/lib/dcc7.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/gg/lib/dcc7.c	Sun Nov 28 08:22:09 2010 +0000
@@ -731,6 +731,7 @@
 		e->event.dcc7_accept.remote_port = dcc->remote_port;
 	} else {
 		e->type = GG_EVENT_DCC7_PENDING;
+		e->event.dcc7_pending.dcc7 = dcc;
 	}
 
 	if (gg_dcc7_connect(sess, dcc) == -1) {
@@ -1004,6 +1005,7 @@
 
 				if (gg_dcc7_reverse_connect(dcc) != -1) {
 					e->type = GG_EVENT_DCC7_PENDING;
+					e->event.dcc7_pending.dcc7 = dcc;
 				} else {
 					e->type = GG_EVENT_DCC7_ERROR;
 					e->event.dcc_error = GG_ERROR_DCC7_NET;
--- a/libpurple/protocols/gg/lib/events.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/gg/lib/events.c	Sun Nov 28 08:22:09 2010 +0000
@@ -1149,6 +1149,7 @@
 
 			e->type = GG_EVENT_NOTIFY60;
 			e->event.notify60 = malloc(sizeof(*e->event.notify60));
+
 			if (!e->event.notify60) {
 				gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd_connected() not enough memory for notify data\n");
 				goto fail;
@@ -1159,7 +1160,7 @@
 			while (length >= sizeof(struct gg_notify_reply80)) {
 				uint32_t descr_len;
 				char *tmp;
-				
+
 				e->event.notify60[i].uin	= gg_fix32(n->uin);
 				e->event.notify60[i].status	= gg_fix32(n->status);
 				e->event.notify60[i].remote_ip	= n->remote_ip;
@@ -1169,7 +1170,6 @@
 				e->event.notify60[i].version	= 0x00;	/* not-supported */
 				e->event.notify60[i].time	= 0;	/* not-supported */
 
-				
 				descr_len = gg_fix32(n->descr_len);
 
 				length -= sizeof(struct gg_notify_reply80);
--- a/libpurple/protocols/gg/lib/libgadu.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/gg/lib/libgadu.c	Sun Nov 28 08:22:09 2010 +0000
@@ -69,7 +69,7 @@
 #  include <openssl/rand.h>
 #endif
 
-#define GG_LIBGADU_VERSION "1.9.0-rc2"
+#define GG_LIBGADU_VERSION "1.9.0"
 
 /**
  * Poziom rejestracji informacji odpluskwiających. Zmienna jest maską bitową
@@ -180,7 +180,7 @@
 #ifdef __GNUC__
 __attribute__ ((unused))
 #endif
-= "$Id: libgadu.c 878 2009-11-16 23:48:19Z wojtekka $";
+= "$Id: libgadu.c 923 2010-03-09 20:03:29Z wojtekka $";
 #endif
 
 #endif /* DOXYGEN */
@@ -1316,41 +1316,65 @@
  * \internal Zamienia tekst z formatowaniem Gadu-Gadu na HTML.
  *
  * \param dst Bufor wynikowy (może być \c NULL)
- * \param utf_msg Tekst źródłowy
+ * \param src Tekst źródłowy w UTF-8
  * \param format Atrybuty tekstu źródłowego
  * \param format_len Długość bloku atrybutów tekstu źródłowego
  *
+ * \note Wynikowy tekst nie jest idealnym kodem HTML, ponieważ ma jak
+ * dokładniej odzwierciedlać to, co wygenerowałby oryginalny klient.
+ *
  * \note Dokleja \c \\0 na końcu bufora wynikowego.
  *
  * \return Długość tekstu wynikowego bez \c \\0 (nawet jeśli \c dst to \c NULL).
  */
-static int gg_convert_to_html(char *dst, const char *utf_msg, const unsigned char *format, int format_len)
+static int gg_convert_to_html(char *dst, const char *src, const unsigned char *format, int format_len)
 {
 	const char span_fmt[] = "<span style=\"color:#%02x%02x%02x; font-family:'MS Shell Dlg 2'; font-size:9pt; \">";
 	const int span_len = 75;
-	const char img_fmt[] = "<img src=\"%02x%02x%02x%02x%02x%02x%02x%02x\">";
-	const int img_len = 28;
+	const char img_fmt[] = "<img name=\"%02x%02x%02x%02x%02x%02x%02x%02x\">";
+	const int img_len = 29;
 	int char_pos = 0;
-	int format_idx = 3;
+	int format_idx = 0;
 	unsigned char old_attr = 0;
 	const unsigned char *color = (const unsigned char*) "\x00\x00\x00";
 	int len, i;
 
 	len = 0;
 
-	for (i = 0; utf_msg[i] != 0; i++) {
-		unsigned char attr;
-		int attr_pos;
+	/* Nie mamy atrybutów dla pierwsze znaku, a tekst nie jest pusty, więc
+	 * tak czy inaczej trzeba otworzyć <span>. */
+
+	if (src[0] != 0 && (format_idx + 3 > format_len || (format[format_idx] | (format[format_idx + 1] << 8)) != 0)) {
+		if (dst != NULL)
+			sprintf(&dst[len], span_fmt, 0, 0, 0);
+
+		len += span_len;
+	}
+
+	/* Pętla przechodzi też przez kończące \0, żeby móc dokleić obrazek
+	 * na końcu tekstu. */
 
-		if (format_idx + 3 <= format_len) {
+	for (i = 0; ; i++) {
+		/* Analizuj atrybuty tak długo jak dotyczą aktualnego znaku. */
+		for (;;) {
+			unsigned char attr;
+			int attr_pos;
+
+			if (format_idx + 3 > format_len)
+				break;
+
 			attr_pos = format[format_idx] | (format[format_idx + 1] << 8);
+
+			if (attr_pos != char_pos)
+				break;
+
 			attr = format[format_idx + 2];
-		} else {
-			attr_pos = -1;
-			attr = 0;
-		}
+
+			/* Nie doklejaj atrybutów na końcu, co najwyżej obrazki. */
 
-		if (attr_pos == char_pos) {
+			if (src[i] == 0)
+				attr &= ~(GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR);
+
 			format_idx += 3;
 
 			if ((attr & (GG_FONT_BOLD | GG_FONT_ITALIC | GG_FONT_UNDERLINE | GG_FONT_COLOR)) != 0) {
@@ -1377,7 +1401,7 @@
 				if (dst != NULL)
 					sprintf(&dst[len], span_fmt, color[0], color[1], color[2]);
 				len += span_len;
-			} else if (char_pos == 0) {
+			} else if (char_pos == 0 && src[0] != 0) {
 				if (dst != NULL)
 					sprintf(&dst[len], span_fmt, 0, 0, 0);
 				len += span_len;
@@ -1410,14 +1434,11 @@
 			}
 
 			old_attr = attr;
-		} else if (i == 0) {
-			if (dst != NULL)
-				sprintf(&dst[len], span_fmt, 0, 0, 0);
-
-			len += span_len;
 		}
 
-		switch (utf_msg[i]) {
+		/* Doklej znak zachowując htmlowe escapowanie. */
+
+		switch (src[i]) {
 			case '&':
 				gg_append(dst, &len, "&amp;", 5);
 				break;
@@ -1437,19 +1458,25 @@
 				gg_append(dst, &len, "<br>", 4);
 				break;
 			case '\r':
+			case 0:
 				break;
 			default:
 				if (dst != NULL)
-					dst[len] = utf_msg[i];
+					dst[len] = src[i];
 				len++;
 		}
 
 		/* Sprawdź, czy bajt nie jest kontynuacją znaku unikodowego. */
 
-		if ((utf_msg[i] & 0xc0) != 0xc0)
+		if ((src[i] & 0xc0) != 0xc0)
 			char_pos++;
+
+		if (src[i] == 0)
+			break;
 	}
 
+	/* Zamknij tagi. */
+
 	if ((old_attr & GG_FONT_UNDERLINE) != 0)
 		gg_append(dst, &len, "</u>", 4);
 
@@ -1459,16 +1486,8 @@
 	if ((old_attr & GG_FONT_BOLD) != 0)
 		gg_append(dst, &len, "</b>", 4);
 
-	/* Dla pustych tekstów dodaj pusty <span>. */
-
-	if (i == 0) {
-		if (dst != NULL)
-			sprintf(&dst[len], span_fmt, 0, 0, 0);
-
-		len += span_len;
-	}
-
-	gg_append(dst, &len, "</span>", 7);
+	if (src[0] != 0)
+		gg_append(dst, &len, "</span>", 7);
 
 	if (dst != NULL)
 		dst[len] = 0;
@@ -1564,7 +1583,7 @@
 			formatlen = 9;
 		}
 
-		len = gg_convert_to_html(NULL, utf_msg, format, formatlen);
+		len = gg_convert_to_html(NULL, utf_msg, format + 3, formatlen - 3);
 
 		html_msg = malloc(len + 1);
 
@@ -1573,7 +1592,7 @@
 			goto cleanup;
 		}
 
-		gg_convert_to_html(html_msg, utf_msg, format, formatlen);
+		gg_convert_to_html(html_msg, utf_msg, format + 3, formatlen - 3);
 
 		s80.seq = gg_fix32(seq_no);
 		s80.msgclass = gg_fix32(msgclass);
--- a/libpurple/protocols/gg/lib/libgadu.h	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/gg/lib/libgadu.h	Sun Nov 28 08:22:09 2010 +0000
@@ -865,6 +865,13 @@
 };
 
 /**
+ * Opis zdarzenia \c GG_EVENT_DCC7_PENDING.
+ */
+struct gg_event_dcc7_pending {
+	struct gg_dcc7 *dcc7;	/**< Struktura połączenia */
+};
+
+/**
  * Opis zdarzenia \c GG_EVENT_DCC7_REJECT.
  */
 struct gg_event_dcc7_reject {
@@ -908,6 +915,7 @@
 	struct gg_dcc7 *dcc7_new;	/**< Nowe połączenie bezpośrednie (\c GG_EVENT_DCC7_NEW) */
 	enum gg_error_t dcc7_error;	/**< Błąd połączenia bezpośredniego (\c GG_EVENT_DCC7_ERROR) */
 	struct gg_event_dcc7_connected dcc7_connected;	/**< Informacja o zestawieniu połączenia bezpośredniego (\c GG_EVENT_DCC7_CONNECTED) */
+	struct gg_event_dcc7_pending dcc7_pending;	/**< Trwa próba połączenia bezpośredniego (\c GG_EVENT_DCC7_PENDING) */
 	struct gg_event_dcc7_reject dcc7_reject;	/**< Odrzucono połączenia bezpośredniego (\c GG_EVENT_DCC7_REJECT) */
 	struct gg_event_dcc7_accept dcc7_accept;	/**< Zaakceptowano połączenie bezpośrednie (\c GG_EVENT_DCC7_ACCEPT) */
 };
--- a/libpurple/protocols/msn/msn.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Sun Nov 28 08:22:09 2010 +0000
@@ -250,24 +250,44 @@
 	MsnSession *session;
 	MsnTransaction *trans;
 	PurpleAccount *account;
-	const char *real_alias;
+	char real_alias[BUDDY_ALIAS_MAXLEN+1];
 	struct public_alias_closure *closure;
 
 	session = purple_connection_get_protocol_data(pc);
 	cmdproc = session->notification->cmdproc;
 	account = purple_connection_get_account(pc);
 
-	if (alias && *alias)
-	{
-		char *tmp = g_strdup(alias);
-		real_alias = purple_url_encode(g_strstrip(tmp));
-		g_free(tmp);
-	}
-	else
-		real_alias = "";
-
-	if (strlen(real_alias) > BUDDY_ALIAS_MAXLEN)
-	{
+	if (alias && *alias) {
+		int i = 0;
+		while (isspace(*alias))
+			alias++;
+
+		for (; *alias && i < BUDDY_ALIAS_MAXLEN; alias++) {
+			if (*alias == '%') {
+				if (i > BUF_LEN - 4)
+					break;
+				real_alias[i++] = '%';
+				real_alias[i++] = '2';
+				real_alias[i++] = '5';
+			} else if (*alias == ' ') {
+				if (i > BUF_LEN - 4)
+					break;
+				real_alias[i++] = '%';
+				real_alias[i++] = '2';
+				real_alias[i++] = '0';
+			} else {
+				real_alias[i++] = *alias;
+			}
+		}
+
+		while (i && isspace(real_alias[i - 1]))
+			i--;
+
+		real_alias[i] = '\0';
+	} else
+		real_alias[0] = '\0';
+
+	if (*alias) {
 		if (failure_cb) {
 			struct public_alias_closure *closure =
 				g_new0(struct public_alias_closure, 1);
@@ -282,8 +302,8 @@
 		return;
 	}
 
-	if (*real_alias == '\0') {
-		real_alias = purple_url_encode(purple_account_get_username(account));
+	if (real_alias[0] == '\0') {
+		strcpy(real_alias, purple_account_get_username(account));
 	}
 
 	closure = g_new0(struct public_alias_closure, 1);
--- a/libpurple/protocols/msn/p2p.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/p2p.c	Sun Nov 28 08:22:09 2010 +0000
@@ -95,6 +95,6 @@
 msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags)
 {
 	return (flags == P2P_MSN_OBJ_DATA ||
-	        flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
+	        flags == (P2P_WLM2009_COMP | P2P_MSN_OBJ_DATA) ||
 	        flags == P2P_FILE_DATA);
 }
--- a/libpurple/protocols/msn/p2p.h	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/p2p.h	Sun Nov 28 08:22:09 2010 +0000
@@ -73,7 +73,7 @@
 	P2P_CLOSE           = 0x40,       /**< Close session */
 	P2P_TLP_ERROR       = 0x80,       /**< Error at transport layer protocol */
 	P2P_DC_HANDSHAKE    = 0x100,      /**< Direct Handshake */
-	P2P_WML2009_COMP    = 0x1000000,  /**< Compatibility with WLM 2009 */
+	P2P_WLM2009_COMP    = 0x1000000,  /**< Compatibility with WLM 2009 */
 	P2P_FILE_DATA       = 0x1000030   /**< File transfer data */
 } MsnP2PHeaderFlag;
 /* Info From:
--- a/libpurple/protocols/msn/slpcall.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/slpcall.c	Sun Nov 28 08:22:09 2010 +0000
@@ -1061,7 +1061,7 @@
 	body = slpmsg->buffer;
 	body_len = slpmsg->header->offset;
 
-	if (slpmsg->header->flags == P2P_NO_FLAG || slpmsg->header->flags == P2P_WML2009_COMP)
+	if (slpmsg->header->flags == P2P_NO_FLAG || slpmsg->header->flags == P2P_WLM2009_COMP)
 	{
 		char *body_str;
 
--- a/libpurple/protocols/msn/slplink.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Sun Nov 28 08:22:09 2010 +0000
@@ -518,7 +518,7 @@
 			msn_directconn_send_handshake(directconn);
 #endif
 	}
-	else if (slpmsg->header->flags == P2P_NO_FLAG || slpmsg->header->flags == P2P_WML2009_COMP ||
+	else if (slpmsg->header->flags == P2P_NO_FLAG || slpmsg->header->flags == P2P_WLM2009_COMP ||
 			msn_p2p_msg_is_data(slpmsg->header->flags))
 	{
 		/* Release all the messages and send the ACK */
--- a/libpurple/protocols/msn/user.c	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/protocols/msn/user.c	Sun Nov 28 08:22:09 2010 +0000
@@ -203,6 +203,8 @@
 		status = "phone";
 	else if (!g_ascii_strcasecmp(state, "LUN"))
 		status = "lunch";
+	else if (!g_ascii_strcasecmp(state, "HDN"))
+		status = NULL;
 	else
 		status = "available";
 
--- a/libpurple/purple-remote	Sat Nov 27 19:58:15 2010 +0000
+++ b/libpurple/purple-remote	Sun Nov 28 08:22:09 2010 +0000
@@ -36,7 +36,8 @@
     def __call__(self, *args):
         result = self.cobj.obj.__getattr__(self.attr)(*args)
         if result == 0:
-            raise "Error: " + self.attr + " " + str(args) + " returned " + str(result)
+            raise Exception("Error: %s %s returned %s" %
+                            (self.attr, args, result))
         return result
             
 def show_help(requested=False):
@@ -223,7 +224,7 @@
                             elif type == "i":
                                 methodparams.append(int(value))
                             else:
-                                raise "Don't know how to handle type \"%s\"" % type
+                                raise Exception("Don't know how to handle type \"%s\"" % type)
                     return purple.__getattr__(command)(*methodparams)
             show_help()