src/protocols/oscar/im.c

changeset 2673
84bb25b76700
parent 2672
5c9b7617a1f3
child 2703
6111a9790868
equal deleted inserted replaced
2672:5c9b7617a1f3 2673:84bb25b76700
142 * 142 *
143 * XXX more precise verification that we never send SNACs larger than 8192 143 * XXX more precise verification that we never send SNACs larger than 8192
144 * XXX check SNAC size for multipart 144 * XXX check SNAC size for multipart
145 * 145 *
146 */ 146 */
147 faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct aim_sendimext_args *args) 147 faim_export int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args)
148 { 148 {
149 static const fu8_t deffeatures[] = { 149 static const fu8_t deffeatures[] = {
150 0x01, 0x01, 0x01, 0x02 150 0x01, 0x01, 0x01, 0x02
151 }; 151 };
152 aim_conn_t *conn;
152 int i, msgtlvlen; 153 int i, msgtlvlen;
153 aim_frame_t *fr; 154 aim_frame_t *fr;
154 aim_snacid_t snacid; 155 aim_snacid_t snacid;
155 156
156 if (!sess || !conn || !args) 157 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
158 return -EINVAL;
159
160 if (!args)
157 return -EINVAL; 161 return -EINVAL;
158 162
159 if (args->flags & AIM_IMFLAGS_MULTIPART) { 163 if (args->flags & AIM_IMFLAGS_MULTIPART) {
160 if (args->mpmsg->numparts <= 0) 164 if (args->mpmsg->numparts <= 0)
161 return -EINVAL; 165 return -EINVAL;
338 * 342 *
339 * aim_send_im also cannot be used if you require UNICODE messages, because 343 * aim_send_im also cannot be used if you require UNICODE messages, because
340 * that requires an explicit message length. Use aim_send_im_ext(). 344 * that requires an explicit message length. Use aim_send_im_ext().
341 * 345 *
342 */ 346 */
343 faim_export int aim_send_im(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu16_t flags, const char *msg) 347 faim_export int aim_send_im(aim_session_t *sess, const char *destsn, fu16_t flags, const char *msg)
344 { 348 {
345 struct aim_sendimext_args args; 349 struct aim_sendimext_args args;
346 350
347 args.destsn = destsn; 351 args.destsn = destsn;
348 args.flags = flags; 352 args.flags = flags;
350 args.msglen = strlen(msg); 354 args.msglen = strlen(msg);
351 355
352 /* Make these don't get set by accident -- they need aim_send_im_ext */ 356 /* Make these don't get set by accident -- they need aim_send_im_ext */
353 args.flags &= ~(AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_HASICON | AIM_IMFLAGS_MULTIPART); 357 args.flags &= ~(AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_HASICON | AIM_IMFLAGS_MULTIPART);
354 358
355 return aim_send_im_ext(sess, conn, &args); 359 return aim_send_im_ext(sess, &args);
356 } 360 }
357 361
358 /* 362 /*
359 * This is also performance sensitive. (If you can believe it...) 363 * This is also performance sensitive. (If you can believe it...)
360 * 364 *
361 */ 365 */
362 faim_export int aim_send_icon(aim_session_t *sess, aim_conn_t *conn, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum) 366 faim_export int aim_send_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum)
363 { 367 {
368 aim_conn_t *conn;
364 int i; 369 int i;
365 fu8_t ck[8]; 370 fu8_t ck[8];
366 aim_frame_t *fr; 371 aim_frame_t *fr;
367 aim_snacid_t snacid; 372 aim_snacid_t snacid;
368 373
369 if (!sess || !conn || !sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN)) 374 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
370 return -EINVAL; 375 return -EINVAL;
371 376
372 if (conn->type != AIM_CONN_TYPE_BOS) 377 if (!sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN))
373 return -EINVAL; 378 return -EINVAL;
374 379
375 for (i = 0; i < 8; i++) 380 for (i = 0; i < 8; i++)
376 aimutil_put8(ck+i, (fu8_t) rand()); 381 aimutil_put8(ck+i, (fu8_t) rand());
377 382
1444 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" 1449 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
1445 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" 1450 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
1446 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" 1451 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
1447 * 1452 *
1448 */ 1453 */
1449 faim_export int aim_denytransfer(aim_session_t *sess, aim_conn_t *conn, const char *sender, const char *cookie, fu16_t code) 1454 faim_export int aim_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code)
1450 { 1455 {
1456 aim_conn_t *conn;
1451 aim_frame_t *fr; 1457 aim_frame_t *fr;
1452 aim_snacid_t snacid; 1458 aim_snacid_t snacid;
1453 aim_tlvlist_t *tl = NULL; 1459 aim_tlvlist_t *tl = NULL;
1454 1460
1461 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
1462 return -EINVAL;
1463
1455 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sender)+6))) 1464 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sender)+6)))
1456 return -ENOMEM; 1465 return -ENOMEM;
1457 1466
1458 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0); 1467 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0);
1459 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid); 1468 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid);
1477 * aim_reqicbmparaminfo() 1486 * aim_reqicbmparaminfo()
1478 * 1487 *
1479 * Request ICBM parameter information. 1488 * Request ICBM parameter information.
1480 * 1489 *
1481 */ 1490 */
1482 faim_export int aim_reqicbmparams(aim_session_t *sess, aim_conn_t *conn) 1491 faim_export int aim_reqicbmparams(aim_session_t *sess)
1483 { 1492 {
1493 aim_conn_t *conn;
1494
1495 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
1496 return -EINVAL;
1497
1484 return aim_genericreq_n(sess, conn, 0x0004, 0x0004); 1498 return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
1485 } 1499 }
1486 1500
1487 /* 1501 /*
1488 * 1502 *
1489 * I definitly recommend sending this. If you don't, you'll be stuck 1503 * I definitly recommend sending this. If you don't, you'll be stuck
1490 * with the rather unreasonable defaults. You don't want those. Send this. 1504 * with the rather unreasonable defaults. You don't want those. Send this.
1491 * 1505 *
1492 */ 1506 */
1493 faim_export int aim_seticbmparam(aim_session_t *sess, aim_conn_t *conn, struct aim_icbmparameters *params) 1507 faim_export int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params)
1494 { 1508 {
1509 aim_conn_t *conn;
1495 aim_frame_t *fr; 1510 aim_frame_t *fr;
1496 aim_snacid_t snacid; 1511 aim_snacid_t snacid;
1497 1512
1498 if (!sess || !conn || !params) 1513 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
1514 return -EINVAL;
1515
1516 if (!params)
1499 return -EINVAL; 1517 return -EINVAL;
1500 1518
1501 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16))) 1519 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16)))
1502 return -ENOMEM; 1520 return -ENOMEM;
1503 1521

mercurial