Changeset 1a64de6


Ignore:
Timestamp:
Jan 10, 2008, 5:22:46 PM (16 years ago)
Author:
Nelson Elhage <nelhage@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:
65fea01
Parents:
214b790
Message:
Document ::Hook and ::Hooks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r74fc22a r1a64de6  
    558558package BarnOwl::Hook;
    559559
     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
    560574sub new {
    561575    my $class = shift;
    562576    return bless [], $class;
    563577}
     578
     579=head2 run [ARGS]
     580
     581Calls each of the functions registered with this hook with the given
     582arguments.
     583
     584=cut
    564585
    565586sub run {
     
    568589    return map {$_->(@args)} @$self;
    569590}
     591
     592=head2 add SUBREF
     593
     594Registers a given subroutine with this hook
     595
     596=cut
    570597
    571598sub add {
     
    576603}
    577604
     605=head2 clear
     606
     607Remove all functions registered with this hook.
     608
     609=cut
     610
    578611sub clear {
    579612    my $self = shift;
     
    582615
    583616package 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
    584667
    585668use Exporter;
Note: See TracChangeset for help on using the changeset viewer.