From 7ce41b23407766eac124b5b572b85840826d0a3a Mon Sep 17 00:00:00 2001 From: Ari Selseng Date: Sun, 12 Jun 2022 14:42:22 +0200 Subject: [PATCH] FIx deprecations in Nextcloud 24. Dropping ownCloud support. --- Makefile | 4 +--- README.md | 4 ++-- appinfo/app.php | 6 ------ appinfo/info.xml | 9 ++++----- lib/AppInfo/Application.php | 35 +++++++++++++++++------------------ lib/RawPreviewBase.php | 5 ++--- lib/RawPreviewIProvider2.php | 18 ------------------ 7 files changed, 26 insertions(+), 55 deletions(-) delete mode 100644 appinfo/app.php delete mode 100644 lib/RawPreviewIProvider2.php diff --git a/Makefile b/Makefile index 3992dd4..e8d50ab 100644 --- a/Makefile +++ b/Makefile @@ -127,10 +127,8 @@ appstore: --exclude=".*" \ --exclude="sign-*.sh" - docker run --user 1000 --rm -v $(appstore_build_directory)/$(app_name):/$(app_name) -v ~/.owncloud/certificates:/certs owncloud/server:10.0.9 php occ integrity:sign-app --path=/$(app_name) --privateKey="/certs/camerarawpreviews.key" --certificate="/certs/camerarawpreviews.crt" - tar -czlf build/$(app_name)_owncloud.tar.gz -C "$(appstore_build_directory)" $(app_name) rm "$(appstore_build_directory)"/$(app_name)/appinfo/signature.json - docker run --rm -v $(appstore_build_directory)/$(app_name):/$(app_name) -v ~/.nextcloud/certificates:/certs nextcloud:17-apache php /usr/src/nextcloud/occ integrity:sign-app --path=/$(app_name) --privateKey="/certs/camerarawpreviews.key" --certificate="/certs/camerarawpreviews.crt" + docker run --rm -v $(appstore_build_directory)/$(app_name):/$(app_name) -v ~/.nextcloud/certificates:/certs nextcloud:24-apache php /usr/src/nextcloud/occ integrity:sign-app --path=/$(app_name) --privateKey="/certs/camerarawpreviews.key" --certificate="/certs/camerarawpreviews.crt" tar -czf build/$(app_name)_nextcloud.tar.gz -C "$(appstore_build_directory)" $(app_name) # Builds the source package for the app store, ignores php and js tests diff --git a/README.md b/README.md index 6a6def9..47cd0b3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Camera RAW Previews [![Github All Releases](https://img.shields.io/github/downloads/ariselseng/camerarawpreviews/total.svg)](https://github.com/ariselseng/camerarawpreviews/releases) [![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/AriSelseng/2EUR) -A Nextcloud/ownCloud app that provides previews for camera RAW images like .CR2, .CRW, .DNG, .MRW, .NEF, .NRW, .RW2, .SRW, .SRW, etc. +A Nextcloud app that provides previews for camera RAW images like .CR2, .CRW, .DNG, .MRW, .NEF, .NRW, .RW2, .SRW, .SRW, etc. This app also gives you preview of Adobe Indesign files (.INDD). @@ -14,7 +14,7 @@ This app also gives you preview of Adobe Indesign files (.INDD). Install in Nextcloud App store. https://apps.nextcloud.com/apps/camerarawpreviews -Install in ownCloud Marketplace +Install in ownCloud Marketplace (older version that is not supported anymore, due to too much difference between owncloud and nextcloud now) https://marketplace.owncloud.com/apps/camerarawpreviews ## Building locally diff --git a/appinfo/app.php b/appinfo/app.php deleted file mode 100644 index 565a577..0000000 --- a/appinfo/app.php +++ /dev/null @@ -1,6 +0,0 @@ -query(Application::class); -$app->register(); \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml index 003e21c..aa591ed 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,10 +3,10 @@ xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd"> camerarawpreviews Camera RAW Previews - Preview and show camera RAW files in Nextcloud/ownCloud + Preview and show camera RAW files in Nextcloud - - 0.7.15 + + 0.7.16 agpl Ari Selseng CameraRawPreviews @@ -16,8 +16,7 @@ https://github.com/ariselseng/camerarawpreviews/issues - - + diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9c75525..8a33635 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -2,12 +2,15 @@ namespace OCA\CameraRawPreviews\AppInfo; -use OCA\CameraRawPreviews\RawPreviewIProvider2; use OCA\CameraRawPreviews\RawPreviewIProviderV2; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\EventDispatcher\IEventDispatcher; use OCP\AppFramework\App; use OCP\Util; -class Application extends App +class Application extends App implements IBootstrap { private $appName = 'camerarawpreviews'; @@ -16,30 +19,28 @@ public function __construct() parent::__construct($this->appName); } - public function register() - { - $this->registerScripts(); - $this->registerProvider(); + public function register(IRegistrationContext $context): void { + include_once __DIR__ . '/../../vendor/autoload.php'; + + $this->registerProvider($context); } - private function registerScripts() + private function registerScripts(IBootContext $context) { + if (!class_exists('\OCA\Viewer\Event\LoadViewer')) { return; } - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); + $eventDispatcher = $context->getServerContainer()->get(IEventDispatcher::class); $eventDispatcher->addListener(\OCA\Viewer\Event\LoadViewer::class, function () { Util::addScript($this->appName, 'register-viewer'); // adds js/script.js }); } - private function registerProvider() + private function registerProvider(IRegistrationContext $context) { - $appName = $this->appName; $server = $this->getContainer()->getServer(); - $logger = $server->getLogger(); - $previewManager = $server->query('PreviewManager'); $mimeTypeDetector = $server->getMimeTypeDetector(); $mimeTypeDetector->getAllMappings(); // is really needed @@ -72,13 +73,11 @@ private function registerProvider() 'x3f' => ['image/x-dcraw'], ]; $mimeTypeDetector->registerTypeArray($mimesToDetect); + $context->registerPreviewProvider(RawPreviewIProviderV2::class, '/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/'); + } - $previewManager->registerProvider('/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/', function () use ($logger, $appName) { - if (interface_exists('\OCP\Preview\IProvider2')) { - return new RawPreviewIProvider2($logger, $appName); - } - return new RawPreviewIProviderV2($logger, $appName); - }); + public function boot(IBootContext $context): void { + $this->registerScripts($context); } } diff --git a/lib/RawPreviewBase.php b/lib/RawPreviewBase.php index 20517fb..b95f6b3 100644 --- a/lib/RawPreviewBase.php +++ b/lib/RawPreviewBase.php @@ -2,7 +2,6 @@ namespace OCA\CameraRawPreviews; -require __DIR__ . '/../vendor/autoload.php'; use Exception; use Intervention\Image\ImageManagerStatic as Image; @@ -25,10 +24,10 @@ class RawPreviewBase protected $appName; protected $tmpFiles = []; - public function __construct(ILogger $logger, string $appName) + public function __construct(ILogger $logger) { $this->logger = $logger; - $this->appName = $appName; + $this->appName = 'camerarawpreviews'; } /** diff --git a/lib/RawPreviewIProvider2.php b/lib/RawPreviewIProvider2.php deleted file mode 100644 index ede5ec7..0000000 --- a/lib/RawPreviewIProvider2.php +++ /dev/null @@ -1,18 +0,0 @@ -getThumbnailInternal($file, $maxX, $maxY) ?? false; - } -} -