comparison libpurple/protocols/oscar/oscar.c @ 30827:ed520e6e972b

Renames and cleanups.
author ivan.komarov@soc.pidgin.im
date Sat, 31 Jul 2010 20:00:39 +0000
parents 5661f30d1b8e
children 1b7152eeea31
comparison
equal deleted inserted replaced
30826:bbb27d65681f 30827:ed520e6e972b
3105 g_string_append(msg, last); 3105 g_string_append(msg, last);
3106 3106
3107 g_string_append(msg, "</BODY></HTML>"); 3107 g_string_append(msg, "</BODY></HTML>");
3108 3108
3109 /* Convert the message to a good encoding */ 3109 /* Convert the message to a good encoding */
3110 tmp = oscar_convert_to_best_encoding(msg->str, &tmplen, &charset, NULL); 3110 tmp = oscar_encode_im(msg->str, &tmplen, &charset, NULL);
3111 g_string_free(msg, TRUE); 3111 g_string_free(msg, TRUE);
3112 msg = g_string_new_len(tmp, tmplen); 3112 msg = g_string_new_len(tmp, tmplen);
3113 g_free(tmp); 3113 g_free(tmp);
3114 3114
3115 /* Append any binary data that we may have */ 3115 /* Append any binary data that we may have */
3254 is_html = TRUE; 3254 is_html = TRUE;
3255 } 3255 }
3256 g_free(tmp1); 3256 g_free(tmp1);
3257 tmp1 = tmp2; 3257 tmp1 = tmp2;
3258 3258
3259 args.msg = oscar_convert_to_best_encoding(tmp1, &args.msglen, &args.charset, NULL); 3259 args.msg = oscar_encode_im(tmp1, &args.msglen, &args.charset, NULL);
3260 if (is_html && (args.msglen > MAXMSGLEN)) { 3260 if (is_html && (args.msglen > MAXMSGLEN)) {
3261 /* If the length was too long, try stripping the HTML and then running it back through 3261 /* If the length was too long, try stripping the HTML and then running it back through
3262 * purple_strdup_withhtml() and the encoding process. The result may be shorter. */ 3262 * purple_strdup_withhtml() and the encoding process. The result may be shorter. */
3263 g_free((char *)args.msg); 3263 g_free((char *)args.msg);
3264 3264
3271 3271
3272 tmp2 = purple_strdup_withhtml(tmp1); 3272 tmp2 = purple_strdup_withhtml(tmp1);
3273 g_free(tmp1); 3273 g_free(tmp1);
3274 tmp1 = tmp2; 3274 tmp1 = tmp2;
3275 3275
3276 args.msg = oscar_convert_to_best_encoding(tmp1, &args.msglen, &args.charset, NULL); 3276 args.msg = oscar_encode_im(tmp1, &args.msglen, &args.charset, NULL);
3277 purple_debug_info("oscar", "Sending %s as %s because the original was too long.\n", 3277 purple_debug_info("oscar", "Sending %s as %s because the original was too long.\n",
3278 message, (char *)args.msg); 3278 message, (char *)args.msg);
3279 } 3279 }
3280 3280
3281 purple_debug_info("oscar", "Sending IM, charset=0x%04hx, length=%" G_GSIZE_FORMAT "\n", args.charset, args.msglen); 3281 purple_debug_info("oscar", "Sending IM, charset=0x%04hx, length=%" G_GSIZE_FORMAT "\n", args.charset, args.msglen);
3411 "again when you are fully connected.")); 3411 "again when you are fully connected."));
3412 } 3412 }
3413 else if (rawinfo != NULL) 3413 else if (rawinfo != NULL)
3414 { 3414 {
3415 char *htmlinfo = purple_strdup_withhtml(rawinfo); 3415 char *htmlinfo = purple_strdup_withhtml(rawinfo);
3416 info = oscar_convert_to_best_encoding(htmlinfo, &infolen, NULL, &info_encoding); 3416 info = oscar_encode_im(htmlinfo, &infolen, NULL, &info_encoding);
3417 g_free(htmlinfo); 3417 g_free(htmlinfo);
3418 3418
3419 if (infolen > od->rights.maxsiglen) 3419 if (infolen > od->rights.maxsiglen)
3420 { 3420 {
3421 gchar *errstr; 3421 gchar *errstr;
3444 { 3444 {
3445 gchar *linkified; 3445 gchar *linkified;
3446 3446
3447 /* We do this for icq too so that they work for old third party clients */ 3447 /* We do this for icq too so that they work for old third party clients */
3448 linkified = purple_markup_linkify(status_html); 3448 linkified = purple_markup_linkify(status_html);
3449 away = oscar_convert_to_best_encoding(linkified, &awaylen, NULL, &away_encoding); 3449 away = oscar_encode_im(linkified, &awaylen, NULL, &away_encoding);
3450 g_free(linkified); 3450 g_free(linkified);
3451 3451
3452 if (awaylen > od->rights.maxawaymsglen) 3452 if (awaylen > od->rights.maxawaymsglen)
3453 { 3453 {
3454 gchar *errstr; 3454 gchar *errstr;
4427 purple_conversation_write(conv, "", 4427 purple_conversation_write(conv, "",
4428 _("Your IM Image was not sent. " 4428 _("Your IM Image was not sent. "
4429 "You cannot send IM Images in AIM chats."), 4429 "You cannot send IM Images in AIM chats."),
4430 PURPLE_MESSAGE_ERROR, time(NULL)); 4430 PURPLE_MESSAGE_ERROR, time(NULL));
4431 4431
4432 buf2 = oscar_convert_to_best_encoding(buf, &len, &charset, &charsetstr); 4432 buf2 = oscar_encode_im(buf, &len, &charset, &charsetstr);
4433 /* 4433 /*
4434 * Evan S. suggested that maxvis really does mean "number of 4434 * Evan S. suggested that maxvis really does mean "number of
4435 * visible characters" and not "number of bytes" 4435 * visible characters" and not "number of bytes"
4436 */ 4436 */
4437 if ((len > c->maxlen) || (len > c->maxvis)) { 4437 if ((len > c->maxlen) || (len > c->maxvis)) {
4443 g_free(buf); 4443 g_free(buf);
4444 4444
4445 buf = purple_strdup_withhtml(buf3); 4445 buf = purple_strdup_withhtml(buf3);
4446 g_free(buf3); 4446 g_free(buf3);
4447 4447
4448 buf2 = oscar_convert_to_best_encoding(buf, &len, &charset, &charsetstr); 4448 buf2 = oscar_encode_im(buf, &len, &charset, &charsetstr);
4449 4449
4450 if ((len > c->maxlen) || (len > c->maxvis)) { 4450 if ((len > c->maxlen) || (len > c->maxvis)) {
4451 purple_debug_warning("oscar", 4451 purple_debug_warning("oscar",
4452 "Could not send %s because (%" G_GSIZE_FORMAT " > maxlen %i) or (%" G_GSIZE_FORMAT " > maxvis %i)\n", 4452 "Could not send %s because (%" G_GSIZE_FORMAT " > maxlen %i) or (%" G_GSIZE_FORMAT " > maxvis %i)\n",
4453 buf2, len, c->maxlen, len, c->maxvis); 4453 buf2, len, c->maxlen, len, c->maxvis);