Add feature flag for poppler signing API

Test and conditionally-compile pdf signing feature, depending
on poppler new-ness.
remotes/origin/work/aacid/dont_show_non_valid_certs
Thorsten Behrens 7 years ago committed by Albert Astals Cid
parent b33a12d786
commit e3e582ee5c
  1. 5
      core/document.cpp
  2. 5
      core/document.h
  3. 8
      generators/poppler/CMakeLists.txt
  4. 2
      generators/poppler/config-okular-poppler.h.cmake
  5. 4
      generators/poppler/generator_pdf.cpp
  6. 5
      part/pageview.cpp
  7. 5
      part/preferencesdialog.cpp

@ -2799,6 +2799,11 @@ bool Document::canProvideFontInformation() const
return d->m_generator ? d->m_generator->hasFeature(Generator::FontInfo) : false;
}
bool Document::canSign() const
{
return d->m_generator ? d->m_generator->canSign() : false;
}
const QList<EmbeddedFile *> *Document::embeddedFiles() const
{
return d->m_generator ? d->m_generator->embeddedFiles() : nullptr;

@ -281,6 +281,11 @@ public:
*/
bool canProvideFontInformation() const;
/**
* Whether the current document can perform digital signing.
*/
bool canSign() const;
/**
* Returns the list of embedded files or 0 if no embedded files
* are available.

@ -15,6 +15,14 @@ int main()
}
" HAVE_POPPLER_0_87)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
auto f = &Poppler::Document::sign;
}
" HAVE_POPPLER_SIGNING)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h

@ -1,3 +1,5 @@
/* Defined if we have the 0.87 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_87 1
/* Defined if we have the pdf signature feature in the Poppler library */
#cmakedefine HAVE_POPPLER_SIGNING 1

@ -1856,10 +1856,14 @@ Okular::AnnotationProxy *PDFGenerator::annotationProxy() const
void PDFGenerator::sign( const Okular::Annotation* pWhichAnnotation )
{
#ifdef HAVE_POPPLER_SIGNING
const Okular::WidgetAnnotation* wa = dynamic_cast<const Okular::WidgetAnnotation*>(pWhichAnnotation);
Poppler::Annotation *popplerAnn = qvariant_cast< Poppler::Annotation * >( pWhichAnnotation->nativeId() );
pdfdoc->sign( popplerAnn, wa->certificateCN(), wa->password() );
#else
Q_UNUSED( pWhichAnnotation );
#endif
}
#include "generator_pdf.moc"

@ -1218,7 +1218,10 @@ void PageView::updateActionState(bool haspages, bool hasformwidgets)
}
if ( d->aSignature )
d->aSignature->setEnabled( haspages );
{
const bool canSign = d->document->canSign();
d->aSignature->setEnabled( canSign && haspages );
}
#ifdef HAVE_SPEECH
if (d->aSpeakDoc) {

@ -11,6 +11,7 @@
#include "preferencesdialog.h"
#include <KLocalizedString>
#include "../generators/poppler/config-okular-poppler.h"
// single config pages
#include "dlgaccessibility.h"
@ -48,11 +49,15 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, KConfigSkeleton *skeleton,
m_presentation = new DlgPresentation(this);
m_annotations = new DlgAnnotations(this);
m_editor = new DlgEditor(this);
#ifdef HAVE_POPPLER_SIGNING
m_signatures = new DlgSignatures(this);
#endif
addPage(m_presentation, i18n("Presentation"), QStringLiteral("view-presentation"), i18n("Options for Presentation Mode"));
m_annotationsPage = addPage(m_annotations, i18n("Annotations"), QStringLiteral("draw-freehand"), i18n("Annotation Options"));
addPage(m_editor, i18n("Editor"), QStringLiteral("accessories-text-editor"), i18n("Editor Options"));
#ifdef HAVE_POPPLER_SIGNING
addPage(m_signatures, i18n("Signatures"), QStringLiteral("application-pkcs7-signature"), i18n("Digital Signatures"));
#endif
}
#ifdef OKULAR_DEBUG_CONFIGPAGE
addPage(m_debug, "Debug", "system-run", "Debug options");

Loading…
Cancel
Save