Changeset 8c46404 for aim.c


Ignore:
Timestamp:
Dec 10, 2003, 3:20:39 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:
cf02dd6
Parents:
b6a7367
Message:
Massive changes to AIM.  Feel the burn.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    ra0a5179 r8c46404  
    6262void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn);
    6363static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...);
    64 int login(aim_session_t *sess, const char *sn, const char *passwd);
    6564static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...);
    6665int logout(aim_session_t *sess);
     
    7978static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname);
    8079static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...);
    81 static void printuserflags(fu16_t flags);
     80/* static void printuserflags(fu16_t flags); */
    8281static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...);
    8382static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, const char *tmpstr);
     
    105104static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...);
    106105
     106static int faimtest_ssi_parseerr     (aim_session_t *, aim_frame_t *, ...);
     107static int faimtest_ssi_parserights  (aim_session_t *, aim_frame_t *, ...);
     108static int faimtest_ssi_parselist    (aim_session_t *, aim_frame_t *, ...);
     109static int faimtest_ssi_parseack     (aim_session_t *, aim_frame_t *, ...);
     110static int faimtest_ssi_authgiven    (aim_session_t *, aim_frame_t *, ...);
     111static int faimtest_ssi_authrequest  (aim_session_t *, aim_frame_t *, ...);
     112static int faimtest_ssi_authreply    (aim_session_t *, aim_frame_t *, ...);
     113static int faimtest_ssi_gotadded     (aim_session_t *, aim_frame_t *, ...);
     114
     115
    107116void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir);
    108117void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir);
     
    112121void owl_aim_init(void)
    113122{
    114   aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
     123  /* aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); */
     124
     125  /*
     126  aim_session_init(owl_global_get_aimsess(&g), TRUE, 0);
    115127  aim_setdebuggingcb(owl_global_get_aimsess(&g), faimtest_debugcb);
    116 
     128  aim_tx_setenqueue(owl_global_get_aimsess(&g), AIM_TX_IMMEDIATE, NULL);
     129  */
    117130  /* an experiment to expose idle time */
    118131  /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */
     
    122135int owl_aim_login(char *screenname, char *password)
    123136{
    124   int ret;
    125137  struct owlfaim_priv *priv;
    126 
     138  aim_conn_t *conn;
     139  aim_session_t *sess;
     140
     141  sess=owl_global_get_aimsess(&g);
     142
     143  aim_session_init(sess, TRUE, 0);
     144  aim_setdebuggingcb(sess, faimtest_debugcb);
     145  aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL);
     146 
    127147  /* this will leak, I know and just don't care right now */
    128148  priv=owl_malloc(sizeof(struct owlfaim_priv));
     
    131151  priv->screenname = owl_strdup(screenname);
    132152  priv->password = owl_strdup(password);
    133   priv->server = "login.oscar.aol.com";
    134   owl_global_get_aimsess(&g)->aux_data = priv;
    135 
    136   aim_tx_setenqueue(owl_global_get_aimsess(&g), AIM_TX_IMMEDIATE, NULL);
    137  
    138   /* request a login */
    139   ret=login(owl_global_get_aimsess(&g), priv->screenname, priv->password);
    140   if (ret) {
     153  priv->server = owl_strdup(FAIM_LOGIN_SERVER);
     154  sess->aux_data = priv;
     155
     156  conn=aim_newconn(sess, AIM_CONN_TYPE_AUTH, priv->server ? priv->server : FAIM_LOGIN_SERVER);
     157  /*  conn=aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); */
     158  if (!conn) {
     159    owl_function_error("owl_aim_login: connection error during AIM login\n");
    141160    owl_global_set_aimnologgedin(&g);
    142161    owl_global_set_no_doaimevents(&g);
     162    return (-1);
     163  }
     164
     165  /*
     166  else if (conn->fd == -1) {
     167    if (conn->status & AIM_CONN_STATUS_RESOLVERR) {
     168      owl_function_error("owl_aim_login: could not resolve authorize name");
     169    } else if (conn->status & AIM_CONN_STATUS_CONNERR) {
     170      owl_function_error("owl_aim_login: could not connect to authorizer");
     171    } else {
     172      owl_function_error("owl_aim_login: unknown connection error");
     173    }
     174    owl_global_set_aimnologgedin(&g);
     175    owl_global_set_no_doaimevents(&g);
     176    aim_conn_kill(sess, &conn);
    143177    return(-1);
    144178  }
    145 
     179  */
     180
     181   
     182  aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
     183  aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
     184
     185  aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_AUTHRESPONSE, faimtest_parse_login, 0);
     186  aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_LOGINRESPONSE, faimtest_parse_authresp, 0);
     187  /* aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); */
     188  /* aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); */
     189  /* aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); */
     190   
    146191  /* start processing AIM events */
    147192  owl_global_set_doaimevents(&g);
     193  /* conn->status |= AIM_CONN_STATUS_INPROGRESS; */
     194  owl_function_debugmsg("owl_aim_login: sending login request for %s", screenname);
     195  aim_request_login(sess, conn, screenname);
     196  owl_function_debugmsg("owl_aim_login: connecting");
    148197
    149198  return(0);
     
    237286  /* there is a max away message lentgh we should check against */
    238287
     288  /*
    239289  aim_bos_setprofile(owl_global_get_aimsess(&g),
    240290                     owl_global_get_bosconn(&g),
    241291                     NULL, NULL, 0, "us-ascii", msg,
    242292                     strlen(msg), 0);
     293  */
    243294  return(0);
    244295}
     
    364415  va_end(ap);
    365416
    366   owl_function_debugmsg("doing faimtest_parse_login");
     417  owl_function_debugmsg("faimtest_parse_login: %s %s %s", priv->screenname, priv->password, key);
    367418
    368419  aim_send_login(sess, fr->conn, priv->screenname, priv->password, &info, key);
     
    504555  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, offlinemsgdone, 0);
    505556
     557  /*
     558  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR,              faimtest_ssi_parseerr, 0);
     559  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO,         faimtest_ssi_parserights, 0);
     560  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST,               faimtest_ssi_parselist, 0);
     561  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST,             faimtest_ssi_parselist, 0);
     562  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK,             faimtest_ssi_parseack, 0);
     563  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH,           faimtest_ssi_authgiven, 0);
     564  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ,        faimtest_ssi_authrequest, 0);
     565  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP,        faimtest_ssi_authreply, 0);
     566  aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED,              faimtest_ssi_gotadded, 0);
     567  */
     568
    506569  return;
    507570}
     
    510573{
    511574  owl_function_debugmsg("doing coninitdone_bos");
     575
     576
    512577  aim_reqpersonalinfo(sess, fr->conn);
    513 
    514578  aim_ssi_reqrights(sess);
    515579  aim_ssi_reqdata(sess);
    516 
    517   aim_bos_reqlocaterights(sess, fr->conn);
    518   aim_bos_reqbuddyrights(sess, fr->conn);
     580  aim_locate_reqrights(sess);
     581  aim_buddylist_reqrights(sess, fr->conn);
     582
    519583  aim_im_reqparams(sess);
    520   aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */
    521 
    522   /* aim_bos_setprofile(owl_global_get_aimsess(&g), fr->conn, NULL, NULL, 0, NULL, NULL, 0, AIM_CAPS_EMPTY); */
    523 
    524 #ifdef NOSSI
    525   /*
     584  /* aim_bos_reqrights(sess, fr->conn); */ /* XXX - Don't call this with ssi */
     585
     586  owl_function_debugmsg("conninitdone_bos: requesting rights");
     587  aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */
    526588  aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS);
    527589  aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
    528   */
    529 #endif
    530590
    531591  return(1);
    532592}
    533 
    534 int login(aim_session_t *sess, const char *sn, const char *passwd)
    535 {
    536   struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;
    537   aim_conn_t *authconn;
    538 
    539   if (sn) priv->screenname = strdup(sn);
    540   if (passwd) priv->password = strdup(passwd);
    541   if (priv->proxy) aim_setupproxy(sess, priv->proxy, priv->proxyusername, priv->proxypass);
    542 
    543   if (!priv->screenname || !priv->password) {
    544     owl_function_error("Internal error: aim login called without screenname or password");
    545     return(-1);
    546   }
    547 
    548   if (!(authconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, priv->server ? priv->server : FAIM_LOGIN_SERVER))) {
    549     owl_function_error("Internal error: connection error during AIM login\n");
    550     return (-1);
    551   } else if (authconn->fd == -1) {
    552     if (authconn->status & AIM_CONN_STATUS_RESOLVERR) {
    553       owl_function_error("AIM: could not resolve authorize name");
    554     } else if (authconn->status & AIM_CONN_STATUS_CONNERR) {
    555       owl_function_error("AIM: could not connect to authorizer");
    556     }
    557     aim_conn_kill(sess, &authconn);
    558     return(-1);
    559   }
    560 
    561   aim_conn_addhandler(sess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
    562   aim_conn_addhandler(sess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
    563   aim_conn_addhandler(sess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
    564   aim_conn_addhandler(sess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
    565 
    566   /* If the connection is in progress, this will just be queued */
    567   aim_request_login(sess, authconn, priv->screenname);
    568   owl_function_debugmsg("AIM login request sent for %s", priv->screenname);
    569 
    570   return(0);
    571 }
    572 
    573593
    574594static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...)
     
    607627  va_end(ap);
    608628 
    609   /* printf("connerr: Code 0x%04x: %s\n", code, msg); */
     629  owl_function_error("faimtest_parse_connerr: Code 0x%04x: %s\n", code, msg);
    610630  aim_conn_kill(sess, &fr->conn); /* this will break the main loop */
    611631 
     
    623643  status = va_arg(ap, int); /* status code of confirmation request */
    624644  va_end(ap);
    625  
    626   /* printf("account confirmation returned status 0x%04x (%s)\n", status, (status==0x0000)?"email sent":"unknown"); */
     645
     646  /* owl_function_debugmsg("faimtest_accountconfirm: Code 0x%04x: %s\n", code, msg); */
     647  owl_function_debugmsg("faimtest_accountconfirm: account confirmation returned status 0x%04x (%s)\n", status, (status==0x0000)?"email sent":"unknown");
    627648 
    628649  return 1;
     
    645666  va_end(ap);
    646667 
    647   /* printf("info%s: perms = %d, type = %x, length = %d, val = %s\n", change?" change":"", perms, type, length, str?val:"(not string)"); */
    648  
    649   return 1;
     668  owl_function_debugmsg("faimtest_infochange: info%s: perms = %d, type = %x, length = %d, val = %s", change?" change":"", perms, type, length, str?val:"(not string)");
     669 
     670  return(1);
    650671}
    651672
     
    666687    tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, redir->ip);
    667688    if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) {
    668       /* printf("unable to reconnect with authorizer\n"); */
     689      owl_function_error("faimtest_handleredirect: unable to reconnect with authorizer");
    669690    } else {
    670691      aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
     
    676697      /* Send the cookie to the Auth */
    677698      aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie);
    678       /* printf("sent cookie to authorizer host\n"); */
     699      owl_function_debugmsg("faimtest_handleredirect: sent cookie to authorizer host");
    679700    }
    680701  } else if (redir->group == 0x000d) {  /* ChatNav */
     
    683704    chat_redirect(sess, redir);
    684705  } else {
    685     /* printf("uh oh... got redirect for unknown service 0x%04x!!\n", redir->group); */
     706    owl_function_debugmsg("faimtest_handleredirect: uh oh... got redirect for unknown service 0x%04x!!", redir->group);
    686707  }
    687708  va_end(ap);
     
    698719  va_end(ap);
    699720 
    700   /* printf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %ld\n", params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval); */
     721  owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %ld",
     722                       params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval);
    701723     
    702724  /*
     
    724746  va_end(ap);
    725747 
    726   /* printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); */
    727   owl_function_debugmsg("in faimtest_parse_buddyrights");
     748  owl_function_debugmsg("faimtest_parse_buddyrights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers);
    728749 
    729750  /* aim_ssi_reqrights(sess, fr->conn); */
     
    743764  va_end(ap);
    744765 
    745   /* printf("BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); */
     766  owl_function_debugmsg("faimtest_bosrights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies);
    746767  aim_clientready(sess, fr->conn);
    747768  owl_function_debugmsg("officially connected to BOS.");
     
    759780  va_end(ap);
    760781
    761   owl_function_debugmsg("in faimtest_parse_locrights");
    762 
    763   /* printf("locate rights: max signature length = %d\n", maxsiglen); */
     782  owl_function_debugmsg("faimtest_locrights: rights: max signature length = %d\n", maxsiglen);
    764783 
    765784  return(1);
     
    776795  va_end(ap);
    777796
    778   /* printf("minimum report interval: %d (seconds?)\n", interval); */
     797  owl_function_debugmsg("faimtest_reportinterval: %d (seconds?)\n", interval);
    779798
    780799  if (!priv->connected) {
     
    792811  fu16_t id;
    793812  va_list ap;
    794   /* static int codeslen = 5;
     813  static int codeslen = 5;
    795814  static char *codes[] = {
    796815    "Unknown",
     
    800819    "Top o' the world!"
    801820  };
    802   */
    803 
    804   return 1;
    805  
     821
    806822  va_start(ap, fr);
    807823  id = va_arg(ap, int);
    808824  msg = va_arg(ap, char *);
    809825  va_end(ap);
    810  
    811   /* printf("motd: %s (%d / %s)\n", msg, id, (id < codeslen)?codes[id]:"unknown"); */
     826
     827  owl_function_debugmsg("faimtest_parse_motd: %s (%d / %s)\n", msg?msg:"nomsg", id, (id < codeslen)?codes[id]:"unknown");
    812828 
    813829  return 1;
     
    887903   
    888904    free(filename); /* not needed */
    889     printf("memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
     905    owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
    890906    i = 8;
    891907    if (modname) {
     
    978994    free(buf);
    979995  } else {
    980     /* printf("memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname); */
     996    owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
    981997    aim_sendmemblock(sess, fr->conn, offset, len, NULL, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    982998  }
     
    9841000}
    9851001
     1002/*
    9861003static void printuserflags(fu16_t flags)
    9871004{
    988 
    989   if (flags & AIM_FLAG_UNCONFIRMED)
    990     printf("UNCONFIRMED ");
    991   if (flags & AIM_FLAG_ADMINISTRATOR)
    992     printf("ADMINISTRATOR ");
    993   if (flags & AIM_FLAG_AOL)
    994     printf("AOL ");
    995   if (flags & AIM_FLAG_OSCAR_PAY)
    996     printf("OSCAR_PAY ");
    997   if (flags & AIM_FLAG_FREE)
    998     printf("FREE ");
    999   if (flags & AIM_FLAG_AWAY)
    1000     printf("AWAY ");
    1001   if (flags & AIM_FLAG_ICQ)
    1002     printf("ICQ ");
    1003   if (flags & AIM_FLAG_WIRELESS)
    1004     printf("WIRELESS ");
    1005   if (flags & AIM_FLAG_ACTIVEBUDDY)
    1006     printf("ACTIVEBUDDY ");
     1005  if (flags & AIM_FLAG_UNCONFIRMED) printf("UNCONFIRMED ");
     1006  if (flags & AIM_FLAG_ADMINISTRATOR) printf("ADMINISTRATOR ");
     1007  if (flags & AIM_FLAG_AOL) printf("AOL ");
     1008  if (flags & AIM_FLAG_OSCAR_PAY) printf("OSCAR_PAY ");
     1009  if (flags & AIM_FLAG_FREE) printf("FREE ");
     1010  if (flags & AIM_FLAG_AWAY) printf("AWAY ");
     1011  if (flags & AIM_FLAG_ICQ) printf("ICQ ");
     1012  if (flags & AIM_FLAG_WIRELESS) printf("WIRELESS ");
     1013  if (flags & AIM_FLAG_ACTIVEBUDDY) printf("ACTIVEBUDDY ");
    10071014 
    10081015  return;
    10091016}
     1017*/
    10101018
    10111019static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...)
     
    10461054  printf("userinfo: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities);
    10471055  */
    1048  
     1056
     1057  /*
    10491058  if (inforeq == AIM_GETINFO_GENERALINFO) {
    10501059    owl_function_debugmsg("userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
     
    10581067    owl_function_debugmsg("userinfo: unknown info request\n");
    10591068  }
    1060  
     1069  */
    10611070  return(1);
    10621071}
     
    13621371  }
    13631372
     1373  owl_function_debugmsg("faimtest_parse_incoming_im_chan1: message from: %s", userinfo->sn?userinfo->sn:"");
    13641374  /* create a message, and put it on the message queue */
    13651375  stripmsg=owl_text_htmlstrip(realmsg);
     
    13791389
    13801390  return(1);
    1381  
    1382   /* printf("icbm: message: %s\n", realmsg); */
     1391
     1392  owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg);
    13831393 
    13841394  if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
     
    13861396    int z;
    13871397
    1388     /* printf("icbm: multipart: this message has %d parts\n", args->mpmsg.numparts); */
     1398    owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
    13891399   
    13901400    for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
    13911401      if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
    1392         /* printf("icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data); */
     1402        owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data);
    13931403      } else {
    1394         /* printf("icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset); */
     1404        owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset);
    13951405      }
    13961406    }
     
    13991409  if (args->icbmflags & AIM_IMFLAGS_HASICON) {
    14001410    /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */
    1401     /* printf("icbm: their icon: iconstamp = %ld, iconlen = 0x%08lx, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum); */
     1411    owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: their icon: iconstamp = %ld, iconlen = 0x%08lx, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum);
    14021412  }
    14031413
     
    14451455 
    14461456  if (args->reqclass == AIM_CAPS_SENDFILE) {
    1447     /* printf("send file!\n"); */
     1457    owl_function_debugmsg("faimtest_parse_incoming_im_chan2: send file!");
    14481458  } else if (args->reqclass == AIM_CAPS_CHAT) {
    1449     owl_function_debugmsg("chat invite: %s, %i, %i", args->info.chat.roominfo.name, args->info.chat.roominfo.exchange, args->info.chat.roominfo.instance);
     1459    owl_function_debugmsg("faimtest_parse_incoming_im_chan2: chat invite: %s, %i, %i", args->info.chat.roominfo.name, args->info.chat.roominfo.exchange, args->info.chat.roominfo.instance);
    14501460    /*
    14511461    printf("chat invitation: room name = %s\n", args->info.chat.roominfo.name);
     
    14581468    /* aim_chat_join(sess, conn, args->info.chat.roominfo.exchange, args->info.chat.roominfo.name, args->info.chat.roominfo.instance); */
    14591469  } else if (args->reqclass == AIM_CAPS_BUDDYICON) {
    1460     /* printf("Buddy Icon from %s, length = %lu\n", userinfo->sn, args->info.icon.length); */
     1470    owl_function_debugmsg("faimtest_parse_incoming_im_chan2: Buddy Icon from %s, length = %lu\n",
     1471                          userinfo->sn, args->info.icon.length);
    14611472  } else if (args->reqclass == AIM_CAPS_ICQRTF) {
    1462     /* printf("RTF message from %s: (fgcolor = 0x%08lx, bgcolor = 0x%08lx) %s\n", userinfo->sn, args->info.rtfmsg.fgcolor, args->info.rtfmsg.bgcolor, args->info.rtfmsg.rtfmsg); */
     1473    owl_function_debugmsg("faimtest_parse_incoming_im_chan2: RTF message from %s: (fgcolor = 0x%08lx, bgcolor = 0x%08lx) %s\n",
     1474                          userinfo->sn, args->info.rtfmsg.fgcolor, args->info.rtfmsg.bgcolor, args->info.rtfmsg.rtfmsg);
    14631475  } else {
    1464     /* printf("icbm: unknown reqclass (%d)\n", args->reqclass); */
     1476    owl_function_debugmsg("faimtest_parse_incoming_im_chan2: icbm: unknown reqclass (%d)\n", args->reqclass);
    14651477  }
    14661478  return 1;
     
    14871499    ret = faimtest_parse_incoming_im_chan2(sess, fr->conn, userinfo, args);
    14881500  } else {
    1489     /* printf("unsupported channel 0x%04x\n", channel); */
    1490   }
    1491   va_end(ap);
    1492   /* printf("icbm: done with ICBM handling (ret = %d)\n", ret); */
     1501    owl_function_debugmsg("faimtest_parse_incoming_im: unsupported channel 0x%04x\n", channel);
     1502  }
     1503  va_end(ap);
     1504  owl_function_debugmsg("faimtest_parse_incoming_im: done with ICBM handling (ret = %d)\n", ret);
    14931505  return 1;
    14941506}
     
    15111523
    15121524  if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
    1513     /*  */
     1525    owl_function_debugmsg("faimtest_parseoncoming: in empty part of userinfo present and present idle");
    15141526  }
    15151527
     
    16451657static int faimtest_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...)
    16461658{
    1647   /*
    16481659  static char *missedreasons[] = {
    16491660    "Invalid (0)",
     
    16531664    "Evil Receiver"
    16541665  };
    1655   static int missedreasonslen = 5; */
     1666  static int missedreasonslen = 5;
    16561667 
    16571668  va_list ap;
     
    16661677  va_end(ap);
    16671678 
    1668   /* printf("missed %d messages from %s on channel %d (reason %d: %s)\n", nummissed, userinfo->sn, chan, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown"); */
     1679  owl_function_debugmsg("faimtest_parse_misses: missed %d messages from %s on channel %d (reason %d: %s)\n", nummissed, userinfo->sn, chan, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown");
    16691680 
    16701681  return 1;
     
    16851696  va_end(ap);
    16861697 
    1687   /* printf("msgack: 0x%04x / %s\n", type, sn); */
     1698  owl_function_debugmsg("faimtest_parse_msgack: 0x%04x / %s\n", type, sn);
    16881699 
    16891700  return 1;
     
    16921703static int faimtest_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...)
    16931704{
    1694   /*
    16951705  static char *codes[5] = {
    16961706    "invalid",
     
    17001710    "limit cleared"
    17011711  };
    1702   */
    17031712  va_list ap;
    17041713  fu16_t code, rateclass;
     
    17331742  va_end(ap);
    17341743 
    1735   /*
    1736   printf("rate %s (rate class 0x%04x): curavg = %ld, maxavg = %ld, alert at %ld, clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n",
    1737          (code < 5)?codes[code]:"invalid",
    1738          rateclass,
    1739          currentavg, maxavg,
    1740          alert, clear,
    1741          limit, disconnect,
    1742          windowsize);
    1743   */
     1744  owl_function_debugmsg("faimtest_parse_ratechange: rate %s (rate class 0x%04x): curavg = %ld, maxavg = %ld, alert at %ld, clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)",
     1745                        (code < 5)?codes[code]:"invalid",
     1746                        rateclass,
     1747                        currentavg, maxavg,
     1748                        alert, clear,
     1749                        limit, disconnect,
     1750                        windowsize);
    17441751  return 1;
    17451752}
     
    17641771   * ten.
    17651772   */
    1766   /* printf("evil level change: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous"); */
     1773  owl_function_debugmsg("faimtest_parse_evilnotify: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous");
    17671774 
    17681775  return 1;
     
    17731780  va_list ap;
    17741781  char *address, *SNs;
    1775   int num;
    1776   /* int i; */
     1782  int num, i;
    17771783 
    17781784  va_start(ap, fr);
     
    17821788  va_end(ap);
    17831789 
    1784   /* printf("E-Mail Search Results for %s: ", address);
    1785  
    1786   for(i = 0; i < num; i++)
    1787     printf("%s, ", &SNs[i*(MAXSNLEN+1)]);
    1788   printf("\n");
    1789   */
     1790  owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address);
     1791 
     1792  for(i = 0; i < num; i++) {
     1793    owl_function_debugmsg("  %s", &SNs[i*(MAXSNLEN+1)]);
     1794  }
    17901795 
    17911796  return 1;
     
    18011806  va_end(ap);
    18021807 
    1803   /* printf("E-Mail Search Results for %s: No Results or Invalid Email\n", address); */
     1808  owl_function_debugmsg("faimtest_parse_searcherror: E-Mail Search Results for %s: No Results or Invalid Email\n", address);
    18041809 
    18051810  return 1;
     
    18201825  va_end(ap);
    18211826 
    1822   /* printf("popup: (%dx%x:%d) %s (%s)\n", width, height, delay, msg, url); */
     1827  owl_function_debugmsg("handlepopup: (%dx%x:%d) %s (%s)\n", width, height, delay, msg, url);
    18231828 
    18241829  return 1;
     
    18431848  va_end(ap);
    18441849 
    1845   /* printf("migration in progress -- new BOS is %s -- disconnecting\n", bosip); */
     1850  owl_function_debugmsg("migrate: migration in progress -- new BOS is %s -- disconnecting", bosip);
    18461851  aim_conn_kill(sess, &fr->conn);
    18471852 
    18481853  if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip))) {
    1849     /* printf("migrate: could not connect to BOS: internal error\n"); */
     1854    owl_function_debugmsg("migrate: could not connect to BOS: internal error");
    18501855    return 1;
    18511856  } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) {       
    1852     /* printf("migrate: could not connect to BOS\n"); */
     1857    owl_function_debugmsg("migrate: could not connect to BOS");
    18531858    aim_conn_kill(sess, &bosconn);
    18541859    return 1;
     
    18571862  /* Login will happen all over again. */
    18581863  addcb_bos(sess, bosconn);
    1859   /* aim_sendcookie(sess, bosconn, cookie); */
     1864  /* aim_sendcookie(sess, bosconn, cookie); */ /********/
    18601865  return 1;
    18611866}
     
    18631868static int ssirights(aim_session_t *sess, aim_frame_t *fr, ...)
    18641869{
    1865   /* printf("got SSI rights, requesting data\n"); */
     1870  owl_function_debugmsg("ssirights: got SSI rights, requesting data\n");
    18661871  /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */
    18671872  aim_ssi_reqdata(sess);
     
    18781883  struct aim_ssi_item *list;
    18791884  struct aim_ssi_item *curitem;
    1880   /* struct aim_ssi_item *l; */
     1885  struct aim_ssi_item *l;
    18811886 
    18821887  va_start(ap, fr);
     
    18871892  va_end(ap);
    18881893 
    1889   /* printf("got SSI data: (0x%02x, %d items, %ld)\n", fmtver, itemcount, stamp); */
     1894  owl_function_debugmsg("ssiddata: got SSI data (0x%02x, %d items, %ld)", fmtver, itemcount, stamp);
     1895  /*
    18901896  for (curitem=sess->ssi.local; curitem; curitem=curitem->next) {
    1891     /* for (l = list; l; l = l->next) { */
    1892     /* printf("\t0x%04x (%s) - 0x%04x/0x%04x\n", l->type, l->name, l->gid, l->bid); */
    1893     /* printf("I would have printed data here!\n"); */
    1894   }
    1895  
     1897    for (l = list; l; l = l->next) {
     1898      owl_function_debugmsg("\t0x%04x (%s) - 0x%04x/0x%04x", l->type, l->name, l->gid, l->bid);
     1899    }
     1900  }
     1901  */
    18961902  aim_ssi_enable(sess);
    18971903 
     
    19011907static int ssidatanochange(aim_session_t *sess, aim_frame_t *fr, ...)
    19021908{
    1903   /* printf("server says we have the latest SSI data already\n"); */
     1909  owl_function_debugmsg("ssidatanochange: server says we have the latest SSI data already");
    19041910  /* aim_ssi_enable(sess, fr->conn); */
    19051911  aim_ssi_enable(sess);
     
    19171923 
    19181924  if (msg->type == 0x0001) {
    1919     /* printf("offline message from %ld at %d/%d/%d %02d:%02d : %s\n", msg->sender, msg->year, msg->month, msg->day, msg->hour, msg->minute, msg->msg); */
     1925    owl_function_debugmsg("offlinemsg: from %ld at %d/%d/%d %02d:%02d : %s", msg->sender, msg->year, msg->month, msg->day, msg->hour, msg->minute, msg->msg);
    19201926  } else {
    1921     /* printf("unknown offline message type 0x%04x\n", msg->type); */
     1927    owl_function_debugmsg("unknown offline message type 0x%04x", msg->type);
    19221928  }
    19231929  return 1;
     
    19271933{
    19281934  /* Tell the server to delete them. */
     1935  owl_function_debugmsg("offlinemsg done: ");
    19291936  aim_icq_ackofflinemsgs(sess);
    19301937  return 1;
     
    19331940
    19341941/******************** chat.c **************************/
    1935 
    19361942
    19371943static int faimtest_chat_join(aim_session_t *sess, aim_frame_t *fr, ...)
     
    22012207
    22022208
    2203 /****************************************/
    2204 
    2205 /*
    2206 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
    2207         struct gaim_connection *gc = sess->aux_data;
    2208         struct oscar_data *od = gc->proto_data;
    2209         aim_userinfo_t *info;
    2210         time_t time_idle = 0, signon = 0;
    2211         int type = 0;
    2212         int caps = 0;
    2213         char *tmp;
    2214 
    2215         va_list ap;
    2216         va_start(ap, fr);
    2217         info = va_arg(ap, aim_userinfo_t *);
    2218         va_end(ap);
    2219 
    2220         if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES)
    2221                 caps = info->capabilities;
    2222         if (info->flags & AIM_FLAG_ACTIVEBUDDY)
    2223                 type |= UC_AB;
    2224 
    2225         if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) {
    2226                         if (info->flags & AIM_FLAG_UNCONFIRMED)
    2227                                 type |= UC_UNCONFIRMED;
    2228                         if (info->flags & AIM_FLAG_ADMINISTRATOR)
    2229                                 type |= UC_ADMIN;
    2230                         if (info->flags & AIM_FLAG_AOL)
    2231                                 type |= UC_AOL;
    2232                         if (info->flags & AIM_FLAG_FREE)
    2233                                 type |= UC_NORMAL;
    2234                         if (info->flags & AIM_FLAG_AWAY)
    2235                                 type |= UC_UNAVAILABLE;
    2236                         if (info->flags & AIM_FLAG_WIRELESS)
    2237                                 type |= UC_WIRELESS;
    2238         }
    2239         if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) {
    2240                 type = (info->icqinfo.status << 16);
    2241                 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) &&
    2242                       (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
    2243                         type |= UC_UNAVAILABLE;
    2244                 }
    2245         }
    2246 
    2247         if (caps & AIM_CAPS_ICQ)
    2248                 caps ^= AIM_CAPS_ICQ;
    2249 
    2250         if (info->present & AIM_USERINFO_PRESENT_IDLE) {
    2251                 time(&time_idle);
    2252                 time_idle -= info->idletime*60;
    2253         }
    2254 
    2255         if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
    2256                 signon = time(NULL) - info->sessionlen;
    2257 
    2258         tmp = g_strdup(normalize(gc->username));
    2259         if (!strcmp(tmp, normalize(info->sn)))
    2260                 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn);
    2261         g_free(tmp);
    2262 
    2263         serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon,
    2264                         time_idle, type, caps);
    2265 
    2266         return 1;
    2267 }
    2268 */
     2209/**********************************************************************************/
     2210
     2211
     2212static int faimtest_ssi_rerequestdata(aim_session_t *sess, aim_frame_t *fr, ...)
     2213{
     2214  aim_ssi_reqdata(sess);
     2215  return(0);
     2216}
     2217
     2218static int faimtest_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...)
     2219{
     2220  /* GaimConnection *gc = sess->aux_data; */
     2221  /*    OscarData *od = gc->proto_data; */
     2222  va_list ap;
     2223  fu16_t reason;
     2224
     2225  va_start(ap, fr);
     2226  reason = (fu16_t)va_arg(ap, unsigned int);
     2227  va_end(ap);
     2228
     2229  owl_function_debugmsg("faimtest_ssi_parseerr: ssi: SNAC error %hu", reason);
     2230
     2231  if (reason == 0x0005) {
     2232    owl_function_error("faimtest_ssi_parseerr: unable to retrieve buddy list");
     2233  }
     2234
     2235  /* Activate SSI */
     2236  /* Sending the enable causes other people to be able to see you, and you to see them */
     2237  /* Make sure your privacy setting/invisibility is set how you want it before this! */
     2238  owl_function_debugmsg("faimtest_ssi_parseerr: ssi: activating server-stored buddy list");
     2239  aim_ssi_enable(sess);
     2240 
     2241  return(1);
     2242}
     2243
     2244static int faimtest_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...)
     2245{
     2246  /* GaimConnection *gc = sess->aux_data; */
     2247  /* OscarData *od = (OscarData *)gc->proto_data; */
     2248  int numtypes, i;
     2249  fu16_t *maxitems;
     2250  va_list ap;
     2251
     2252  va_start(ap, fr);
     2253  numtypes = va_arg(ap, int);
     2254  maxitems = va_arg(ap, fu16_t *);
     2255  va_end(ap);
     2256
     2257  owl_function_debugmsg("faimtest_ssi_parserights: ");
     2258  for (i=0; i<numtypes; i++) {
     2259    owl_function_debugmsg(" max type 0x%04x=%hd,", i, maxitems[i]);
     2260  }
     2261
     2262  /*
     2263  if (numtypes >= 0) od->rights.maxbuddies = maxitems[0];
     2264  if (numtypes >= 1) od->rights.maxgroups = maxitems[1];
     2265  if (numtypes >= 2) od->rights.maxpermits = maxitems[2];
     2266  if (numtypes >= 3) od->rights.maxdenies = maxitems[3];
     2267  */
     2268 
     2269  return(1);
     2270}
     2271
     2272#if 0
     2273static int faimtest_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...)
     2274{
     2275  /* GaimConnection *gc = sess->aux_data; */
     2276  /* GaimAccount *account = gaim_connection_get_account(gc); */
     2277  /* OscarData *od = (OscarData *)gc->proto_data; */
     2278  struct aim_ssi_item *curitem;
     2279  int tmp;
     2280  int export = FALSE;
     2281  /* XXX - use these?
     2282     va_list ap;
     2283     
     2284     va_start(ap, fr);
     2285     fmtver = (fu16_t)va_arg(ap, int);
     2286     numitems = (fu16_t)va_arg(ap, int);
     2287     items = va_arg(ap, struct aim_ssi_item);
     2288     timestamp = va_arg(ap, fu32_t);
     2289     va_end(ap); */
     2290 
     2291  owl_function_debugmsg("faimtest_ssi_parselist: syncing local list and server list");
     2292
     2293  /* Clean the buddy list */
     2294  aim_ssi_cleanlist(sess);
     2295
     2296  /* Add from server list to local list */
     2297  for (curitem=sess->ssi.local; curitem; curitem=curitem->next) {
     2298    if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))
     2299      switch (curitem->type) {
     2300      case 0x0000: { /* Buddy */
     2301        if (curitem->name) {
     2302          char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name);
     2303          char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL;
     2304          char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);
     2305          char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL;
     2306          GaimBuddy *buddy = gaim_find_buddy(gc->account, curitem->name);
     2307          /* Should gname be freed here? -- elb */
     2308          /* Not with the current code, but that might be cleaner -- med */
     2309          free(alias);
     2310          if (buddy) {
     2311            /* Get server stored alias */
     2312            if (alias_utf8) {
     2313              g_free(buddy->alias);
     2314              buddy->alias = g_strdup(alias_utf8);
     2315            }
     2316          } else {
     2317            GaimGroup *g;
     2318            buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8);
     2319           
     2320            if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
     2321              g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
     2322              gaim_blist_add_group(g, NULL);
     2323            }
     2324           
     2325            gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2326                       "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans"));
     2327            gaim_blist_add_buddy(buddy, NULL, g, NULL);
     2328            export = TRUE;
     2329          }
     2330          g_free(gname_utf8);
     2331          g_free(alias_utf8);
     2332        }
     2333      } break;
     2334     
     2335      case 0x0001: { /* Group */
     2336        /* Shouldn't add empty groups */
     2337      } break;
     2338     
     2339      case 0x0002: { /* Permit buddy */
     2340        if (curitem->name) {
     2341          /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */
     2342          GSList *list;
     2343          for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
     2344          if (!list) {
     2345            gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2346                       "ssi: adding permit buddy %s to local list\n", curitem->name);
     2347            gaim_privacy_permit_add(account, curitem->name, TRUE);
     2348            export = TRUE;
     2349          }
     2350        }
     2351      } break;
     2352     
     2353      case 0x0003: { /* Deny buddy */
     2354        if (curitem->name) {
     2355          GSList *list;
     2356          for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
     2357          if (!list) {
     2358            gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2359                       "ssi: adding deny buddy %s to local list\n", curitem->name);
     2360            gaim_privacy_deny_add(account, curitem->name, TRUE);
     2361            export = TRUE;
     2362          }
     2363        }
     2364      } break;
     2365     
     2366      case 0x0004: { /* Permit/deny setting */
     2367        if (curitem->data) {
     2368          fu8_t permdeny;
     2369          if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) {
     2370            gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2371                       "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);
     2372            account->perm_deny = permdeny;
     2373            if (od->icq && account->perm_deny == 0x03) {
     2374              serv_set_away(gc, "Invisible", "");
     2375            }
     2376            export = TRUE;
     2377          }
     2378        }
     2379      } break;
     2380     
     2381      case 0x0005: { /* Presence setting */
     2382        /* We don't want to change Gaim's setting because it applies to all accounts */
     2383      } break;
     2384      } /* End of switch on curitem->type */
     2385  } /* End of for loop */
     2386 
     2387  /* If changes were made, then flush buddy list to file */
     2388  if (export)
     2389    gaim_blist_save();
     2390 
     2391  { /* Add from local list to server list */
     2392    GaimBlistNode *gnode, *cnode, *bnode;
     2393    GaimGroup *group;
     2394    GaimBuddy *buddy;
     2395    GaimBuddyList *blist;
     2396    GSList *cur;
     2397   
     2398    /* Buddies */
     2399    if ((blist = gaim_get_blist()))
     2400      for (gnode = blist->root; gnode; gnode = gnode->next) {
     2401        if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
     2402          continue;
     2403        group = (GaimGroup *)gnode;
     2404        for (cnode = gnode->child; cnode; cnode = cnode->next) {
     2405          if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
     2406            continue;
     2407          for (bnode = cnode->child; bnode; bnode = bnode->next) {
     2408            if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
     2409              continue;
     2410            buddy = (GaimBuddy *)bnode;
     2411            if (buddy->account == gc->account) {
     2412              const char *servernick = gaim_buddy_get_setting(buddy, "servernick");
     2413              if (servernick)
     2414                serv_got_alias(gc, buddy->name, servernick);
     2415             
     2416              if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) {
     2417                /* Store local alias on server */
     2418                char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name);
     2419                if (!alias && buddy->alias && strlen(buddy->alias))
     2420                  aim_ssi_aliasbuddy(sess, group->name, buddy->name, buddy->alias);
     2421                free(alias);
     2422              } else {
     2423                gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2424                           "ssi: adding buddy %s from local list to server list\n", buddy->name);
     2425                aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0);
     2426              }
     2427            }
     2428          }
     2429        }
     2430      }
     2431   
     2432    /* Permit list */
     2433    if (gc->account->permit) {
     2434      for (cur=gc->account->permit; cur; cur=cur->next)
     2435        if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {
     2436          gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2437                     "ssi: adding permit %s from local list to server list\n", (char *)cur->data);
     2438          aim_ssi_addpermit(sess, cur->data);
     2439        }
     2440    }
     2441   
     2442    /* Deny list */
     2443    if (gc->account->deny) {
     2444      for (cur=gc->account->deny; cur; cur=cur->next)
     2445        if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) {
     2446          gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2447                     "ssi: adding deny %s from local list to server list\n", (char *)cur->data);
     2448          aim_ssi_adddeny(sess, cur->data);
     2449        }
     2450    }
     2451    /* Presence settings (idle time visibility) */
     2452    if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF)
     2453      if (!(tmp & 0x400))
     2454        aim_ssi_setpresence(sess, tmp | 0x400);
     2455  } /* end adding buddies from local list to server list */
     2456 
     2457  /* Set our ICQ status */
     2458  if  (od->icq && !gc->away) {
     2459    aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL);
     2460  }
     2461 
     2462  /* Activate SSI */
     2463  /* Sending the enable causes other people to be able to see you, and you to see them */
     2464  /* Make sure your privacy setting/invisibility is set how you want it before this! */
     2465  gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: activating server-stored buddy list\n");
     2466  aim_ssi_enable(sess);
     2467 
     2468  return 1;
     2469}
     2470
     2471static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...)
     2472{
     2473  GaimConnection *gc = sess->aux_data;
     2474  va_list ap;
     2475  struct aim_ssi_tmp *retval;
     2476 
     2477  va_start(ap, fr);
     2478  retval = va_arg(ap, struct aim_ssi_tmp *);
     2479  va_end(ap);
     2480 
     2481  while (retval) {
     2482    gaim_debug(GAIM_DEBUG_MISC, "oscar",
     2483               "ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack,  retval->action, retval->item ? (retval->item->name ? retval->item->name : "no name") : "no item");
     2484   
     2485    if (retval->ack != 0xffff)
     2486      switch (retval->ack) {
     2487      case 0x0000: { /* added successfully */
     2488      } break;
     2489     
     2490      case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */
     2491        gchar *buf;
     2492        buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list.  Please remove one and try again."), (retval->name ? retval->name : _("(no name)")));
     2493        gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
     2494        g_free(buf);
     2495      }
     2496       
     2497      case 0x000e: { /* buddy requires authorization */
     2498        if ((retval->action == AIM_CB_SSI_ADD) && (retval->name))
     2499          gaim_auth_sendrequest(gc, retval->name);
     2500      } break;
     2501     
     2502      default: { /* La la la */
     2503        gchar *buf;
     2504        gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack);
     2505        buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason.  The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)")));
     2506        gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
     2507        g_free(buf);
     2508        /* XXX - Should remove buddy from local list */
     2509      } break;
     2510      }
     2511   
     2512    retval = retval->next;
     2513  }
     2514 
     2515  return 1;
     2516}
     2517
     2518static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...)
     2519{
     2520  GaimConnection *gc = sess->aux_data;
     2521  va_list ap;
     2522  char *sn, *msg;
     2523  gchar *dialog_msg, *nombre;
     2524  struct name_data *data;
     2525  GaimBuddy *buddy;
     2526 
     2527  va_start(ap, fr);
     2528  sn = va_arg(ap, char *);
     2529  msg = va_arg(ap, char *);
     2530  va_end(ap);
     2531 
     2532  gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2533             "ssi: %s has given you permission to add him to your buddy list\n", sn);
     2534 
     2535  buddy = gaim_find_buddy(gc->account, sn);
     2536  if (buddy && (gaim_get_buddy_alias_only(buddy)))
     2537    nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));
     2538  else
     2539    nombre = g_strdup(sn);
     2540 
     2541  dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list.  Do you want to add them?"), nombre);
     2542  data = g_new(struct name_data, 1);
     2543  data->gc = gc;
     2544  data->name = g_strdup(sn);
     2545  data->nick = NULL;
     2546 
     2547  gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg,
     2548                      0, data,
     2549                      G_CALLBACK(gaim_icq_buddyadd),
     2550                      G_CALLBACK(oscar_free_name_data));
     2551 
     2552  g_free(dialog_msg);
     2553  g_free(nombre);
     2554 
     2555  return 1;
     2556}
     2557
     2558static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...)
     2559{
     2560  GaimConnection *gc = sess->aux_data;
     2561  va_list ap;
     2562  char *sn, *msg;
     2563  gchar *dialog_msg, *nombre;
     2564  struct name_data *data;
     2565  GaimBuddy *buddy;
     2566 
     2567  va_start(ap, fr);
     2568  sn = va_arg(ap, char *);
     2569  msg = va_arg(ap, char *);
     2570  va_end(ap);
     2571 
     2572  gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2573             "ssi: received authorization request from %s\n", sn);
     2574 
     2575  buddy = gaim_find_buddy(gc->account, sn);
     2576  if (buddy && (gaim_get_buddy_alias_only(buddy)))
     2577    nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));
     2578  else
     2579    nombre = g_strdup(sn);
     2580 
     2581  dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));
     2582  data = g_new(struct name_data, 1);
     2583  data->gc = gc;
     2584  data->name = g_strdup(sn);
     2585  data->nick = NULL;
     2586 
     2587  gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg,
     2588                      0, data, 2,
     2589                      _("Authorize"), G_CALLBACK(gaim_auth_grant),
     2590                      _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt));
     2591 
     2592  g_free(dialog_msg);
     2593  g_free(nombre);
     2594 
     2595  return 1;
     2596}
     2597
     2598static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...)
     2599{
     2600  GaimConnection *gc = sess->aux_data;
     2601  va_list ap;
     2602  char *sn, *msg;
     2603  gchar *dialog_msg, *nombre;
     2604  fu8_t reply;
     2605  GaimBuddy *buddy;
     2606 
     2607  va_start(ap, fr);
     2608  sn = va_arg(ap, char *);
     2609  reply = (fu8_t)va_arg(ap, int);
     2610  msg = va_arg(ap, char *);
     2611  va_end(ap);
     2612 
     2613  gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2614             "ssi: received authorization reply from %s.  Reply is 0x%04hhx\n", sn, reply);
     2615 
     2616  buddy = gaim_find_buddy(gc->account, sn);
     2617  if (buddy && (gaim_get_buddy_alias_only(buddy)))
     2618    nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));
     2619  else
     2620    nombre = g_strdup(sn);
     2621 
     2622  if (reply) {
     2623    /* Granted */
     2624    dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your buddy list."), nombre);
     2625    gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg);
     2626  } else {
     2627    /* Denied */
     2628    dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));
     2629    gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg);
     2630  }
     2631  g_free(dialog_msg);
     2632  g_free(nombre);
     2633 
     2634  return 1;
     2635}
     2636
     2637static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...)
     2638{
     2639  GaimConnection *gc = sess->aux_data;
     2640  va_list ap;
     2641  char *sn;
     2642  GaimBuddy *buddy;
     2643 
     2644  va_start(ap, fr);
     2645  sn = va_arg(ap, char *);
     2646  va_end(ap);
     2647 
     2648  buddy = gaim_find_buddy(gc->account, sn);
     2649  gaim_debug(GAIM_DEBUG_INFO, "oscar",
     2650             "ssi: %s added you to their buddy list\n", sn);
     2651  gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL);
     2652 
     2653  return 1;
     2654}
     2655#endif
Note: See TracChangeset for help on using the changeset viewer.