Index: ChangeLog
===================================================================
--- ChangeLog	(revision db2dd3d7ef308a3ef1bbf34331fb91a26178e0e4)
+++ ChangeLog	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -4,4 +4,6 @@
 	Updated basic help
 	Display CC: in outgoing CC messages
+	More AIM logout detection
+	Don't proclaim "interfaces changed" on first build.
 	
 2.0.10
Index: Makefile.in
===================================================================
--- Makefile.in	(revision ec6ff526f80f4544b68f01e84ccd88c783e54326)
+++ Makefile.in	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -69,5 +69,5 @@
 	perl codelist.pl > owl_prototypes.h.new
 	@cmp -s owl_prototypes.h.new $@ || { \
-	 echo 'Interfaces changed!'; \
+	 test -f $@ && echo 'Interfaces changed!'; \
 	 echo mv -f owl_prototypes.h.new $@; \
 	      mv -f owl_prototypes.h.new $@; }
Index: aim.c
===================================================================
--- aim.c	(revision a836200bd06580bd1af73b18e4e365e6ea92db2e)
+++ aim.c	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -149,5 +149,6 @@
 
 #if 0
-static void oscar_login(GaimAccount *account) {
+static void oscar_login(GaimAccount *account)
+{
   aim_session_t *sess;
   aim_conn_t *conn;
@@ -207,4 +208,5 @@
 void owl_aim_successful_login(char *screenname)
 {
+  owl_function_debugmsg("doing owl_aim_successful_login");
   owl_global_set_aimloggedin(&g, screenname);
   owl_global_set_doaimevents(&g); /* this should already be on */
@@ -218,4 +220,5 @@
 
   /* aim_bos_setidle(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), 5000); */
+  /* aim_bos_setprofile(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), NULL, NULL, 0, NULL, NULL, 0, AIM_CAPS_CHAT); */
 }
 
@@ -281,6 +284,20 @@
 }
 
-void owl_aim_chat_join(char *chatroom)
-{
+void owl_aim_chat_join(char *chatroom, int exchange)
+{
+  int ret;
+
+  /* ret=aim_chat_join(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), exchange, chatroom, 0x0000); */
+  /*
+  ret=aim_chat_join(owl_global_get_aimsess(&g),
+		    aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV), exchange, chatroom, 0x0000);
+  */
+
+  aim_reqservice(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), AIM_CONN_TYPE_CHATNAV);
+  ret = aim_chatnav_createroom(owl_global_get_aimsess(&g),
+			       aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV), chatroom, exchange);
+   ret=aim_chat_join(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), exchange, chatroom, 0x0000);
+  
+  owl_function_debugmsg("Attempting to join chatroom %s exchange %i", chatroom, exchange);
 }
 
@@ -295,5 +312,6 @@
 
 /* caller must free the return */
-char *owl_aim_normalize_screenname(char *in) {
+char *owl_aim_normalize_screenname(char *in)
+{
   char *out;
   int i, j, k;
@@ -312,5 +330,6 @@
 }
 
-int owl_aim_process_events() {
+int owl_aim_process_events()
+{
   aim_session_t *aimsess;
   aim_conn_t *waitingconn = NULL;
@@ -334,5 +353,5 @@
   if (selstat == -1) {
     owl_aim_logged_out();
-  } else if (selstat == 0) {
+  } else if (selstat == 0) { 
     /* no events pending */
   } else if (selstat == 1) { /* outgoing data pending */
@@ -350,12 +369,14 @@
 	  /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */
 	  aim_conn_kill(aimsess, &waitingconn);
+	  owl_aim_logged_out();
 	}
       } else {
 	aim_conn_kill(aimsess, &waitingconn);
+	owl_aim_logged_out();
       }
       if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) {
 	/* printf("major connection error\n"); */
+	owl_aim_logged_out();
 	/* break; */
-	/* we should probably kill the session */
       }
     }
@@ -383,7 +404,9 @@
   va_end(ap);
 
