From: Carlos Garcia Campos Date: Sat, 10 Feb 2007 19:51:47 +0000 (+0000) Subject: Check whether there are missing files in indirect multipage djvu X-Git-Tag: EVINCE_0_7_2~15 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f897c94aa9ceb0cca024bea351a2821d2f0b4a57;p=evince.git Check whether there are missing files in indirect multipage djvu 2007-02-10 Carlos Garcia Campos * po/POTFILES.in: * backend/djvu/djvu-document.c: (djvu_document_load): Check whether there are missing files in indirect multipage djvu documents. Fixes bug #361683. svn path=/trunk/; revision=2306 --- diff --git a/ChangeLog b/ChangeLog index 66678853..18469c1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-02-10 Carlos Garcia Campos + + * po/POTFILES.in: + * backend/djvu/djvu-document.c: (djvu_document_load): + + Check whether there are missing files in indirect multipage djvu + documents. Fixes bug #361683. + 2007-02-07 Nickolay V. Shmyrev * test/Makefile.am: diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c index ad185559..df5ecb34 100644 --- a/backend/djvu/djvu-document.c +++ b/backend/djvu/djvu-document.c @@ -28,8 +28,8 @@ #include #include -#include #include +#include #include #include @@ -67,10 +67,13 @@ djvu_handle_events (DjvuDocument *djvu_document, int wait) { ddjvu_context_t *ctx = djvu_document->d_context; const ddjvu_message_t *msg; + if (!ctx) return; + if (wait) msg = ddjvu_message_wait (ctx); + while ((msg = ddjvu_message_peek (ctx))) { switch (msg->m_any.tag) { case DDJVU_ERROR: @@ -80,6 +83,7 @@ djvu_handle_events (DjvuDocument *djvu_document, int wait) g_warning ("DjvuLibre error: %s:%d", msg->m_error.filename, msg->m_error.lineno); + break; default: break; } @@ -95,6 +99,7 @@ djvu_document_load (EvDocument *document, DjvuDocument *djvu_document = DJVU_DOCUMENT (document); ddjvu_document_t *doc; gchar *filename; + gboolean missing_files = FALSE; /* FIXME: We could actually load uris */ filename = g_filename_from_uri (uri, NULL, error); @@ -103,7 +108,10 @@ djvu_document_load (EvDocument *document, doc = ddjvu_document_create_by_filename (djvu_document->d_context, filename, TRUE); - if (!doc) return FALSE; + if (!doc) { + g_free (filename); + return FALSE; + } if (djvu_document->d_document) ddjvu_document_release (djvu_document->d_document); @@ -111,10 +119,51 @@ djvu_document_load (EvDocument *document, djvu_document->d_document = doc; while (!ddjvu_document_decoding_done (djvu_document->d_document)) - djvu_handle_events(djvu_document, TRUE); + djvu_handle_events (djvu_document, TRUE); g_free (djvu_document->uri); djvu_document->uri = g_strdup (uri); + if (ddjvu_document_get_type (djvu_document->d_document) == DDJVU_DOCTYPE_INDIRECT) { + gint n_files; + gint i; + gchar *base; + + base = g_path_get_dirname (filename); + + n_files = ddjvu_document_get_filenum (djvu_document->d_document); + for (i = 0; i < n_files; i++) { + struct ddjvu_fileinfo_s fileinfo; + gchar *file; + + ddjvu_document_get_fileinfo (djvu_document->d_document, + i, &fileinfo); + + if (fileinfo.type != 'P') + continue; + + file = g_build_filename (base, fileinfo.id, NULL); + if (!g_file_test (file, G_FILE_TEST_EXISTS)) { + missing_files = TRUE; + g_free (file); + + break; + } + g_free (file); + } + g_free (base); + } + g_free (filename); + + if (missing_files) { + g_set_error (error, + G_FILE_ERROR, + G_FILE_ERROR_EXIST, + _("The document is composed by several files. " + "One or more of such files cannot be accessed.")); + + return FALSE; + } + return TRUE; } @@ -150,7 +199,7 @@ djvu_document_get_page_size (EvDocument *document, ddjvu_status_t r; g_return_if_fail (djvu_document->d_document); - + while ((r = ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info)) < DDJVU_JOB_OK) djvu_handle_events(djvu_document, TRUE); diff --git a/po/POTFILES.in b/po/POTFILES.in index 6761e52e..0716f98f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,6 +2,7 @@ # Please keep this file sorted alphabetically. [encoding: UTF-8] backend/comics/comics-document.c +backend/djvu/djvu-document.c backend/dvi/dvi-document.c backend/pdf/ev-poppler.cc backend/impress/zip.c