comparison src/protocols/oscar/oscar.c @ 6019:272c761c52e3

[gaim-migrate @ 6469] So Decklin sent me a patch to fix the problem with setting profiles, and then later that day, before I got a shot at it, KingAnt fixed it himself. But Decklin's fix is better, so here it is, hand-merged with love. KingAnt also points out that Decklin Foster is a cool name. Decklin also realized (and fixed) that we were initializing static protocols after importing prefs, causing the import to fail. Thanks, Decklin. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 05 Jul 2003 01:49:07 +0000
parents 80e5258226f3
children 38999b6b1838
comparison
equal deleted inserted replaced
6018:d4caf585f6ff 6019:272c761c52e3
4411 } 4411 }
4412 4412
4413 static void oscar_set_info(GaimConnection *gc, const char *text) { 4413 static void oscar_set_info(GaimConnection *gc, const char *text) {
4414 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 4414 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
4415 fu32_t flags = 0; 4415 fu32_t flags = 0;
4416 char *text_html = NULL;
4416 char *msg = NULL; 4417 char *msg = NULL;
4417 int msglen = 0; 4418 int msglen = 0;
4418 4419
4419 if (od->rights.maxsiglen == 0) 4420 if (od->rights.maxsiglen == 0)
4420 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), 4421 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."),
4428 else { 4429 else {
4429 if (!text) { 4430 if (!text) {
4430 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_aim); 4431 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_aim);
4431 return; 4432 return;
4432 } 4433 }
4433 4434
4434 flags = oscar_encoding_check(text); 4435 text_html = strdup_withhtml(text);
4436 flags = oscar_encoding_check(text_html);
4435 if (flags & AIM_IMFLAGS_UNICODE) { 4437 if (flags & AIM_IMFLAGS_UNICODE) {
4436 msg = g_convert(text, strlen(text), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); 4438 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
4437 aim_bos_setprofile(od->sess, od->conn, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); 4439 aim_bos_setprofile(od->sess, od->conn, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim);
4438 g_free(msg); 4440 g_free(msg);
4439 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { 4441 } else if (flags & AIM_IMFLAGS_ISO_8859_1) {
4440 msg = g_convert(text, strlen(text), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); 4442 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL);
4441 aim_bos_setprofile(od->sess, od->conn, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); 4443 aim_bos_setprofile(od->sess, od->conn, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim);
4442 g_free(msg); 4444 g_free(msg);
4443 } else { 4445 } else {
4444 msglen = strlen(text); 4446 msglen = strlen(text_html);
4445 aim_bos_setprofile(od->sess, od->conn, "us-ascii", text, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); 4447 aim_bos_setprofile(od->sess, od->conn, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim);
4446 } 4448 }
4447 4449
4448 if (msglen > od->rights.maxsiglen) { 4450 if (msglen > od->rights.maxsiglen) {
4449 gchar *errstr; 4451 gchar *errstr;
4450 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " 4452 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. "
4451 "Gaim has truncated it for you."), od->rights.maxsiglen); 4453 "Gaim has truncated it for you."), od->rights.maxsiglen);
4452 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); 4454 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr);
4453 g_free(errstr); 4455 g_free(errstr);
4454 } 4456 }
4455 4457
4458 g_free(text_html);
4459
4456 } 4460 }
4457 4461
4458 return; 4462 return;
4459 } 4463 }
4460 4464
4461 static void oscar_set_away_aim(GaimConnection *gc, struct oscar_data *od, const char *text) 4465 static void oscar_set_away_aim(GaimConnection *gc, struct oscar_data *od, const char *text)
4462 { 4466 {
4463 fu32_t flags = 0; 4467 fu32_t flags = 0;
4468 gchar *text_html = NULL;
4464 char *msg = NULL; 4469 char *msg = NULL;
4465 int msglen = 0; 4470 int msglen = 0;
4466 4471
4467 if (od->rights.maxawaymsglen == 0) 4472 if (od->rights.maxawaymsglen == 0)
4468 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), 4473 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."),
4480 if (!text) { 4485 if (!text) {
4481 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, "", 0, caps_aim); 4486 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, "", 0, caps_aim);
4482 return; 4487 return;
4483 } 4488 }
4484 4489
4485 flags = oscar_encoding_check(text); 4490 flags = oscar_encoding_check(text_html);
4486 if (flags & AIM_IMFLAGS_UNICODE) { 4491 if (flags & AIM_IMFLAGS_UNICODE) {
4487 msg = g_convert(text, strlen(text), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); 4492 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
4488 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", msg, 4493 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", msg,
4489 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); 4494 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim);
4490 g_free(msg); 4495 g_free(msg);
4491 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); 4496 gc->away = g_strndup(text, od->rights.maxawaymsglen/2);
4492 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { 4497 } else if (flags & AIM_IMFLAGS_ISO_8859_1) {
4493 msg = g_convert(text, strlen(text), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); 4498 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL);
4494 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "iso-8859-1", msg, 4499 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "iso-8859-1", msg,
4495 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); 4500 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim);
4496 g_free(msg); 4501 g_free(msg);
4497 gc->away = g_strndup(text, od->rights.maxawaymsglen); 4502 gc->away = g_strndup(text_html, od->rights.maxawaymsglen);
4498 } else { 4503 } else {
4499 msglen = strlen(text); 4504 msglen = strlen(text_html);
4500 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", text, 4505 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", text_html,
4501 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); 4506 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim);
4502 gc->away = g_strndup(text, od->rights.maxawaymsglen); 4507 gc->away = g_strndup(text_html, od->rights.maxawaymsglen);
4503 } 4508 }
4504 4509
4505 if (msglen > od->rights.maxawaymsglen) { 4510 if (msglen > od->rights.maxawaymsglen) {
4506 gchar *errstr; 4511 gchar *errstr;
4507 4512
4508 errstr = g_strdup_printf(_("The maximum away message length of %d bytes has been exceeded. " 4513 errstr = g_strdup_printf(_("The maximum away message length of %d bytes has been exceeded. "
4509 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); 4514 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen);
4510 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); 4515 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr);
4511 g_free(errstr); 4516 g_free(errstr);
4512 } 4517 }
4513 4518
4519 g_free(text_html);
4514 return; 4520 return;
4515 } 4521 }
4516 4522
4517 static void oscar_set_away_icq(GaimConnection *gc, struct oscar_data *od, const char *state, const char *message) 4523 static void oscar_set_away_icq(GaimConnection *gc, struct oscar_data *od, const char *state, const char *message)
4518 { 4524 {