Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 10781:f6d630211935
[gaim-migrate @ 12406]
My changes from oldstatus dealing with HTML and plaintext messages for
AIM and ICQ. Hopefully I didn't miss anything.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 04 Apr 2005 04:35:57 +0000 |
parents | b40a67d45dbb |
children | 48779a02fe99 |
comparison
equal
deleted
inserted
replaced
10780:33fe0093bbba | 10781:f6d630211935 |
---|---|
3399 curpart = curpart->next; | 3399 curpart = curpart->next; |
3400 } | 3400 } |
3401 tmp = g_string_free(message, FALSE); | 3401 tmp = g_string_free(message, FALSE); |
3402 | 3402 |
3403 /* | 3403 /* |
3404 * If the message is being received by an ICQ user then escape any HTML, | 3404 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
3405 * because HTML is not sent over ICQ as a means to format a message. | 3405 * because HTML is not sent over ICQ as a means to format a message. |
3406 * so any HTML we receive is intended to be displayed | 3406 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3407 * replaced with <br> | |
3407 * | 3408 * |
3408 * Note: There *may* be some clients which send messages as HTML formatted - | 3409 * Note: There *may* be some clients which send messages as HTML formatted - |
3409 * they need to be special-cased somehow. | 3410 * they need to be special-cased somehow. |
3410 */ | 3411 */ |
3411 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { | 3412 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
3412 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | 3413 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3413 gchar *tmp2 = g_markup_escape_text(tmp, -1); | 3414 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
3415 g_free(tmp); | |
3416 tmp = tmp2; | |
3417 gaim_strreplace(tmp, "\r\n", "<br>"); | |
3414 g_free(tmp); | 3418 g_free(tmp); |
3415 tmp = tmp2; | 3419 tmp = tmp2; |
3416 } | 3420 } |
3417 | 3421 |
3418 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); | 3422 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
5510 OscarData *od = (OscarData *)gc->proto_data; | 5514 OscarData *od = (OscarData *)gc->proto_data; |
5511 GaimAccount *account = gaim_connection_get_account(gc); | 5515 GaimAccount *account = gaim_connection_get_account(gc); |
5512 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); | 5516 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5513 int ret = 0; | 5517 int ret = 0; |
5514 const char *iconfile = gaim_account_get_buddy_icon(account); | 5518 const char *iconfile = gaim_account_get_buddy_icon(account); |
5515 char *tmpmsg = NULL, *tmpmsg2 = NULL; | 5519 char *tmpmsg = NULL; |
5516 | 5520 |
5517 if (dim && dim->connected) { | 5521 if (dim && dim->connected) { |
5518 /* If we're directly connected, send a direct IM */ | 5522 /* If we're directly connected, send a direct IM */ |
5519 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); | 5523 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
5520 } else { | 5524 } else { |
5590 } | 5594 } |
5591 | 5595 |
5592 args.destsn = name; | 5596 args.destsn = name; |
5593 | 5597 |
5594 /* | 5598 /* |
5595 * If we're IMing an ICQ user then send newlines as CR/LF and | 5599 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5596 * strip all HTML | 5600 * and use \r\n as the newline character. |
5597 */ | 5601 */ |
5598 if (aim_sn_is_icq(name) ) { | 5602 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5599 /* being sent to an ICQ user */ | 5603 if (aim_sn_is_icq(name)) |
5600 if (!aim_sn_is_icq(gaim_account_get_username(account))) { | 5604 /* From ICQ to ICQ */ |
5601 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5602 tmpmsg = gaim_str_add_cr(message); | |
5603 } else { | |
5604 /* from an ICQ user - do nothing */ | |
5605 tmpmsg = g_strdup(message); | 5605 tmpmsg = g_strdup(message); |
5606 } | 5606 else |
5607 /* From ICQ to AIM */ | |
5608 tmpmsg = g_markup_escape_text(message, -1); | |
5607 } else { | 5609 } else { |
5608 /* being sent to an AIM user */ | 5610 if (aim_sn_is_icq(name)) |
5609 if (aim_sn_is_icq(gaim_account_get_username(account))) { | 5611 /* From AIM to AIM and AIM to ICQ */ |
5610 /* from an ICQ user */ | 5612 tmpmsg = g_strdup(message); |
5611 tmpmsg2 = gaim_strdup_withhtml(message); | |
5612 tmpmsg = g_markup_escape_text(tmpmsg2, -1); | |
5613 g_free(tmpmsg2); | |
5614 } else | |
5615 tmpmsg = gaim_strdup_withhtml(message); | |
5616 } | 5613 } |
5617 len = strlen(tmpmsg); | 5614 len = strlen(tmpmsg); |
5618 | 5615 |
5619 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); | 5616 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5620 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | 5617 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", |