--- googlecode.com/svn/trunk/Meteor/Message.pm 2006/11/20 17:59:30 3 +++ googlecode.com/svn/trunk/Meteor/Message.pm 2006/12/08 16:52:58 9 @@ -1,116 +1,116 @@ -#!/usr/bin/perl -w -############################################################################### -# Meteor -# An HTTP server for the 2.0 web -# Copyright (c) 2006 contributing authors -# -# Subscriber.pm -# -# Description: -# Meteor message object -# -############################################################################### -# -# 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 -# -# For more information visit www.meteorserver.org -# -############################################################################### - -package Meteor::Message; -############################################################################### -# Configuration -############################################################################### - - use strict; - -############################################################################### -# Factory methods -############################################################################### -sub new { - # - # Create a new empty instance - # - my $class=shift; - - my $obj={}; - - bless($obj,$class); -} - -sub newWithID { - # - # new instance from new server connection - # - my $self=shift->new(); - my $id=shift; - my $text=shift || ''; - - $self->{'timestamp'}=time; - $self->{'id'}=$id; - $self->{'text'}=$text; - - &::syslog('debug',"New message $id"); - - $self; -} - -############################################################################### -# Instance methods -############################################################################### -sub setText { - my $self=shift; - my $text=shift || ''; - - $self->{'text'}=$text; -} - -sub text { - shift->{'text'}; -} - -sub id { - shift->{'id'}; -} - -sub timestamp { - shift->{'timestamp'}; -} - -sub message { - my $self=shift; - - my $msg=$::CONF{'MessageTemplate'}; - - $msg=~s/~([^~]*)~/ - if(!defined($1) || $1 eq '') - { - '~'; - } - elsif(exists($self->{$1})) - { - $self->{$1}; - } - else - { - ''; - } - /gex; - - $msg; -} - -1; +#!/usr/bin/perl -w +############################################################################### +# Meteor +# An HTTP server for the 2.0 web +# Copyright (c) 2006 contributing authors +# +# Subscriber.pm +# +# Description: +# Meteor message object +# +############################################################################### +# +# 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 +# +# For more information visit www.meteorserver.org +# +############################################################################### + +package Meteor::Message; +############################################################################### +# Configuration +############################################################################### + + use strict; + +############################################################################### +# Factory methods +############################################################################### +sub new { + # + # Create a new empty instance + # + my $class=shift; + + my $obj={}; + + bless($obj,$class); +} + +sub newWithID { + # + # new instance from new server connection + # + my $self=shift->new(); + my $id=shift; + my $text=shift || ''; + + $self->{'timestamp'}=time; + $self->{'id'}=$id; + $self->{'text'}=$text; + + &::syslog('debug',"New message $id"); + + $self; +} + +############################################################################### +# Instance methods +############################################################################### +sub setText { + my $self=shift; + my $text=shift || ''; + + $self->{'text'}=$text; +} + +sub text { + shift->{'text'}; +} + +sub id { + shift->{'id'}; +} + +sub timestamp { + shift->{'timestamp'}; +} + +sub message { + my $self=shift; + + my $msg=$::CONF{'MessageTemplate'}; + + $msg=~s/~([^~]*)~/ + if(!defined($1) || $1 eq '') + { + '~'; + } + elsif(exists($self->{$1})) + { + $self->{$1}; + } + else + { + ''; + } + /gex; + + $msg; +} + +1; ############################################################################EOF \ No newline at end of file