Blame SOURCES/gnome-documents-skydrive-printing-and-lok-fixes.patch

ce5a06
From 4ba7db7a91de431134c23bd2b43ca4e5e63e2bac Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Wed, 29 Mar 2017 16:04:08 +0200
ce5a06
Subject: [PATCH 01/16] documents: Simplify calculation of thumbnail paths for
ce5a06
 GoogleDocuments
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=780718
ce5a06
---
ce5a06
 src/documents.js | 9 ++++-----
ce5a06
 1 file changed, 4 insertions(+), 5 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 50cfbdafc7ee..2071882218b2 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -30,6 +30,7 @@ const GdPrivate = imports.gi.GdPrivate;
ce5a06
 const Gdk = imports.gi.Gdk;
ce5a06
 const GData = imports.gi.GData;
ce5a06
 const GLib = imports.gi.GLib;
ce5a06
+const GnomeDesktop = imports.gi.GnomeDesktop;
ce5a06
 const Gtk = imports.gi.Gtk;
ce5a06
 const Zpj = imports.gi.Zpj;
ce5a06
 const _ = imports.gettext.gettext;
ce5a06
@@ -916,12 +917,10 @@ const GoogleDocument = new Lang.Class({
ce5a06
                                                              authorization_domain: authorizationDomain,
ce5a06
                                                              download_uri: uri });
ce5a06
 
ce5a06
-                let checksum = new GLib.Checksum(GLib.ChecksumType.MD5);
ce5a06
-                checksum.update(this.uri, -1);
ce5a06
-                let dirPath = GLib.build_filenamev([GLib.get_user_cache_dir(), "thumbnails", "normal"]);
ce5a06
+                let path = GnomeDesktop.desktop_thumbnail_path_for_uri (this.uri,
ce5a06
+                                                                        GnomeDesktop.DesktopThumbnailSize.NORMAL);
ce5a06
+                let dirPath = GLib.path_get_dirname(path);
ce5a06
                 GLib.mkdir_with_parents(dirPath, 448);
ce5a06
-                let basename = checksum.get_string() + '.png';
ce5a06
-                let path = GLib.build_filenamev([dirPath, basename])
ce5a06
 
ce5a06
                 let downloadFile = Gio.File.new_for_path(path);
