2010-08-07 09:10:44 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_ENTRY_H
|
|
|
|
#define KEEPASSX_ENTRY_H
|
|
|
|
|
2013-10-03 09:18:16 -04:00
|
|
|
#include <QColor>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QUrl>
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2012-07-16 03:54:04 -04:00
|
|
|
#include "core/AutoTypeAssociations.h"
|
2012-04-14 09:38:20 -04:00
|
|
|
#include "core/EntryAttachments.h"
|
|
|
|
#include "core/EntryAttributes.h"
|
2011-07-08 08:51:14 -04:00
|
|
|
#include "core/TimeInfo.h"
|
|
|
|
#include "core/Uuid.h"
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2010-08-14 06:24:35 -04:00
|
|
|
class Database;
|
2010-08-12 15:38:59 -04:00
|
|
|
class Group;
|
|
|
|
|
2012-04-23 15:06:04 -04:00
|
|
|
struct EntryData
|
|
|
|
{
|
|
|
|
int iconNumber;
|
|
|
|
Uuid customIcon;
|
|
|
|
QColor foregroundColor;
|
|
|
|
QColor backgroundColor;
|
|
|
|
QString overrideUrl;
|
|
|
|
QString tags;
|
|
|
|
bool autoTypeEnabled;
|
|
|
|
int autoTypeObfuscation;
|
|
|
|
QString defaultAutoTypeSequence;
|
|
|
|
TimeInfo timeInfo;
|
|
|
|
};
|
|
|
|
|
2010-08-12 15:38:59 -04:00
|
|
|
class Entry : public QObject
|
2010-08-07 09:10:44 -04:00
|
|
|
{
|
2010-08-12 15:38:59 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
public:
|
|
|
|
Entry();
|
2010-08-18 10:22:48 -04:00
|
|
|
~Entry();
|
2010-08-12 15:38:59 -04:00
|
|
|
Uuid uuid() const;
|
2012-01-01 15:52:54 -05:00
|
|
|
QImage icon() const;
|
|
|
|
QPixmap iconPixmap() const;
|
2016-01-24 12:45:10 -05:00
|
|
|
QPixmap iconScaledPixmap() const;
|
2010-08-18 16:57:26 -04:00
|
|
|
int iconNumber() const;
|
|
|
|
Uuid iconUuid() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
QColor foregroundColor() const;
|
|
|
|
QColor backgroundColor() const;
|
|
|
|
QString overrideUrl() const;
|
2010-09-25 06:41:00 -04:00
|
|
|
QString tags() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
TimeInfo timeInfo() const;
|
|
|
|
bool autoTypeEnabled() const;
|
|
|
|
int autoTypeObfuscation() const;
|
|
|
|
QString defaultAutoTypeSequence() const;
|
2016-11-11 16:26:07 -05:00
|
|
|
QString effectiveAutoTypeSequence() const;
|
2012-07-16 03:54:04 -04:00
|
|
|
AutoTypeAssociations* autoTypeAssociations();
|
|
|
|
const AutoTypeAssociations* autoTypeAssociations() const;
|
2010-08-18 09:08:17 -04:00
|
|
|
QString title() const;
|
|
|
|
QString url() const;
|
|
|
|
QString username() const;
|
|
|
|
QString password() const;
|
|
|
|
QString notes() const;
|
2012-05-15 13:58:10 -04:00
|
|
|
bool isExpired() const;
|
2017-03-05 17:47:08 -05:00
|
|
|
bool hasReferences() const;
|
2012-04-14 09:38:20 -04:00
|
|
|
EntryAttributes* attributes();
|
|
|
|
const EntryAttributes* attributes() const;
|
|
|
|
EntryAttachments* attachments();
|
|
|
|
const EntryAttachments* attachments() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2012-05-15 10:47:46 -04:00
|
|
|
static const int DefaultIconNumber;
|
|
|
|
|
2010-08-12 15:38:59 -04:00
|
|
|
void setUuid(const Uuid& uuid);
|
|
|
|
void setIcon(int iconNumber);
|
|
|
|
void setIcon(const Uuid& uuid);
|
|
|
|
void setForegroundColor(const QColor& color);
|
|
|
|
void setBackgroundColor(const QColor& color);
|
|
|
|
void setOverrideUrl(const QString& url);
|
2010-09-25 06:41:00 -04:00
|
|
|
void setTags(const QString& tags);
|
2010-08-12 15:38:59 -04:00
|
|
|
void setTimeInfo(const TimeInfo& timeInfo);
|
|
|
|
void setAutoTypeEnabled(bool enable);
|
|
|
|
void setAutoTypeObfuscation(int obfuscation);
|
|
|
|
void setDefaultAutoTypeSequence(const QString& sequence);
|
2010-08-18 09:08:17 -04:00
|
|
|
void setTitle(const QString& title);
|
|
|
|
void setUrl(const QString& url);
|
|
|
|
void setUsername(const QString& username);
|
|
|
|
void setPassword(const QString& password);
|
|
|
|
void setNotes(const QString& notes);
|
2012-04-16 20:27:38 -04:00
|
|
|
void setExpires(const bool& value);
|
|
|
|
void setExpiryTime(const QDateTime& dateTime);
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2010-08-25 07:52:59 -04:00
|
|
|
QList<Entry*> historyItems();
|
|
|
|
const QList<Entry*>& historyItems() const;
|
|
|
|
void addHistoryItem(Entry* entry);
|
2013-03-26 18:53:34 -04:00
|
|
|
void removeHistoryItems(const QList<Entry*>& historyEntries);
|
2012-05-04 17:45:34 -04:00
|
|
|
void truncateHistory();
|
2013-11-22 07:27:49 -05:00
|
|
|
|
|
|
|
enum CloneFlag {
|
|
|
|
CloneNoFlags = 0,
|
2017-02-27 20:25:56 -05:00
|
|
|
CloneNewUuid = 1, // generate a random uuid for the clone
|
|
|
|
CloneResetTimeInfo = 2, // set all TimeInfo attributes to the current time
|
|
|
|
CloneIncludeHistory = 4, // clone the history items
|
|
|
|
CloneRenameTitle = 8, // add "-Clone" after the original title
|
|
|
|
CloneUserAsRef = 16, // Add the user as a refrence to the origional entry
|
|
|
|
ClonePassAsRef = 32, // Add the password as a refrence to the origional entry
|
2013-11-22 07:27:49 -05:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(CloneFlags, CloneFlag)
|
|
|
|
|
2013-07-04 07:59:32 -04:00
|
|
|
/**
|
2013-11-22 07:27:49 -05:00
|
|
|
* Creates a duplicate of this entry except that the returned entry isn't
|
|
|
|
* part of any group.
|
2013-07-04 07:59:32 -04:00
|
|
|
* Note that you need to copy the custom icons manually when inserting the
|
|
|
|
* new entry into another database.
|
|
|
|
*/
|
2013-11-22 07:27:49 -05:00
|
|
|
Entry* clone(CloneFlags flags) const;
|
2013-04-14 08:21:42 -04:00
|
|
|
void copyDataFrom(const Entry* other);
|
2016-11-25 12:26:59 -05:00
|
|
|
QString resolveMultiplePlaceholders(const QString& str) const;
|
|
|
|
QString resolvePlaceholder(const QString& str) const;
|
2012-05-04 17:45:34 -04:00
|
|
|
|
2012-04-23 15:06:04 -04:00
|
|
|
/**
|
|
|
|
* Call before and after set*() methods to create a history item
|
|
|
|
* if the entry has been changed.
|
|
|
|
*/
|
|
|
|
void beginUpdate();
|
2016-07-31 17:49:38 -04:00
|
|
|
bool endUpdate();
|
2010-08-25 07:52:59 -04:00
|
|
|
|
2010-10-06 16:54:07 -04:00
|
|
|
Group* group();
|
2012-07-23 12:06:04 -04:00
|
|
|
const Group* group() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
void setGroup(Group* group);
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2012-04-11 13:51:54 -04:00
|
|
|
void setUpdateTimeinfo(bool value);
|
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
signals:
|
2011-07-08 07:57:02 -04:00
|
|
|
/**
|
|
|
|
* Emitted when a default attribute has been changed.
|
|
|
|
*/
|
2010-08-23 15:30:20 -04:00
|
|
|
void dataChanged(Entry* entry);
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2012-04-11 13:51:54 -04:00
|
|
|
void modified();
|
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
private slots:
|
2012-04-14 09:38:20 -04:00
|
|
|
void emitDataChanged();
|
2012-04-16 19:02:02 -04:00
|
|
|
void updateTimeinfo();
|
2012-04-23 15:06:04 -04:00
|
|
|
void updateModifiedSinceBegin();
|
2012-04-14 09:38:20 -04:00
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
private:
|
2012-04-18 07:57:57 -04:00
|
|
|
const Database* database() const;
|
2012-08-01 04:40:38 -04:00
|
|
|
template <class T> bool set(T& property, const T& value);
|
2012-04-18 07:57:57 -04:00
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
Uuid m_uuid;
|
2012-04-23 15:06:04 -04:00
|
|
|
EntryData m_data;
|
2012-07-16 03:54:04 -04:00
|
|
|
EntryAttributes* const m_attributes;
|
|
|
|
EntryAttachments* const m_attachments;
|
|
|
|
AutoTypeAssociations* const m_autoTypeAssociations;
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2010-08-25 07:52:59 -04:00
|
|
|
QList<Entry*> m_history;
|
2012-04-23 15:06:04 -04:00
|
|
|
Entry* m_tmpHistoryItem;
|
|
|
|
bool m_modifiedSinceBegin;
|
2011-07-09 15:54:01 -04:00
|
|
|
QPointer<Group> m_group;
|
2012-04-11 13:51:54 -04:00
|
|
|
bool m_updateTimeinfo;
|
2010-08-07 09:10:44 -04:00
|
|
|
};
|
|
|
|
|
2013-11-22 07:27:49 -05:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Entry::CloneFlags)
|
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
#endif // KEEPASSX_ENTRY_H
|