+  owl_function_debugmsg("doing faimtest_parse_login");
+
   aim_send_login(sess, fr->conn, priv->screenname, priv->password, &info, key);
   
-  return 1;
+  return(1);
 }
 
@@ -400,4 +423,5 @@
 
   /* printf("Screen name: %s\n", info->sn); */
+  owl_function_debugmsg("doing faimtest_parse_authresp");
   owl_function_debugmsg("faimtest_parse_authresp: %s", info->sn);
 
@@ -411,17 +435,12 @@
     */
     if (info->errorcode==0x05) {
-      /* Incorrect nick/password */
       owl_aim_login_error("Incorrect nickname or password.");
     } else if (info->errorcode==0x11) {
-      /* Suspended account */
       owl_aim_login_error("Your account is currently suspended.");
     } else if (info->errorcode==0x14) {
-      /* service temporarily unavailable */
       owl_aim_login_error("The AOL Instant Messenger service is temporarily unavailable.");
     } else if (info->errorcode==0x18) {
-      /* connecting too frequently */
       owl_aim_login_error("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.");
     } else if (info->errorcode==0x1c) {
-      /* client too old */
       owl_aim_login_error("The client version you are using is too old.");
     } else {
@@ -429,5 +448,5 @@
     }
     aim_conn_kill(sess, &fr->conn);
-    return 1;
+    return(1);
   }
 
@@ -442,9 +461,9 @@
   if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, info->bosip))) {
     /* printf("could not connect to BOS: internal error\n"); */
-    return 1;
+    return(1);
   } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) {
     /* printf("could not connect to BOS\n"); */
     aim_conn_kill(sess, &bosconn);
-    return 1;
+    return(1);
   }
   owl_global_set_bossconn(&g, bosconn);
@@ -452,9 +471,11 @@
   addcb_bos(sess, bosconn);
   aim_sendcookie(sess, bosconn, info->cookielen, info->cookie);
-  return 1;
+  return(1);
 }
 
 int faimtest_flapversion(aim_session_t *sess, aim_frame_t *fr, ...)
 {
+  owl_function_debugmsg("doing faimtest_flapversion");
+
 #if 0
   /* XXX fix libfaim to support this */
@@ -478,6 +499,6 @@
 int faimtest_conncomplete(aim_session_t *sess, aim_frame_t *fr, ...)
 {
+  owl_function_debugmsg("doing faimtest_conncomplete");
   /* owl_aim_successful_login(info->sn); */
-
   return 1;
 }
@@ -485,5 +506,5 @@
 void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn)
 {
-
+  owl_function_debugmsg("doing addcb_bos");
   aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
   aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0);
@@ -523,19 +544,14 @@
   aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, offlinemsgdone, 0);
 
-  #ifdef MID_REWROTE_ALL_THE_CRAP
-  aim_conn_addhandler(sess, bosconn, 0xffff,         0xffff,                        faimtest_parse_unknown, 0);
-  #endif
-
   return;
 }
 
-
-static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...)
+{
+  owl_function_debugmsg("doing coninitdone_bos");
   aim_reqpersonalinfo(sess, fr->conn);
 
-  #ifndef NOSSI
   aim_ssi_reqrights(sess);
   aim_ssi_reqdata(sess);
-  #endif
 
   aim_bos_reqlocaterights(sess, fr->conn);
@@ -544,10 +560,14 @@
   aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */
 
-  #ifdef NOSSI
+  aim_bos_setprofile(owl_global_get_aimsess(&g), fr->conn, NULL, NULL, 0, NULL, NULL, 0, AIM_CAPS_CHAT);
+
+#ifdef NOSSI
+  /*
   aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS);
   aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
-  #endif
-
-  return 1;
+  */
+#endif
+
+  return(1);
 }
 
@@ -763,5 +783,5 @@
   /* printf("BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); */
   aim_clientready(sess, fr->conn);
