- Timestamp:
- Nov 19, 2003, 11:19:03 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- f1645da
- Parents:
- 52f3507
- Location:
- libfaim
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/aim_cbtypes.h
re374dee ra0a5179 212 212 #define AIM_CB_SSI_REQDATA 0x0004 213 213 #define AIM_CB_SSI_REQIFCHANGED 0x0005 214 #define AIM_CB_SSI_REQLIST 0x0005 214 215 #define AIM_CB_SSI_LIST 0x0006 215 216 #define AIM_CB_SSI_ACTIVATE 0x0007 -
libfaim/ssi.c
ra053de8 ra0a5179 41 41 int newlen; 42 42 struct aim_ssi_item *cur, *group; 43 44 if (!list) 45 return NULL; 43 44 owl_function_debugmsg("aim_ssi_itemlist_rebuildgroup: in for group %s", name?name:"NULL"); 45 46 if (!list) return(NULL); 46 47 47 48 /* Find the group */ 48 if (!(group = aim_ssi_itemlist_finditem(list, name, NULL, AIM_SSI_TYPE_GROUP))) 49 return NULL; 49 if (!(group = aim_ssi_itemlist_finditem(list, name, NULL, AIM_SSI_TYPE_GROUP))) return(NULL); 50 50 51 51 /* Free the old data */ … … 64 64 newlen += 2; 65 65 } 66 owl_function_debugmsg("aim_ssi_itemlist_rebuildgroup: newlen is %i", newlen); 66 67 67 68 /* Build the new TLV list */ … … 69 70 fu8_t *newdata; 70 71 71 if (!(newdata = (fu8_t *)malloc((newlen)*sizeof(fu8_t)))) 72 return NULL; 72 if (!(newdata = (fu8_t *)malloc((newlen)*sizeof(fu8_t)))) return NULL; 73 73 newlen = 0; 74 74 if (group->gid == 0x0000) { … … 85 85 free(newdata); 86 86 } 87 87 88 owl_function_debugmsg("aim_ssi_itemlist_rebuildgroup: exiting"); 88 89 return group; 89 90 } … … 177 178 if (!list || !(*list) || !del) return -EINVAL; 178 179 180 owl_function_debugmsg("aim_ssi_itemlist_del: in"); 179 181 /* Remove the item from the list */ 180 182 if (*list == del) { 181 183 *list = (*list)->next; 184 owl_function_debugmsg("aim_ssi_itemlist_del: deleted %s from beginning of list", del->name); 182 185 } else { 183 186 struct aim_ssi_item *cur; 184 187 for (cur=*list; (cur->next && (cur->next!=del)); cur=cur->next); 185 188 if (cur->next) cur->next=cur->next->next; 189 owl_function_debugmsg("aim_ssi_itemlist_del: deleted %s from middle of list", del->name); 186 190 } 187 191 188 192 /* Free the deleted item */ 193 owl_function_debugmsg("aim_ssi_itemlist_del: freeing"); 189 194 free(del->name); 190 195 aim_freetlvchain(&del->data); … … 450 455 struct aim_ssi_item *cur1, *cur2; 451 456 struct aim_ssi_tmp *cur, *new; 452 453 if (!sess) 454 return -EINVAL; 455 457 458 owl_function_debugmsg("aim_ssi_sync: beginning"); 459 460 if (!sess) return (-EINVAL); 461 456 462 /* If we're waiting for an ack, we shouldn't do anything else */ 457 if (sess->ssi.waiting_for_ack) 463 if (sess->ssi.waiting_for_ack) { 464 owl_function_debugmsg("Aborting aim_ssi_sync, waiting for ack"); 458 465 return 0; 466 } 459 467 460 468 /* … … 466 474 * buddy ID#s, which makes things more efficient. I think. 467 475 */ 468 476 469 477 /* Additions */ 470 478 if (!sess->ssi.pending) { 471 479 for (cur1=sess->ssi.local; cur1; cur1=cur1->next) { 472 480 if (!aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid)) { 481 owl_function_debugmsg("aim_ssi_sync: doing addition"); 473 482 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp)); 474 483 new->action = AIM_CB_SSI_ADD; … … 490 499 for (cur1=sess->ssi.official; cur1; cur1=cur1->next) { 491 500 if (!aim_ssi_itemlist_find(sess->ssi.local, cur1->gid, cur1->bid)) { 501 owl_function_debugmsg("aim_ssi_sync: doing deletion"); 492 502 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp)); 493 503 new->action = AIM_CB_SSI_DEL; … … 510 520 cur2 = aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid); 511 521 if (cur2 && (aim_ssi_itemlist_cmp(cur1, cur2))) { 522 owl_function_debugmsg("aim_ssi_sync: doing modification"); 512 523 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp)); 513 524 new->action = AIM_CB_SSI_MOD; … … 527 538 /* We're out of stuff to do, so tell the AIM servers we're done and exit */ 528 539 if (!sess->ssi.pending) { 540 owl_function_debugmsg("aim_ssi_sync: telling server we're done modifying SSI data."); 529 541 aim_ssi_modend(sess); 530 542 return 0; … … 533 545 /* Make sure we don't send anything else between now 534 546 * and when we receive the ack for the following operation */ 547 owl_function_debugmsg("aim_ssi_sync: setting SSI waiting_for_ack"); 535 548 sess->ssi.waiting_for_ack = 1; 536 549 537 550 /* Now go mail off our data and wait 4 to 6 weeks */ 551 owl_function_debugmsg("aim_ssi_sync: about to call addmoddel to send SNACs to server"); 538 552 aim_ssi_addmoddel(sess); 539 553 … … 789 803 /* Remove the item from the list */ 790 804 aim_ssi_itemlist_del(&sess->ssi.local, del); 791 805 792 806 /* Modify the parent group */ 793 807 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group); … … 807 821 808 822 /* Sync our local list with the server list */ 823 owl_function_debugmsg("aim_ssi_delbuddy: about to sync"); 809 824 aim_ssi_sync(sess); 810 825 … … 1261 1276 struct aim_ssi_tmp *cur; 1262 1277 1263 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sess->ssi.pending || !sess->ssi.pending->item) 1278 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sess->ssi.pending || !sess->ssi.pending->item) { 1279 owl_function_debugmsg("aim_ssi_addmoddel: aborting early"); 1264 1280 return -EINVAL; 1281 } 1265 1282 1266 1283 /* Calculate total SNAC size */ … … 1268 1285 for (cur=sess->ssi.pending; cur; cur=cur->next) { 1269 1286 snaclen += 10; /* For length, GID, BID, type, and length */ 1270 if (cur->item->name) 1271 snaclen += strlen(cur->item->name); 1272 if (cur->item->data) 1273 snaclen += aim_sizetlvchain(&cur->item->data); 1274 } 1275 1276 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) 1277 return -ENOMEM; 1287 if (cur->item->name) snaclen += strlen(cur->item->name); 1288 if (cur->item->data) snaclen += aim_sizetlvchain(&cur->item->data); 1289 } 1290 1291 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) return (-ENOMEM); 1278 1292 1279 1293 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, sess->ssi.pending->action, 0x0000, NULL, 0); … … 1282 1296 for (cur=sess->ssi.pending; cur; cur=cur->next) { 1283 1297 aimbs_put16(&fr->data, cur->item->name ? strlen(cur->item->name) : 0); 1284 if (cur->item->name) 1285 aimbs_putraw(&fr->data, cur->item->name, strlen(cur->item->name)); 1298 if (cur->item->name) aimbs_putraw(&fr->data, cur->item->name, strlen(cur->item->name)); 1286 1299 aimbs_put16(&fr->data, cur->item->gid); 1287 1300 aimbs_put16(&fr->data, cur->item->bid); 1288 1301 aimbs_put16(&fr->data, cur->item->type); 1289 1302 aimbs_put16(&fr->data, cur->item->data ? aim_sizetlvchain(&cur->item->data) : 0); 1290 if (cur->item->data) 1291 aim_writetlvchain(&fr->data, &cur->item->data); 1303 if (cur->item->data) aim_writetlvchain(&fr->data, &cur->item->data); 1292 1304 } 1293 1305 1294 1306 aim_tx_enqueue(sess, fr); 1295 1307 1308 owl_function_debugmsg("aim_ssi_addmoddel: exiting normally"); 1296 1309 return 0; 1297 1310 } … … 1441 1454 aim_rxcallback_t userfunc; 1442 1455 struct aim_ssi_tmp *cur, *del; 1456 1457 owl_function_debugmsg("Handling SNAC SSI ACK"); 1443 1458 1444 1459 /* Read in the success/failure flags from the ack SNAC */ … … 1455 1470 */ 1456 1471 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) { 1472 owl_function_debugmsg("parseack: processing a change"); 1457 1473 if (cur->item) { 1458 1474 if (cur->ack) { 1459 1475 /* Our action was unsuccessful, so change the local list back to how it was */ 1460 1476 if (cur->action == AIM_CB_SSI_ADD) { 1477 owl_function_debugmsg("parseack: unsuccesful add, reverting"); 1461 1478 /* Remove the item from the local list */ 1462 1479 /* Make sure cur->item is still valid memory */ … … 1472 1489 } else if (cur->action == AIM_CB_SSI_MOD) { 1473 1490 /* Replace the local item with the item from the official list */ 1491 owl_function_debugmsg("parseack: unsuccesful modify, reverting"); 1474 1492 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { 1475 1493 struct aim_ssi_item *cur1; … … 1489 1507 } else if (cur->action == AIM_CB_SSI_DEL) { 1490 1508 /* Add the item back into the local list */ 1509 owl_function_debugmsg("parseack: unsuccesful delete, reverting"); 1491 1510 if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item)) { 1492 1511 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); … … 1499 1518 if (cur->action == AIM_CB_SSI_ADD) { 1500 1519 /* Add the local item to the official list */ 1520 owl_function_debugmsg("parseack: succesful add"); 1501 1521 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { 1502 1522 aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); … … 1506 1526 } else if (cur->action == AIM_CB_SSI_MOD) { 1507 1527 /* Replace the official item with the item from the local list */ 1528 owl_function_debugmsg("parseack: succesful modify"); 1508 1529 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { 1509 1530 struct aim_ssi_item *cur1; … … 1523 1544 } else if (cur->action == AIM_CB_SSI_DEL) { 1524 1545 /* Remove the item from the official list */ 1546 owl_function_debugmsg("parseack: succesful delete"); 1525 1547 if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item)) 1526 1548 aim_ssi_itemlist_del(&sess->ssi.official, cur->item); … … 1546 1568 1547 1569 /* If we're not waiting for any more acks, then send more SNACs */ 1570 1548 1571 if (!sess->ssi.pending) { 1549 1572 sess->ssi.pending = NULL; 1550 1573 sess->ssi.waiting_for_ack = 0; 1574 owl_function_debugmsg("parseack: Clearing SSI waiting_for_ack"); 1551 1575 aim_ssi_sync(sess); 1552 1576 } 1577 1578 owl_function_debugmsg("parseack: returning with %i", ret); 1553 1579 1554 1580 return ret; … … 1601 1627 aim_conn_t *conn; 1602 1628 1603 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI))) 1604 return -EINVAL; 1629 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI))) return -EINVAL; 1605 1630 1606 1631 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_EDITSTOP);
Note: See TracChangeset
for help on using the changeset viewer.