From 4ee839d69c83bcd71d194864eed47f4448a6ca85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 29 Jun 2018 10:10:58 +0200 Subject: [PATCH] Add provider for room shares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RoomShareProvider is provided by the Talk app, so it is necessary to check whether the app is available or not, and also whether the class itself exists or not (just in case an older version of the app that did not have support yet for room shares is being used). Signed-off-by: Daniel Calviño Sánchez --- lib/private/Share20/ProviderFactory.php | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 0aacca409d1..6cb6c082df5 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -60,6 +60,8 @@ class ProviderFactory implements IProviderFactory { private $shareByCircleProvider = null; /** @var bool */ private $circlesAreNotAvailable = false; + /** @var \OCA\Spreed\Share\RoomShareProvider */ + private $roomShareProvider = null; /** * IProviderFactory constructor. @@ -221,6 +223,30 @@ class ProviderFactory implements IProviderFactory { return $this->shareByCircleProvider; } + /** + * Create the room share provider + * + * @return RoomShareProvider + */ + protected function getRoomShareProvider() { + if ($this->roomShareProvider === null) { + /* + * Check if the app is enabled + */ + $appManager = $this->serverContainer->getAppManager(); + if (!$appManager->isEnabledForUser('spreed')) { + return null; + } + + try { + $this->roomShareProvider = $this->serverContainer->query('\OCA\Spreed\Share\RoomShareProvider'); + } catch (\OCP\AppFramework\QueryException $e) { + return null; + } + } + + return $this->roomShareProvider; + } /** * @inheritdoc @@ -235,6 +261,8 @@ class ProviderFactory implements IProviderFactory { $provider = $this->getShareByMailProvider(); } else if ($id === 'ocCircleShare') { $provider = $this->getShareByCircleProvider(); + } else if ($id === 'ocRoomShare') { + $provider = $this->getRoomShareProvider(); } if ($provider === null) { @@ -261,6 +289,8 @@ class ProviderFactory implements IProviderFactory { $provider = $this->getShareByMailProvider(); } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { $provider = $this->getShareByCircleProvider(); + } else if ($shareType === \OCP\Share::SHARE_TYPE_ROOM) { + $provider = $this->getRoomShareProvider(); } @@ -281,6 +311,10 @@ class ProviderFactory implements IProviderFactory { if ($shareByCircle !== null) { $shares[] = $shareByCircle; } + $roomShare = $this->getRoomShareProvider(); + if ($roomShare !== null) { + $shares[] = $roomShare; + } return $shares; }