[gnome-documents/wip/rishi/onedrive: 7/8] documents: Fix previewing of LOKDocView-supported OneDrive documents



commit 98760f5eb467e9e0117eff51c5e8fcc5d77162be
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Mar 30 18:31:18 2017 +0200

    documents: Fix previewing of LOKDocView-supported OneDrive documents
    
    OneDrive documents were being converted to PDFs via GdPdfLoader, but
    LOKDocView was being used instead of EvView to render them. LOKDocView
    uses the document's URI property, and in this case it is not a valid
    URI that it can use. As a result the preview would fail and sometimes
    crash the application.
    
    Solve all that by removing the PDF conversion, and passing the correct
    URI to LOKDocView.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774937

 src/documents.js |   51 +++++++++++++++++++++++++++------------------------
 1 files changed, 27 insertions(+), 24 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 9136255..fe6d94c 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -1245,34 +1245,37 @@ const SkydriveDocument = new Lang.Class({
     },
 
     load: function(passwd, cancellable, callback) {
-        this._createZpjEntry(cancellable, Lang.bind(this,
-            function(entry, service, exception) {
-                if (exception) {
-                    // try loading from the most recent cache, if any
-                    GdPrivate.pdf_loader_load_uri_async(this.identifier, passwd, cancellable, Lang.bind(this,
-                        function(source, res) {
-                            try {
-                                let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
-                                callback(this, docModel, null);
-                            } catch (e) {
-                                // report the outmost error only
-                                callback(this, null, exception);
-                            }
-                        }));
-
+        this.download(true, cancellable, Lang.bind(this,
+            function(fromCache, error) {
+                if (error) {
+                    callback(this, null, error);
                     return;
                 }
 
-                GdPrivate.pdf_loader_load_zpj_entry_async
-                    (entry, service, cancellable, Lang.bind(this,
-                        function(source, res) {
-                            try {
-                                let docModel = GdPrivate.pdf_loader_load_zpj_entry_finish(res);
-                                callback(this, docModel, null);
-                            } catch (e) {
-                                callback(this, null, e);
+                this.loadLocal(passwd, cancellable, Lang.bind(this,
+                    function(doc, docModel, error) {
+                        if (error) {
+                            if (error.matches(EvDocument.DocumentError, EvDocument.DocumentError.ENCRYPTED)) 
{
+                                callback(this, null, error);
+                            } else if (fromCache) {
+                                this.download(false, cancellable, Lang.bind(this,
+                                    function(fromCache, error) {
+                                        if (error) {
+                                            callback(this, null, error);
+                                            return;
+                                        }
+
+                                        this.loadLocal(passwd, cancellable, callback);
+                                    }));
+                            } else {
+                                callback(this, null, error);
                             }
-                        }));
+
+                            return;
+                        }
+
+                        callback(this, docModel, null);
+                    }));
             }));
     },
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]