Skip to content

Commit

Permalink
Update OCP
Browse files Browse the repository at this point in the history
  • Loading branch information
nextcloud-command committed Jan 16, 2025
1 parent 3d9b3b4 commit 0209a87
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 0 deletions.
13 changes: 13 additions & 0 deletions OCP/AppFramework/Bootstrap/IRegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ public function registerTaskProcessingProvider(string $taskProcessingProviderCla
*/
public function registerTaskProcessingTaskType(string $taskProcessingTaskTypeClass): void;

/**
* Register an implementation of \OCP\Files\Conversion\IConversionProvider
* that will handle the conversion of files from one MIME type to another
*
* @param string $class
* @psalm-param class-string<\OCP\Files\Conversion\IConversionProvider> $class
*
* @return void
*
* @since 31.0.0
*/
public function registerFileConversionProvider(string $class): void;

/**
* Register a mail provider
*
Expand Down
44 changes: 44 additions & 0 deletions OCP/Files/Conversion/ConversionMimeTuple.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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,
];
}
}
46 changes: 46 additions & 0 deletions OCP/Files/Conversion/IConversionManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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 OCP\Files\File;

/**
* @since 31.0.0
*/
interface IConversionManager {
/**
* Determines whether or not conversion providers are available
*
* @since 31.0.0
*/
public function hasProviders(): bool;

/**
* Gets all supported MIME type conversions
*
* @return list<ConversionMimeTuple>
*
* @since 31.0.0
*/
public function getMimeTypes(): array;

/**
* Convert a file to a given MIME type
*
* @param File $file The file to be converted
* @param string $targetMimeType The MIME type to convert the file to
* @param ?string $destination The destination to save the converted file
*
* @return string Path to the converted file
*
* @since 31.0.0
*/
public function convert(File $file, string $targetMimeType, ?string $destination = null): string;
}
41 changes: 41 additions & 0 deletions OCP/Files/Conversion/IConversionProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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 OCP\Files\File;

/**
* This interface is implemented by apps that provide
* a file conversion provider
*
* @since 31.0.0
*/
interface IConversionProvider {
/**
* Get an array of MIME type tuples this conversion provider supports
*
* @return list<ConversionMimeTuple>
*
* @since 31.0.0
*/
public function getSupportedMimeTypes(): array;

/**
* Convert a file to a given MIME type
*
* @param File $file The file to be converted
* @param string $targetMimeType The MIME type to convert the file to
*
* @return resource|string Resource or string content of the file
*
* @since 31.0.0
*/
public function convertFile(File $file, string $targetMimeType): mixed;
}
16 changes: 16 additions & 0 deletions OCP/Share/Exceptions/ShareTokenException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\Share\Exceptions;

use Exception;

/**
* @since 31.0.0
*/
class ShareTokenException extends Exception {
}
17 changes: 17 additions & 0 deletions OCP/Share/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCP\IUser;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\Exceptions\ShareTokenException;

/**
* This interface allows to manage sharing files between users and groups.
Expand Down Expand Up @@ -463,6 +464,14 @@ public function matchEmail(): bool;
*/
public function ignoreSecondDisplayName(): bool;


/**
* Check if custom tokens are allowed
*
* @since 31.0.0
*/
public function allowCustomTokens(): bool;

/**
* Check if the current user can enumerate the target user
*
Expand Down Expand Up @@ -522,4 +531,12 @@ public function registerShareProvider(string $shareProviderClass): void;
* @since 18.0.0
*/
public function getAllShares(): iterable;

/**
* Generate a unique share token
*
* @throws ShareTokenException Failed to generate a unique token
* @since 31.0.0
*/
public function generateToken(): string;
}

0 comments on commit 0209a87

Please sign in to comment.