Changeset d09e5a1 for global.c


Ignore:
Timestamp:
May 31, 2003, 3:33:42 PM (18 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:
5e53c4a
Parents:
c86a35c
Message:
Added libfaim
Added basic AIM support, including the "aimlogin", "aimwrite" and
   "aimlogout" commands
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    recd5dc5 rd09e5a1  
    5151  owl_list_create(&(g->filterlist));
    5252  owl_list_create(&(g->puntlist));
     53  owl_list_create(&(g->messagequeue));
    5354  g->curmsg_vert_offset=0;
    5455  g->resizepending=0;
     
    8788  owl_mainwin_init(&(g->mw));
    8889  owl_popwin_init(&(g->pw));
     90
     91  g->aim_screenname=NULL;
     92  g->aim_loggedin=0;
     93  g->aim_lastnop=0;
    8994}
    9095
     
    637642  return(g->malloced-g->freed);
    638643}
     644
     645/* AIM stuff */
     646
     647int owl_global_is_aimloggedin(owl_global *g) {
     648  if (g->aim_loggedin) return(1);
     649  return(0);
     650}
     651
     652char *owl_global_get_aim_screenname(owl_global *g) {
     653  return (g->aim_screenname);
     654}
     655
     656void owl_global_set_aimloggedin(owl_global *g, char *screenname) {
     657  g->aim_loggedin=1;
     658  if (g->aim_screenname) owl_free(g->aim_screenname);
     659  g->aim_screenname=owl_strdup(screenname);
     660}
     661
     662void owl_global_set_aimnologgedin(owl_global *g) {
     663  g->aim_loggedin=0;
     664}
     665
     666aim_session_t *owl_global_get_aimsess(owl_global *g) {
     667  return(&(g->aimsess));
     668}
     669
     670aim_conn_t *owl_global_get_waitingconn(owl_global *g) {
     671  return(&(g->waitingconn));
     672}
     673
     674int owl_global_is_aimnop_time(owl_global *g) {
     675  time_t now;
     676
     677  now=time(NULL);
     678  if (g->aim_lastnop==0) {
     679    g->aim_lastnop=now;
     680    return(0);
     681  }
     682
     683  if (now-g->aim_lastnop >= 30) {
     684    return(1);
     685  }
     686  return(0);
     687}
     688
     689void owl_global_aimnop_sent(owl_global *g) {
     690  time_t now;
     691
     692  now=time(NULL);
     693  g->aim_lastnop=now;
     694}
     695
     696/* message queue */
     697
     698void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m) {
     699  owl_list_append_element(&(g->messagequeue), m);
     700}
     701
     702/* pop off the first message and return it.  Return NULL if the queue
     703 * is empty.  The caller should free the message after using it, if
     704 * necessary.
     705 */
     706owl_message *owl_global_messageuque_popmsg(owl_global *g) {
     707  owl_message *out;
     708
     709  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
     710  out=owl_list_get_element(&(g->messagequeue), 0);
     711  owl_list_remove_element(&(g->messagequeue), 0);
     712  return(out);
     713}
     714
     715int owl_global_messagequeue_pending(owl_global *g) {
     716  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
     717  return(1);
     718}
Note: See TracChangeset for help on using the changeset viewer.