Changes in / [4779b8c:484b14d]


Ignore:
Files:
13 added
3 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r6b7e7a5 r03285f5  
    11*.a
     2*.o
     3*.par
     4*~
     5META.yml
     6Makefile
     7TAGS
     8aclocal.m4
    29autom4te.cache
    310barnowl
     
    512config.cache
    613config.h
     14config.h.in
    715config.log
    816config.status
     
    1018core
    1119jabber.log
    12 Makefile
    13 META.yml
    14 *.o
    1520owl_prototypes.h
    1621owl_prototypes.h.new
    17 *.par
    1822perlglue.c
    1923perlwrap.c
    2024pm_to_blib
    21 TAGS
    2225tester
    2326varstubs.c
  • COPYING

    r17e2357 r23e1110  
    1 Copyright (c) 2006-2008 The BarnOwl Developers. All rights reserved.
     1Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.
    22Copyright (c) 2004 James Kretchmar. All rights reserved.
    33
  • ChangeLog

    reef5b52 r879e90dc  
     11.1
     2 * Support building with -fstack-protector. -hartmans
     3 * Don't save partial passwords in editwin history. -nelhage
     4 * Improve IRC documentation. -nelhage
     5 * Don't use the 'zsender' variable for personals. -geofft
     6 * Implement irc-quote and irc-mode. -nelhage
     7 * Leave a one-column margin when wordwrapping. -nelhage
     8 * Remove some autotools-generated files. -andersk
     9 * Include IRC in the default build. -nelhage
     10 * Add a wordwrapping variant of the default style. -nelhage
     11 * Don't send stderr to admin messages. -nelhage
     12 * Remove a build-dependency on krb4. -hartmans
     13 * Allow the creation of type zephyr messages from perl. -geofft
     14 * Initialize Zephyr asynchronously at startup. -nelhage
     15
    1161.0.5
    217 * Implement initial support for real timers. -nelhage
  • Makefile.in

    rdf7f364 rf200413  
    3333
    3434EXE = barnowl
    35 PERL_MODULES = Jabber IRC
     35PERL_MODULES = Jabber IRC WordWrap
    3636MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%)
    3737
     
    7979modules_clean:
    8080        for i in $(MODULE_DIRS); do \
    81                 cd $$i; test ! -f Makefile || make clean; \
     81                (cd $$i && (test ! -f Makefile || make clean)) \
    8282        done
    8383
  • commands.c

    rf34dd65 r6e400cc  
    26502650  owl_function_makemsg("Command cancelled.");
    26512651
    2652   hist=owl_editwin_get_history(e);
    2653   owl_history_store(hist, owl_editwin_get_text(e));
    2654   owl_history_reset(hist);
     2652  if(e->echochar == 0) {
     2653    hist=owl_editwin_get_history(e);
     2654    owl_history_store(hist, owl_editwin_get_text(e));
     2655    owl_history_reset(hist);
     2656  }
    26552657
    26562658  owl_editwin_fullclear(e);
  • configure.ac

    r17acafb r17acafb  
    1111     CFLAGS="$CFLAGS -Wall -g";
    1212fi
    13 
    14 m4_include(/usr/share/aclocal/pkg.m4)
    15 dnl m4_include(pkg.m4)
    1613
    1714dnl Check for Athena
  • functions.c

    rb4c270c r45cf49f  
    127127  text=""
    128128    "barnowl version " OWL_VERSION_STRING "\n"
    129     "Copyright (c) 2006-2008 The BarnOwl Developers. All rights reserved.\n"
     129    "Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.\n"
    130130    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
    131131    "\n"
     
    921921  if (!owl_context_is_interactive(owl_global_get_context(&g))) return;
    922922  if (ret==0) {
    923     owl_function_makemsg("Subscribed to login messages from file.");
    924923  } else if (ret==-1) {
    925924    owl_function_error("Could not open file for login subscriptions.");
     
    13981397    "because we feel our owls should live closer to our ponies.\n"
    13991398    "\n"
    1400     "Copyright (c) 2006-2008 The BarnOwl Developers. All rights reserved.\n"
     1399    "Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.\n"
    14011400    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
    14021401    "Copyright 2002 Massachusetts Institute of Technology\n"
     
    32893288void owl_function_source(char *filename)
    32903289{
     3290  char *path;
    32913291  FILE *file;
    32923292  char buff[LINE];
     
    32953295  if (!filename) {
    32963296    fail_silent = 1;
    3297     filename=owl_global_get_startupfile(&g);
    3298   }
    3299   file=fopen(filename, "r");
     3297    path = owl_strdup(owl_global_get_startupfile(&g));
     3298  } else {
     3299    path = owl_util_makepath(filename);
     3300  }
     3301  file=fopen(path, "r");
     3302  owl_free(path);
    33003303  if (!file) {
    33013304    if (!fail_silent) {
     
    33493352{
    33503353  va_list ap;
    3351   char *buff, *buff2;
     3354  char *buff;
    33523355  char *nl;
    3353   char *date;
    3354   time_t now;
    3355 
    3356   now=time(NULL);
    3357   date=owl_strdup(ctime(&now));
    3358   date[strlen(date)-1]='\0';
    33593356
    33603357  va_start(ap, fmt);
    33613358
    33623359  buff = g_strdup_vprintf(fmt, ap);
    3363   buff2 = owl_sprintf("%s %s", date, buff);
    33643360  owl_function_debugmsg("ERROR: %s", buff);
    33653361  nl = strchr(buff, '\n');
     
    33703366    owl_function_makemsg("[Error] %s", buff);
    33713367  }
    3372   owl_errqueue_append_err(owl_global_get_errqueue(&g), buff2);
     3368  owl_function_log_err(buff);
    33733369  va_end(ap);
     3370  owl_free(buff);
     3371}
     3372
     3373void owl_function_log_err(char *string)
     3374{
     3375  char *date;
     3376  time_t now;
     3377  char *buff;
     3378
     3379  now=time(NULL);
     3380  date=owl_strdup(ctime(&now));
     3381  date[strlen(date)-1]='\0';
     3382
     3383  buff = owl_sprintf("%s %s", date, string);
     3384
     3385  owl_errqueue_append_err(owl_global_get_errqueue(&g), buff);
     3386
     3387  owl_free(buff);
    33743388  owl_free(date);
    3375   owl_free(buff);
    3376   owl_free(buff2);
    33773389}
    33783390
  • owl.c

    r28fa23c r5283b01  
    1 /*  Copyright (c) 2006-2008 The BarnOwl Developers. All rights reserved.
     1/*  Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.
    22 *  Copyright (c) 2004 James Kretchmar. All rights reserved.
    33 *
     
    4343  owl_editwin *tw;
    4444  owl_popwin *pw;
    45   int ret, initialsubs, debug, argcsave, followlast;
     45  int debug, argcsave, followlast;
    4646  int newmsgs, nexttimediff;
    4747  struct sigaction sigact;
     
    6565  tty=NULL;
    6666  debug=0;
    67   initialsubs=1;
     67  g.load_initial_subs = 1;
    6868
    6969  setlocale(LC_ALL, "");
     
    7575  while (argc>0) {
    7676    if (!strcmp(argv[0], "-n")) {
    77       initialsubs=0;
     77      g.load_initial_subs = 0;
    7878      argv++;
    7979      argc--;
     
    191191    owl_select_add_dispatch(d);
    192192  }
    193  
    194 #ifdef HAVE_LIBZEPHYR
    195   /* zephyr init */
    196   ret=owl_zephyr_initialize();
    197   if (!ret) {
    198     owl_dispatch *d = owl_malloc(sizeof(owl_dispatch));
    199     d->fd = ZGetFD();
    200     d->cfunc = &owl_zephyr_process_events;
    201     d->destroy = NULL;
    202     owl_select_add_dispatch(d);
    203     owl_global_set_havezephyr(&g);
    204   }
    205 
    206 #endif
     193
     194  owl_zephyr_initialize();
    207195
    208196#if OWL_STDERR_REDIR
     
    339327
    340328  wrefresh(sepwin);
    341 
    342   /* load zephyr subs */
    343   if (initialsubs) {
    344     int ret2;
    345     owl_function_debugmsg("startup: loading initial zephyr subs");
    346 
    347     /* load default subscriptions */
    348     ret=owl_zephyr_loaddefaultsubs();
    349    
    350     /* load subscriptions from subs file */
    351     ret2=owl_zephyr_loadsubs(NULL, 0);
    352 
    353     if (ret || ret2) {
    354       owl_function_adminmsg("", "Error loading zephyr subscriptions");
    355     } else if (ret2!=-1) {
    356       owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
    357     }
    358 
    359     /* load login subscriptions */
    360     if (owl_global_is_loginsubs(&g)) {
    361       owl_function_debugmsg("startup: loading login subs");
    362       owl_function_loadloginsubs(NULL);
    363     }
    364   }
    365329
    366330  /* First buddy check to sync the list without notifications */
     
    753717  char buf[4096];
    754718  int rfd = d->fd;
     719  char *err;
     720
    755721  if (rfd<0) return;
    756722  if (-1 == ioctl(rfd, FIONREAD, (void*)&navail)) {
     
    766732    buf[navail] = '\0';
    767733  }
    768   owl_function_error("[stderr]\n%s", buf);
     734
     735  err = owl_sprintf("[stderr]\n%s", buf);
     736
     737  owl_function_log_err(err);
    769738}
    770739
  • owl.h

    reef5b52 r879e90dc  
    1 /*  Copyright (c) 2006-2008 The BarnOwl Developers. All rights reserved.
     1/*  Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.
    22 *  Copyright (c) 2004 James Kretchmar. All rights reserved.
    33 *
     
    5252
    5353#ifndef OWL_VERSION_STRING
    54 #define OWL_VERSION_STRING "1.0.5"
     54#define OWL_VERSION_STRING "1.1"
    5555#endif
    5656
     
    594594  GList *timerlist;
    595595  owl_timer *aim_nop_timer;
     596  int load_initial_subs;
    596597} owl_global;
    597598
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r56d0189 re0fba58  
    6969}
    7070
     71sub quickstart {
     72    return <<'END_QUICKSTART';
     73@b[IRC:]
     74Use ':irc-connect @b[server]' to connect to an IRC server, and
     75':irc-join @b[#channel]' to join a channel. ':irc-msg @b[#channel]
     76@b[message]' sends a message to a channel.
     77END_QUICKSTART
     78}
     79
    7180#sub mainloop_hook {
    7281#    return unless defined $irc;
     
    93102}
    94103
     104use constant OPTIONAL_CHANNEL => 1;
     105use constant REQUIRE_CHANNEL => 2;
     106
    95107sub register_commands {
    96     BarnOwl::new_command('irc-connect' => \&cmd_connect,
    97                        {
    98                            summary      => 'Connect to an IRC server',
    99                            usage        => 'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
    100                            description  =>
    101 
    102                            "Connect to an IRC server. Supported options are\n\n" .
    103                            "-a <alias>          Define an alias for this server\n" .
    104                            "-s                  Use SSL\n" .
    105                            "-p <password>       Specify the password to use\n" .
    106                            "-n <nick>           Use a non-default nick"
    107                        });
    108     BarnOwl::new_command('irc-disconnect' => \&cmd_disconnect);
    109     BarnOwl::new_command('irc-msg'        => \&cmd_msg);
    110     BarnOwl::new_command('irc-join'       => \&cmd_join);
    111     BarnOwl::new_command('irc-part'       => \&cmd_part);
    112     BarnOwl::new_command('irc-nick'       => \&cmd_nick);
    113     BarnOwl::new_command('irc-names'      => \&cmd_names);
    114     BarnOwl::new_command('irc-whois'      => \&cmd_whois);
    115     BarnOwl::new_command('irc-motd'       => \&cmd_motd);
    116     BarnOwl::new_command('irc-list'       => \&cmd_list);
    117     BarnOwl::new_command('irc-who'        => \&cmd_who);
    118     BarnOwl::new_command('irc-stats'      => \&cmd_stats);
    119     BarnOwl::new_command('irc-topic'      => \&cmd_topic);
    120 }
     108    BarnOwl::new_command(
     109        'irc-connect' => \&cmd_connect,
     110        {
     111            summary => 'Connect to an IRC server',
     112            usage =>
     113'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
     114            description =>
     115
     116              <<END_DESCR
     117Connect to an IRC server. Supported options are
     118
     119 -a <alias>          Define an alias for this server
     120 -s                  Use SSL
     121 -p <password>       Specify the password to use
     122 -n <nick>           Use a non-default nick
     123
     124The -a option specifies an alias to use for this connection. This
     125alias can be passed to the '-a' argument of any other IRC command to
     126control which connection it operates on.
     127
     128For servers with hostnames of the form "irc.FOO.{com,org,...}", the
     129alias will default to "FOO"; For other servers the full hostname is
     130used.
     131END_DESCR
     132        }
     133    );
     134
     135    BarnOwl::new_command(
     136        'irc-disconnect' => mk_irc_command( \&cmd_disconnect ),
     137        {
     138            summary => 'Disconnect from an IRC server',
     139            usage   => 'irc-disconnect [-a ALIAS]',
     140
     141            description => <<END_DESCR
     142Disconnect from an IRC server. You can specify a specific server with
     143"-a SERVER-ALIAS" if necessary.
     144END_DESCR
     145        }
     146    );
     147
     148    BarnOwl::new_command(
     149        'irc-msg' => mk_irc_command( \&cmd_msg ),
     150        {
     151            summary => 'Send an IRC message',
     152            usage   => 'irc-msg [-a ALIAS] DESTINATION MESSAGE',
     153
     154            description => <<END_DESCR
     155Send an IRC message
     156END_DESCR
     157        }
     158    );
     159
     160    BarnOwl::new_command(
     161        'irc-mode' => mk_irc_command( \&cmd_mode, OPTIONAL_CHANNEL ),
     162        {
     163            summary => 'Change an IRC channel or user mode',
     164            usage   => 'irc-mode [-a ALIAS] TARGET [+-]MODE OPTIONS',
     165
     166            description => <<END_DESCR
     167
     168Change the mode of an IRC user or channel.
     169END_DESCR
     170        }
     171    );
     172
     173    BarnOwl::new_command(
     174        'irc-join' => mk_irc_command( \&cmd_join ),
     175        {
     176            summary => 'Join an IRC channel',
     177            usage   => 'irc-join [-a ALIAS] #channel',
     178
     179            description => <<END_DESCR
     180
     181Join an IRC channel.
     182END_DESCR
     183        }
     184    );
     185
     186    BarnOwl::new_command(
     187        'irc-part' => mk_irc_command( \&cmd_part, REQUIRE_CHANNEL ),
     188        {
     189            summary => 'Leave an IRC channel',
     190            usage   => 'irc-part [-a ALIAS] #channel',
     191
     192            description => <<END_DESCR
     193
     194Part from an IRC channel.
     195END_DESCR
     196        }
     197    );
     198
     199    BarnOwl::new_command(
     200        'irc-nick' => mk_irc_command( \&cmd_nick ),
     201        {
     202            summary => 'Change your IRC nick on an existing connection.',
     203            usage   => 'irc-nick [-a ALIAS] NEW-NICK',
     204
     205            description => <<END_DESCR
     206
     207Set your IRC nickname on an existing connect. To change it prior to
     208connecting, adjust the `irc:nick' variable.
     209END_DESCR
     210        }
     211    );
     212
     213    BarnOwl::new_command(
     214        'irc-names' => mk_irc_command( \&cmd_names, REQUIRE_CHANNEL ),
     215        {
     216            summary => 'View the list of users in a channel',
     217            usage   => 'irc-names [-a ALIAS] #channel',
     218
     219            description => <<END_DESCR
     220
     221`irc-names' displays the list of users in a given channel in a pop-up
     222window.
     223END_DESCR
     224        }
     225    );
     226
     227    BarnOwl::new_command(
     228        'irc-whois' => mk_irc_command( \&cmd_whois ),
     229        {
     230            summary => 'Displays information about a given IRC user',
     231            usage   => 'irc-whois [-a ALIAS] NICK',
     232
     233            description => <<END_DESCR
     234
     235Pops up information about a given IRC user.
     236END_DESCR
     237        }
     238    );
     239
     240    BarnOwl::new_command(
     241        'irc-motd' => mk_irc_command( \&cmd_motd ),
     242        {
     243            summary => 'Displays an IRC server\'s MOTD (Message of the Day)',
     244            usage   => 'irc-motd [-a ALIAS]',
     245
     246            description => <<END_DESCR
     247
     248Displays an IRC server's message of the day.
     249END_DESCR
     250        }
     251    );
     252
     253    BarnOwl::new_command(
     254        'irc-list' => \&cmd_list,
     255        {
     256            summary => 'Show all the active IRC connections.',
     257            usage   => 'irc-list',
     258
     259            description => <<END_DESCR
     260
     261Show all the currently active IRC connections with their aliases and
     262server names.
     263END_DESCR
     264        }
     265    );
     266
     267    BarnOwl::new_command( 'irc-who'   => mk_irc_command( \&cmd_who ) );
     268    BarnOwl::new_command( 'irc-stats' => mk_irc_command( \&cmd_stats ) );
     269
     270    BarnOwl::new_command(
     271        'irc-topic' => mk_irc_command( \&cmd_topic, REQUIRE_CHANNEL ),
     272        {
     273            summary => 'View or change the topic of an IRC channel',
     274            usage   => 'irc-topic [-a ALIAS] #channel [TOPIC]',
     275
     276            description => <<END_DESCR
     277
     278Without extra arguments, fetches and displays a given channel's topic.
     279
     280With extra arguments, changes the target channel's topic string. This
     281may require +o on some channels.
     282END_DESCR
     283        }
     284    );
     285
     286    BarnOwl::new_command(
     287        'irc-quote' => mk_irc_command( \&cmd_quote ),
     288        {
     289            summary => 'Send a raw command to the IRC servers.',
     290            usage   => 'irc-quote [-a ALIAS] TEXT',
     291
     292            description => <<END_DESCR
     293
     294Send a raw command line to an IRC server.
     295
     296This can be used to perform some operation not yet supported by
     297BarnOwl, or to define new IRC commands.
     298END_DESCR
     299        }
     300    );
     301}
     302
    121303
    122304$BarnOwl::Hooks::startup->add('BarnOwl::Module::IRC::startup');
    123305$BarnOwl::Hooks::shutdown->add('BarnOwl::Module::IRC::shutdown');
     306$BarnOwl::Hooks::getQuickstart->add('BarnOwl::Module::IRC::quickstart');
    124307
    125308################################################################################
     
    189372sub cmd_disconnect {
    190373    my $cmd = shift;
    191     my $conn = get_connection(\@_);
     374    my $conn = shift;
    192375    $conn->conn->disconnect;
    193376    delete $ircnets{$conn->alias};
     
    195378
    196379sub cmd_msg {
    197     my $cmd = shift;
    198     my $conn = get_connection(\@_);
    199     my $to = shift or die("Usage: $cmd NICK\n");
     380    my $cmd  = shift;
     381    my $conn = shift;
     382    my $to = shift or die("Usage: $cmd [NICK|CHANNEL]\n");
    200383    # handle multiple recipients?
    201384    if(@_) {
     
    234417}
    235418
     419sub cmd_mode {
     420    my $cmd = shift;
     421    my $conn = shift;
     422    my $target = shift;
     423    $target ||= shift;
     424    $conn->conn->mode($target, @_);
     425}
     426
    236427sub cmd_join {
    237428    my $cmd = shift;
    238     my $conn = get_connection(\@_);
     429    my $conn = shift;
    239430    my $chan = shift or die("Usage: $cmd channel\n");
    240431    $channels{$chan} ||= [];
     
    245436sub cmd_part {
    246437    my $cmd = shift;
    247     my $conn = get_connection(\@_);
    248     my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
     438    my $conn = shift;
     439    my $chan = shift;
    249440    $channels{$chan} = [grep {$_ ne $conn} @{$channels{$chan} || []}];
    250441    $conn->conn->part($chan);
     
    253444sub cmd_nick {
    254445    my $cmd = shift;
    255     my $conn = get_connection(\@_);
     446    my $conn = shift;
    256447    my $nick = shift or die("Usage: $cmd <new nick>\n");
    257448    $conn->conn->nick($nick);
     
    260451sub cmd_names {
    261452    my $cmd = shift;
    262     my $conn = get_connection(\@_);
    263     my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
     453    my $conn = shift;
     454    my $chan = shift;
    264455    $conn->names_tmp([]);
    265456    $conn->conn->names($chan);
     
    268459sub cmd_whois {
    269460    my $cmd = shift;
    270     my $conn = get_connection(\@_);
     461    my $conn = shift;
    271462    my $who = shift || die("Usage: $cmd <user>\n");
    272463    $conn->conn->whois($who);
     
    275466sub cmd_motd {
    276467    my $cmd = shift;
    277     my $conn = get_connection(\@_);
     468    my $conn = shift;
    278469    $conn->conn->motd;
    279470}
     
    290481sub cmd_who {
    291482    my $cmd = shift;
    292     my $conn = get_connection(\@_);
     483    my $conn = shift;
    293484    my $who = shift || die("Usage: $cmd <user>\n");
     485    BarnOwl::error("WHO $cmd $conn $who");
    294486    $conn->conn->who($who);
    295487}
     
    297489sub cmd_stats {
    298490    my $cmd = shift;
    299     my $conn = get_connection(\@_);
     491    my $conn = shift;
    300492    my $type = shift || die("Usage: $cmd <chiklmouy> [server] \n");
    301493    $conn->conn->stats($type, @_);
     
    304496sub cmd_topic {
    305497    my $cmd = shift;
    306     my $conn = get_connection(\@_);
    307     $conn->conn->topic(@_);
     498    my $conn = shift;
     499    my $chan = shift;
     500    $conn->conn->topic($chan, @_ ? join(" ", @_) : undef);
     501}
     502
     503sub cmd_quote {
     504    my $cmd = shift;
     505    my $conn = shift;
     506    $conn->conn->sl(join(" ", @_));
    308507}
    309508
     
    312511################################################################################
    313512
    314 sub get_connection {
    315     my $args = shift;
    316     if(scalar @$args >= 2 && $args->[0] eq '-a') {
    317         shift @$args;
    318         return get_connection_by_alias(shift @$args);
    319     }
    320     my $channel = $args->[-1];
    321     if (defined($channel) && $channel =~ /^#/
    322         and $channels{$channel} and @{$channels{$channel}} == 1) {
    323         return $channels{$channel}[0];
    324     }
    325     my $m = BarnOwl::getcurmsg();
    326     if($m && $m->type eq 'IRC') {
    327         return get_connection_by_alias($m->network);
    328     }
    329     if(scalar keys %ircnets == 1) {
    330         return [values(%ircnets)]->[0];
    331     }
    332     die("You must specify a network with -a\n");
    333 }
    334 
    335 sub get_channel {
    336     my $args = shift;
    337     if(scalar @$args) {
    338         return shift @$args;
    339     }
    340     my $m = BarnOwl::getcurmsg();
    341     if($m && $m->type eq 'IRC') {
    342         return $m->channel if !$m->is_private;
    343     }
    344     return undef;
     513sub mk_irc_command {
     514    my $sub = shift;
     515    my $use_channel = shift || 0;
     516    return sub {
     517        my $cmd = shift;
     518        my $conn;
     519        my $alias;
     520        my $channel;
     521        my $getopt = Getopt::Long::Parser->new;
     522        my $m = BarnOwl::getcurmsg();
     523
     524        local @ARGV = @_;
     525        $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
     526        $getopt->getoptions("alias=s" => \$alias);
     527
     528        if(defined($alias)) {
     529            $conn = get_connection_by_alias($alias);
     530        }
     531        if(!$conn && $use_channel) {
     532            $channel = $ARGV[0];
     533            if(defined($channel) && $channel =~ /^#/) {
     534                if($channels{$channel} && @{$channels{$channel}} == 1) {
     535                    shift @ARGV;
     536                    $conn = $channels{$channel}[0];
     537                } 
     538            } else {
     539                if($m && $m->type eq 'IRC' && !$m->is_private) {
     540                    $channel = $m->channel;
     541                } else {
     542                    undef $channel;
     543                }
     544            }
     545        }
     546        if(!$channel && $use_channel == REQUIRE_CHANNEL) {
     547            die("Usage: $cmd <channel>\n");
     548        }
     549        if(!$conn) {
     550            if($m && $m->type eq 'IRC') {
     551                $conn = get_connection_by_alias($m->network);
     552            }
     553        }
     554        if(!$conn && scalar keys %ircnets == 1) {
     555            $conn = [values(%ircnets)]->[0];
     556        }
     557        if(!$conn) {
     558            die("You must specify an IRC network using -a.\n");
     559        }
     560        if($use_channel) {
     561            $sub->($cmd, $conn, $channel, @ARGV);
     562        } else {
     563            $sub->($cmd, $conn, @ARGV);
     564        }
     565    };
    345566}
    346567
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r3048f1f r4df2568  
    7373    $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) });
    7474    $self->conn->add_handler(endofwhois=> sub { shift; $self->on_endofwhois(@_) });
     75    $self->conn->add_handler(mode      => sub { shift; $self->on_mode(@_) });
     76
     77    # * nosuchchannel
     78    # *
    7579
    7680    return $self;
     
    273277}
    274278
     279sub on_mode {
     280    my ($self, $evt) = @_;
     281    BarnOwl::admin_message("IRC",
     282                           "[" . $self->alias . "] User " . ($evt->nick) . + " set mode " .
     283                           join(" ", $evt->args) . "on " . $evt->to->[0]
     284                          );
     285}
     286
    275287sub on_event {
    276288    my ($self, $evt) = @_;
  • perlconfig.c

    re8c6d8f r87dfeb7  
    129129   message2hashref and hashref2message. Currently we lose
    130130   zephyr-specific properties stored in the ZNotice_t
     131
     132   This has been somewhat addressed, but is still not lossless.
    131133 */
    132134owl_message * owl_perlconfig_hashref2message(SV *msg)
     
    173175      owl_message_set_attribute(m, "adminheader", "");
    174176  }
     177#ifdef HAVE_LIBZEPHYR
     178  if (owl_message_is_type_zephyr(m)) {
     179    ZNotice_t *n = &(m->notice);
     180    n->z_kind = ACKED;
     181    n->z_port = 0;
     182    n->z_auth = ZAUTH_NO;
     183    n->z_checked_auth = 0;
     184    n->z_class = owl_message_get_class(m);
     185    n->z_class_inst = owl_message_get_instance(m);
     186    n->z_opcode = owl_message_get_opcode(m);
     187    n->z_sender = owl_message_get_sender(m);
     188    n->z_recipient = owl_message_get_recipient(m);
     189    n->z_default_format = "[zephyr created from perl]";
     190    n->z_multinotice = "[zephyr created from perl]";
     191    n->z_num_other_fields = 0;
     192    n->z_message = owl_sprintf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));
     193    n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1;
     194  }
     195#endif
    175196  return m;
    176197}
  • perlwrap.pm

    re9708d2 r19aeff4  
    10481048    my $sender = $m->long_sender;
    10491049    $sender =~ s/\n.*$//s;
    1050     return "  (" . $sender . '@color[default]' . ")";
     1050    if (BarnOwl::getvar('colorztext') eq 'on') {
     1051      return "  (" . $sender . '@color[default]' . ")";
     1052    } else {
     1053      return "  ($sender)";
     1054    }
    10511055}
    10521056
     
    10581062    my $body = $m->body;
    10591063    if ($m->{should_wordwrap}) {
    1060       $body = BarnOwl::wordwrap($body, BarnOwl::getnumcols()-8);
     1064      $body = BarnOwl::wordwrap($body, BarnOwl::getnumcols()-9);
    10611065    }
    10621066    # replace newline followed by anything with
     
    10861090
    10871091################################################################################
     1092
     1093sub maybe {
     1094    my $thing = shift;
     1095    return defined($thing) ? $thing : "";
     1096}
    10881097
    10891098sub format_login {
     
    11361145    $line = sprintf(BASE_FORMAT,
    11371146                    $dirsym,
    1138                     $m->context,
    1139                     $m->subcontext,
     1147                    maybe($m->context),
     1148                    maybe($m->subcontext),
    11401149                    ($dir eq 'out'
    11411150                     ? $m->pretty_recipient
  • zephyr.c

    re2a620b ra5e7ed6  
    99static const char fileIdent[] = "$Id$";
    1010
     11static GList *deferred_subs = NULL;
     12typedef struct _owl_sub_list {                            /* noproto */
     13  ZSubscription_t *subs;
     14  int nsubs;
     15} owl_sub_list;
     16
    1117#ifdef HAVE_LIBZEPHYR
    1218Code_t ZResetAuthentication();
    1319#endif
    1420
    15 int owl_zephyr_initialize()
    16 {
    17 #ifdef HAVE_LIBZEPHYR
     21#define HM_SVC_FALLBACK         htons((unsigned short) 2104)
     22
     23#ifdef HAVE_LIBZEPHYR
     24void owl_zephyr_initialize()
     25{
    1826  int ret;
    19   ZNotice_t notice;
    20 
    21   /* Stat the zhm manually, with a shorter timeout */
    22   if ((ret = ZOpenPort(NULL)) != ZERR_NONE)
    23     return(ret);
    24 
    25   if ((ret = owl_zhm_stat(&notice)) != ZERR_NONE)
    26     return(ret);
    27 
    28   ZClosePort();
    29 
    30   if ((ret = ZInitialize()) != ZERR_NONE) {
    31     com_err("owl",ret,"while initializing");
    32     return(1);
    33   }
    34   if ((ret = ZOpenPort(NULL)) != ZERR_NONE) {
    35     com_err("owl",ret,"while opening port");
    36     return(1);
    37   }
    38 #endif
    39   return(0);
    40 }
    41 
    42 #ifdef HAVE_LIBZEPHYR
    43 #define HM_SVC_FALLBACK         htons((unsigned short) 2104)
    44 
    45 /*
    46  * Code modified from libzephyr's ZhmStat.c
    47  *
    48  * Modified to only wait one second to time out if there is no
    49  * hostmanager present, rather than a rather excessive 10 seconds.
    50  */
    51 Code_t owl_zhm_stat(ZNotice_t *notice) {
    5227  struct servent *sp;
    5328  struct sockaddr_in sin;
    5429  ZNotice_t req;
    5530  Code_t code;
    56   struct timeval tv;
    57   fd_set readers;
     31  owl_dispatch *dispatch;
     32
     33  /*
     34   * Code modified from libzephyr's ZhmStat.c
     35   *
     36   * Modified to add the fd to our select loop, rather than hanging
     37   * until we get an ack.
     38   */
     39
     40  if ((ret = ZOpenPort(NULL)) != ZERR_NONE) {
     41    owl_function_error("Error opening Zephyr port: %s", error_message(ret));
     42    return;
     43  }
    5844
    5945  (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));
     
    7662  req.z_default_format = "";
    7763  req.z_message_len = 0;
    78        
    79   if ((code = ZSetDestAddr(&sin)) != ZERR_NONE)
    80     return(code);
    81 
    82   if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE)
    83     return(code);
    84 
    85   /* Wait up to 1 second for a response. */
    86   FD_ZERO(&readers);
    87   FD_SET(ZGetFD(), &readers);
    88   tv.tv_sec = 1;
    89   tv.tv_usec = 0;
    90   code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv);
    91   if (code < 0 && errno != EINTR)
    92     return(errno);
    93   if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0)
    94     return(ZERR_HMDEAD);
    95 
    96   return(ZReceiveNotice(notice, (struct sockaddr_in *) 0));
    97 }
    98 
    99 #endif
     64
     65  if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) {
     66    owl_function_error("Initializing Zephyr: %s", error_message(code));
     67    return;
     68  }
     69
     70  if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) {
     71    owl_function_error("Initializing Zephyr: %s", error_message(code));
     72    return;
     73  }
     74
     75  dispatch = owl_malloc(sizeof(*dispatch));
     76  dispatch->fd = ZGetFD();
     77  dispatch->cfunc = owl_zephyr_finish_initialization;
     78  dispatch->destroy = (void(*)(owl_dispatch*))owl_free;
     79
     80  owl_select_add_dispatch(dispatch);
     81}
     82
     83void owl_zephyr_finish_initialization(owl_dispatch *d) {
     84  Code_t code;
     85
     86  owl_select_remove_dispatch(d->fd);
     87
     88  ZClosePort();
     89
     90  if ((code = ZInitialize()) != ZERR_NONE) {
     91    owl_function_error("Initializing Zephyr: %s", error_message(code));
     92    return;
     93  }
     94
     95  if ((code = ZOpenPort(NULL)) != ZERR_NONE) {
     96    owl_function_error("Initializing Zephyr: %s", error_message(code));
     97    return;
     98  }
     99
     100  d = owl_malloc(sizeof(owl_dispatch));
     101  d->fd = ZGetFD();
     102  d->cfunc = &owl_zephyr_process_events;
     103  d->destroy = NULL;
     104  owl_select_add_dispatch(d);
     105  owl_global_set_havezephyr(&g);
     106
     107  if(g.load_initial_subs) {
     108    owl_zephyr_load_initial_subs();
     109  }
     110  while(deferred_subs != NULL) {
     111    owl_sub_list *subs = deferred_subs->data;
     112    owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs);
     113    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
     114    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
     115    owl_free(subs);
     116  }
     117}
     118
     119void owl_zephyr_load_initial_subs() {
     120  int ret, ret2;
     121
     122  owl_function_debugmsg("startup: loading initial zephyr subs");
     123
     124  /* load default subscriptions */
     125  ret = owl_zephyr_loaddefaultsubs();
     126
     127  /* load subscriptions from subs file */
     128  ret2 = owl_zephyr_loadsubs(NULL, 0);
     129
     130  if (ret || ret2) {
     131    owl_function_error("Error loading zephyr subscriptions");
     132  } else if (ret2!=-1) {
     133    owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
     134  }
     135
     136  /* load login subscriptions */
     137  if (owl_global_is_loginsubs(&g)) {
     138    owl_function_debugmsg("startup: loading login subs");
     139    owl_function_loadloginsubs(NULL);
     140  }
     141}
     142#else
     143void owl_zephyr_initialize()
     144{
     145}
     146#endif
     147
    100148
    101149int owl_zephyr_shutdown()
     
    143191int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
    144192{
    145   int i, ret = 0;
    146   /* sub without defaults */
    147   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    148     owl_function_error("Error subscribing to zephyr notifications.");
    149     ret=-2;
    150   }
    151 
    152   /* free stuff */
    153   for (i=0; i<count; i++) {
    154     owl_free(subs[i].zsub_class);
    155     owl_free(subs[i].zsub_classinst);
    156     owl_free(subs[i].zsub_recipient);
     193  int ret;
     194  if (owl_global_is_havezephyr(&g)) {
     195    int i;
     196    /* sub without defaults */
     197    if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
     198      owl_function_error("Error subscribing to zephyr notifications.");
     199      ret=-2;
     200    }
     201
     202    /* free stuff */
     203    for (i=0; i<count; i++) {
     204      owl_free(subs[i].zsub_class);
     205      owl_free(subs[i].zsub_classinst);
     206      owl_free(subs[i].zsub_recipient);
     207    }
     208
     209    owl_free(subs);
     210  } else {
     211    owl_sub_list *s = owl_malloc(sizeof(owl_sub_list));
     212    s->subs = subs;
     213    s->nsubs = count;
     214    deferred_subs = g_list_append(deferred_subs, s);
    157215  }
    158216
     
    207265   
    208266    if (count >= subSize) {
    209       ZSubscription_t* newsubs;
    210       newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2);
    211       if (NULL == newsubs) {
    212         /* If realloc fails, load what we've got, clear, and continue */
    213         ret = owl_zephyr_loadsubs_helper(subs, count);
    214         if (ret != 0) {
    215           fclose(file);
    216           return(ret);
    217         }
    218         count=0;
    219       }
    220       else {
    221         subs = newsubs;
    222         subSize *= 2;
    223       }
     267      subSize *= 2;
     268      subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize);
    224269    }
    225270   
     
    246291  fclose(file);
    247292
    248   ret=owl_zephyr_loadsubs_helper(subs, count);
    249   owl_free(subs);
     293  owl_zephyr_loadsubs_helper(subs, count);
    250294  return(ret);
    251295#else
     
    273317#ifdef HAVE_LIBZEPHYR
    274318  FILE *file;
    275   ZSubscription_t subs[3001];
     319  ZSubscription_t *subs;
     320  int numSubs = 100;
    276321  char subsfile[1024], buffer[1024];
    277   int count, ret, i;
     322  int count, ret;
    278323  struct stat statbuff;
     324
     325  subs = owl_malloc(numSubs * sizeof(ZSubscription_t));
    279326
    280327  if (filename==NULL) {
     
    290337
    291338  ZResetAuthentication();
    292   /* need to redo this to do chunks, not just bag out after 3000 */
    293339  count=0;
    294340  file=fopen(subsfile, "r");
     
    297343      if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue;
    298344     
    299       if (count >= 3000) break; /* also tell the user */
     345      if (count == numSubs) {
     346        numSubs *= 2;
     347        subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t));
     348      }
    300349
    301350      buffer[strlen(buffer)-1]='\0';
    302       subs[count].zsub_class="login";
    303       subs[count].zsub_recipient="*";
     351      subs[count].zsub_class=owl_strdup("login");
     352      subs[count].zsub_recipient=owl_strdup("*");
    304353      if (strchr(buffer, '@')) {
    305         subs[count].zsub_classinst=owl_strdup(buffer);
     354        subs[count].zsub_classinst=owl_strdup(buffer);
    306355      } else {
    307         subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm());
     356        subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm());
    308357      }
    309358
     
    316365  }
    317366
    318   /* sub with defaults */
    319   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    320     owl_function_error("Error subscribing to zephyr notifications.");
    321     ret=-2;
    322   }
    323 
    324   /* free stuff */
    325   for (i=0; i<count; i++) {
    326     owl_free(subs[i].zsub_classinst);
    327   }
    328 
     367  ret = owl_zephyr_loadsubs_helper(subs, count);
    329368  return(ret);
    330369#else
     
    602641  notice.z_class=class;
    603642  notice.z_class_inst=instance;
     643  notice.z_sender=NULL;
    604644  if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) {
    605645    notice.z_recipient="";
     646    if (*owl_global_get_zsender(&g))
     647        notice.z_sender=owl_global_get_zsender(&g);
    606648  } else {
    607649    notice.z_recipient=recipient;
    608650  }
    609651  notice.z_default_format="Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2";
    610   if (*owl_global_get_zsender(&g))
    611       notice.z_sender=owl_global_get_zsender(&g);
    612   else
    613       notice.z_sender=NULL;
    614652  if (opcode) notice.z_opcode=opcode;
    615653
Note: See TracChangeset for help on using the changeset viewer.