Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r18fb3d4f rb0c8011  
    1414
    1515package BarnOwl;
     16
     17=head1 NAME
     18
     19BarnOwl
     20
     21=head1 DESCRIPTION
     22
     23The BarnOwl module contains the core of BarnOwl's perl
     24bindings. Source in this module is also run at startup to bootstrap
     25barnowl by defining things like the default style.
     26
     27=for NOTE
     28These following functions are defined in perlglue.xs. Keep the
     29documentation here in sync with the user-visible commands defined
     30there!
     31
     32=head2 command STRING
     33
     34Executes a BarnOwl command in the same manner as if the user had
     35executed it at the BarnOwl command prompt. If the command returns a
     36value, return it as a string, otherwise return undef.
     37
     38=head2 getcurmsg
     39
     40Returns the current message as a C<BarnOwl::Message> subclass, or
     41undef if there is no message selected
     42
     43=head2 getnumcols
     44
     45Returns the width of the display window BarnOwl is currently using
     46
     47=head2 getidletime
     48
     49Returns the length of time since the user has pressed a key, in
     50seconds.
     51
     52=head2 zephyr_getrealm
     53
     54Returns the zephyr realm barnowl is running in
     55
     56=head2 zephyr_getsender
     57
     58Returns the fully-qualified name of the zephyr sender barnowl is
     59running as, e.g. C<nelhage@ATHENA.MIT.EDU>
     60
     61=head2 zephyr_zwrite COMMAND MESSAGE
     62
     63Sends a zephyr programmatically. C<COMMAND> should be a C<zwrite>
     64command line, and C<MESSAGE> is the zephyr body to send.
     65
     66=head2 ztext_stylestrip STRING
     67
     68Strips zephyr formatting from a string and returns the result
     69
     70=head2 queue_message MESSAGE
     71
     72Enqueue a message in the BarnOwl message list, logging it and
     73processing it appropriately. C<MESSAGE> should be an instance of
     74BarnOwl::Message or a subclass.
     75
     76=head2 admin_message HEADER BODY
     77
     78Display a BarnOwl B<Admin> message, with the given header and body.
     79
     80=head2 start_question PROMPT CALLBACK
     81
     82Displays C<PROMPT> on the screen and lets the user enter a line of
     83text, and calls C<CALLBACK>, which must be a perl subroutine
     84reference, with the text the user entered
     85
     86=head2 start_password PROMPT CALLBACK
     87
     88Like C<start_question>, but echoes the user's input as C<*>s when they
     89input.
     90
     91=head2 start_editwin PROMPT CALLBACK
     92
     93Like C<start_question>, but displays C<PROMPT> on a line of its own
     94and opens the editwin. If the user cancels the edit win, C<CALLBACK>
     95is not invoked.
     96
     97=head2 get_data_dir
     98
     99Returns the BarnOwl system data directory, where system libraries and
     100modules are stored
     101
     102=head2 get_config_dir
     103
     104Returns the BarnOwl user configuration directory, where user modules
     105and configuration are stored (by default, C<$HOME/.owl>)
     106
     107=head2 popless_text TEXT
     108
     109Show a popup window containing the given C<TEXT>
     110
     111=head2 popless_ztext TEXT
     112
     113Show a popup window containing the provided zephyr-formatted C<TEXT>
     114
     115=head2 error STRING
     116
     117Reports an error and log it in `show errors'. Note that in any
     118callback or hook called in perl code from BarnOwl, a C<die> will be
     119caught and passed to C<error>.
     120
     121=head2 getnumcolors
     122
     123Returns the number of colors this BarnOwl is capable of displaying
     124
     125=cut
     126
    16127
    17128BEGIN {
     
    46157    return &BarnOwl::Hooks::_receive_msg($m);
    47158}
     159
     160=head2 AUTOLOAD
     161
     162BarnOwl.pm has a C<AUTOLOAD> method that translates unused names in
     163the BarnOwl:: namespace to a call to BarnOwl::command() with that
     164command. Underscores are also translated to C<->s, so you can do
     165e.g. C<BarnOwl::start_command()> and it will be translated into
     166C<start-command>.
     167
     168So, if you're looking for functionality that you can't find in the
     169perl interface, check C<:show commands> or C<commands.c> in the
     170BarnOwl source tree -- there's a good chance it exists as a BarnOwl
     171command.
     172
     173=head3 BUGS
     174
     175There are horrible quoting issues here. The AUTOLOAD simple joins your
     176commands with spaces and passes them unmodified to C<::command>
     177
     178=cut
    48179
    49180# make BarnOwl::<command>("foo") be aliases to BarnOwl::command("<command> foo");
     
    63194
    64195ARGS should be a hashref containing any or all of C<summary>,
    65 C<usage>, or C<description> keys.
     196C<usage>, or C<description> keys:
     197
     198=over 4
     199
     200=item summary
     201
     202A one-line summary of the purpose of the command
     203
     204=item usage
     205
     206A one-line usage synopsis, showing available options and syntax
     207
     208=item description
     209
     210A longer description of the syntax and semantics of the command,
     211explaining usage and options
     212
     213=back
    66214
    67215=cut
     
    410558package BarnOwl::Hook;
    411559
     560=head1 BarnOwl::Hook
     561
     562=head1 DESCRIPTION
     563
     564A C<BarnOwl::Hook> represents a list of functions to be triggered on
     565some event. C<BarnOwl> exports a default set of these (see
     566C<BarnOwl::Hooks>), but can also be created and used by module code.
     567
     568=head2 new
     569
     570Creates a new Hook object
     571
     572=cut
     573
    412574sub new {
    413575    my $class = shift;
    414576    return bless [], $class;
    415577}
     578
     579=head2 run [ARGS]
     580
     581Calls each of the functions registered with this hook with the given
     582arguments.
     583
     584=cut
    416585
    417586sub run {
     
    420589    return map {$_->(@args)} @$self;
    421590}
     591
     592=head2 add SUBREF
     593
     594Registers a given subroutine with this hook
     595
     596=cut
    422597
    423598sub add {
     
    428603}
    429604
     605=head2 clear
     606
     607Remove all functions registered with this hook.
     608
     609=cut
     610
    430611sub clear {
    431612    my $self = shift;
     
    434615
    435616package BarnOwl::Hooks;
     617
     618=head1 BarnOwl::Hooks
     619
     620=head1 DESCRIPTION
     621
     622C<BarnOwl::Hooks> exports a set of C<BarnOwl::Hook> objects made
     623available by BarnOwl internally.
     624
     625=head2 USAGE
     626
     627Modules wishing to respond to events in BarnOwl should register
     628functions with these hooks.
     629
     630=head2 EXPORTS
     631
     632None by default. Either import the hooks you need explicitly, or refer
     633to them with fully-qualified names. Available hooks are:
     634
     635=over 4
     636
     637=item $startup
     638
     639Called on BarnOwl startup, and whenever modules are
     640reloaded. Functions registered with the C<$startup> hook get a true
     641argument if this is a reload, and false if this is a true startup
     642
     643=item $shutdown
     644
     645Called before BarnOwl shutdown
     646
     647=item $receiveMessage
     648
     649Called with a C<BarnOwl::Message> object every time BarnOwl appends a
     650new message to its message list
     651
     652=item $mainLoop
     653
     654Called on B<every pass> through the C<BarnOwl> main loop. Any
     655functions with this hook should be very cheap, as they are very
     656frequently by the runtime.
     657
     658=item $getBuddyList
     659
     660Called to display buddy lists for all protocol handlers. The result
     661from every function registered with this hook will be appended and
     662displayed in a popup window, with zephyr formatting parsed.
     663
     664=back
     665
     666=cut
    436667
    437668use Exporter;
     
    468699    }
    469700}
     701
     702# These are the internal hooks called by the barnowl C code, which
     703# take care of dispatching to the appropriate perl hooks, and deal
     704# with compatibility by calling the old, fixed-name hooks.
    470705
    471706sub _startup {
Note: See TracChangeset for help on using the changeset viewer.