Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/oscar.c @ 19640:eb0933e158a4
Add non-US SMS support for ICQ. This is a patch from DB42.
Fixes #2913. Sweet.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 04 Sep 2007 08:04:06 +0000 |
parents | 66882abaf8f1 |
children | c0f503c18f7e |
comparison
equal
deleted
inserted
replaced
19639:1a16d474c459 | 19640:eb0933e158a4 |
---|---|
2484 } | 2484 } |
2485 g_strfreev(text); | 2485 g_strfreev(text); |
2486 } | 2486 } |
2487 } break; | 2487 } break; |
2488 | 2488 |
2489 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ | 2489 case 0x1a: { /* Handle SMS or someone has sent you a greeting card or requested buddies? */ |
2490 /* This is boring and silly. */ | 2490 ByteStream qbs; |
2491 int smstype, taglen, smslen; | |
2492 char *tagstr = NULL, *smsmsg = NULL; | |
2493 xmlnode *xmlroot = NULL, *xmltmp = NULL; | |
2494 gchar *uin = NULL, *message = NULL; | |
2495 | |
2496 /* From libicq2000-0.3.2/src/ICQ.cpp */ | |
2497 byte_stream_init(&qbs, (guint8 *)args->msg, args->msglen); | |
2498 byte_stream_advance(&qbs, 21); | |
2499 smstype = byte_stream_getle16(&qbs); | |
2500 taglen = byte_stream_getle32(&qbs); | |
2501 tagstr = byte_stream_getstr(&qbs, taglen); | |
2502 byte_stream_advance(&qbs, 3); | |
2503 byte_stream_advance(&qbs, 4); | |
2504 smslen = byte_stream_getle32(&qbs); | |
2505 smsmsg = byte_stream_getstr(&qbs, smslen); | |
2506 | |
2507 /* Check if this is an SMS being sent from server */ | |
2508 if ((smstype == 0) && (!strcmp(tagstr, "ICQSMS")) && (smsmsg != NULL)) | |
2509 { | |
2510 xmlroot = xmlnode_from_str(smsmsg, -1); | |
2511 if (xmlroot != NULL) | |
2512 { | |
2513 xmltmp = xmlnode_get_child(xmlroot, "sender"); | |
2514 if (xmltmp != NULL) | |
2515 uin = xmlnode_get_data(xmltmp); | |
2516 | |
2517 xmltmp = xmlnode_get_child(xmlroot, "text"); | |
2518 if (xmltmp != NULL) | |
2519 message = xmlnode_get_data(xmltmp); | |
2520 | |
2521 if ((uin != NULL) && (message != NULL)) | |
2522 serv_got_im(gc, uin, message, 0, time(NULL)); | |
2523 | |
2524 g_free(uin); | |
2525 g_free(message); | |
2526 xmlnode_free(xmlroot); | |
2527 } | |
2528 } | |
2529 g_free(tagstr); | |
2530 g_free(smsmsg); | |
2491 } break; | 2531 } break; |
2492 | 2532 |
2493 default: { | 2533 default: { |
2494 purple_debug_info("oscar", | 2534 purple_debug_info("oscar", |
2495 "Received a channel 4 message of unknown type " | 2535 "Received a channel 4 message of unknown type " |
4152 | 4192 |
4153 od = (OscarData *)gc->proto_data; | 4193 od = (OscarData *)gc->proto_data; |
4154 account = purple_connection_get_account(gc); | 4194 account = purple_connection_get_account(gc); |
4155 ret = 0; | 4195 ret = 0; |
4156 | 4196 |
4197 if (od->icq && aim_sn_is_sms(name)) { | |
4198 /* | |
4199 * We're sending to a phone number and this is ICQ, | |
4200 * so send the message as an SMS using aim_icq_sendsms() | |
4201 */ | |
4202 int ret; | |
4203 purple_debug_info("oscar", "Sending SMS to %s.\n", name); | |
4204 ret = aim_icq_sendsms(od, name, message, purple_account_get_username(account)); | |
4205 return (ret >= 0 ? 1 : ret); | |
4206 } | |
4207 | |
4157 if (imflags & PURPLE_MESSAGE_AUTO_RESP) | 4208 if (imflags & PURPLE_MESSAGE_AUTO_RESP) |
4158 tmp1 = purple_str_sub_away_formatters(message, name); | 4209 tmp1 = purple_str_sub_away_formatters(message, name); |
4159 else | 4210 else |
4160 tmp1 = g_strdup(message); | 4211 tmp1 = g_strdup(message); |
4161 | 4212 |