Index: ChangeLog
===================================================================
--- ChangeLog	(revision 210c261c49bad5412cd56575e989ce1e865777c0)
+++ ChangeLog	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -6,4 +6,5 @@
 	Cleaned up some warnings from linux gcc.
 	Fixed bug that can cause response stuff to crash
+	Idletimes now appear in the buddylisting
 	
 2.0.6
Index: aim.c
===================================================================
--- aim.c	(revision 6a87084c9530f873715f9304d5f7433249fbae6f)
+++ aim.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -157,4 +157,6 @@
   }
   owl_global_set_aimloggedin(&g, screenname);
+
+  owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
   return(0);
 }
@@ -220,4 +222,13 @@
 
 }
+
+void owl_aim_get_idle(char *screenname)
+{
+  aim_getinfo(owl_global_get_aimsess(&g),
+	      aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
+	      screenname,
+	      AIM_GETINFO_GENERALINFO);
+}
+
 
 void owl_aim_chat_join(char *chatroom)
@@ -977,5 +988,7 @@
   va_end(ap);
 
-  return (1);
+  /* right now the only reason we call this is for idle times */
+  owl_buddylist_set_idletime(owl_global_get_buddylist(&g), userinfo->sn, userinfo->idletime);
+  return(1);
 
   printf("userinfo: sn: %s\n", userinfo->sn);
Index: buddylist.c
===================================================================
--- buddylist.c	(revision ceb8cfbce9ff735337949dad9e42dcc800fccd6e)
+++ buddylist.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -6,4 +6,5 @@
 {
   owl_list_create(&(b->buddies));
+  owl_list_create(&(b->idletimes));
 }
 
@@ -16,4 +17,5 @@
   int i, j, found;
   owl_message *m;
+  int *zero;
 
   found=0;
@@ -27,6 +29,13 @@
 
   if (!found) {
+    /* add the buddy */
     owl_list_append_element(&(b->buddies), owl_strdup(screenname));
+    zero=owl_malloc(sizeof(int));
+    *zero=0;
+    owl_list_append_element(&(b->idletimes), zero);
 
+    /* do a request for idle time */
+    owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
+	
     /* are we ingoring login messages for a while? */
     if (!owl_timer_is_expired(owl_global_get_aim_login_timer(&g))) return;
@@ -40,4 +49,5 @@
 			   1);
     owl_global_messagequeue_addmsg(&g, m);
+
   }
 }
@@ -57,5 +67,7 @@
       found=1;
       owl_free(owl_list_get_element(&(b->buddies), i));
+      owl_free(owl_list_get_element(&(b->idletimes), i));
       owl_list_remove_element(&(b->buddies), i);
+      owl_list_remove_element(&(b->idletimes), i);
       break;
     }
@@ -75,4 +87,18 @@
 }
 
+/* send requests to the AIM server to retrieve info
+ * on all buddies.  The AIM callback then fills in the
+ * values when the responses are received
+ */
+void owl_buddylist_request_idletimes(owl_buddylist *b)
+{
+  int i, j;
+
+  j=owl_buddylist_get_size(b);
+  for (i=0; i<j; i++) {
+    owl_aim_get_idle(owl_buddylist_get_buddy(b, i));
+  }
+}
+
 /* return the number of logged in buddies */
 int owl_buddylist_get_size(owl_buddylist *b)
@@ -87,7 +113,37 @@
 }
 
+/* get the idle time for buddy number 'n' */
+int owl_buddylist_get_idletime(owl_buddylist *b, int n)
+{
+  int *foo;
+
+  foo=owl_list_get_element(&(b->idletimes), n);
+  return(*foo);
+}
+
+/* set the idle time for user 'screenname'.  If the given
+ * screenname is not on the buddy list do nothing
+ */
+void owl_buddylist_set_idletime(owl_buddylist *b, char *screenname, int seconds)
+{
+  int i, j, *idle;
+
+  j=owl_buddylist_get_size(b);
+  for (i=0; i<j; i++) {
+    if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
+      owl_free(owl_list_get_element(&(b->idletimes), i));
+      idle=owl_malloc(sizeof(int));
+      *idle=seconds;
+      owl_list_replace_element(&(b->idletimes), i, idle);
+      return;
+    }
+  }
+}
+
 /* remove all buddies from the list */
 void owl_buddylist_clear(owl_buddylist *b) {
   owl_list_free_all(&(b->buddies), owl_free);
+  owl_list_free_all(&(b->idletimes), owl_free);
   owl_list_create(&(b->buddies));
+  owl_list_create(&(b->idletimes));
 }
