Changeset a352335c


Ignore:
Timestamp:
Jul 5, 2003, 7:38:16 AM (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:
6873455
Parents:
c045455
Message:
Fixed bug in buddy idle time stuff
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rc045455 ra352335c  
    11$Id$
    22
    3 2.0.7-pre-2
    4         Don't allow zwrite if zephyr isn't present
     32.0.7
     4        Idletimes now appear in the buddylisting
     5        Failed AIM logins are now correctly reported
     6        Owl will build now without zephyr, enabling it to act as a
     7          standalone AIM client.
    58        There is now a zcrypt command
    69        Replies to zcrypted messages now work
    7         Failed AIM logins are now correctly reported
    8        
    9 2.0.7-pre-1
    10         Owl should build now without zephyr, enabling it to act as a
    11           standalone AIM client.
     10        Don't allow zwrite if zephyr isn't present
    1211        Cleaned up some warnings from linux gcc.
    1312        Fixed bug that can cause response stuff to crash
    14         Idletimes now appear in the buddylisting
     13        Improved status command
     14        Fixed bug in buddy stuff
    1515       
    16162.0.6
  • aim.c

    rc045455 ra352335c  
    147147  priv->server = "login.oscar.aol.com";
    148148  owl_global_get_aimsess(&g)->aux_data = priv;
    149 
    150149 
    151150  /* login */
     
    153152  if (ret) {
    154153    owl_global_set_aimnologgedin(&g);
    155     /* printf("login returned %i\n"); */
     154    owl_global_set_no_doaimevents(&g);
    156155    return(-1);
    157156  }
     157  owl_global_set_doaimevents(&g);
     158  return(0);
     159}
     160
     161/* stuff to run once login has been successful */
     162void owl_aim_successful_login(char *screenname)
     163{
    158164  owl_global_set_aimloggedin(&g, screenname);
    159 
    160   return(0);
     165  owl_global_set_doaimevents(&g); /* this should already be on */
     166  owl_function_makemsg("%s logged in", screenname);
     167
     168  owl_function_debugmsg("Successful AIM login for %s", screenname);
     169
     170  /* start the ingorelogin timer */
     171  owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g),
     172                           owl_global_get_aim_ignorelogin_timer(&g));
     173
    161174}
    162175
     
    166179  logout(owl_global_get_aimsess(&g));
    167180  owl_global_set_aimnologgedin(&g);
    168 }
    169 
    170 void owl_aim_login_error(void)
    171 {
    172   owl_function_makemsg("Authentication error on login");
     181  owl_global_set_no_doaimevents(&g);
     182}
     183
     184void owl_aim_login_error(char *message)
     185{
     186  if (message) {
     187    owl_function_makemsg(message);
     188  } else {
     189    owl_function_makemsg("Authentication error on login");
     190  }
    173191  owl_function_beep();
    174192  owl_global_set_aimnologgedin(&g);
     193  owl_global_set_no_doaimevents(&g);
    175194}
    176195
     
    365384
    366385  /* printf("Screen name: %s\n", info->sn); */
     386  owl_function_debugmsg("Here with %s", info->sn);
    367387
    368388  /*
     
    374394    printf("Error URL: %s\n", info->errorurl);
    375395    */
    376     owl_aim_login_error();
    377     /* aim_conn_kill(sess, &fr->conn); */
     396    if (info->errorcode==0x05) {
     397      /* Incorrect nick/password */
     398      owl_aim_login_error("Incorrect nickname or password.");
     399    } else if (info->errorcode==0x11) {
     400      /* Suspended account */
     401      owl_aim_login_error("Your account is currently suspended.");
     402    } else if (info->errorcode==0x14) {
     403      /* service temporarily unavailable */
     404      owl_aim_login_error("The AOL Instant Messenger service is temporarily unavailable.");
     405    } else if (info->errorcode==0x18) {
     406      /* connecting too frequently */
     407      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.");
     408    } else if (info->errorcode==0x1c) {
     409      /* client too old */
     410      owl_aim_login_error("The client version you are using is too old.");
     411    } else {
     412      owl_aim_login_error(NULL);
     413    }
     414    aim_conn_kill(sess, &fr->conn);
    378415    return 1;
    379416  }
     
    395432    return 1;
    396433  }
     434  owl_aim_successful_login(info->sn);
    397435  addcb_bos(sess, bosconn);
    398436  aim_sendcookie(sess, bosconn, info->cookie);
    399   owl_function_makemsg("%s logged in", info->sn);
    400437  return 1;
    401438}
     
    424461int faimtest_conncomplete(aim_session_t *sess, aim_frame_t *fr, ...)
    425462{
     463  /* owl_aim_successful_login(info->sn); */
     464
    426465  return 1;
    427466}
  • buddylist.c

    r5b85d19 ra352335c  
    1010
    1111/* Deal with an "oncoming" message.  This means recognizing the user
    12  * has logged in, and sending a message if they were not already
     12 * has logged in, and displaying a message if they were not already
    1313 * logged in.
    1414 */
    1515void owl_buddylist_oncoming(owl_buddylist *b, char *screenname)
    1616{
    17   int i, j, found;
     17  int *zero;
    1818  owl_message *m;
    19   int *zero;
    2019
    21   found=0;
    22   j=owl_list_get_size(&(b->buddies));
    23   for (i=0; i<j; i++) {
    24     if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
    25       found=1;
    26       break;
    27     }
    28   }
     20  if (!owl_buddylist_is_buddy_loggedin(b, screenname)) {
    2921
    30   if (!found) {
    3122    /* add the buddy */
    3223    owl_list_append_element(&(b->buddies), owl_strdup(screenname));
     
    3627
    3728    /* do a request for idle time */
    38     owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));
     29    owl_buddylist_request_idletime(b, screenname);
    3930       
    4031    /* are we ingoring login messages for a while? */
    4132    if (!owl_timer_is_expired(owl_global_get_aim_login_timer(&g))) return;
    4233
     34    /* if not, create the login message */
    4335    m=owl_malloc(sizeof(owl_message));
    4436    owl_message_create_aim(m,
     
    4941                           1);
    5042    owl_global_messagequeue_addmsg(&g, m);
    51 
    5243  }
    5344}
     
    5849void owl_buddylist_offgoing(owl_buddylist *b, char *screenname)
    5950{
    60   int i, j, found;
     51  int index;
    6152  owl_message *m;
    6253
    63   found=0;
    64   j=owl_list_get_size(&(b->buddies));
    65   for (i=0; i<j; i++) {
    66     if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
    67       found=1;
    68       owl_free(owl_list_get_element(&(b->buddies), i));
    69       owl_free(owl_list_get_element(&(b->idletimes), i));
    70       owl_list_remove_element(&(b->buddies), i);
    71       owl_list_remove_element(&(b->idletimes), i);
    72       break;
    73     }
    74   }
     54  index=owl_buddylist_get_buddy_index(b, screenname);
     55  if (index==-1) return;
    7556
    76   if (found) {
    77     m=owl_malloc(sizeof(owl_message));
    78     owl_message_create_aim(m,
    79                            screenname,
    80                            owl_global_get_aim_screenname(&g),
    81                            "",
    82                            OWL_MESSAGE_DIRECTION_IN,
    83                            -1);
     57  owl_free(owl_list_get_element(&(b->buddies), index));
     58  owl_free(owl_list_get_element(&(b->idletimes), index));
     59  owl_list_remove_element(&(b->buddies), index);
     60  owl_list_remove_element(&(b->idletimes), index);
    8461
    85     owl_global_messagequeue_addmsg(&g, m);
    86   }
     62  m=owl_malloc(sizeof(owl_message));
     63  owl_message_create_aim(m,
     64                         screenname,
     65                         owl_global_get_aim_screenname(&g),
     66                         "",
     67                         OWL_MESSAGE_DIRECTION_IN,
     68                         -1);
     69  owl_global_messagequeue_addmsg(&g, m);
    8770}
    8871
     
    10184}
    10285
     86/* send request to the AIM server to retrieve info on one buddy.  The
     87 * AIM callback then fills in the values when the responses are
     88 * received.  The buddy must be logged in or no request will be
     89 * performed.
     90 */
     91void owl_buddylist_request_idletime(owl_buddylist *b, char *screenname)
     92{
     93  if (!owl_buddylist_is_buddy_loggedin(b, screenname)) return;
     94  owl_aim_get_idle(screenname);
     95}
     96
    10397/* return the number of logged in buddies */
    10498int owl_buddylist_get_size(owl_buddylist *b)
     
    110104char *owl_buddylist_get_buddy(owl_buddylist *b, int n)
    111105{
     106  if (n > owl_buddylist_get_size(b)-1) return("");
    112107  return(owl_list_get_element(&(b->buddies), n));
     108}
     109
     110/* Return the index of the buddy 'screename' or -1
     111 * if the buddy is not logged in.
     112 */
     113int owl_buddylist_get_buddy_index(owl_buddylist *b, char *screenname)
     114{
     115  int i, j;
     116 
     117  j=owl_list_get_size(&(b->buddies));
     118  for (i=0; i<j; i++) {
     119    if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) {
     120      return(i);
     121    }
     122  }
     123  return(-1);
     124}
     125
     126/* return 1 if the buddy 'screenname' is logged in,
     127 * otherwise return 0
     128 */
     129int owl_buddylist_is_buddy_loggedin(owl_buddylist *b, char *screenname)
     130{
     131  if (owl_buddylist_get_buddy_index(b, screenname)!=-1) return(1);
     132  return(0);
    113133}
    114134
     
    127147void owl_buddylist_set_idletime(owl_buddylist *b, char *screenname, int minutes)
    128148{
    129   int i, j, *idle;
     149  int index, *idle;
    130150
    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=minutes;
    137       owl_list_replace_element(&(b->idletimes), i, idle);
    138       return;
    139     }
    140   }
     151  index=owl_buddylist_get_buddy_index(b, screenname);
     152  if (index==-1) return;
     153
     154  owl_free(owl_list_get_element(&(b->idletimes), index));
     155  idle=owl_malloc(sizeof(int));
     156  *idle=minutes;
     157  owl_list_replace_element(&(b->idletimes), index, idle);
    141158}
    142159
  • commands.c

    rc045455 ra352335c  
    21302130  /* try to login */
    21312131  ret=owl_aim_login(argv[1], argv[2]);
    2132   if (!ret) {
    2133     /* start the ingorelogin timer */
    2134     owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g),
    2135                              owl_global_get_aim_ignorelogin_timer(&g));
    2136    
    2137     return(NULL);
    2138   }
    2139  
    2140   owl_function_makemsg("Warning: login for %s failed.\n");
     2132  if (ret) owl_function_makemsg("Warning: login for %s failed.\n");
     2133
     2134  /* this is a test */
    21412135  return(NULL);
    21422136}
  • functions.c

    r3ba3af0 ra352335c  
    16841684  time_t start;
    16851685  int up, days, hours, minutes;
     1686  owl_fmtext fm;
     1687
     1688  owl_fmtext_init_null(&fm);
    16861689
    16871690  start=owl_global_get_starttime(&g);
    16881691
    1689   sprintf(buff, "Version: %s\n", OWL_VERSION_STRING);
    1690   sprintf(buff, "%sScreen size: %i lines, %i columns\n", buff, owl_global_get_lines(&g), owl_global_get_cols(&g));
    1691   sprintf(buff, "%sStartup Arugments: %s\n", buff, owl_global_get_startupargs(&g));
    1692   sprintf(buff, "%sStartup Time: %s", buff, ctime(&start));
     1692  owl_fmtext_append_normal(&fm, "Version: ");
     1693  owl_fmtext_append_normal(&fm, OWL_VERSION_STRING);
     1694  owl_fmtext_append_normal(&fm, "\n");
     1695
     1696  sprintf(buff, "Screen size: %i lines, %i columns\n", owl_global_get_lines(&g), owl_global_get_cols(&g));
     1697  owl_fmtext_append_normal(&fm, buff);
     1698
     1699  owl_fmtext_append_normal(&fm, "Startup Arugments: ");
     1700  owl_fmtext_append_normal(&fm, owl_global_get_startupargs(&g));
     1701  owl_fmtext_append_normal(&fm, "\n");
     1702  sprintf(buff, "Startup Time: %s", ctime(&start));
     1703  owl_fmtext_append_normal(&fm, buff);
     1704 
    16931705
    16941706  up=owl_global_get_runtime(&g);
     
    16991711  minutes=up/60;
    17001712  up-=minutes*60;
    1701   sprintf(buff, "%sRun Time: %i days %2.2i:%2.2i:%2.2i\n", buff, days, hours, minutes, up);
     1713  sprintf(buff, "Run Time: %i days %2.2i:%2.2i:%2.2i\n", days, hours, minutes, up);
     1714  owl_fmtext_append_normal(&fm, buff);
    17021715
    17031716  if (owl_global_get_hascolors(&g)) {
    1704     sprintf(buff, "%sColor: Yes, %i color pairs.\n", buff, owl_global_get_colorpairs(&g));
     1717    sprintf(buff, "Color: Yes, %i color pairs.\n", owl_global_get_colorpairs(&g));
    17051718  } else {
    1706     strcat(buff, "Color: No.\n");
    1707   }
    1708 
     1719    sprintf(buff, "Color: No.\n");
     1720  }
     1721  owl_fmtext_append_normal(&fm, buff);
     1722
     1723  /*
    17091724  sprintf(buff, "%sMemory Malloced: %i\n", buff, owl_global_get_malloced(&g));
    17101725  sprintf(buff, "%sMemory Freed: %i\n", buff, owl_global_get_freed(&g));
    17111726  sprintf(buff, "%sMemory In Use: %i\n", buff, owl_global_get_meminuse(&g));
    1712 
    1713   owl_function_popless_text(buff);
     1727  */
     1728
     1729  owl_fmtext_append_normal(&fm, "\n");
     1730  if (owl_global_is_aimloggedin(&g)) {
     1731    owl_fmtext_append_normal(&fm, "AIM: logged in as ");
     1732    owl_fmtext_append_normal(&fm, owl_global_get_aim_screenname(&g));
     1733    owl_fmtext_append_normal(&fm, "\n");
     1734  } else {
     1735    owl_fmtext_append_normal(&fm, "AIM: not logged in\n");
     1736  }
     1737  if (owl_global_is_doaimevents(&g)) {
     1738    owl_fmtext_append_normal(&fm, "AIM: processing events\n ");
     1739  } else {
     1740    owl_fmtext_append_normal(&fm, "AIM: not processing events\n ");
     1741  }
     1742
     1743  owl_function_popless_fmtext(&fm);
     1744  owl_fmtext_free(&fm);
    17141745}
    17151746
  • global.c

    rde03334 ra352335c  
    100100  g->havezephyr=0;
    101101  g->haveaim=0;
     102  owl_global_set_no_doaimevents(g);
    102103}
    103104
     
    674675char *owl_global_get_aim_screenname(owl_global *g)
    675676{
    676   return (g->aim_screenname);
     677  if (owl_global_is_aimloggedin(g)) {
     678    return (g->aim_screenname);
     679  }
     680  return("");
    677681}
    678682
     
    688692  g->aim_loggedin=0;
    689693}
     694
     695int owl_global_is_doaimevents(owl_global *g)
     696{
     697  if (g->aim_doprocessing) return(1);
     698  return(0);
     699}
     700
     701void owl_global_set_doaimevents(owl_global *g)
     702{
     703  g->aim_doprocessing=1;
     704}
     705
     706void owl_global_set_no_doaimevents(owl_global *g)
     707{
     708  g->aim_doprocessing=0;
     709}
     710
    690711
    691712aim_session_t *owl_global_get_aimsess(owl_global *g)
  • owl.c

    rde03334 ra352335c  
    319319    followlast=owl_global_should_followlast(&g);
    320320   
    321     /* If we're logged into AIM, do AIM stuff */
    322     if (owl_global_is_aimloggedin(&g)) {
    323       owl_function_debugmsg("Doing aim processing");
     321    /* Do AIM stuff */
     322    if (owl_global_is_doaimevents(&g)) {
    324323      owl_aim_process_events();
    325324
    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));
     325      if (owl_global_is_aimloggedin(&g)) {
     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        }
    329330      }
    330331    }
  • owl.h

    r5b85d19 ra352335c  
    2121static const char owl_h_fileIdent[] = "$Id$";
    2222
    23 #define OWL_VERSION         2.0.7-pre-2
    24 #define OWL_VERSION_STRING "2.0.7-pre-2"
     23#define OWL_VERSION         2.0.7
     24#define OWL_VERSION_STRING "2.0.7"
    2525
    2626#define OWL_DEBUG 0
     
    447447  owl_timer aim_buddyinfo_timer;
    448448  int aim_loggedin;         /* true if currently logged into AIM */
     449  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
    449450  char *aim_screenname;     /* currently logged in AIM screen name */
    450451  owl_buddylist buddylist;  /* list of logged in AIM buddies */
Note: See TracChangeset for help on using the changeset viewer.