pidgin/pidgin

Parents 7fd6d7cba52d
Children f0fbb41b072e
Change the last param of yahoo_string_encode from gboolean* to gboolean.

There was no reason for it to be a pointer. Maybe someone wanted to
optionally set utf-8 to true if we needed it or something? But that's
not the current behavior. It's better for the code to be simpler now,
and it can be changed back to a pointer if we need it for some reason.
--- a/libpurple/protocols/yahoo/libymsg.c Mon Jan 20 00:11:11 2014 -0800
+++ b/libpurple/protocols/yahoo/libymsg.c Mon Jan 20 00:26:52 2014 -0800
@@ -1320,7 +1320,7 @@
const char *who = add_req->who;
if (msg && *msg)
- encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL);
+ encoded_msg = yahoo_string_encode(add_req->gc, msg, FALSE);
pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15,
YAHOO_STATUS_AVAILABLE, yd->session_id);
@@ -1333,7 +1333,7 @@
241, add_req->fed,
13, 2,
334, 0,
- 97, 1,
+ 97, 1, /* UTF-8 */
14, encoded_msg ? encoded_msg : "");
}
else {
@@ -1342,7 +1342,7 @@
5, who,
13, 2,
334, 0,
- 97, 1,
+ 97, 1, /* UTF-8 */
14, encoded_msg ? encoded_msg : "");
}
@@ -4563,7 +4563,6 @@
struct yahoo_packet *pkt = NULL;
char *msg = yahoo_html_to_codes(what);
char *msg2;
- gboolean utf8 = TRUE;
PurpleWhiteboard *wb;
int ret = 1;
const char *fed_who;
@@ -4571,7 +4570,7 @@
glong lenc = 0;
struct yahoo_p2p_data *p2p_data;
YahooFederation fed = YAHOO_FEDERATION_NONE;
- msg2 = yahoo_string_encode(gc, msg, &utf8);
+ msg2 = yahoo_string_encode(gc, msg, TRUE);
if(msg2) {
lenb = strlen(msg2);
@@ -4654,8 +4653,7 @@
if (fed)
yahoo_packet_hash_int(pkt, 241, fed);
- if (utf8)
- yahoo_packet_hash_str(pkt, 97, "1");
+ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */
yahoo_packet_hash_str(pkt, 14, msg2);
/*
@@ -4780,7 +4778,6 @@
const char *msg = NULL;
char *tmp = NULL;
char *conv_msg = NULL;
- gboolean utf8 = TRUE;
if (!purple_status_is_active(status))
return;
@@ -4797,13 +4794,13 @@
msg = purple_status_get_attr_string(status, "message");
if (purple_status_is_available(status)) {
- tmp = yahoo_string_encode(gc, msg, &utf8);
+ tmp = yahoo_string_encode(gc, msg, TRUE);
conv_msg = purple_markup_strip_html(tmp);
g_free(tmp);
} else {
if ((msg == NULL) || (*msg == '\0'))
msg = _("Away");
- tmp = yahoo_string_encode(gc, msg, &utf8);
+ tmp = yahoo_string_encode(gc, msg, TRUE);
conv_msg = purple_markup_strip_html(tmp);
g_free(tmp);
}
@@ -4821,7 +4818,7 @@
yahoo_packet_hash_int(pkt, 10, yd->current_status);
if (yd->current_status == YAHOO_STATUS_CUSTOM) {
- yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0);
+ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */
yahoo_packet_hash_str(pkt, 19, conv_msg);
} else {
yahoo_packet_hash_str(pkt, 19, "");
@@ -4881,10 +4878,9 @@
status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc)));
tmp = purple_status_get_attr_string(status, "message");
if (tmp != NULL) {
- gboolean utf8 = TRUE;
- msg = yahoo_string_encode(gc, tmp, &utf8);
+ msg = yahoo_string_encode(gc, tmp, TRUE);
msg2 = purple_markup_strip_html(msg);
- yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0);
+ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */
yahoo_packet_hash_str(pkt, 19, msg2);
} else {
/* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for
@@ -5030,13 +5026,13 @@
else
group = "Buddies";
- group2 = yahoo_string_encode(gc, group, NULL);
+ group2 = yahoo_string_encode(gc, group, FALSE);
pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
if (fed) {
yahoo_packet_hash(pkt, "sssssssisss",
14, "",
65, group2,
- 97, "1",
+ 97, "1", /* UTF-8 */
1, purple_connection_get_display_name(gc),
302, "319",
300, "319",
@@ -5051,7 +5047,7 @@
yahoo_packet_hash(pkt, "ssssssssss",
14, "",
65, group2,
- 97, "1",
+ 97, "1", /* UTF-8 */
1, purple_connection_get_display_name(gc),
302, "319",
300, "319",
@@ -5101,7 +5097,7 @@
f = NULL; /* f no longer valid - Just making it clear */
}
- cg = yahoo_string_encode(gc, gname, NULL);
+ cg = yahoo_string_encode(gc, gname, FALSE);
pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);
switch (fed) {
@@ -5216,8 +5212,8 @@
* end up deleting the buddy, which would be bad.
* This might happen because of the charset conversation.
*/
- gpn = yahoo_string_encode(gc, new_group, NULL);
- gpo = yahoo_string_encode(gc, old_group, NULL);
+ gpn = yahoo_string_encode(gc, new_group, FALSE);
+ gpo = yahoo_string_encode(gc, old_group, FALSE);
if (!strcmp(gpn, gpo)) {
g_free(gpn);
g_free(gpo);
@@ -5246,8 +5242,8 @@
struct yahoo_packet *pkt;
char *gpn, *gpo;
- gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL);
- gpo = yahoo_string_encode(gc, old_name, NULL);
+ gpn = yahoo_string_encode(gc, purple_group_get_name(group), FALSE);
+ gpo = yahoo_string_encode(gc, old_name, FALSE);
if (!strcmp(gpn, gpo)) {
g_free(gpn);
g_free(gpo);
--- a/libpurple/protocols/yahoo/libymsg.h Mon Jan 20 00:11:11 2014 -0800
+++ b/libpurple/protocols/yahoo/libymsg.h Mon Jan 20 00:26:52 2014 -0800
@@ -330,14 +330,12 @@
*
* @param gc The connection handle.
* @param str The null terminated utf8 string to encode.
- * @param utf8 If not @c NULL, whether utf8 is okay or not.
- * Even if it is okay, we may not use it. If we
- * used it, we set this to @c TRUE, else to
- * @c FALSE. If @c NULL, false is assumed, and
- * it is not dereferenced.
- * @return The g_malloced string in the appropriate encoding.
+ * @param utf8 Whether to return a UTF-8 string.
+ * @return A g_malloc'ed string in the appropriate encoding. If jd->jp or
+ * utf8 is true then the string is copied verbatim. Otherwise the
+ * encoding from account settings is used.
*/
-char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8);
+gchar *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean utf8);
/**
* Decode some text received from the server.
--- a/libpurple/protocols/yahoo/util.c Mon Jan 20 00:11:11 2014 -0800
+++ b/libpurple/protocols/yahoo/util.c Mon Jan 20 00:26:52 2014 -0800
@@ -116,19 +116,7 @@
return ans;
}
-/**
- * Encode some text to send to the yahoo server.
- *
- * @param gc The connection handle.
- * @param str The null terminated utf8 string to encode.
- * @param utf8 If not @c NULL, whether utf8 is okay or not.
- * Even if it is okay, we may not use it. If we
- * used it, we set this to @c TRUE, else to
- * @c FALSE. If @c NULL, false is assumed, and
- * it is not dereferenced.
- * @return The g_malloced string in the appropriate encoding.
- */
-char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8)
+char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean utf8)
{
YahooData *yd = purple_connection_get_protocol_data(gc);
char *ret;
@@ -138,7 +126,7 @@
if (yd->jp)
return g_strdup(str);
- if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
+ if (utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
return g_strdup(str);
to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
--- a/libpurple/protocols/yahoo/yahoochat.c Mon Jan 20 00:11:11 2014 -0800
+++ b/libpurple/protocols/yahoo/yahoochat.c Mon Jan 20 00:26:52 2014 -0800
@@ -406,7 +406,6 @@
YahooData *yd = purple_connection_get_protocol_data(gc);
struct yahoo_packet *pkt;
char *room2;
- gboolean utf8 = TRUE;
if (yd->wm) {
g_return_if_fail(yd->ycht != NULL);
@@ -416,7 +415,7 @@
/* apparently room names are always utf8, or else always not utf8,
* so we don't have to actually pass the flag in the packet. Or something. */
- room2 = yahoo_string_encode(gc, room, &utf8);
+ room2 = yahoo_string_encode(gc, room, TRUE);
pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, yd->session_id);
yahoo_packet_hash(pkt, "ssss",
@@ -853,10 +852,9 @@
struct yahoo_packet *pkt;
GList *who;
char *msg, *msg2;
- int utf8 = 1;
msg = yahoo_html_to_codes(what);
- msg2 = yahoo_string_encode(gc, msg, &utf8);
+ msg2 = yahoo_string_encode(gc, msg, TRUE);
pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, yd->session_id);
@@ -866,8 +864,7 @@
yahoo_packet_hash_str(pkt, 53, name);
}
yahoo_packet_hash(pkt, "ss", 57, room, 14, msg2);
- if (utf8)
- yahoo_packet_hash_str(pkt, 97, "1"); /* utf-8 */
+ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */
yahoo_packet_send_and_free(pkt, yd);
g_free(msg);
@@ -912,7 +909,7 @@
char *msg2 = NULL;
if (msg)
- msg2 = yahoo_string_encode(gc, msg, NULL);
+ msg2 = yahoo_string_encode(gc, msg, FALSE);
members = purple_chat_conversation_get_users(c);
@@ -938,9 +935,7 @@
{
YahooData *yd = purple_connection_get_protocol_data(gc);
struct yahoo_packet *pkt;
-
char *eroom;
- gboolean utf8 = 1;
if (yd->wm) {
g_return_if_fail(yd->ycht != NULL);
@@ -949,7 +944,7 @@
return;
}
- eroom = yahoo_string_encode(gc, room, &utf8);
+ eroom = yahoo_string_encode(gc, room, TRUE);
pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, yd->session_id);
yahoo_packet_hash(pkt, "sss", 104, eroom, 109, dn, 108, "1");
@@ -991,7 +986,6 @@
struct yahoo_packet *pkt;
int me = 0;
char *msg1, *msg2, *room2;
- gboolean utf8 = TRUE;
if (yd->wm) {
g_return_val_if_fail(yd->ycht != NULL, 1);
@@ -1006,9 +1000,9 @@
msg2 = yahoo_html_to_codes(msg1);
g_free(msg1);
- msg1 = yahoo_string_encode(gc, msg2, &utf8);
+ msg1 = yahoo_string_encode(gc, msg2, TRUE);
g_free(msg2);
- room2 = yahoo_string_encode(gc, room, NULL);
+ room2 = yahoo_string_encode(gc, room, FALSE);
pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, yd->session_id);
@@ -1018,8 +1012,7 @@
else
yahoo_packet_hash_str(pkt, 124, "1");
/* fixme: what about /think? (124=3) */
- if (utf8)
- yahoo_packet_hash_str(pkt, 97, "1");
+ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */
yahoo_packet_send_and_free(pkt, yd);
g_free(msg1);
@@ -1035,7 +1028,6 @@
YahooData *yd = purple_connection_get_protocol_data(gc);
struct yahoo_packet *pkt;
char *room2, *msg2 = NULL;
- gboolean utf8 = TRUE;
if (yd->wm) {
g_return_if_fail(yd->ycht != NULL);
@@ -1043,9 +1035,9 @@
return;
}
- room2 = yahoo_string_encode(gc, room, &utf8);
+ room2 = yahoo_string_encode(gc, room, TRUE);
if (msg)
- msg2 = yahoo_string_encode(gc, msg, NULL);
+ msg2 = yahoo_string_encode(gc, msg, FALSE);
pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, yd->session_id);
yahoo_packet_hash(pkt, "sssss", 1, dn, 118, buddy, 104, room2, 117, (msg2?msg2:""), 129, "0");
--- a/libpurple/protocols/yahoo/ycht.c Mon Jan 20 00:11:11 2014 -0800
+++ b/libpurple/protocols/yahoo/ycht.c Mon Jan 20 00:26:52 2014 -0800
@@ -626,7 +626,7 @@
pkt = ycht_packet_new(YCHT_VERSION, YCHT_SERVICE_CHATMSG, 0);
msg1 = yahoo_html_to_codes(what);
- msg2 = yahoo_string_encode(ycht->gc, msg1, NULL);
+ msg2 = yahoo_string_encode(ycht->gc, msg1, FALSE);
g_free(msg1);
buf = g_strdup_printf("%s\001%s", ycht->room, msg2);