diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-12-10 14:30:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 14:30:08 +0100 |
commit | 3c693db0ca770fccd5521ecdc4da6d77ae966a73 (patch) | |
tree | 387539171b181bc1169c7ab81abf2ab2729e8486 /lib | |
parent | 16be144aab96796f093b557f29652e277482a2c3 (diff) | |
parent | c4ea37b8a102adec16cf13085dba2fd7ef893195 (diff) | |
download | nextcloud-server-3c693db0ca770fccd5521ecdc4da6d77ae966a73.tar.gz nextcloud-server-3c693db0ca770fccd5521ecdc4da6d77ae966a73.zip |
Merge pull request #24605 from nextcloud/enh/share-deck
Add deck share provider support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Share/Constants.php | 5 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 5 | ||||
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 36 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 6 | ||||
-rw-r--r-- | lib/public/Share/IProviderFactory.php | 6 | ||||
-rw-r--r-- | lib/public/Share/IShare.php | 11 |
6 files changed, 69 insertions, 0 deletions
diff --git a/lib/private/Share/Constants.php b/lib/private/Share/Constants.php index 2310859c5be..77ed3176277 100644 --- a/lib/private/Share/Constants.php +++ b/lib/private/Share/Constants.php @@ -70,6 +70,11 @@ class Constants { */ public const SHARE_TYPE_ROOM = 10; // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider + /** + * @deprecated 21.0.0 - use IShare::TYPE_DECK instead + */ + public const SHARE_TYPE_DECK = 12; + // const SHARE_TYPE_DECK_USER = 13; // Internal type used by DeckShareProvider public const FORMAT_NONE = -1; public const FORMAT_STATUSES = -2; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index e9895edf95a..6b782237b8c 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -248,6 +248,7 @@ class Manager implements IManager { throw new \InvalidArgumentException('SharedWith is not a valid circle'); } } elseif ($share->getShareType() === IShare::TYPE_ROOM) { + } elseif ($share->getShareType() === IShare::TYPE_DECK) { } else { // We can't handle other types yet throw new \InvalidArgumentException('unknown share type'); @@ -1887,6 +1888,10 @@ class Manager implements IManager { return true; } + public function registerShareProvider(string $shareProviderClass): void { + $this->factory->registerProvider($shareProviderClass); + } + public function getAllShares(): iterable { $providers = $this->factory->getAllProviders(); diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 2d4c4e6d40a..9f93df46ac0 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -44,6 +44,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IServerContainer; use OCP\Share\IProviderFactory; use OCP\Share\IShare; +use OCP\Share\IShareProvider; /** * Class ProviderFactory @@ -67,6 +68,10 @@ class ProviderFactory implements IProviderFactory { /** @var \OCA\Talk\Share\RoomShareProvider */ private $roomShareProvider = null; + private $registeredShareProviders = []; + + private $shareProviders = []; + /** * IProviderFactory constructor. * @@ -76,6 +81,10 @@ class ProviderFactory implements IProviderFactory { $this->serverContainer = $serverContainer; } + public function registerProvider(string $shareProviderClass): void { + $this->registeredShareProviders[] = $shareProviderClass; + } + /** * Create the default share provider. * @@ -257,6 +266,10 @@ class ProviderFactory implements IProviderFactory { */ public function getProvider($id) { $provider = null; + if (isset($this->shareProviders[$id])) { + return $this->shareProviders[$id]; + } + if ($id === 'ocinternal') { $provider = $this->defaultShareProvider(); } elseif ($id === 'ocFederatedSharing') { @@ -269,6 +282,16 @@ class ProviderFactory implements IProviderFactory { $provider = $this->getRoomShareProvider(); } + foreach ($this->registeredShareProviders as $shareProvider) { + /** @var IShareProvider $instance */ + $instance = $this->serverContainer->get($shareProvider); + $this->shareProviders[$instance->identifier()] = $instance; + } + + if (isset($this->shareProviders[$id])) { + $provider = $this->shareProviders[$id]; + } + if ($provider === null) { throw new ProviderException('No provider with id .' . $id . ' found.'); } @@ -295,6 +318,8 @@ class ProviderFactory implements IProviderFactory { $provider = $this->getShareByCircleProvider(); } elseif ($shareType === IShare::TYPE_ROOM) { $provider = $this->getRoomShareProvider(); + } elseif ($shareType === IShare::TYPE_DECK) { + $provider = $this->getProvider('deck'); } @@ -320,6 +345,17 @@ class ProviderFactory implements IProviderFactory { $shares[] = $roomShare; } + foreach ($this->registeredShareProviders as $shareProvider) { + /** @var IShareProvider $instance */ + $instance = $this->serverContainer->get($shareProvider); + if (!isset($this->shareProviders[$instance->identifier()])) { + $this->shareProviders[$instance->identifier()] = $instance; + } + $shares[] = $this->shareProviders[$instance->identifier()]; + } + + + return $shares; } } diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index cc2ec45cc9f..635ccc1483d 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -417,6 +417,12 @@ interface IManager { public function shareProviderExists($shareType); /** + * @param string $shareProviderClass + * @since 21.0.0 + */ + public function registerShareProvider(string $shareProviderClass): void; + + /** * @Internal * * Get all the shares as iterable to reduce memory overhead diff --git a/lib/public/Share/IProviderFactory.php b/lib/public/Share/IProviderFactory.php index 27218497e53..480837404f0 100644 --- a/lib/public/Share/IProviderFactory.php +++ b/lib/public/Share/IProviderFactory.php @@ -53,4 +53,10 @@ interface IProviderFactory { * @since 11.0.0 */ public function getAllProviders(); + + /** + * @since 21.0.0 + * @param string $shareProvier + */ + public function registerProvider(string $shareProvier): void; } diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index 7b38e00df46..86aceba80f5 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -106,6 +106,17 @@ interface IShare { // const TYPE_USERROOM = 11; /** + * @since 21.0.0 + */ + public const TYPE_DECK = 12; + + /** + * @internal + * @since 21.0.0 + */ + public const TYPE_DECK_USER = 13; + + /** * @since 18.0.0 */ public const STATUS_PENDING = 0; |