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

kleopatra

  • sources
  • kde-4.14
  • kdepim
  • kleopatra
  • crypto
  • gui
signencryptwizard.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  crypto/gui/signencryptwizard.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 "signencryptwizard.h"
36 
37 #include "objectspage.h"
38 #include "resolverecipientspage.h"
39 #include "signerresolvepage.h"
40 #include "resultpage.h"
41 
42 #include <crypto/task.h>
43 #include <crypto/taskcollection.h>
44 #include <crypto/certificateresolver.h>
45 
46 #include <utils/kleo_assert.h>
47 
48 #include <kleo/stl_util.h>
49 
50 #include <gpgme++/key.h>
51 
52 #include <KConfig>
53 #include <KGlobal>
54 
55 #include <QFileInfo>
56 #include <QTimer>
57 
58 #ifndef Q_MOC_RUN
59 #include <boost/bind.hpp>
60 #endif
61 
62 using namespace Kleo;
63 using namespace Kleo::Crypto;
64 using namespace Kleo::Crypto::Gui;
65 using namespace boost;
66 using namespace GpgME;
67 using namespace KMime::Types;
68 
69 class SignEncryptWizard::Private {
70  friend class ::Kleo::Crypto::Gui::SignEncryptWizard;
71  SignEncryptWizard * q;
72 public:
73  explicit Private( SignEncryptWizard * qq );
74  ~Private();
75 
76  void setCommitPage( Page page );
77 
78  Gui::ResolveRecipientsPage * recipientResolvePage; // clashes with enum of same name
79  SignerResolvePage * signerResolvePage;
80  Gui::ObjectsPage * objectsPage; // clashes with enum of same name
81  Gui::ResultPage * resultPage; // clashes with enum of same name
82 };
83 
84 
85 SignEncryptWizard::Private::Private( SignEncryptWizard * qq )
86  : q( qq ),
87  recipientResolvePage( new Gui::ResolveRecipientsPage ),
88  signerResolvePage( new SignerResolvePage ),
89  objectsPage( new Gui::ObjectsPage ),
90  resultPage( new Gui::ResultPage )
91 {
92  connect( resultPage, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)) );
93  q->setPage( SignEncryptWizard::ResolveSignerPage, signerResolvePage );
94  q->setPage( SignEncryptWizard::ObjectsPage, objectsPage );
95  q->setPage( SignEncryptWizard::ResolveRecipientsPage, recipientResolvePage );
96  q->setPage( SignEncryptWizard::ResultPage, resultPage );
97  //TODO: move the RecipientPreferences creation out of here, don't create a new instance for each wizard
98  recipientResolvePage->setRecipientPreferences( shared_ptr<RecipientPreferences>( new KConfigBasedRecipientPreferences( KGlobal::config() ) ) );
99  signerResolvePage->setSigningPreferences( shared_ptr<SigningPreferences>( new KConfigBasedSigningPreferences( KGlobal::config() ) ) );
100  q->resize( QSize( 640, 480 ).expandedTo( q->sizeHint() ) );
101 }
102 
103 void SignEncryptWizard::onNext( int currentId )
104 {
105  if ( currentId == ResolveRecipientsPage )
106  QTimer::singleShot( 0, this, SIGNAL(recipientsResolved()) );
107  if ( currentId == ResolveSignerPage ) {
108  //FIXME: Sign&Encrypt is only supported by OpenPGP. Remove this when we support this for CMS, too
109  if ( encryptionSelected() && signingSelected() )
110  setPresetProtocol( OpenPGP );
111  QTimer::singleShot( 0, this, SIGNAL(signersResolved()) );
112  }
113  if ( currentId == ObjectsPage )
114  QTimer::singleShot( 0, this, SIGNAL(objectsResolved()) );
115 }
116 
117 SignEncryptWizard::Private::~Private() {}
118 
119 SignEncryptWizard::SignEncryptWizard( QWidget * p, Qt::WindowFlags f )
120  : Wizard( p, f ), d( new Private( this ) )
121 {
122 }
123 
124 
125 SignEncryptWizard::~SignEncryptWizard() {}
126 
127 void SignEncryptWizard::setCommitPage( Page page )
128 {
129  d->setCommitPage( page );
130 }
131 
132 void SignEncryptWizard::Private::setCommitPage( Page page )
133 {
134  q->page( ResolveSignerPage )->setCommitPage( false );
135  q->page( ResolveRecipientsPage )->setCommitPage( false );
136  q->page( ObjectsPage )->setCommitPage( false );
137  q->page( ResultPage )->setCommitPage( false );
138  q->page( page )->setCommitPage( true );
139 }
140 
141 void SignEncryptWizard::setPresetProtocol( Protocol proto ) {
142  d->signerResolvePage->setPresetProtocol( proto );
143  d->signerResolvePage->setProtocolSelectionUserMutable( proto == UnknownProtocol );
144  d->recipientResolvePage->setPresetProtocol( proto );
145 }
146 
147 GpgME::Protocol SignEncryptWizard::selectedProtocol() const
148 {
149  return d->recipientResolvePage->selectedProtocol();
150 }
151 
152 GpgME::Protocol SignEncryptWizard::presetProtocol() const
153 {
154  return d->recipientResolvePage->presetProtocol();
155 }
156 
157 void SignEncryptWizard::setEncryptionSelected( bool selected )
158 {
159  d->signerResolvePage->setEncryptionSelected( selected );
160 }
161 
162 void SignEncryptWizard::setSigningSelected( bool selected )
163 {
164  d->signerResolvePage->setSigningSelected( selected );
165 }
166 
167 bool SignEncryptWizard::isSigningUserMutable() const
168 {
169  return d->signerResolvePage->isSigningUserMutable();
170 }
171 
172 void SignEncryptWizard::setSigningUserMutable( bool isMutable )
173 {
174  d->signerResolvePage->setSigningUserMutable( isMutable );
175 }
176 
177 bool SignEncryptWizard::isEncryptionUserMutable() const
178 {
179  return d->signerResolvePage->isEncryptionUserMutable();
180 }
181 
182 
183 bool SignEncryptWizard::isMultipleProtocolsAllowed() const
184 {
185  return d->recipientResolvePage->multipleProtocolsAllowed();
186 }
187 
188 void SignEncryptWizard::setMultipleProtocolsAllowed( bool allowed )
189 {
190  d->signerResolvePage->setMultipleProtocolsAllowed( allowed );
191  d->recipientResolvePage->setMultipleProtocolsAllowed( allowed );
192 }
193 
194 void SignEncryptWizard::setEncryptionUserMutable( bool isMutable )
195 {
196  d->signerResolvePage->setEncryptionUserMutable( isMutable );
197 }
198 
199 void SignEncryptWizard::setFiles( const QStringList & files ) {
200  d->objectsPage->setFiles( files );
201 }
202 
203 QFileInfoList SignEncryptWizard::resolvedFiles() const {
204  const QStringList files = d->objectsPage->files();
205  QFileInfoList fileInfos;
206  Q_FOREACH( const QString& i, files )
207  fileInfos.push_back( QFileInfo( i ) );
208  return fileInfos;
209 }
210 
211 bool SignEncryptWizard::signingSelected() const {
212  return d->signerResolvePage->signingSelected();
213 }
214 
215 bool SignEncryptWizard::encryptionSelected() const {
216  return d->signerResolvePage->encryptionSelected();
217 }
218 
219 void SignEncryptWizard::setRecipients( const std::vector<Mailbox> & recipients, const std::vector<Mailbox> & encryptToSelfRecipients ) {
220  d->recipientResolvePage->setRecipients( recipients, encryptToSelfRecipients );
221 }
222 
223 void SignEncryptWizard::setSignersAndCandidates( const std::vector<Mailbox> & signers, const std::vector< std::vector<Key> > & keys ) {
224  d->signerResolvePage->setSignersAndCandidates( signers, keys );
225 }
226 
227 
228 void SignEncryptWizard::setTaskCollection( const shared_ptr<TaskCollection> & coll )
229 {
230  kleo_assert( coll );
231  d->resultPage->setTaskCollection( coll );
232 }
233 
234 std::vector<Key> SignEncryptWizard::resolvedCertificates() const {
235  return d->recipientResolvePage->resolvedCertificates();
236 }
237 
238 std::vector<Key> SignEncryptWizard::resolvedSigners() const {
239  return d->signerResolvePage->resolvedSigners();
240 }
241 
242 bool SignEncryptWizard::isAsciiArmorEnabled() const
243 {
244  return d->signerResolvePage->isAsciiArmorEnabled();
245 }
246 
247 void SignEncryptWizard::setAsciiArmorEnabled( bool enabled )
248 {
249  d->signerResolvePage->setAsciiArmorEnabled( enabled );
250 }
251 
252 bool SignEncryptWizard::removeUnencryptedFile() const
253 {
254  return d->signerResolvePage->removeUnencryptedFile();
255 }
256 
257 void SignEncryptWizard::setRemoveUnencryptedFile( bool remove )
258 {
259  d->signerResolvePage->setRemoveUnencryptedFile( remove );
260 }
261 
262 bool SignEncryptWizard::recipientsUserMutable() const
263 {
264  return d->recipientResolvePage->recipientsUserMutable();
265 }
266 
267 void SignEncryptWizard::setRecipientsUserMutable( bool isMutable )
268 {
269  d->recipientResolvePage->setRecipientsUserMutable( isMutable );
270 }
271 
272 void SignEncryptWizard::setSignerResolvePageValidator( const boost::shared_ptr<SignerResolvePage::Validator>& validator )
273 {
274  d->signerResolvePage->setValidator( validator );
275 }
276 
277 Gui::SignerResolvePage* SignEncryptWizard::signerResolvePage()
278 {
279  return d->signerResolvePage;
280 }
281 
282 const Gui::SignerResolvePage* SignEncryptWizard::signerResolvePage() const
283 {
284  return d->signerResolvePage;
285 }
286 
287 Gui::ResolveRecipientsPage* SignEncryptWizard::resolveRecipientsPage()
288 {
289  return d->recipientResolvePage;
290 }
291 
292 Gui::ObjectsPage* SignEncryptWizard::objectsPage()
293 {
294  return d->objectsPage;
295 }
296 
297 Gui::ResultPage* SignEncryptWizard::resultPage()
298 {
299  return d->resultPage;
300 }
301 
302 bool SignEncryptWizard::keepResultPageOpenWhenDone() const
303 {
304  return d->resultPage->keepOpenWhenDone();
305 }
306 
307 void SignEncryptWizard::setKeepResultPageOpenWhenDone( bool keep )
308 {
309  d->resultPage->setKeepOpenWhenDone( keep );
310 }
311 
Kleo::Crypto::Gui::SignEncryptWizard
Definition: signencryptwizard.h:72
Kleo::Crypto::Gui::SignEncryptWizard::setMultipleProtocolsAllowed
void setMultipleProtocolsAllowed(bool allowed)
Definition: signencryptwizard.cpp:188
objectspage.h
Kleo::Crypto::Gui::SignEncryptWizard::signersResolved
void signersResolved()
Kleo::Crypto::Gui::SignEncryptWizard::isSigningUserMutable
bool isSigningUserMutable() const
Definition: signencryptwizard.cpp:167
Kleo::Crypto::KConfigBasedSigningPreferences
Definition: certificateresolver.h:81
QWidget
Kleo::Crypto::KConfigBasedRecipientPreferences
Definition: certificateresolver.h:69
Kleo::Crypto::Gui::SignEncryptWizard::keepResultPageOpenWhenDone
bool keepResultPageOpenWhenDone() const
Definition: signencryptwizard.cpp:302
Kleo::Crypto::Gui::SignEncryptWizard::resultPage
Gui::ResultPage * resultPage()
Definition: signencryptwizard.cpp:297
QList::push_back
void push_back(const T &value)
Kleo::Crypto::Gui::SignEncryptWizard::~SignEncryptWizard
virtual ~SignEncryptWizard()
Definition: signencryptwizard.cpp:125
Kleo::Crypto::Gui::SignEncryptWizard::setFiles
void setFiles(const QStringList &files)
Definition: signencryptwizard.cpp:199
Kleo::Crypto::Gui::SignEncryptWizard::setSignerResolvePageValidator
void setSignerResolvePageValidator(const boost::shared_ptr< SignerResolvePage::Validator > &validator)
Definition: signencryptwizard.cpp:272
Kleo::Crypto::Gui::SignEncryptWizard::setSignersAndCandidates
void setSignersAndCandidates(const std::vector< KMime::Types::Mailbox > &signers, const std::vector< std::vector< GpgME::Key > > &keys)
Definition: signencryptwizard.cpp:223
Kleo::Crypto::Gui::SignEncryptWizard::linkActivated
void linkActivated(const QString &link)
Kleo::Crypto::Gui::SignEncryptWizard::objectsPage
Gui::ObjectsPage * objectsPage()
Definition: signencryptwizard.cpp:292
Kleo::Crypto::Gui::SignEncryptWizard::onNext
void onNext(int currentId)
Definition: signencryptwizard.cpp:103
Kleo::Crypto::Gui::SignEncryptWizard::ObjectsPage
Definition: signencryptwizard.h:80
Kleo::Crypto::Gui::SignEncryptWizard::signingSelected
bool signingSelected() const
Definition: signencryptwizard.cpp:211
Kleo::Crypto::Gui::SignEncryptWizard::setRecipientsUserMutable
void setRecipientsUserMutable(bool isMutable)
Definition: signencryptwizard.cpp:267
Kleo::Crypto::Gui::SignEncryptWizard::ResultPage
Definition: signencryptwizard.h:82
Kleo::Crypto::Gui::SignEncryptWizard::Page
Page
Definition: signencryptwizard.h:78
Kleo::Crypto::Gui::SignEncryptWizard::setTaskCollection
void setTaskCollection(const boost::shared_ptr< TaskCollection > &tasks)
Definition: signencryptwizard.cpp:228
Kleo::Crypto::Gui::SignEncryptWizard::setEncryptionUserMutable
void setEncryptionUserMutable(bool isMutable)
Definition: signencryptwizard.cpp:194
Kleo::Crypto::Gui::SignEncryptWizard::resolvedCertificates
std::vector< GpgME::Key > resolvedCertificates() const
Definition: signencryptwizard.cpp:234
Kleo::Crypto::Gui::ResolveRecipientsPage
Definition: resolverecipientspage.h:65
Kleo::Crypto::Gui::SignEncryptWizard::recipientsUserMutable
bool recipientsUserMutable() const
if true, the user is allowed to remove/add recipients via the UI.
Definition: signencryptwizard.cpp:262
Kleo::Crypto::Gui::SignEncryptWizard::isAsciiArmorEnabled
bool isAsciiArmorEnabled() const
Definition: signencryptwizard.cpp:242
kleo_assert.h
boost::shared_ptr
Definition: encryptemailcontroller.h:51
Kleo::Crypto::Gui::SignEncryptWizard::encryptionSelected
bool encryptionSelected() const
Definition: signencryptwizard.cpp:215
Kleo::Crypto::Gui::SignEncryptWizard::resolvedSigners
std::vector< GpgME::Key > resolvedSigners() const
Definition: signencryptwizard.cpp:238
d
#define d
Definition: adduseridcommand.cpp:89
Kleo::Crypto::Gui::SignEncryptWizard::setEncryptionSelected
void setEncryptionSelected(bool selected)
Definition: signencryptwizard.cpp:157
Kleo::Class::OpenPGP
Definition: classify.h:49
Kleo::Crypto::Gui::SignEncryptWizard::removeUnencryptedFile
bool removeUnencryptedFile() const
Definition: signencryptwizard.cpp:252
signerresolvepage.h
QString
QList
Definition: commands/command.h:46
resultpage.h
Kleo::Crypto::Gui::SignEncryptWizard::setRecipients
void setRecipients(const std::vector< KMime::Types::Mailbox > &recipients, const std::vector< KMime::Types::Mailbox > &encryptoToSelfRecipients)
Definition: signencryptwizard.cpp:219
signencryptwizard.h
QStringList
Kleo::Crypto::Gui::SignEncryptWizard::setCommitPage
void setCommitPage(Page)
Definition: signencryptwizard.cpp:127
Kleo::Crypto::Gui::SignerResolvePage
Definition: signerresolvepage.h:59
Kleo::Crypto::Gui::SignEncryptWizard::ResolveRecipientsPage
Definition: signencryptwizard.h:81
QFileInfo
Kleo::Crypto::Gui::SignEncryptWizard::ResolveSignerPage
Definition: signencryptwizard.h:79
Kleo::Crypto::Gui::SignEncryptWizard::isEncryptionUserMutable
bool isEncryptionUserMutable() const
Definition: signencryptwizard.cpp:177
QSize
kleo_assert
#define kleo_assert(cond)
Definition: kleo_assert.h:86
Kleo::Crypto::Gui::SignEncryptWizard::resolveRecipientsPage
Gui::ResolveRecipientsPage * resolveRecipientsPage()
Definition: signencryptwizard.cpp:287
Kleo::Crypto::Gui::SignEncryptWizard::recipientsResolved
void recipientsResolved()
Kleo::Crypto::Gui::SignEncryptWizard::setAsciiArmorEnabled
void setAsciiArmorEnabled(bool enabled)
Definition: signencryptwizard.cpp:247
task.h
Kleo::Crypto::Gui::SignEncryptWizard::setPresetProtocol
void setPresetProtocol(GpgME::Protocol proto)
Definition: signencryptwizard.cpp:141
Kleo::Crypto::Gui::SignEncryptWizard::resolvedFiles
QFileInfoList resolvedFiles() const
SignOrEncryptFiles mode subinterface.
Definition: signencryptwizard.cpp:203
Kleo::Crypto::Gui::SignerResolvePage::setSigningPreferences
void setSigningPreferences(const boost::shared_ptr< SigningPreferences > &prefs)
Definition: signerresolvepage.cpp:650
Kleo::Crypto::Gui::SignEncryptWizard::setSigningUserMutable
void setSigningUserMutable(bool isMutable)
Definition: signencryptwizard.cpp:172
Kleo::Crypto::Gui::Wizard
Definition: wizard.h:49
q
#define q
Definition: adduseridcommand.cpp:90
Kleo::Crypto::Gui::ResultPage
Definition: resultpage.h:53
Kleo::Crypto::Gui::SignEncryptWizard::objectsResolved
void objectsResolved()
Page
Page
Definition: newsignencryptfileswizard.cpp:87
Kleo::Crypto::Gui::SignEncryptWizard::isMultipleProtocolsAllowed
bool isMultipleProtocolsAllowed() const
Definition: signencryptwizard.cpp:183
Kleo::Crypto::Gui::SignEncryptWizard::selectedProtocol
GpgME::Protocol selectedProtocol() const
Definition: signencryptwizard.cpp:147
Qt::WindowFlags
typedef WindowFlags
Kleo::Crypto::Gui::ObjectsPage
Definition: objectspage.h:46
certificateresolver.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Kleo::Crypto::Gui::SignEncryptWizard::setKeepResultPageOpenWhenDone
void setKeepResultPageOpenWhenDone(bool keep)
Definition: signencryptwizard.cpp:307
Kleo::Crypto::Gui::SignEncryptWizard::setSigningSelected
void setSigningSelected(bool selected)
Definition: signencryptwizard.cpp:162
Kleo::Crypto::Gui::SignEncryptWizard::presetProtocol
GpgME::Protocol presetProtocol() const
Definition: signencryptwizard.cpp:152
Kleo::Crypto::Gui::SignEncryptWizard::setRemoveUnencryptedFile
void setRemoveUnencryptedFile(bool remove)
Definition: signencryptwizard.cpp:257
taskcollection.h
resolverecipientspage.h
Kleo::Crypto::Gui::SignEncryptWizard::signerResolvePage
Gui::SignerResolvePage * signerResolvePage()
Definition: signencryptwizard.cpp:277
Kleo::Crypto::Gui::SignEncryptWizard::SignEncryptWizard
SignEncryptWizard(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: signencryptwizard.cpp:119
QTimer::singleShot
singleShot
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:11 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
  • pimprint

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