Index: aim.c
===================================================================
--- aim.c	(revision 1db061d21d0e731372f0030eb5b47cfbe6521ff0)
+++ aim.c	(revision a0a517919ef86311a49f1e5652564bf3c3408ef0)
@@ -116,5 +116,5 @@
 
   /* an experiment to expose idle time */
-  aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400);
+  /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */
 }
 
@@ -136,5 +136,5 @@
   aim_tx_setenqueue(owl_global_get_aimsess(&g), AIM_TX_IMMEDIATE, NULL);
   
-  /* login */
+  /* request a login */
   ret=login(owl_global_get_aimsess(&g), priv->screenname, priv->password);
   if (ret) {
@@ -143,65 +143,10 @@
     return(-1);
   }
+
+  /* start processing AIM events */
   owl_global_set_doaimevents(&g);
 
   return(0);
 }
-
-#if 0
-static void oscar_login(GaimAccount *account)
-{
-  aim_session_t *sess;
-  aim_conn_t *conn;
-  char buf[256];
-  GaimConnection *gc = gaim_account_get_connection(account);
-  struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1);
-
-  gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc);
-
-  if (isdigit(*(gaim_account_get_username(account)))) {
-    od->icq = TRUE;
-  } else {
-    gc->flags |= GAIM_CONNECTION_HTML;
-    gc->flags |= GAIM_CONNECTION_AUTO_RESP;
-  }
-  od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo);
-
-  sess = g_new0(aim_session_t, 1);
-
-  aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
-  aim_setdebuggingcb(sess, oscar_debug);
-
-  /* we need an immediate queue because we don't use a while-loop to
-   * see if things need to be sent. */
-  aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL);
-  od->sess = sess;
-  sess->aux_data = gc;
-
-  conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
-  if (conn == NULL) {
-    gaim_debug(GAIM_DEBUG_ERROR, "oscar",
-	       "internal connection error\n");
-    gaim_connection_error(gc, _("Unable to login to AIM"));
-    return;
-  }
-
-  g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account));
-  gaim_connection_update_progress(gc, buf, 2, 5);
-
-  aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0);
-  aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0);
-  aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0);
-
-  conn->status |= AIM_CONN_STATUS_INPROGRESS;
-  if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER),
-			 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT),
-			 oscar_login_connect, gc) < 0) {
-    gaim_connection_error(gc, _("Couldn't connect to host"));
-    return;
-  }
-  aim_request_login(sess, conn, gaim_account_get_username(account));
-}
-#endif
-
 
 /* stuff to run once login has been successful */
@@ -269,5 +214,14 @@
 void owl_aim_addbuddy(char *name)
 {
+
   aim_ssi_addbuddy(owl_global_get_aimsess(&g), name, "Buddies", NULL, NULL, NULL, 0);
+
+  /*
+  aim_ssi_addbuddy(owl_global_get_aimsess(&g),
+		   name,
+		   "Buddies",
+		   NULL, NULL, NULL,
+		   aim_ssi_waitingforauth(owl_global_get_aimsess(&g)->ssi.local, "Buddies", name));
+  */
 }
 
@@ -566,5 +520,5 @@
   aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */
 
-  /* aim_bos_setprofile(owl_global_get_aimsess(&g), fr->conn, NULL, NULL, 0, NULL, NULL, 0, AIM_CAPS_CHAT); */
+  /* aim_bos_setprofile(owl_global_get_aimsess(&g), fr->conn, NULL, NULL, 0, NULL, NULL, 0, AIM_CAPS_EMPTY); */
 
 #ifdef NOSSI
@@ -588,16 +542,16 @@
 
   if (!priv->screenname || !priv->password) {
-    /* printf("need SN and password\n"); */
+    owl_function_error("Internal error: aim login called without screenname or password");
     return(-1);
   }
 
   if (!(authconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, priv->server ? priv->server : FAIM_LOGIN_SERVER))) {
-    /* printf("internal connection error during login\n"); */
+    owl_function_error("Internal error: connection error during AIM login\n");
     return (-1);
   } else if (authconn->fd == -1) {
     if (authconn->status & AIM_CONN_STATUS_RESOLVERR) {
-      /* printf("could not resolve authorizer name\n");*/
+      owl_function_error("AIM: could not resolve authorize name");
     } else if (authconn->status & AIM_CONN_STATUS_CONNERR) {
-      /* printf("could not connect to authorizer\n"); */
+      owl_function_error("AIM: could not connect to authorizer");
     }
     aim_conn_kill(sess, &authconn);
@@ -612,6 +566,6 @@
   /* If the connection is in progress, this will just be queued */
   aim_request_login(sess, authconn, priv->screenname);
-
-  /* printf("login request sent\n"); */
+  owl_function_debugmsg("AIM login request sent for %s", priv->screenname);
+
   return(0);
 }
@@ -621,5 +575,5 @@
 {
   aim_clientready(sess, fr->conn);
-  /* printf("initialization done for admin connection\n"); */
+  owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection");
   return(1);
 }
@@ -629,6 +583,7 @@
   aim_session_kill(sess);
   owl_aim_init();
-  
-  /* kretch
+
+  owl_function_debugmsg("libfaim logout called");
+  /*
   if (faimtest_init() == -1)
     printf("faimtest_init failed\n");
@@ -770,4 +725,5 @@
   
   /* printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); */
+  owl_function_debugmsg("in faimtest_parse_buddyrights");
   
   /* aim_ssi_reqrights(sess, fr->conn); */
@@ -802,4 +758,6 @@
   maxsiglen = va_arg(ap, int);
   va_end(ap);
+
+  owl_function_debugmsg("in faimtest_parse_locrights");
 
   /* printf("locate rights: max signature length = %d\n", maxsiglen); */
