Add provider for room shares

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 <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-06-29 10:10:58 +02:00
parent 857bb45366
commit 4ee839d69c
1 changed files with 34 additions and 0 deletions

View File

@ -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;
}