33 #include <config-kleopatra.h>
39 #include <kleo/exception.h>
44 using namespace Kleo::Crypto;
45 using namespace boost;
47 class SignEncryptFilesCommand::Private :
public QObject {
50 friend class ::Kleo::SignEncryptFilesCommand;
61 void checkForErrors()
const;
65 void slotError(
int,
const QString & );
79 void SignEncryptFilesCommand::Private::checkForErrors()
const {
82 throw Exception( makeError( GPG_ERR_ASS_NO_INPUT ),
83 i18n(
"At least one FILE must be present") );
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") ) );
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") ) );
114 int SignEncryptFilesCommand::doStart() {
120 d->controller->setProtocol( checkProtocol( FileManager ) );
122 unsigned int op = operation();
123 if ( hasOption(
"archive" ) )
124 op |= SignEncryptFilesController::ArchiveForced;
126 op |= SignEncryptFilesController::ArchiveAllowed;
127 d->controller->setOperationMode( op );
128 d->controller->setFiles( fileNames() );
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 );
133 d->controller->start();
138 void SignEncryptFilesCommand::Private::slotDone() {
142 void SignEncryptFilesCommand::Private::slotError(
int err,
const QString & details ) {
143 q->done( err, details );
146 void SignEncryptFilesCommand::doCanceled() {
148 d->controller->cancel();
151 #include "signencryptfilescommand.moc"
SignEncryptFilesCommand()
virtual ~SignEncryptFilesCommand()