• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kleopatra

  • sources
  • kde-4.12
  • kdepim
  • kleopatra
  • crypto
  • gui
signencryptfileswizard.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  crypto/gui/signencryptfileswizard.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2007 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include <config-kleopatra.h>
34 
35 #include "signencryptfileswizard.h"
36 #include "signerresolvepage.h"
37 
38 #include <KLocale>
39 
40 #include <gpgme++/key.h>
41 
42 #include <cassert>
43 
44 using namespace Kleo;
45 using namespace Kleo::Crypto::Gui;
46 using namespace GpgME;
47 
48 namespace {
49 
50  class SignerResolveValidator : public SignerResolvePage::Validator {
51  public:
52  explicit SignerResolveValidator( SignerResolvePage* page );
53  bool isComplete() const;
54  QString explanation() const;
55  void update() const;
56  QString customWindowTitle() const;
57 
58  private:
59  SignerResolvePage* const m_page;
60  mutable QString expl;
61  mutable bool complete;
62  };
63 }
64 
65 SignerResolveValidator::SignerResolveValidator( SignerResolvePage* page ) : SignerResolvePage::Validator(), m_page( page ), complete( true )
66 {
67  assert( m_page );
68 }
69 
70 void SignerResolveValidator::update() const {
71  expl.clear();
72  const bool needPgpSC = m_page->operation() == SignerResolvePage::SignAndEncrypt;
73  const bool isSignEncrypt = m_page->operation() == SignerResolvePage::SignAndEncrypt;
74  const bool needAnySC = m_page->operation() != SignerResolvePage::EncryptOnly;
75  const bool havePgpSC = !m_page->signingCertificates( GpgME::OpenPGP ).empty();
76  const bool haveCmsSC = !m_page->signingCertificates( GpgME::CMS ).empty();
77  const bool haveAnySC = havePgpSC || haveCmsSC;
78  complete = ( !needPgpSC || havePgpSC ) && ( !needAnySC || haveAnySC );
79 
80 #undef setAndReturn
81 #define setAndReturn(text) { expl = text; return; }
82 
83  if( needPgpSC && !havePgpSC )
84  setAndReturn( i18n( "You need to select an OpenPGP signing certificate to perform this operation." ) );
85 
86  if ( needAnySC && !haveAnySC )
87  setAndReturn( i18n( "You need to select at least one signing certificate to proceed." ) );
88 
89  if ( isSignEncrypt && needPgpSC && havePgpSC )
90  setAndReturn( i18n( "Only OpenPGP certificates will be offered for selection because you specified a combined sign/encrypt operation that is only available for OpenPGP." ) );
91 
92  if ( isSignEncrypt && havePgpSC && !haveCmsSC )
93  setAndReturn( i18n( "Only OpenPGP certificates will be offered for selection because you only specified an OpenPGP signing certificate." ) );
94 
95  if ( haveCmsSC && !havePgpSC )
96  setAndReturn( i18n( "Only S/MIME certificates will be offered for selection because you only specified an S/MIME signing certificate." ) );
97 
98  switch ( m_page->operation() )
99  {
100  case SignerResolvePage::SignOnly:
101  if ( havePgpSC && haveCmsSC )
102  expl = i18n( "You have selected both OpenPGP and S/MIME signing certificate types, thus two signatures will be created." );
103  break;
104  case SignerResolvePage::SignAndEncrypt:
105  case SignerResolvePage::EncryptOnly:
106  expl = i18n( "If you select both OpenPGP and S/MIME receipient certificates, two encrypted files will be created: one for OpenPGP recipients, one for S/MIME recipients." );
107  break;
108  }
109 
110 
111 #undef setAndReturn
112 }
113 
114 bool SignerResolveValidator::isComplete() const
115 {
116  update();
117  return complete;
118 }
119 
120 QString SignerResolveValidator::explanation() const
121 {
122  update();
123  return expl;
124 }
125 
126 QString SignerResolveValidator::customWindowTitle() const
127 {
128  const bool sign = m_page->signingSelected();
129  const bool encr = m_page->encryptionSelected();
130 
131  return sign && encr ? i18n( "Sign/Encrypt Files" ) :
132  sign ? i18n( "Sign Files" ) :
133  encr ? i18n( "Encrypt Files" ) : QString();
134 }
135 
136 class SignEncryptFilesWizard::Private {
137  friend class ::Kleo::Crypto::Gui::SignEncryptFilesWizard;
138  SignEncryptFilesWizard * const q;
139 public:
140  explicit Private( SignEncryptFilesWizard * qq );
141  ~Private();
142 
143  void operationSelected();
144 private:
145 
146 };
147 
148 
149 SignEncryptFilesWizard::Private::Private( SignEncryptFilesWizard * qq )
150  : q( qq )
151 {
152  q->connect( q, SIGNAL(signersResolved()), q, SLOT(operationSelected()) );
153  std::vector<int> pageOrder;
154  q->setSignerResolvePageValidator( boost::shared_ptr<SignerResolveValidator>( new SignerResolveValidator( q->signerResolvePage() ) ) );
155  pageOrder.push_back( SignEncryptWizard::ResolveSignerPage );
156  pageOrder.push_back( SignEncryptWizard::ObjectsPage );
157  pageOrder.push_back( SignEncryptWizard::ResolveRecipientsPage );
158  pageOrder.push_back( SignEncryptWizard::ResultPage );
159  q->setPageOrder( pageOrder );
160  q->setCommitPage( SignEncryptWizard::ResolveRecipientsPage );
161  std::vector<Protocol> protocols;
162  protocols.push_back( OpenPGP );
163  protocols.push_back( CMS );
164  q->setMultipleProtocolsAllowed( true );
165  q->setRecipientsUserMutable( true );
166 }
167 
168 SignEncryptFilesWizard::Private::~Private() {}
169 
170 void SignEncryptFilesWizard::Private::operationSelected()
171 {
172  const bool encrypt = q->encryptionSelected();
173  q->setPageVisible( SignEncryptWizard::ResolveRecipientsPage, encrypt );
174  q->setCommitPage( encrypt ? SignEncryptWizard::ResolveRecipientsPage : SignEncryptWizard::ObjectsPage );
175 }
176 
177 SignEncryptFilesWizard::SignEncryptFilesWizard( QWidget * parent, Qt::WindowFlags f )
178  : SignEncryptWizard( parent, f ), d( new Private( this ) )
179 {
180 }
181 
182 SignEncryptFilesWizard::~SignEncryptFilesWizard() {}
183 
184 void SignEncryptFilesWizard::onNext( int currentId )
185 {
186  SignEncryptWizard::onNext( currentId );
187  const bool encrypt = encryptionSelected();
188 
189  if ( ( encrypt && currentId == ResolveRecipientsPage ) || ( !encrypt && currentId == ObjectsPage ) )
190  emit operationPrepared();
191 }
192 
193 #include "moc_signencryptfileswizard.cpp"
194 
Kleo::Crypto::Gui::SignEncryptWizard
Definition: signencryptwizard.h:70
Kleo::Crypto::Gui::SignEncryptWizard::onNext
void onNext(int currentId)
Definition: signencryptwizard.cpp:102
QWidget
Kleo::Crypto::Gui::SignEncryptFilesWizard::onNext
void onNext(int currentId)
Definition: signencryptfileswizard.cpp:184
signencryptfileswizard.h
Kleo::Crypto::Gui::SignEncryptFilesWizard::~SignEncryptFilesWizard
~SignEncryptFilesWizard()
Definition: signencryptfileswizard.cpp:182
Kleo::Crypto::Gui::ResolveRecipientsPage
Definition: resolverecipientspage.h:63
boost::shared_ptr
Definition: encryptemailcontroller.h:51
Kleo::Crypto::Gui::SignEncryptWizard::encryptionSelected
bool encryptionSelected() const
Definition: signencryptwizard.cpp:214
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Class::OpenPGP
Definition: classify.h:49
Kleo::Crypto::Gui::SignEncryptFilesWizard::operationPrepared
void operationPrepared()
Kleo::Class::CMS
Definition: classify.h:48
signerresolvepage.h
setAndReturn
#define setAndReturn(text)
Kleo::Crypto::Gui::SignerResolvePage
Definition: signerresolvepage.h:57
update
static void update(const QString &fname, const QString &id)
Definition: filedialog.cpp:61
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::Crypto::Gui::ObjectsPage
Definition: objectspage.h:46
Kleo::Crypto::Gui::SignerResolvePage::Validator
Definition: signerresolvepage.h:111
Kleo::Crypto::Gui::SignEncryptFilesWizard
Definition: signencryptfileswizard.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal