• 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
checksumverifyfilescommand.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  commands/checksumverifyfilescommand.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 "checksumverifyfilescommand.h"
36 
37 #include "command_p.h"
38 
39 #include <crypto/verifychecksumscontroller.h>
40 
41 #include <utils/filedialog.h>
42 
43 #include <kleo/stl_util.h>
44 
45 #include <KLocale>
46 #include <KMessageBox>
47 #include <kdebug.h>
48 
49 #include <QStringList>
50 
51 #include <exception>
52 
53 using namespace Kleo;
54 using namespace Kleo::Commands;
55 using namespace Kleo::Crypto;
56 using namespace boost;
57 
58 class ChecksumVerifyFilesCommand::Private : public Command::Private {
59  friend class ::Kleo::Commands::ChecksumVerifyFilesCommand;
60  ChecksumVerifyFilesCommand * q_func() const { return static_cast<ChecksumVerifyFilesCommand*>( q ); }
61 public:
62  explicit Private( ChecksumVerifyFilesCommand * qq, KeyListController * c );
63  ~Private();
64 
65  QStringList selectFiles() const;
66 
67  void init();
68 
69 private:
70  void slotControllerDone() {
71  finished();
72  }
73  void slotControllerError( int, const QString & ) {
74  finished();
75  }
76 
77 private:
78  QStringList files;
79  shared_ptr<const ExecutionContext> shared_qq;
80  VerifyChecksumsController controller;
81 };
82 
83 
84 ChecksumVerifyFilesCommand::Private * ChecksumVerifyFilesCommand::d_func() { return static_cast<Private*>( d.get() ); }
85 const ChecksumVerifyFilesCommand::Private * ChecksumVerifyFilesCommand::d_func() const { return static_cast<const Private*>( d.get() ); }
86 
87 #define d d_func()
88 #define q q_func()
89 
90 ChecksumVerifyFilesCommand::Private::Private( ChecksumVerifyFilesCommand * qq, KeyListController * c )
91  : Command::Private( qq, c ),
92  files(),
93  shared_qq( qq, kdtools::nodelete() ),
94  controller()
95 {
96 
97 }
98 
99 ChecksumVerifyFilesCommand::Private::~Private() { kDebug(); }
100 
101 ChecksumVerifyFilesCommand::ChecksumVerifyFilesCommand( KeyListController * c )
102  : Command( new Private( this, c ) )
103 {
104  d->init();
105 }
106 
107 ChecksumVerifyFilesCommand::ChecksumVerifyFilesCommand( QAbstractItemView * v, KeyListController * c )
108  : Command( v, new Private( this, c ) )
109 {
110  d->init();
111 }
112 
113 ChecksumVerifyFilesCommand::ChecksumVerifyFilesCommand( const QStringList & files, KeyListController * c )
114  : Command( new Private( this, c ) )
115 {
116  d->init();
117  d->files = files;
118 }
119 
120 ChecksumVerifyFilesCommand::ChecksumVerifyFilesCommand( const QStringList & files, QAbstractItemView * v, KeyListController * c )
121  : Command( v, new Private( this, c ) )
122 {
123  d->init();
124  d->files = files;
125 }
126 
127 void ChecksumVerifyFilesCommand::Private::init() {
128  controller.setExecutionContext( shared_qq );
129  connect( &controller, SIGNAL(done()), q, SLOT(slotControllerDone()) );
130  connect( &controller, SIGNAL(error(int,QString)), q, SLOT(slotControllerError(int,QString)) );
131 }
132 
133 ChecksumVerifyFilesCommand::~ChecksumVerifyFilesCommand() { kDebug(); }
134 
135 void ChecksumVerifyFilesCommand::setFiles( const QStringList & files ) {
136  d->files = files;
137 }
138 
139 void ChecksumVerifyFilesCommand::doStart() {
140 
141  try {
142 
143  if ( d->files.empty() )
144  d->files = d->selectFiles();
145  if ( d->files.empty() ) {
146  d->finished();
147  return;
148  }
149 
150  d->controller.setFiles( d->files );
151  d->controller.start();
152 
153  } catch ( const std::exception & e ) {
154  d->information( i18n("An error occurred: %1",
155  QString::fromLocal8Bit( e.what() ) ),
156  i18n("Verify Checksum Files Error") );
157  d->finished();
158  }
159 }
160 
161 void ChecksumVerifyFilesCommand::doCancel() {
162  kDebug();
163  d->controller.cancel();
164 }
165 
166 QStringList ChecksumVerifyFilesCommand::Private::selectFiles() const {
167  return FileDialog::getOpenFileNames( parentWidgetOrView(), i18n( "Select One or More Checksum Files" ), QLatin1String("chk") );
168 }
169 
170 #undef d
171 #undef q
172 
173 #include "moc_checksumverifyfilescommand.cpp"
Kleo::Command::Private
Definition: commands/command_p.h:52
d
#define d
Definition: checksumverifyfilescommand.cpp:87
Kleo::KeyListController
Definition: keylistcontroller.h:55
verifychecksumscontroller.h
Kleo::Command::d
kdtools::pimpl_ptr< Private > d
Definition: commands/command.h:129
Kleo::Crypto::VerifyChecksumsController
Definition: verifychecksumscontroller.h:52
boost::shared_ptr
Definition: encryptemailcontroller.h:51
Kleo::Commands::ChecksumVerifyFilesCommand::setFiles
void setFiles(const QStringList &files)
Definition: checksumverifyfilescommand.cpp:135
q
#define q
Definition: checksumverifyfilescommand.cpp:88
Kleo::FileDialog::getOpenFileNames
QStringList getOpenFileNames(QWidget *parent=0, const QString &caption=QString(), const QString &dirID=QString(), const QString &filter=QString())
Definition: filedialog.cpp:115
checksumverifyfilescommand.h
command_p.h
Kleo::Commands::ChecksumVerifyFilesCommand::ChecksumVerifyFilesCommand
ChecksumVerifyFilesCommand(QAbstractItemView *view, KeyListController *parent)
Definition: checksumverifyfilescommand.cpp:107
Kleo::Commands::ChecksumVerifyFilesCommand
Definition: checksumverifyfilescommand.h:47
Kleo::Commands::ChecksumVerifyFilesCommand::~ChecksumVerifyFilesCommand
~ChecksumVerifyFilesCommand()
Definition: checksumverifyfilescommand.cpp:133
Kleo::Command
Definition: commands/command.h:58
filedialog.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:40 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