key.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef KABC_KEY_H 00022 #define KABC_KEY_H 00023 00024 #include <qvaluelist.h> 00025 00026 namespace KABC { 00027 00031 class Key 00032 { 00033 friend QDataStream &operator<<( QDataStream &, const Key & ); 00034 friend QDataStream &operator>>( QDataStream &, Key & ); 00035 00036 public: 00037 typedef QValueList<Key> List; 00038 typedef QValueList<int> TypeList; 00039 00047 enum Types { 00048 X509, 00049 PGP, 00050 Custom 00051 }; 00052 00059 Key( const QString &text = QString::null, int type = PGP ); 00060 00064 ~Key(); 00065 00066 bool operator==( const Key & ) const; 00067 bool operator!=( const Key & ) const; 00068 00072 void setId( const QString &id ); 00073 00077 QString id() const; 00078 00082 void setBinaryData( const QByteArray &binary ); 00083 00087 QByteArray binaryData() const; 00088 00092 void setTextData( const QString &text ); 00093 00097 QString textData() const; 00098 00102 bool isBinary() const; 00103 00107 void setType( int type ); 00108 00112 void setCustomTypeString( const QString &custom ); 00113 00117 int type() const; 00118 00122 QString customTypeString() const; 00123 00127 static TypeList typeList(); 00128 00132 static QString typeLabel( int type ); 00133 00134 private: 00135 QByteArray mBinaryData; 00136 QString mId; 00137 QString mTextData; 00138 QString mCustomTypeString; 00139 00140 int mIsBinary; 00141 int mType; 00142 }; 00143 00144 QDataStream &operator<<( QDataStream &, const Key & ); 00145 QDataStream &operator>>( QDataStream &, Key & ); 00146 00147 } 00148 #endif