Changeset de03334 for buddylist.c


Ignore:
Timestamp:
Jul 3, 2003, 9:31:03 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.