Net::ICal::FreebusyItem - represents the FREEBUSY property for


Net-ICal documentation Contained in the Net-ICal distribution.

Index


Code Index:

NAME

Top

Net::ICal::FreebusyItem -- represents the FREEBUSY property for VFREEBUSY objects.

SYNOPSIS

Top

  use Net::ICal;

  my $p1 = Net::ICal::Period->new("19970101T120000","19970101T123000");
  my $p2 = Net::ICal::Period->new("19970101T133000","19970101T140000");

  my $item1 = Net::ICal::FreebusyItem->new($p1, (fbtype => 'BUSY'));
  my $item2 = Net::ICal::FreebusyItem->new($p2, (fbtype => 'BUSY'));

  # TODO: we ought to be able to do things like:
    my $item3 = Net::ICal::FreebusyItem->new([$p1, $p2], (fbtype => 'BUSY'));
  # so that both items show up on the same line. 

DESCRIPTION

Top

FreebusyItems are used to mark sections of time that are free to be scheduled or that are already busy.

CONSTRUCTORS

Top

new ($period, %options)

$period is a Net::ICal::Period object. In the future, this will change to be an array of Periods. Valid keys for the options hash are:

* fbtype - can be BUSY, FREE, BUSY-UNAVAILABLE, or BUSY-TENTATIVE; defaults to BUSY. BUSY means there's already something scheduled in this time slot. FREE means that this time slot is open. BUSY-UNAVAILABLE means that this time slot can't be scheduled. BUSY-TENTATIVE means that this time slot has something tentatively scheduled for it.

SEE ALSO

Top

Net::ICal::Period, Net::ICal::Freebusy. There are a lot of semantics to handling these for real usage; see RFC2445.

More documentation can also be found in Net::ICal.


Net-ICal documentation Contained in the Net-ICal distribution.
#!/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: FreebusyItem.pm,v 1.8 2001/08/04 04:59:36 srl Exp $
#
# (C) COPYRIGHT 2000-2001, Reefknot developers.
#
# See the AUTHORS file included in the distribution for a full list.
#======================================================================

package Net::ICal::FreebusyItem;
use strict;

use base qw(Net::ICal::Property);

use Net::ICal::Duration;
use Net::ICal::Time;

sub new {
  my ($class, $content, %args) = @_;

  my $ref = ref ($content);
  return undef unless %args;

  unless ($ref) {
    if ($content =~ /^[\+-]?P/) {
      %args = (content => new Net::ICal::Period ($content));
    } else {
      # explicitly set everything to default
      %args = (content => Net::ICal::Period->new ($content));
    }
  } elsif ($ref eq 'Net::ICal::Period') {
    %args = (content => $content);
  } elsif ($ref eq 'ARRAY') {
    # FIXME: support arrays of periods so that multiple periods can
    # be on one FREEBUSY line separated by commas, as required by the RFC.
    warn "Arrays of Periods aren't yet supported";
    return undef;

  } else {
    warn "Argument $content is not a valid Period";
    return undef;
  }

  # set up the default fbtype
  $args{fbtype} = 'BUSY' unless $args{fbtype};

  return &_create ($class, %args);
}

sub _create {
  my ($class, %args) = @_;

  my $map = {
    fbtype => {     # RFC2445 4.2.9
      type => 'parameter',
      doc => '',
      domain => 'enum',
      options => [qw(FREE BUSY BUSY-UNAVAILABLE BUSY-TENTATIVE)],
      # "The value FREE indicates that the time interval is free for scheduling.
      # The value BUSY indicates that the time interval is busy because one
      # or more events have been scheduled for that interval. The value
      # BUSY-UNAVAILABLE indicates that the time interval is busy and that
      # the interval can not be scheduled. The value BUSY-TENTATIVE indicates
      # that the time interval is busy because one or more events have been
      # tentatively scheduled for that interval. If not specified on a
      # property that allows this parameter, the default is BUSY." -- RFC2445
    
      # FIXME this is actually a property that goes on the same line as a FREEBUSY. 
    },
    content => {
	  type => 'volatile',
	  doc => 'the value of the trigger',
	  domain => 'reclass',
	  options => {default => 'Net::ICal::Period'},
	  value => undef,
    },
  };

  my $self = $class->SUPER::new ('FREEBUSY', $map, %args);
  return $self;
}

1;
__END__