File Coverage

blib/lib/Net/ICal/Attendee.pm
Criterion Covered Total %
statement 12 25 48.0
branch 0 6 0.0
condition n/a
subroutine 4 7 57.1
pod 2 2 100.0
total 18 40 45.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2             # -*- Mode: perl -*-
3             #======================================================================
4             #
5             # This package is free software and is provided "as is" without express
6             # or implied warranty. It may be used, redistributed and/or modified
7             # under the same terms as perl itself. ( Either the Artistic License or the
8             # GPL. )
9             #
10             # $Id: Attendee.pm,v 1.20 2001/08/04 04:59:36 srl Exp $
11             #
12             # (C) COPYRIGHT 2000, Reefknot developers, including:
13             # Eric Busboom, http://www.softwarestudio.org
14             #
15             # See the AUTHORS file included in the distribution for a full list.
16             #======================================================================
17              
18             =head1 NAME
19              
20             Net::ICal::Attendee -- represents an attendee or organizer of a meeting
21              
22             =cut
23              
24             package Net::ICal::Attendee;
25 1     1   6 use strict;
  1         1  
  1         43  
26 1     1   6 use Net::ICal::Util qw(:all);
  1         2  
  1         143  
27              
28 1     1   4 use UNIVERSAL;
  1         2  
  1         4  
29 1     1   20 use base qw(Net::ICal::Property);
  1         1  
  1         478  
