[gnome-documents/wip/lokdocview-rebase: 10/19] Share the code between ownCloud and local backends
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/lokdocview-rebase: 10/19] Share the code between ownCloud and local backends
- Date: Mon, 4 Jan 2016 16:54:08 +0000 (UTC)
commit bfcba1802af1f2a0e807738be94fa3aa0b25b0d2
Author: Bastien Nocera <hadess hadess net>
Date: Fri Dec 4 19:06:32 2015 +0100
Share the code between ownCloud and local backends
Because they both load files through GIO/gvfs mounted filesystems. This
means that OwnCloud should be able to load LibreOffice documents now.
src/documents.js | 76 +++++++++++++++++++++++++----------------------------
1 files changed, 36 insertions(+), 40 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 2bea4c6..3378de2 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -592,6 +592,40 @@ const DocCommon = new Lang.Class({
Application.searchCategoryManager.disconnect(this._filterId);
},
+ loadLocal: function(passwd, cancellable, callback) {
+ if (this.mimeType == 'application/epub+zip' ||
+ this.mimeType == 'application/x-mobipocket-ebook' ||
+ this.mimeType == 'application/x-fictionbook+xml' ||
+ this.mimeType == 'application/x-zip-compressed-fb2') {
+ let exception = new GLib.Error(Gio.IOErrorEnum,
+ Gio.IOErrorEnum.NOT_SUPPORTED,
+ "Internal error: Ebooks preview isn't support yet");
+ callback(this, null, exception);
+ return;
+ }
+
+ if (LOKView.isOpenDocumentFormat(this.mimeType) && !Application.application.isBooks) {
+ let exception = null;
+ if (!LOKView.isAvailable()) {
+ exception = new GLib.Error(Gio.IOErrorEnum,
+ Gio.IOErrorEnum.NOT_SUPPORTED,
+ "Internal error: LibreOffice isn't available");
+ }
+ callback (this, null, exception);
+ return;
+ }
+
+ GdPrivate.pdf_loader_load_uri_async(this.uri, passwd, cancellable, Lang.bind(this,
+ function(source, res) {
+ try {
+ let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
+ callback(this, docModel, null);
+ } catch (e) {
+ callback(this, null, e);
+ }
+ }));
+ },
+
open: function(screen, timestamp) {
if (!this.defaultAppName)
return;
@@ -731,37 +765,7 @@ const LocalDocument = new Lang.Class({
},
load: function(passwd, cancellable, callback) {
- if (this.mimeType == 'application/epub+zip' ||
- this.mimeType == 'application/x-mobipocket-ebook' ||
- this.mimeType == 'application/x-fictionbook+xml' ||
- this.mimeType == 'application/x-zip-compressed-fb2') {
- let exception = new GLib.Error(Gio.IOErrorEnum,
- Gio.IOErrorEnum.NOT_SUPPORTED,
- "Internal error: Ebooks preview isn't support yet");
- callback(this, null, exception);
- return;
- }
-
- if (LOKView.isOpenDocumentFormat(this.mimeType) && !Application.application.isBooks) {
- let exception = null;
- if (!LOKView.isAvailable()) {
- exception = new GLib.Error(Gio.IOErrorEnum,
- Gio.IOErrorEnum.NOT_SUPPORTED,
- "Internal error: LibreOffice isn't available");
- }
- callback (this, null, exception);
- return;
- }
-
- GdPrivate.pdf_loader_load_uri_async(this.uri, passwd, cancellable, Lang.bind(this,
- function(source, res) {
- try {
- let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
- callback(this, docModel, null);
- } catch (e) {
- callback(this, null, e);
- }
- }));
+ this.loadLocal(passwd, cancellable, callback);
},
canEdit: function() {
@@ -1013,15 +1017,7 @@ const OwncloudDocument = new Lang.Class({
},
load: function(passwd, cancellable, callback) {
- GdPrivate.pdf_loader_load_uri_async(this.uri, passwd, cancellable, Lang.bind(this,
- function(source, res) {
- try {
- let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
- callback(this, docModel, null);
- } catch (e) {
- callback(this, null, e);
- }
- }));
+ this.loadLocal(passwd, cancellable, callback);
},
canEdit: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]