From de132bfcabbb4c65a250e1756b59706cebcc96bb Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Wed, 6 Aug 2008 17:35:22 +0000 Subject: [PATCH] Fix loading encrypted documents since I broke it with the jobs rework. 2008-08-06 Carlos Garcia Campos * shell/ev-jobs.[ch]: (ev_job_load_dispose), (ev_job_load_run), (ev_job_load_set_password): * shell/ev-password.[ch]: (ev_password_dialog_get_password): * shell/ev-window.c: (password_dialog_response), (ev_window_load_job_cb): Fix loading encrypted documents since I broke it with the jobs rework. svn path=/trunk/; revision=3099 --- ChangeLog | 11 +++++++++++ shell/ev-jobs.c | 27 +++++++++++++++++++++++++-- shell/ev-jobs.h | 3 +++ shell/ev-password.c | 4 ++-- shell/ev-password.h | 8 ++++---- shell/ev-window.c | 35 ++++++++--------------------------- 6 files changed, 53 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46d9d50a..32410fdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,17 @@ Update for release 2.23.6. +2008-08-06 Carlos Garcia Campos + + * shell/ev-jobs.[ch]: (ev_job_load_dispose), (ev_job_load_run), + (ev_job_load_set_password): + * shell/ev-password.[ch]: (ev_password_dialog_get_password): + * shell/ev-window.c: (password_dialog_response), + (ev_window_load_job_cb): + + Fix loading encrypted documents since I broke it with the jobs + rework. + 2008-08-05 Carlos Garcia Campos * NEWS: diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 7371dd1a..dd8fb097 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -30,7 +30,7 @@ #include "ev-document-misc.h" #include "ev-file-helpers.h" #include "ev-document-fonts.h" -#include "ev-async-renderer.h" +#include "ev-document-security.h" #include "ev-debug.h" #include @@ -716,6 +716,11 @@ ev_job_load_dispose (GObject *object) job->uri = NULL; } + if (job->password) { + g_free (job->password); + job->password = NULL; + } + if (job->dest) { g_object_unref (job->dest); job->dest = NULL; @@ -740,11 +745,19 @@ ev_job_load_run (EvJob *job) ev_document_fc_mutex_lock (); - /* TODO: reuse the job!!! */ /* This job may already have a document even if the job didn't complete because, e.g., a password is required - if so, just reload rather than creating a new instance */ if (job->document) { + if (job_load->password) { + ev_document_security_set_password (EV_DOCUMENT_SECURITY (job->document), + job_load->password); + } + + job->failed = FALSE; + job->finished = FALSE; + g_clear_error (&job->error); + ev_document_load (job->document, job_load->uri, &error); @@ -805,6 +818,16 @@ ev_job_load_set_uri (EvJobLoad *job, const gchar *uri) job->uri = g_strdup (uri); } +void +ev_job_load_set_password (EvJobLoad *job, const gchar *password) +{ + ev_debug_message (DEBUG_JOBS, NULL); + + if (job->password) + g_free (job->password); + job->password = password ? g_strdup (password) : NULL; +} + /* EvJobSave */ static void ev_job_save_init (EvJobSave *job) diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h index 336567b4..95c7f7da 100644 --- a/shell/ev-jobs.h +++ b/shell/ev-jobs.h @@ -226,6 +226,7 @@ struct _EvJobLoad EvWindowRunMode mode; gchar *search_string; gchar *uri; + gchar *password; }; struct _EvJobLoadClass @@ -323,6 +324,8 @@ EvJob *ev_job_load_new (const gchar *uri, const gchar *search_string); void ev_job_load_set_uri (EvJobLoad *load, const gchar *uri); +void ev_job_load_set_password (EvJobLoad *job, + const gchar *password); /* EvJobSave */ GType ev_job_save_get_type (void) G_GNUC_CONST; diff --git a/shell/ev-password.c b/shell/ev-password.c index ae317f02..a191b9f1 100644 --- a/shell/ev-password.c +++ b/shell/ev-password.c @@ -334,10 +334,10 @@ ev_password_search_in_keyring (EvPasswordDialog *dialog, const gchar *uri) return; } -char * +const char * ev_password_dialog_get_password (EvPasswordDialog *dialog) { - return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry))); + return gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)); } void diff --git a/shell/ev-password.h b/shell/ev-password.h index af76d3d4..d092ccab 100644 --- a/shell/ev-password.h +++ b/shell/ev-password.h @@ -47,11 +47,11 @@ struct _EvPasswordDialogClass GtkDialogClass parent_class; }; -GType ev_password_dialog_get_type (void) G_GNUC_CONST; +GType ev_password_dialog_get_type (void) G_GNUC_CONST; -char *ev_password_dialog_get_password (EvPasswordDialog *dialog); -void ev_password_dialog_set_bad_pass (EvPasswordDialog *dialog); -void ev_password_dialog_save_password (EvPasswordDialog *dialog); +const char *ev_password_dialog_get_password (EvPasswordDialog *dialog); +void ev_password_dialog_set_bad_pass (EvPasswordDialog *dialog); +void ev_password_dialog_save_password (EvPasswordDialog *dialog); G_END_DECLS diff --git a/shell/ev-window.c b/shell/ev-window.c index cf65611a..02932295 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -55,7 +55,6 @@ #include "ev-document-fonts.h" #include "ev-document-images.h" #include "ev-document-links.h" -#include "ev-document-security.h" #include "ev-document-thumbnails.h" #include "ev-file-exporter.h" #include "ev-file-helpers.h" @@ -1219,18 +1218,9 @@ password_dialog_response (GtkWidget *password_dialog, gint response_id, EvWindow *ev_window) { - char *password; - if (response_id == GTK_RESPONSE_OK) { - - password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog)); - if (password) { - ev_document_doc_mutex_lock (); - ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->load_job->document), - password); - ev_document_doc_mutex_unlock (); - } - g_free (password); + ev_job_load_set_password (EV_JOB_LOAD (ev_window->priv->load_job), + ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog))); ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog)); @@ -1351,8 +1341,8 @@ ev_window_clear_temp_file (EvWindow *ev_window) * function should _not_ necessarily expect those to exist after being * called. */ static void -ev_window_load_job_cb (EvJob *job, - gpointer data) +ev_window_load_job_cb (EvJob *job, + gpointer data) { EvWindow *ev_window = EV_WINDOW (data); EvDocument *document = EV_JOB (job)->document; @@ -1398,16 +1388,7 @@ ev_window_load_job_cb (EvJob *job, break; } - /* Restart the search after reloading */ - if (ev_window->priv->in_reload) { - GtkWidget *widget; - - widget = gtk_window_get_focus (GTK_WINDOW (ev_window)); - if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) { - find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar), - NULL, ev_window); - } - } else if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) { + if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) { ev_window_cmd_edit_find (NULL, ev_window); egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar), job_load->search_string); @@ -1458,7 +1439,7 @@ ev_window_reload_job_cb (EvJob *job, ev_window->priv->in_reload = FALSE; return; } - + ev_window_set_document (ev_window, job->document); /* Restart the search after reloading */ @@ -1467,7 +1448,7 @@ ev_window_reload_job_cb (EvJob *job, find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar), NULL, ev_window); } - + ev_window_clear_reload_job (ev_window); ev_window->priv->in_reload = FALSE; } @@ -4271,7 +4252,7 @@ ev_window_dispose (GObject *object) ev_window_clear_local_uri (window); priv->local_uri = NULL; } - + ev_window_close_dialogs (window); ev_window_clear_print_job (window); -- 2.43.5