Changes in / [5f3168a:680ed23]


Ignore:
Files:
1 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • Makefile.in

    r9c7a701 r5ff830a  
    2626     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    2727     aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \
    28      zbuddylist.c muxevents.c popexec.c obarray.c select.c wcwidth.c \
    29      glib_compat.c
     28     zbuddylist.c muxevents.c popexec.c obarray.c wcwidth.c glib_compat.c
    3029OWL_SRC = owl.c
    3130TESTER_SRC = tester.c
  • functions.c

    r6b580b0 raf1920fd  
    798798    owl_global_set_curmsg(&g, curmsg+1);
    799799  }
    800   /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */
     800  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    801801  owl_global_set_direction_downwards(&g);
    802802}
  • global.c

    r9c7a701 reebef19  
    117117
    118118  owl_message_init_fmtext_cache();
    119   owl_list_create(&(g->dispatchlist));
    120119}
    121120
     
    933932  return owl_obarray_insert(&(g->obarray), string);
    934933}
    935 
    936 owl_list *owl_global_get_dispatchlist(owl_global *g)
    937 {
    938   return &(g->dispatchlist);
    939 }
  • keys.c

    ra6a4155 rfac5463  
    4444  BIND_CMD("M-f",         "edit:move-next-word", "");
    4545  BIND_CMD("M-O 3 C",     "edit:move-next-word", "");
    46   BIND_CMD("M-LEFT",      "edit:move-next-word", "");
    4746  BIND_CMD("M-b",         "edit:move-prev-word", "");
    4847  BIND_CMD("M-O 3 D",     "edit:move-prev-word", "");
    49   BIND_CMD("M-RIGHT",     "edit:move-prev-word", "");
    5048
    5149  BIND_CMD("LEFT",        "edit:move-left", "");
  • owl.c

    r9c7a701 r6fe806a  
    4646#include <sys/param.h>
    4747#include <sys/types.h>
    48 #include <sys/time.h>
    4948#include <termios.h>
    5049#include <sys/stat.h>
     
    6261#endif
    6362
    64 #define STDIN 0
    65 
    6663static const char fileIdent[] = "$Id$";
    6764
     
    7471  owl_popwin *pw;
    7572  int ret, initialsubs, debug, argcsave, followlast;
     73  owl_input j;
    7674  int newmsgs, nexttimediff;
    7775  struct sigaction sigact;
     
    216214  owl_global_set_haveaim(&g);
    217215
    218   /* prepare stdin dispatch */
    219   {
    220     owl_dispatch *d = owl_malloc(sizeof(owl_dispatch));
    221     d->fd = STDIN;
    222     d->cfunc = &owl_process_input;
    223     d->pfunc = NULL;
    224     owl_select_add_dispatch(d);
    225   }
    226  
    227216#ifdef HAVE_LIBZEPHYR
    228217  /* zephyr init */
    229218  ret=owl_zephyr_initialize();
    230   if (!ret) {
    231     owl_dispatch *d = owl_malloc(sizeof(owl_dispatch));
    232     d->fd = ZGetFD();
    233     d->cfunc = &owl_zephyr_process_events;
    234     d->pfunc = NULL;
    235     owl_select_add_dispatch(d);
    236     owl_global_set_havezephyr(&g);
    237   }
    238 
     219  if (!ret)
     220      owl_global_set_havezephyr(&g);
    239221#endif
    240222
     
    451433    followlast=owl_global_should_followlast(&g);
    452434   
     435    /* Do AIM stuff */
     436    if (owl_global_is_doaimevents(&g)) {
     437      owl_aim_process_events();
     438
     439      if (owl_global_is_aimloggedin(&g)) {
     440        if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
     441          /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
     442          owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
     443        }
     444      }
     445    }
     446
    453447    owl_perlconfig_mainloop();
    454448
     
    468462    }
    469463
     464    owl_zephyr_process_events();
     465   
    470466    /* Grab incoming messages. */
    471467    newmsgs=0;
     
    539535    }
    540536
    541     /* select on FDs we know about. */
    542     owl_select();
     537    /* Handle all keypresses.  If no key has been pressed, sleep for a
     538     * little bit, but otherwise do not.  This lets input be grabbed
     539     * as quickly as possbile */
     540    j.ch = wgetch(typwin);
     541    if (j.ch == ERR) {
     542      usleep(10000);
     543    } else {
     544      j.uch = '\0';
     545      if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
     546        /* This is a curses control character. */
     547      }
     548      else if (j.ch > 0x7f && j.ch < 0xfe) {
     549        /* Pull in a full utf-8 character. */
     550        int bytes, i;
     551        char utf8buf[7];
     552        memset(utf8buf, '\0', 7);
     553
     554        utf8buf[0] = j.ch;
     555
     556        if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
     557        else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
     558        else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
     559        else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
     560        else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
     561        else bytes = 1;
     562       
     563        for (i = 1; i < bytes; i++) {
     564          int tmp =  wgetch(typwin);
     565          /* If what we got was not a byte, or not a continuation byte */
     566          if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
     567            /* ill-formed UTF-8 code unit subsequence, put back the
     568               char we just got. */
     569            ungetch(tmp);
     570            j.ch = ERR;
     571            break;
     572          }
     573          utf8buf[i] = tmp;
     574        }
     575       
     576        if (j.ch != ERR) {
     577          if (g_utf8_validate(utf8buf, -1, NULL)) {
     578            j.uch = g_utf8_get_char(utf8buf);
     579          }
     580          else {
     581            j.ch = ERR;
     582          }
     583        }
     584      }
     585      else if (j.ch <= 0x7f) {
     586        j.uch = j.ch;
     587      }
     588     
     589      owl_global_set_lastinputtime(&g, now);
     590      /* find and activate the current keymap.
     591       * TODO: this should really get fixed by activating
     592       * keymaps as we switch between windows...
     593       */
     594      if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
     595        owl_context_set_popless(owl_global_get_context(&g),
     596                                owl_global_get_viewwin(&g));
     597        owl_function_activate_keymap("popless");
     598      } else if (owl_global_is_typwin_active(&g)
     599                 && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
     600        /*
     601          owl_context_set_editline(owl_global_get_context(&g), tw);
     602          owl_function_activate_keymap("editline");
     603        */
     604      } else if (owl_global_is_typwin_active(&g)
     605                 && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
     606        owl_context_set_editmulti(owl_global_get_context(&g), tw);
     607        owl_function_activate_keymap("editmulti");
     608      } else {
     609        owl_context_set_recv(owl_global_get_context(&g));
     610        owl_function_activate_keymap("recv");
     611      }
     612      /* now actually handle the keypress */
     613      ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
     614      if (ret!=0 && ret!=1) {
     615        owl_function_makemsg("Unable to handle keypress");
     616      }
     617    }
    543618
    544619    /* Log any error signals */
     
    658733}
    659734
    660 void owl_process_aim()
    661 {
    662   if (owl_global_is_doaimevents(&g)) {
    663     owl_aim_process_events();
    664    
    665     if (owl_global_is_aimloggedin(&g)) {
    666       if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
    667         /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
    668         owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
    669       }
    670     }
    671   }
    672 }
    673 
    674 void owl_process_input()
    675 {
    676   int ret;
    677   owl_input j;
    678   owl_popwin *pw;
    679   owl_editwin *tw;
    680   WINDOW *typwin;
    681 
    682   typwin = owl_global_get_curs_typwin(&g);
    683   j.ch = wgetch(typwin);
    684   if (j.ch == ERR) return;
    685 
    686   owl_global_set_lastinputtime(&g, time(NULL));
    687   pw=owl_global_get_popwin(&g);
    688   tw=owl_global_get_typwin(&g);
    689 
    690   j.uch = '\0';
    691   if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
    692     /* This is a curses control character. */
    693   }
    694   else if (j.ch > 0x7f && j.ch < 0xfe) {
    695     /* Pull in a full utf-8 character. */
    696     int bytes, i;
    697     char utf8buf[7];
    698     memset(utf8buf, '\0', 7);
    699 
    700     utf8buf[0] = j.ch;
    701 
    702     if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
    703     else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
    704     else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
    705     else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
    706     else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
    707     else bytes = 1;
    708 
    709     for (i = 1; i < bytes; i++) {
    710       int tmp =  wgetch(typwin);
    711       /* If what we got was not a byte, or not a continuation byte */
    712       if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
    713         /* ill-formed UTF-8 code unit subsequence, put back the
    714            char we just got. */
    715         ungetch(tmp);
    716         j.ch = ERR;
    717         break;
    718       }
    719       utf8buf[i] = tmp;
    720     }
    721    
    722     if (j.ch != ERR) {
    723       if (g_utf8_validate(utf8buf, -1, NULL)) {
    724         j.uch = g_utf8_get_char(utf8buf);
    725       }
    726       else {
    727         j.ch = ERR;
    728       }
    729     }
    730   }
    731   else if (j.ch <= 0x7f) {
    732     j.uch = j.ch;
    733   }
    734      
    735   owl_global_set_lastinputtime(&g, time(NULL));
    736   /* find and activate the current keymap.
    737    * TODO: this should really get fixed by activating
    738    * keymaps as we switch between windows...
    739    */
    740   if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
    741     owl_context_set_popless(owl_global_get_context(&g),
    742                             owl_global_get_viewwin(&g));
    743     owl_function_activate_keymap("popless");
    744   } else if (owl_global_is_typwin_active(&g)
    745              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
    746     /*
    747       owl_context_set_editline(owl_global_get_context(&g), tw);
    748       owl_function_activate_keymap("editline");
    749     */
    750   } else if (owl_global_is_typwin_active(&g)
    751              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
    752     owl_context_set_editmulti(owl_global_get_context(&g), tw);
    753     owl_function_activate_keymap("editmulti");
    754   } else {
    755     owl_context_set_recv(owl_global_get_context(&g));
    756     owl_function_activate_keymap("recv");
    757   }
    758   /* now actually handle the keypress */
    759   ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    760   if (ret!=0 && ret!=1) {
    761     owl_function_makemsg("Unable to handle keypress");
    762   }
    763 }
    764 
    765735void sig_handler(int sig, siginfo_t *si, void *data)
    766736{
     
    777747    owl_function_quit();
    778748  }
     749
    779750}
    780751
  • owl.h

    r9c7a701 r6f6330b  
    561561  owl_list strings;
    562562} owl_obarray;
    563 
    564 typedef struct _owl_dispatch {
    565   int fd;           /* FD to watch for dispatch. */
    566   void (*cfunc)();  /* C function to dispatch to. */
    567   SV *pfunc;        /* Perl function to dispatch to. */
    568 } owl_dispatch;
    569563
    570564typedef struct _owl_global {
     
    638632  struct termios startup_tio;
    639633  owl_obarray obarray;
    640   owl_list dispatchlist;
    641634} owl_global;
    642635
  • perl/lib/BarnOwl/ModuleLoader.pm

    rb4fcc06 rb0c8011  
    2424                $modules{$1} = 1;
    2525            } elsif(-d "$dir/$f" && -d "$dir/$f/lib") {
    26                 unshift @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
     26                push @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
    2727                $modules{$f} = 1;
    2828            }
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r9c7a701 rcab045b  
    6969}
    7070
    71 #sub mainloop_hook {
    72 #    return unless defined $irc;
    73 #    eval {
    74 #        $irc->do_one_loop();
    75 #    };
    76 #    return;
    77 #}
    78 
    79 sub OwlProcess {
     71sub mainloop_hook {
    8072    return unless defined $irc;
    8173    eval {
     
    8476    return;
    8577}
    86 
    8778
    8879sub register_handlers {
     
    118109$BarnOwl::Hooks::startup->add(\&startup);
    119110$BarnOwl::Hooks::shutdown->add(\&shutdown);
    120 #$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);
     111$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);
    121112
    122113################################################################################
     
    174165        BarnOwl::admin_message("IRC", "Connected to $alias as $nick");
    175166        $ircnets{$alias} = $conn;
    176         my $fd = $conn->getSocket()->fileno();
    177         BarnOwl::add_dispatch($fd, \&OwlProcess);
    178         $conn->{FD} = $fd;
    179167    } else {
    180168        die("IRC::Connection->connect failed: $!");
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r9c7a701 r5ff830a  
    6969}
    7070
    71 sub getSocket
    72 {
    73     my $self = shift;
    74     return $self->conn->socket;
    75 }
    76 
    7771################################################################################
    7872############################### IRC callbacks ##################################
     
    174168    my $self = shift;
    175169    delete $BarnOwl::Module::IRC::ircnets{$self->alias};
    176     BarnOwl::remove_dispatch($self->{FD});
     170
    177171    BarnOwl::admin_message('IRC',
    178172                           "[" . $self->alias . "] Disconnected from server");
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r6b580b0 r879e7e94  
    118118            BarnOwl::error("Connection for $jid undefined -- error in reload?");
    119119        }
    120         # We keep this in the mainloop hook for keep-alives
     120
    121121        my $status = $client->Process(0);
    122122        if ( !defined($status) ) {
     
    126126        if ($::shutdown) {
    127127            do_logout($jid);
    128             next;
    129         }
    130 
     128            return;
     129        }
    131130        if ($vars{status_changed}) {
    132131            my $p = new Net::Jabber::Presence;
     
    390389                $conn->renameConnection($jidStr, $fullJid);
    391390                queue_admin_msg("Connected to jabber as $fullJid");
    392                 # The remove_dispatch() method is called from the
    393                 # ConnectionManager's removeConnection() method.
    394                 $client->{fileno} = $client->getSocket()->fileno();
    395                 #queue_admin_msg("Connected to jabber as $fullJid ($client->{fileno})");
    396                 BarnOwl::add_dispatch($client->{fileno}, sub { $client->OwlProcess() });
    397391            }
    398392        }
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r6b580b0 re0ffe77  
    111111
    112112
    113 =head2 getSID
    114 
    115 Returns the StreamID for this connection.
    116 
    117 =cut
    118 
    119 sub getStreamID {
    120     my $self = shift;
    121     return $self->{SESSION}->{id} || "";
    122 }
    123 
    124 =head2 getSocket
    125 
    126 Returns the IO::Socket for this connection.
    127 
    128 =cut
    129 
    130 sub getSocket {
    131     my $self = shift;
    132     my $sid = getStreamID($self);
    133     return $self->{STREAM}->GetSock($sid) || -1;
    134 }
    135 
    136 =head2 OwlProcess
    137 
    138 Non-blocking connection processing. For use in a select loop.
    139 
    140 =cut
    141 
    142 sub OwlProcess {
    143     my $self = shift;
    144     my $status = $self->Process(0);
    145     if ( !defined($status) ) {
    146         my $jid = $self->{SESSION}->{FULLJID};
    147         BarnOwl::error("Jabber account $jid disconnected!");
    148         BarnOwl::Module::Jabber::do_logout($jid);
    149     }
    150 }
    151 
    152113=head1 SEE ALSO
    153114
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm

    r6b580b0 r7f33c18  
    3737    return 0 unless exists $self->{$jidStr};
    3838
    39     BarnOwl::remove_dispatch($self->{$jidStr}->{Client}->{fileno}) if $self->{$jidStr}->{Client}->{fileno};
    4039    $self->{$jidStr}->{Client}->Disconnect()
    4140      if $self->{$jidStr}->{Client};
     
    5251    return 0 if $oldJidStr eq $newJidStr;
    5352
    54     $self->{$newJidStr} = $self->{$oldJidStr};
     53    $self->{$newJidStr} = $self->{$oldJidStr}; 
    5554    delete $self->{$oldJidStr};
    5655    return 1;
  • perlconfig.c

    r9c7a701 raf1920fd  
    487487}
    488488
    489 void owl_perlconfig_dispatch_free(owl_dispatch *d)
    490 {
    491   SvREFCNT_dec(d->pfunc);
    492 }
    493 
    494489void owl_perlconfig_edit_callback(owl_editwin *e)
    495490{
     
    538533  return;
    539534}
    540 
    541 void owl_perlconfig_do_dispatch(owl_dispatch *d)
    542 {
    543   SV *cb = d->pfunc;
    544   unsigned int n_a;
    545   dSP;
    546   if(cb == NULL) {
    547     owl_function_error("Perl callback is NULL!");
    548   }
    549 
    550   ENTER;
    551   SAVETMPS;
    552 
    553   PUSHMARK(SP);
    554   PUTBACK;
    555  
    556   call_sv(cb, G_DISCARD|G_KEEPERR|G_EVAL);
    557 
    558   if(SvTRUE(ERRSV)) {
    559     owl_function_error("%s", SvPV(ERRSV, n_a));
    560   }
    561 
    562   FREETMPS;
    563   LEAVE;
    564 }
  • perlglue.xs

    r9c7a701 r65fea01  
    342342                                      desc,
    343343                                      ival);
    344 
    345 void
    346 add_dispatch(fd, cb)
    347         int fd
    348         SV * cb
    349         CODE:
    350         SvREFCNT_inc(cb);
    351         owl_select_add_perl_dispatch(fd, cb);
    352 
    353 void
    354 remove_dispatch(fd)
    355         int fd
    356         CODE:
    357         owl_select_remove_perl_dispatch(fd);
  • zephyr.c

    r9c7a701 r247cbc9  
    2929  return(0);
    3030}
     31
    3132
    3233int owl_zephyr_shutdown()
Note: See TracChangeset for help on using the changeset viewer.