X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=backend%2Fev-document-factory.c;h=3b3f701a5ce6edf54aa5f7100ab9f833e1705614;hb=ddd3af422a32a56bdf0ae88c3f704b40776e9ede;hp=23364a2db1f5cdddc1a980a8104fba09bf1ad06b;hpb=f00b898dd13b85e510188714f6b9d9a349d23ed2;p=evince.git diff --git a/backend/ev-document-factory.c b/backend/ev-document-factory.c index 23364a2d..3b3f701a 100644 --- a/backend/ev-document-factory.c +++ b/backend/ev-document-factory.c @@ -287,28 +287,58 @@ EvDocument * ev_document_factory_get_document (const char *uri, GError **error) { EvDocument *document; + int result; document = get_document_from_uri (uri, FALSE, error); - if (*error == NULL) { - ev_document_load (document, uri, error); + if (*error != NULL) { + return NULL; } - - if (*error) { - g_error_free (*error); - *error = NULL; + + result = ev_document_load (document, uri, error); + + if (result == FALSE || *error) { + if (*error && + (*error)->domain == EV_DOCUMENT_ERROR && + (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) + return document; } else { return document; } + /* Try again with slow mime detection */ + if (document) + g_object_unref (document); + document = NULL; + + if (*error) + g_error_free (*error); + *error = NULL; + document = get_document_from_uri (uri, TRUE, error); if (*error != NULL) { return NULL; } - ev_document_load (document, uri, error); + result = ev_document_load (document, uri, error); + + if (result == FALSE) { + if (*error == NULL) { + g_set_error (error, + EV_DOCUMENT_ERROR, + 0, + _("Unknown MIME Type")); + } else if ((*error)->domain == EV_DOCUMENT_ERROR && + (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) { + return document; + } + if (document) + g_object_unref (document); + document = NULL; + } + return document; }