home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / key.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.1 KB  |  151 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KABC_KEY_H
  22. #define KABC_KEY_H
  23.  
  24. #include <qvaluelist.h>
  25.  
  26. #include <kdelibs_export.h>
  27.  
  28. namespace KABC {
  29.  
  30. /**
  31.  * @short A class to store an encryption key.
  32.  */
  33. class KABC_EXPORT Key
  34. {
  35.   friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Key & );
  36.   friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Key & );
  37.  
  38. public:
  39.   typedef QValueList<Key> List;
  40.   typedef QValueList<int> TypeList;  
  41.  
  42.   /**
  43.    * Key types
  44.    *
  45.    * @li X509   - X509 key
  46.    * @li PGP    - Pretty Good Privacy key
  47.    * @li Custom - Custom or IANA conform key
  48.    */
  49.   enum Types {
  50.     X509,
  51.     PGP,
  52.     Custom
  53.   };
  54.  
  55.   /**
  56.    * Constructor.
  57.    *
  58.    * @param text  The text data.
  59.    * @param type  The key type, see Types.
  60.    */
  61.   Key( const QString &text = QString::null, int type = PGP );
  62.  
  63.   /**
  64.    * Destructor.
  65.    */
  66.   ~Key();
  67.     
  68.   bool operator==( const Key & ) const;
  69.   bool operator!=( const Key & ) const;
  70.  
  71.   /**
  72.    * Sets the unique identifier.
  73.    */
  74.   void setId( const QString &id );
  75.  
  76.   /**
  77.    * Returns the unique identifier.
  78.    */
  79.   QString id() const;
  80.  
  81.   /**
  82.    * Sets binary data.
  83.    */
  84.   void setBinaryData( const QByteArray &binary );
  85.  
  86.   /**
  87.    * Returns the binary data.
  88.    */
  89.   QByteArray binaryData() const;
  90.  
  91.   /**
  92.    * Sets text data.
  93.    */
  94.   void setTextData( const QString &text );
  95.  
  96.   /**
  97.    * Returns the text data.
  98.    */
  99.   QString textData() const;
  100.  
  101.   /**
  102.    * Returns whether the key contains binary or text data.
  103.    */
  104.   bool isBinary() const;
  105.  
  106.   /**
  107.    * Sets the type, see Type.
  108.    */
  109.   void setType( int type );
  110.  
  111.   /**
  112.    * Sets custom type string.
  113.    */
  114.   void setCustomTypeString( const QString &custom );
  115.  
  116.   /**
  117.    * Returns the type, see Type.
  118.    */
  119.   int type() const;
  120.  
  121.   /**
  122.    * Returns the custom type string.
  123.    */
  124.   QString customTypeString() const;
  125.  
  126.   /**
  127.    * Returns a list of all available key types.
  128.    */
  129.   static TypeList typeList();
  130.   
  131.   /**
  132.    * Returns a translated label for a given key type.
  133.    */
  134.   static QString typeLabel( int type );
  135.  
  136. private:
  137.   QByteArray mBinaryData;
  138.   QString mId;
  139.   QString mTextData;
  140.   QString mCustomTypeString;
  141.  
  142.   int mIsBinary;
  143.   int mType;
  144. };
  145.  
  146. KABC_EXPORT QDataStream &operator<<( QDataStream &, const Key & );
  147. KABC_EXPORT QDataStream &operator>>( QDataStream &, Key & );
  148.  
  149. }
  150. #endif
  151.