Changeset de03334


Ignore:
Timestamp:
Jul 3, 2003, 9:31:03 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:
5b85d19
Parents:
210c261
Message:
Idletimes now appear in the buddylist
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r210c261 rde03334  
    66        Cleaned up some warnings from linux gcc.
    77        Fixed bug that can cause response stuff to crash
     8        Idletimes now appear in the buddylisting
    89       
    9102.0.6
  • aim.c

    r6a87084 rde03334  
    157157  }
    158158  owl_global_set_aimloggedin(&g, screenname);
     159
     160  owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
    159161  return(0);
    160162}
     
    220222
    221223}
     224
     225void owl_aim_get_idle(char *screenname)
     226{
     227  aim_getinfo(owl_global_get_aimsess(&g),
     228              aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS),
     229              screenname,
     230              AIM_GETINFO_GENERALINFO);
     231}
     232
    222233
    223234void owl_aim_chat_join(char *chatroom)
     
    977988  va_end(ap);
    978989
    979   return (1);
     990  /* right now the only reason we call this is for idle times */
     991  owl_buddylist_set_idletime(owl_global_get_buddylist(&g), userinfo->sn, userinfo->idletime);
     992  return(1);
    980993
    981994  printf("userinfo: sn: %s\n", userinfo->sn);
  • buddylist.c

    rceb8cfb rde03334  
    66{
    77  owl_list_create(&(b->buddies));
     8  owl_list_create(&(b->idletimes));
    89}
    910
     
    1617  int i, j, found;
    1718  owl_message *m;
     19  int *zero;
    1820
    1921  found=0;
     
    2729
    2830  if (!found) {
     31    /* add the buddy */
    2932    owl_list_append_element(&(b->buddies), owl_strdup(screenname));
     33    zero=owl_malloc(sizeof(int));
     34    *zero=0;
     35    owl_list_append_element(&(b->idletimes), zero);
    3036
     37    /* do a request for idle time */
     38    owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
     39       
    3140    /* are we ingoring login messages for a while? */
    3241    if (!owl_timer_is_expired(owl_global_get_aim_login_timer(&g))) return;
     
    4049                           1);
    4150    owl_global_messagequeue_addmsg(&g, m);
     51
    4252  }
    4353}
     
    5767      found=1;
    5868      owl_free(owl_list_get_element(&(b->buddies), i));
     69      owl_free(owl_list_get_element(&(b->idletimes), i));
    5970      owl_list_remove_element(&(b->buddies), i);
     71      owl_list_remove_element(&(b->idletimes), i);
    6072      break;
    6173    }
     
    7587}
    7688
     89/* send requests to the AIM server to retrieve info
     90 * on all buddies.  The AIM callback then fills in the
     91 * values when the responses are received
     92 */
     93void owl_buddylist_request_idletimes(owl_buddylist *b)
     94{
     95  int i, j;
     96
     97  j=owl_buddylist_get_size(b);
     98  for (i=0; i<j; i++) {
     99    owl_aim_get_idle(owl_buddylist_get_buddy(b, i));
     100  }
     101}
     102
    77103/* return the number of logged in buddies */
    78104int owl_buddylist_get_size(owl_buddylist *b)
     
    87113}
    88114
     115/* get the idle time for buddy number 'n' */
     116int owl_buddylist_get_idletime(owl_buddylist *b, int n)
     117{
     118  int *foo;
     119
     120  foo=owl_list_get_element(&(b->idletimes), n);
     121  return(*foo);
     122}
     123
     124/* set the idle time for user 'screenname'.  If the given
     125 * screenname is not on the buddy list do nothing
     126 */
     127void owl_buddylist_set_idletime(owl_buddylist *b, char *screenname, int seconds)
     128{
     129  int i, j, *idle;
     130
     131  j=owl_buddylist_get_size(b);
     132  for (i=0; i<j; i++) {
     133    if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
     134      owl_free(owl_list_get_element(&(b->idletimes), i));
     135      idle=owl_malloc(sizeof(int));
     136      *idle=seconds;
     137      owl_list_replace_element(&(b->idletimes), i, idle);
     138      return;
     139    }
     140  }
     141}
     142
    89143/* remove all buddies from the list */
    90144void owl_buddylist_clear(owl_buddylist *b) {
    91145  owl_list_free_all(&(b->buddies), owl_free);
     146  owl_list_free_all(&(b->idletimes), owl_free);
    92147  owl_list_create(&(b->buddies));
     148  owl_list_create(&(b->idletimes));
    93149}
  • functions.c

    re6449bc rde03334  
    28442844void owl_function_buddylist(int aim, int zephyr, char *file)
    28452845{
    2846   int i, j;
     2846  int i, j, idle;
    28472847  owl_fmtext fm;
    28482848  owl_buddylist *b;
     2849  char *foo, *timestr;
    28492850#ifdef HAVE_LIBZEPHYR
    28502851  char *ourfile, *tmp, buff[LINE], *line;
     
    28622863    j=owl_buddylist_get_size(b);
    28632864    for (i=0; i<j; i++) {
    2864       owl_fmtext_append_normal(&fm, "  ");
    2865       owl_fmtext_append_normal(&fm, owl_buddylist_get_buddy(b, i));
    2866       owl_fmtext_append_normal(&fm, "\n");
     2865      idle=owl_buddylist_get_idletime(b, i);
     2866      if (idle!=0) {
     2867        timestr=owl_util_seconds_to_timestr(idle);
     2868      } else {
     2869        timestr=owl_strdup("");
     2870      }
     2871      foo=owl_sprintf("  %-10.10s %-15.15s\n",
     2872                      owl_buddylist_get_buddy(b, i),
     2873                      timestr);
     2874      owl_fmtext_append_normal(&fm, foo);
     2875      owl_free(timestr);
     2876      owl_free(foo);
    28672877    }
    28682878  }
  • global.c

    r210c261 rde03334  
    9595  owl_timer_create_countdown(&(g->aim_noop_timer), 30);
    9696  owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
     97  owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);
    9798  owl_buddylist_init(&(g->buddylist));
    9899  g->response=NULL;
     
    804805  return(0);
    805806}
     807
     808owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
     809{
     810  return(&(g->aim_buddyinfo_timer));
     811}
  • owl.c

    re6449bc rde03334  
    323323      owl_function_debugmsg("Doing aim processing");
    324324      owl_aim_process_events();
     325
     326      if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
     327        owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
     328        owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
     329      }
    325330    }
    326331
  • owl.h

    re6449bc rde03334  
    385385typedef struct _owl_buddylist {
    386386  owl_list buddies;
     387  owl_list idletimes;
    387388} owl_buddylist;
    388389
     
    444445  owl_timer aim_noop_timer;
    445446  owl_timer aim_ignorelogin_timer;
     447  owl_timer aim_buddyinfo_timer;
    446448  int aim_loggedin;         /* true if currently logged into AIM */
    447449  char *aim_screenname;     /* currently logged in AIM screen name */
  • util.c

    re6449bc rde03334  
    278278
    279279  return(argv);
     280}
     281
     282/* caller must free the return */
     283char *owl_util_seconds_to_timestr(int seconds)
     284{
     285  int days, minutes, hours;
     286  long run;
     287  char *out;
     288
     289  run=seconds;
     290
     291  days=run/86400;
     292  run-=days*86400;
     293  hours=run/3600;
     294  run-=hours*3600;
     295  minutes=run/60;
     296  run-=minutes*60;
     297
     298  if (days>0) {
     299    out=owl_sprintf("%i d %2.2i:%2.2i:%2.2li", days, hours, minutes, run);
     300  } else {
     301    out=owl_sprintf("     %2.2i:%2.2i:%2.2li", hours, minutes, run);
     302  }
     303  return(out);
    280304}
    281305
Note: See TracChangeset for help on using the changeset viewer.