After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 700716 - Support previewing of password protected documents
Support previewing of password protected documents
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
3.7.x
Other All
: Normal enhancement
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-05-20 13:45 UTC by Debarshi Ray
Modified: 2014-02-25 10:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mainToolbar: Don't forward key presses to the search bar on load-error (1.49 KB, patch)
2013-05-27 14:49 UTC, Debarshi Ray
committed Details | Review
pdf-loader: Simplify reference counting (1.07 KB, patch)
2013-05-27 14:50 UTC, Debarshi Ray
committed Details | Review
Support password protected PDFs (14.04 KB, patch)
2013-05-27 14:50 UTC, Debarshi Ray
none Details | Review
Screenshot: trying to open a file named password-protected.pdf (25.01 KB, image/png)
2013-05-27 14:54 UTC, Debarshi Ray
  Details
Support password protected PDFs (14.79 KB, patch)
2013-05-27 15:19 UTC, Debarshi Ray
none Details | Review
Support password protected PDFs (15.12 KB, patch)
2013-05-27 15:58 UTC, Debarshi Ray
reviewed Details | Review
Support previewing of password protected PDFs (14.93 KB, patch)
2013-05-28 09:50 UTC, Debarshi Ray
accepted-commit_now Details | Review
Support previewing of password protected PDFs (17.80 KB, patch)
2013-07-08 16:19 UTC, Debarshi Ray
accepted-commit_now Details | Review
Support previewing of password protected PDFs (17.80 KB, patch)
2013-07-08 21:04 UTC, Debarshi Ray
committed Details | Review
preview: The toolbar is created after load-{started, finished} (2.75 KB, patch)
2014-02-24 10:32 UTC, Debarshi Ray
committed Details | Review
embed: Handle the password dialog being deleted (916 bytes, patch)
2014-02-24 10:33 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2013-05-20 13:45:56 UTC
Documents should be able to handle password protected content -- PDFs, ODTs, etc..
Comment 1 Debarshi Ray 2013-05-27 14:49:42 UTC
Created attachment 245388 [details] [review]
mainToolbar: Don't forward key presses to the search bar on load-error
Comment 2 Debarshi Ray 2013-05-27 14:50:16 UTC
Created attachment 245389 [details] [review]
pdf-loader: Simplify reference counting

I hope I am not missing something in this one.
Comment 3 Debarshi Ray 2013-05-27 14:50:45 UTC
Created attachment 245390 [details] [review]
Support password protected PDFs
Comment 4 Debarshi Ray 2013-05-27 14:54:18 UTC
Created attachment 245391 [details]
Screenshot: trying to open a file named password-protected.pdf
Comment 5 Debarshi Ray 2013-05-27 15:19:44 UTC
Created attachment 245393 [details] [review]
Support password protected PDFs

Forgot to 'git add src/mainToolbar.js'.
Comment 6 Debarshi Ray 2013-05-27 15:58:50 UTC
Created attachment 245395 [details] [review]
Support password protected PDFs

This time I forgot to update the call to load from the print method.
Comment 7 Cosimo Cecchi 2013-05-28 02:46:57 UTC
Review of attachment 245389 [details] [review]:

I probably didn't realize ev_job_scheduler_push_job() took a reference to the job object when writing that code. If you tested this to work, looks good to me.
Comment 8 Cosimo Cecchi 2013-05-28 02:58:48 UTC
Review of attachment 245395 [details] [review]:

Thanks, looks great. Just a couple of minor comments below.

::: src/embed.js
@@ +241,3 @@
+        vgrid.add(entryGrid);
+
+                                   row_spacing: 18,

Why activates_default = FALSE if the button is can_default = TRUE?