Index: functions.c
===================================================================
--- functions.c	(revision e6449bc3713fa8e0d1af7b15ef39089c748ae567)
+++ functions.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -2844,7 +2844,8 @@
 void owl_function_buddylist(int aim, int zephyr, char *file)
 {
-  int i, j;
+  int i, j, idle;
   owl_fmtext fm;
   owl_buddylist *b;
+  char *foo, *timestr;
 #ifdef HAVE_LIBZEPHYR
   char *ourfile, *tmp, buff[LINE], *line;
@@ -2862,7 +2863,16 @@
     j=owl_buddylist_get_size(b);
     for (i=0; i<j; i++) {
-      owl_fmtext_append_normal(&fm, "  ");
-      owl_fmtext_append_normal(&fm, owl_buddylist_get_buddy(b, i));
-      owl_fmtext_append_normal(&fm, "\n");
+      idle=owl_buddylist_get_idletime(b, i);
+      if (idle!=0) {
+	timestr=owl_util_seconds_to_timestr(idle);
+      } else {
+	timestr=owl_strdup("");
+      }
+      foo=owl_sprintf("  %-10.10s %-15.15s\n",
+		      owl_buddylist_get_buddy(b, i),
+		      timestr);
+      owl_fmtext_append_normal(&fm, foo);
+      owl_free(timestr);
+      owl_free(foo);
     }
   }
Index: global.c
===================================================================
--- global.c	(revision 210c261c49bad5412cd56575e989ce1e865777c0)
+++ global.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -95,4 +95,5 @@
   owl_timer_create_countdown(&(g->aim_noop_timer), 30);
   owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
+  owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);
   owl_buddylist_init(&(g->buddylist));
   g->response=NULL;
@@ -804,2 +805,7 @@
   return(0);
 }
+
+owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
+{
+  return(&(g->aim_buddyinfo_timer));
+}
Index: owl.c
===================================================================
--- owl.c	(revision e6449bc3713fa8e0d1af7b15ef39089c748ae567)
+++ owl.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -323,4 +323,9 @@
       owl_function_debugmsg("Doing aim processing");
       owl_aim_process_events();
+
+      if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
+	owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
+	owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
+      }
     }
 
Index: owl.h
===================================================================
--- owl.h	(revision e6449bc3713fa8e0d1af7b15ef39089c748ae567)
+++ owl.h	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -385,4 +385,5 @@
 typedef struct _owl_buddylist {
   owl_list buddies;
+  owl_list idletimes;
 } owl_buddylist;
 
@@ -444,4 +445,5 @@
   owl_timer aim_noop_timer;
   owl_timer aim_ignorelogin_timer;
+  owl_timer aim_buddyinfo_timer;
   int aim_loggedin;         /* true if currently logged into AIM */
   char *aim_screenname;     /* currently logged in AIM screen name */
Index: util.c
===================================================================
--- util.c	(revision e6449bc3713fa8e0d1af7b15ef39089c748ae567)
+++ util.c	(revision de0333491c0a25f06d19685b9e2e266e07b5187e)
@@ -278,4 +278,28 @@
 
   return(argv);
+}
+
+/* caller must free the return */
+char *owl_util_seconds_to_timestr(int seconds)
+{
+  int days, minutes, hours;
+  long run;
+  char *out;
+
+  run=seconds;
+
+  days=run/86400;
+  run-=days*86400;
+  hours=run/3600;
+  run-=hours*3600;
+  minutes=run/60;
+  run-=minutes*60;
+
+  if (days>0) {
+    out=owl_sprintf("%i d %2.2i:%2.2i:%2.2li", days, hours, minutes, run);
+  } else {
+    out=owl_sprintf("     %2.2i:%2.2i:%2.2li", hours, minutes, run);
+  }
+  return(out);
 }
 
