• 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
signemailwizard.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  crypto/gui/signemailwizard.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2008 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 "signemailwizard.h"
36 
37 #include "signerresolvepage.h"
38 
39 #include <utils/formatting.h>
40 
41 #include <KLocale>
42 
43 #include <gpgme++/key.h>
44 
45 #include <cassert>
46 
47 using namespace Kleo;
48 using namespace Kleo::Crypto::Gui;
49 using namespace GpgME;
50 
51 namespace {
52 
53  class SignerResolveValidator : public SignerResolvePage::Validator {
54  public:
55  explicit SignerResolveValidator( SignerResolvePage* page );
56  bool isComplete() const;
57  QString explanation() const;
58  void update() const;
59  QString customWindowTitle() const { return QString(); }
60 
61  private:
62  SignerResolvePage* m_page;
63  mutable QString expl;
64  mutable bool complete;
65  };
66 }
67 
68 SignerResolveValidator::SignerResolveValidator( SignerResolvePage* page ) : SignerResolvePage::Validator(), m_page( page ), complete( true )
69 {
70  assert( m_page );
71 }
72 
73 void SignerResolveValidator::update() const {
74  const bool haveSelected = !m_page->selectedProtocols().empty();
75  const std::vector<Protocol> missing = m_page->selectedProtocolsWithoutSigningCertificate();
76 
77  complete = haveSelected && missing.empty();
78  expl.clear();
79  if ( complete )
80  return;
81  if ( !haveSelected ) {
82  expl = i18n( "You need to select a signing certificate to proceed." );
83  return;
84  }
85 
86  assert( missing.size() <= 2 );
87  if ( missing.size() == 1 )
88  expl = i18n( "You need to select an %1 signing certificate to proceed.", Formatting::displayName( missing[0] ) );
89  else
90  expl = i18n( "You need to select %1 and %2 signing certificates to proceed.", Formatting::displayName( missing[0] ), Formatting::displayName( missing[1] ) );
91 }
92 
93 QString SignerResolveValidator::explanation() const {
94  update();
95  return expl;
96 }
97 
98 bool SignerResolveValidator::isComplete() const {
99  update();
100  return complete;
101 }
102 
103 class SignEMailWizard::Private {
104  friend class ::Kleo::Crypto::Gui::SignEMailWizard;
105  SignEMailWizard * const q;
106 public:
107  explicit Private( SignEMailWizard * qq );
108  ~Private();
109 
110  void operationSelected();
111 
112  bool m_quickMode;
113 };
114 
115 SignEMailWizard::Private::Private( SignEMailWizard * qq )
116  : q( qq ), m_quickMode( false )
117 {
118  q->setWindowTitle( i18n("Sign Mail Message") );
119 
120  std::vector<int> pageOrder;
121  q->setSignerResolvePageValidator( boost::shared_ptr<SignerResolveValidator>( new SignerResolveValidator( q->signerResolvePage() ) ) );
122  pageOrder.push_back( SignEncryptWizard::ResolveSignerPage );
123  pageOrder.push_back( SignEncryptWizard::ResultPage );
124  q->setPageOrder( pageOrder );
125  q->setCommitPage( SignEncryptWizard::ResolveSignerPage );
126  q->setEncryptionSelected( false );
127  q->setEncryptionUserMutable( false );
128  q->setSigningSelected( true );
129  q->setSigningUserMutable( false );
130  q->signerResolvePage()->setProtocolSelectionUserMutable( false );
131  q->setMultipleProtocolsAllowed( false );
132 }
133 
134 SignEMailWizard::Private::~Private() {}
135 
136 SignEMailWizard::SignEMailWizard( QWidget * parent, Qt::WindowFlags f )
137  : SignEncryptWizard( parent, f ), d( new Private( this ) )
138 {
139 }
140 
141 bool SignEMailWizard::quickMode() const
142 {
143  return d->m_quickMode;
144 }
145 
146 void SignEMailWizard::setQuickMode( bool quick )
147 {
148  if ( quick == d->m_quickMode )
149  return;
150  d->m_quickMode = quick;
151  signerResolvePage()->setAutoAdvance( quick );
152  setKeepResultPageOpenWhenDone( !quick );
153 }
154 
155 SignEMailWizard::~SignEMailWizard() {}
156 
157 #include "moc_signemailwizard.cpp"
Kleo::Crypto::Gui::SignEncryptWizard
Definition: signencryptwizard.h:70
Kleo::Crypto::Gui::SignEMailWizard::~SignEMailWizard
~SignEMailWizard()
Definition: signemailwizard.cpp:155
signemailwizard.h
Kleo::Formatting::displayName
QString displayName(GpgME::Protocol prot)
QWidget
formatting.h
Kleo::Crypto::Gui::WizardPage::setAutoAdvance
void setAutoAdvance(bool enabled)
Definition: wizardpage.cpp:89
boost::shared_ptr
Definition: encryptemailcontroller.h:51
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Crypto::Gui::SignEMailWizard
Definition: signemailwizard.h:44
signerresolvepage.h
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::SignerResolvePage::Validator
Definition: signerresolvepage.h:111
Kleo::Crypto::Gui::SignEMailWizard::quickMode
bool quickMode() const
Definition: signemailwizard.cpp:141
Kleo::Crypto::Gui::SignEncryptWizard::setKeepResultPageOpenWhenDone
void setKeepResultPageOpenWhenDone(bool keep)
Definition: signencryptwizard.cpp:306
Kleo::Crypto::Gui::SignEncryptWizard::signerResolvePage
Gui::SignerResolvePage * signerResolvePage()
Definition: signencryptwizard.cpp:276
Kleo::Crypto::Gui::SignEMailWizard::setQuickMode
void setQuickMode(bool quick)
Definition: signemailwizard.cpp:146
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