From 697761cc337aa77a47140c8df50ed84bc25e23f6 Mon Sep 17 00:00:00 2001 From: Hans Petter Date: Thu, 11 Sep 2003 22:04:44 +0000 Subject: Import new libical from mainline HEAD and make appropriate changes to Evolution. svn path=/trunk/; revision=22538 --- libical/src/Net-ICal-Libical/MANIFEST | 16 + libical/src/Net-ICal-Libical/Makefile.PL | 42 + libical/src/Net-ICal-Libical/README | 7 + .../src/Net-ICal-Libical/lib/Net/ICal/Libical.pm | 386 +++ .../lib/Net/ICal/Libical/Component.pm | 175 + .../lib/Net/ICal/Libical/Duration.pm | 160 + .../lib/Net/ICal/Libical/Period.pm | 359 ++ .../lib/Net/ICal/Libical/Property.pm | 173 + .../Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm | 468 +++ libical/src/Net-ICal-Libical/netical.i | 317 ++ libical/src/Net-ICal-Libical/netical_wrap.c | 3048 +++++++++++++++++ libical/src/Net-ICal-Libical/netical_wrap.doc | 393 +++ libical/src/Net-ICal-Libical/test-data/2446.mime | 3426 ++++++++++++++++++++ libical/src/Net-ICal-Libical/test-data/error | 58 + .../src/Net-ICal-Libical/test-data/mail-examples | 262 ++ libical/src/Net-ICal-Libical/test-data/no-error | 26 + libical/src/Net-ICal-Libical/test-data/rfc2445.ics | 321 ++ libical/src/Net-ICal-Libical/test-data/rfc2446.ics | 1004 ++++++ .../Net-ICal-Libical/test-data/single-with-error | 39 + libical/src/Net-ICal-Libical/test/component.pl | 106 + libical/src/Net-ICal-Libical/test/libical.pl | 94 + libical/src/Net-ICal-Libical/test/swig.pl | 29 + 22 files changed, 10909 insertions(+) create mode 100644 libical/src/Net-ICal-Libical/MANIFEST create mode 100644 libical/src/Net-ICal-Libical/Makefile.PL create mode 100644 libical/src/Net-ICal-Libical/README create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical.pm create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Property.pm create mode 100644 libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm create mode 100644 libical/src/Net-ICal-Libical/netical.i create mode 100644 libical/src/Net-ICal-Libical/netical_wrap.c create mode 100644 libical/src/Net-ICal-Libical/netical_wrap.doc create mode 100644 libical/src/Net-ICal-Libical/test-data/2446.mime create mode 100644 libical/src/Net-ICal-Libical/test-data/error create mode 100644 libical/src/Net-ICal-Libical/test-data/mail-examples create mode 100644 libical/src/Net-ICal-Libical/test-data/no-error create mode 100644 libical/src/Net-ICal-Libical/test-data/rfc2445.ics create mode 100644 libical/src/Net-ICal-Libical/test-data/rfc2446.ics create mode 100644 libical/src/Net-ICal-Libical/test-data/single-with-error create mode 100644 libical/src/Net-ICal-Libical/test/component.pl create mode 100755 libical/src/Net-ICal-Libical/test/libical.pl create mode 100755 libical/src/Net-ICal-Libical/test/swig.pl (limited to 'libical/src/Net-ICal-Libical') diff --git a/libical/src/Net-ICal-Libical/MANIFEST b/libical/src/Net-ICal-Libical/MANIFEST new file mode 100644 index 0000000000..1a6880e8b4 --- /dev/null +++ b/libical/src/Net-ICal-Libical/MANIFEST @@ -0,0 +1,16 @@ +MANIFEST +Makefile.PL +lib/Net/ICal/Libical.pm +netical.i +netical_wrap.c +netical_wrap.doc +test-data/2446.mime +test-data/error +test-data/mail-examples +test-data/no-error +test-data/rfc2445.ics +test-data/rfc2446.ics +test-data/single-with-error +test/example.pl +test/libical.pl +test/swig.pl diff --git a/libical/src/Net-ICal-Libical/Makefile.PL b/libical/src/Net-ICal-Libical/Makefile.PL new file mode 100644 index 0000000000..f46c61bc02 --- /dev/null +++ b/libical/src/Net-ICal-Libical/Makefile.PL @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# -*- Mode: perl -*- + +use ExtUtils::MakeMaker; +WriteMakefile( + 'MAKEFILE'=> 'Makefile', + 'VERSION_FROM' => 'lib/Net/ICal/Libical.pm', + 'NAME' => 'Net::ICal::Libical', + 'INC' => '-I../libical -I ../libicalss', + 'LIBS' => ['-L../libical/.libs -L../libicalss/.libs -lical -licalss -lm'], + 'OBJECT' => 'netical_wrap.o', # Object files + dist => { + COMPRESS =>'gzip', + SUFFIX =>'gz' + }, + + ); + +sub MY::top_targets +{ + my $self = shift; + + my $old = $self->MM::top_targets; + + return "all:: netical_wrap.o\n$old"; + +} + +sub MY::postamble +{ + + return <dict{TZID} +sub timezone(self,v=None): + + +# Represents the value and all parameters of an attendee +package Net::ICal::Libical::Attendee(Property): +@ISA = (Property); + +sub new{} + +# Methods for accessing enumerated parameters +sub cn {} +sub cutype {} +sub dir {} +sub delegated_from {} +sub delegated_to {} +sub language {} +sub member {} +sub partstat {} +sub role {} +sub rsvp {} +sub sent_by {} + + +package Net::ICal::Libical::Organizer; +@ISA = (Property) +# Methods for accessing enumerated parameters +sub cn{} +sub dir{} +sub language {} +sub sent_by {} + +package Net::ICal::Libical::Recurrence_Id; +@ISA= (Property) + +package Net::ICal::Libical::Attach; +@ISA= (Property) + +package Net::ICal::Libical::Event; +@ISA= (Component) + +sub component_type {} + +#"Returns a copy of the object." +sub clone {} + +#Sets or returns the value of the DTEND property. +#Usage: +#dtend(time_obj) # Set the value using a Time object +#dtend('19970101T123000Z') # Set the value as an iCalendar string +#dtend(982362522) # Set the value using seconds (time_t) +#dtend() # Return a Time +# +#If the dtend value is being set and duration() has a value, the +#duration property will be removed. +sub dtend{} + +#Sets or returns the value of the duration property. +#Usage: +#duration(dur_obj) # Set the value using a Duration object +#duration("P3DT12H") # Set value as an iCalendar string +#duration(3600) # Set duration using seconds +#duration() # Return a duration +# +#If the duration value is being set and dtend() has a value, the dtend +#property will be removed. +sub duration{} + +#Sets attendees or returns a list of Attendee objects. +sub attendees {} + +#Sets or gets the value of the ORGANIZER property. +#Usage: +#organizer(orgObj) # Set value using an organizer object +#organizer('MAILTO:jd@not.com') # Set value using a CAL-ADDRESS string +#organizer() # Return a CAL-ADDRESS string +sub organizer{} + +#"Sets or gets the SUMMARY value of the Event." +sub summary{} + +#Sets or gets the UID of the Event. +sub uid{} + +#Sets or gets the value for the RECURRENCE-ID property. +#Usage: +#Recurrence_id(recIdObj) # Set using a Recurrence_Id object +#Recurrence_id("19700801T133000") # Set using an iCalendar string +#Recurrence_id(8349873494) # Set using seconds from epoch +#Recurrence_id() # Return a Time +sub recurrence_id{} + +#Sets or gets the SEQUENCE value of the Event. +#Usage: +#sequence(1) # Set the value using an integer +#sequence('2') # Set the value using a string containing an integer +#sequence() # Return an integer +sub sequence{} + +#Sets or returns the value of the LAST-MODIFIED property. +#Usage: +#lastmodified(time_obj) # Set the value using a Time object +#lastmodified('19970101T123000Z')# Set using an iCalendar string +#lastmodified(982362522) # Set using seconds +#lastmodified() # Return a Time +sub lastmodified{} + + + +#Sets or returns the value of the CREATED property. +#Usage: +#created(time_obj) # Set the value using a Time object +#created('19970101T123000Z') # Set using an iCalendar string +#created(982362522) # Set using seconds +#created() # Return a Time +sub created {} + + +sub related_to{} +sub comment{} + +"Sets or returns the value of the DESCRIPTION property." + +sub description {} + +#Sets categories or returns a list of Attendee objects. +sub categories {} + +sub attach{} + +#Represents a set of event occurrences. This +#package controls a component's RRULE, EXRULE, RDATE and EXDATE +#properties and can produce from them a set of occurrences. +package Net::ICal::Libical::RecurrenceSet: + + +#Include a date or rule to the set. +#Use date= or pass in a +#Time instance to include a date. Included dates will add an +#RDATE property or will remove an EXDATE property of the same +#date. +#Use rule= or pass in a string to include a rule. Included +#rules with either add a RRULE property or remove an EXRULE +#property. + +sub include{} + +#Exclude date or rule to the set. +#Use date= or pass in a Time instance to exclude a +#date. Excluded dates will add an EXDATE property or will remove +#an RDATE property of the same date. +#Use rule= or pass in a string to exclude a rule. Excluded +#rules with either add an EXRULE property or remove an RRULE +#property. +sub exclude{} + +#Return 'count' occurrences as a tuple of Time instances. +sub occurrences{} + +package Net::ICal::Libical::Store; +sub new{} +sub path{} +sub mark{} +sub commit{} +sub addComponent{} +sub removeComponent{} +sub countComponents{} +sub select{} +sub clearSelect{} +sub fetch{} +sub fetchMatchK{} +sub modify{} +sub currentComponent{} +sub firstComponent{} +sub nextComponent{} + + +package Net::ICal::Libical::FileStore; +@ISA = (Store) +sub new{} +sub path{} +sub mark{} +sub commit{} +sub addComponent{} +sub removeComponent{} +sub countComponents{} +sub select{} +sub clearSelect{} +sub fetch{} +sub fetchMatchK{} +sub modify{} +sub currentComponent{} +sub firstComponent{} +sub nextComponent{} + + +1; diff --git a/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm new file mode 100644 index 0000000000..c25297c111 --- /dev/null +++ b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm @@ -0,0 +1,175 @@ +#!/usr/bin/perl +# -*- Mode: perl -*- +#====================================================================== +# FILE: Component.pm +# CREATOR: eric 1 Mar 01 +# +# DESCRIPTION: +# +# +# $Id$ +# $Locker$ +# +# (C) COPYRIGHT 2000, Eric Busboom, eric@softwarestudio.org +# +# This package is free software and is provided "as is" without express +# or implied warranty. It may be used, redistributed and/or modified +# under the same terms as perl itself. ( Either the Artistic License or the +# GPL. ) +# +# +#====================================================================== + + + +package Net::ICal::Libical::Component; +use Net::ICal::Libical; + +use strict; + +sub new{ + my $class = shift; + my $ical_str = shift; # Ical data in string form + my $self = {}; + + $self->{'comp_p'} = Net::ICal::Libical::icalparser_parse_string($ical_str); + + die "Can't parse string into component" if !$self->{'comp_p'}; + + bless $self, $class; +} + +sub new_from_ref { + my $class = shift; + my $r = shift; + my $self = {}; + + $self->{'comp_p'} = $r; + + bless $self, $class; +} + +# Destroy must call icalcomponent_free() if icalcomponent_get_parent() +# returns NULL +sub DESTROY { + my $self = shift; + + my $c = $self->{'comp_p'}; + + if($c && !Net::ICal::Libical::icalcomponent_get_parent($c)){ + Net::ICal::Libical::icalcomponent_free($c); + } + +} + +# Return an array of all properties of the given type +sub properties{ + + my $self = shift; + my $prop_name = shift; + + my @props; + + if(!$prop_name){ + $prop_name = 'ANY'; + } + + # To loop over properties + # $comp_p = $self->{'comp_p'} + # $p = icallangbind_get_first_property($comp_p,$prop_name) + # $p = icallangbind_get_next_property($comp_p,$prop_name) + + my $c = $self->{'comp_p'}; + my $p; + + for($p = Net::ICal::Libical::icallangbind_get_first_property($c,$prop_name); + $p; + $p = Net::ICal::Libical::icallangbind_get_next_property($c,$prop_name)){ + + my $d_string = Net::ICal::Libical::icallangbind_property_eval_string($p,"=>"); + my %dict = %{eval($d_string)}; + + $dict{'ref'} = $p; + + # Now, look at $dict{'value_type'} or $dict{'name'} to construct a + # derived class of Property. I'll do this later. + + my $prop; + + if($dict{'value_type'} eq 'DATE' or $dict{'value_type'} eq 'DATE-TIME'){ + $prop = new Net::ICal::Libical::Time(\%dict); + } elsif($dict{'value_type'} eq 'DURATION' ) { + $prop = new Net::ICal::Libical::Duration(\%dict); + } else { + $prop = new Net::ICal::Libical::Property(\%dict); + } + + push(@props,$prop); + + } + + + return @props; + +} + + +sub add_property { + + # if there is a 'ref' key in the prop's dict, then it is owned by + # an icalcomponent, so dont add it again. But, you may check that + # it is owned by this component with: + # icalproperty_get_parent(p->{'ref'}') != $self->{'comp_p'} + + # If there is no 'ref' key, then create one with $p->{'ref'} = + # icalproperty_new_from_string($p->as_ical_string) + +} + +sub remove_property { + +# If $p->{'ref'} is set, then remove the property with +# icalcomponent_remove_property() } +} + +# Return an array of all components of the given type +sub components { + + my $self = shift; + my $comp_name = shift; + + my @comps; + + if(!$comp_name){ + $comp_name = 'ANY'; + } + + my $c = $self->{'comp_p'}; + my $p; + + for($p = Net::ICal::Libical::icallangbind_get_first_component($c,$comp_name); + $p; + $p = Net::ICal::Libical::icallangbind_get_next_component($c,$comp_name)){ + + push(@comps, Net::ICal::Libical::Component->new_from_ref($p)); + + } + + return @comps; + +} + + +sub add_component {} + +sub remove_component {} + +sub as_ical_string { + my $self = shift; + + return Net::ICal::Libical::icalcomponent_as_ical_string($self->{'comp_p'}) +} + + + +1; diff --git a/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm new file mode 100644 index 0000000000..13ec9c437e --- /dev/null +++ b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm @@ -0,0 +1,160 @@ +#============================================================================= +# +# This package is free software and is provided "as is" without express +# or implied warranty. It may be used, redistributed and/or modified +# under the same terms as perl itself. (Either the Artistic License or +# the GPL.) +# +#============================================================================= + +=head1 NAME + +Net::ICal::Duration -- represent a length of time + +=head1 SYNOPSIS + + use Net::ICal; + $d = Net::ICal::Duration->new("P3DT6H15M10S"); + $d = Net::ICal::Duration->new(3600); # 1 hour in seconds + +=head1 DESCRIPTION + +I Represents a length of time, such a 3 days, 30 seconds or +7 weeks. You would use this for representing an abstract block of +time; "I want to have a 1-hour meeting sometime." If you want a +calendar- and timezone-specific block of time, see Net::ICal::Period. + +=cut + +#============================================================================= + +package Net::ICal::Libical::Duration; +use Net::ICal::Libical::Property; +use strict; +use Carp; +@Net::ICal::Libical::Duration::ISA = qw ( Net::ICal::Libical::Property ); + +=head1 METHODS + +=head2 new + +Create a new I from: + +=over 4 + +=item * A string in RFC2445 duration format + +=item * An integer representing a number of seconds + +=cut + +sub new { + my $package = shift; + my $arg = shift; + my $self; + + if (ref($arg) == 'HASH'){ + # Construct from dictionary + $self = Net::ICal::Libical::Property::new($package,$arg); + my $val=Net::ICal::Libical::icalproperty_get_value_as_string($self->{'ref'}); + $self->{'dur'} = Net::ICal::Libical::icaldurationtype_from_string($val); + + return $self; + + } elsif ($arg =~ /^[-+]?\d+$/){ + # Seconds + $self = Net::ICal::Libical::Property::new($package,'DURATION'); + $self->{'dur'} = Net::ICal::Libical::icaldurationtype_new_from_int($arg); + } elsif ($arg) { + # iCalendar string + $self = Net::ICal::Libical::Property::new($package,'DURATION'); + $self->{'dur'} = Net::ICal::Libical::icaldurationtype_new_from_string($arg); + } else { + die; + } + + $self->_update_value(); + return $self; + +} + +sub _update_value { + my $self = shift; + + die "Can't find internal icalduration reference" if !$self->{'dur'}; + + $self->value(Net::ICal::Libical::icaldurationtype_as_ical_string($self->{'dur'})); + +} +=head2 clone() + +Return a new copy of the duration. + +=cut + +sub clone { + die "Not Implemented"; + +} + + +=head2 is_valid() + +Determine if this is a valid duration (given criteria TBD). + +=cut + +sub is_valid { + + die "Not Implemented;" + +} + +=head2 seconds() + +Set or Get the length of the duration as seconds. + +=cut + +sub seconds { + my $self = shift; + my $seconds = shift; + + if($seconds){ + $self->{'dur'} = + Net::ICal::Libical::icaldurationtype_from_int($seconds); + $self->_update_value(); + } + + return Net::ICal::Libical::icaldurationtype_as_int($self->{'dur'}); + +} + +=head2 add($duration) + +Return a new duration that is the sum of this and $duration. Does not +modify this object. + +=cut + +sub add { + my ($self, $duration) = @_; + + return new Duration($self->seconds() + $duration->seconds()); +} + + +=head2 subtract($duration) + +Return a new duration that is the difference between this and +$duration. Does not modify this object. + +=cut + +sub subtract { + my ($self, $duration) = @_; + + return new Duration($self->seconds() - $duration->seconds()); +} + +1; diff --git a/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm new file mode 100644 index 0000000000..ecf29f3370 --- /dev/null +++ b/libical/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm @@ -0,0 +1,359 @@ +#!/usr/bin/perl -w +# -*- Mode: perl -*- +#====================================================================== +# +# This package is free software and is provided "as is" without express +# or implied warranty. It may be used, redistributed and/or modified +# under the same terms as perl itself. ( Either the Artistic License or the +# GPL. ) +# +# $Id$ +# +# (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org +# +# $Log +#====================================================================== + + +=pod +=head1 NAME + +Net::ICal::Period -- represent a period of time + +=head1 SYNOPSIS + + use Net::ICal; + $p = new Net::ICal::Period("19970101T120000","19970101T123000"); + $p = new Net::ICal::Period("19970101T120000","PT3W2D40S"); + $p = new Net::ICal::Period(time(),3600); + $p = new Net::ICal::Period( + new Net::ICal::Time("19970101T120000", + "America/Los_Angeles"), + new Net::ICal::Duration("2h")); + +=head1 DESCRIPTION + +Use this to make an object representing a block of time on a +real schedule. You can either say, "This event starts at 12 +and ends at 2" or "This event starts at 12 and lasts 2 hours." + +These two ways of specifying events can be treated differently +in schedules. If you say, "The meeting is from 12 to 2, but I +have to leave at 2," you are implying that the start date and +end date are fixed. If you say, "I have a 2-hour drive to +Chicago, and I need to leave at 4," you are saying that it will +take 2 hours no matter when you leave, and that moving the start +time will slide the end time correspondingly. + +=head1 BASIC METHODS + +=cut + + +#========================================================================= + +package Net::ICal::Period; +use strict; +use Net::ICal::Time; +use Net::ICal::Duration; + +use UNIVERSAL qw(isa); + +#------------------------------------------------------------------------- + +=pod +=head2 new($time, $time|$duration) + +Creates a new period object given to parameters: The first must be a +I