-  /* printf("officially connected to BOS.\n"); */
+  owl_function_debugmsg("officially connected to BOS.");
   aim_icq_reqofflinemsgs(sess);
   return 1;
@@ -776,8 +796,8 @@
   maxsiglen = va_arg(ap, int);
   va_end(ap);
-  
+
   /* printf("locate rights: max signature length = %d\n", maxsiglen); */
   
-  return 1;
+  return(1);
 }
 
@@ -1048,4 +1068,5 @@
   return(1);
 
+  /*
   printf("userinfo: sn: %s\n", userinfo->sn);
   printf("userinfo: warnlevel: %f\n", aim_userinfo_warnlevel(userinfo));
@@ -1053,4 +1074,5 @@
   printuserflags(userinfo->flags);
   printf("\n");
+  */
 
   /*
@@ -1062,16 +1084,16 @@
   
   if (inforeq == AIM_GETINFO_GENERALINFO) {
-    printf("userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
-    printf("userinfo: prof: %s\n", prof ? prof : "[none]");
+    owl_function_debugmsg("userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
+    owl_function_debugmsg("userinfo: prof: %s\n", prof ? prof : "[none]");
   } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) {
-    printf("userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
-    printf("userinfo: awaymsg: %s\n", prof ? prof : "[none]");
+    owl_function_debugmsg("userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
+    owl_function_debugmsg("userinfo: awaymsg: %s\n", prof ? prof : "[none]");
   } else if (inforeq == AIM_GETINFO_CAPABILITIES) {
-    printf("userinfo: capabilities: see above\n");
+    owl_function_debugmsg("userinfo: capabilities: see above\n");
   } else {
-    printf("userinfo: unknown info request\n");
-  }
-  
-  return 1;
+    owl_function_debugmsg("userinfo: unknown info request\n");
+  }
+  
+  return(1);
 }
 
@@ -1435,5 +1457,5 @@
   }
   
-  return 1;
+  return(1);
 }
 
@@ -1461,4 +1483,5 @@
     /* printf("send file!\n"); */
   } else if (args->reqclass == AIM_CAPS_CHAT) {
+    owl_function_debugmsg("chat invite: %s, %i, %i", args->info.chat.roominfo.name, args->info.chat.roominfo.exchange, args->info.chat.roominfo.instance);
     /*
     printf("chat invitation: room name = %s\n", args->info.chat.roominfo.name);
@@ -1538,4 +1561,9 @@
     owl_buddy_set_idle_since(b, userinfo->idletime);
   }
+
+  if (userinfo->flags & AIM_FLAG_AWAY) {
+    owl_function_debugmsg("parse_oncoming sn: %s away flag!", userinfo->sn);
+  }
+  
   owl_function_debugmsg("parse_oncoming sn: %s idle: %i", userinfo->sn, userinfo->idletime);
     
@@ -1871,10 +1899,9 @@
 static int ssirights(aim_session_t *sess, aim_frame_t *fr, ...)
 {
-  
   /* printf("got SSI rights, requesting data\n"); */
   /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */
   aim_ssi_reqdata(sess);
   
-  return 1;
+  return(1);
 }
 
@@ -1956,4 +1983,5 @@
   va_end(ap);
 
+  owl_function_debugmsg("In faimtest_chat_join");
   /*
   printf("chat: %s:  New occupants have joined:\n", aim_chat_getname(fr->conn));
@@ -2015,4 +2043,5 @@
   va_end(ap);
 
+  owl_function_debugmsg("In faimtest_chat_infoupdate");
   /*
   printf("chat: %s:  info update:\n", croomname);
@@ -2025,5 +2054,5 @@
     printf("chat: %s:  \t\t%s\n", croomname, userinfo[i].sn);
   
-  printf("chat: %s:  \tRoom flags: 0x%04x (%s%s%s%s)\n", 
+  owl_function_debugmsg("chat: %s:  \tRoom flags: 0x%04x (%s%s%s%s)\n", 
 	 croomname, flags,
 	 (flags & AIM_CHATROOM_FLAG_EVILABLE) ? "Evilable, " : "",
@@ -2038,5 +2067,5 @@
   */
   
