Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-05-29 13:22:58 +0300
committerGitHub <noreply@github.com>2020-05-29 13:22:58 +0300
commit95029aeb46786fc4daf5daa8010412a3471282f5 (patch)
tree5373bb687781e9b1e9907f87d3c5776d004a05ee /lib
parenteebb667acde93c7429ccfeb5f9135a23c254f03f (diff)
parent512499670845653e36eaadb29ed9529da1097dc1 (diff)
Merge pull request #993 from mrkara/master
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php37
-rw-r--r--lib/Service/CapabilitiesService.php5
2 files changed, 42 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index bf8237f0..dfbd7b89 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -27,18 +27,24 @@ namespace OCA\Richdocuments\AppInfo;
use OC\Files\Type\Detection;
use OC\Security\CSP\ContentSecurityPolicy;
use OCA\Federation\TrustedServers;
+use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Capabilities;
use OCA\Richdocuments\Preview\MSExcel;
use OCA\Richdocuments\Preview\MSWord;
use OCA\Richdocuments\Preview\OOXML;
use OCA\Richdocuments\Preview\OpenDocument;
use OCA\Richdocuments\Preview\Pdf;
+use OCA\Richdocuments\Service\CapabilitiesService;
use OCA\Richdocuments\Service\FederationService;
+use OCA\Richdocuments\WOPI\DiscoveryManager;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\App;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IPreview;
+
+
+
class Application extends App {
const APPNAME = 'richdocuments';
@@ -131,4 +137,35 @@ class Application extends App {
$cspManager->addDefaultPolicy($policy);
}
+
+ public function checkAndEnableCODEServer() {
+ // Supported only on Linux OS, and x86_64 platform
+ if (PHP_OS_FAMILY !== 'Linux' || php_uname('m') !== 'x86_64')
+ return;
+
+ if ($this->getContainer()->getServer()->getAppManager()->isEnabledForUser('richdocumentscode')) {
+ $appConfig = $this->getContainer()->query(AppConfig::class);
+ $wopi_url = $appConfig->getAppValue('wopi_url');
+
+ // Check if we have the wopi_url set currently
+ if ($wopi_url !== null && $wopi_url !== '') {
+ return;
+ }
+
+ $urlGenerator = \OC::$server->getURLGenerator();
+ $relativeUrl = $urlGenerator->linkTo('richdocumentscode', '') . 'proxy.php';
+ $absoluteUrl = $urlGenerator->getAbsoluteURL($relativeUrl);
+ $wopi_url = $absoluteUrl . '?req=';
+
+ $appConfig->setAppValue('wopi_url', $wopi_url);
+ $appConfig->setAppValue('disable_certificate_verification', 'yes');
+
+ $discoveryManager = $this->getContainer()->query(DiscoveryManager::class);
+ $capabilitiesService = $this->getContainer()->query(CapabilitiesService::class);
+
+ $discoveryManager->refretch();
+ $capabilitiesService->clear();
+ $capabilitiesService->refretch();
+ }
+ }
}
diff --git a/lib/Service/CapabilitiesService.php b/lib/Service/CapabilitiesService.php
index c6eb90b4..8cdd3264 100644
--- a/lib/Service/CapabilitiesService.php
+++ b/lib/Service/CapabilitiesService.php
@@ -54,6 +54,11 @@ class CapabilitiesService {
public function getCapabilities() {
if ($this->capabilities) {
+ $isCODEInstalled = $this->getContainer()->getServer()->getAppManager()->isEnabledForUser('richdocumentscode');
+ $isCODEEnabled = strpos($this->config->getAppValue('richdocuments', 'wopi_url'), 'proxy.php?req=') !== false;
+ if($isCODEInstalled && $isCODEEnabled && count($this->capabilities) === 0) {
+ $this->refretch();
+ }
return $this->capabilities;
}
try {