| 314 aimbs_putle16(&fr->data, 0x0998); /* shrug. */ |
314 aimbs_putle16(&fr->data, 0x0998); /* shrug. */ |
| 315 aimbs_putle16(&fr->data, strlen(xml) + 1); |
315 aimbs_putle16(&fr->data, strlen(xml) + 1); |
| 316 aimbs_putraw(&fr->data, xml, strlen(xml) + 1); |
316 aimbs_putraw(&fr->data, xml, strlen(xml) + 1); |
| 317 |
317 |
| 318 aim_tx_enqueue(sess, fr); |
318 aim_tx_enqueue(sess, fr); |
| |
319 |
| |
320 return 0; |
| |
321 } |
| |
322 |
| |
323 /* |
| |
324 * Send an SMS message. This is the non-US way. The US-way is to IM |
| |
325 * their cell phone number (+19195551234). |
| |
326 * |
| |
327 * We basically construct and send an XML message. The format is: |
| |
328 * <icq_sms_message> |
| |
329 * <destination>full_phone_without_leading_+</destination> |
| |
330 * <text>message</text> |
| |
331 * <codepage>1252</codepage> |
| |
332 * <senders_UIN>self_uin</senders_UIN> |
| |
333 * <senders_name>self_name</senders_name> |
| |
334 * <delivery_receipt>Yes|No</delivery_receipt> |
| |
335 * <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time> |
| |
336 * </icq_sms_message> |
| |
337 * |
| |
338 * Yeah hi Peter, whaaaat's happening. If there's any way to use |
| |
339 * a codepage other than 1252 that would be great. Thaaaanks. |
| |
340 */ |
| |
341 faim_export int aim_icq_sendsms(aim_session_t *sess, const char *name, const char *msg, const char *alias) |
| |
342 { |
| |
343 aim_conn_t *conn; |
| |
344 aim_frame_t *fr; |
| |
345 aim_snacid_t snacid; |
| |
346 int bslen, xmllen; |
| |
347 char *xml, timestr[30]; |
| |
348 time_t t; |
| |
349 struct tm *tm; |
| |
350 |
| |
351 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
| |
352 return -EINVAL; |
| |
353 |
| |
354 if (!name || !msg || !alias) |
| |
355 return -EINVAL; |
| |
356 |
| |
357 time(&t); |
| |
358 tm = gmtime(&t); |
| |
359 strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm); |
| |
360 |
| |
361 /* The length of xml included the null terminating character */ |
| |
362 xmllen = 500 + strlen(name) + strlen(msg) + strlen(sess->sn) + strlen(alias) + strlen(timestr) + 1; |
| |
363 |
| |
364 if (!(xml = (char *)malloc(xmllen*sizeof(char)))) |
| |
365 return -ENOMEM; |
| |
366 snprintf(xml, xmllen, "<icq_sms_message>\n" |
| |
367 "\t<destination>%s</destination>\n" |
| |
368 "\t<text>%s</text>\n" |
| |
369 "\t<codepage>1252</codepage>\n" |
| |
370 "\t<senders_UIN>%s</senders_UIN>\n" |
| |
371 "\t<senders_name>%s</senders_name>\n" |
| |
372 "\t<delivery_receipt>Yes</delivery_receipt>\n" |
| |
373 "\t<time>%s</time>\n" |
| |
374 "</icq_sms_message>\n", |
| |
375 name, msg, sess->sn, alias, timestr); |
| |
376 |
| |
377 bslen = 37 + xmllen; |
| |
378 |
| |
379 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) { |
| |
380 free(xml); |
| |
381 return -ENOMEM; |
| |
382 } |
| |
383 |
| |
384 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); |
| |
385 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); |
| |
386 |
| |
387 /* For simplicity, don't bother using a tlvlist */ |
| |
388 aimbs_put16(&fr->data, 0x0001); |
| |
389 aimbs_put16(&fr->data, bslen); |
| |
390 |
| |
391 aimbs_putle16(&fr->data, bslen - 2); |
| |
392 aimbs_putle32(&fr->data, atoi(sess->sn)); |
| |
393 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ |
| |
394 aimbs_putle16(&fr->data, snacid); /* eh. */ |
| |
395 |
| |
396 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */ |
| |
397 aimbs_putle16(&fr->data, 0x8214); |
| |
398 aimbs_put16(&fr->data, 0x0001); |
| |
399 aimbs_put16(&fr->data, 0x0016); |
| |
400 aimbs_put32(&fr->data, 0x00000000); |
| |
401 aimbs_put32(&fr->data, 0x00000000); |
| |
402 aimbs_put32(&fr->data, 0x00000000); |
| |
403 aimbs_put32(&fr->data, 0x00000000); |
| |
404 |
| |
405 aimbs_put16(&fr->data, 0x0000); |
| |
406 aimbs_put16(&fr->data, xmllen); |
| |
407 aimbs_putraw(&fr->data, xml, xmllen); |
| |
408 |
| |
409 aim_tx_enqueue(sess, fr); |
| |
410 |
| |
411 free(xml); |
| 319 |
412 |
| 320 return 0; |
413 return 0; |
| 321 } |
414 } |
| 322 |
415 |
| 323 static void aim_icq_freeinfo(struct aim_icq_info *info) { |
416 static void aim_icq_freeinfo(struct aim_icq_info *info) { |