summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-06-04 15:25:25 +0200
committerRobin Appelman <robin@icewind.nl>2019-06-17 14:09:09 +0200
commit615061437422499025e038483504d4ef2004c8e1 (patch)
treebd8752decea5d8c10fea43bdcdd92c38c26ebf30 /lib/public
parentf6ad353c7c1176bcaa167051c9f3e118e69f7a20 (diff)
downloadnextcloud-server-615061437422499025e038483504d4ef2004c8e1.tar.gz
nextcloud-server-615061437422499025e038483504d4ef2004c8e1.zip
Add new Provider interface for preview providers
the main difference is passing the `File` object to the provider instead of a `View` + path Old providers will still continue to work as before Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/Preview/IProvider.php1
-rw-r--r--lib/public/Preview/IProviderV2.php57
2 files changed, 58 insertions, 0 deletions
diff --git a/lib/public/Preview/IProvider.php b/lib/public/Preview/IProvider.php
index ca545d8eb76..5d62b3ce6d0 100644
--- a/lib/public/Preview/IProvider.php
+++ b/lib/public/Preview/IProvider.php
@@ -27,6 +27,7 @@ namespace OCP\Preview;
*
* @package OCP\Preview
* @since 8.1.0
+ * @deprecated 17.0.0 use IProviderV2 instead
*/
interface IProvider {
/**
diff --git a/lib/public/Preview/IProviderV2.php b/lib/public/Preview/IProviderV2.php
new file mode 100644
index 00000000000..97fca21eaf5
--- /dev/null
+++ b/lib/public/Preview/IProviderV2.php
@@ -0,0 +1,57 @@
+<?php declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Preview;
+
+use OCP\Files\File;
+use OCP\Files\FileInfo;
+use OCP\IImage;
+
+/**
+ * @since 17.0.0
+ */
+interface IProviderV2 {
+ /**
+ * @return string Regex with the mimetypes that are supported by this provider
+ * @since 17.0.0
+ */
+ public function getMimeType(): string;
+
+ /**
+ * Check if a preview can be generated for $path
+ *
+ * @param FileInfo $file
+ * @return bool
+ * @since 17.0.0
+ */
+ public function isAvailable(FileInfo $file): bool;
+
+ /**
+ * get thumbnail for file at path $path
+ *
+ * @param File $file
+ * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
+ * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
+ * @return null|\OCP\IImage null if no preview was generated
+ * @since 17.0.0
+ */
+ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage;
+}