Allow IProviderV2 for previews as well

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-07-03 12:02:31 +02:00
parent eaabe97373
commit 4505afe184
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
3 changed files with 28 additions and 13 deletions

View File

@ -25,6 +25,7 @@
namespace OC\Preview;
use OC\Preview\GeneratorHelper;
use OCP\Files\File;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
@ -34,9 +35,7 @@ use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IImage;
use OCP\IPreview;
use OCP\Preview\IProvider;
use OCP\Preview\IProviderV2;
use OCP\Preview\IVersionedPreviewFile;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;

View File

@ -35,7 +35,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IConfig;
use OCP\IPreview;
use OCP\Preview\IProvider;
use OCP\Preview\IProviderV2;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class PreviewManager implements IPreview {
@ -53,6 +53,9 @@ class PreviewManager implements IPreview {
/** @var Generator */
private $generator;
/** @var GeneratorHelper */
private $helper;
/** @var bool */
protected $providerListDirty = false;
@ -85,11 +88,13 @@ class PreviewManager implements IPreview {
IRootFolder $rootFolder,
IAppData $appData,
EventDispatcherInterface $eventDispatcher,
GeneratorHelper $helper,
$userId) {
$this->config = $config;
$this->rootFolder = $rootFolder;
$this->appData = $appData;
$this->eventDispatcher = $eventDispatcher;
$this->helper = $helper;
$this->userId = $userId;
}
@ -255,9 +260,9 @@ class PreviewManager implements IPreview {
foreach ($this->providers as $supportedMimeType => $providers) {
if (preg_match($supportedMimeType, $file->getMimetype())) {
foreach ($providers as $closure) {
$provider = $closure();
if (!($provider instanceof IProvider)) {
foreach ($providers as $providerClosure) {
$provider = $this->helper->getProvider($providerClosure);
if (!($provider instanceof IProviderV2)) {
continue;
}

View File

@ -68,6 +68,7 @@ use OC\Command\CronBus;
use OC\Comments\ManagerFactory as CommentsManagerFactory;
use OC\Contacts\ContactsMenu\ActionFactory;
use OC\Contacts\ContactsMenu\ContactsStore;
use OC\Dashboard\DashboardManager;
use OC\Diagnostics\EventLogger;
use OC\Diagnostics\QueryLogger;
use OC\Federation\CloudFederationFactory;
@ -99,19 +100,20 @@ use OC\Memcache\ArrayCache;
use OC\Memcache\Factory;
use OC\Notification\Manager;
use OC\OCS\DiscoveryService;
use OC\Preview\GeneratorHelper;
use OC\Remote\Api\ApiFactory;
use OC\Remote\InstanceFactory;
use OC\RichObjectStrings\Validator;
use OC\Security\Bruteforce\Throttler;
use OC\Security\CertificateManager;
use OC\Security\CSP\ContentSecurityPolicyManager;
use OC\Security\CredentialsManager;
use OC\Security\Crypto;
use OC\Security\CSP\ContentSecurityPolicyManager;
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OC\Security\CSRF\CsrfTokenGenerator;
use OC\Security\CSRF\CsrfTokenManager;
use OC\Security\CSRF\TokenStorage\SessionStorage;
use OC\Security\Hasher;
use OC\Security\CredentialsManager;
use OC\Security\SecureRandom;
use OC\Security\TrustedDomainHelper;
use OC\Session\CryptoWrapper;
@ -122,21 +124,20 @@ use OC\Tagging\TagMapper;
use OC\Template\IconsCacher;
use OC\Template\JSCombiner;
use OC\Template\SCSSCacher;
use OC\Dashboard\DashboardManager;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\Authentication\LoginCredentials\IStore;
use OCP\Collaboration\AutoComplete\IManager;
use OCP\Contacts\ContactsMenu\IActionFactory;
use OCP\Contacts\ContactsMenu\IContactsStore;
use OCP\Dashboard\IDashboardManager;
use OCP\Defaults;
use OCA\Theming\Util;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\Authentication\LoginCredentials\IStore;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\FullTextSearch\IFullTextSearchManager;
@ -148,7 +149,6 @@ use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IServerContainer;
use OCP\ITempManager;
use OCP\Contacts\ContactsMenu\IActionFactory;
use OCP\IUser;
use OCP\Lock\ILockingProvider;
use OCP\Log\ILogFactory;
@ -207,6 +207,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->getRootFolder(),
$c->getAppDataDir('preview'),
$c->getEventDispatcher(),
$c->getGeneratorHelper(),
$c->getSession()->get('user_id')
);
});
@ -2060,4 +2061,14 @@ class Server extends ServerContainer implements IServerContainer {
public function getStorageFactory() {
return $this->query(IStorageFactory::class);
}
/**
* Get the Preview GeneratorHelper
*
* @return GeneratorHelper
* @since 17.0.0
*/
public function getGeneratorHelper() {
return $this->query(\OC\Preview\GeneratorHelper::class);
}
}