@@ +273,3 @@
+        let file = new Gio.File.new_for_uri(doc.uri);
+        let msg = _("The document “%s” is locked and requires a password before it can be opened."
+        let entryGrid = new Gtk.Grid({ column_spacing: 12,

Can you use doc.name instead?

::: src/lib/gd-pdf-loader.c
@@ +1016,3 @@
+ * @user_data:
+ *
+ * @passwd: (allow-none):

The method doesn't return anything, so the Returns annotation should be removed.
Comment 9 Cosimo Cecchi 2013-05-28 02:59:37 UTC
Review of attachment 245388 [details] [review]:

Looks good.
Comment 10 Debarshi Ray 2013-05-28 09:17:17 UTC
(In reply to comment #7)
> Review of attachment 245389 [details] [review]:
> 
> I probably didn't realize ev_job_scheduler_push_job() took a reference to the
> job object when writing that code. If you tested this to work, looks good to
> me.

Yes, I tested it and it works for me.
Comment 11 Debarshi Ray 2013-05-28 09:49:28 UTC
(In reply to comment #8)
> Review of attachment 245395 [details] [review]:

Thanks for the review.

> ::: src/embed.js
> @@ +241,3 @@
> +        vgrid.add(entryGrid);
> +
> +                                   row_spacing: 18,
> 
> Why activates_default = FALSE if the button is can_default = TRUE?

I don't know. :-)

It is a remnant of me experimenting with the code when keypresses were being forwarded to the searchbar and the activate default widget machinery wasn't working. Fixed.

> @@ +273,3 @@
> +        let file = new Gio.File.new_for_uri(doc.uri);
> +        let msg = _("The document “%s” is locked and requires a password
> before it can be opened."
> +        let entryGrid = new Gtk.Grid({ column_spacing: 12,
> 
> Can you use doc.name instead?

Done. Reading src/documents.js, I see that there doc.name can be theoretically ''. Can it actually happen in practice?

> ::: src/lib/gd-pdf-loader.c
> @@ +1016,3 @@
> + * @user_data:
> + *
> + * @passwd: (allow-none):
> 
> The method doesn't return anything, so the Returns annotation should be
> removed.

Fixed.
Comment 12 Debarshi Ray 2013-05-28 09:50:07 UTC
Created attachment 245442 [details] [review]
Support previewing of password protected PDFs
Comment 13 Cosimo Cecchi 2013-05-28 15:13:46 UTC
Review of attachment 245442 [details] [review]:

Looks good to me
Comment 14 Cosimo Cecchi 2013-05-28 15:14:55 UTC
(In reply to comment #11)

> Done. Reading src/documents.js, I see that there doc.name can be theoretically
> ''. Can it actually happen in practice?

doc.name should already fall back to the filename, in case the value returned by Tracker is empty. It's also already used everywhere else, so I don't think this should be a problem in practice.
Comment 15 Allan Day 2013-05-30 12:22:11 UTC
(In reply to comment #4)
> Created an attachment (id=245391) [details]
> Screenshot: trying to open a file named password-protected.pdf

It looks a bit odd embedding the password entry in the view itself. The controls float in space.

Here's some mockups for using dialogs instead:

https://raw.github.com/gnome-design-team/gnome-mockups/master/documents/wireframes/password-protected-docs.png

https://raw.github.com/gnome-design-team/gnome-mockups/master/documents/wireframes/password-protected-docs-batch.png
Comment 16 Matthias Clasen 2013-07-01 21:30:05 UTC
Debarshi, can we land this ? (and backport for f19, ideally)
Comment 17 Debarshi Ray 2013-07-08 16:19:12 UTC
Created attachment 248624 [details] [review]
Support previewing of password protected PDFs
Comment 18 Cosimo Cecchi 2013-07-08 16:33:51 UTC
Review of attachment 248624 [details] [review]:

Thanks Debarshi, this looks good with this minor style fix.

::: src/password.js
@@ +79,3 @@
+                                mnemonic_widget: entry,
+                                use_underline: true });
+        label.get_style_context ().add_class('dim-label');

Extra space here.
Comment 19 Debarshi Ray 2013-07-08 21:04:15 UTC
Created attachment 248665 [details] [review]
Support previewing of password protected PDFs
Comment 20 Debarshi Ray 2014-02-24 08:55:47 UTC
Reopening.
Comment 21 Debarshi Ray 2014-02-24 08:58:15 UTC
Review of attachment 248665 [details] [review]:

This patch is incomplete. Among other things it breaks the fix for bug 701264

The issue is that PreviewToolbar listens to DocumentManager::load-{started, finished} to enable and disable various UI elements. However, due to this patch the toolbar never receives those signals because the toolbar gets created after those signals have been emitted.

::: src/embed.js
@@ +387,3 @@
     _onLoadFinished: function(manager, doc, docModel) {
+        Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
+

Due to this hunk and the one above it, the mode is changed after load-{started, finished, etc.} have been emitted. Which means that PreviewToolbar did not get a chance to receive those signals.
Comment 22 Debarshi Ray 2014-02-24 10:32:47 UTC
Created attachment 270103 [details] [review]
preview: The toolbar is created after load-{started, finished}
Comment 23 Debarshi Ray 2014-02-24 10:33:28 UTC
Created attachment 270104 [details] [review]
embed: Handle the password dialog being deleted
Comment 24 Cosimo Cecchi 2014-02-24 16:40:10 UTC
Review of attachment 270103 [details] [review]:

Looks good, but why do you need this._handleEvent at all?
Comment 25 Cosimo Cecchi 2014-02-24 16:40:27 UTC
Review of attachment 270104 [details] [review]:

Sure
Comment 26 Debarshi Ray 2014-02-24 17:55:11 UTC
(In reply to comment #24)
> Review of attachment 270103 [details] [review]:
> 
> Looks good, but why do you need this._handleEvent at all?

It was introduced in:

commit 983f439c8348ca04eff6b911c5a05ca52e7bd872
Author: Debarshi Ray <debarshir@gnome.org>
Date:   Mon May 27 16:27:51 2013 +0200

    mainToolbar: Don't forward key presses to the search bar on load-error
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700716

The idea was to have a way of not forwarding key presses to the search bar.
Comment 27 Cosimo Cecchi 2014-02-24 18:15:25 UTC
Comment on attachment 270103 [details] [review]
preview: The toolbar is created after load-{started, finished}

OK I missed that. Looks good then.
Comment 28 Debarshi Ray 2014-02-25 08:23:59 UTC
Comment on attachment 270103 [details] [review]
preview: The toolbar is created after load-{started, finished}

Thanks for the review!