/[meteor]/googlecode.com/svn/trunk/Meteor/Message.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /googlecode.com/svn/trunk/Meteor/Message.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by andrew.betts, Fri Dec 8 16:52:58 2006 UTC revision 11 by knops.gerd, Thu Dec 14 16:29:42 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  ###############################################################################  ###############################################################################
3  #   Meteor  #   Meteor
4  #   An HTTP server for the 2.0 web  #   An HTTP server for the 2.0 web
5  #   Copyright (c) 2006 contributing authors  #   Copyright (c) 2006 contributing authors
6  #  #
7  #   Subscriber.pm  #   Subscriber.pm
8  #  #
9  #       Description:  #       Description:
10  #       Meteor message object  #       Meteor message object
11  #  #
12  ###############################################################################  ###############################################################################
13  #  #
14  #   This program is free software; you can redistribute it and/or modify it  #   This program is free software; you can redistribute it and/or modify it
15  #   under the terms of the GNU General Public License as published by the Free  #   under the terms of the GNU General Public License as published by the Free
16  #   Software Foundation; either version 2 of the License, or (at your option)  #   Software Foundation; either version 2 of the License, or (at your option)
17  #   any later version.  #   any later version.
18  #  #
19  #   This program is distributed in the hope that it will be useful, but WITHOUT  #   This program is distributed in the hope that it will be useful, but WITHOUT
20  #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  #   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  #   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for  #   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22  #   more details.  #   more details.
23  #  #
24  #   You should have received a copy of the GNU General Public License along  #   You should have received a copy of the GNU General Public License along
25  #   with this program; if not, write to the Free Software Foundation, Inc.,  #   with this program; if not, write to the Free Software Foundation, Inc.,
26  #   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  #   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  #  #
28  #   For more information visit www.meteorserver.org  #   For more information visit www.meteorserver.org
29  #  #
30  ###############################################################################  ###############################################################################
31    
32  package Meteor::Message;  package Meteor::Message;
33  ###############################################################################  ###############################################################################
34  # Configuration  # Configuration
35  ###############################################################################  ###############################################################################
36                    
37          use strict;          use strict;
38    
39  ###############################################################################  ###############################################################################
40  # Factory methods  # Factory methods
41  ###############################################################################  ###############################################################################
42  sub new {  sub new {
43          #          #
44          # Create a new empty instance          # Create a new empty instance
45          #          #
46          my $class=shift;          my $class=shift;
47                    
48          my $obj={};          my $obj={};
49                    
50          bless($obj,$class);          bless($obj,$class);
51  }  }
52                    
53  sub newWithID {  sub newWithID {
54          #          #
55          # new instance from new server connection          # new instance from new server connection
56          #          #
57          my $self=shift->new();          my $self=shift->new();
58          my $id=shift;          my $id=shift;
59          my $text=shift || '';          my $text=shift || '';
60                    
61          $self->{'timestamp'}=time;          $self->{'timestamp'}=time;
62          $self->{'id'}=$id;          $self->{'id'}=$id;
63          $self->{'text'}=$text;          $self->{'text'}=$text;
64                    
65          &::syslog('debug',"New message $id");          &::syslog('debug',"New message $id");
66                    
67          $self;          $self;
68  }  }
69    
70  ###############################################################################  ###############################################################################
71  # Instance methods  # Instance methods
72  ###############################################################################  ###############################################################################
73  sub setText {  sub setText {
74          my $self=shift;          my $self=shift;
75          my $text=shift || '';          my $text=shift || '';
76                    
77          $self->{'text'}=$text;          $self->{'text'}=$text;
78  }  }
79    
80  sub text {  sub text {
81          shift->{'text'};          shift->{'text'};
82  }  }
83    
84  sub id {  sub id {
85          shift->{'id'};          shift->{'id'};
86  }  }
87    
88  sub timestamp {  sub timestamp {
89          shift->{'timestamp'};          shift->{'timestamp'};
90  }  }
91    
92  sub message {  sub message {
93          my $self=shift;          my $self=shift;
94                    
95          my $msg=$::CONF{'MessageTemplate'};          my $msg=$::CONF{'MessageTemplate'};
96                    
97          $msg=~s/~([^~]*)~/          $msg=~s/~([^~]*)~/
98                  if(!defined($1) || $1 eq '')                  if(!defined($1) || $1 eq '')
99                  {                  {
100                          '~';                          '~';
101                  }                  }
102                  elsif(exists($self->{$1}))                  elsif(exists($self->{$1}))
103                  {                  {
104                          $self->{$1};                          $self->{$1};
105                  }                  }
106                  else                  else
107                  {                  {
108                          '';                          '';
109                  }                  }
110          /gex;          /gex;
111                    
112          $msg;          $msg;
113  }  }
114    
115  1;  1;
116  ############################################################################EOF  ############################################################################EOF

Legend:
Removed from v.9  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26