Changeset a0a5179 for libfaim


Ignore:
Timestamp:
Nov 19, 2003, 11:19:03 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f1645da
Parents:
52f3507
Message:
blist works for AIM even if the zephyr .anyone can't be read
AIM Buddy debugging
Location:
libfaim
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfaim/aim_cbtypes.h

    re374dee ra0a5179  
    212212#define AIM_CB_SSI_REQDATA 0x0004
    213213#define AIM_CB_SSI_REQIFCHANGED 0x0005
     214#define AIM_CB_SSI_REQLIST 0x0005
    214215#define AIM_CB_SSI_LIST 0x0006
    215216#define AIM_CB_SSI_ACTIVATE 0x0007
  • libfaim/ssi.c

    ra053de8 ra0a5179  
    4141  int newlen;
    4242  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);
    4647 
    4748  /* 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);
    5050 
    5151  /* Free the old data */
     
    6464        newlen += 2;
    6565  }
     66  owl_function_debugmsg("aim_ssi_itemlist_rebuildgroup: newlen is %i", newlen);
    6667 
    6768  /* Build the new TLV list */
     
    6970    fu8_t *newdata;
    7071   
    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;
    7373    newlen = 0;
    7474    if (group->gid == 0x0000) {
     
    8585    free(newdata);
    8686  }
    87  
     87
     88  owl_function_debugmsg("aim_ssi_itemlist_rebuildgroup: exiting");
    8889  return group;
    8990}
     
    177178  if (!list || !(*list) || !del) return -EINVAL;
    178179
     180  owl_function_debugmsg("aim_ssi_itemlist_del: in");
    179181  /* Remove the item from the list */
    180182  if (*list == del) {
    181183    *list = (*list)->next;
     184    owl_function_debugmsg("aim_ssi_itemlist_del: deleted %s from beginning of list", del->name);
    182185  } else {
    183186    struct aim_ssi_item *cur;
    184187    for (cur=*list; (cur->next && (cur->next!=del)); cur=cur->next);
    185188    if (cur->next) cur->next=cur->next->next;
     189    owl_function_debugmsg("aim_ssi_itemlist_del: deleted %s from middle of list", del->name);
    186190  }
    187191
    188192  /* Free the deleted item */
     193  owl_function_debugmsg("aim_ssi_itemlist_del: freeing");
    189194  free(del->name);
    190195  aim_freetlvchain(&del->data);
     
    450455  struct aim_ssi_item *cur1, *cur2;
    451456  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
    456462  /* 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");
    458465    return 0;
     466  }
    459467 
    460468  /*
     
    466474   * buddy ID#s, which makes things more efficient.  I think.
    467475   */
    468  
     476
    469477  /* Additions */
    470478  if (!sess->ssi.pending) {
    471479    for (cur1=sess->ssi.local; cur1; cur1=cur1->next) {
    472480      if (!aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid)) {
     481        owl_function_debugmsg("aim_ssi_sync: doing addition");
    473482        new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
    474483        new->action = AIM_CB_SSI_ADD;
     
    490499    for (cur1=sess->ssi.official; cur1; cur1=cur1->next) {
    491500      if (!aim_ssi_itemlist_find(sess->ssi.local, cur1->gid, cur1->bid)) {
     501        owl_function_debugmsg("aim_ssi_sync: doing deletion");
    492502        new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
    493503        new->action = AIM_CB_SSI_DEL;
     
    510520      cur2 = aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid);
    511521      if (cur2 && (aim_ssi_itemlist_cmp(cur1, cur2))) {
     522        owl_function_debugmsg("aim_ssi_sync: doing modification");
    512523        new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
    513524        new->action = AIM_CB_SSI_MOD;
     
    527538  /* We're out of stuff to do, so tell the AIM servers we're done and exit */
    528539  if (!sess->ssi.pending) {
     540    owl_function_debugmsg("aim_ssi_sync: telling server we're done modifying SSI data.");
    529541    aim_ssi_modend(sess);
    530542    return 0;
     
    533545  /* Make sure we don't send anything else between now
    534546   * and when we receive the ack for the following operation */
     547  owl_function_debugmsg("aim_ssi_sync: setting SSI waiting_for_ack");
    535548  sess->ssi.waiting_for_ack = 1;
    536549 
    537550  /* 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");
    538552  aim_ssi_addmoddel(sess);
    539553 
     
    789803  /* Remove the item from the list */
    790804  aim_ssi_itemlist_del(&sess->ssi.local, del);
    791  
     805
    792806  /* Modify the parent group */
    793807  aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group);
     
    807821 
    808822  /* Sync our local list with the server list */
     823  owl_function_debugmsg("aim_ssi_delbuddy: about to sync");
    809824  aim_ssi_sync(sess);
    810825 
     
    12611276  struct aim_ssi_tmp *cur;
    12621277 
    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");
    12641280    return -EINVAL;
     1281  }
    12651282 
    12661283  /* Calculate total SNAC size */
     
    12681285  for (cur=sess->ssi.pending; cur; cur=cur->next) {
    12691286    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);
    12781292 
    12791293  snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, sess->ssi.pending->action, 0x0000, NULL, 0);
     
    12821296  for (cur=sess->ssi.pending; cur; cur=cur->next) {
    12831297    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));
    12861299    aimbs_put16(&fr->data, cur->item->gid);
    12871300    aimbs_put16(&fr->data, cur->item->bid);
    12881301    aimbs_put16(&fr->data, cur->item->type);
    12891302    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);
    12921304  }
    12931305 
    12941306  aim_tx_enqueue(sess, fr);
    1295  
     1307
     1308  owl_function_debugmsg("aim_ssi_addmoddel: exiting normally");
    12961309  return 0;
    12971310}
     
    14411454  aim_rxcallback_t userfunc;
    14421455  struct aim_ssi_tmp *cur, *del;
     1456
     1457  owl_function_debugmsg("Handling SNAC SSI ACK");
    14431458 
    14441459  /* Read in the success/failure flags from the ack SNAC */
     
    14551470   */
    14561471  for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) {
     1472    owl_function_debugmsg("parseack: processing a change");
    14571473    if (cur->item) {
    14581474      if (cur->ack) {
    14591475        /* Our action was unsuccessful, so change the local list back to how it was */
    14601476        if (cur->action == AIM_CB_SSI_ADD) {
     1477          owl_function_debugmsg("parseack: unsuccesful add, reverting");
    14611478          /* Remove the item from the local list */
    14621479          /* Make sure cur->item is still valid memory */
     
    14721489        } else if (cur->action == AIM_CB_SSI_MOD) {
    14731490          /* Replace the local item with the item from the official list */
     1491          owl_function_debugmsg("parseack: unsuccesful modify, reverting");
    14741492          if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
    14751493            struct aim_ssi_item *cur1;
     
    14891507        } else if (cur->action == AIM_CB_SSI_DEL) {
    14901508          /* Add the item back into the local list */
     1509          owl_function_debugmsg("parseack: unsuccesful delete, reverting");
    14911510          if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item)) {
    14921511            aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
     
    14991518        if (cur->action == AIM_CB_SSI_ADD) {
    15001519          /* Add the local item to the official list */
     1520          owl_function_debugmsg("parseack: succesful add");
    15011521          if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
    15021522            aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
     
    15061526        } else if (cur->action == AIM_CB_SSI_MOD) {
    15071527          /* Replace the official item with the item from the local list */
     1528          owl_function_debugmsg("parseack: succesful modify");
    15081529          if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
    15091530            struct aim_ssi_item *cur1;
     
    15231544        } else if (cur->action == AIM_CB_SSI_DEL) {
    15241545          /* Remove the item from the official list */
     1546          owl_function_debugmsg("parseack: succesful delete");
    15251547          if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item))
    15261548            aim_ssi_itemlist_del(&sess->ssi.official, cur->item);
     
    15461568 
    15471569  /* If we're not waiting for any more acks, then send more SNACs */
     1570
    15481571  if (!sess->ssi.pending) {
    15491572    sess->ssi.pending = NULL;
    15501573    sess->ssi.waiting_for_ack = 0;
     1574    owl_function_debugmsg("parseack: Clearing SSI waiting_for_ack");
    15511575    aim_ssi_sync(sess);
    15521576  }
     1577
     1578  owl_function_debugmsg("parseack: returning with %i", ret);
    15531579 
    15541580  return ret;
     
    16011627  aim_conn_t *conn;
    16021628 
    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;
    16051630 
    16061631  return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_EDITSTOP);
Note: See TracChangeset for help on using the changeset viewer.