Changeset f4d0975


Ignore:
Timestamp:
Oct 10, 2003, 5:12:19 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
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:
e374dee
Parents:
12582d3
Message:
Fixed bug with idle times causing broken pipes.
New libfaim
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rf933403 rf4d0975  
    11$Id$
     2
     32.0.8-pre-5     
     4        Fixed bug with idle times causing broken pipes.
     5        New libfaim
    26
    372.0.8-pre-4
  • Makefile.in

    rf1e629d rf4d0975  
    2323     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
    2424     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    25      aim.c buddylist.c timer.c style.c stylefunc.c
     25     aim.c buddy.c buddylist.c timer.c style.c stylefunc.c
    2626OWL_SRC = owl.c
    2727TESTER_SRC = tester.c
  • aim.c

    ra352335c rf4d0975  
    7777static int faimtest_locrights(aim_session_t *sess, aim_frame_t *fr, ...);
    7878static int faimtest_reportinterval(aim_session_t *sess, aim_frame_t *fr, ...);
     79/* static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs); */
    7980static int faimtest_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...);
    8081static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname);
     
    106107static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...);
    107108
    108 static int directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...);
    109 static int directim_typing(aim_session_t *sess, aim_frame_t *fr, ...);
    110 static int faimtest_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...);
    111 static int faimtest_getfile_filereq(aim_session_t *ses, aim_frame_t *fr, ...);
    112 static int faimtest_getfile_filesend(aim_session_t *sess, aim_frame_t *fr, ...);
    113 static int faimtest_getfile_complete(aim_session_t *sess, aim_frame_t *fr, ...);
    114 static int faimtest_getfile_disconnect(aim_session_t *sess, aim_frame_t *fr, ...);
    115 static int faimtest_getfile_listing(aim_session_t *sess, aim_frame_t *fr, ...);
    116 static int faimtest_getfile_listingreq(aim_session_t *sess, aim_frame_t *fr, ...);
    117 static int faimtest_getfile_receive(aim_session_t *sess, aim_frame_t *fr, ...);
    118 static int faimtest_getfile_state4(aim_session_t *sess, aim_frame_t *fr, ...);
    119 static int faimtest_getfile_initiate(aim_session_t *sess, aim_frame_t *fr, ...);
    120 void getfile_start(aim_session_t *sess, aim_conn_t *conn, const char *sn);
    121 void getfile_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args);
    122 void directim_start(aim_session_t *sess, const char *sn);
    123 void directim_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args);
    124 
    125109void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir);
    126110void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir);
     
    130114void owl_aim_init(void)
    131115{
    132   aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 1);
     116  aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
    133117  aim_setdebuggingcb(owl_global_get_aimsess(&g), faimtest_debugcb);
    134118}
     119
    135120
    136121int owl_aim_login(char *screenname, char *password)
     
    147132  priv->server = "login.oscar.aol.com";
    148133  owl_global_get_aimsess(&g)->aux_data = priv;
     134
     135  aim_tx_setenqueue(owl_global_get_aimsess(&g), AIM_TX_IMMEDIATE, NULL);
    149136 
    150137  /* login */
     
    159146}
    160147
     148#if 0
     149static void oscar_login(GaimAccount *account) {
     150  aim_session_t *sess;
     151  aim_conn_t *conn;
     152  char buf[256];
     153  GaimConnection *gc = gaim_account_get_connection(account);
     154  struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1);
     155
     156  gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc);
     157
     158  if (isdigit(*(gaim_account_get_username(account)))) {
     159    od->icq = TRUE;
     160  } else {
     161    gc->flags |= GAIM_CONNECTION_HTML;
     162    gc->flags |= GAIM_CONNECTION_AUTO_RESP;
     163  }
     164  od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo);
     165
     166  sess = g_new0(aim_session_t, 1);
     167
     168  aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
     169  aim_setdebuggingcb(sess, oscar_debug);
     170
     171  /* we need an immediate queue because we don't use a while-loop to
     172   * see if things need to be sent. */
     173  aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL);
     174  od->sess = sess;
     175  sess->aux_data = gc;
     176
     177  conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
     178  if (conn == NULL) {
     179    gaim_debug(GAIM_DEBUG_ERROR, "oscar",
     180               "internal connection error\n");
     181    gaim_connection_error(gc, _("Unable to login to AIM"));
     182    return;
     183  }
     184
     185  g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account));
     186  gaim_connection_update_progress(gc, buf, 2, 5);
     187
     188  aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0);
     189  aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0);
     190  aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0);
     191
     192  conn->status |= AIM_CONN_STATUS_INPROGRESS;
     193  if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER),
     194                         gaim_account_get_int(account, "port", FAIM_LOGIN_PORT),
     195                         oscar_login_connect, gc) < 0) {
     196    gaim_connection_error(gc, _("Couldn't connect to host"));
     197    return;
     198  }
     199  aim_request_login(sess, conn, gaim_account_get_username(account));
     200}
     201#endif
     202
     203
    161204/* stuff to run once login has been successful */
    162205void owl_aim_successful_login(char *screenname)
     
    171214  owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g),
    172215                           owl_global_get_aim_ignorelogin_timer(&g));
    173 
    174216}
    175217
     
    196238int owl_aim_send_im(char *to, char *msg)
    197239{
    198   aim_send_im(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_ACK, msg);
     240  int ret;
     241
     242  ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, NULL, msg);
     243   
     244  /* aim_send_im(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_ACK, msg); */
    199245
    200246  /* I don't know how to check for an error yet */
     
    204250void owl_aim_addbuddy(char *screenname)
    205251{
    206   const char **foo;
    207  
    208   /*
    209   aim_bos_setbuddylist(owl_global_get_aimsess(&g),
    210                        aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    211                        foo);
    212   */
    213 
    214   /*
    215   aim_add_buddy(owl_global_get_aimsess(&g),
    216                 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    217                 screenname);
    218   */
    219 
    220   foo=(char *) owl_malloc(30);
    221   foo[0]=screenname;
    222   aim_ssi_addbuddies(owl_global_get_aimsess(&g),
    223                      aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    224                      "Buddies", foo, 1);
    225   owl_free(foo);
    226 
     252  aim_ssi_addbuddy(owl_global_get_aimsess(&g), screenname, "Buddies", NULL, NULL, NULL, 0);
    227253}
    228254
    229255void owl_aim_delbuddy(char *screenname)
    230256{
    231   /*
    232   aim_remove_buddy(owl_global_get_aimsess(&g),
    233                    aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    234                    screenname);
    235   */
    236 
    237   aim_ssi_delbuddies(owl_global_get_aimsess(&g),
    238                      aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    239                      "Buddies", &screenname, 1);
    240 
    241   /* for some reason we don't get an offgoing notice, so we'll remove
    242    * manually
    243    */
    244 
     257  aim_ssi_delbuddy(owl_global_get_aimsess(&g), screenname, "Buddies");
    245258  owl_buddylist_offgoing(owl_global_get_buddylist(&g), screenname);
    246 
    247 
    248 }
    249 
     259}
     260
     261#if 0
    250262void owl_aim_get_idle(char *screenname)
    251263{
     264  /*
    252265  aim_getinfo(owl_global_get_aimsess(&g),
    253266              aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
    254267              screenname,
    255268              AIM_GETINFO_GENERALINFO);
    256 }
     269  */
     270}
     271#endif
    257272
    258273
     
    308323  }
    309324
    310   if (selstat == -1) { /* error */
    311     /* keepgoing = 0; */ /* fall through */
    312   } else if (selstat == 0) { /* no events pending */
    313     /* printf("selstat == 0\n"); */
     325  if (selstat == -1) {
     326    owl_function_debugmsg("Error in select");
     327    /* error */
     328  } else if (selstat == 0) {
     329    /* no events pending */
    314330  } else if (selstat == 1) { /* outgoing data pending */
    315     /* printf("selstat == 1\n"); */
    316331    aim_tx_flushqueue(aimsess);
    317332  } else if (selstat == 2) { /* incoming data pending */
    318333    /* printf("selstat == 2\n"); */
    319     if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
    320       if (aim_handlerendconnect(aimsess, waitingconn) < 0) {
    321         /* printf("connection error (rend out)\n"); */
     334   
     335    if (aim_get_command(aimsess, waitingconn) >= 0) {
     336      aim_rxdispatch(aimsess);
     337    } else {
     338      /* printf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); */
     339      /* we should have callbacks for all these, else the library will do the conn_kill for us. */
     340      if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) {
     341        if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) {
     342          /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */
     343          aim_conn_kill(aimsess, &waitingconn);
     344        }
     345      } else {
    322346        aim_conn_kill(aimsess, &waitingconn);
    323347      }
    324     } else {
    325       if (aim_get_command(aimsess, waitingconn) >= 0) {
    326         aim_rxdispatch(aimsess);
    327       } else {
    328         /* printf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); */
    329         /* we should have callbacks for all these, else the library will do the conn_kill for us. */
    330         if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) {
    331           if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) {
    332             /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */
    333             aim_conn_kill(aimsess, &waitingconn);
    334           }
    335         } else {
    336           aim_conn_kill(aimsess, &waitingconn);
    337         }
    338         if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) {
    339           /* printf("major connection error\n"); */
    340           /* break; */
    341           /* we should probably kill the session */
    342         }
     348      if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) {
     349        /* printf("major connection error\n"); */
     350        /* break; */
     351        /* we should probably kill the session */
    343352      }
    344353    }
     
    354363}
    355364
    356 
    357365static int faimtest_parse_login(aim_session_t *sess, aim_frame_t *fr, ...)
    358366{
     
    384392
    385393  /* printf("Screen name: %s\n", info->sn); */
    386   owl_function_debugmsg("Here with %s", info->sn);
     394  owl_function_debugmsg("faimtest_parse_authresp: %s", info->sn);
    387395
    388396  /*
     
    434442  owl_aim_successful_login(info->sn);
    435443  addcb_bos(sess, bosconn);
    436   aim_sendcookie(sess, bosconn, info->cookie);
     444  aim_sendcookie(sess, bosconn, info->cookielen, info->cookie);
    437445  return 1;
    438446}
     
    513521}
    514522
    515 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...)
    516 {
    517   char buddies[128]; /* this is the new buddy list */
    518   char profile[256]; /* this is the new profile */
    519   /* char awaymsg[] = {"blah blah blah Ole! blah blah blah"}; */
    520 
    521   /* Caution: Buddy1 and Buddy2 are real people! (who I don't know) */
    522   /*  snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&%s&", priv->ohcaptainmycaptain ? priv->ohcaptainmycaptain : "blah");
    523   snprintf(profile, sizeof(profile), "Hello.<br>My captain is %s.  They were dumb enough to leave this message in their client, or they are using faimtest.  Shame
    524 on them.", priv->ohcaptainmycaptain);
    525   */
    526 
    527   /*
    528   snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&");
    529   snprintf(profile, sizeof(profile), "Hello.<br>This is a test");
    530   */
    531   strcpy(profile, "");
    532 
     523
     524static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
    533525  aim_reqpersonalinfo(sess, fr->conn);
     526
     527  #ifndef NOSSI
     528  aim_ssi_reqrights(sess);
     529  aim_ssi_reqdata(sess);
     530  #endif
     531
    534532  aim_bos_reqlocaterights(sess, fr->conn);
    535 
    536   /* aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS | AIM_CAPS_SENDBUDDYLIST | AIM_CAPS_ICQ | AIM_CAPS_ICQUNKNOWN | AIM_CAPS_ICQRTF | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_TRILLIANCRYPT); */
    537   aim_bos_setprofile(sess, fr->conn, "", "", AIM_CAPS_SENDBUDDYLIST );
    538533  aim_bos_reqbuddyrights(sess, fr->conn);
    539 
    540   /* send the buddy list and profile (required, even if empty) */
    541   aim_bos_setbuddylist(sess, fr->conn, buddies);
    542 
    543   aim_reqicbmparams(sess);
    544 
    545   aim_bos_reqrights(sess, fr->conn);
    546   /* set group permissions -- all user classes */
     534  aim_im_reqparams(sess);
     535  aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */
     536
     537  #ifdef NOSSI
    547538  aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS);
    548   aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE);
     539  aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
     540  #endif
    549541
    550542  return 1;
     
    693685      aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0);
    694686      /* Send the cookie to the Auth */
    695       aim_sendcookie(sess, tstconn, redir->cookie);
     687      aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie);
    696688      /* printf("sent cookie to authorizer host\n"); */
    697689    }
     
    726718  params->maxmsglen = 8000;
    727719  params->minmsginterval = 0; /* in milliseconds */
    728   aim_seticbmparam(sess, params);
     720  /* aim_seticbmparam(sess, params); */
     721  aim_im_setparams(sess, params);
    729722 
    730723  return 1;
     
    743736  /* printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); */
    744737 
    745   aim_ssi_reqrights(sess, fr->conn);
     738  /* aim_ssi_reqrights(sess, fr->conn); */
     739  aim_ssi_reqrights(sess);
    746740 
    747741  return 1;
     
    784778  va_list ap;
    785779  fu16_t interval;
    786  
     780
    787781  va_start(ap, fr);
    788782  interval = va_arg(ap, int);
    789783  va_end(ap);
    790  
     784
    791785  /* printf("minimum report interval: %d (seconds?)\n", interval); */
    792  
     786
    793787  if (!priv->connected) {
    794788    priv->connected++;
    795789  }
    796   aim_reqicbmparams(sess);
     790  /* aim_reqicbmparams(sess); */
     791  aim_im_reqparams(sess);
     792  /* kretch */
    797793  return 1;
    798794}
     
    10261022  char *prof = NULL;
    10271023  fu16_t inforeq = 0;
    1028 
     1024  owl_buddy *b;
    10291025  va_list ap;
    10301026  va_start(ap, fr);
     
    10361032
    10371033  /* right now the only reason we call this is for idle times */
    1038   owl_buddylist_set_idletime(owl_global_get_buddylist(&g), userinfo->sn, userinfo->idletime);
     1034  owl_function_debugmsg("parse_userinfo sn: %s idle: %i", userinfo->sn, userinfo->idletime);
     1035  b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g),
     1036                                userinfo->sn);
     1037  if (!b) return(1);
     1038  owl_buddy_set_idle_since(b, userinfo->idletime);
    10391039  return(1);
    10401040
     
    10441044  printuserflags(userinfo->flags);
    10451045  printf("\n");
    1046  
     1046
     1047  /*
    10471048  printf("userinfo: membersince: %lu\n", userinfo->membersince);
    10481049  printf("userinfo: onlinesince: %lu\n", userinfo->onlinesince);
    10491050  printf("userinfo: idletime: 0x%04x\n", userinfo->idletime);
    10501051  printf("userinfo: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities);
    1051  
     1052  */
    10521053 
    10531054  if (inforeq == AIM_GETINFO_GENERALINFO) {
     
    10661067}
    10671068
     1069#if 0
    10681070static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, const char *tmpstr)
    10691071{
     
    10731075    logout(sess);
    10741076  } else if (strstr(tmpstr, "goodday")) {
    1075     aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");
     1077    /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); */
    10761078  } else if (strstr(tmpstr, "haveicon") && priv->buddyicon) {
    10771079    struct aim_sendimext_args args;
     
    11181120     */
    11191121    args.destsn = userinfo->sn;
    1120     args.flags = AIM_IMFLAGS_CUSTOMCHARSET;
     1122    /* args.flags = AIM_IMFLAGS_CUSTOMCHARSET; */
    11211123    args.charset = args.charsubset = 0x4242;
    11221124    args.msg = data;
    11231125    args.msglen = sizeof(data);
    1124     aim_send_im_ext(sess, &args);
     1126    /* aim_send_im_ext(sess, &args); */
    11251127   } else if (strstr(tmpstr, "sendmulti")) {
    11261128    struct aim_sendimext_args args;
     
    11481150    args.mpmsg = &mpm;
    11491151   
    1150     aim_send_im_ext(sess, &args);
     1152    /* aim_send_im_ext(sess, &args); */
    11511153   
    11521154    aim_mpmsg_free(sess, &mpm);
     
    11821184    args.mpmsg = &mpm;
    11831185   
    1184     aim_send_im_ext(sess, &args);
     1186    /* aim_send_im_ext(sess, &args); */
    11851187    aim_mpmsg_free(sess, &mpm);
    11861188   
     
    11971199    args.featureslen = sizeof(features);
    11981200   
    1199     aim_send_im_ext(sess, &args);
     1201    /* aim_send_im_ext(sess, &args); */
    12001202  } else if (strstr(tmpstr, "sendicon") && priv->buddyicon) {
    1201     aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum);
     1203    /* aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); */
    12021204  } else if (strstr(tmpstr, "warnme")) {
    12031205    /* printf("icbm: sending non-anon warning\n"); */
    1204     aim_send_warning(sess, conn, userinfo->sn, 0);
     1206    /* aim_send_warning(sess, conn, userinfo->sn, 0); */
    12051207  } else if (strstr(tmpstr, "anonwarn")) {
    12061208    /* printf("icbm: sending anon warning\n"); */
    1207     aim_send_warning(sess, conn, userinfo->sn, AIM_WARN_ANON);
     1209    /* aim_send_warning(sess, conn, userinfo->sn, AIM_WARN_ANON); */
    12081210  } else if (strstr(tmpstr, "setdirectoryinfo")) {
    12091211    /* printf("icbm: sending backwards profile data\n"); */
     
    12121214    /* printf("icbm: setting fun interests\n"); */
    12131215    aim_setuserinterests(sess, conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1);
    1214   } else if (!strncmp(tmpstr, "getfile", 7)) {
    1215     if (!priv->ohcaptainmycaptain) {
    1216       aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!");
    1217     } else {
    1218       getfile_start(sess, conn, (strlen(tmpstr) < 8)?priv->ohcaptainmycaptain:tmpstr+8);
    1219     }
    12201216  } else if (!strncmp(tmpstr, "open chatnav", 12)) {
    12211217    aim_reqservice(sess, conn, AIM_CONN_TYPE_CHATNAV);
     
    12341230    aim_getinfo(sess, conn, "midendian", AIM_GETINFO_AWAYMESSAGE);
    12351231    aim_getinfo(sess, conn, "midendian", AIM_GETINFO_CAPABILITIES);
    1236   } else if (strstr(tmpstr, "open directim")) {
    1237     directim_start(sess, userinfo->sn);
    12381232  } else if(strstr(tmpstr, "lookup")) {
    1239     aim_usersearch_address(sess, conn, "mid@auk.cx");
     1233    /* aim_usersearch_address(sess, conn, "mid@auk.cx"); */
    12401234  } else if (!strncmp(tmpstr, "reqsendmsg", 10)) {
    1241     aim_send_im(sess, priv->ohcaptainmycaptain, 0, "sendmsg 7900");
     1235    /* aim_send_im(sess, priv->ohcaptainmycaptain, 0, "sendmsg 7900"); */
    12421236  } else if (!strncmp(tmpstr, "reqadmin", 8)) {
    12431237    aim_reqservice(sess, conn, AIM_CONN_TYPE_AUTH);
     
    12641258        newbuf[z] = (z % 10)+0x30;
    12651259      newbuf[i] = '\0';
    1266       aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf);
     1260      /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
    12671261      free(newbuf);
    12681262    }
    12691263  } else if (strstr(tmpstr, "seticqstatus")) {
    1270     aim_setextstatus(sess, conn, AIM_ICQ_STATE_DND);
     1264    aim_setextstatus(sess, AIM_ICQ_STATE_DND);
    12711265  } else if (strstr(tmpstr, "rtfmsg")) {
    12721266    static const char rtfmsg[] = {"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\froman\\fprq2\\fcharset0 Georgia;}{\\f2\\fmodern\\fprq1\\fcharset0 MS Mincho;}{\\f3\\froman\\fprq2\\fcharset2 Symbol;}}\\viewkind4\\uc1\\pard\\f0\\fs20 Test\\f1 test\\f2\fs44 test\\f3\\fs20 test\\f0\\par}"};
     
    12781272    rtfargs.bgcolor = 0x00000000;
    12791273    rtfargs.rtfmsg = rtfmsg;
    1280     aim_send_rtfmsg(sess, &rtfargs);
     1274    /* aim_send_rtfmsg(sess, &rtfargs); */
    12811275  } else {
    12821276    /* printf("unknown command.\n"); */
     
    12861280  return 0;
    12871281}
     1282#endif
    12881283
    12891284/*
     
    12931288{
    12941289  struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;
    1295   int clienttype = AIM_CLIENTTYPE_UNKNOWN;
    12961290  owl_message *m;
    12971291  char *stripmsg, *nz_screenname, *wrapmsg;
    12981292  char realmsg[8192+1] = {""};
    1299   clienttype = aim_fingerprintclient(args->features, args->featureslen);
     1293  /* int clienttype = AIM_CLIENTTYPE_UNKNOWN; */
     1294
     1295  /* clienttype = aim_fingerprintclient(args->features, args->featureslen); */
    13001296
    13011297  /*
     
    13251321  */
    13261322
     1323  /*
    13271324  if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) {
    1328     /* printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset); */
    1329   }
     1325  printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset);
     1326  }
     1327  */
    13301328 
    13311329  /*
     
    14251423 
    14261424  if (priv->buddyicon && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) {
    1427     aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum);
     1425    /* aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); */
    14281426  }
    14291427 
     
    14511449  */
    14521450 
    1453   if (args->reqclass == AIM_CAPS_GETFILE) {
    1454     getfile_requested(sess, conn, userinfo, args);
    1455   } else if (args->reqclass == AIM_CAPS_SENDFILE) {
     1451  if (args->reqclass == AIM_CAPS_SENDFILE) {
    14561452    /* printf("send file!\n"); */
    14571453  } else if (args->reqclass == AIM_CAPS_CHAT) {
     
    14651461
    14661462    /* aim_chat_join(sess, conn, args->info.chat.roominfo.exchange, args->info.chat.roominfo.name, args->info.chat.roominfo.instance); */
    1467   } else if (args->reqclass == AIM_CAPS_IMIMAGE) {
    1468     directim_requested(sess, conn, userinfo, args);
    14691463  } else if (args->reqclass == AIM_CAPS_BUDDYICON) {
    14701464    /* printf("Buddy Icon from %s, length = %lu\n", userinfo->sn, args->info.icon.length); */
     
    15081502  aim_userinfo_t *userinfo;
    15091503  char *nz_screenname;
    1510 
     1504  owl_buddy *b;
     1505  owl_buddylist *bl;
    15111506  va_list ap;
    15121507  va_start(ap, fr);
     
    15151510
    15161511  nz_screenname=owl_aim_normalize_screenname(userinfo->sn);
     1512  bl=owl_global_get_buddylist(&g);
     1513 
    15171514  owl_buddylist_oncoming(owl_global_get_buddylist(&g), nz_screenname);
     1515
     1516  if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
     1517    /*  */
     1518  }
     1519
     1520  b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), nz_screenname);
     1521  if (!b) {
     1522    owl_function_debugmsg("Error: parse_oncoming setting idle time with no buddy present.");
     1523    return(1);
     1524  }
     1525  if (userinfo->idletime==0) {
     1526    owl_buddy_set_unidle(b);
     1527  } else {
     1528    owl_buddy_set_idle(b);
     1529    owl_buddy_set_idle_since(b, userinfo->idletime);
     1530  }
     1531  owl_function_debugmsg("parse_oncoming sn: %s idle: %i", userinfo->sn, userinfo->idletime);
     1532   
    15181533  owl_free(nz_screenname);
    15191534 
     
    15501565  owl_free(nz_screenname);
    15511566
     1567  if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
     1568    owl_function_debugmsg("parse_offgoing sn: %s idle time %i", userinfo->sn, userinfo->idletime);
     1569  }
     1570
    15521571  /*
    15531572  printf("%ld  %s is now offline (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n",
     
    18301849  /* Login will happen all over again. */
    18311850  addcb_bos(sess, bosconn);
    1832   aim_sendcookie(sess, bosconn, cookie);
     1851  /* aim_sendcookie(sess, bosconn, cookie); */
    18331852  return 1;
    18341853}
     
    18381857 
    18391858  /* printf("got SSI rights, requesting data\n"); */
    1840   aim_ssi_reqdata(sess, fr->conn, 0, 0x0000);
     1859  /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */
     1860  aim_ssi_reqdata(sess);
    18411861 
    18421862  return 1;
     
    18491869  fu16_t itemcount;
    18501870  fu32_t stamp;
    1851   struct aim_ssi_item *list, *l;
     1871  struct aim_ssi_item *list;
     1872  struct aim_ssi_item *curitem;
     1873  /* struct aim_ssi_item *l; */
    18521874 
    18531875  va_start(ap, fr);
     
    18591881 
    18601882  /* printf("got SSI data: (0x%02x, %d items, %ld)\n", fmtver, itemcount, stamp); */
    1861   for (l = list; l; l = l->next) {
     1883  for (curitem=sess->ssi.local; curitem; curitem=curitem->next) {
     1884    /* for (l = list; l; l = l->next) { */
    18621885    /* printf("\t0x%04x (%s) - 0x%04x/0x%04x\n", l->type, l->name, l->gid, l->bid); */
    18631886    /* printf("I would have printed data here!\n"); */
    18641887  }
    18651888 
    1866   aim_ssi_enable(sess, fr->conn);
     1889  aim_ssi_enable(sess);
    18671890 
    18681891  return 1;
     
    18721895{
    18731896  /* printf("server says we have the latest SSI data already\n"); */
    1874   aim_ssi_enable(sess, fr->conn);
     1897  /* aim_ssi_enable(sess, fr->conn); */
     1898  aim_ssi_enable(sess);
    18751899  return 1;
    18761900}
     
    21282152  aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
    21292153  aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0);
    2130   aim_sendcookie(sess, tstconn, redir->cookie);
     2154  aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie);
    21312155  /* printf("chatnav: connected\n"); */
    21322156  return;
     
    21522176  aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
    21532177  aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0);
    2154   aim_sendcookie(sess, tstconn, redir->cookie);
     2178  aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie);
    21552179  return;       
    2156 }
    2157 
    2158 
    2159 
    2160 
    2161 /******************************************* ft.c ******************************************/
    2162 
    2163 
    2164 static int directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...)
    2165 {
    2166   va_list ap;
    2167   char *sn, *msg;
    2168  
    2169   va_start(ap, fr);
    2170   sn = va_arg(ap, char *);
    2171   msg = va_arg(ap, char *);
    2172   va_end(ap);
    2173  
    2174   /* printf("Directim from %s: %s\n", sn, msg); */
    2175   if (strstr(msg, "sendmsg")) {
    2176     int i;
    2177    
    2178     i = atoi(strstr(msg, "sendmsg")+8);
    2179     if (i < 10000) {
    2180       char *newbuf;
    2181       int z;
    2182      
    2183       newbuf = malloc(i+1);
    2184       for (z = 0; z < i; z++)
    2185         newbuf[z] = (z % 10)+0x30;
    2186       newbuf[i] = '\0';
    2187       aim_send_im_direct(sess, fr->conn, newbuf, strlen(newbuf), 0);
    2188       free(newbuf);
    2189     }
    2190   } else if (strstr(msg, "goodday")) {
    2191     aim_send_im_direct(sess, fr->conn, "Good day to you, too", 18, 0);
    2192   } else {
    2193     char newmsg[1024];
    2194     snprintf(newmsg, sizeof(newmsg), "unknown (%s)\n", msg);
    2195     aim_send_im_direct(sess, fr->conn, newmsg, strlen(newmsg), 0);
    2196   }
    2197 
    2198   return 1;
    2199 }
    2200 
    2201 static int directim_typing(aim_session_t *sess, aim_frame_t *fr, ...)
    2202 {
    2203   va_list ap;
    2204   char *sn;
    2205  
    2206   va_start(ap, fr);
    2207   sn = va_arg(ap, char *);
    2208   va_end(ap);
    2209   /* printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); */
    2210   return 1;
    2211 }
    2212 
    2213 static int faimtest_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...)
    2214 {
    2215   va_list ap;
    2216   aim_conn_t *newconn, *listenerconn;
    2217  
    2218   va_start(ap, fr);
    2219   newconn = va_arg(ap, aim_conn_t *);
    2220   listenerconn = va_arg(ap, aim_conn_t *);
    2221   va_end(ap);
    2222  
    2223   aim_conn_close(listenerconn);
    2224   aim_conn_kill(sess, &listenerconn);
    2225  
    2226   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, directim_incoming, 0);
    2227   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, directim_typing, 0);
    2228  
    2229   aim_send_im_direct(sess, newconn, "goodday", 8, 0);
    2230  
    2231   /* printf("OFT: DirectIM: connected to %s\n", aim_directim_getsn(newconn)); */
    2232  
    2233   return 1;
    2234 }
    2235 
    2236 static int faimtest_getfile_filereq(aim_session_t *ses, aim_frame_t *fr, ...)
    2237 {
    2238   va_list ap;
    2239   aim_conn_t *oftconn;
    2240   struct aim_fileheader_t *fh;
    2241   fu8_t *cookie;
    2242  
    2243   va_start(ap, fr);
    2244   oftconn = va_arg(ap, aim_conn_t *);
    2245   fh = va_arg(ap, struct aim_fileheader_t *);
    2246   cookie = va_arg(ap, fu8_t *);
    2247   va_end(ap);
    2248  
    2249   /* printf("request for file %s.\n", fh->name); */
    2250  
    2251   return 1;
    2252 }
    2253 
    2254 static int faimtest_getfile_filesend(aim_session_t *sess, aim_frame_t *fr, ...)
    2255 {
    2256   struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;
    2257   va_list ap;
    2258   aim_conn_t *oftconn;
    2259   struct aim_fileheader_t *fh;
    2260   char *path;
    2261   fu8_t *cookie;
    2262   int pos, bufpos = 0, bufsize = 2048, i;
    2263   char *buf;
    2264   FILE *file;
    2265  
    2266   va_start(ap, fr);
    2267   oftconn = va_arg(ap, aim_conn_t *);
    2268   fh = va_arg(ap, struct aim_fileheader_t *);
    2269   cookie = va_arg(ap, fu8_t *);
    2270   va_end(ap);
    2271  
    2272   /* printf("sending file %s(%ld).\n", fh->name, fh->size); */
    2273 
    2274   if (!(buf = malloc(2048)))
    2275     return -1;
    2276  
    2277   if (!(path = (char *)calloc(1, strlen(priv->listingpath) +strlen(fh->name)+2))) {
    2278     /* perror("calloc"); */
    2279     /* printf("error in calloc of path\n"); */
    2280    
    2281     return 0; /* XXX: no idea what winaim expects here =) */
    2282   }
    2283 
    2284   snprintf(path, strlen(priv->listingpath)+strlen(fh->name)+2, "%s/%s", priv->listingpath, fh->name);
    2285  
    2286   if (!(file = fopen(path, "r"))) {
    2287     /* printf("getfile_send fopen failed for %s. damn.\n", path); */
    2288     return 0;
    2289   }
    2290  
    2291   /*
    2292    * This is a mess. Remember that faimtest is demonstration code
    2293    * only and for the sake of the gods, don't use this code in any
    2294    * of your clients. --mid
    2295    */
    2296   for(pos = 0; pos < fh->size; pos++) {
    2297    
    2298     bufpos = pos % bufsize;
    2299    
    2300     if (bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */
    2301       if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {
    2302         /* perror("faim: getfile_send: write1"); */
    2303         /* printf("faim: getfile_send: whoopsy, didn't write it all...\n"); */
    2304         free(buf);   
    2305         return 0;
    2306       }
    2307     }
    2308    
    2309     if( (buf[bufpos] = fgetc(file)) == EOF) {
    2310       if(pos != fh->size) {
    2311         /* printf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size); */
    2312         free(buf);   
    2313         return 0;
    2314       }
    2315     }     
    2316     /* printf("%c(0x%02x) ", buf[pos], buf[pos]); */
    2317   }
    2318  
    2319   if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {
    2320     /* perror("faim: getfile_send: write2"); */
    2321     /* printf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n"); */
    2322     free(buf);   
    2323     return 0;
    2324   }
    2325  
    2326   free(buf);
    2327   free(fh);
    2328  
    2329   return 1;
    2330 }
    2331 
    2332 static int faimtest_getfile_complete(aim_session_t *sess, aim_frame_t *fr, ...)
    2333 {
    2334   va_list ap;
    2335   aim_conn_t *conn;
    2336   struct aim_fileheader_t *fh;
    2337  
    2338   va_start(ap, fr);
    2339   conn = va_arg(ap, aim_conn_t *);
    2340   fh = va_arg(ap, struct aim_fileheader_t *);
    2341   va_end(ap);
    2342  
    2343   /* printf("completed file transfer for %s.\n", fh->name); */
    2344  
    2345   aim_conn_close(conn);
    2346   aim_conn_kill(sess, &conn);
    2347  
    2348   return 1;
    2349 }
    2350 
    2351 static int faimtest_getfile_disconnect(aim_session_t *sess, aim_frame_t *fr, ...)
    2352 {
    2353   va_list ap;
    2354   aim_conn_t *conn;
    2355   char *sn;
    2356  
    2357   va_start(ap, fr);
    2358   conn = va_arg(ap, aim_conn_t *);
    2359   sn = va_arg(ap, char *);
    2360   va_end(ap);
    2361  
    2362   aim_conn_kill(sess, &conn);
    2363  
    2364   /* printf("getfile: disconnected from %s\n", sn); */
    2365  
    2366   return 1;
    2367 }
    2368 
    2369 static int faimtest_getfile_listing(aim_session_t *sess, aim_frame_t *fr, ...)
    2370 {
    2371   va_list ap;
    2372   aim_conn_t *conn;
    2373   char *listing;
    2374   struct aim_filetransfer_priv *ft;
    2375   char *filename, *nameend, *sizec;
    2376   int filesize, namelen;
    2377  
    2378   va_start(ap, fr);
    2379   conn = va_arg(ap, aim_conn_t *);
    2380   ft = va_arg(ap, struct aim_filetransfer_priv *);
    2381   listing = va_arg(ap, char *);
    2382   va_end(ap);
    2383  
    2384   /* printf("listing on %d==================\n%s\n===========\n", conn->fd, listing); */
    2385  
    2386   nameend = strstr(listing+0x1a, "\r");
    2387   namelen = nameend - (listing + 0x1a);
    2388  
    2389   filename = malloc(namelen + 1);
    2390   strncpy(filename, listing+0x1a, namelen);
    2391   filename[namelen] = 0x00;
    2392  
    2393   sizec = malloc(8+1);
    2394   memcpy(sizec, listing + 0x11, 8);
    2395   sizec[8] = 0x00;
    2396  
    2397   filesize =  strtol(sizec, (char **)NULL, 10);
    2398  
    2399   /* printf("requesting %d %s(%d long)\n", namelen, filename, filesize); */
    2400  
    2401   /* aim_oft_getfile_request(sess, conn, filename, filesize); */
    2402  
    2403   free(filename);
    2404   free(sizec);
    2405  
    2406   return 0;
    2407 }
    2408 
    2409 static int faimtest_getfile_listingreq(aim_session_t *sess, aim_frame_t *fr, ...)
    2410 {
    2411   struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;
    2412   va_list ap;
    2413   aim_conn_t *oftconn;
    2414   struct aim_fileheader_t *fh;
    2415   int pos, bufpos = 0, bufsize = 2048, i;
    2416   char *buf;
    2417  
    2418   va_start(ap, fr);
    2419   oftconn = va_arg(ap, aim_conn_t *);
    2420   fh = va_arg(ap, struct aim_fileheader_t *);
    2421   va_end(ap);
    2422  
    2423   /* printf("sending listing of size %ld\n", fh->size); */
    2424 
    2425   if(!(buf = malloc(2048))) return -1;
    2426  
    2427   for(pos = 0; pos < fh->size; pos++) {
    2428     bufpos = pos % bufsize;
    2429     if(bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */
    2430       if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {
    2431         /* perror("faim: getfile_send: write1"); */
    2432         /* printf("faim: getfile_send: whoopsy, didn't write it all...\n"); */
    2433         free(buf);   
    2434         return 0;
    2435       }
    2436     }
    2437     if( (buf[bufpos] = fgetc(priv->listingfile)) == EOF) {
    2438       if(pos != fh->size) {
    2439         /* printf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size); */
    2440         free(buf);   
    2441         return 0;
    2442       }
    2443     }     
    2444   }
    2445  
    2446   if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {
    2447     /* perror("faim: getfile_send: write2"); */
    2448     /* printf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n"); */
    2449     free(buf);   
    2450     return 0;
    2451   }
    2452  
    2453   /* printf("sent listing\n"); */
    2454   free(buf);
    2455  
    2456   return 0;
    2457 }
    2458 
    2459 static int faimtest_getfile_receive(aim_session_t *sess, aim_frame_t *fr, ...)
    2460 {
    2461   /* needs ot be fixed --kretch */
    2462 #if 0
    2463   va_list ap;
    2464   aim_conn_t *conn;
    2465   struct aim_filetransfer_priv *ft;
    2466   unsigned char data;
    2467   int pos;
    2468 
    2469 
    2470   va_start(ap, fr);
    2471   conn = va_arg(ap, aim_conn_t *);
    2472   ft = va_arg(ap, struct aim_filetransfer_priv *);
    2473   va_end(ap);
    2474 
    2475   /* printf("receiving %ld bytes of file data for %s:\n\t", ft->fh.size, ft->fh.name); */
    2476 
    2477   for(pos = 0; pos < ft->fh.size; pos++) {
    2478     read(conn->fd, &data, 1);
    2479     /* printf("%c(%02x) ", data, data); */
    2480   }
    2481 
    2482   /* printf("\n"); */
    2483 
    2484   aim_oft_getfile_end(sess, conn);
    2485 #endif
    2486   return 0;
    2487 }
    2488 
    2489 static int faimtest_getfile_state4(aim_session_t *sess, aim_frame_t *fr, ...)
    2490 {
    2491   va_list ap;
    2492   aim_conn_t *conn;
    2493  
    2494   va_start(ap, fr);
    2495   conn = va_arg(ap, aim_conn_t *);
    2496   va_end(ap);
    2497  
    2498   aim_conn_close(conn);
    2499   aim_conn_kill(sess, &conn);
    2500  
    2501   return 0;
    2502 }
    2503 
    2504 static int faimtest_getfile_initiate(aim_session_t *sess, aim_frame_t *fr, ...)
    2505 {
    2506   va_list ap;
    2507   aim_conn_t *conn, *listenerconn;
    2508   struct aim_filetransfer_priv *priv;
    2509  
    2510   va_start(ap, fr);
    2511   conn = va_arg(ap, aim_conn_t *);
    2512   listenerconn = va_arg(ap, aim_conn_t *);
    2513   va_end(ap);
    2514  
    2515   aim_conn_close(listenerconn);
    2516   aim_conn_kill(sess, &listenerconn);
    2517 
    2518   /*   This doesn't work with the new libfaim */
    2519   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ,  faimtest_getfile_filereq, 0);
    2520   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);
    2521   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);     
    2522   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);     
    2523   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTING, faimtest_getfile_listing, 0);
    2524   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);
    2525   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILERECEIVE, faimtest_getfile_receive, 0);
    2526   aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILESTATE4, faimtest_getfile_state4, 0);
    2527  
    2528   priv = (struct aim_filetransfer_priv *)conn->priv;
    2529  
    2530   /* printf("getfile: %s (%s) connected to us on %d\n", priv->sn, priv->ip, conn->fd); */
    2531  
    2532   return 1;
    2533 }
    2534 
    2535 void getfile_start(aim_session_t *sess, aim_conn_t *conn, const char *sn)
    2536 {
    2537   aim_conn_t *newconn;
    2538  
    2539   newconn = aim_getfile_initiate(sess, conn, sn);
    2540   /* printf("getting file listing from %s\n", sn); */
    2541   aim_conn_addhandler(sess, newconn,  AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE, faimtest_getfile_initiate,0);
    2542  
    2543   return;
    2544 }
    2545 
    2546 void getfile_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args)
    2547 {
    2548   struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;
    2549   aim_conn_t *newconn;
    2550   struct aim_fileheader_t *fh;
    2551  
    2552   printf("get file request from %s (at %s/%s/%s) %x\n", userinfo->sn, args->clientip, args->clientip2, args->verifiedip, args->reqclass);
    2553   fh = aim_getlisting(sess, priv->listingfile);
    2554   newconn = aim_accepttransfer(sess, conn, userinfo->sn, args->cookie, args->clientip, fh->totfiles, fh->totsize, fh->size, fh->checksum, args->reqclass);
    2555   free(fh);
    2556 
    2557   if ( (!newconn) || (newconn->fd == -1) ) {
    2558     printf("getfile: requestconn: apparent error in accepttransfer\n");
    2559     if (newconn) aim_conn_kill(sess, &newconn);
    2560     return;
    2561   }
    2562  
    2563   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);
    2564   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ,  faimtest_getfile_filereq, 0);
    2565   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);
    2566   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);     
    2567   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);     
    2568  
    2569   /* printf("getfile connect succeeded, handlers added.\n"); */
    2570  
    2571   return;
    2572 }
    2573 
    2574 void directim_start(aim_session_t *sess, const char *sn)
    2575 {
    2576   aim_conn_t *newconn;
    2577  
    2578   /* printf("opening directim to %s\n", sn); */
    2579   newconn = aim_directim_initiate(sess, sn);
    2580   if (!newconn || (newconn->fd == -1)) {
    2581     /* printf("connection failed!\n"); */
    2582     if (newconn) aim_conn_kill(sess, &newconn);
    2583   } else {
    2584     aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate, 0);
    2585   }
    2586   return;
    2587 }
    2588 
    2589 void directim_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args)
    2590 {
    2591   aim_conn_t *newconn;
    2592  
    2593   /* printf("OFT: DirectIM: request from %s (%s/%s/%s)\n", userinfo->sn, args->clientip, args->clientip2, args->verifiedip); */
    2594  
    2595   newconn = aim_directim_connect(sess, userinfo->sn, args->clientip, args->cookie);
    2596   if (!newconn || (newconn->fd == -1)) {
    2597     /* printf("icbm: imimage: could not connect\n"); */
    2598     if (newconn) aim_conn_kill(sess, &newconn);
    2599   } else {
    2600     aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, directim_incoming, 0);
    2601     aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, directim_typing, 0);
    2602     /* printf("OFT: DirectIM: connected to %s\n", userinfo->sn); */
    2603     aim_send_im_direct(sess, newconn, "goodday", 7, 0);
    2604   }
    26052180}
    26062181
  • buddylist.c

    r2404c3a rf4d0975  
    33static const char fileIdent[] = "$Id$";
    44
    5 void owl_buddylist_init(owl_buddylist *b)
     5void owl_buddylist_init(owl_buddylist *bl)
    66{
    7   owl_list_create(&(b->buddies));
    8   owl_list_create(&(b->idletimes));
    9   /* owl_list_create(&(g->buddymsg_queue)); */
     7  owl_list_create(&(bl->buddies));
     8}
     9
     10/* add a (logged-in) AIM buddy to the buddy list
     11 */
     12void owl_buddylist_add_aim_buddy(owl_buddylist *bl, char *screenname)
     13{
     14  owl_buddy *b;
     15  b=owl_malloc(sizeof(owl_buddy));
     16 
     17  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
     18  owl_list_append_element(&(bl->buddies), b);
     19}
     20
     21/* remove an AIM buddy from the buddy list
     22 */
     23int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, char *name)
     24{
     25  int i, j;
     26  owl_buddy *b;
     27
     28  j=owl_list_get_size(&(bl->buddies));
     29  for (i=0; i<j; i++) {
     30    b=owl_list_get_element(&(bl->buddies), i);
     31    if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) {
     32      owl_list_remove_element(&(bl->buddies), i);
     33      owl_buddy_free(b);
     34      return(0);
     35    }
     36  }
     37  return(1);
    1038}
    1139
     
    1442 * logged in.
    1543 */
    16 void owl_buddylist_oncoming(owl_buddylist *b, char *screenname)
     44void owl_buddylist_oncoming(owl_buddylist *bl, char *screenname)
    1745{
    18   int *zero;
    1946  owl_message *m;
    2047
    21   if (!owl_buddylist_is_buddy_loggedin(b, screenname)) {
     48  if (!owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) {
    2249
    23     /* add the buddy */
    24     owl_list_append_element(&(b->buddies), owl_strdup(screenname));
    25     zero=owl_malloc(sizeof(int));
    26     *zero=0;
    27     owl_list_append_element(&(b->idletimes), zero);
     50    owl_buddylist_add_aim_buddy(bl, screenname);
    2851
    29     /* do a request for idle time */
    30     owl_buddylist_request_idletime(b, screenname);
    31        
    3252    /* are we ingoring login messages for a while? */
    3353    if (!owl_timer_is_expired(owl_global_get_aim_login_timer(&g))) return;
     
    4868 * has logged out, and sending a message if they were logged in.
    4969 */
    50 void owl_buddylist_offgoing(owl_buddylist *b, char *screenname)
     70void owl_buddylist_offgoing(owl_buddylist *bl, char *screenname)
    5171{
    52   int index;
    5372  owl_message *m;
    5473
    55   index=owl_buddylist_get_buddy_index(b, screenname);
    56   if (index==-1) return;
    57 
    58   owl_free(owl_list_get_element(&(b->buddies), index));
    59   owl_free(owl_list_get_element(&(b->idletimes), index));
    60   owl_list_remove_element(&(b->buddies), index);
    61   owl_list_remove_element(&(b->idletimes), index);
    62 
     74  owl_buddylist_remove_aim_buddy(bl, screenname);
     75 
    6376  m=owl_malloc(sizeof(owl_message));
    6477  owl_message_create_aim(m,
     
    7184}
    7285
    73 /* send requests to the AIM server to retrieve info
    74  * on all buddies.  The AIM callback then fills in the
    75  * values when the responses are received
     86/* return the number of logged in buddies */
     87int owl_buddylist_get_size(owl_buddylist *bl)
     88{
     89  return(owl_list_get_size(&(bl->buddies)));
     90}
     91
     92/* return the buddy with index N.  If out of range, return NULL
    7693 */
    77 void owl_buddylist_request_idletimes(owl_buddylist *b)
     94owl_buddy *owl_buddylist_get_buddy_n(owl_buddylist *bl, int index)
     95{
     96  if (index<0) return(NULL);
     97  if (index>(owl_buddylist_get_size(bl)-1)) return(NULL);
     98
     99  return(owl_list_get_element(&(bl->buddies), index));
     100}
     101
     102/* return the AIM buddy with screenname 'name'.  If
     103 * no such buddy is logged in, return NULL.
     104 */
     105owl_buddy *owl_buddylist_get_aim_buddy(owl_buddylist *bl, char *name)
    78106{
    79107  int i, j;
     108  owl_buddy *b;
    80109
    81   j=owl_buddylist_get_size(b);
     110  j=owl_list_get_size(&(bl->buddies));
    82111  for (i=0; i<j; i++) {
    83     owl_aim_get_idle(owl_buddylist_get_buddy(b, i));
     112    b=owl_list_get_element(&(bl->buddies), i);
     113    if (!strcasecmp(name, owl_buddy_get_name(b))) return(b);
    84114  }
    85 }
    86 
    87 /* send request to the AIM server to retrieve info on one buddy.  The
    88  * AIM callback then fills in the values when the responses are
    89  * received.  The buddy must be logged in or no request will be
    90  * performed.
    91  */
    92 void owl_buddylist_request_idletime(owl_buddylist *b, char *screenname)
    93 {
    94   if (!owl_buddylist_is_buddy_loggedin(b, screenname)) return;
    95  
    96   owl_aim_get_idle(screenname);
    97 }
    98 
    99 /* return the number of logged in buddies */
    100 int owl_buddylist_get_size(owl_buddylist *b)
    101 {
    102   return(owl_list_get_size(&(b->buddies)));
    103 }
    104 
    105 /* get buddy number 'n' */
    106 char *owl_buddylist_get_buddy(owl_buddylist *b, int n)
    107 {
    108   if (n > owl_buddylist_get_size(b)-1) return("");
    109   return(owl_list_get_element(&(b->buddies), n));
    110 }
    111 
    112 /* Return the index of the buddy 'screename' or -1
    113  * if the buddy is not logged in.
    114  */
    115 int owl_buddylist_get_buddy_index(owl_buddylist *b, char *screenname)
    116 {
    117   int i, j;
    118  
    119   j=owl_list_get_size(&(b->buddies));
    120   for (i=0; i<j; i++) {
    121     if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
    122       return(i);
    123     }
    124   }
    125   return(-1);
     115  return(NULL);
    126116}
    127117
     
    129119 * otherwise return 0
    130120 */
    131 int owl_buddylist_is_buddy_loggedin(owl_buddylist *b, char *screenname)
     121int owl_buddylist_is_aim_buddy_loggedin(owl_buddylist *bl, char *screenname)
    132122{
    133   if (owl_buddylist_get_buddy_index(b, screenname)!=-1) return(1);
    134   return(0);
    135 }
     123  owl_buddy *b;
    136124
    137 /* get the idle time for buddy number 'n' */
    138 int owl_buddylist_get_idletime(owl_buddylist *b, int n)
    139 {
    140   int *foo;
    141 
    142   foo=owl_list_get_element(&(b->idletimes), n);
    143   return(*foo);
    144 }
    145 
    146 /* Set the idle time for user 'screenname'.  If the given screenname
    147  * is not on the buddy list do nothing.  If there is a queued request
    148  * for this screename, remove it from the queue.
    149  */
    150 void owl_buddylist_set_idletime(owl_buddylist *b, char *screenname, int minutes)
    151 {
    152   int index, *idle;
    153 
    154   index=owl_buddylist_get_buddy_index(b, screenname);
    155   if (index==-1) return;
    156 
    157   owl_free(owl_list_get_element(&(b->idletimes), index));
    158   idle=owl_malloc(sizeof(int));
    159   *idle=minutes;
    160   owl_list_replace_element(&(b->idletimes), index, idle);
     125  b=owl_buddylist_get_aim_buddy(bl, screenname);
     126  if (b==NULL) return(0);
     127  return(1);
    161128}
    162129
    163130/* remove all buddies from the list */
    164 void owl_buddylist_clear(owl_buddylist *b) {
    165   owl_list_free_all(&(b->buddies), owl_free);
    166   owl_list_free_all(&(b->idletimes), owl_free);
    167   owl_list_create(&(b->buddies));
    168   owl_list_create(&(b->idletimes));
     131void owl_buddylist_clear(owl_buddylist *bl)
     132{
     133  owl_list_free_all(&(bl->buddies), (void(*)(void*))owl_buddy_free);
     134  owl_list_create(&(bl->buddies));
    169135}
     136
     137void owl_buddylist_free(owl_buddylist *bl)
     138{
     139  owl_list_free_all(&(bl->buddies), (void(*)(void*))owl_buddy_free);
     140}
  • functions.c

    rf933403 rf4d0975  
    28752875  int i, j, idle;
    28762876  owl_fmtext fm;
    2877   owl_buddylist *b;
     2877  owl_buddylist *bl;
     2878  owl_buddy *b;
    28782879  char *foo, *timestr;
    28792880#ifdef HAVE_LIBZEPHYR
     
    28872888
    28882889  if (aim && owl_global_is_aimloggedin(&g)) {
    2889     b=owl_global_get_buddylist(&g);
     2890    bl=owl_global_get_buddylist(&g);
    28902891
    28912892    owl_fmtext_append_bold(&fm, "AIM users logged in:\n");
    2892     j=owl_buddylist_get_size(b);
     2893    /* we're assuming AIM for now */
     2894    j=owl_buddylist_get_size(bl);
    28932895    for (i=0; i<j; i++) {
    2894       idle=owl_buddylist_get_idletime(b, i);
     2896      b=owl_buddylist_get_buddy_n(bl, i);
     2897      idle=owl_buddy_get_idle_time(b);
    28952898      if (idle!=0) {
    28962899        timestr=owl_util_minutes_to_timestr(idle);
     
    28992902      }
    29002903      foo=owl_sprintf("  %-15.15s %-12.12s\n",
    2901                       owl_buddylist_get_buddy(b, i),
     2904                      owl_buddy_get_name(b),
    29022905                      timestr);
    29032906      owl_fmtext_append_normal(&fm, foo);
  • message.c

    rf1e629d rf4d0975  
    7575    }
    7676  }
    77   owl_function_debugmsg("No attribute %s found", attrname);
     77
     78  /*
     79  owl_function_debugmsg("No attribute %s found for message %i",
     80                        attrname,
     81                        owl_message_get_id(m));
     82  */
    7883  return(NULL);
    7984}
     
    848853  owl_fmtext_free(&(m->fmtext));
    849854}
    850 
    851 
  • owl.c

    r12582d3 rf4d0975  
    329329      if (owl_global_is_aimloggedin(&g)) {
    330330        if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
    331           owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
     331          /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
    332332          owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
    333333        }
  • owl.h

    r2404c3a rf4d0975  
    2121static const char owl_h_fileIdent[] = "$Id$";
    2222
    23 #define OWL_VERSION         2.0.8-pre-4
    24 #define OWL_VERSION_STRING "2.0.8-pre-4"
     23#define OWL_VERSION         2.0.8-pre-5
     24#define OWL_VERSION_STRING "2.0.8-pre-5"
    2525
    2626#define OWL_DEBUG 0
     
    4747#define OWL_EDITWIN_STYLE_MULTILINE 0
    4848#define OWL_EDITWIN_STYLE_ONELINE   1
     49
     50#define OWL_PROTOCOL_ZEPHYR         0
     51#define OWL_PROTOCOL_AIM            1
     52#define OWL_PROTOCOL_JABBER         2
     53#define OWL_PROTOCOL_ICQ            3
     54#define OWL_PROTOCOL_YAHOO          4
     55#define OWL_PROTOCOL_MSN            5
    4956
    5057#define OWL_MESSAGE_TYPE_ADMIN      0
     
    384391} owl_keyhandler;
    385392
     393typedef struct _owl_buddy {
     394  int proto;
     395  char *name;
     396  int isidle;
     397  int idlesince;
     398} owl_buddy;
     399
    386400typedef struct _owl_buddylist {
    387401  owl_list buddies;
    388   owl_list idletimes;
    389402} owl_buddylist;
    390403
Note: See TracChangeset for help on using the changeset viewer.