Net-CalDAVTalk
view release on metacpan or search on metacpan
0.11 Sun Nov 12 18:55 2017
- add GetEventLinks, GetEventsMulti and SyncEventLinks APIs
- $Net::CalDAVTalk::BATCHSIZE = 100 default for GetEventsMulti
0.10 Wed Feb 15 16:46 2017
- set the timezone on recurrences based on the top level timezone, not
the recurrence timezone
0.09 Fri Oct 14 11:49 2016
- fix freebusy parsing for zero length events and updated stamp
- add JMAP_ALWAYS_FULL environment variable to suppress deep
diff creation
0.08 Fri Oct 14 09:20 2016
- major rewrite to support the new TC-API from CalConnect which
will be part of the JMAP specification, including tests
0.07 Tue Jun 28 11:48 2016
- uploaded bogus path, so just fix it with a new version
lib/Net/CalDAVTalk.pm view on Meta::CPAN
mayRead => $JSON::false,
mayReadFreeBusy => $JSON::false,
);
my $Priv = $Propstat->{"{$NS_D}prop"}{"{$NS_D}current-user-privilege-set"}{"{$NS_D}privilege"};
$Priv = [] unless ($Priv and ref($Priv) eq 'ARRAY');
foreach my $item (@$Priv) {
$Privileges{'mayAdmin'} = $JSON::true if $item->{"{$NS_CY}admin"};
$Privileges{'mayWrite'} = $JSON::true if $item->{"{$NS_D}write-content"};
$Privileges{'mayRead'} = $JSON::true if $item->{"{$NS_D}read"};
$Privileges{'mayReadFreeBusy'} = $JSON::true if $item->{"{$NS_C}read-free-busy"};
}
my $CanSync;
my $Report = $Propstat->{"{$NS_D}prop"}{"{$NS_D}supported-report-set"}{"{$NS_D}supported-report"};
$Report = [] unless ($Report and ref($Report) eq 'ARRAY');
foreach my $item (@$Report) {
# XXX - do we want to check the other things too?
$CanSync = 1 if $item->{"{$NS_D}report"}{"{$NS_D}sync-collection"};
}
lib/Net/CalDAVTalk.pm view on Meta::CPAN
email => $email,
mayAdmin => $JSON::false,
mayWrite => $JSON::false,
mayRead => $JSON::false,
mayReadFreeBusy => $JSON::false,
);
foreach my $item (@{$Acl->{"{$NS_D}grant"}{"{$NS_D}privilege"}}) {
$ShareObject{'mayAdmin'} = $JSON::true if $item->{"{$NS_CY}admin"};
$ShareObject{'mayWrite'} = $JSON::true if $item->{"{$NS_D}write-content"};
$ShareObject{'mayRead'} = $JSON::true if $item->{"{$NS_D}read"};
$ShareObject{'mayReadFreeBusy'} = $JSON::true if $item->{"{$NS_C}read-free-busy"};
}
push @ShareWith, \%ShareObject;
}
my %Cal = (
id => $calendarId,
name => ($Propstat->{"{$NS_D}prop"}{"{$NS_D}displayname"}{content} || $DefaultDisplayName),
href => $href,
color => _fixColour($Propstat->{"{$NS_D}prop"}{"{$NS_A}calendar-color"}{content}),
lib/Net/CalDAVTalk.pm view on Meta::CPAN
my ($Events, $Errors) = $Self->GetEventsMulti($calendarId, [$Self->fullpath($href)], %Args);
die "Errors @$Errors" if @$Errors;
die "Multiple items returned for $href" if @$Events > 1;
return $Events->[0];
}
=head2 $self->GetFreeBusy($calendarId, %Args)
Like 'GetEvents' but uses a free-busy-query and then generates
synthetic events out of the result.
Doesn't have a 'href' parameter, just the before/after range.
=cut
sub GetFreeBusy {
my ($Self, $calendarId, %Args) = @_;
# validate parameters {{{
lib/Net/CalDAVTalk.pm view on Meta::CPAN
start => $Start->strftime('%Y%m%dT000000Z'),
end => $End->strftime('%Y%m%dT000000Z'),
});
}
# }}}
my $Response = $Self->Request(
'REPORT',
"$calendarId/",
x('C:free-busy-query', $Self->NS(),
@Query,
),
Depth => 1,
);
my $Data = eval { vcard2hash($Response->{content}, multival => ['rrule'], only_one => 1) }
or confess "Error parsing VFreeBusy data: $@";
my @result;
my @errors;
my $now = DateTime->now();
foreach my $item (@{$Data->{objects}[0]{objects}}) {
next unless $item->{type} eq 'vfreebusy';
foreach my $line (@{$item->{properties}{freebusy}}) {
my ($Start, $End) = split '/', $line->{value};
my ($StartTime, $IsAllDay) = $Self->_makeDateObj($Start, 'UTC', 'UTC');
my $EndTime;
if ($End =~ m/^[+-]?P/i) {
my $Duration = eval { DateTime::Format::ICal->parse_duration(uc $End) }
|| next;
$EndTime = $StartTime->clone()->add($Duration);
} else {
($EndTime) = $Self->_makeDateObj($End, 'UTC', 'UTC');
}
my $duration = $Self->_make_duration($EndTime->subtract_datetime($StartTime));
my $NewEvent = {
timeZone => 'Etc/UTC',
start => $StartTime->iso8601(),
duration => $duration,
title => ($Args{name} // ''),
isAllDay => ($IsAllDay ? $JSON::true : $JSON::false),
updated => $now->iso8601(),
};
# Generate a uid that should remain the same for this freebusy entry
$NewEvent->{uid} = _hexkey($NewEvent) . '-freebusyauto';
$NewEvent->{isAllDay} =
$NewEvent->{isAllDay} ? $JSON::true : $JSON::false;
push @result, $NewEvent;
}
}
return (\@result, \@errors);
}
=head2 $self->SyncEvents($calendarId, %Args)
( run in 0.374 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )