• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kleopatra

assuancommand.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset:4 -*-
00002     uiserver/assuancommand.h
00003 
00004     This file is part of Kleopatra, the KDE keymanager
00005     Copyright (c) 2007 Klarälvdalens Datakonsult AB
00006 
00007     Kleopatra is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     Kleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #ifndef __KLEOPATRA_UISERVER_ASSUANCOMMAND_H__
00034 #define __KLEOPATRA_UISERVER_ASSUANCOMMAND_H__
00035 
00036 #include <crypto/controller.h>
00037 
00038 #include <utils/pimpl_ptr.h>
00039 
00040 #include <gpgme++/global.h>
00041 #include <gpgme++/error.h>
00042 
00043 #include <kmime/kmime_header_parsing.h>
00044 
00045 #include <boost/shared_ptr.hpp>
00046 #include <boost/enable_shared_from_this.hpp>
00047 
00048 #include <string>
00049 #include <map>
00050 #include <vector>
00051 
00052 class QVariant;
00053 class QIODevice;
00054 class QObject;
00055 class QStringList;
00056 class QDialog;
00057 class QFile;
00058 
00059 struct assuan_context_s;
00060 
00061 namespace Kleo {
00062 
00063     class Input;
00064     class Output;
00065 
00066     class AssuanCommandFactory;
00067 
00208     class AssuanCommand : public Crypto::ExecutionContext, public boost::enable_shared_from_this<AssuanCommand> {
00209         // defined in assuanserverconnection.cpp!
00210     public:
00211         AssuanCommand();
00212         virtual ~AssuanCommand();
00213 
00214         int start();
00215         void canceled();
00216 
00217         virtual const char * name() const = 0;
00218 
00219         class Memento {
00220         public:
00221             virtual ~Memento() {}
00222         };
00223 
00224         template <typename T>
00225         class TypedMemento : public Memento {
00226             T m_t;
00227         public:
00228             explicit TypedMemento( const T & t ) : m_t( t ) {}
00229 
00230             const T & get() const { return m_t; }
00231             T & get() { return m_t; }
00232         };
00233 
00234         template <typename T>
00235         static boost::shared_ptr< TypedMemento<T> > make_typed_memento( const T & t ) {
00236             return boost::shared_ptr< TypedMemento<T> >( new TypedMemento<T>( t ) );
00237         }
00238 
00239         static int makeError( int code );
00240 
00241         // convenience methods:
00242         enum Mode { NoMode, EMail, FileManager };
00243         Mode checkMode() const;
00244 
00245         enum CheckProtocolOption {
00246             AllowProtocolMissing=0x01
00247         };
00248 
00249         GpgME::Protocol checkProtocol( Mode mode, int options=0 ) const;
00250 
00251         /* reimp */ void applyWindowID( QWidget* w ) const {
00252             doApplyWindowID( w );
00253         }
00254 
00255         QString heuristicBaseDirectory() const;
00256 
00257         void setNohup( bool on );
00258         bool isNohup() const;
00259         bool isDone() const;
00260 
00261         QString sessionTitle() const;
00262 
00263         bool informativeRecipients() const;
00264         bool informativeSenders() const;
00265 
00266         const std::vector<KMime::Types::Mailbox> & recipients() const;
00267         const std::vector<KMime::Types::Mailbox> & senders() const;
00268 
00269         bool hasMemento( const QByteArray & tag ) const;
00270         boost::shared_ptr<Memento> memento( const QByteArray & tag ) const;
00271         template <typename T>
00272         boost::shared_ptr<T> mementoAs( const QByteArray & tag ) const {
00273             return boost::dynamic_pointer_cast<T>( this->memento( tag ) );
00274         }
00275         const std::map< QByteArray, boost::shared_ptr<Memento> > & mementos() const;
00276         QByteArray registerMemento( const boost::shared_ptr<Memento> & mem );
00277         QByteArray registerMemento( const QByteArray & tag, const boost::shared_ptr<Memento> & mem );
00278         void removeMemento( const QByteArray & tag );
00279         template <typename T>
00280         T mementoContent( const QByteArray & tag ) const {
00281             if ( boost::shared_ptr< TypedMemento<T> > m = mementoAs< TypedMemento<T> >( tag ) )
00282                 return m->get();
00283             else
00284                 return T();
00285         }
00286 
00287         bool hasOption( const char * opt ) const;
00288         QVariant option( const char * opt ) const;
00289         const std::map<std::string,QVariant> & options() const;
00290 
00291         const std::vector< boost::shared_ptr<Input> > & inputs() const;
00292         const std::vector< boost::shared_ptr<Input> > & messages() const;
00293         const std::vector< boost::shared_ptr<Output> > & outputs() const;
00294 
00295         QStringList fileNames() const;
00296         std::vector< boost::shared_ptr<QFile> > files() const;
00297         unsigned int numFiles() const;
00298 
00299         void sendStatus( const char * keyword, const QString & text );
00300         void sendStatusEncoded( const char * keyword, const std::string & text );
00301         void sendData( const QByteArray & data, bool moreToCome=false );
00302 
00303         int inquire( const char * keyword, QObject * receiver, const char * slot, unsigned int maxSize=0 );
00304 
00305         void done( const GpgME::Error& err = GpgME::Error() );
00306         void done( const GpgME::Error& err, const QString & details );
00307         void done( int err ) { done( GpgME::Error(err) ); }
00308         void done( int err, const QString & details ) { done( GpgME::Error(err), details ); }
00309 
00310     private:
00311         virtual void doCanceled() = 0;
00312         virtual int doStart() = 0;
00313 
00314     private:
00315         void doApplyWindowID( QWidget * w ) const;
00316 
00317     private:
00318         friend class ::Kleo::AssuanCommandFactory;
00319         class Private;
00320         kdtools::pimpl_ptr<Private> d;
00321     };
00322 
00323     class AssuanCommandFactory {
00324     public:
00325         virtual ~AssuanCommandFactory() {}
00326 
00327         virtual boost::shared_ptr<AssuanCommand> create() const = 0;
00328         virtual const char * name() const = 0;
00329 
00330         typedef int(*_Handler)( assuan_context_s*, char *);
00331         virtual _Handler _handler() const = 0;
00332     protected:
00333         static int _handle( assuan_context_s*, char *, const char * );
00334     };
00335 
00336     template <typename Command>
00337     class GenericAssuanCommandFactory : public AssuanCommandFactory {
00338         /* reimp */ AssuanCommandFactory::_Handler _handler() const { return &GenericAssuanCommandFactory::_handle; }
00339         static int _handle( assuan_context_s* _ctx, char * _line ) {
00340             return AssuanCommandFactory::_handle( _ctx, _line, Command::staticName() );
00341         }
00342         /* reimp */ boost::shared_ptr<AssuanCommand> create() const { return make(); }
00343         /* reimp */ const char * name() const { return Command::staticName(); }
00344     public:
00345         static boost::shared_ptr<Command> make() { return boost::shared_ptr<Command>( new Command ); }
00346     };
00347 
00348     template <typename Derived, typename Base=AssuanCommand>
00349     class AssuanCommandMixin : public Base {
00350     protected:
00351         /* reimp */ const char * name() const { return Derived::staticName(); }
00352     };
00353 
00354 }
00355 
00356 #endif /* __KLEOPATRA_UISERVER_ASSUANCOMMAND_H__ */

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal