• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kabc
 

kabc

  • kabc
key.cpp
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 #include <kapplication.h>
22 #include <klocale.h>
23 
24 #include "key.h"
25 
26 using namespace KABC;
27 
28 Key::Key( const TQString &text, int type )
29  : mTextData( text ), mIsBinary( false ), mType( type )
30 {
31  mId = KApplication::randomString(8);
32 }
33 
34 Key::~Key()
35 {
36 }
37 
38 bool Key::operator==( const Key &k ) const
39 {
40  if ( mIsBinary != k.mIsBinary ) return false;
41  if ( mIsBinary )
42  if ( mBinaryData != k.mBinaryData ) return false;
43  else
44  if ( mTextData != k.mTextData ) return false;
45  if ( mType != k.mType ) return false;
46  if ( mCustomTypeString != k.mCustomTypeString ) return false;
47 
48  return true;
49 }
50 
51 bool Key::operator!=( const Key &k ) const
52 {
53  return !( k == *this );
54 }
55 
56 void Key::setId( const TQString &id )
57 {
58  mId = id;
59 }
60 
61 TQString Key::id() const
62 {
63  return mId;
64 }
65 
66 void Key::setBinaryData( const TQByteArray &binary )
67 {
68  mBinaryData = binary;
69  mIsBinary = true;
70 }
71 
72 TQByteArray Key::binaryData() const
73 {
74  return mBinaryData;
75 }
76 
77 void Key::setTextData( const TQString &text )
78 {
79  mTextData = text;
80  mIsBinary = false;
81 }
82 
83 TQString Key::textData() const
84 {
85  return mTextData;
86 }
87 
88 bool Key::isBinary() const
89 {
90  return mIsBinary;
91 }
92 
93 void Key::setType( int type )
94 {
95  mType = type;
96 }
97 
98 void Key::setCustomTypeString( const TQString &custom )
99 {
100  mCustomTypeString = custom;
101 }
102 
103 int Key::type() const
104 {
105  return mType;
106 }
107 
108 TQString Key::customTypeString() const
109 {
110  return mCustomTypeString;
111 }
112 
113 Key::TypeList Key::typeList()
114 {
115  TypeList list;
116  list << X509;
117  list << PGP;
118  list << Custom;
119 
120  return list;
121 }
122 
123 TQString Key::typeLabel( int type )
124 {
125  switch ( type ) {
126  case X509:
127  return i18n( "X509" );
128  break;
129  case PGP:
130  return i18n( "PGP" );
131  break;
132  case Custom:
133  return i18n( "Custom" );
134  break;
135  default:
136  return i18n( "Unknown type" );
137  break;
138  }
139 }
140 
141 TQDataStream &KABC::operator<<( TQDataStream &s, const Key &key )
142 {
143  return s << key.mId << key.mIsBinary << key.mTextData << key.mBinaryData <<
144  key.mCustomTypeString << key.mType;
145 }
146 
147 TQDataStream &KABC::operator>>( TQDataStream &s, Key &key )
148 {
149  s >> key.mId >> key.mIsBinary >> key.mTextData >> key.mBinaryData >>
150  key.mCustomTypeString >> key.mType;
151 
152  return s;
153 }

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kabc

Skip menu "kabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kabc by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |