Author: dylan
Date: 2005-04-10 04:42:53 -0400 (Sun, 10 Apr 2005)
New Revision: 666
Added:
trunk/docs/login.txt
trunk/main/server/lib/Haver/Server/Avatar.pm
trunk/main/server/lib/Haver/Server/Base.pm
trunk/main/server/lib/Haver/Server/Container.pm
trunk/main/server/lib/Haver/Server/Entity/Channel.pm
trunk/main/server/lib/Haver/Server/Entity/Lobby.pm
trunk/main/server/lib/Haver/Server/Entity/Service.pm
trunk/main/server/lib/Haver/Server/Entity/User.pm
trunk/main/server/lib/Haver/Server/Messages.pm
trunk/main/server/lib/Haver/Server/Messages/
trunk/main/server/lib/Haver/Server/Messages/Login.pm
trunk/misc/poe-session-plugin/
trunk/misc/poe-session-plugin/Build.PL
trunk/misc/poe-session-plugin/COPYING
trunk/misc/poe-session-plugin/MANIFEST.SKIP
trunk/misc/poe-session-plugin/lib/
trunk/misc/poe-session-plugin/lib/POE/
trunk/misc/poe-session-plugin/lib/POE/Session/
trunk/misc/poe-session-plugin/lib/POE/Session/Plugin.pm
trunk/misc/poe-session-plugin/lib/POE/Session/Plugin/
trunk/misc/poe-session-plugin/lib/POE/Session/Plugin/Loader.pm
trunk/misc/poe-session-plugin/t/
Removed:
trunk/main/server/lib/Haver/Server/Entity/Avatar.pm
trunk/main/server/lib/Haver/Server/Entity/Index.pm
trunk/main/server/lib/Haver/Server/Entity/Room.pm
trunk/main/server/lib/Haver/Server/Events.pm
trunk/main/server/lib/Haver/Server/Events/
trunk/main/server/lib/Haver/Server/Plugin.pm
Modified:
trunk/
trunk/docs/manual/messages.texi
trunk/docs/manual/messages/connection.texi
trunk/main/core/lib/Haver/Formats.pm
trunk/main/core/lib/Haver/Logger.pm
trunk/main/core/lib/Haver/Object.pm
trunk/main/server/Build.PL
trunk/main/server/lib/Haver/Server.pm
trunk/main/server/lib/Haver/Server/Entity.pm
trunk/web/clients/javer/
Log:
[EMAIL PROTECTED]: dylan | 2005-03-27 23:49:14 -0500
Cleaning up the server source.
Ugh. it's a mess.
[EMAIL PROTECTED]: dylan | 2005-03-27 23:56:14 -0500
I'm using spiffy now. And things are quite spiffy.
[EMAIL PROTECTED]: dylan | 2005-04-05 23:47:10 -0400
Blaa.
[EMAIL PROTECTED]: dylan | 2005-04-05 23:55:41 -0400
organizing the modules into the proper places.
[EMAIL PROTECTED]: dylan | 2005-04-06 00:00:23 -0400
Added field 'contents'
[EMAIL PROTECTED]: dylan | 2005-04-06 00:01:37 -0400
small correction -- only things which descend from Haver::Server::Entity
are under the ::Entity namespace.
[EMAIL PROTECTED]: dylan | 2005-04-06 00:09:48 -0400
Most of the base objects work now.
[EMAIL PROTECTED]: dylan | 2005-04-06 02:58:29 -0400
going to sleep.
Plugin should work now.
[EMAIL PROTECTED]: dylan | 2005-04-06 02:59:23 -0400
I forget what I've added to the manual. I should have commited sooner.
I did some code-removal from Formats, Logger, and Object.
[EMAIL PROTECTED]: dylan | 2005-04-09 21:26:45 -0400
Added the login.txt to docs, even thought it not very useful.
The server's Entity::User no longer supports get/set/del/has methods.
Instead we'll access its attr() hash directly.
[EMAIL PROTECTED]: dylan | 2005-04-10 02:52:36 -0400
field() now warns about redefining fields,
Entity->id is now Entity->name.
Haver::Server::Plugin is going to become POE::Session::Plugin.
[EMAIL PROTECTED]: dylan | 2005-04-10 03:36:07 -0400
poe-session-plugin: it's like a wheel, except not.
[EMAIL PROTECTED]: dylan | 2005-04-10 04:39:25 -0400
Fixed syntax error.
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:885
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
+ 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:908
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
Added: trunk/docs/login.txt
===================================================================
--- trunk/docs/login.txt 2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/docs/login.txt 2005-04-10 08:42:53 UTC (rev 666)
@@ -0,0 +1,16 @@
+C: HAVER Foobar
+S: HAVER FoobarServer
+S: WANT IDENT
+C: IDENT User
+
+if User is registered then
+ S: WANT AUTH:TYPE basic plain
+ if basic then
+ C: AUTH:TYPE basic
+ S: WANT AUTH:BASIC $rand sha1 sha256
+ C: AUTH:BASIC sha1 sha1($rand + sha1($password))
+ S: ACCEPT User
+ end if
+else
+ S: ACCEPT User
+end if
Modified: trunk/docs/manual/messages/connection.texi
===================================================================
--- trunk/docs/manual/messages/connection.texi 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/docs/manual/messages/connection.texi 2005-04-10 08:42:53 UTC (rev
666)
@@ -12,12 +12,12 @@
@c ########################################################
@deffn {Client Message} HAVER client
-This message @strong{must} only be sent once during the lifetime of the
connection.
+This message must only be sent once during the lifetime of the connection.
-This message @strong{must} be the first message sent by the client.
-If a different message is received, servers @strong{must}
+This message must be the first message sent by the client.
+If a different message is received, servers must
immediately terminate the connection.
-This message @strong{must not} be sent be sent more than once
+This message must not be sent be sent more than once
during the lifetime of the connection.
The parameter @param{client} is the name and version
@@ -26,7 +26,7 @@
is a number from 0 to 9. This format shall not be strictly enforced,
but clients are encouraged to not deviate from it.
-The server @strong{must} respond to this message
+The server must respond to this message
by sending the messages @cmd{HAVER}, @cmd{HOST}, and @cmd{WANT IDENT}.
@end deffn
@@ -35,8 +35,8 @@
@deffn {Server Message} HAVER server
-This message @strong{must} be sent after the client sends @cmd{HAVER},
-and @strong{must not} be sent again during the lifetime of the connection.
+This message must be sent after the client sends @cmd{HAVER},
+and must not be sent again during the lifetime of the connection.
The parameter @param{server} is name and version number of the server,
for example ``Haver::Server::POE/0.07''. This is the same form as
@@ -46,11 +46,11 @@
@end deffn
@deffn {Server Message} HOST hostname
-This message @strong{must} be sent after the client sends @cmd{HAVER},
-and @strong{must not} be sent again during the lifetime of the connection.
+This message must be sent after the client sends @cmd{HAVER},
+and must not be sent again during the lifetime of the connection.
The parameter @param{hostname} is the @acronym{DNS} name of the server.
-It @strong{must} resolve back to the server, but a client does no have to
verify this
+It must resolve back to the server, but a client does no have to verify this
(it is a good idea, however).
This value should be remembered, as most clients should use when generating
passcodes
@@ -62,11 +62,11 @@
@deffn {Server Message} WANT cmd [EMAIL PROTECTED]
When the server sends this message, the client
[EMAIL PROTECTED] either reply with @cmd{cmd}
+must either reply with @cmd{cmd}
or @code{CANT @param{cmd}}.
-The server @strong{must not} send this message after it sends @cmd{ACCEPT}.
+The server must not send this message after it sends @cmd{ACCEPT}.
-If the client sends any other message(s), the server @strong{must} disconnect
+If the client sends any other message(s), the server must disconnect
the client.
@end deffn
@@ -74,7 +74,7 @@
@c ########################################################
@deffn {Client Message} IDENT [type] ident
-This message @strong{must} only be sent when the server requests it with
@cmd{WANT}.
+This message must only be sent when the server requests it with @cmd{WANT}.
@param{ident} is the identifier the client wishes to go by
(@pxref{Identifiers}).
@param{type} is optional, and may be one of ``user'' or ``service''.
@@ -89,7 +89,7 @@
@deffn {Client Message} AUTH:TYPE name
@deffnx {Server Message} {WANT AUTH:TYPE} [EMAIL PROTECTED]
-This message @strong{must} only be sent when the server requests it with
@cmd{WANT}.
+This message must only be sent when the server requests it with @cmd{WANT}.
Request to use authentication type @param{name}.
Supported values for @param{name} would have been given by
@@ -166,7 +166,7 @@
fast enough. Typically, the login procedure must be completed in
20 seconds from login, however this can be different depending on server.
-This @strong{must not} be sent if the client never sent @cmd{HAVER}.
+This must not be sent if the client never sent @cmd{HAVER}.
@item ping
The client did not respond to a @cmd{PING}
in time.
@@ -178,10 +178,12 @@
@deffn {Server Message} PING data
@deffnx {Client Message} PONG data
-When the server issues the @cmd{PING} message, the client @strong{must} reply
+When the server issues the @cmd{PING} message, the client must reply
with @cmd{PONG}. The @param{data} parameter of @cmd{PONG}
is whatever value the server sent with @cmd{PING}.
+Servers should not ping more than once a minute.
+The ping time should be configurable.
@end deffn
@c ########################################################
@@ -189,7 +191,7 @@
@deffn {Client Message} POKE [EMAIL PROTECTED]
@deffnx {Server Message} OUCH [EMAIL PROTECTED]
-When the client sends @cmd{POKE}, the server @strong{must} respond with
@cmd{OUCH}.
+When the client sends @cmd{POKE}, the server must respond with @cmd{OUCH}.
There are some limits to this; in general you should not
send this more than once a minute. Sending every five minutes is even better.
Modified: trunk/docs/manual/messages.texi
===================================================================
--- trunk/docs/manual/messages.texi 2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/docs/manual/messages.texi 2005-04-10 08:42:53 UTC (rev 666)
@@ -21,7 +21,9 @@
@menu
-* Connection Messages::
+* Connection Messages:: How to connect and stay connected.
+* Error Messages:: How haver signals errors.
@end menu
@include messages/connection.texi
[EMAIL PROTECTED] messages/error.texi
Modified: trunk/main/core/lib/Haver/Formats.pm
===================================================================
--- trunk/main/core/lib/Haver/Formats.pm 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/main/core/lib/Haver/Formats.pm 2005-04-10 08:42:53 UTC (rev
666)
@@ -18,26 +18,26 @@
package Haver::Formats;
use strict;
use warnings;
-use Haver::Preprocessor;
use POSIX qw( strftime );
-use Time::Duration qw( duration_exact concise );
+#use Time::Duration qw( duration_exact concise );
use Date::Parse qw( str2time );
use Carp;
use Exporter;
use base 'Exporter';
-our @EXPORT_OK = qw( format_datetime parse_datetime parse_duration
format_duration );
+our @EXPORT_OK = qw(
+ format_datetime parse_datetime
+ check_id_valid check_id_reserved
+);
our %EXPORT_TAGS = (
'datetime' => [qw( format_datetime parse_datetime )],
- 'duration' => [qw( format_duration parse_duration )],
- 'check' => [qw( check_id_valid check_ns_valid check_id_reserved )],
+ 'check' => [qw( check_id_valid check_id_reserved )],
);
-our $VERSION = 0.04;
+our $VERSION = 0.05;
our $RELOAD = 1;
our $IdPattern ||= qr/&?[A-Za-z][A-Za-z0-9_'[EMAIL PROTECTED]/;
-our $NsPattern ||= qr/[a-z]+/;
sub check_id_reserved {
my $id = shift;
@@ -52,19 +52,13 @@
return $id =~ $IdPattern;
}
-sub check_ns_valid {
- my $id = shift;
-
- return $id =~ $NsPattern;
-}
-
# Author: dylan
sub format_datetime {
# dylan: Because bd_ thought it should work this way...
# ASSERT: @_ <= 1;
my $now = @_ ? shift : time;
- strftime('%Y-%m-%d %H:%M:%S %z', localtime($now));
+ strftime('%Y-%m-%d %H:%M:%S', gmtime($now));
}
@@ -74,48 +68,12 @@
# patterns
my $date = qr/(\d{4})-(\d\d)-(\d\d)/;
my $time = qr/(\d\d):(\d\d):(\d\d)/;
- my $tz = qr/([+-])(\d{4})/;
- if ($str =~ /^$date $time $tz$/) {
+ if ($str =~ /^$date $time$/) {
return str2time($str);
} else {
croak "Datetime format is invalid!";
}
}
-# TODO
-# * Do this ourself, don't rely on Time::Duration.
-sub format_duration {
- my ($secs) = shift;
-
- return concise(duration_exact($secs));
-}
-
-sub parse_duration {
- my $dur = shift;
- my $secs = 0;
-
- my %table = (
- y => 31556930, # a year
- w => 604800, # a week
- d => 86400, # a day
- h => 3600, # an hour
- m => 60, # a minute
- s => 1, # a second
- );
-
- # If there is no s at the end,
- # add one.
- # Thus 5h23 is the same as 5h23s.
- if ($dur =~ s/(\d+)$//) {
- $dur .= "${1}s";
- }
-
- while ( $dur =~ s/^(\d+)([ywdhms])// ) {
- $secs += $1 * $table{$2};
- }
- return $secs;
-}
-
-
1;
Modified: trunk/main/core/lib/Haver/Logger.pm
===================================================================
--- trunk/main/core/lib/Haver/Logger.pm 2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/main/core/lib/Haver/Logger.pm 2005-04-10 08:42:53 UTC (rev 666)
@@ -7,7 +7,7 @@
use base 'Haver::Object';
-our $VERSION = 0.03;
+our $VERSION = 0.04;
sub initialize {
my ($me, $p) = @_;
Modified: trunk/main/core/lib/Haver/Object.pm
===================================================================
--- trunk/main/core/lib/Haver/Object.pm 2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/main/core/lib/Haver/Object.pm 2005-04-10 08:42:53 UTC (rev 666)
@@ -32,11 +32,6 @@
return $me;
}
-
-
-sub initialize { return }
-sub finalize { return }
-
sub DESTROY {
my $me = shift;
@@ -46,7 +41,11 @@
$me->finalize();
}
+sub initialize { return }
+sub finalize { return }
+
+
1;
__END__
Modified: trunk/main/server/Build.PL
===================================================================
--- trunk/main/server/Build.PL 2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/main/server/Build.PL 2005-04-10 08:42:53 UTC (rev 666)
@@ -1,17 +1,18 @@
#!/usr/bin/perl
+require 5.008;
use Module::Build;
my $build = Module::Build->new(
module_name => 'Haver::Server',
dist_version_from => 'lib/Haver/Server.pm',
- dist_author => 'Dylan William Hardison <[EMAIL PROTECTED]>',
+ dist_author => 'Dylan William Hardison <[EMAIL PROTECTED]>',
dist_abstract => 'POE-based simple chat server',
license => 'gpl',
requires => {
'perl' => '5.8.0',
POE => 0.27,
- Haver => 0.07,
- YAML => 0.35,
'Digest::SHA1' => 2.01,
+ Spiffy => 0.22,
+
},
create_makefile_pl => 'passthrough',
script_files => [glob('bin/*.pl')],
Added: trunk/main/server/lib/Haver/Server/Avatar.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Avatar.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Avatar.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -0,0 +1,30 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Avatar;
+use Haver::Server::Base qw( -Base );
+
+our $VERSION = 0.07;
+
+field 'wheel';
+field _access => {};
+
+sub grant {
+ my ($me, $where, $what, $level) = @_;
+
+ $me->{_access}{$where}{$what} = $level || 1;
+}
+
+sub revoke {
+ my ($me, $where, $what) = @_;
+
+ return undef if not exists $me->{_access}{$where};
+ return delete $me->{_access}{$where}{$what};
+}
+
+sub may {
+ my ($me, $where, $what) = @_;
+
+ return undef unless exists $me->{_access}{$where};
+ return undef unless exists $me->{_access}{$where}{$what};
+ return $me->{_access}{$where}{$what};
+}
Property changes on: trunk/main/server/lib/Haver/Server/Avatar.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/main/server/lib/Haver/Server/Base.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Base.pm 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/main/server/lib/Haver/Server/Base.pm 2005-04-10 08:42:53 UTC (rev
666)
@@ -0,0 +1,50 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Base;
+use Spiffy qw( -Base );
+use Spiffy qw( -XXX -dumper );
+use Carp;
+
+our @EXPORT = qw( croak carp confess );
+our @EXPORT_BASE = qw( field );
+
+
+{
+no warnings;
+sub field(@) {
+ use warnings;
+ my $package = caller;
+ my ($args, @values) = do {
+ no warnings;
+ local *boolean_arguments = sub { (qw( -weak -force )) };
+ local *paired_arguments = sub { (qw( -package -init )) };
+ Haver::Server::Base->parse_arguments(@_);
+ };
+ my ($field, $default) = @values;
+ if (my $sub = $package->can($field) and not $args->{'-force'}) {
+ require B;
+ my $p = B::svref_2object($sub)->START->stashpv;
+ if ($p ne $package) {
+ croak "Warning: redefining field $field in $package (Previously
defined in $p)\n\t";
+ }
+ }
+ Spiffy::field (-package => $package, @_);}
+}
+
+sub new() {
+ my $this = shift;
+ my $self = super;
+
+ $self->initialize;
+
+ return $self;
+}
+
+sub DESTROY {
+ $self->finalize;
+}
+
+sub initialize { }
+sub finalize { }
+
+
Added: trunk/main/server/lib/Haver/Server/Container.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Container.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Container.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -0,0 +1,58 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+# This is a mixin class.
+package Haver::Server::Container;
+use Haver::Server::Base '-Base';
+
+our $VERSION = 0.04;
+
+field _contents => {};
+stub 'can_contain';
+
+sub add {
+ my ($object) = @_;
+
+ my $ns = $object->namespace;
+ my $name = $object->name;
+
+ croak ref($self) . " can't contain $object!" unless
$self->can_contain($object);
+
+ $self->{_contents}{$ns}{lc $name} = $object;
+}
+
+sub fetch {
+ my ($ns, $name) = @_;
+ $name = lc $name;
+
+ return undef unless exists $self->{_contents}{$ns};
+ return undef unless exists $self->{_contents}{$ns}{$name};
+ return $self->{_contents}{$ns}{$name};
+}
+
+sub remove {
+ my ($ns, $name) = @_;
+ $name = lc $name;
+
+ return undef unless exists $self->{_contents}{$ns};
+ return undef unless exists $self->{_contents}{$ns}{$name};
+ return delete $self->{_contents}{$ns}{$name};
+}
+
+sub _contents {
+ my ($ns) = @_;
+ my @values = ();
+
+ if (exists $self->{_contents}{$ns}) {
+ @values = values %{ $self->{_contents}{$ns} };
+ }
+
+ return wantarray ? @values : [EMAIL PROTECTED];
+}
+
+sub contains {
+ my ($ns, $name) = @_;
+
+ return undef unless exists $self->{_contents}{$ns};
+ return exists $self->{_contents}{$ns}{lc $name};
+}
+
Deleted: trunk/main/server/lib/Haver/Server/Entity/Avatar.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Avatar.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Avatar.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,139 +0,0 @@
-# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
-# This module is copyrighted, see end of file for details.
-package Haver::Server::Entity::Avatar;
-use strict;
-use warnings;
-use Carp;
-
-use Haver::Preprocessor;
-use base qw( Haver::Server::Entity );
-use Scalar::Util;
-
-our $VERSION = 0.05;
-
-
-sub initialize {
- my ($me) = @_;
- $me->SUPER::initialize();
-
- croak "required paramter: -wheel" unless $me->{'-wheel'};
-
- $me->{access} = {};
-}
-
-sub wheel {
- $_[0]{'-wheel'}
-}
-
-sub grant {
- my ($me, $where, $what, $level) = @_;
- # ASSERT: defined $where;
- # ASSERT: defined $what;
- $level ||= 1;
-
- $me->{access}{$where}{$what} = $level;
-}
-
-sub revoke {
- my ($me, $where, $what) = @_;
- # ASSERT: defined $where;
- # ASSERT: defined $what;
-
- return undef if not exists $me->{access}{$where};
- return delete $me->{access}{$where}{$what};
-}
-
-sub may {
- my ($me, $where, $what) = @_;
- # ASSERT: defined $where;
- # ASSERT: defined $what;
-
- return undef unless exists $me->{access}{$where};
- return undef unless exists $me->{access}{$where}{$what};
- return $me->{access}{$where}{$what};
-}
-
-# Now for the API manual.
-__END__
-
-=head1 NAME
-
-Haver::Server::Entity::Avatar - An object that contains information about a
user.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Entity::Avatar;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Entity::Avatar extends L<Haver::Server::Entity>.
-
-=head1 CONSTRUCTOR
-
-The constructor requires a C<-wheel> parameter, which is the read/write
-wheel of the associated session.
-
-It also requires C<-id> parameter, because of inheritence.
-
-=head1 METHODS
-
-This class implements the following methods:
-
-=head2 wheel(Z<>)
-
-Returns the I/O wheel of the avatar's Speaker session.
-
-=head2 grant($room, $perm, $level=1)
-
-Grants permision $perm in room $room with authority $level (default: 1).
-
-=head2 revoke($room, $perm)
-
-Removes permision $perm in room $room.
-
-=head2 may($room, $perm)
-
-Returns the access level for $perm in room $room.
-Returns undef when $perm has never been granted for $room.
-
-=head1 FIELDS
-
-The field C<access> is reserved by this class.
-
-=head1 BUGS
-
-None known. Bug reports are willelcome. Please use our bug tracker at
-L<http://gna.org/bugs/?func=additem&group=haver>.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<Haver::Server::Entity::User>, L<Haver::Server::Entity::Room>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2004, 2005 by Dylan Hardison
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Added: trunk/main/server/lib/Haver/Server/Entity/Channel.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-03-27
21:52:46 UTC (rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-04-10
08:42:53 UTC (rev 666)
@@ -0,0 +1,14 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Entity::Channel;
+use Haver::Server::Entity qw( -Base );
+use Haver::Server::Container qw( -mixin );
+
+our $VERSION = 0.12;
+
+const namespace => 'channel';
+
+sub can_contain {
+ my $object = shift;
+ $object->namespace eq 'user';
+}
Property changes on: trunk/main/server/lib/Haver/Server/Entity/Channel.pm
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: trunk/main/server/lib/Haver/Server/Entity/Index.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Index.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Index.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,33 +0,0 @@
-# Haver::Server::Object::Index - Index of objects.
-#
-# Copyright (C) 2003 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Server::Object::Index;
-use strict;
-use warnings;
-use Carp;
-
-
-our $VERSION = 0.05;
-our $RELOAD = 1;
-
-
-sub namespace {
- return 'container';
-}
-
-
-1;
Added: trunk/main/server/lib/Haver/Server/Entity/Lobby.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Lobby.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Lobby.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -0,0 +1,14 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Entity::Lobby;
+use Haver::Server::Entity qw( -Base );
+use Haver::Server::Container qw( -mixin );
+
+our $VERSION = 0.12;
+
+const namespace => 'lobby';
+
+sub can_contain {
+ my $object = shift;
+ $object->namespace ne 'lobby';
+}
Deleted: trunk/main/server/lib/Haver/Server/Entity/Room.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Room.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Room.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,178 +0,0 @@
-# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
-# This module is copyrighted, see end of file for details.
-package Haver::Server::Entity::Room;
-use strict;
-use warnings;
-use Carp;
-use base qw( Haver::Server::Entity );
-
-our $VERSION = 0.10;
-
-sub initialize {
- my ($me) = @_;
-
- $me->SUPER::initialize;
- $me->{contents} = {};
-}
-
-sub namespace {
- return 'room';
-}
-
-sub add {
- my ($me, $object) = @_;
-
- my $ns = $object->namespace;
- my $id = $object->id;
-
- croak ref($me) . " can't contain $object!" unless
$me->can_contain($object);
-
- $me->{contents}{$ns}{lc $id} = $object;
-}
-
-sub can_contain {
- my ($me, $object) = @_;
-
- $object->namespace eq 'user';
-}
-
-sub fetch {
- my ($me, $ns, $id) = @_;
- $id = lc $id;
-
- return undef unless exists $me->{contents}{$ns};
- return undef unless exists $me->{contents}{$ns}{$id};
- return $me->{contents}{$ns}{$id};
-}
-
-sub remove {
- my ($me, $ns, $id) = @_;
- $id = lc $id;
-
- return undef unless exists $me->{contents}{$ns};
- return undef unless exists $me->{contents}{$ns}{$id};
- return delete $me->{contents}{$ns}{$id};
-}
-
-sub contents {
- my ($me, $ns) = @_;
- my @values = ();
-
- if (exists $me->{contents}{$ns}) {
- @values = values %{ $me->{contents}{$ns} };
- }
-
- return wantarray ? @values : [EMAIL PROTECTED];
-}
-
-sub contains {
- my ($me, $ns, $id) = @_;
-
- return undef unless exists $me->{contents}{$ns};
- return exists $me->{contents}{$ns}{lc $id};
-}
-
-
-
-
-1;
-
-# Now for the API manual.
-__END__
-
-=head1 NAME
-
-Haver::Server::Entity::Room - A Server::Object that contains Server::Objects.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Entity::Room;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Entity::Room extends L<Haver::Server::Entity>.
-
-=head1 METHODS
-
-Haver::Server::Entity::Room implements the following methods:
-
-=head2 namespace(Z<>)
-
-Returns 'room'
-
-=head2 add($thing)
-
-This inserts the object $thing to the contents of the channel,
-provided that $thing supports both the namespace() and id() methods,
-and C<<$channel->can_contain($thing)>> returns a true value.
-
-For Haver::Server::Entity::Room, can_contain will return true
-if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
-
-=head2 can_contain($thing)
-
-Returns true of C<<$thing->namespace()>> is equal to 'user'.
-
-=head2 fetch($ns, $id)
-
-Returns the object with namespace $ns and id $id if such an object exists,
-undef otherwise.
-
-=head2 remove($ns, $id)
-
-Deletes and returns the object with namesapce $ns and id $id if it exists,
-returns undef otherwise.
-
-=head2 contains($ns, $id)
-
-Returns true if an object with namespace $ns and id $id exists, false
otherwise.
-
-=head2 contents($ns)
-
-Returns all objects under namespace $ns.
-Will return empty list if there are no object under the namespace.
-
-In scalar context, returns an arrayref. In list context, it returns a list.
-
-
-=head1 FIELDS
-
-This class reserves the field C<contents>.
-
-=head1 BUGS
-
-None known. Bug reports are welcome. Please use our bug tracker at
-L<http://gna.org/bugs/?func=additem&group=haver>.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<Haver::Server::Object::User>, L<Haver::Server::Object::User>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2004, 2005 by Dylan Hardison
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-=cut
Added: trunk/main/server/lib/Haver/Server/Entity/Service.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/Service.pm 2005-03-27
21:52:46 UTC (rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/Service.pm 2005-04-10
08:42:53 UTC (rev 666)
@@ -0,0 +1,7 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Entity::Service;
+use Haver::Server::Entity qw( -Base );
+use Haver::Server::Avatar qw( -mixin );
+
+const namespace => 'service';
Added: trunk/main/server/lib/Haver/Server/Entity/User.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity/User.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity/User.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -0,0 +1,16 @@
+# vim: set ts=4 sw=4 noexpandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Server::Entity::User;
+use Haver::Server::Entity qw( -Base );
+use Haver::Server::Container qw( -mixin );
+use Haver::Server::Avatar qw( -mixin );
+
+field idd => 'foobar';
+const namespace => 'user';
+
+sub can_contain {
+ my $object = shift;
+ $object->namespace eq 'user'
+ or $object->namespace eq 'channel';
+}
+
Modified: trunk/main/server/lib/Haver/Server/Entity.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Entity.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Entity.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,176 +1,10 @@
# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
# This module is copyrighted, see end of file for details.
package Haver::Server::Entity;
-use strict;
-use warnings;
-use Haver::Preprocessor;
-use Carp;
+use Haver::Server::Base '-Base';
-use Fatal qw(:void open close opendir closedir);
-use Haver::Base;
-use Storable (); # nstore, retrieve.
-use File::Basename (); # fileparse
-use File::Spec;
-use File::Path ();
+field -force => (id => '_default_');
+field attr => {};
+stub 'namespace';
-use base 'Haver::Base';
-
-sub initialize {
- my ($me) = @_;
-
- croak "required paramter: -id" unless $me->{'-id'};
- $me->{attribs} = { };
-}
-
-sub id {
- my ($me) = @_;
-
- return $me->{'-id'};
-}
-
-sub set {
- my ($me, $key, $val) = @_;
- croak "Too few args!" if @_ < 3;
- croak "Too many args, use set_many!" if @_ > 3;
-
- $me->{attribs}{$key} = $val;
-}
-
-
-sub get {
- my ($me, $key) = @_;
-
- croak "Too few args!" if @_ < 2;
- croak "Too many args, try get_many!" if @_ > 2;
-
- if (exists $me->{attribs}{$key}) {
- return $me->{attribs}{$key};
- } else {
- return undef;
- }
-}
-
-
-sub get_many {
- my $me = shift;
- my @ret = ();
- my $f = $me->{attribs};
-
- foreach my $key (@_) {
- push @ret, exists $f->{$key} ? $f->{$key} : undef;
- }
-
- return wantarray ? @ret : [EMAIL PROTECTED] ;
-}
-
-sub del {
- my ($me, $key) = @_;
- croak "Too few args" if @_ < 2;
- croak "Too many args" if @_ > 2;
-
- delete $me->{attribs}{$key};
-}
-
-sub has {
- my ($me, $key) = @_;
- croak "Too few args!" if @_ < 2;
- croak "Too many args!" if @_ > 2;
-
- return exists $me->{attribs}{$key};
-}
-
-
-1;
-__END__
-=head1 NAME
-
-Haver::Server::Entity - Base class for Users and Channels.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Entity;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Entity extends L<Haver::Base>.
-
-=head1 CONSTRUCTOR
-
-The parameter C<-id> is required.
-
-=head1 METHODS
-
-Haver::Server::Entity supports the following methods:
-
-
-=head2 id(Z<>)
-
-Returns the id (name) of the object.
-
-=head2 set($key, $val)
-
-Set the attribute C<$key> to C<$val> on the current object.
-
-=head2 get($key)
-
-Returns the value of the attribute C<$key>.
-
-=head2 get_many(@keys)
-
-In scalar context, returns an arrayref of values of each attribute
-in C<@keys>. In list context, returns a list of the same.
-
-=head2 del($key)
-
-Remove the attribute C<$key> and return it.
-
-=head2 has($key)
-
-Returns true if the attribute C<$key> is set, false otherwise.
-
-=head1 VIRTUAL METHODS
-
-The follow methods may be implemented by subclasses:
-
-=head2 namespace(Z<>)
-
-Returns the namespace of the object.
-
-This method B<must> be implemented by subclasses.
-
-
-=head1 FIELDS
-
-The field C<attribs> is reserved.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<Haver::Server::Entity::Avatar>, L<Haver::Server::Entity::Room>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2004, 2005 by Dylan Hardison
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Deleted: trunk/main/server/lib/Haver/Server/Events.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Events.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Events.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,42 +0,0 @@
-# vim: set ft=perl ts=4 sw=4:
-# Haver::Server::Event - Base class for
-#
-# Copyright (C) 2004 Dylan William Hardison.
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Server::Events;
-use strict;
-use warnings;
-
-our $VERSION = '0.01';
-
-sub new {
- my $me = shift->SUPER::new(@_);
-
- if (ref($me) eq __PACKAGE__) {
- croak __PACKAGE__ . " is a virtual base class!";
- }
-}
-
-sub setup {
- my $me = shift;
-
- $me->provide_prefix('on_', $me->states);
- $me->provide_prefix_both('evt_', $me->events);
-}
-
-
-
-1;
Added: trunk/main/server/lib/Haver/Server/Messages/Login.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Messages/Login.pm 2005-03-27
21:52:46 UTC (rev 665)
+++ trunk/main/server/lib/Haver/Server/Messages/Login.pm 2005-04-10
08:42:53 UTC (rev 666)
@@ -0,0 +1,214 @@
+# vim: set ft=perl ts=4 sw=4:
+# Commands::Basic - description
+#
+# Copyright (C) 2004 Dylan William Hardison.
+#
+# This module is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this module; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+package Haver::Server::Events::Connection;
+use strict;
+use warnings;
+
+use Haver::Formats qw( :duration );
+use Digest::SHA1 qw( sha1_base64 );
+use Haver::Server::Registry qw( $Registry );
+use base 'Haver::Server::Commands';
+
+our $VERSION = '0.01';
+
+sub states {
+ qw(
+ want
+ accept
+ auth
+ unknown_cmd
+ init
+ timeout
+ );
+}
+
+sub events {
+ qw(
+ HAVER
+ IDENT
+ CANT
+ AUTH
+ AUTH:PASS
+ );
+}
+
+sub evt_HAVER {
+ my ($me, $kernel, $heap, $args) = @_[OBJECT, KERNEL, HEAP, ARG0];
+ my $client = $args->[0];
+
+ if (exists $me->{version}) {
+ $kernel->yield('oops', 'repeat', ['HAVER']);
+ return;
+ }
+
+ eval {
+ $heap->{client}->put(['HAVER',
"Haver::Server/$Haver::Server::VERSION"]);
+ };
+ $me->{version} = $client;
+ $kernel->yield('want', 'IDENT');
+}
+
+sub evt_IDENT {
+ my ($me, $kernel, $heap, $args) = @_[OBJECT, KERNEL, HEAP, ARG0];
+ my ($id, $ns) = @$args;
+
+ $ns ||= 'user';
+
+ # This may only be called once.
+ if ($me->{did}{IDENT}++) {
+ $kernel->yield('oops', "repeat", ['IDENT']);
+ return;
+ }
+
+ # We don't support other types of clients right now.
+ if ($ns ne 'user') {
+ $kernel->yield('fail', 'IDENT', 'unsupported.ns', [$ns]);
+ $kernel->yield('want', 'IDENT');
+ return;
+ }
+
+ # Make sure it's a valid id.
+ if (not Haver::Server::Object->is_valid_id($id)) {
+ $kernel->yield('fail', 'IDENT', 'syntax.id', [$id]);
+ $kernel->yield('want', 'IDENT');
+ return;
+ }
+
+ # users arn't allowed to have names that begin with
+ # & or @ in them.
+ if ($ns eq 'user' and ($id =~ /^&/ or $id =~ /@/)) {
+ $kernel->yield('fail', 'IDENT', 'reserved.id', [$id]);
+ $kernel->yield('want', 'IDENT');
+ return;
+ }
+
+ # Check if we already have a user by that name.
+ if ($Registry->contains('user', $id)) {
+ $kernel->yield('fail', 'IDENT', 'used.id', [$id]);
+ $kernel->yield('want', 'IDENT');
+ return;
+ }
+
+ my $user = new Haver::Server::Object::User (
+ id => $id,
+ wheel => $heap->{client},
+ sid => $_[SESSION]->ID,
+ );
+ $user->set (
+ Client => $heap->{version},
+ Rank => 0,
+ Role => 'User',
+ _info => [qw( Rank Role Client IP Login Idle )],
+ );
+
+ $kernel->yield('accept', $id, $user);
+}
+
+sub evt_AUTH {
+ my ($me, $kernel, $heap, $args) = @_[OBJECT, KERNEL, HEAP, ARG0];
+ my $method = $args->[0];
+
+ if ($me->{did}{AUTH}++) {
+ $kernel->yield('oops', 'repeat', ['AUTH']);
+ return;
+ }
+
+ if ($method eq 'PASS') {
+ $kernel->yield('want', 'AUTH:PASS');
+ } else {
+ $kernel->yield('fail', 'AUTH', 'unknown.method', [$method]);
+ $kernel->yield('want', 'IDENT');
+ }
+}
+
+sub evt_AUTH_PASS {
+ my ($me, $kernel, $heap, $args) = @_[OBJECT, KERNEL, HEAP, ARG0];
+ my ($pass) = @$args;
+ my $user = delete $heap->{user};
+ my $id = delete $heap->{uid};
+
+ if ($heap->{did}{'AUTH:PASS'}++) {
+ $kernel->yield('oops', 'repeat', ['AUTH:PASS']);
+ return;
+ }
+
+ if ($pass eq $user->get('.password')) {
+ $kernel->yield('accept');
+ } else {
+ $kernel->yield('fail', 'AUTH:PASS', 'nomatch.passhash', []);
+ $kernel->yield('bye', 'monkeys');
+ }
+}
+
+#-------------------------------- Events
--------------------------------------#
+
+sub on_init {
+ my ($me, $kernel, $heap) = @_[OBJECT, KERNEL, HEAP];
+
+ $me->{timeout} = $kernel->alarm_set('timeout', time + (60 * 3));
+}
+
+sub on_timeout {
+ my ($kernel, $heap) = @_[KERNEL, HEAP];
+
+ delete $heap->{client};
+ $kernel->yield('shutdown');
+}
+
+sub on_want {
+ my ($kernel, $heap, $want) = @_[KERNEL, HEAP, ARG0];
+
+ delete $me->{did}{$want};
+ $heap->{client}->put(['WANT', $want]);
+}
+
+sub since {
+ my ($then, $now) = @_;
+
+ $now ||= time;
+ format_duration($now - $then);
+}
+
+sub on_accept {
+ my ($me, $kernel, $heap, $uid, $user) = @_[OBJECT, KERNEL, HEAP, ARG0,
ARG1];
+
+ $kernel->alarm_remove(delete $me->{timeout});
+
+ $Registry->add($user);
+ my $addr = join('.', (split(/\./, $heap->{address}))[0,1,2]) .
'.*';
+ my $login_time = time;
+
+ $user->set(
+ IP => $addr,
+ Login => sub {
+ since($login_time);
+ },
+ _lastmsg => $login_time,
+ Idle => sub {
+ my ($u) = @_;
+ since($u->get('_lastmsg'));
+ },
+ '.IP' => $heap->{address},
+ );
+
+ $kernel->call($_[SESSION], 'ready', $uid, $user);
+ $heap->{client}->put(['ACCEPT', $uid]);
+}
+
+1;
Added: trunk/main/server/lib/Haver/Server/Messages.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Messages.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Messages.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -0,0 +1,42 @@
+# vim: set ft=perl ts=4 sw=4:
+# Haver::Server::Event - Base class for
+#
+# Copyright (C) 2004 Dylan William Hardison.
+#
+# This module is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this module; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+package Haver::Server::Messages;
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+sub new {
+ my $me = shift->SUPER::new(@_);
+
+ if (ref($me) eq __PACKAGE__) {
+ croak __PACKAGE__ . " is a virtual base class!";
+ }
+}
+
+sub setup {
+ my $me = shift;
+
+ $me->provide_prefix('on_', $me->states);
+ $me->provide_prefix_both('evt_', $me->events);
+}
+
+
+
+1;
Deleted: trunk/main/server/lib/Haver/Server/Plugin.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Plugin.pm 2005-03-27 21:52:46 UTC
(rev 665)
+++ trunk/main/server/lib/Haver/Server/Plugin.pm 2005-04-10 08:42:53 UTC
(rev 666)
@@ -1,144 +0,0 @@
-# vim: set ft=perl ts=4 sw=4 expandtab ai si sta tw=104:
-# Haver::Server::Commands - description
-#
-# Copyright (C) 2004 Dylan William Hardison.
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Server::Plugin;
-use strict;
-use warnings;
-use Carp;
-use base 'Haver::Base';
-
-use Haver::Preprocessor;
-
-our $VERSION = '0.01';
-
-sub new {
- my $me = shift->SUPER::new(@_);
-
- if (ref($me) eq __PACKAGE__) {
- croak __PACKAGE__ . " is a virtual base class!";
- }
-}
-
-sub initialize {
- my ($me) = @_;
-
- $me->{provided} = [];
- $me->{registry} = {};
-
- $me->setup();
-
- if ($me->{load}) {
- $me->load();
- }
-}
-
-sub setup {
- my ($me) = @_;
-
-}
-
-sub provide {
- my $me = shift;
-
- foreach my $thing (@_) {
- # ASSERT: $thing eq 'ARRAY' or not ref $thing;
- push(@{ $me->{provided} }, ref $thing ? $thing : [ $thing ]);
- }
-}
-
-sub provide_prefix {
- my $me = shift;
- my $prefix = shift;
-
- $me->provide (
- map { [ $_, $prefix . $_ ] } @_
- );
-}
-
-sub provide_prefix_both {
- my $me = shift;
- my $prefix = shift;
-
- $me->provide (
- map [ $prefix . $_, $prefix . $_ ], @_
- );
-}
-
-sub provided {
- my $me = shift;
- return @{ $me->{provided} };
-}
-
-sub load {
- my ($me) = @_;
-
- # $p = ['state', 'method']
- # OR $p = ['state']
- foreach my $p ($me->provided) {
- $me->register(@$p);
- }
-}
-
-sub unload {
- my ($me) = @_;
-
- foreach my $state ($me->registered) {
- $me->unregister($state);
- }
-}
-
-sub registered {
- my $me = shift;
- return keys %{ $me->{registry} };
-}
-
-sub register {
- my ($me, $state, $method) = @_;
- my $kernel = $POE::Kernel::poe_kernel;
-
- if (exists $me->{registry}{$state}) {
- croak "Can't register $state, already registered!";
- }
-
- $me->{registry}{$state} = 1;
- $kernel->state(
- $state,
- not($me->{package}) ? $me : ref($me),
- $method,
- );
-}
-
-sub unregister {
- my ($this, $state) = @_;
- my $kernel = $POE::Kernel::poe_kernel;
-
- if (not exists $me->{registry}{$state}) {
- croak "Can't unregister $state, it is not registered!";
- }
-
- delete $me->{registry}{$state};
- $kernel->state($state);
-}
-
-sub finalize {
- my ($me) = @_;
-
- $me->unload();
-}
-
-1;
Modified: trunk/main/server/lib/Haver/Server.pm
===================================================================
--- trunk/main/server/lib/Haver/Server.pm 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/main/server/lib/Haver/Server.pm 2005-04-10 08:42:53 UTC (rev
666)
@@ -20,7 +20,7 @@
use strict;
use warnings;
-our $VERSION = 0.0705;
+our $VERSION = 0.08;
Added: trunk/misc/poe-session-plugin/Build.PL
===================================================================
--- trunk/misc/poe-session-plugin/Build.PL 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/misc/poe-session-plugin/Build.PL 2005-04-10 08:42:53 UTC (rev
666)
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+require 5.008;
+use Module::Build;
+my $build = Module::Build->new(
+ module_name => 'POE::Session::Plugin',
+ dist_version_from => 'lib/POE/Session/Plugin.pm',
+ dist_author => 'Dylan William Hardison <[EMAIL PROTECTED]>',
+ dist_abstract => 'Base class for modules that extend POE::Session
at runtime.',
+ license => 'gpl',
+ requires => {
+ 'perl' => '5.8.0',
+ POE => 0.27,
+
+ },
+ create_makefile_pl => 'passthrough',
+ script_files => [glob('bin/*.pl')],
+);
+$build->create_build_script();
Property changes on: trunk/misc/poe-session-plugin/Build.PL
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/misc/poe-session-plugin/COPYING
===================================================================
--- trunk/misc/poe-session-plugin/COPYING 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/misc/poe-session-plugin/COPYING 2005-04-10 08:42:53 UTC (rev
666)
@@ -0,0 +1,326 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is intended
+to guarantee your freedom to share and change free software--to make sure the
+software is free for all its users. This General Public License applies to
+most of the Free Software Foundation's software and to any other program whose
+authors commit to using it. (Some other Free Software Foundation software is
+covered by the GNU Library General Public License instead.) You can apply it
+to your programs, too.
+
+ When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the freedom to
+distribute copies of free software (and charge for this service if you wish),
+that you receive source code or can get it if you want it, that you can change
+the software or use pieces of it in new free programs; and that you know you
+can do these things.
+
+ To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These
+restrictions translate to certain responsibilities for you if you distribute
+copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether gratis or
+for a fee, you must give the recipients all the rights that you have. You
+must make sure that they, too, receive or can get the source code. And you
+must show them these terms so they know their rights.
+
+ We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients to
+know that what they have is not the original, so that any problems introduced
+by others will not reflect on the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must be licensed for
+everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and modification
+follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms of
+this General Public License. The "Program", below, refers to any such program
+or work, and a "work based on the Program" means either the Program or any
+derivative work under copyright law: that is to say, a work containing the
+Program or a portion of it, either verbatim or with modifications and/or
+translated into another language. (Hereinafter, translation is included
+without limitation in the term "modification".) Each licensee is addressed as
+"you".
+
+Activities other than copying, distribution and modification are not covered
+by this License; they are outside its scope. The act of running the Program
+is not restricted, and the output from the Program is covered only if its
+contents constitute a work based on the Program (independent of having been
+made by running the Program). Whether that is true depends on what the
+Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's source code
+as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may
+at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion of it,
+thus forming a work based on the Program, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that you
+also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be reasonably
+considered independent and separate works in themselves, then this License,
+and its terms, do not apply to those sections when you distribute them as
+separate works. But when you distribute the same sections as part of a whole
+which is a work based on the Program, the distribution of the whole must be on
+the terms of this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your
+rights to work written entirely by you; rather, the intent is to exercise the
+right to control the distribution of derivative or collective works based on
+the Program.
+
+In addition, mere aggregation of another work not based on the Program with
+the Program (or with a work based on the Program) on a volume of a storage or
+distribution medium does not bring the other work under the scope of this
+License.
+
+ 3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1 and
+2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making
+modifications to it. For an executable work, complete source code means all
+the source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and
+installation of the executable. However, as a special exception, the source
+code distributed need not include anything that is normally distributed (in
+either source or binary form) with the major components (compiler, kernel, and
+so on) of the operating system on which the executable runs, unless that
+component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to
+copy from a designated place, then offering equivalent access to copy the
+source code from the same place counts as distribution of the source code,
+even though third parties are not compelled to copy the source along with the
+object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy, modify,
+sublicense or distribute the Program is void, and will automatically terminate
+your rights under this License. However, parties who have received copies, or
+rights, from you under this License will not have their licenses terminated so
+long as such parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not signed
+it. However, nothing else grants you permission to modify or distribute the
+Program or its derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or distributing the
+Program (or any work based on the Program), you indicate your acceptance of
+this License to do so, and all its terms and conditions for copying,
+distributing or modifying the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these terms and
+conditions. You may not impose any further restrictions on the recipients'
+exercise of the rights granted herein. You are not responsible for enforcing
+compliance by third parties to this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or otherwise)
+that contradict the conditions of this License, they do not excuse you from
+the conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In
+such case, this License incorporates the limitation as if written in the body
+of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions of
+the General Public License from time to time. Such new versions will be
+similar in spirit to the present version, but may differ in detail to address
+new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any later
+version", you have the option of following the terms and conditions either of
+that version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of this License,
+you may choose any version ever published by the Free Software Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we sometimes make
+exceptions for this. Our decision will be guided by the two goals of
+preserving the free status of all derivatives of our free software and of
+promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
+PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO
+LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
+THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest possible
+use to the public, the best way to achieve this is to make it free software
+which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey the
+exclusion of warranty; and each file should have at least the "copyright" line
+and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it
+starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may be
+called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General Public
+License instead of this License.
Added: trunk/misc/poe-session-plugin/MANIFEST.SKIP
===================================================================
--- trunk/misc/poe-session-plugin/MANIFEST.SKIP 2005-03-27 21:52:46 UTC (rev
665)
+++ trunk/misc/poe-session-plugin/MANIFEST.SKIP 2005-04-10 08:42:53 UTC (rev
666)
@@ -0,0 +1,11 @@
+\.old$
+\.bak
+store
+blib
+_build
+^Build$
+^\.#
+\.svn
+\.tar\.gz$
+^data
+^conf
Added: trunk/misc/poe-session-plugin/lib/POE/Session/Plugin/Loader.pm
===================================================================
--- trunk/misc/poe-session-plugin/lib/POE/Session/Plugin/Loader.pm
2005-03-27 21:52:46 UTC (rev 665)
+++ trunk/misc/poe-session-plugin/lib/POE/Session/Plugin/Loader.pm
2005-04-10 08:42:53 UTC (rev 666)
@@ -0,0 +1,88 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package POE::Session::Plugin::Loader;
+use strict;
+use warnings;
+
+our $VERSION = '0.04';
+
+sub new {
+ my $class = shift;
+ my $self = {
+ plugins => {},
+ };
+ bless $self, $class;
+}
+
+sub load {
+ my ($self, $class, @args) = @_;
+ my $object = $class->new(@args);
+ $object->load;
+ $self->{plugins}{$class} = $object;
+}
+
+sub unload {
+ my ($self, $class) = @_;
+ my $object = delete $self->{plugins}{$class};
+ $object->unload;
+}
+
+
+1;
+__END__
+=head1 NAME
+
+POE::Session::Plugin::Loader - description
+
+=head1 SYNOPSIS
+
+ use POE::Session::Plugin::Loader;
+ # Small code example.
+
+=head1 DESCRIPTION
+
+FIXME
+
+=head1 CONSTRUCTOR
+
+List required parameters for new().
+
+=head1 METHODS
+
+This class implements the following methods:
+
+=head2 method1(Z<>)
+
+...
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<http://www.haverdev.org/>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Added: trunk/misc/poe-session-plugin/lib/POE/Session/Plugin.pm
===================================================================
--- trunk/misc/poe-session-plugin/lib/POE/Session/Plugin.pm 2005-03-27
21:52:46 UTC (rev 665)
+++ trunk/misc/poe-session-plugin/lib/POE/Session/Plugin.pm 2005-04-10
08:42:53 UTC (rev 666)
@@ -0,0 +1,82 @@
+package POE::Session::Plugin;
+use strict;
+use warnings;
+use Carp;
+
+our $VERSION = '0.04';
+our $Kernel = $POE::Kernel::poe_kernel;
+
+sub new {
+ my $class = shift;
+ my $self = {
+ # I only prefix these with underscores because I am paranoid of
+ # subclasses clobbering them. :)
+ _provided_states => [ ],
+ _defined_states => { },
+ };
+ bless $self, $class;
+ $self->setup(@_);
+ return $self;
+}
+
+sub setup { }
+
+sub kernel {
+ my ($self, $kernel) = @_;
+ $Kernel = $kernel;
+}
+
+sub provide {
+ my ($self, $state, $method) = @_;
+ push @{ $self->{_provided_states} }, [ $state, $method ];
+}
+
+sub provided_states {
+ my $self = shift;
+ @{ $self->{_provided_states} };
+}
+
+sub defined_states {
+ my $self = shift;
+ keys %{ $self->{_defined_states} };
+}
+
+# Load all provided states.
+sub load {
+ my $self = shift;
+ map {
+ $self->define(@$_)
+ } $self->provided_states;
+}
+
+# Unload all *defined* states.
+sub unload {
+ my $self = shift;
+ map {
+ $self->undefine($_)
+ } $self->defined_states;
+}
+
+sub define {
+ my ($self, $state, $method) = @_;
+ $method ||= $state;
+
+ croak "State $state defined; can't redefine"
+ if exists $self->{_defined_states}{$state};
+ $self->{_defined_states}{$state} = $method;
+ $Kernel->state($state,
+ $self->{package} ? ref $self : $self,
+ $method
+ );
+}
+
+sub undefine {
+ my ($self, $state) = @_;
+
+ croak "State $state not defined; can't undefine"
+ unless exists $self->{_defined_states}{$state};
+ delete $self->{_defined_states}{$state};
+ $Kernel->state($state);
+}
+
+1;
Property changes on: trunk/web/clients/javer
___________________________________________________________________
Name: svn:ignore
- .*.valid
+ .*.valid
*.html