30              
31             =head1 SYNOPSIS
32              
33             use Net::ICal;
34             $a = new Net::ICal::Attendee('mailto:alice@example.com');
35             $a = new Net::ICal::Attendee('mailto:alice@example.com',
36             cn => 'Alice Anders',
37             role => 'REQ-PARTICIPANT');
38              
39             =head1 DESCRIPTION
40              
41             Net::ICal::Attendee provides an interface to manipulate attendee data
42             in iCalendar (RFC2445) format.
43              
44             =head1 METHODS
45              
46             =head2 new($calid, $hash)
47              
48             New will take a string and optional key-value pairs. The string is the
49             calender user address of the Attendee (usually a mailto uri).
50              
51             $a = new Net::ICal::Attendee('mailto:alice@example.com');
52             $a = new Net::ICal::Attendee('mailto:alice@example.com',
53             cn => 'Alice Anders',
54             role => 'REQ-PARTICIPANT');
55              
56             Meaningful hash keys are:
57              
58              
59             =over 4
60              
61             =item * cn - common name - the name most people use for this attendee.
62              
63             =item * cutype - type of user this attendee represents. Meaningful
64             values are INDIVIDUAL, GROUP, ROOM, RESOURCE, UNKNOWN.
65              
66             =item * delegated_from - the user who delegated a meeting request to this
67             attendee.
68              
69             =item * delegated_to - the user who's been delegated to handle meeting
70             requests for this attendee.
71              
72             =item * dir - a URI that gives a directory entry associated with the user.
73              
74             =item * partstat - whether this attendee will actually be at a meeting.
75             Meaningful values are NEEDS-ACTION, ACCEPTED, DECLINED, TENTATIVE,
76             DELEGATED, COMPLETED, or IN-PROCESS.
77              
78             =item * role - how this attendee will participate in a meeting.
79             Meaningful values are REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT,
80             and CHAIR.
81              
82             =item * rsvp - should the user send back a response to this request?
83             Valid values are TRUE and FALSE. FALSE is the default.
84              
85             =item * sent_by - specifies a user who is acting on behalf of this
86             attendee; for example, a secretary for his/her boss, or a parent for his/her
87             10-year-old.
88              
89             =back
90              
91             To understand more about the uses for each of these properties,
92             read the source for this module and and look at RFC2445.
93              
94             =begin testing
95             #generic stuff
96             use lib "./lib";
97             use Net::ICal::Attendee;
98             $mail = 'mailto:alice@example.com';
99              
100              
101             #start of tests
102             ok(my $a = Net::ICal::Attendee->new ($mail), "Simple attendee creation");
103             ok(not(Net::ICal::Attendee->new ("xyzzy")), "Nonsense email address");
104              
105             =end testing
106             =cut
107              
108             sub new {
109 0     0 1   my ($class, $value, %args) = @_;
110            
111 0           $args{content} = $value;
112              
113             #TODO: rsvp should default to false; see rfc2445 4.2.17 and SF bug 424101
114              
115 0           my $self = _create ($class, %args);
116              
117 0 0         return undef unless $self;
118              
119 0 0         return undef unless $self->validate;
120            
121 0           return $self;
122             }
123              
124             =pod
125              
126             =head2 validate
127              
128             Returns 1 for valid attendee data, undef for invalid.
129              
130             =for testing
131             ok($a->validate, "Simple validation");
132              
133             =cut
134              
135             sub validate {
136 0     0 1   my ($self) = @_;
137              
138             # TODO: write this routine! SF bug 435998
139              
140 0 0         unless ($self->content =~ /^mailto:.*\@/i) {
141             # TODO: make this work
142             #add_validation_error($self, "Attendee must begin with 'mailto:'");
143 0           return undef;
144             }
145              
146 0           return 1;
147             }
148              
149             sub _create {
150 0     0     my ($class, %args) = @_;
151              
152 0           my $map = {
153             content => { # RFC2445 4.8.4.1
154             type =>'volatile',
155             doc => 'the email address of this attendee',
156             value => undef,
157             },
158             cn => { # RFC2445 4.2.2
159             type => 'parameter',
160             doc => "'Common Name', the name most people use to address the user",
161             value => undef,
162             },
163             cutype => { # RFC2445 4.2.3
164             type => 'parameter',
165             doc => 'type of user this calid represents',
166             domain => 'enum',
167             options => [qw(INDIVIDUAL GROUP ROOM RESOURCE UNKNOWN)],
168             # This attendee may be a person, or it may be a group, or a place,
169             # or a resource (overhead projector, for example) or something else.
170             value => undef,
171             },
172             delegated_from => { # RFC2445 4.2.4
173             type => 'parameter',
174             doc => 'the user this request was delegated from',
175             value => undef,
176             # Someone's passing the buck to Attendee.
177             },
178             delegated_to => { # RFC2445 4.2.5
179             type => 'parameter',
180             doc => 'who Attendee is delegating this request to',
181             value => undef,
182             # Mmm, passing the buck to someone else.
183             },
184             dir => { # RFC2445 4.2.6
185             type => 'parameter',
186             doc => 'Directory entry associated with the user',
187             value => undef,
188             },
189             partstat => { # RFC2445 4.2.12
190             type => 'parameter',
191             doc => 'status of user-participation',
192             domain => 'enum',
193             options => [qw(NEEDS-ACTION ACCEPTED DECLINED TENTATIVE DELEGATED COMPLETED IN-PROCESS)],
194             value => undef,
195             # whether the user's actually going to be there.
196             },
197             role => { # RFC2445 4.2.16
198             type => 'parameter',
199             doc => 'how the user will participate in the meeting',
200             domain => 'enum',
201             options => [qw(REQ-PARTICIPANT OPT-PARTICIPANT NON-PARTICIPANT CHAIR)],
202             # is the Attendee required, requested, not-participating, or running
203             # the event?
204             value => undef,
205             },
206             rsvp => { # RFC2445 4.2.17
207             type => 'parameter',
208             doc => 'User needs to send back a reply to this',
209             domain => 'enum',
210             options => [qw(FALSE TRUE)],
211             value => undef,
212             },
213             sent_by => { # RFC2445 4.2.18
214             type => 'parameter',
215             doc => 'who responds on behalf of this Attendee',
216             # a secretary, for example.
217             value => undef,
218             },
219             };
220              
221 0           return $class->SUPER::new ('ATTENDEE', $map, %args);
222             }
223              
224             1;
225              
226             =head1 SEE ALSO
227              
228             More documentation pointers can be found in L.
229              
230             =cut