Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/dav/lib/CalDAV/CalendarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
namespace OCA\DAV\CalDAV;

use OCA\dav\lib\CalDAV\SchedulingInbox;
use OCP\Calendar\ICalendarProvider;
use OCP\IConfig;
use OCP\IL10N;
Expand Down Expand Up @@ -69,4 +70,10 @@ public function getCalendars(string $principalUri, array $calendarUris = []): ar
}
return $iCalendars;
}

public function getSchedulingInboxes(string $principalUri): array {
return [
new SchedulingInbox($principalUri)
];
}
}
42 changes: 42 additions & 0 deletions apps/dav/lib/CalDAV/SchedulingInbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/*
* @copyright 2021 Christoph Wurst <[email protected]>
*
* @author 2021 Christoph Wurst <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace OCA\dav\lib\CalDAV;

use OCP\Calendar\ISchedulingInbox;

class SchedulingInbox implements ISchedulingInbox {

/** @var string */
private $principalUri;

public function __construct(string $principalUri) {
$this->principalUri = $principalUri;
}

public function getAvailability(): ?string {
return null;
}
}
56 changes: 52 additions & 4 deletions lib/private/Calendar/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
use OCP\Calendar\ICalendarProvider;
use OCP\Calendar\ICalendarQuery;
use OCP\Calendar\IManager;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Throwable;
use function array_map;
use function array_merge;

class Manager implements IManager {

Expand All @@ -47,8 +52,18 @@ class Manager implements IManager {
/** @var Coordinator */
private $coordinator;

public function __construct(Coordinator $coordinator) {
/** @var ContainerInterface */
private $container;

/** @var LoggerInterface */
private $logger;

public function __construct(Coordinator $coordinator,
ContainerInterface $container,
LoggerInterface $logger) {
$this->coordinator = $coordinator;
$this->container = $container;
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -159,9 +174,20 @@ public function searchForPrincipal(ICalendarQuery $query): array {
}

/** @var CalendarQuery $query */
$calendars = array_merge(...array_map(static function (ICalendarProvider $p) use ($query) {
return $p->getCalendars($query->getPrincipalUri(), $query->getCalendarUris());
}, $context->getCalendarProviders()));
$calendars = array_merge(
...array_map(function ($registration) use ($query) {
try {
/** @var ICalendarProvider $provider */
$provider = $this->container->get($registration->getService());
} catch (Throwable $e) {
$this->logger->error('Could not load calendar provider ' . $registration->getService() . ': ' . $e->getMessage(), [
'exception' => $e,
]);
}

return $provider->getCalendars($query->getPrincipalUri(), $query->getCalendarUris());
}, $context->getCalendarProviders())
);

$results = [];
/** @var ICalendar $calendar */
Expand All @@ -185,4 +211,26 @@ public function searchForPrincipal(ICalendarQuery $query): array {
public function newQuery(string $principalUri): ICalendarQuery {
return new CalendarQuery($principalUri);
}

public function getSchedulingInboxes(string $principalUri): array {
$context = $this->coordinator->getRegistrationContext();
if ($context === null) {
return [];
}

return array_merge(
...array_map(function($registration) use ($principalUri) {
try {
/** @var ICalendarProvider $provider */
$provider = $this->container->get($registration->getService());
} catch (Throwable $e) {
$this->logger->error('Could not load calendar provider ' . $registration->getService() . ': ' . $e->getMessage(), [
'exception' => $e,
]);
}

return $provider->getSchedulingInboxes($principalUri);
}, $context->getCalendarProviders())
);
}
}
11 changes: 11 additions & 0 deletions lib/public/Calendar/ICalendarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ interface ICalendarProvider {
* @since 23.0.0
*/
public function getCalendars(string $principalUri, array $calendarUris = []): array;

/**
* Get the principal's scheduling inboxes
*
* @param string $principalUri
*
* @return ISchedulingInbox[]]
*
* @since 23.0.0
*/
public function getSchedulingInboxes(string $principalUri): array;
}
11 changes: 11 additions & 0 deletions lib/public/Calendar/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,15 @@ public function searchForPrincipal(ICalendarQuery $query): array;
* @since 23.0.0
*/
public function newQuery(string $principalUri) : ICalendarQuery;

/**
* Get the principal's scheduling inboxes
*
* @param string $principalUri
*
* @return ISchedulingInbox[]]
*
* @since 23.0.0
*/
public function getSchedulingInboxes(string $principalUri): array;
}
35 changes: 35 additions & 0 deletions lib/public/Calendar/ISchedulingInbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/*
* @copyright 2021 Christoph Wurst <[email protected]>
*
* @author 2021 Christoph Wurst <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace OCP\Calendar;

/**
* @since 23.0.0
*/
interface ISchedulingInbox {

public function getAvailability(): ?string;

}