• 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
  • commands
setinitialpincommand.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  commands/setinitialpincommand.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2009 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 "setinitialpincommand.h"
36 #include "command_p.h"
37 
38 #include <dialogs/setinitialpindialog.h>
39 
40 #include <smartcard/readerstatus.h>
41 
42 #include <KLocale>
43 
44 #include <cassert>
45 
46 using namespace Kleo;
47 using namespace Kleo::Commands;
48 using namespace Kleo::Dialogs;
49 using namespace Kleo::SmartCard;
50 using namespace GpgME;
51 
52 class SetInitialPinCommand::Private : public Command::Private {
53  friend class ::Kleo::Commands::SetInitialPinCommand;
54  SetInitialPinCommand * q_func() const { return static_cast<SetInitialPinCommand*>( q ); }
55 public:
56  explicit Private( SetInitialPinCommand * qq );
57  ~Private();
58 
59 private:
60  void init() {
61 
62  }
63 
64  void ensureDialogCreated() const {
65  if ( dialog )
66  return;
67 
68  SetInitialPinDialog * dlg = new SetInitialPinDialog;
69  applyWindowID( dlg );
70  dlg->setAttribute( Qt::WA_DeleteOnClose );
71  dlg->setWindowTitle( i18nc("@title","Set Initial Pin") );
72 
73  const std::vector<ReaderStatus::PinState> pinStates = ReaderStatus::instance()->pinStates( 0 );
74 
75  dlg->setNksPinPresent( pinStates.size() >= 1 && pinStates[0] != ReaderStatus::NullPin );
76  dlg->setSigGPinPresent( pinStates.size() >= 3 && pinStates[2] != ReaderStatus::NullPin );
77 
78  connect( dlg, SIGNAL(nksPinRequested()), q_func(), SLOT(slotNksPinRequested()) );
79  connect( dlg, SIGNAL(sigGPinRequested()), q_func(), SLOT(slotSigGPinRequested()) );
80  connect( dlg, SIGNAL(rejected()), q_func(), SLOT(slotDialogRejected()) );
81  connect( dlg, SIGNAL(accepted()), q_func(), SLOT(slotDialogAccepted()) );
82 
83  dialog = dlg;
84  }
85 
86  void ensureDialogVisible() {
87  ensureDialogCreated();
88  if ( dialog->isVisible() )
89  dialog->raise();
90  else
91  dialog->show();
92  }
93 
94 private:
95  void slotNksPinRequested() {
96  ReaderStatus::mutableInstance()
97  ->startSimpleTransaction( "SCD PASSWD --nullpin PW1.CH",
98  dialog, "setNksPinSettingResult" );
99  }
100 
101  void slotSigGPinRequested() {
102  ReaderStatus::mutableInstance()
103  ->startSimpleTransaction( "SCD PASSWD --nullpin PW1.CH.SIG",
104  dialog, "setSigGPinSettingResult" );
105  }
106 
107  void slotDialogRejected() {
108  if ( dialog->isComplete() )
109  slotDialogAccepted();
110  else
111  canceled();
112  }
113  void slotDialogAccepted() {
114  ReaderStatus::mutableInstance()->updateStatus();
115  finished();
116  }
117 
118 private:
119  mutable QPointer<SetInitialPinDialog> dialog;
120 };
121 
122 SetInitialPinCommand::Private * SetInitialPinCommand::d_func() { return static_cast<Private*>( d.get() ); }
123 const SetInitialPinCommand::Private * SetInitialPinCommand::d_func() const { return static_cast<const Private*>( d.get() ); }
124 
125 #define q q_func()
126 #define d d_func()
127 
128 SetInitialPinCommand::Private::Private( SetInitialPinCommand * qq )
129  : Command::Private( qq, 0 ),
130  dialog()
131 {
132 
133 }
134 
135 SetInitialPinCommand::Private::~Private() {}
136 
137 SetInitialPinCommand::SetInitialPinCommand()
138  : Command( new Private( this ) )
139 {
140  d->init();
141 }
142 
143 SetInitialPinCommand::~SetInitialPinCommand() {}
144 
145 QDialog * SetInitialPinCommand::dialog() const {
146  d->ensureDialogCreated();
147  return d->dialog;
148 }
149 
150 void SetInitialPinCommand::doStart() {
151  d->ensureDialogVisible();
152 }
153 
154 
155 void SetInitialPinCommand::doCancel() {
156  if ( d->dialog )
157  d->dialog->close();
158 }
159 
160 #undef q_func
161 #undef d_func
162 
163 #include "moc_setinitialpincommand.cpp"
Kleo::Commands::SetInitialPinCommand::~SetInitialPinCommand
~SetInitialPinCommand()
Definition: setinitialpincommand.cpp:143
Kleo::Command::Private
Definition: commands/command_p.h:52
QDialog
readerstatus.h
Kleo::Dialogs::SetInitialPinDialog::setNksPinPresent
void setNksPinPresent(bool)
Definition: setinitialpindialog.cpp:176
Kleo::Command::d
kdtools::pimpl_ptr< Private > d
Definition: commands/command.h:129
d
#define d
Definition: setinitialpincommand.cpp:126
Kleo::Commands::SetInitialPinCommand
Definition: setinitialpincommand.h:41
q
#define q
Definition: setinitialpincommand.cpp:125
Kleo::Dialogs::SetInitialPinDialog::setSigGPinPresent
void setSigGPinPresent(bool)
Definition: setinitialpindialog.cpp:181
command_p.h
Kleo::Dialogs::SetInitialPinDialog
Definition: setinitialpindialog.h:47
Kleo::Commands::SetInitialPinCommand::dialog
QDialog * dialog() const
Definition: setinitialpincommand.cpp:145
setinitialpincommand.h
setinitialpindialog.h
Kleo::Command
Definition: commands/command.h:58
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