comparison src/protocols/oscar/oscar.c @ 6310:f14718d7082e

[gaim-migrate @ 6809] Robot101 is a fancy bastard. Regarding my fix for "Make Gaim not crash when you unload the system tray icon when there are messages queued," he writes: The correct fix for this is to use &handle as the function data, I have a function that removes callbacks with that data pointer that gets called at unload. Fancy. In other news, we now send a BR tag instead of \n for newlines for AIM. And for ICQ we send CR/LF instead of \n. This is more correct, and should make messages with new lines sent from Gaim to Miranda show up correctly for Miranda users. ICQ Lite sends CR/LF to Gaim for newlines, but I would rather use a BR tag, and it seems to work with no problems. In still other news, de purk und beans mit sauerkrauten. In yet still other news, I don't have anything else to add. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 26 Jul 2003 20:40:44 +0000
parents a21cf07cd8e1
children 96196cfb132e
comparison
equal deleted inserted replaced
6309:bf63ddea431f 6310:f14718d7082e
4253 struct oscar_data *od = (struct oscar_data *)gc->proto_data; 4253 struct oscar_data *od = (struct oscar_data *)gc->proto_data;
4254 struct direct_im *dim = find_direct_im(od, name); 4254 struct direct_im *dim = find_direct_im(od, name);
4255 int ret = 0; 4255 int ret = 0;
4256 GError *err = NULL; 4256 GError *err = NULL;
4257 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); 4257 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc));
4258 char *tmpmsg;
4258 4259
4259 if (dim && dim->connected) { 4260 if (dim && dim->connected) {
4260 /* If we're directly connected, send a direct IM */ 4261 /* If we're directly connected, send a direct IM */
4261 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ 4262 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */
4262 if (imflags & IM_FLAG_AWAY) 4263 if (imflags & IM_FLAG_AWAY)
4327 } 4328 }
4328 } 4329 }
4329 4330
4330 args.destsn = name; 4331 args.destsn = name;
4331 4332
4332 len = strlen(message); 4333 /* For ICQ send newlines as CR/LF, for AIM send newlines as <BR> */
4333 args.flags |= oscar_encoding_check(message); 4334 if (isdigit(name[0]))
4335 tmpmsg = add_cr(message);
4336 else
4337 tmpmsg = strdup_withhtml(message);
4338 len = strlen(tmpmsg);
4339
4340 args.flags |= oscar_encoding_check(tmpmsg);
4334 if (args.flags & AIM_IMFLAGS_UNICODE) { 4341 if (args.flags & AIM_IMFLAGS_UNICODE) {
4335 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n"); 4342 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n");
4336 args.charset = 0x0002; 4343 args.charset = 0x0002;
4337 args.charsubset = 0x0000; 4344 args.charsubset = 0x0000;
4338 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); 4345 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err);
4339 if (err) { 4346 if (err) {
4340 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 4347 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
4341 "Error converting a unicode message: %s\n", err->message); 4348 "Error converting a unicode message: %s\n", err->message);
4342 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 4349 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
4343 "This really shouldn't happen!\n"); 4350 "This really shouldn't happen!\n");
4348 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { 4355 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) {
4349 gaim_debug(GAIM_DEBUG_INFO, "oscar", 4356 gaim_debug(GAIM_DEBUG_INFO, "oscar",
4350 "Sending ISO-8859-1 IM\n"); 4357 "Sending ISO-8859-1 IM\n");
4351 args.charset = 0x0003; 4358 args.charset = 0x0003;
4352 args.charsubset = 0x0000; 4359 args.charsubset = 0x0000;
4353 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); 4360 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err);
4354 if (err) { 4361 if (err) {
4355 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 4362 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
4356 "conversion error: %s\n", err->message); 4363 "conversion error: %s\n", err->message);
4357 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 4364 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
4358 "Someone tell Ethan his 8859-1 detection is wrong\n"); 4365 "Someone tell Ethan his 8859-1 detection is wrong\n");
4359 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; 4366 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE;
4360 len = strlen(message); 4367 len = strlen(tmpmsg);
4361 g_error_free(err); 4368 g_error_free(err);
4362 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); 4369 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err);
4363 if (err) { 4370 if (err) {
4364 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 4371 gaim_debug(GAIM_DEBUG_ERROR, "oscar",
4365 "Error in unicode fallback: %s\n", err->message); 4372 "Error in unicode fallback: %s\n", err->message);
4366 g_error_free(err); 4373 g_error_free(err);
4367 } 4374 }
4368 } 4375 }
4369 } else { 4376 } else {
4370 args.charset = 0x0000; 4377 args.charset = 0x0000;
4371 args.charsubset = 0x0000; 4378 args.charsubset = 0x0000;
4372 args.msg = message; 4379 args.msg = tmpmsg;
4373 } 4380 }
4374 args.msglen = len; 4381 args.msglen = len;
4375 4382
4376 ret = aim_im_sendch1_ext(od->sess, &args); 4383 ret = aim_im_sendch1_ext(od->sess, &args);
4377 } 4384 }
4385
4386 g_free(tmpmsg);
4378 4387
4379 if (ret >= 0) 4388 if (ret >= 0)
4380 return 1; 4389 return 1;
4390
4381 return ret; 4391 return ret;
4382 } 4392 }
4383 4393
4384 static void oscar_get_info(GaimConnection *g, const char *name) { 4394 static void oscar_get_info(GaimConnection *g, const char *name) {
4385 struct oscar_data *od = (struct oscar_data *)g->proto_data; 4395 struct oscar_data *od = (struct oscar_data *)g->proto_data;