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

tdeabc

  • tdeabc
key.cpp
1/*
2 This file is part of libtdeabc.
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 <tdeapplication.h>
22#include <tdelocale.h>
23
24#include "key.h"
25
26using namespace TDEABC;
27
28Key::Key( const TQString &text, int type )
29 : mTextData( text ), mIsBinary( false ), mType( type )
30{
31 mId = TDEApplication::randomString(8);
32}
33
34Key::~Key()
35{
36}
37
38bool 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
51bool Key::operator!=( const Key &k ) const
52{
53 return !( k == *this );
54}
55
56void Key::setId( const TQString &id )
57{
58 mId = id;
59}
60
61TQString Key::id() const
62{
63 return mId;
64}
65
66void Key::setBinaryData( const TQByteArray &binary )
67{
68 mBinaryData = binary;
69 mIsBinary = true;
70}
71
72TQByteArray Key::binaryData() const
73{
74 return mBinaryData;
75}
76
77void Key::setTextData( const TQString &text )
78{
79 mTextData = text;
80 mIsBinary = false;
81}
82
83TQString Key::textData() const
84{
85 return mTextData;
86}
87
88bool Key::isBinary() const
89{
90 return mIsBinary;
91}
92
93void Key::setType( int type )
94{
95 mType = type;
96}
97
98void Key::setCustomTypeString( const TQString &custom )
99{
100 mCustomTypeString = custom;
101}
102
103int Key::type() const
104{
105 return mType;
106}
107
108TQString Key::customTypeString() const
109{
110 return mCustomTypeString;
111}
112
113Key::TypeList Key::typeList()
114{
115 TypeList list;
116 list << X509;
117 list << PGP;
118 list << Custom;
119
120 return list;
121}
122
123TQString 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
141TQDataStream &TDEABC::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
147TQDataStream &TDEABC::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}
TDEABC::Key
A class to store an encryption key.
Definition: key.h:34
TDEABC::Key::setId
void setId(const TQString &id)
Sets the unique identifier.
Definition: key.cpp:56
TDEABC::Key::typeList
static TypeList typeList()
Returns a list of all available key types.
Definition: key.cpp:113
TDEABC::Key::setTextData
void setTextData(const TQString &text)
Sets text data.
Definition: key.cpp:77
TDEABC::Key::isBinary
bool isBinary() const
Returns whether the key contains binary or text data.
Definition: key.cpp:88
TDEABC::Key::setBinaryData
void setBinaryData(const TQByteArray &binary)
Sets binary data.
Definition: key.cpp:66
TDEABC::Key::typeLabel
static TQString typeLabel(int type)
Returns a translated label for a given key type.
Definition: key.cpp:123
TDEABC::Key::customTypeString
TQString customTypeString() const
Returns the custom type string.
Definition: key.cpp:108
TDEABC::Key::textData
TQString textData() const
Returns the text data.
Definition: key.cpp:83
TDEABC::Key::~Key
~Key()
Destructor.
Definition: key.cpp:34
TDEABC::Key::binaryData
TQByteArray binaryData() const
Returns the binary data.
Definition: key.cpp:72
TDEABC::Key::setType
void setType(int type)
Sets the type, see Type.
Definition: key.cpp:93
TDEABC::Key::setCustomTypeString
void setCustomTypeString(const TQString &custom)
Sets custom type string.
Definition: key.cpp:98
TDEABC::Key::id
TQString id() const
Returns the unique identifier.
Definition: key.cpp:61
TDEABC::Key::type
int type() const
Returns the type, see Type.
Definition: key.cpp:103
TDEApplication::randomString
static TQString randomString(int length)
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
tdelocale.h

tdeabc

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

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.9.4
This website is maintained by Timothy Pearson.