it does not make much sense to check for a serie of permissions at the same time, so just check one permission at a time

svn path=/trunk/playground/graphics/okular/; revision=641341
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 9a10418505
commit 1bfc805a3e
  1. 4
      core/document.cpp
  2. 7
      core/document.h
  3. 2
      core/generator.cpp
  4. 4
      core/generator.h
  5. 22
      generators/poppler/generator_pdf.cpp
  6. 2
      generators/poppler/generator_pdf.h

@ -1165,14 +1165,14 @@ KUrl Document::currentDocument() const
return d->m_url; return d->m_url;
} }
bool Document::isAllowed( Permissions flags ) const bool Document::isAllowed( Permission action ) const
{ {
#if !OKULAR_FORCE_DRM #if !OKULAR_FORCE_DRM
if ( KAuthorized::authorize( "skip_drm" ) && !Okular::Settings::obeyDRM() ) if ( KAuthorized::authorize( "skip_drm" ) && !Okular::Settings::obeyDRM() )
return true; return true;
#endif #endif
return d->m_generator ? d->m_generator->isAllowed( flags ) : false; return d->m_generator ? d->m_generator->isAllowed( action ) : false;
} }
bool Document::supportsSearching() const bool Document::supportsSearching() const

@ -180,11 +180,10 @@ class OKULAR_EXPORT Document : public QObject
KUrl currentDocument() const; KUrl currentDocument() const;
/** /**
* Returns whether the given @p actions are allowed * Returns whether the given @p action is allowed in the document.
* in the document. * @see @ref Permission
* @see @ref Permissions
*/ */
bool isAllowed( Permissions actions ) const; bool isAllowed( Permission action ) const;
/** /**
* Returns whether the document supports searching. * Returns whether the document supports searching.

@ -223,7 +223,7 @@ Generator::PageSizeMetric Generator::pagesSizeMetric() const
return None; return None;
} }
bool Generator::isAllowed( Permissions ) const bool Generator::isAllowed( Permission ) const
{ {
return true; return true;
} }

@ -286,10 +286,10 @@ class OKULAR_EXPORT Generator : public QObject
virtual PageSizeMetric pagesSizeMetric() const; virtual PageSizeMetric pagesSizeMetric() const;
/** /**
* This method returns whether given action (@ref Permission) is * This method returns whether given @p action (@ref Permission) is
* allowed in this document. * allowed in this document.
*/ */
virtual bool isAllowed( Permissions action ) const; virtual bool isAllowed( Permission action ) const;
/** /**
* This method is called when the orientation has been changed by the user. * This method is called when the orientation has been changed by the user.

@ -591,13 +591,25 @@ const QList<Okular::EmbeddedFile*> *PDFGenerator::embeddedFiles() const
return &docEmbeddedFiles; return &docEmbeddedFiles;
} }
bool PDFGenerator::isAllowed( Okular::Permissions permissions ) const bool PDFGenerator::isAllowed( Okular::Permission permission ) const
{ {
bool b = true; bool b = true;
if (permissions & Okular::AllowModify) b = b && pdfdoc->okToChange(); switch ( permission )
if (permissions & Okular::AllowCopy) b = b && pdfdoc->okToCopy(); {
if (permissions & Okular::AllowPrint) b = b && pdfdoc->okToPrint(); case Okular::AllowModify:
if (permissions & Okular::AllowNotes) b = b && pdfdoc->okToAddNotes(); b = pdfdoc->okToChange();
break;
case Okular::AllowCopy:
b = pdfdoc->okToCopy();
break;
case Okular::AllowPrint:
b = pdfdoc->okToPrint();
break;
case Okular::AllowNotes:
b = pdfdoc->okToAddNotes();
break;
default: ;
}
return b; return b;
} }

@ -63,7 +63,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface
PageSizeMetric pagesSizeMetric() const { return Points; } PageSizeMetric pagesSizeMetric() const { return Points; }
// [INHERITED] document information // [INHERITED] document information
bool isAllowed( Okular::Permissions permissions ) const; bool isAllowed( Okular::Permission permission ) const;
// [INHERITED] perform actions on document / pages // [INHERITED] perform actions on document / pages
bool canGeneratePixmap() const; bool canGeneratePixmap() const;

Loading…
Cancel
Save