diff --git a/OCP/Files/Conversion/ConversionMimeProvider.php b/OCP/Files/Conversion/ConversionMimeProvider.php new file mode 100644 index 00000000..0daf4a10 --- /dev/null +++ b/OCP/Files/Conversion/ConversionMimeProvider.php @@ -0,0 +1,66 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Files\Conversion; + +use JsonSerializable; + +/** + * A tuple-like object representing both an original and target + * MIME type for a file conversion + * + * @since 31.0.0 + */ +class ConversionMimeProvider implements JsonSerializable { + /** + * @param string $from The source MIME type of a file + * @param string $to The target MIME type for the file + * @param string $extension The file extension for the target MIME type (e.g. 'png') + * @param string $displayName The human-readable name of the target MIME type (e.g. 'Image (.png)') + * + * @since 31.0.0 + */ + public function __construct( + private string $from, + private string $to, + private string $extension, + private string $displayName, + ) { + } + + public function getFrom(): string { + return $this->from; + } + + public function getTo(): string { + return $this->to; + } + + public function getExtension(): string { + return $this->extension; + } + + public function getDisplayName(): string { + return $this->displayName; + } + + /** + * @return array{from: string, to: string, extension: string, displayName: string} + * + * @since 31.0.0 + */ + public function jsonSerialize(): array { + return [ + 'from' => $this->from, + 'to' => $this->to, + 'extension' => $this->extension, + 'displayName' => $this->displayName, + ]; + } +} diff --git a/OCP/Files/Conversion/ConversionMimeTuple.php b/OCP/Files/Conversion/ConversionMimeTuple.php deleted file mode 100644 index 0180f331..00000000 --- a/OCP/Files/Conversion/ConversionMimeTuple.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -namespace OCP\Files\Conversion; - -use JsonSerializable; - -/** - * A tuple-like object representing both an original and target - * MIME type for a file conversion - * - * @since 31.0.0 - */ -class ConversionMimeTuple implements JsonSerializable { - /** - * @param string $from The original MIME type of a file - * @param list<array{mime: string, name: string}> $to The desired MIME type for the file mapped to its translated name - * - * @since 31.0.0 - */ - public function __construct( - private string $from, - private array $to, - ) { - } - - /** - * @return array{from: string, to: list<array{mime: string, name: string}>} - * - * @since 31.0.0 - */ - public function jsonSerialize(): array { - return [ - 'from' => $this->from, - 'to' => $this->to, - ]; - } -} diff --git a/OCP/Files/Conversion/IConversionManager.php b/OCP/Files/Conversion/IConversionManager.php index 59ff580f..ed418129 100644 --- a/OCP/Files/Conversion/IConversionManager.php +++ b/OCP/Files/Conversion/IConversionManager.php @@ -25,11 +25,11 @@ public function hasProviders(): bool; /** * Gets all supported MIME type conversions * - * @return list<ConversionMimeTuple> + * @return list<ConversionMimeProvider> * * @since 31.0.0 */ - public function getMimeTypes(): array; + public function getProviders(): array; /** * Convert a file to a given MIME type diff --git a/OCP/Files/Conversion/IConversionProvider.php b/OCP/Files/Conversion/IConversionProvider.php index b0a09fc9..3b5c5945 100644 --- a/OCP/Files/Conversion/IConversionProvider.php +++ b/OCP/Files/Conversion/IConversionProvider.php @@ -21,7 +21,7 @@ interface IConversionProvider { /** * Get an array of MIME type tuples this conversion provider supports * - * @return list<ConversionMimeTuple> + * @return list<ConversionMimeProvider> * * @since 31.0.0 */ diff --git a/OCP/IUserManager.php b/OCP/IUserManager.php index 091ccd89..50eaa9c9 100644 --- a/OCP/IUserManager.php +++ b/OCP/IUserManager.php @@ -163,6 +163,16 @@ public function createUserFromBackend($uid, $password, UserInterface $backend); */ public function countUsers(); + /** + * Get how many users exists in total, whithin limit + * + * @param int $limit Limit the count to avoid resource waste. 0 to disable + * @param bool $onlyMappedUsers Count mapped users instead of all users for compatible backends + * + * @since 31.0.0 + */ + public function countUsersTotal(int $limit = 0, bool $onlyMappedUsers = false): int|false; + /** * @param \Closure $callback * @psalm-param \Closure(\OCP\IUser):void $callback diff --git a/OCP/User/Backend/ICountUsersBackend.php b/OCP/User/Backend/ICountUsersBackend.php index e337147d..194cf465 100644 --- a/OCP/User/Backend/ICountUsersBackend.php +++ b/OCP/User/Backend/ICountUsersBackend.php @@ -10,6 +10,7 @@ /** * @since 14.0.0 + * @deprecated 31.0.0 use and implement ILimitAwareCountUsersBackend instead. */ interface ICountUsersBackend { /** diff --git a/OCP/User/Backend/ILimitAwareCountUsersBackend.php b/OCP/User/Backend/ILimitAwareCountUsersBackend.php new file mode 100644 index 00000000..a59c0bd8 --- /dev/null +++ b/OCP/User/Backend/ILimitAwareCountUsersBackend.php @@ -0,0 +1,23 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\User\Backend; + +/** + * @since 31.0.0 + */ +interface ILimitAwareCountUsersBackend extends ICountUsersBackend { + /** + * @since 31.0.0 + * + * @param int $limit Limit to stop counting users if there are more than $limit. 0 to disable limiting. + * @return int|false The number of users (may be limited to $limit) on success false on failure + */ + public function countUsers(int $limit = 0): int|false; +}