ce5a06
                 downloadFile.replace_async
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 7597a3e77b5c0192fc848f5fc7f65bb5b662ed20 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 30 Mar 2017 16:54:15 +0200
ce5a06
Subject: [PATCH 02/16] documents: Track nfo:fileName for later use
ce5a06
ce5a06
Now that we can open ODFs and OOXMLs in LOKDocView, we don't need to
ce5a06
convert all remote documents to PDF. For example, we can open office
ce5a06
documents stored from OneDrive without any format conversion. The
ce5a06
nfo:fileName can be used to determine the extension of the cached file.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 src/documents.js | 7 ++++---
ce5a06
 1 file changed, 4 insertions(+), 3 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 2071882218b2..6ecc255c9407 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -229,6 +229,7 @@ const DocCommon = new Lang.Class({
ce5a06
     _init: function(cursor) {
ce5a06
         this.id = null;
ce5a06
         this.uri = null;
ce5a06
+        this.filename = null;
ce5a06
         this.name = null;
ce5a06
         this.author = null;
ce5a06
         this.mtime = null;
ce5a06
@@ -306,12 +307,12 @@ const DocCommon = new Lang.Class({
ce5a06
             this.uri = '';
ce5a06
 
ce5a06
         let title = cursor.get_string(Query.QueryColumns.TITLE)[0];
ce5a06
-        let filename = cursor.get_string(Query.QueryColumns.FILENAME)[0];
ce5a06
+        this.filename = cursor.get_string(Query.QueryColumns.FILENAME)[0];
ce5a06
 
ce5a06
         if (title && title != '')
ce5a06
             this.name = title;
ce5a06
-        else if (filename)
ce5a06
-            this.name = GdPrivate.filename_strip_extension(filename);
ce5a06
+        else if (this.filename)
ce5a06
+            this.name = GdPrivate.filename_strip_extension(this.filename);
ce5a06
         else
ce5a06
             this.name = '';
ce5a06
 
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 291a12b177411b960c91413a51f05493daf98bd1 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 30 Mar 2017 17:25:44 +0200
ce5a06
Subject: [PATCH 03/16] documents: Add property to denote the URI to be loaded
ce5a06
 by the preview
ce5a06
ce5a06
We want to open ODFs and OOXMLs from OneDrive using LOKDocView, not
ce5a06
EvView. Therefore, the logic to convert a remote document into
ce5a06
something that can be loaded by the different preview widgets can no
ce5a06
longer be hidden inside GdPdfLoader. LOKDocView needs to know the URI
ce5a06
it can load without hitting the network.
ce5a06
ce5a06
For local and ownCloud this is the same as the actual URI because they
ce5a06
are natively handled by GIO. The property is not defined for Google
ce5a06
because it is still handled entirely by GdPdfLoader.
ce5a06
ce5a06
This changes the caching for SkydriveDocuments. The old scheme was:
ce5a06
  ~/.cache/gnome-documents/gnome-documents-<g_str_hash(id)>.pdf
ce5a06
The new structure is:
ce5a06
  ~/.cache/gnome-documents/skydrive/<SHA1(id)>.<original-extension>
ce5a06
ce5a06
The new scheme namespaces each document type and uses a hash function
ce5a06
that can be easily replicated by other tools for debugging. This is a
ce5a06
good time to change this because we are about to invalidate existing
ce5a06
caches by not using the ".pdf" extension for all SkydriveDocuments.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 src/documents.js | 24 +++++++++++++++++++++++-
ce5a06
 src/epubview.js  |  2 +-
ce5a06
 src/lokview.js   |  2 +-
ce5a06
 3 files changed, 25 insertions(+), 3 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 6ecc255c9407..c50d50078f2f 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -229,6 +229,7 @@ const DocCommon = new Lang.Class({
ce5a06
     _init: function(cursor) {
ce5a06
         this.id = null;
ce5a06
         this.uri = null;
ce5a06
+        this.uriToLoad = null;
ce5a06
         this.filename = null;
ce5a06
         this.name = null;
ce5a06
         this.author = null;
ce5a06
@@ -618,7 +619,7 @@ const DocCommon = new Lang.Class({
ce5a06
             return;
ce5a06
         }
ce5a06
 
ce5a06
-        GdPrivate.pdf_loader_load_uri_async(this.uri, passwd, cancellable, Lang.bind(this,
ce5a06
+        GdPrivate.pdf_loader_load_uri_async(this.uriToLoad, passwd, cancellable, Lang.bind(this,
ce5a06
             function(source, res) {
ce5a06
                 try {
ce5a06
                     let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
ce5a06
@@ -749,6 +750,7 @@ const LocalDocument = new Lang.Class({
ce5a06
 
ce5a06
     populateFromCursor: function(cursor) {
ce5a06
         this.parent(cursor);
ce5a06
+        this.uriToLoad = this.uri;
ce5a06
 
ce5a06
         if (!Application.application.gettingStartedLocation)
ce5a06
             return;
ce5a06
@@ -1013,6 +1015,11 @@ const OwncloudDocument = new Lang.Class({
ce5a06
             this.defaultAppName = this.defaultApp.get_name();
ce5a06
     },
ce5a06
 
ce5a06
+    populateFromCursor: function(cursor) {
ce5a06
+        this.parent(cursor);
ce5a06
+        this.uriToLoad = this.uri;
ce5a06
+    },
ce5a06
+
ce5a06
     createThumbnail: function(callback) {
ce5a06
         GdPrivate.queue_thumbnail_job_for_file_async(this._file, Lang.bind(this,
ce5a06
             function(object, res) {
ce5a06
@@ -1071,6 +1078,21 @@ const SkydriveDocument = new Lang.Class({
ce5a06
         this.sourceName = _("OneDrive");
ce5a06
     },
ce5a06
 
ce5a06
+    populateFromCursor: function(cursor) {
ce5a06
+        this.parent(cursor);
ce5a06
+
ce5a06
+        let localDir = GLib.build_filenamev([GLib.get_user_cache_dir(), "gnome-documents", "skydrive"]);
ce5a06
+
ce5a06
+        let identifierHash = GLib.compute_checksum_for_string(GLib.ChecksumType.SHA1, this.identifier, -1);
ce5a06
+        let filenameStripped = GdPrivate.filename_strip_extension(this.filename);
ce5a06
+        let extension = this.filename.substring(filenameStripped.length);
ce5a06
+        let localFilename = identifierHash + extension;
ce5a06
+
ce5a06
+        let localPath = GLib.build_filenamev([localDir, localFilename]);
ce5a06
+        let localFile = Gio.File.new_for_path(localPath);
ce5a06
+        this.uriToLoad = localFile.get_uri();
ce5a06
+    },
ce5a06
+
ce5a06
     _createZpjEntry: function(cancellable, callback) {
ce5a06
         let source = Application.sourceManager.getItemById(this.resourceUrn);
ce5a06
 
ce5a06
diff --git a/src/epubview.js b/src/epubview.js
ce5a06
index 923b0aa265ab..12f392225d6f 100644
ce5a06
--- a/src/epubview.js
ce5a06
+++ b/src/epubview.js
ce5a06
@@ -65,7 +65,7 @@ const EPUBView = new Lang.Class({
ce5a06
     onLoadFinished: function(manager, doc) {
ce5a06
         this.parent(manager, doc);
ce5a06
 
ce5a06
-        let f = Gio.File.new_for_uri(doc.uri);
ce5a06
+        let f = Gio.File.new_for_uri(doc.uriToLoad);
ce5a06
         this._epubdoc = new Gepub.Doc({ path: f.get_path() });
ce5a06
         this._epubdoc.init(null);
ce5a06
 
ce5a06
diff --git a/src/lokview.js b/src/lokview.js
ce5a06
index 092adc5a0471..988db963d5d9 100644
ce5a06
--- a/src/lokview.js
ce5a06
+++ b/src/lokview.js
ce5a06
@@ -148,7 +148,7 @@ const LOKView = new Lang.Class({
ce5a06
         if (!isAvailable())
ce5a06
             return;
ce5a06
         this._doc = doc;
ce5a06
-        this._lokview.open_document(doc.uri, '{}', null, Lang.bind(this, this._onDocumentOpened));
ce5a06
+        this._lokview.open_document(doc.uriToLoad, '{}', null, Lang.bind(this, this._onDocumentOpened));
ce5a06
         this._progressBar.show();
ce5a06
     },
ce5a06
 
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 0ea69b0519a4e374feabc1923c82e1e0c71d5914 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 30 Mar 2017 18:18:16 +0200
ce5a06
Subject: [PATCH 04/16] documents: Let everybody provide their own download
ce5a06
 implementation
ce5a06
ce5a06
This is meant to reduce our reliance on GdPdfLoader for loading remote
ce5a06
documents. We can open ODFs and OOXMLs in LOKDocView, so we don't need
ce5a06
to convert everything to PDFs. In the future, remote sub-classes will
ce5a06
provider their own implementation to download a document, and this will
ce5a06
help unify the loading across the various sub-classes.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 src/documents.js | 42 ++++++++++++++++++++++++++++++++++++++++++
ce5a06
 1 file changed, 42 insertions(+)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index c50d50078f2f..9028e9b5084f 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -360,6 +360,48 @@ const DocCommon = new Lang.Class({
ce5a06
         }
ce5a06
     },
ce5a06
 
ce5a06
+    download: function(useCache, cancellable, callback) {
ce5a06
+        let localFile = Gio.File.new_for_uri(this.uriToLoad);
ce5a06
+        let localPath = localFile.get_path();
ce5a06
+        let localDir = GLib.path_get_dirname(localPath);
ce5a06
+        GLib.mkdir_with_parents(localDir, 448);
ce5a06
+
ce5a06
+        if (!useCache) {
ce5a06
+            this.downloadImpl(localFile, cancellable, callback);
ce5a06
+            return;
ce5a06
+        }
ce5a06
+
ce5a06
+        localFile.query_info_async(Gio.FILE_ATTRIBUTE_TIME_MODIFIED,
ce5a06
+                                   Gio.FileQueryInfoFlags.NONE,
ce5a06
+                                   GLib.PRIORITY_DEFAULT,
ce5a06
+                                   cancellable,
ce5a06
+                                   Lang.bind(this,
ce5a06
+            function(object, res) {
ce5a06
+                let info;
ce5a06
+
ce5a06
+                try {
ce5a06
+                    info = object.query_info_finish(res);
ce5a06
+                } catch (e) {
ce5a06
+                    this.downloadImpl(localFile, cancellable, callback);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                let cacheMtime = info.get_attribute_uint64(Gio.FILE_ATTRIBUTE_TIME_MODIFIED);
ce5a06
+                cacheMtime /= 1000000;
ce5a06
+
ce5a06
+                if (this.mtime <= cacheMtime) {
ce5a06
+                    callback(true, null);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                this.downloadImpl(localFile, cancellable, callback);
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
+    downloadImpl: function(localFile, cancellable, callback) {
ce5a06
+        throw(new Error('DocCommon implementations must override downloadImpl'));
ce5a06
+    },
ce5a06
+
ce5a06
     load: function() {
ce5a06
         log('Error: DocCommon implementations must override load');
ce5a06
     },
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 630fc1a93bbd3a93ee242231a6a1129aef924127 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 30 Mar 2017 18:23:27 +0200
ce5a06
Subject: [PATCH 05/16] documents: Implement the downloadImpl vfunc for
ce5a06
 SkydriveDocument
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 src/documents.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ce5a06
 1 file changed, 56 insertions(+)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 9028e9b5084f..781019091754 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -1161,6 +1161,62 @@ const SkydriveDocument = new Lang.Class({
ce5a06
                  }));
ce5a06
     },
ce5a06
 
ce5a06
+    downloadImpl: function(localFile, cancellable, callback) {
ce5a06
+        this._createZpjEntry(cancellable, Lang.bind(this,
ce5a06
+            function(entry, service, error) {
ce5a06
+                if (error) {
ce5a06
+                    callback(false, error);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                service.download_file_to_stream_async(entry, cancellable, Lang.bind(this,
ce5a06
+                    function(object, res) {
ce5a06
+                        let inputStream;
ce5a06
+
ce5a06
+                        try {
ce5a06
+                            inputStream = object.download_file_to_stream_finish(res);
ce5a06
+                        } catch (e) {
ce5a06
+                            callback(false, e);
ce5a06
+                            return;
ce5a06
+                        }
ce5a06
+
ce5a06
+                        localFile.replace_async(null,
ce5a06
+                                                false,
ce5a06
+                                                Gio.FileCreateFlags.PRIVATE,
ce5a06
+                                                GLib.PRIORITY_DEFAULT,
ce5a06
+                                                cancellable,
ce5a06
+                                                Lang.bind(this,
ce5a06
+                            function(object, res) {
ce5a06
+                                let outputStream;
ce5a06
+
ce5a06
+                                try {
ce5a06
+                                    outputStream = object.replace_finish(res);
ce5a06
+                                } catch (e) {
ce5a06
+                                    callback(false, e);
ce5a06
+                                    return;
ce5a06
+                                }
ce5a06
+
ce5a06
+                                outputStream.splice_async(inputStream,
ce5a06
+                                                          Gio.OutputStreamSpliceFlags.CLOSE_SOURCE |
ce5a06
+                                                          Gio.OutputStreamSpliceFlags.CLOSE_TARGET,
ce5a06
+                                                          GLib.PRIORITY_DEFAULT,
ce5a06
+                                                          cancellable,
ce5a06
+                                                          Lang.bind(this,
ce5a06
+                                    function(object, res) {
ce5a06
+                                        try {
ce5a06
+                                            object.splice_finish(res);
ce5a06
+                                        } catch (e) {
ce5a06
+                                            callback(false, e);
ce5a06
+                                            return;
ce5a06
+                                        }
ce5a06
+
ce5a06
+                                        callback(false, null);
ce5a06
+                                    }));
ce5a06
+                            }));
ce5a06
+                    }));
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
     load: function(passwd, cancellable, callback) {
ce5a06
         this._createZpjEntry(cancellable, Lang.bind(this,
ce5a06
             function(entry, service, exception) {
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From c21f27f63ec2cf31c254896ad8343689b9cc9499 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 30 Mar 2017 18:31:18 +0200
ce5a06
Subject: [PATCH 06/16] documents, pdf-loader: Fix previewing of ODFs and
ce5a06
 OOXMLs on OneDrive
ce5a06
ce5a06
OneDrive documents were being converted to PDFs via GdPdfLoader, but
ce5a06
LOKDocView was being used instead of EvView to render them. LOKDocView
ce5a06
uses the document's URI property, and in this case it is not a valid
ce5a06
URI that it can use. As a result the preview would fail and sometimes
ce5a06
crash the application.
ce5a06
ce5a06
Solve all that by removing the PDF conversion, and passing the correct
ce5a06
URI to LOKDocView.
ce5a06
ce5a06
This effectively reverts 0bfb23786dc84d390c4bd6bde5f20987874e1e9b
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 configure.ac            |   4 +-
ce5a06
 src/documents.js        |  50 ++++++------
ce5a06
 src/lib/gd-pdf-loader.c | 205 +-----------------------------------------------
ce5a06
 src/lib/gd-pdf-loader.h |   9 ---
ce5a06
 4 files changed, 29 insertions(+), 239 deletions(-)
ce5a06
ce5a06
diff --git a/configure.ac b/configure.ac
ce5a06
index 78cda4f799d5..8098515028d1 100644
ce5a06
--- a/configure.ac
ce5a06
+++ b/configure.ac
ce5a06
@@ -57,7 +57,6 @@ GOBJECT_INTROSPECTION_MIN_VERSION=1.31.6
ce5a06
 GDATA_MIN_VERSION=0.13.3
ce5a06
 GOA_MIN_VERSION=3.2.0
ce5a06
 TRACKER_MIN_VERSION=0.17.3
ce5a06
-ZAPOJIT_MIN_VERSION=0.0.2
ce5a06
 SOUP_MIN_VERSION=2.41.3
ce5a06
 
ce5a06
 AC_ARG_ENABLE(documentation,
ce5a06
@@ -85,8 +84,7 @@ PKG_CHECK_MODULES(DOCUMENTS,
ce5a06
                   tracker-control-1.0 >= $TRACKER_MIN_VERSION
ce5a06
                   tracker-sparql-1.0 >= $TRACKER_MIN_VERSION
ce5a06
                   goa-1.0 >= $GOA_MIN_VERSION
ce5a06
-                  libgdata >= $GDATA_MIN_VERSION
ce5a06
-                  zapojit-0.0 >= $ZAPOJIT_MIN_VERSION)
ce5a06
+                  libgdata >= $GDATA_MIN_VERSION)
ce5a06
 
ce5a06
 # Although GTK+ 3.10 includes hi-dpi functionality, it does not require a cairo with
ce5a06
 # cairo_surface_set_device_scale(), which we also need if we're to support hi-dpi,
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 781019091754..ca48e53db25d 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -1218,34 +1218,36 @@ const SkydriveDocument = new Lang.Class({
ce5a06
     },
ce5a06
 
ce5a06
     load: function(passwd, cancellable, callback) {
ce5a06
-        this._createZpjEntry(cancellable, Lang.bind(this,
ce5a06
-            function(entry, service, exception) {
ce5a06
-                if (exception) {
ce5a06
-                    // try loading from the most recent cache, if any
ce5a06
-                    GdPrivate.pdf_loader_load_uri_async(this.identifier, passwd, cancellable, Lang.bind(this,
ce5a06
-                        function(source, res) {
ce5a06
-                            try {
ce5a06
-                                let docModel = GdPrivate.pdf_loader_load_uri_finish(res);
ce5a06
-                                callback(this, docModel, null);
ce5a06
-                            } catch (e) {
ce5a06
-                                // report the outmost error only
ce5a06
-                                callback(this, null, exception);
ce5a06
-                            }
ce5a06
-                        }));
ce5a06
-
ce5a06
+        this.download(true, cancellable, Lang.bind(this,
ce5a06
+            function(fromCache, error) {
ce5a06
+                if (error) {
ce5a06
+                    callback(this, null, error);
ce5a06
                     return;
ce5a06
                 }
ce5a06
 
ce5a06
-                GdPrivate.pdf_loader_load_zpj_entry_async
ce5a06
-                    (entry, service, cancellable, Lang.bind(this,
ce5a06
-                        function(source, res) {
ce5a06
-                            try {
ce5a06
-                                let docModel = GdPrivate.pdf_loader_load_zpj_entry_finish(res);
ce5a06
-                                callback(this, docModel, null);
ce5a06
-                            } catch (e) {
ce5a06
-                                callback(this, null, e);
ce5a06
+                this.loadLocal(passwd, cancellable, Lang.bind(this,
ce5a06
+                    function(doc, docModel, error) {
ce5a06
+                        if (error) {
ce5a06
+                            if (fromCache &&
ce5a06
+                                !error.matches(EvDocument.DocumentError, EvDocument.DocumentError.ENCRYPTED)) {
ce5a06
+                                this.download(false, cancellable, Lang.bind(this,
ce5a06
+                                    function(fromCache, error) {
ce5a06
+                                        if (error) {
ce5a06
+                                            callback(this, null, error);
ce5a06
+                                            return;
ce5a06
+                                        }
ce5a06
+
ce5a06
+                                        this.loadLocal(passwd, cancellable, callback);
ce5a06
+                                    }));
ce5a06
+                            } else {
ce5a06
+                                callback(this, null, error);
ce5a06
                             }
ce5a06
-                        }));
ce5a06
+
ce5a06
+                            return;
ce5a06
+                        }
ce5a06
+
ce5a06
+                        callback(this, docModel, null);
ce5a06
+                    }));
ce5a06
             }));
ce5a06
     },
ce5a06
 
ce5a06
diff --git a/src/lib/gd-pdf-loader.c b/src/lib/gd-pdf-loader.c
ce5a06
index 7a8890e75891..202f6cc0a65f 100644
ce5a06
--- a/src/lib/gd-pdf-loader.c
ce5a06
+++ b/src/lib/gd-pdf-loader.c
ce5a06
@@ -51,9 +51,6 @@ typedef struct {
ce5a06
   GDataService *gdata_service;
ce5a06
   gchar *resource_id;
ce5a06
 
ce5a06
-  ZpjSkydriveEntry *zpj_entry;
ce5a06
-  ZpjSkydrive *zpj_service;
ce5a06
-
ce5a06
   guint64 pdf_cache_mtime;
ce5a06
   guint64 original_file_mtime;
ce5a06
 
ce5a06
@@ -64,7 +61,6 @@ typedef struct {
ce5a06
 static void pdf_load_job_from_openoffice (PdfLoadJob *job);
ce5a06
 static void pdf_load_job_gdata_refresh_cache (PdfLoadJob *job);
ce5a06
 static void pdf_load_job_openoffice_refresh_cache (PdfLoadJob *job);
ce5a06
-static void pdf_load_job_zpj_refresh_cache (PdfLoadJob *job);
ce5a06
 
ce5a06
 /* --------------------------- utils -------------------------------- */
ce5a06
 
ce5a06
@@ -134,8 +130,6 @@ pdf_load_job_free (PdfLoadJob *job)
ce5a06
   g_clear_object (&job->download_file);
ce5a06
   g_clear_object (&job->gdata_service);
ce5a06
   g_clear_object (&job->gdata_entry);
ce5a06
-  g_clear_object (&job->zpj_service);
ce5a06
-  g_clear_object (&job->zpj_entry);
ce5a06
 
ce5a06
   g_free (job->uri);
ce5a06
   g_free (job->passwd);
ce5a06
@@ -160,7 +154,6 @@ static PdfLoadJob *
ce5a06
 pdf_load_job_new (GSimpleAsyncResult *result,
ce5a06
                   const gchar *uri,
ce5a06
                   GDataEntry *gdata_entry,
ce5a06
-                  ZpjSkydriveEntry *zpj_entry,
ce5a06
                   const gchar *passwd,
ce5a06
                   GCancellable *cancellable)
ce5a06
 {
ce5a06
@@ -178,8 +171,6 @@ pdf_load_job_new (GSimpleAsyncResult *result,
ce5a06
     retval->passwd = g_strdup (passwd);
ce5a06
   if (gdata_entry != NULL)
ce5a06
     retval->gdata_entry = g_object_ref (gdata_entry);
ce5a06
-  if (zpj_entry != NULL)
ce5a06
-    retval->zpj_entry = g_object_ref (zpj_entry);
ce5a06
   if (cancellable != NULL)
ce5a06
     retval->cancellable = g_object_ref (cancellable);
ce5a06
 
ce5a06
@@ -216,8 +207,6 @@ pdf_load_job_force_refresh_cache (PdfLoadJob *job)
ce5a06
 
ce5a06
   if (job->gdata_entry != NULL)
ce5a06
     pdf_load_job_gdata_refresh_cache (job);
ce5a06
-  if (job->zpj_entry != NULL)
ce5a06
-    pdf_load_job_zpj_refresh_cache (job);
ce5a06
   else
ce5a06
     pdf_load_job_openoffice_refresh_cache (job);
ce5a06
 }
ce5a06
@@ -429,61 +418,6 @@ pdf_load_job_gdata_refresh_cache (PdfLoadJob *job)
ce5a06
 }
ce5a06
 
ce5a06
 static void
ce5a06
-zpj_download_stream_ready (GObject *source,
ce5a06
-                       GAsyncResult *res,
ce5a06
-                       gpointer user_data)
ce5a06
-{
ce5a06
-  GError *error = NULL;
ce5a06
-  PdfLoadJob *job = (PdfLoadJob *) user_data;
ce5a06
-  const gchar *name;
ce5a06
-  const gchar *extension;
ce5a06
-
ce5a06
-  job->stream = zpj_skydrive_download_file_to_stream_finish (ZPJ_SKYDRIVE (source), res, &error);
ce5a06
-  if (error != NULL) {
ce5a06
-    pdf_load_job_complete_error (job, error);
ce5a06
-    return;
ce5a06
-  }
ce5a06
-
ce5a06
-  name = zpj_skydrive_entry_get_name (job->zpj_entry);
ce5a06
-  extension = gd_filename_get_extension_offset (name);
ce5a06
-
ce5a06
-  /* If it is not a PDF, we need to convert it afterwards.
ce5a06
-   * http://msdn.microsoft.com/en-us/library/live/hh826545#fileformats
ce5a06
-   */
ce5a06
-  if (g_strcmp0 (extension, ".pdf") != 0)
ce5a06
-    {
ce5a06
-      GFileIOStream *iostream;
ce5a06
-
ce5a06
-      job->download_file = g_file_new_tmp (NULL, &iostream, &error);
ce5a06
-      if (error != NULL) {
ce5a06
-        pdf_load_job_complete_error (job, error);
ce5a06
-        return;
ce5a06
-      }
ce5a06
-
ce5a06
-      /* We don't need the iostream. */
ce5a06
-      g_io_stream_close (G_IO_STREAM (iostream), NULL, NULL);
ce5a06
-    }
ce5a06
-  else
ce5a06
-    job->download_file = g_file_new_for_path (job->pdf_path);
ce5a06
-
ce5a06
-  g_file_replace_async (job->download_file, NULL, FALSE,
ce5a06
-                        G_FILE_CREATE_PRIVATE,
ce5a06
-                        G_PRIORITY_DEFAULT,
ce5a06
-                        job->cancellable, file_replace_ready_cb,
ce5a06
-                        job);
ce5a06
-}
ce5a06
-
ce5a06
-static void
ce5a06
-pdf_load_job_zpj_refresh_cache (PdfLoadJob *job)
ce5a06
-{
ce5a06
-  zpj_skydrive_download_file_to_stream_async (job->zpj_service,
ce5a06
-                                              ZPJ_SKYDRIVE_FILE (job->zpj_entry),
ce5a06
-                                              job->cancellable,
ce5a06
-                                              zpj_download_stream_ready,
ce5a06
-                                              job);
ce5a06
-}
ce5a06
-
ce5a06
-static void
ce5a06
 gdata_cache_query_info_ready_cb (GObject *source,
ce5a06
                                  GAsyncResult *res,
ce5a06
                                  gpointer user_data)
ce5a06
@@ -518,40 +452,6 @@ gdata_cache_query_info_ready_cb (GObject *source,
ce5a06
 }
ce5a06
 
ce5a06
 static void
ce5a06
-zpj_cache_query_info_ready_cb (GObject *source,
ce5a06
-                               GAsyncResult *res,
ce5a06
-                               gpointer user_data)
ce5a06
-{
ce5a06
-  PdfLoadJob *job = user_data;
ce5a06
-  GError *error = NULL;
ce5a06
-  GFileInfo *info;
ce5a06
-  guint64 cache_mtime;
ce5a06
-
ce5a06
-  info = g_file_query_info_finish (G_FILE (source), res, &error);
ce5a06
-
ce5a06
-  if (error != NULL) {
ce5a06
-    /* create/invalidate cache */
ce5a06
-    pdf_load_job_zpj_refresh_cache (job);
ce5a06
-    g_error_free (error);
ce5a06
-
ce5a06
-    return;
ce5a06
-  }
ce5a06
-
ce5a06
-  job->pdf_cache_mtime = cache_mtime =
ce5a06
-    g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
ce5a06
-  g_object_unref (info);
ce5a06
-
ce5a06
-  if (job->original_file_mtime != cache_mtime) {
ce5a06
-    pdf_load_job_zpj_refresh_cache (job);
ce5a06
-  } else {
ce5a06
-    job->from_old_cache = TRUE;
ce5a06
-
ce5a06
-    /* load the cached file */
ce5a06
-    pdf_load_job_from_pdf (job);
ce5a06
-  }
ce5a06
-}
ce5a06
-
ce5a06
-static void
ce5a06
 pdf_load_job_from_google_documents (PdfLoadJob *job)
ce5a06
 {
ce5a06
   gchar *tmp_name;
ce5a06
@@ -583,39 +483,6 @@ pdf_load_job_from_google_documents (PdfLoadJob *job)
ce5a06
 }
ce5a06
 
ce5a06
 static void
ce5a06
-pdf_load_job_from_skydrive (PdfLoadJob *job)
ce5a06
-{
ce5a06
-  gchar *tmp_name;
ce5a06
-  gchar *tmp_path, *pdf_path;
ce5a06
-  GDateTime *updated_time;
ce5a06
-  GFile *pdf_file;
ce5a06
-
ce5a06
-  updated_time = zpj_skydrive_entry_get_updated_time (job->zpj_entry);
ce5a06
-  job->original_file_mtime = (guint64) g_date_time_to_unix (updated_time);
ce5a06
-
ce5a06
-  tmp_name = g_strdup_printf ("gnome-documents-%u.pdf",
ce5a06
-                              g_str_hash (zpj_skydrive_entry_get_id (job->zpj_entry)));
ce5a06
-  tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL);
ce5a06
-  job->pdf_path = pdf_path =
ce5a06
-    g_build_filename (tmp_path, tmp_name, NULL);
ce5a06
-  g_mkdir_with_parents (tmp_path, 0700);
ce5a06
-
ce5a06
-  pdf_file = g_file_new_for_path (pdf_path);
ce5a06
-
ce5a06
-  g_file_query_info_async (pdf_file,
ce5a06
-                           G_FILE_ATTRIBUTE_TIME_MODIFIED,
ce5a06
-                           G_FILE_QUERY_INFO_NONE,
ce5a06
-                           G_PRIORITY_DEFAULT,
ce5a06
-                           job->cancellable,
ce5a06
-                           zpj_cache_query_info_ready_cb,
ce5a06
-                           job);
ce5a06
-
ce5a06
-  g_free (tmp_name);
ce5a06
-  g_free (tmp_path);
ce5a06
-  g_object_unref (pdf_file);
ce5a06
-}
ce5a06
-
ce5a06
-static void
ce5a06
 pdf_load_job_from_gdata_cache (PdfLoadJob *job)
ce5a06
 {
ce5a06
   gchar *tmp_name;
ce5a06
@@ -633,23 +500,6 @@ pdf_load_job_from_gdata_cache (PdfLoadJob *job)
ce5a06
 }
ce5a06
 
ce5a06
 static void
ce5a06
-pdf_load_job_from_zpj_cache (PdfLoadJob *job)
ce5a06
-{
ce5a06
-  gchar *tmp_name;
ce5a06
-  gchar *tmp_path;
ce5a06
-
ce5a06
-  tmp_name = g_strdup_printf ("gnome-documents-%u.pdf",
ce5a06
-                              g_str_hash (job->resource_id));
ce5a06
-  tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL);
ce5a06
-  job->pdf_path = g_build_filename (tmp_path, tmp_name, NULL);
ce5a06
-
ce5a06
-  pdf_load_job_from_pdf (job);
ce5a06
-
ce5a06
-  g_free (tmp_path);
ce5a06
-  g_free (tmp_name);
ce5a06
-}
ce5a06
-
ce5a06
-static void
ce5a06
 unoconv_cancelled_cb (GCancellable *cancellable,
ce5a06
                       gpointer user_data)
ce5a06
 {
ce5a06
@@ -1134,7 +984,6 @@ pdf_load_job_from_uri (PdfLoadJob *job)
ce5a06
 {
ce5a06
   GFile *file;
ce5a06
   const gchar *gdata_prefix = "google:drive:";
ce5a06
-  const gchar *zpj_prefix = "windows-live:skydrive:";
ce5a06
 
ce5a06
   if (g_str_has_prefix (job->uri, gdata_prefix)) {
ce5a06
     job->resource_id = g_strdup (job->uri + strlen (gdata_prefix));
ce5a06
@@ -1142,12 +991,6 @@ pdf_load_job_from_uri (PdfLoadJob *job)
ce5a06
     return;
ce5a06
   }
ce5a06
 
ce5a06
-  if (g_str_has_prefix (job->uri, zpj_prefix)) {
ce5a06
-    job->resource_id = g_strdup (job->uri + strlen (zpj_prefix));
ce5a06
-    pdf_load_job_from_zpj_cache (job);
ce5a06
-    return;
ce5a06
-  }
ce5a06
-
ce5a06
   file = g_file_new_for_uri (job->uri);
ce5a06
   if (!g_file_is_native (file))
ce5a06
     pdf_load_job_from_remote_file (job);
ce5a06
@@ -1162,8 +1005,6 @@ pdf_load_job_start (PdfLoadJob *job)
ce5a06
 {
ce5a06
   if (job->gdata_entry != NULL)
ce5a06
     pdf_load_job_from_google_documents (job);
ce5a06
-  else if (job->zpj_entry != NULL)
ce5a06
-    pdf_load_job_from_skydrive (job);
ce5a06
   else
ce5a06
     pdf_load_job_from_uri (job);
ce5a06
 }
ce5a06
@@ -1189,7 +1030,7 @@ gd_pdf_loader_load_uri_async (const gchar *uri,
ce5a06
   result = g_simple_async_result_new (NULL, callback, user_data,
ce5a06
                                       gd_pdf_loader_load_uri_async);
ce5a06
 
ce5a06
-  job = pdf_load_job_new (result, uri, NULL, NULL, passwd, cancellable);
ce5a06
+  job = pdf_load_job_new (result, uri, NULL, passwd, cancellable);
ce5a06
 
ce5a06
   pdf_load_job_start (job);
ce5a06
 
ce5a06
@@ -1230,7 +1071,7 @@ gd_pdf_loader_load_gdata_entry_async (GDataEntry *entry,
ce5a06
   result = g_simple_async_result_new (NULL, callback, user_data,
ce5a06
                                       gd_pdf_loader_load_gdata_entry_async);
ce5a06
 
ce5a06
-  job = pdf_load_job_new (result, NULL, entry, NULL, NULL, cancellable);
ce5a06
+  job = pdf_load_job_new (result, NULL, entry, NULL, cancellable);
ce5a06
   job->gdata_service = g_object_ref (service);
ce5a06
 
ce5a06
   pdf_load_job_start (job);
ce5a06
@@ -1257,45 +1098,3 @@ gd_pdf_loader_load_gdata_entry_finish (GAsyncResult *res,
ce5a06
   retval = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
ce5a06
   return retval;
ce5a06
 }
ce5a06
-
ce5a06
-
ce5a06
-void
ce5a06
-gd_pdf_loader_load_zpj_entry_async (ZpjSkydriveEntry *entry,
ce5a06
-                                    ZpjSkydrive *service,
ce5a06
-                                    GCancellable *cancellable,
ce5a06
-                                    GAsyncReadyCallback callback,
ce5a06
-                                    gpointer user_data)
ce5a06
-{
ce5a06
-  PdfLoadJob *job;
ce5a06
-  GSimpleAsyncResult *result;
ce5a06
-
ce5a06
-  result = g_simple_async_result_new (NULL, callback, user_data,
ce5a06
-                                      gd_pdf_loader_load_zpj_entry_async);
ce5a06
-
ce5a06
-  job = pdf_load_job_new (result, NULL, NULL, entry, NULL, cancellable);
ce5a06
-  job->zpj_service = g_object_ref (service);
ce5a06
-
ce5a06
-  pdf_load_job_start (job);
ce5a06
-
ce5a06
-  g_object_unref (result);
ce5a06
-}
ce5a06
-
ce5a06
-/**
ce5a06
- * gd_pdf_loader_load_zpj_entry_finish:
ce5a06
- * @res:
ce5a06
- * @error: (allow-none) (out):
ce5a06
- *
ce5a06
- * Returns: (transfer full):
ce5a06
- */
ce5a06
-EvDocumentModel *
ce5a06
-gd_pdf_loader_load_zpj_entry_finish (GAsyncResult *res,
ce5a06
-                                     GError **error)
ce5a06
-{
ce5a06
-  EvDocumentModel *retval;
ce5a06
-
ce5a06
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
ce5a06
-    return NULL;
ce5a06
-
ce5a06
-  retval = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
ce5a06
-  return retval;
ce5a06
-}
ce5a06
diff --git a/src/lib/gd-pdf-loader.h b/src/lib/gd-pdf-loader.h
ce5a06
index 9e5ffb737eee..70ded295dad3 100644
ce5a06
--- a/src/lib/gd-pdf-loader.h
ce5a06
+++ b/src/lib/gd-pdf-loader.h
ce5a06
@@ -28,7 +28,6 @@
ce5a06
 
ce5a06
 #define GOA_API_IS_SUBJECT_TO_CHANGE
ce5a06
 #include <gdata/gdata.h>
ce5a06
-#include <zpj/zpj.h>
ce5a06
 
ce5a06
 G_BEGIN_DECLS
ce5a06
 
ce5a06
@@ -48,14 +47,6 @@ void gd_pdf_loader_load_gdata_entry_async (GDataEntry *entry,
ce5a06
 EvDocumentModel *gd_pdf_loader_load_gdata_entry_finish (GAsyncResult *res,
ce5a06
                                                         GError **error);
ce5a06
 
ce5a06
-void gd_pdf_loader_load_zpj_entry_async (ZpjSkydriveEntry *entry,
ce5a06
-                                         ZpjSkydrive *service,
ce5a06
-                                         GCancellable *cancellable,
ce5a06
-                                         GAsyncReadyCallback callback,
ce5a06
-                                         gpointer user_data);
ce5a06
-EvDocumentModel *gd_pdf_loader_load_zpj_entry_finish (GAsyncResult *res,
ce5a06
-                                                      GError **error);
ce5a06
-
ce5a06
 G_END_DECLS
ce5a06
 
ce5a06
 #endif /* __GD_PDF_LOADER_H__ */
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From b80863a8d5666c9bd246a09bf770a8ea58367637 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 20 Apr 2017 11:51:47 +0200
ce5a06
Subject: [PATCH 07/16] documents: Fix the retrieval of the cache's
ce5a06
 modification time
ce5a06
ce5a06
Gio.FILE_ATTRIBUTE_TIME_MODIFIED returns a value in seconds, not
ce5a06
microseconds.
ce5a06
ce5a06
Fallout from 4133adf06a0ff473e6234f8ab3eb88c47589e627
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=774937
ce5a06
---
ce5a06
 src/documents.js | 2 --
ce5a06
 1 file changed, 2 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index ca48e53db25d..4db7d07029b4 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -387,8 +387,6 @@ const DocCommon = new Lang.Class({
ce5a06
                 }
ce5a06
 
ce5a06
                 let cacheMtime = info.get_attribute_uint64(Gio.FILE_ATTRIBUTE_TIME_MODIFIED);
ce5a06
-                cacheMtime /= 1000000;
ce5a06
-
ce5a06
                 if (this.mtime <= cacheMtime) {
ce5a06
                     callback(true, null);
ce5a06
                     return;
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From dd1343e7869882d632d75307b396de0c3fde4447 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Tue, 18 Apr 2017 19:01:26 +0200
ce5a06
Subject: [PATCH 08/16] Optionally load the document when determining if it can
ce5a06
 be printed
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=781533
ce5a06
---
ce5a06
 src/documents.js  | 99 ++++++++++++++++++++++++++++++++++++-------------------
ce5a06
 src/evinceview.js |  8 ++++-
ce5a06
 2 files changed, 72 insertions(+), 35 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 4db7d07029b4..fb0eee962548 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -36,6 +36,7 @@ const Zpj = imports.gi.Zpj;
ce5a06
 const _ = imports.gettext.gettext;
ce5a06
 
ce5a06
 const Lang = imports.lang;
ce5a06
+const Mainloop = imports.mainloop;
ce5a06
 const Signals = imports.signals;
ce5a06
 
ce5a06
 const Application = imports.application;
ce5a06
@@ -416,11 +417,37 @@ const DocCommon = new Lang.Class({
ce5a06
         log('Error: DocCommon implementations must override canTrash');
ce5a06
     },
ce5a06
 
ce5a06
-    canPrint: function(docModel) {
ce5a06
-        if (!docModel)
ce5a06
-            return false;
ce5a06
+    canPrint: function(docModel, cancellable, callback) {
ce5a06
+        if (docModel) {
ce5a06
+            Mainloop.idle_add(Lang.bind(this,
ce5a06
+                function() {
ce5a06
+                    this._canPrint(docModel, callback);
ce5a06
+                    return GLib.SOURCE_REMOVE;
ce5a06
+                }));
ce5a06
+
ce5a06
+            return;
ce5a06
+        }
ce5a06
+
ce5a06
+        this.load(null, cancellable, Lang.bind(this,
ce5a06
+            function(doc, docModel, error) {
ce5a06
+                if (error) {
ce5a06
+                    callback(this, false);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                this._canPrint(docModel, callback);
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
+    _canPrint: function(docModel, callback) {
ce5a06
+        if (!docModel) {
ce5a06
+            callback(this, false);
ce5a06
+            return;
ce5a06
+        }
ce5a06
 
ce5a06
-        return EvView.PrintOperation.exists_for_document(docModel.get_document());
ce5a06
+        let evDoc = docModel.get_document();
ce5a06
+        let supported = EvView.PrintOperation.exists_for_document(evDoc);
ce5a06
+        callback(this, supported);
ce5a06
     },
ce5a06
 
ce5a06
     trash: function() {
ce5a06
@@ -694,41 +721,45 @@ const DocCommon = new Lang.Class({
ce5a06
                     return;
ce5a06
                 }
ce5a06
 
ce5a06
-                if (!this.canPrint(docModel))
ce5a06
-                    return;
ce5a06
+                this.canPrint(docModel, null, Lang.bind(this,
ce5a06
+                    function(doc, supported) {
ce5a06
+                        if (!supported)
ce5a06
+                            return;
ce5a06
 
ce5a06
-                let printOp = EvView.PrintOperation.new(docModel.get_document());
ce5a06
+                        let printOp = EvView.PrintOperation.new(docModel.get_document());
ce5a06
 
ce5a06
-                printOp.connect('begin-print', Lang.bind(this,
ce5a06
-                    function() {
ce5a06
-                        Application.selectionController.setSelectionMode(false);
ce5a06
-                    }));
ce5a06
 
ce5a06
-                printOp.connect('done', Lang.bind(this,
ce5a06
-                    function(op, res) {
ce5a06
-                        if (res == Gtk.PrintOperationResult.ERROR) {
ce5a06
-                            try {
ce5a06
-                                printOp.get_error();
ce5a06
-                            } catch (e) {
ce5a06
-                                let errorDialog = new Gtk.MessageDialog ({ transient_for: toplevel,
ce5a06
-                                                                           modal: true,
ce5a06
-                                                                           destroy_with_parent: true,
ce5a06
-                                                                           buttons: Gtk.ButtonsType.OK,
ce5a06
-                                                                           message_type: Gtk.MessageType.ERROR,
ce5a06
-                                                                           text: _("Failed to print document"),
ce5a06
-                                                                           secondary_text: e.message });
ce5a06
-                                errorDialog.connect ('response', Lang.bind(this,
ce5a06
-                                    function() {
ce5a06
-                                        errorDialog.destroy();
ce5a06
-                                    }));
ce5a06
-                                errorDialog.show();
ce5a06
-                            }
ce5a06
-                        }
ce5a06
-                    }));
ce5a06
+                        printOp.connect('begin-print', Lang.bind(this,
ce5a06
+                            function() {
ce5a06
+                                Application.selectionController.setSelectionMode(false);
ce5a06
+                            }));
ce5a06
 
ce5a06
-                let printNotification = new Notifications.PrintNotification(printOp, doc);
ce5a06
+                        printOp.connect('done', Lang.bind(this,
ce5a06
+                            function(op, res) {
ce5a06
+                                if (res == Gtk.PrintOperationResult.ERROR) {
ce5a06
+                                    try {
ce5a06
+                                        printOp.get_error();
ce5a06
+                                    } catch (e) {
ce5a06
+                                        let errorDialog = new Gtk.MessageDialog ({ transient_for: toplevel,
ce5a06
+                                                                                   modal: true,
ce5a06
+                                                                                   destroy_with_parent: true,
ce5a06
+                                                                                   buttons: Gtk.ButtonsType.OK,
ce5a06
+                                                                                   message_type: Gtk.MessageType.ERROR,
ce5a06
+                                                                                   text: _("Failed to print document"),
ce5a06
+                                                                                   secondary_text: e.message });
ce5a06
+                                        errorDialog.connect ('response', Lang.bind(this,
ce5a06
+                                            function() {
ce5a06
+                                                errorDialog.destroy();
ce5a06
+                                            }));
ce5a06
+                                        errorDialog.show();
ce5a06
+                                    }
ce5a06
+                                }
ce5a06
+                            }));
ce5a06
+
ce5a06
+                        let printNotification = new Notifications.PrintNotification(printOp, doc);
ce5a06
 
ce5a06
-                printOp.run(toplevel);
ce5a06
+                        printOp.run(toplevel);
ce5a06
+                    }));
ce5a06
             }));
ce5a06
     },
ce5a06
 
ce5a06
diff --git a/src/evinceview.js b/src/evinceview.js
ce5a06
index d4ea883e76b4..3e0070bb785c 100644
ce5a06
--- a/src/evinceview.js
ce5a06
+++ b/src/evinceview.js
ce5a06
@@ -264,7 +264,13 @@ const EvinceView = new Lang.Class({
ce5a06
 
ce5a06
         this.getAction('copy').enabled = false;
ce5a06
         this.getAction('edit-current').enabled = doc.canEdit();
ce5a06
-        this.getAction('print-current').enabled = doc.canPrint(docModel);
ce5a06
+
ce5a06
+        this.getAction('print-current').enabled = false;
ce5a06
+        doc.canPrint(docModel, null, Lang.bind(this,
ce5a06
+            function(doc, supported) {
ce5a06
+                this.getAction('print-current').enabled = supported;
ce5a06
+            }));
ce5a06
+
ce5a06
         let presentCurrent = this.getAction('present-current');
ce5a06
         if (presentCurrent)
ce5a06
             presentCurrent.enabled = true;
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From c37a9a62610ba301f09d2e53a4004dcbf12dadec Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 20 Apr 2017 14:40:40 +0200
ce5a06
Subject: [PATCH 09/16] documents: Check whether it is a collection in canPrint
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=781533
ce5a06
---
ce5a06
 src/documents.js | 10 ++++++++++
ce5a06
 1 file changed, 10 insertions(+)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index fb0eee962548..3bed18c36a49 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -418,6 +418,16 @@ const DocCommon = new Lang.Class({
ce5a06
     },
ce5a06
 
ce5a06
     canPrint: function(docModel, cancellable, callback) {
ce5a06
+        if (this.collection) {
ce5a06
+            Mainloop.idle_add(Lang.bind(this,
ce5a06
+                function() {
ce5a06
+                    callback(this, false);
ce5a06
+                    return GLib.SOURCE_REMOVE;
ce5a06
+                }));
ce5a06
+
ce5a06
+            return;
ce5a06
+        }
ce5a06
+
ce5a06
         if (docModel) {
ce5a06
             Mainloop.idle_add(Lang.bind(this,
ce5a06
                 function() {
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 7d63e3fc760aef6ec56868a16e930af8977f0973 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 20 Apr 2017 14:59:12 +0200
ce5a06
Subject: [PATCH 10/16] selections: Enable printing only for documents handled
ce5a06
 by EvView
ce5a06
ce5a06
Now that we don't convert everything to PDFs, we might not be able to
ce5a06
print everything that's not a collection. eg., we can't print EPUBs,
ce5a06
ODFs and OOXMLs. Therefore it is not enough to only check for
ce5a06
collections.
ce5a06
ce5a06
Instead, let's use canPrint which encapsulates all the conditions that
ce5a06
need to be met for printing.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=781533
ce5a06
---
ce5a06
 src/selections.js | 15 ++++++++++-----
ce5a06
 1 file changed, 10 insertions(+), 5 deletions(-)
ce5a06
ce5a06
diff --git a/src/selections.js b/src/selections.js
ce5a06
index b864c8f8a634..ecfd3ec694c7 100644
ce5a06
--- a/src/selections.js
ce5a06
+++ b/src/selections.js
ce5a06
@@ -946,7 +946,7 @@ const SelectionToolbar = new Lang.Class({
ce5a06
         let hasSelection = (selection.length > 0);
ce5a06
 
ce5a06
         let showTrash = hasSelection;
ce5a06
-        let showPrint = hasSelection;
ce5a06
+        let showPrint = false;
ce5a06
         let showProperties = hasSelection;
ce5a06
         let showOpen = hasSelection;
ce5a06
         let showShare = hasSelection;
ce5a06
@@ -967,16 +967,21 @@ const SelectionToolbar = new Lang.Class({
ce5a06
                     showShare = false;
ce5a06
 
ce5a06
                 showTrash &= doc.canTrash();
ce5a06
-                showPrint &= !doc.collection;
ce5a06
             }));
ce5a06
 
ce5a06
         showOpen = (apps.length > 0);
ce5a06
 
ce5a06
-        if (selection.length > 1) {
ce5a06
-            showPrint = false;
ce5a06
-            showProperties = false;
ce5a06
+        if (selection.length == 1) {
ce5a06
+            let doc = Application.documentManager.getItemById(selection[0]);
ce5a06
+            doc.canPrint(null, null, Lang.bind(this,
ce5a06
+                function(doc, supported) {
ce5a06
+                    this._toolbarPrint.set_sensitive(supported);
ce5a06
+                }));
ce5a06
         }
ce5a06
 
ce5a06
+        if (selection.length > 1)
ce5a06
+            showProperties = false;
ce5a06
+
ce5a06
         let openLabel = null;
ce5a06
         if (apps.length == 1) {
ce5a06
             // Translators: this is the Open action in a context menu
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From aa507bc55aef99815308fe7865f016d40ed6f76d Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Mon, 27 Mar 2017 16:08:57 +0200
ce5a06
Subject: [PATCH 11/16] documents: Thumbnail SkydriveDocuments once they are
ce5a06
 loaded
ce5a06
MIME-Version: 1.0
ce5a06
Content-Type: text/plain; charset=UTF-8
ce5a06
Content-Transfer-Encoding: 8bit
ce5a06
ce5a06
Historically, unlike GoogleDocuments, we were unable to fetch
ce5a06
server-side thumbnails for SkydriveDocuments due to limitations of
ce5a06
OneDrive's REST API. Newer versions of the REST API do support it [1],
ce5a06
but it is not implemented in libzapojit.
ce5a06
ce5a06
Some ways to work around these limitations:
ce5a06
  - Create the thumbnail from the EvDocument when it is loaded for
ce5a06
    previewing
ce5a06
  - Use a cached copy of the document as source for the thumbnail
ce5a06
ce5a06
Even if we can fetch thumbnails from the server in future, these would
ce5a06
still be nice optimizations to have — reduces network consumption and
ce5a06
offers a cheap way to jump ahead in the thumbnailing queue.
ce5a06
ce5a06
[1] https://dev.onedrive.com/items/thumbnails.htm
ce5a06
---
ce5a06
 src/documents.js | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
ce5a06
 1 file changed, 109 insertions(+), 2 deletions(-)
ce5a06
ce5a06
diff --git a/src/documents.js b/src/documents.js
ce5a06
index 3bed18c36a49..27518b2251d1 100644
ce5a06
--- a/src/documents.js
ce5a06
+++ b/src/documents.js
ce5a06
@@ -1150,7 +1150,7 @@ const SkydriveDocument = new Lang.Class({
ce5a06
     Extends: DocCommon,
ce5a06
 
ce5a06
     _init: function(cursor) {
ce5a06
-        this._failedThumbnailing = true;
ce5a06
+        this._failedThumbnailing = false;
ce5a06
 
ce5a06
         this.parent(cursor);
ce5a06
 
ce5a06
@@ -1174,6 +1174,54 @@ const SkydriveDocument = new Lang.Class({
ce5a06
         this.uriToLoad = localFile.get_uri();
ce5a06
     },
ce5a06
 
ce5a06
+    _createThumbnailFromEvDocument: function(evDoc, cancellable, callback) {
ce5a06
+        let thumbnailPath = GnomeDesktop.desktop_thumbnail_path_for_uri (this.uri,
ce5a06
+                                                                         GnomeDesktop.DesktopThumbnailSize.LARGE);
ce5a06
+        let thumbnailFile = Gio.File.new_for_path(thumbnailPath);
ce5a06
+
ce5a06
+        let thumbnailDir = GLib.path_get_dirname(thumbnailPath);
ce5a06
+        GLib.mkdir_with_parents(thumbnailDir, 448);
ce5a06
+
ce5a06
+        thumbnailFile.replace_async(null,
ce5a06
+                                    false,
ce5a06
+                                    Gio.FileCreateFlags.PRIVATE,
ce5a06
+                                    GLib.PRIORITY_DEFAULT,
ce5a06
+                                    cancellable,
ce5a06
+                                    Lang.bind(this,
ce5a06
+            function(source, res) {
ce5a06
+                let outputStream;
ce5a06
+
ce5a06
+                try {
ce5a06
+                    outputStream = thumbnailFile.replace_finish(res);
ce5a06
+                } catch (e) {
ce5a06
+                    callback(e);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                let [width, height] = evDoc.get_page_size(0);
ce5a06
+                let maxDimension = Math.max(width, height);
ce5a06
+                let scale = Application.application.getScaleFactor();
ce5a06
+                let size = 128 * scale;
ce5a06
+                let zoom = size / maxDimension;
ce5a06
+
ce5a06
+                let page = evDoc.get_page(0);
ce5a06
+
ce5a06
+                let rc = EvDocument.RenderContext.new(page, 0, zoom);
ce5a06
+                let pixbuf = evDoc.get_thumbnail(rc);
ce5a06
+                pixbuf.save_to_streamv_async(outputStream, "png", [], [], cancellable, Lang.bind(this,
ce5a06
+                    function(source, res) {
ce5a06
+                        try {
ce5a06
+                            GdkPixbuf.Pixbuf.save_to_stream_finish(res);
ce5a06
+                        } catch (e) {
ce5a06
+                            callback(e);
ce5a06
+                            return;
ce5a06
+                        }
ce5a06
+
ce5a06
+                        callback(null);
ce5a06
+                    }));
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
     _createZpjEntry: function(cancellable, callback) {
ce5a06
         let source = Application.sourceManager.getItemById(this.resourceUrn);
ce5a06
 
ce5a06
@@ -1276,7 +1324,16 @@ const SkydriveDocument = new Lang.Class({
ce5a06
                                             return;
ce5a06
                                         }
ce5a06
 
ce5a06
-                                        this.loadLocal(passwd, cancellable, callback);
ce5a06
+                                        this.loadLocal(passwd, cancellable, Lang.bind(this,
ce5a06
+                                            function(doc, docModel, error) {
ce5a06
+                                                if (error) {
ce5a06
+                                                    callback(this, null, error);
ce5a06
+                                                    return;
ce5a06
+                                                }
ce5a06
+
ce5a06
+                                                callback(this, docModel, null);
ce5a06
+                                                this._postLoad(docModel);
ce5a06
+                                            }));
ce5a06
                                     }));
ce5a06
                             } else {
ce5a06
                                 callback(this, null, error);
ce5a06
@@ -1286,6 +1343,56 @@ const SkydriveDocument = new Lang.Class({
ce5a06
                         }
ce5a06
 
ce5a06
                         callback(this, docModel, null);
ce5a06
+                        this._postLoad(docModel);
ce5a06
+                    }));
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
+    _postLoad: function(docModel) {
ce5a06
+        if (this._thumbPath)
ce5a06
+            return;
ce5a06
+
ce5a06
+        if (!docModel)
ce5a06
+            return;
ce5a06
+
ce5a06
+        this._createThumbnailFromEvDocument(docModel.document, null, Lang.bind(this,
ce5a06
+            function(error) {
ce5a06
+                if (error) {
ce5a06
+                    logError(error, 'Unable to create thumbnail from EvDocument');
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                this._failedThumbnailing = false;
ce5a06
+                this.refreshIcon();
ce5a06
+            }));
ce5a06
+    },
ce5a06
+
ce5a06
+    createThumbnail: function(callback) {
ce5a06
+        // try loading from the most recent cache, if any
ce5a06
+        this.loadLocal(null, null, Lang.bind(this,
ce5a06
+            function(doc, docModel, error) {
ce5a06
+                if (error) {
ce5a06
+                    if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) &&
ce5a06
+                        !error.matches(EvDocument.DocumentError, EvDocument.DocumentError.ENCRYPTED)) {
ce5a06
+                        logError(error, 'Unable to load document from the cache');
ce5a06
+                        callback(false);
ce5a06
+                        return;
ce5a06
+                    }
ce5a06
+                }
ce5a06
+
ce5a06
+                if (!docModel) {
ce5a06
+                    callback(false);
ce5a06
+                    return;
ce5a06
+                }
ce5a06
+
ce5a06
+                this._createThumbnailFromEvDocument(docModel.document, null, Lang.bind(this,
ce5a06
+                    function(error) {
ce5a06
+                        if (error) {
ce5a06
+                            logError(error, 'Unable to create thumbnail from EvDocument');
ce5a06
+                            return;
ce5a06
+                        }
ce5a06
+
ce5a06
+                        callback(true);
ce5a06
                     }));
ce5a06
             }));
ce5a06
     },
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 3bd516524432f9decb0a15ab209a9957b7ae7488 Mon Sep 17 00:00:00 2001
ce5a06
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
ce5a06
Date: Mon, 8 May 2017 16:44:32 +0100
ce5a06
Subject: [PATCH 12/16] lokview: Fix crash on repeated open of presentations
ce5a06
ce5a06
Ensure prompt destruction of the LOKDocView widget when the view is
ce5a06
destroyed. This gives LOK a chance to shutdown at the right time.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=782508
ce5a06
---
ce5a06
 src/lokview.js | 12 ++++++++++--
ce5a06
 1 file changed, 10 insertions(+), 2 deletions(-)
ce5a06
ce5a06
diff --git a/src/lokview.js b/src/lokview.js
ce5a06
index 988db963d5d9..238832ed4502 100644
ce5a06
--- a/src/lokview.js
ce5a06
+++ b/src/lokview.js
ce5a06
@@ -137,11 +137,19 @@ const LOKView = new Lang.Class({
ce5a06
             this._lokview.connect('text-selection', Lang.bind(this, this._onTextSelection));
ce5a06
             this._lokview.connect('notify::can-zoom-in', Lang.bind(this, this._onCanZoomInChanged));
ce5a06
             this._lokview.connect('notify::can-zoom-out', Lang.bind(this, this._onCanZoomOutChanged));
ce5a06
+            this.connect('destroy', Lang.bind(this, this._destroyView));
ce5a06
         }
ce5a06
 
ce5a06
         return sw;
ce5a06
     },
ce5a06
 
ce5a06
+    _destroyView: function() {
ce5a06
+	if (this._lokview) {
ce5a06
+	    this._lokview.destroy();
ce5a06
+	    this._lokview = null;
ce5a06
+	}
ce5a06
+    },
ce5a06
+
ce5a06
     onLoadFinished: function(manager, doc) {
ce5a06
         this.parent(manager, doc);
ce5a06
 
ce5a06
@@ -237,10 +245,10 @@ const LOKView = new Lang.Class({
ce5a06
     },
ce5a06
 
ce5a06
     get page() {
ce5a06
-        return this._lokview.get_part();
ce5a06
+        return this._lokview ? this._lokview.get_part() : 0;
ce5a06
     },
ce5a06
 
ce5a06
     get numPages() {
ce5a06
-        return this._lokview.get_parts();
ce5a06
+        return this._lokview ? this._lokview.get_parts() : 0;
ce5a06
     }
ce5a06
 });
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 238a4d4c95b78eff9d1a764f184936ddc58db73d Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 8 Jun 2017 16:10:57 +0200
ce5a06
Subject: [PATCH 13/16] application: Avoid CRITICALs if a primary instance is
ce5a06
 already present
ce5a06
ce5a06
The dbus_unregister method can be invoked more than once. Trying to
ce5a06
unexport an already unexported GDBusInterfaceSkeleton led to:
ce5a06
  GLib-GIO-CRITICAL **:
ce5a06
    g_dbus_interface_skeleton_unexport_from_connection: assertion
ce5a06
    'interface_->priv->connections != NULL' failed
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=783548
ce5a06
---
ce5a06
 src/application.js | 5 ++++-
ce5a06
 1 file changed, 4 insertions(+), 1 deletion(-)
ce5a06
ce5a06
diff --git a/src/application.js b/src/application.js
ce5a06
index a82395d6afd2..40a5dd0e5114 100644
ce5a06
--- a/src/application.js
ce5a06
+++ b/src/application.js
ce5a06
@@ -521,7 +521,10 @@ const Application = new Lang.Class({
ce5a06
     },
ce5a06
 
ce5a06
     vfunc_dbus_unregister: function(connection, path) {
ce5a06
-        this._searchProvider.unexport(connection);
ce5a06
+        if (this._searchProvider != null) {
ce5a06
+            this._searchProvider.unexport(connection);
ce5a06
+            this._searchProvider = null;
ce5a06
+        }
ce5a06
 
ce5a06
         this.parent(connection, path);
ce5a06
     },
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From ca10b8d02486630db2f3de746ee4b885490cbaab Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 8 Jun 2017 16:12:15 +0200
ce5a06
Subject: [PATCH 14/16] application: Instantiate ShellSearchProvider only when
ce5a06
 registering
ce5a06
ce5a06
Now that the --version flag was implemented using the
ce5a06
handle_local_options virtual method, it is possible that the
ce5a06
Application may exit without ever touching D-Bus. So it is a tad
ce5a06
wasteful to instantiate the ShellSearchProvider when it is never going
ce5a06
to be used. Since we are unreffing it in dbus_register, we might as
ce5a06
well create it in dbus_register.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=783548
ce5a06
---
ce5a06
 src/application.js | 9 +++++----
ce5a06
 1 file changed, 5 insertions(+), 4 deletions(-)
ce5a06
ce5a06
diff --git a/src/application.js b/src/application.js
ce5a06
index 40a5dd0e5114..2630e1971826 100644
ce5a06
--- a/src/application.js
ce5a06
+++ b/src/application.js
ce5a06
@@ -100,6 +100,7 @@ const Application = new Lang.Class({
ce5a06
         this.minersRunning = [];
ce5a06
         this._activationTimestamp = Gdk.CURRENT_TIME;
ce5a06
         this._extractPriority = null;
ce5a06
+        this._searchProvider = null;
ce5a06
 
ce5a06
         this.isBooks = isBooks;
ce5a06
 
ce5a06
@@ -120,10 +121,6 @@ const Application = new Lang.Class({
ce5a06
 
ce5a06
         this.add_main_option('version', 'v'.charCodeAt(0), GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
ce5a06
                              _("Show the version of the program"), null);
ce5a06
-
ce5a06
-        this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
ce5a06
-        this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
ce5a06
-        this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
ce5a06
     },
ce5a06
 
ce5a06
     _initGettingStarted: function() {
ce5a06
@@ -516,6 +513,10 @@ const Application = new Lang.Class({
ce5a06
     vfunc_dbus_register: function(connection, path) {
ce5a06
         this.parent(connection, path);
ce5a06
 
ce5a06
+        this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
ce5a06
+        this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
ce5a06
+        this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
ce5a06
+
ce5a06
         this._searchProvider.export(connection);
ce5a06
         return true;
ce5a06
     },
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From af6130bfe229521869f33a125dd4d354f4327ff4 Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 8 Jun 2017 16:12:34 +0200
ce5a06
Subject: [PATCH 15/16] application: Assert that the ShellSearchProvider's
ce5a06
 lifetime is sane
ce5a06
ce5a06
The ShellSearchProvider should be instantiated in the dbus_register
ce5a06
virtual method, which is expected to be called only once.
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=783548
ce5a06
---
ce5a06
 src/application.js | 3 +++
ce5a06
 1 file changed, 3 insertions(+)
ce5a06
ce5a06
diff --git a/src/application.js b/src/application.js
ce5a06
index 2630e1971826..1e439815f0b4 100644
ce5a06
--- a/src/application.js
ce5a06
+++ b/src/application.js
ce5a06
@@ -513,6 +513,9 @@ const Application = new Lang.Class({
ce5a06
     vfunc_dbus_register: function(connection, path) {
ce5a06
         this.parent(connection, path);
ce5a06
 
ce5a06
+        if (this._searchProvider != null)
ce5a06
+            throw(new Error('ShellSearchProvider already instantiated - dbus_register called twice?'));
ce5a06
+
ce5a06
         this._searchProvider = new ShellSearchProvider.ShellSearchProvider();
ce5a06
         this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
ce5a06
         this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
ce5a06
-- 
ce5a06
2.9.4
ce5a06
ce5a06
ce5a06
From 4d3476a700ecbb5066269f9fb15fc201d134859e Mon Sep 17 00:00:00 2001
ce5a06
From: Debarshi Ray <debarshir@gnome.org>
ce5a06
Date: Thu, 8 Jun 2017 16:58:08 +0200
ce5a06
Subject: [PATCH 16/16] application: Don't unexport a skeleton that was never
ce5a06
 exported
ce5a06
ce5a06
Otherwise it will again lead to:
ce5a06
  GLib-GIO-CRITICAL **:
ce5a06
    g_dbus_interface_skeleton_unexport_from_connection: assertion
ce5a06
    'interface_->priv->connections != NULL' failed
ce5a06
ce5a06
https://bugzilla.gnome.org/show_bug.cgi?id=783548
ce5a06
---
ce5a06
 src/application.js | 8 +++++++-
ce5a06
 1 file changed, 7 insertions(+), 1 deletion(-)
ce5a06
ce5a06
diff --git a/src/application.js b/src/application.js
ce5a06
index 1e439815f0b4..f9e8b6ae9863 100644
ce5a06
--- a/src/application.js
ce5a06
+++ b/src/application.js
ce5a06
@@ -520,7 +520,13 @@ const Application = new Lang.Class({
ce5a06
         this._searchProvider.connect('activate-result', Lang.bind(this, this._onActivateResult));
ce5a06
         this._searchProvider.connect('launch-search', Lang.bind(this, this._onLaunchSearch));
ce5a06
 
ce5a06
-        this._searchProvider.export(connection);
ce5a06
+        try {
ce5a06
+            this._searchProvider.export(connection);
ce5a06
+        } catch(e) {
ce5a06
+            this._searchProvider = null;
ce5a06
+            throw(e);
ce5a06
+        }
ce5a06
+
ce5a06
         return true;
ce5a06
     },
ce5a06
 
ce5a06
-- 
ce5a06
2.9.4
ce5a06