Add DownloadAsPostMessage
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
a008e964c2
Коммит
28c0e502ba
|
@ -81,6 +81,12 @@
|
|||
<default>false</default>
|
||||
<notnull>true</notnull>
|
||||
</field>
|
||||
<field>
|
||||
<name>direct</name>
|
||||
<type>boolean</type>
|
||||
<default>false</default>
|
||||
<notnull>true</notnull>
|
||||
</field>
|
||||
|
||||
<index>
|
||||
<name>rd_wopi_token_idx</name>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<name>Collabora Online</name>
|
||||
<summary>Edit office documents directly in your browser.</summary>
|
||||
<description>This application can connect to a Collabora Online server (WOPI Client). Nextcloud is the WOPI Host. Please read the documentation to learn more about that.</description>
|
||||
<version>3.3.9</version>
|
||||
<version>3.3.9-1</version>
|
||||
<licence>agpl</licence>
|
||||
<author>Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk</author>
|
||||
<types>
|
||||
|
|
|
@ -683,6 +683,17 @@ var documentsMain = {
|
|||
msgId = e.data;
|
||||
}
|
||||
|
||||
if (msgId === 'Download_As') {
|
||||
console.log('download for ' + args.Type + '. Use this url: ' + args.URL);
|
||||
if (
|
||||
window.RichDocumentsMobileInterface ||
|
||||
(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.RichDocumentsMobileInterface)
|
||||
) {
|
||||
documentsMain.callMobileMessage('downloadAs', args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for webview handler
|
||||
if (window.RichDocumentsMobileInterface) {
|
||||
if (msgId === 'UI_Close') {
|
||||
|
@ -926,7 +937,7 @@ var documentsMain = {
|
|||
}
|
||||
}
|
||||
// Forward to mobile handler
|
||||
if (window.RichDocumentsMobileInterface && typeof window.RichDocumentsMobileInterface[messageName] !== 'undefined') {
|
||||
if (window.RichDocumentsMobileInterface && typeof window.RichDocumentsMobileInterface[messageName] === 'function') {
|
||||
window.RichDocumentsMobileInterface[messageName](attributes);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class DirectViewController extends Controller {
|
|||
}
|
||||
|
||||
try {
|
||||
list($urlSrc, $token) = $this->tokenManager->getTokenForTemplate($item, $direct->getUid(), $direct->getTemplateDestination());
|
||||
list($urlSrc, $token) = $this->tokenManager->getTokenForTemplate($item, $direct->getUid(), $direct->getTemplateDestination(), true);
|
||||
} catch (\Exception $e) {
|
||||
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class DirectViewController extends Controller {
|
|||
throw new \Exception();
|
||||
}
|
||||
|
||||
list($urlSrc, $token) = $this->tokenManager->getToken($item->getId(), null, $direct->getUid());
|
||||
list($urlSrc, $token) = $this->tokenManager->getToken($item->getId(), null, $direct->getUid(), true);
|
||||
} catch (\Exception $e) {
|
||||
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,8 @@ class WopiController extends Controller {
|
|||
'DisableExport' => $wopi->getHideDownload(),
|
||||
'DisableCopy' => $wopi->getHideDownload(),
|
||||
'HideExportOption' => $wopi->getHideDownload(),
|
||||
'HidePrintOption' => $wopi->getHideDownload()
|
||||
'HidePrintOption' => $wopi->getHideDownload(),
|
||||
'DownloadAsPostMessage' => $wopi->getDirect(),
|
||||
];
|
||||
|
||||
if ($wopi->isTemplateToken()) {
|
||||
|
|
|
@ -84,6 +84,9 @@ class Wopi extends Entity {
|
|||
/** @var bool */
|
||||
protected $hideDownload;
|
||||
|
||||
/** @var bool */
|
||||
protected $direct;
|
||||
|
||||
public function __construct() {
|
||||
$this->addType('owner_uid', 'string');
|
||||
$this->addType('editor_uid', 'string');
|
||||
|
@ -96,6 +99,8 @@ class Wopi extends Entity {
|
|||
$this->addType('guest_displayname', 'string');
|
||||
$this->addType('templateDestination', 'int');
|
||||
$this->addType('hide_download', 'bool');
|
||||
$this->addType('direct', 'bool');
|
||||
|
||||
}
|
||||
|
||||
public function isTemplateToken() {
|
||||
|
|
|
@ -64,7 +64,7 @@ class WopiMapper extends Mapper {
|
|||
* @param int $templateDestination
|
||||
* @return Wopi
|
||||
*/
|
||||
public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname, $templateDestination = 0, $hideDownload = false) {
|
||||
public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname, $templateDestination = 0, $hideDownload = false, $direct = false) {
|
||||
$token = $this->random->generate(32, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
|
||||
|
||||
$wopi = Wopi::fromParams([
|
||||
|
@ -78,7 +78,8 @@ class WopiMapper extends Mapper {
|
|||
'expiry' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME_SECONDS,
|
||||
'guestDisplayname' => $guestDisplayname,
|
||||
'templateDestination' => $templateDestination,
|
||||
'hideDownload' => $hideDownload
|
||||
'hideDownload' => $hideDownload,
|
||||
'direct' => $direct
|
||||
]);
|
||||
|
||||
/** @var Wopi $wopi */
|
||||
|
|
|
@ -95,7 +95,7 @@ class TokenManager {
|
|||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getToken($fileId, $shareToken = null, $editoruid = null) {
|
||||
public function getToken($fileId, $shareToken = null, $editoruid = null, $direct = false) {
|
||||
list($fileId,, $version) = Helper::parseFileId($fileId);
|
||||
$owneruid = null;
|
||||
$hideDownload = false;
|
||||
|
@ -169,7 +169,7 @@ class TokenManager {
|
|||
$guest_name = NULL;
|
||||
}
|
||||
|
||||
$wopi = $this->wopiMapper->generateFileToken($fileId, $owneruid, $editoruid, $version, (int)$updatable, $serverHost, $guest_name, 0, $hideDownload);
|
||||
$wopi = $this->wopiMapper->generateFileToken($fileId, $owneruid, $editoruid, $version, (int)$updatable, $serverHost, $guest_name, 0, $hideDownload, $direct);
|
||||
|
||||
try {
|
||||
|
||||
|
@ -182,7 +182,7 @@ class TokenManager {
|
|||
}
|
||||
}
|
||||
|
||||
public function getTokenForTemplate(File $file, $userId, $templateDestination) {
|
||||
public function getTokenForTemplate(File $file, $userId, $templateDestination, $direct = false) {
|
||||
$owneruid = $userId;
|
||||
$editoruid = $userId;
|
||||
$updatable = $file->isUpdateable();
|
||||
|
@ -205,7 +205,7 @@ class TokenManager {
|
|||
|
||||
$serverHost = $this->urlGenerator->getAbsoluteURL('/');
|
||||
|
||||
$wopi = $this->wopiMapper->generateFileToken($file->getId(), $owneruid, $editoruid, 0, (int)$updatable, $serverHost, null, $templateDestination);
|
||||
$wopi = $this->wopiMapper->generateFileToken($file->getId(), $owneruid, $editoruid, 0, (int)$updatable, $serverHost, null, $templateDestination, $direct);
|
||||
|
||||
return [
|
||||
$this->wopiParser->getUrlSrc($file->getMimeType())['urlsrc'],
|
||||
|
|
Загрузка…
Ссылка в новой задаче