Changeset 9c7a701 for owl.c


Ignore:
Timestamp:
Feb 15, 2008, 12:56:49 AM (17 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
18a54ee
Parents:
a6a4155
Message:
Initial select() changes.
stdin, zephyr, jabber, and irc are checked and have dispatch functions.
aim is hacked in -- not entirely pretty, but documented and isolated.
We still want timers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    reebef19 r9c7a701  
    4646#include <sys/param.h>
    4747#include <sys/types.h>
     48#include <sys/time.h>
    4849#include <termios.h>
    4950#include <sys/stat.h>
     
    6061#endif
    6162
     63#define STDIN 0
     64
    6265static const char fileIdent[] = "$Id$";
    6366
     
    6972  owl_editwin *tw;
    7073  owl_popwin *pw;
    71   int j, ret, initialsubs, debug, argcsave, followlast;
     74  int ret, initialsubs, debug, argcsave, followlast;
    7275  int newmsgs, nexttimediff;
    7376  struct sigaction sigact;
     
    206209  owl_global_set_haveaim(&g);
    207210
     211  /* prepare stdin dispatch */
     212  {
     213    owl_dispatch *d = owl_malloc(sizeof(owl_dispatch));
     214    d->fd = STDIN;
     215    d->cfunc = &owl_process_input;
     216    d->pfunc = NULL;
     217    owl_select_add_dispatch(d);
     218  }
     219 
    208220#ifdef HAVE_LIBZEPHYR
    209221  /* zephyr init */
    210222  ret=owl_zephyr_initialize();
    211   if (!ret)
    212       owl_global_set_havezephyr(&g);
     223  if (!ret) {
     224    owl_dispatch *d = owl_malloc(sizeof(owl_dispatch));
     225    d->fd = ZGetFD();
     226    d->cfunc = &owl_zephyr_process_events;
     227    d->pfunc = NULL;
     228    owl_select_add_dispatch(d);
     229    owl_global_set_havezephyr(&g);
     230  }
     231
    213232#endif
    214233
     
    425444    followlast=owl_global_should_followlast(&g);
    426445   
    427     /* Do AIM stuff */
    428     if (owl_global_is_doaimevents(&g)) {
    429       owl_aim_process_events();
    430 
    431       if (owl_global_is_aimloggedin(&g)) {
    432         if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
    433           /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
    434           owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
    435         }
    436       }
    437     }
    438 
    439446    owl_perlconfig_mainloop();
    440447
     
    454461    }
    455462
    456     owl_zephyr_process_events();
    457    
    458463    /* Grab incoming messages. */
    459464    newmsgs=0;
     
    530535     * little bit, but otherwise do not.  This lets input be grabbed
    531536     * as quickly as possbile */
    532     j=wgetch(typwin);
    533     if (j==ERR) {
    534       usleep(10000);
    535     } else {
    536       owl_global_set_lastinputtime(&g, now);
    537       /* find and activate the current keymap.
    538        * TODO: this should really get fixed by activating
    539        * keymaps as we switch between windows...
    540        */
    541       if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
    542         owl_context_set_popless(owl_global_get_context(&g),
    543                                 owl_global_get_viewwin(&g));
    544         owl_function_activate_keymap("popless");
    545       } else if (owl_global_is_typwin_active(&g)
    546                  && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
    547         /*
    548           owl_context_set_editline(owl_global_get_context(&g), tw);
    549           owl_function_activate_keymap("editline");
    550         */
    551       } else if (owl_global_is_typwin_active(&g)
    552                  && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
    553         owl_context_set_editmulti(owl_global_get_context(&g), tw);
    554         owl_function_activate_keymap("editmulti");
    555       } else {
    556         owl_context_set_recv(owl_global_get_context(&g));
    557         owl_function_activate_keymap("recv");
    558       }
    559       /* now actually handle the keypress */
    560       ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    561       if (ret!=0 && ret!=1) {
    562         owl_function_makemsg("Unable to handle keypress");
    563       }
    564     }
     537
     538    /* select on FDs we know about. */
     539    owl_select();
    565540
    566541    /* Log any error signals */
     
    680655}
    681656
     657void owl_process_aim()
     658{
     659  if (owl_global_is_doaimevents(&g)) {
     660    owl_aim_process_events();
     661   
     662    if (owl_global_is_aimloggedin(&g)) {
     663      if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
     664        /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
     665        owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
     666      }
     667    }
     668  }
     669}
     670
     671void owl_process_input()
     672{
     673  int ret, j;
     674  owl_popwin *pw;
     675  owl_editwin *tw;
     676
     677  j = wgetch(owl_global_get_curs_typwin(&g));
     678  if (j == ERR) return;
     679
     680  owl_global_set_lastinputtime(&g, time(NULL));
     681  pw=owl_global_get_popwin(&g);
     682  tw=owl_global_get_typwin(&g);
     683
     684  /* find and activate the current keymap.
     685   * TODO: this should really get fixed by activating
     686   * keymaps as we switch between windows...
     687   */
     688  if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
     689    owl_context_set_popless(owl_global_get_context(&g),
     690                            owl_global_get_viewwin(&g));
     691    owl_function_activate_keymap("popless");
     692  } else if (owl_global_is_typwin_active(&g)
     693             && owl_editwin_get_style(tw) == OWL_EDITWIN_STYLE_ONELINE) {
     694    /*
     695      owl_context_set_editline(owl_global_get_context(&g), tw);
     696      owl_function_activate_keymap("editline");
     697    */
     698  } else if (owl_global_is_typwin_active(&g)
     699             && owl_editwin_get_style(tw) == OWL_EDITWIN_STYLE_MULTILINE) {
     700    owl_context_set_editmulti(owl_global_get_context(&g), tw);
     701    owl_function_activate_keymap("editmulti");
     702  } else {
     703    owl_context_set_recv(owl_global_get_context(&g));
     704    owl_function_activate_keymap("recv");
     705  }
     706  /* now actually handle the keypress */
     707  ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
     708  if (ret != 0 && ret != 1) {
     709    owl_function_makemsg("Unable to handle keypress");
     710  }
     711}
     712
    682713void sig_handler(int sig, siginfo_t *si, void *data)
    683714{
     
    694725    owl_function_quit();
    695726  }
    696 
    697727}
    698728
Note: See TracChangeset for help on using the changeset viewer.