soc.2010.icq-tlc: 7a18137f: Renames and cleanups.

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Sat Jul 31 16:15:42 EDT 2010


----------------------------------------------------------------------
Revision: 7a18137f663908c5d0306e4d79ddb7d953386eab
Parent:   92760ff5074d9bcc75f59473f013ca8a959a85b8
Author:   ivan.komarov at soc.pidgin.im
Date:     07/31/10 16:00:39
Branch:   im.pidgin.soc.2010.icq-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/7a18137f663908c5d0306e4d79ddb7d953386eab

Changelog: 

Renames and cleanups.

Changes against parent 92760ff5074d9bcc75f59473f013ca8a959a85b8

  patched  libpurple/protocols/oscar/bstream.c
  patched  libpurple/protocols/oscar/encoding.c
  patched  libpurple/protocols/oscar/encoding.h
  patched  libpurple/protocols/oscar/oscar.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	8d460041bf979c45c0519d452822ea562168b5aa
+++ libpurple/protocols/oscar/oscar.c	92380e9a657075cc0d514e4e0cffaa3712b7b7b0
@@ -3107,7 +3107,7 @@ purple_odc_send_im(PeerConnection *conn,
 	g_string_append(msg, "</BODY></HTML>");
 
 	/* Convert the message to a good encoding */
-	tmp = oscar_convert_to_best_encoding(msg->str, &tmplen, &charset, NULL);
+	tmp = oscar_encode_im(msg->str, &tmplen, &charset, NULL);
 	g_string_free(msg, TRUE);
 	msg = g_string_new_len(tmp, tmplen);
 	g_free(tmp);
@@ -3256,7 +3256,7 @@ oscar_send_im(PurpleConnection *gc, cons
 		g_free(tmp1);
 		tmp1 = tmp2;
 
-		args.msg = oscar_convert_to_best_encoding(tmp1, &args.msglen, &args.charset, NULL);
+		args.msg = oscar_encode_im(tmp1, &args.msglen, &args.charset, NULL);
 		if (is_html && (args.msglen > MAXMSGLEN)) {
 			/* If the length was too long, try stripping the HTML and then running it back through
 			* purple_strdup_withhtml() and the encoding process. The result may be shorter. */
@@ -3273,7 +3273,7 @@ oscar_send_im(PurpleConnection *gc, cons
 			g_free(tmp1);
 			tmp1 = tmp2;
 
-			args.msg = oscar_convert_to_best_encoding(tmp1, &args.msglen, &args.charset, NULL);
+			args.msg = oscar_encode_im(tmp1, &args.msglen, &args.charset, NULL);
 			purple_debug_info("oscar", "Sending %s as %s because the original was too long.\n",
 								  message, (char *)args.msg);
 		}
@@ -3413,7 +3413,7 @@ oscar_set_info_and_status(PurpleAccount 
 	else if (rawinfo != NULL)
 	{
 		char *htmlinfo = purple_strdup_withhtml(rawinfo);
-		info = oscar_convert_to_best_encoding(htmlinfo, &infolen, NULL, &info_encoding);
+		info = oscar_encode_im(htmlinfo, &infolen, NULL, &info_encoding);
 		g_free(htmlinfo);
 
 		if (infolen > od->rights.maxsiglen)
@@ -3446,7 +3446,7 @@ oscar_set_info_and_status(PurpleAccount 
 
 			/* We do this for icq too so that they work for old third party clients */
 			linkified = purple_markup_linkify(status_html);
-			away = oscar_convert_to_best_encoding(linkified, &awaylen, NULL, &away_encoding);
+			away = oscar_encode_im(linkified, &awaylen, NULL, &away_encoding);
 			g_free(linkified);
 
 			if (awaylen > od->rights.maxawaymsglen)
@@ -4429,7 +4429,7 @@ int oscar_send_chat(PurpleConnection *gc
 			  "You cannot send IM Images in AIM chats."),
 			PURPLE_MESSAGE_ERROR, time(NULL));
 
-	buf2 = oscar_convert_to_best_encoding(buf, &len, &charset, &charsetstr);
+	buf2 = oscar_encode_im(buf, &len, &charset, &charsetstr);
 	/*
 	 * Evan S. suggested that maxvis really does mean "number of
 	 * visible characters" and not "number of bytes"
@@ -4445,7 +4445,7 @@ int oscar_send_chat(PurpleConnection *gc
 		buf = purple_strdup_withhtml(buf3);
 		g_free(buf3);
 
-		buf2 = oscar_convert_to_best_encoding(buf, &len, &charset, &charsetstr);
+		buf2 = oscar_encode_im(buf, &len, &charset, &charsetstr);
 
 		if ((len > c->maxlen) || (len > c->maxvis)) {
 			purple_debug_warning("oscar",
============================================================
--- libpurple/protocols/oscar/bstream.c	296d6ffef0d2491187928c1da11ba145c0bc96fa
+++ libpurple/protocols/oscar/bstream.c	05c8286d786fa8b4dd3d4ef41cd1ffbf4b0f85fb
@@ -78,7 +78,8 @@ int byte_stream_advance(ByteStream *bs, 
  */
 int byte_stream_advance(ByteStream *bs, int n)
 {
-	g_return_val_if_fail((byte_stream_curpos(bs) + n >= 0) && (n <= byte_stream_bytes_left(bs)), 0);
+	g_return_val_if_fail(byte_stream_curpos(bs) + n >= 0, 0);
+	g_return_val_if_fail(n <= byte_stream_bytes_left(bs), 0);
 
 	bs->offset += n;
 	return n;
============================================================
--- libpurple/protocols/oscar/encoding.c	8726cdfec9120686b1dde92486283120738c80d1
+++ libpurple/protocols/oscar/encoding.c	c76fb83034d71716e0b6d555c77c0c79eff2456a
@@ -20,19 +20,6 @@
 
 #include "encoding.h"
 
-guint16
-oscar_charset_check(const char *utf8)
-{
-	while (*utf8++)
-	{
-		if ((unsigned char)(*utf8) > 0x7f) {
-			/* not ASCII! */
-			return AIM_CHARSET_UNICODE;
-		}
-	}
-	return AIM_CHARSET_ASCII;
-}
-
 static gchar *
 encoding_extract(const char *encoding)
 {
@@ -214,10 +201,23 @@ oscar_decode_im(PurpleAccount *account, 
 	return ret;
 }
 
+static guint16
+get_simplest_charset(const char *utf8)
+{
+	while (*utf8++)
+	{
+		if ((unsigned char)(*utf8) > 0x7f) {
+			/* not ASCII! */
+			return AIM_CHARSET_UNICODE;
+		}
+	}
+	return AIM_CHARSET_ASCII;
+}
+
 gchar *
-oscar_convert_to_best_encoding(const gchar *msg, gsize *result_len, guint16 *charset, gchar **charsetstr)
+oscar_encode_im(const gchar *msg, gsize *result_len, guint16 *charset, gchar **charsetstr)
 {
-	guint16 msg_charset = oscar_charset_check(msg);
+	guint16 msg_charset = get_simplest_charset(msg);
 	if (charset != NULL) {
 		*charset = msg_charset;
 	}
============================================================
--- libpurple/protocols/oscar/encoding.h	cba2057e91b5a8f4f0993825637b6fcc74267874
+++ libpurple/protocols/oscar/encoding.h	41b1a8eb9b8cd7a19b04481b0c1ae4f0338d3a63
@@ -24,11 +24,6 @@
 #include "oscar.h"
 #include "oscarcommon.h"
 
-/**
- * Determine the simplest encoding we can send this message in.
- */
-guint16 oscar_charset_check(const char *utf8);
-
 gchar * oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen);
 gchar * oscar_utf8_try_convert(PurpleAccount *account, OscarData *od, const gchar *msg);
 
@@ -46,6 +41,6 @@ gchar * oscar_decode_im(PurpleAccount *a
 /**
  * Figure out what encoding to use when sending a given outgoing message.
  */
-gchar * oscar_convert_to_best_encoding(const gchar *msg, gsize *result_len, guint16 *charset, gchar **charsetstr);
+gchar * oscar_encode_im(const gchar *msg, gsize *result_len, guint16 *charset, gchar **charsetstr);
 
 #endif
\ No newline at end of file


More information about the Commits mailing list