File indexing completed on 2024-06-16 03:53:04

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2001-2003 George Staikos <staikos@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "kwalletentry.h"
0009 
0010 using namespace KWallet;
0011 #include <QDataStream>
0012 #include <QIODevice>
0013 
0014 Entry::Entry()
0015 {
0016 }
0017 
0018 Entry::~Entry()
0019 {
0020     _value.fill(0);
0021 }
0022 
0023 const QString &Entry::key() const
0024 {
0025     return _key;
0026 }
0027 
0028 const QByteArray &Entry::value() const
0029 {
0030     return _value;
0031 }
0032 
0033 QString Entry::password() const
0034 {
0035     QString x;
0036     QDataStream qds(_value);
0037     qds >> x;
0038     return x;
0039 }
0040 
0041 void Entry::setValue(const QByteArray &val)
0042 {
0043     // do a direct copy from one into the other without
0044     // temporary variables
0045     _value.fill(0);
0046     _value = val;
0047 }
0048 
0049 void Entry::setValue(const QString &val)
0050 {
0051     _value.fill(0);
0052     QDataStream qds(&_value, QIODevice::WriteOnly);
0053     qds << val;
0054 }
0055 
0056 void Entry::setKey(const QString &key)
0057 {
0058     _key = key;
0059 }
0060 
0061 Wallet::EntryType Entry::type() const
0062 {
0063     return _type;
0064 }
0065 
0066 void Entry::setType(Wallet::EntryType type)
0067 {
0068     _type = type;
0069 }
0070 
0071 void Entry::copy(const Entry *x)
0072 {
0073     _type = x->_type;
0074     _key = x->_key;
0075     _value.fill(0);
0076     _value = x->_value;
0077 }
0078