diff --git a/lib/private/Calendar/Resource/Manager.php b/lib/private/Calendar/Resource/Manager.php new file mode 100644 index 0000000000..0cb4a739b7 --- /dev/null +++ b/lib/private/Calendar/Resource/Manager.php @@ -0,0 +1,71 @@ + + * + * @author Georg Ehrke + * + * @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 . + * + */ + +namespace OC\Calendar\Resource; + +use OCP\Calendar\Resource\IBackend; + +class Manager implements \OCP\Calendar\Resource\IManager { + + /** @var IBackend[] holds all registered resource backends */ + private $backends; + + /** + * Registers a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function registerBackend(IBackend $backend) { + $this->backends[$backend->getBackendIdentifier()] = $backend; + } + + /** + * Unregisters a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function unregisterBackend(IBackend $backend) { + unset($this->backends[$backend->getBackendIdentifier()]); + } + + /** + * @return IBackend[] + * @since 14.0.0 + */ + public function getBackends():array { + return array_values($this->backends); + } + + /** + * removes all registered backend instances + * @return void + * @since 14.0.0 + */ + public function clear() { + $this->backends = []; + } +} diff --git a/lib/private/Calendar/Room/Manager.php b/lib/private/Calendar/Room/Manager.php new file mode 100644 index 0000000000..ac446aca94 --- /dev/null +++ b/lib/private/Calendar/Room/Manager.php @@ -0,0 +1,71 @@ + + * + * @author Georg Ehrke + * + * @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 . + * + */ + +namespace OC\Calendar\Room; + +use OCP\Calendar\Room\IBackend; + +class Manager implements \OCP\Calendar\Room\IManager { + + /** @var IBackend[] holds all registered resource backends */ + private $backends; + + /** + * Registers a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function registerBackend(IBackend $backend) { + $this->backends[$backend->getBackendIdentifier()] = $backend; + } + + /** + * Unregisters a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function unregisterBackend(IBackend $backend) { + unset($this->backends[$backend->getBackendIdentifier()]); + } + + /** + * @return IBackend[] + * @since 14.0.0 + */ + public function getBackends():array { + return array_values($this->backends); + } + + /** + * removes all registered backend instances + * @return void + * @since 14.0.0 + */ + public function clear() { + $this->backends = []; + } +} diff --git a/lib/public/Calendar/Resource/IBackend.php b/lib/public/Calendar/Resource/IBackend.php index 99a4ff0633..8b0ea67740 100644 --- a/lib/public/Calendar/Resource/IBackend.php +++ b/lib/public/Calendar/Resource/IBackend.php @@ -36,14 +36,14 @@ interface IBackend { * * @return IResource[] */ - public function getAllResources(); + public function getAllResources():array; /** * get a list of all resource identifiers in this backend * * @return string[] */ - public function listAllResources(); + public function listAllResources():array; /** * get a resource by it's id @@ -52,4 +52,12 @@ interface IBackend { * @return IResource|null */ public function getResource($id); + + /** + * Get unique identifier of the backend + * + * @return string + * @since 14.0.0 + */ + public function getBackendIdentifier():string; } diff --git a/lib/public/Calendar/Resource/IManager.php b/lib/public/Calendar/Resource/IManager.php new file mode 100644 index 0000000000..dc52b269ad --- /dev/null +++ b/lib/public/Calendar/Resource/IManager.php @@ -0,0 +1,58 @@ + + * + * @author Georg Ehrke + * + * @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 . + * + */ + +namespace OCP\Calendar\Resource; + +interface IManager { + + /** + * Registers a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function registerBackend(IBackend $backend); + + /** + * Unregisters a resource backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function unregisterBackend(IBackend $backend); + + /** + * @return IBackend[] + * @since 14.0.0 + */ + public function getBackends():array; + + /** + * removes all registered backend instances + * @return void + * @since 14.0.0 + */ + public function clear(); +} diff --git a/lib/public/Calendar/Resource/IResource.php b/lib/public/Calendar/Resource/IResource.php index a60378435b..1f588ccb48 100644 --- a/lib/public/Calendar/Resource/IResource.php +++ b/lib/public/Calendar/Resource/IResource.php @@ -39,7 +39,7 @@ interface IResource { * @return string * @since 14.0.0 */ - public function getId(); + public function getId():string; /** * get the display name for a resource @@ -47,7 +47,7 @@ interface IResource { * @return string * @since 14.0.0 */ - public function getDisplayName(); + public function getDisplayName():string; /** * Get a list of groupIds that are allowed to access this resource @@ -58,13 +58,23 @@ interface IResource { * @return string[] * @since 14.0.0 */ - public function getGroupRestrictions(); + public function getGroupRestrictions():array; /** - * Get the name of the backend class the room is connected with + * get email-address for resource + * + * The email address has to be globally unique * * @return string * @since 14.0.0 */ - public function getBackendClassName(); + public function getEMail():string; + + /** + * Get corresponding backend object + * + * @return IBackend + * @since 14.0.0 + */ + public function getBackend():IBackend; } diff --git a/lib/public/Calendar/Room/IBackend.php b/lib/public/Calendar/Room/IBackend.php index a7550347c7..84e01f6e32 100644 --- a/lib/public/Calendar/Room/IBackend.php +++ b/lib/public/Calendar/Room/IBackend.php @@ -36,14 +36,14 @@ interface IBackend { * * @return IRoom[] */ - public function getAllRooms(); + public function getAllRooms():array; /** * get a list of all room identifiers in this backend * * @return string[] */ - public function listAllRooms(); + public function listAllRooms():array; /** * get a room by it's id @@ -52,4 +52,12 @@ interface IBackend { * @return IRoom|null */ public function getRoom($id); + + /** + * Get unique identifier of the backend + * + * @return string + * @since 14.0.0 + */ + public function getBackendIdentifier():string; } diff --git a/lib/public/Calendar/Room/IManager.php b/lib/public/Calendar/Room/IManager.php new file mode 100644 index 0000000000..a04e75c41b --- /dev/null +++ b/lib/public/Calendar/Room/IManager.php @@ -0,0 +1,58 @@ + + * + * @author Georg Ehrke + * + * @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 . + * + */ + +namespace OCP\Calendar\Room; + +interface IManager { + + /** + * Registers a room backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function registerBackend(IBackend $backend); + + /** + * Unregisters a room backend + * + * @param IBackend $backend + * @return void + * @since 14.0.0 + */ + public function unregisterBackend(IBackend $backend); + + /** + * @return IBackend[] + * @since 14.0.0 + */ + public function getBackends():array; + + /** + * removes all registered backend instances + * @return void + * @since 14.0.0 + */ + public function clear(); +} diff --git a/lib/public/Calendar/Room/IRoom.php b/lib/public/Calendar/Room/IRoom.php index deac92a79d..d860bb6fc5 100644 --- a/lib/public/Calendar/Room/IRoom.php +++ b/lib/public/Calendar/Room/IRoom.php @@ -39,7 +39,7 @@ interface IRoom { * @return string * @since 14.0.0 */ - public function getId(); + public function getId():string; /** * get the display name for a room @@ -47,7 +47,7 @@ interface IRoom { * @return string * @since 14.0.0 */ - public function getDisplayName(); + public function getDisplayName():string; /** * Get a list of groupIds that are allowed to access this room @@ -58,13 +58,23 @@ interface IRoom { * @return string[] * @since 14.0.0 */ - public function getGroupRestrictions(); + public function getGroupRestrictions():array; /** - * Get the name of the backend class the room is connected with + * get email-address for room + * + * The email address has to be globally unique * * @return string * @since 14.0.0 */ - public function getBackendClassName(); + public function getEMail():string; + + /** + * Get corresponding backend object + * + * @return IBackend + * @since 14.0.0 + */ + public function getBackend():IBackend; }