-  return 1;
+  return(1);
 }
 
@@ -2052,4 +2081,6 @@
   msg = va_arg(ap, char *);
   va_end(ap);
+
+  owl_function_debugmsg("in faimtest_chat_incomingmsg");
 
   /*
@@ -2075,4 +2106,6 @@
   va_start(ap, fr);
   type = (fu16_t)va_arg(ap, unsigned int);
+
+  owl_function_debugmsg("in faimtest_chatnav_info");
   
   if (type == 0x0002) {
@@ -2136,4 +2169,6 @@
 {
 
+  owl_function_debugmsg("in faimtest_conninitdone_chat");
+  
   aim_clientready(sess, fr->conn);
   
@@ -2145,4 +2180,5 @@
   } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) {
     /* printf("chat ready\n"); */
+    owl_function_debugmsg("Chat ready");
     aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, faimtest_parse_genericerr, 0);
     aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
@@ -2157,4 +2193,6 @@
 {
   aim_conn_t *tstconn;
+
+  owl_function_debugmsg("in faimtest_chatnav_redirect");
   
   tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, redir->ip);
@@ -2177,4 +2215,6 @@
 {
   aim_conn_t *tstconn;
+
+  owl_function_debugmsg("in chat_redirect");
   
   tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, redir->ip);
Index: commands.c
===================================================================
--- commands.c	(revision 15283bb262a596e38cf9c59b498670211458c33d)
+++ commands.c	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -245,4 +245,11 @@
 	      "such as zephyr, will also be able to use this command.  For now the\n"
 	      "only available protocol is 'aim', specified as the first argument.\n"),
+
+#if 0
+  OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE,
+	      "join a chat group",
+	      "join aim <groupname> [exchange]",
+	      "Join the AIM chatroom with 'groupname'.\n"),
+#endif
 
   OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
@@ -992,8 +999,4 @@
       return(NULL);
     }
-    /*
-    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
-    return(NULL);
-    */
     owl_aim_delbuddy(argv[2]);
     owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
@@ -1005,5 +1008,28 @@
   }
 
-
+  return(NULL);
+}
+
+char *owl_command_join(int argc, char **argv, char *buff)
+{
+  if (argc!=3 && argc!=4) {
+    owl_function_makemsg("usage: join <protocol> <buddyname> [exchange]");
+    return(NULL);
+  }
+
+  if (!strcasecmp(argv[1], "aim")) {
+    if (!owl_global_is_aimloggedin(&g)) {
+      owl_function_makemsg("join aim: You must be logged into aim to use this command.");
+      return(NULL);
+    }
+    if (argc==3) {
+      owl_aim_chat_join(argv[2], 4);
+    } else {
+      owl_aim_chat_join(argv[2], atoi(argv[3]));
+    }
+    /* owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g)); */
+  } else {
+    owl_function_makemsg("join: currently the only supported protocol is 'aim'");
+  }
   return(NULL);
 }
Index: functions.c
===================================================================
--- functions.c	(revision f17bff98f482cb9dd71819bc8605f37e318b10f8)
+++ functions.c	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -748,4 +748,5 @@
 {
   owl_global_set_zaway_on(&g);
+  owl_aim_set_awaymsg(owl_global_get_zaway_msg(&g));
   owl_function_makemsg("zaway set (%s)", owl_global_get_zaway_msg(&g));
 }
Index: owl.c
===================================================================
--- owl.c	(revision 1077753bcdc0e2d541cc8b1fa5cc6591cdc9273d)
+++ owl.c	(revision 8c9284854a3fc6c3ac6cd959706f5674878cd849)
@@ -156,5 +156,4 @@
 #endif   
 
-  
   /* create the owl directory, in case it does not exist */
   dir=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_CONFIG_DIR);
