Hi ports@,

This is a backport of r339 from epdfview trunk, it fixes erroneous error
messages related to "encrypted files".

http://trac.emma-soft.com/epdfview/changeset/338
http://trac.emma-soft.com/epdfview/changeset/339

There are a few other issues that have been fixed in SVN, here is a list
if anyone sees something they would like have in the ports tree.

http://trac.emma-soft.com/epdfview/changeset/331
http://trac.emma-soft.com/epdfview/changeset/336
http://trac.emma-soft.com/epdfview/changeset/337
http://trac.emma-soft.com/epdfview/changeset/341
http://trac.emma-soft.com/epdfview/changeset/342
http://trac.emma-soft.com/epdfview/changeset/343
http://trac.emma-soft.com/epdfview/changeset/346

It may be a good idea importing some of these, official releases don't
occur very often.

-Bryan.

Index: Makefile
===================================================================
RCS file: /cvs/ports/print/epdfview/Makefile,v
retrieving revision 1.15
diff -N -u Makefile
--- Makefile    22 Dec 2009 15:54:32 -0000      1.15
+++ Makefile    30 Dec 2009 05:46:07 -0000
@@ -3,7 +3,7 @@
 COMMENT=       lightweight PDF document viewer

 DISTNAME=      epdfview-0.1.7
-PKGNAME=       ${DISTNAME}p3
+PKGNAME=       ${DISTNAME}p4
 CATEGORIES=    print
 HOMEPAGE=      http://trac.emma-soft.com/epdfview/

Index: patches/patch-src_IDocument_cxx
===================================================================
RCS file: patches/patch-src_IDocument_cxx
diff -N -u patches/patch-src_IDocument_cxx
--- /dev/null   30 Dec 2009 05:46:07 -0000
+++ patches/patch-src_IDocument_cxx     30 Dec 2009 05:46:07 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+Better error message for failed opens, r338.
+--- src/IDocument.cxx.orig     Wed Dec 30 00:38:35 2009
++++ src/IDocument.cxx  Wed Dec 30 00:39:05 2009
+@@ -82,7 +82,7 @@ IDocument::getErrorMessage (DocumentError errorCode)
+             errorMessage = g_strdup (_("No error."));
+             break;
+         case DocumentErrorOpenFile:
+-            errorMessage = g_strdup (_("File not found."));
++            errorMessage = g_strdup (_("Could not open file."));
+             break;
+         case DocumentErrorBadCatalog:
+             errorMessage = g_strdup (_("Couldn't read the page
catalog."));
Index: patches/patch-src_PDFDocument_cxx
===================================================================
RCS file: patches/patch-src_PDFDocument_cxx
diff -N -u patches/patch-src_PDFDocument_cxx
--- /dev/null   30 Dec 2009 05:46:07 -0000
+++ patches/patch-src_PDFDocument_cxx   30 Dec 2009 05:46:07 -0000
@@ -0,0 +1,45 @@
+$OpenBSD$
+Fixes error handling, bogus encrypted files, r339.
+--- src/PDFDocument.cxx.orig   Sat Feb 28 16:00:35 2009
++++ src/PDFDocument.cxx        Tue Dec 29 23:00:29 2009
+@@ -246,23 +246,25 @@ PDFDocument::loadFile (const gchar *filename,
const gc
+     // Check if the document couldn't be opened successfully and why.
+     if ( NULL == newDocument )
+     {
+-        // Poppler's glib wrapper passes the Poppler error code unless the
+-        // error is that the file is encrypted. We want to set our own
+-        // error code in this case.
+         DocumentError errorCode = DocumentErrorNone;
+-        if ( POPPLER_ERROR == loadError->domain )
++        switch ( loadError->code )
+         {
+-            errorCode = DocumentErrorEncrypted;
+-        }
+-        else
+-        {
+-            // OK, the glib's wrapper don't pass the error code directly
+-            // from Poppler. Instead returns G_FILE_ERROR_FAILED and a
+-            // non translated string.
+-            // Maybe I'm wrong (very probable) but that's a wrong way.
+-            // So I'm reading the error code from the error string...
+-            sscanf (loadError->message, "Failed to load document
(error %d)",
+-                    (gint *)&errorCode);
++            case POPPLER_ERROR_OPEN_FILE:
++            case POPPLER_ERROR_INVALID:
++                errorCode = DocumentErrorOpenFile;
++                break;
++
++            case POPPLER_ERROR_BAD_CATALOG:
++                errorCode = DocumentErrorBadCatalog;
++                break;
++
++            case POPPLER_ERROR_DAMAGED:
++                errorCode = DocumentErrorDamaged;
++                break;
++
++            case POPPLER_ERROR_ENCRYPTED:
++                errorCode = DocumentErrorEncrypted;
++                break;
+         }
+         g_error_free (loadError);
+         // Get our error message.

Reply via email to