• 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
  • uiserver
uiserver/signencryptfilescommand.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  uiserver/signencryptfilescommand.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 "signencryptfilescommand.h"
36 
37 #include <crypto/signencryptfilescontroller.h>
38 
39 #include <kleo/exception.h>
40 
41 #include <KLocale>
42 
43 using namespace Kleo;
44 using namespace Kleo::Crypto;
45 using namespace boost;
46 
47 class SignEncryptFilesCommand::Private : public QObject {
48  Q_OBJECT
49 private:
50  friend class ::Kleo::SignEncryptFilesCommand;
51  SignEncryptFilesCommand * const q;
52 public:
53  explicit Private( SignEncryptFilesCommand * qq )
54  : q( qq ),
55  controller()
56  {
57 
58  }
59 
60 private:
61  void checkForErrors() const;
62 
63 private Q_SLOTS:
64  void slotDone();
65  void slotError( int, const QString & );
66 
67 private:
68  shared_ptr<SignEncryptFilesController> controller;
69 };
70 
71 SignEncryptFilesCommand::SignEncryptFilesCommand()
72  : AssuanCommandMixin<SignEncryptFilesCommand>(), d( new Private( this ) )
73 {
74 
75 }
76 
77 SignEncryptFilesCommand::~SignEncryptFilesCommand() {}
78 
79 void SignEncryptFilesCommand::Private::checkForErrors() const {
80 
81  if ( !q->numFiles() )
82  throw Exception( makeError( GPG_ERR_ASS_NO_INPUT ),
83  i18n("At least one FILE must be present") );
84 
85 
86  if ( !q->senders().empty() )
87  throw Exception( makeError( GPG_ERR_CONFLICT ),
88  i18n( "%1 is a filemanager mode command, "
89  "connection seems to be in email mode (%2 present)",
90  QString::fromLatin1( q->name() ), QLatin1String("SENDER") ) );
91  if ( !q->recipients().empty() )
92  throw Exception( makeError( GPG_ERR_CONFLICT ),
93  i18n( "%1 is a filemanager mode command, "
94  "connection seems to be in email mode (%2 present)",
95  QString::fromLatin1( q->name() ), QLatin1String("RECIPIENT") ) );
96 
97  if ( !q->inputs().empty() )
98  throw Exception( makeError( GPG_ERR_CONFLICT ),
99  i18n( "%1 is a filemanager mode command, "
100  "connection seems to be in email mode (%2 present)",
101  QString::fromLatin1( q->name() ), QLatin1String("INPUT") ) );
102  if ( !q->outputs().empty() )
103  throw Exception( makeError( GPG_ERR_CONFLICT ),
104  i18n( "%1 is a filemanager mode command, "
105  "connection seems to be in email mode (%2 present)",
106  QString::fromLatin1( q->name() ), QLatin1String("OUTPUT") ) );
107  if ( !q->messages().empty() )
108  throw Exception( makeError( GPG_ERR_CONFLICT ),
109  i18n( "%1 is a filemanager mode command, "
110  "connection seems to be in email mode (%2 present)",
111  QString::fromLatin1( q->name() ), QLatin1String("MESSAGE") ) );
112 }
113 
114 int SignEncryptFilesCommand::doStart() {
115 
116  d->checkForErrors();
117 
118  d->controller.reset( new SignEncryptFilesController( shared_from_this() ) );
119 
120  d->controller->setProtocol( checkProtocol( FileManager ) );
121 
122  unsigned int op = operation();
123  if ( hasOption( "archive" ) )
124  op |= SignEncryptFilesController::ArchiveForced;
125  else
126  op |= SignEncryptFilesController::ArchiveAllowed;
127  d->controller->setOperationMode( op );
128  d->controller->setFiles( fileNames() );
129 
130  QObject::connect( d->controller.get(), SIGNAL(done()), d.get(), SLOT(slotDone()), Qt::QueuedConnection );
131  QObject::connect( d->controller.get(), SIGNAL(error(int,QString)), d.get(), SLOT(slotError(int,QString)), Qt::QueuedConnection );
132 
133  d->controller->start();
134 
135  return 0;
136 }
137 
138 void SignEncryptFilesCommand::Private::slotDone() {
139  q->done();
140 }
141 
142 void SignEncryptFilesCommand::Private::slotError( int err, const QString & details ) {
143  q->done( err, details );
144 }
145 
146 void SignEncryptFilesCommand::doCanceled() {
147  if ( d->controller )
148  d->controller->cancel();
149 }
150 
151 #include "signencryptfilescommand.moc"
152 
Kleo::SignEncryptFilesCommand::SignEncryptFilesCommand
SignEncryptFilesCommand()
Definition: uiserver/signencryptfilescommand.cpp:71
signencryptfilescommand.h
Kleo::AssuanCommandMixin
Definition: assuancommand.h:367
boost::shared_ptr< SignEncryptFilesController >
d
#define d
Definition: adduseridcommand.cpp:90
signencryptfilescontroller.h
kdtools::pimpl_ptr::get
T * get()
Definition: pimpl_ptr.h:39
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::SignEncryptFilesCommand
Definition: uiserver/signencryptfilescommand.h:42
Kleo::Crypto::SignEncryptFilesController
Definition: signencryptfilescontroller.h:50
Kleo::SignEncryptFilesCommand::~SignEncryptFilesCommand
virtual ~SignEncryptFilesCommand()
Definition: uiserver/signencryptfilescommand.cpp:77
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