Implemented backup feature

Disabled desktop integration plugins
Disabled "Features" tab in SettingsDlg
Removed useless files

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@231 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
sniperbeamer
2008-10-06 17:18:48 +00:00
parent a8fafee769
commit ef92de215c
23 changed files with 361 additions and 775 deletions

View File

@@ -157,7 +157,7 @@ public:
\return TRUE if the handle is valid and FALSE if the handle is invalid e.g. because the associated entry was deleted.*/
virtual bool isValid()const=0;
virtual CEntry data()const=0;
};
//! Custom Icon Interface
@@ -206,13 +206,13 @@ public:
//! \return a pointer to the handle of the parent group or NULL if the group has no parent.
virtual IGroupHandle* parent()=0;
//! \return a List of pointers to the handles of all childs of the group and an empty list if the group has no childs. The list is sorted and starts with the first child.
virtual QList<IGroupHandle*> childs()=0;
//! \return a List of pointers to the handles of all children of the group and an empty list if the group has no children. The list is sorted.
virtual QList<IGroupHandle*> children()=0;
//! \return the index of the group amongst the childs of its parent. The index of the first child is 0.
//! \return the index of the group amongst the children of its parent. The index of the first child is 0.
virtual int index()=0;
/*! Sets the index of a group amongst the childs of its parent.
/*! Sets the index of a group amongst the children of its parent.
This function can be used to sort the groups of the database in a specific order.
\param index The new index of the group. The indices of the other groups which are affected by this operation will be automatically adjusted.*/
virtual void setIndex(int index)=0;
@@ -291,6 +291,10 @@ public:
\return a list with the pointers to the handles of all entries of the database. The list ist sorted and contains only valid handles.*/
virtual QList<IGroupHandle*> sortedGroups()=0;
/*! \return handle of the backup group or NULL if it doesn't exist
\param create Create the backup group if it doesn't exist
*/
virtual IGroupHandle* backupGroup(bool create=false)=0;
/*! \return the last error message or an empty QString() object if no error occured.*/
virtual QString getError()=0;

View File

@@ -407,8 +407,8 @@ bool Kdb3Database::createGroupTree(QList<quint32>& Levels){
for(int i=0;i<Groups.size();i++){
if(Levels[i]==0){
Groups[i].Parent=&RootGroup;
Groups[i].Index=RootGroup.Childs.size();
RootGroup.Childs.append(&Groups[i]);
Groups[i].Index=RootGroup.Children.size();
RootGroup.Children.append(&Groups[i]);
continue;
}
int j;
@@ -421,8 +421,8 @@ bool Kdb3Database::createGroupTree(QList<quint32>& Levels){
if(j==0)return false; //No parent found
}
Groups[i].Parent=&Groups[j];
Groups[i].Index=Groups[j].Childs.size();
Groups[i].Parent->Childs.append(&Groups[i]);
Groups[i].Index=Groups[j].Children.size();
Groups[i].Parent->Children.append(&Groups[i]);
}
QList<int> EntryIndexCounter;
@@ -468,6 +468,9 @@ void Kdb3Database::restoreGroupTreeState(){
for(int i=0;i<Groups.size();i++)
Groups[i].IsExpanded=true;
break;
case KpxConfig::DoNothing:
break;
}
}
@@ -744,17 +747,17 @@ int Kdb3Database::numEntries(){
void Kdb3Database::deleteGroup(StdGroup* group){
while(group->Childs.size())
deleteGroup(group->Childs.front());
while(group->Children.size())
deleteGroup(group->Children.front());
QList<IEntryHandle*> GroupEntries;
GroupEntries=entries(group->Handle);
deleteEntries(GroupEntries);
Q_ASSERT(group==group->Parent->Childs[group->Index]);
group->Parent->Childs.removeAt(group->Index);
for(int i=group->Index;i<group->Parent->Childs.size();i++){
group->Parent->Childs[i]->Index--;
Q_ASSERT(group==group->Parent->Children[group->Index]);
group->Parent->Children.removeAt(group->Index);
for(int i=group->Index;i<group->Parent->Children.size();i++){
group->Parent->Children[i]->Index--;
}
group->Handle->invalidate();
@@ -791,7 +794,7 @@ void Kdb3Database::GroupHandle::setIndex(int index){
if(pDB->Groups[NewPos].ParentId==ParentId && pDB->Groups[NewPos].Index+1==index)
break;
}
//skip the childs of the found sibling
//skip the children of the found sibling
for(NewPos;NewPos<Groups.size();NewPos++){
if(Groups[NewPos]
pDB->Groups.move(Pos,NewPos);
@@ -978,13 +981,13 @@ void Kdb3Database::deleteEntries(QList<IEntryHandle*> entries){
if(&Entries[j]==((EntryHandle*)entries[i])->Entry)
break;
}
Group->Childs.removeAt(Entries[j].Index);
Group->Children.removeAt(Entries[j].Index);
Entries[j].Handle->invalidate();
Entries.removeAt(j);
}
for(int i=0;i<Group->Childs.size();i++){
Group->Childs[i]->Index=i;
for(int i=0;i<Group->Children.size();i++){
Group->Children[i]->Index=i;
}
};
@@ -1018,17 +1021,37 @@ IGroupHandle* Kdb3Database::addGroup(const CGroup* group,IGroupHandle* ParentHan
GroupHandles.back().Group=&Groups.back();
if(ParentHandle){
Groups.back().Parent=((GroupHandle*)ParentHandle)->Group;
Groups.back().Index=Groups.back().Parent->Childs.size();
Groups.back().Parent->Childs.append(&Groups.back());
Groups.back().Index=Groups.back().Parent->Children.size();
Groups.back().Parent->Children.append(&Groups.back());
}
else{
Groups.back().Parent=&RootGroup;
Groups.back().Index=RootGroup.Childs.size();
Groups.back().Parent->Childs.append(&Groups.back());
Groups.back().Index=RootGroup.Children.size();
Groups.back().Parent->Children.append(&Groups.back());
}
return &GroupHandles.back();
}
IGroupHandle* Kdb3Database::backupGroup(bool create){
IGroupHandle* group = NULL;
QList<IGroupHandle*> allGroups = groups();
for (int i=0; i<allGroups.size(); i++){
if (allGroups[i]->parent()==NULL && allGroups[i]->title()=="Backup"){
group = allGroups[i];
break;
}
}
if (group==NULL && create){
CGroup newGroup;
newGroup.Title = "Backup";
newGroup.Image = 4;
group = addGroup(&newGroup, NULL);
}
return group;
}
Kdb3Database::StdGroup::StdGroup(const CGroup& other){
Index=0;
Id=other.Id;
@@ -1104,6 +1127,10 @@ int Kdb3Database::EntryHandle::visualIndex()const{return Entry->Index;}
void Kdb3Database::EntryHandle::setVisualIndexDirectly(int i){Entry->Index=i;}
bool Kdb3Database::EntryHandle::isValid()const{return valid;}
CEntry Kdb3Database::EntryHandle::data()const{
return *this->Entry;
}
void Kdb3Database::EntryHandle::setVisualIndex(int index){
QList<IEntryHandle*>Entries=pDB->entries(Entry->Group->Handle);
Entries.move(visualIndex(),index);
@@ -1150,35 +1177,35 @@ int Kdb3Database::GroupHandle::level(){
}
QList<IGroupHandle*> Kdb3Database::GroupHandle::childs(){
QList<IGroupHandle*> childs;
for(int i=0;i<Group->Childs.size();i++){
childs.append(Group->Childs[i]->Handle);
QList<IGroupHandle*> Kdb3Database::GroupHandle::children(){
QList<IGroupHandle*> children;
for(int i=0; i < Group->Children.size(); i++){
children.append(Group->Children[i]->Handle);
}
return childs;
return children;
}
void memcpyFromLEnd32(quint32* dst,const char* src){
if(QSysInfo::ByteOrder==QSysInfo::BigEndian){
memcpy(((char*)dst)+3,src+0,1);
memcpy(((char*)dst)+2,src+1,1);
memcpy(((char*)dst)+1,src+2,1);
memcpy(((char*)dst)+0,src+3,1);
}
else
memcpy(dst,src,4);
if (QSysInfo::ByteOrder==QSysInfo::BigEndian){
memcpy(((char*)dst)+3,src+0,1);
memcpy(((char*)dst)+2,src+1,1);
memcpy(((char*)dst)+1,src+2,1);
memcpy(((char*)dst)+0,src+3,1);
}
else{
memcpy(dst,src,4);
}
}
void memcpyFromLEnd16(quint16* dst,const char* src){
if(QSysInfo::ByteOrder==QSysInfo::BigEndian){
memcpy(((char*)dst)+1,src+0,1);
memcpy(((char*)dst)+0,src+1,1);
}
else
memcpy(dst,src,2);
if (QSysInfo::ByteOrder==QSysInfo::BigEndian){
memcpy(((char*)dst)+1,src+0,1);
memcpy(((char*)dst)+0,src+1,1);
}
else{
memcpy(dst,src,2);
}
}
void memcpyToLEnd32(char* dst,const quint32* src){
@@ -1188,8 +1215,9 @@ void memcpyToLEnd32(char* dst,const quint32* src){
memcpy(dst+2,((char*)src)+1,1);
memcpy(dst+3,((char*)src)+0,1);
}
else
else{
memcpy(dst,src,4);
}
}
void memcpyToLEnd16(char* dst,const quint16* src){
@@ -1197,8 +1225,9 @@ void memcpyToLEnd16(char* dst,const quint16* src){
memcpy(dst+0,((char*)src)+1,1);
memcpy(dst+1,((char*)src)+0,1);
}
else
else{
memcpy(dst,src,2);
}
}
bool Kdb3Database::save(){
@@ -1206,6 +1235,17 @@ bool Kdb3Database::save(){
error=tr("The database must contain at least one group.");
return false;
}
//Delete old backup entries
if (config->backup() && config->backupDelete() && config->backupDeleteAfter()>0 && backupGroup()){
QDateTime time = QDateTime::currentDateTime().addDays(-config->backupDeleteAfter());
QList<IEntryHandle*> backupEntries = entries(backupGroup());
for (int i=0; i<backupEntries.size(); i++){
if (backupEntries[i]->lastMod()<time)
deleteEntry(backupEntries[i]);
}
}
quint32 NumGroups,NumEntries,Signature1,Signature2,Flags,Version;
quint8 FinalRandomSeed[16];
quint8 ContentsHash[32];
@@ -1418,23 +1458,23 @@ void Kdb3Database::createCustomIconsMetaStream(StdEntry* e){
QList<IGroupHandle*> Kdb3Database::sortedGroups(){
QList<IGroupHandle*> SortedGroups;
appendChildsToGroupList(SortedGroups,RootGroup);
appendChildrenToGroupList(SortedGroups,RootGroup);
return SortedGroups;
}
void Kdb3Database::appendChildsToGroupList(QList<IGroupHandle*>& list,StdGroup& group){
for(int i=0;i<group.Childs.size();i++){
list << group.Childs[i]->Handle;
appendChildsToGroupList(list,*group.Childs[i]);
void Kdb3Database::appendChildrenToGroupList(QList<IGroupHandle*>& list,StdGroup& group){
for(int i=0;i<group.Children.size();i++){
list << group.Children[i]->Handle;
appendChildrenToGroupList(list,*group.Children[i]);
}
}
void Kdb3Database::appendChildsToGroupList(QList<StdGroup*>& list,StdGroup& group){
for(int i=0;i<group.Childs.size();i++){
list << group.Childs[i];
appendChildsToGroupList(list,*group.Childs[i]);
void Kdb3Database::appendChildrenToGroupList(QList<StdGroup*>& list,StdGroup& group){
for(int i=0;i<group.Children.size();i++){
list << group.Children[i];
appendChildrenToGroupList(list,*group.Children[i]);
}
}
@@ -1444,7 +1484,7 @@ void Kdb3Database::serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsig
quint32 FieldSize;
quint32 Flags=0; //unused
QList<StdGroup*>SortedGroups;
appendChildsToGroupList(SortedGroups,RootGroup);
appendChildrenToGroupList(SortedGroups,RootGroup);
for(int i=0; i < SortedGroups.size(); i++){
unsigned char Date[5];
@@ -1692,8 +1732,8 @@ bool Kdb3Database::searchStringContains(const QString& search, const QString& st
void Kdb3Database::getEntriesRecursive(IGroupHandle* Group, QList<IEntryHandle*>& EntryList){
EntryList<<entries(Group);
for(int i=0;i<((GroupHandle*)Group)->Group->Childs.size(); i++){
getEntriesRecursive(((GroupHandle*)Group)->Group->Childs[i]->Handle,EntryList);
for(int i=0;i<((GroupHandle*)Group)->Group->Children.size(); i++){
getEntriesRecursive(((GroupHandle*)Group)->Group->Children[i]->Handle,EntryList);
}
}
@@ -1712,23 +1752,14 @@ QList<IEntryHandle*> Kdb3Database::search(IGroupHandle* Group,const QString& sea
else
SearchEntries=entries();
IGroupHandle* backupGroup = NULL;
if (!Group){
QList<IGroupHandle*> allGroups = groups();
for (int i=0; i<allGroups.size(); i++){
if (allGroups[i]->parent()==NULL && allGroups[i]->title()=="Backup"){
backupGroup = allGroups[i];
break;
}
}
}
IGroupHandle* bGroup = backupGroup();
QList<IEntryHandle*> ResultEntries;
for(int i=0; i<SearchEntries.size(); i++){
IGroupHandle* entryGroup = SearchEntries[i]->group();
while (entryGroup->parent())
entryGroup = entryGroup->parent();
if (entryGroup == backupGroup)
if (entryGroup == bGroup)
continue;
bool match=false;
@@ -1762,18 +1793,18 @@ void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,i
Parent=((GroupHandle*)NewParent)->Group;
else
Parent=&RootGroup;
Group->Parent->Childs.removeAt(Group->Index);
rebuildIndices(Group->Parent->Childs);
Group->Parent->Children.removeAt(Group->Index);
rebuildIndices(Group->Parent->Children);
Group->Parent=Parent;
if(Pos==-1){
Parent->Childs.append(Group);
Parent->Children.append(Group);
}
else
{
Q_ASSERT(Parent->Childs.size()>=Pos);
Parent->Childs.insert(Pos,Group);
Q_ASSERT(Parent->Children.size()>=Pos);
Parent->Children.insert(Pos,Group);
}
rebuildIndices(Parent->Childs);
rebuildIndices(Parent->Children);
}
bool Kdb3Database::changeFile(const QString& filename){

View File

@@ -80,6 +80,7 @@ public:
virtual quint32 binarySize();
virtual QString friendlySize();
virtual bool isValid() const;
virtual CEntry data()const;
private:
void invalidate(){valid=false;}
bool valid;
@@ -98,7 +99,7 @@ public:
virtual quint32 image();
virtual bool isValid();
virtual IGroupHandle* parent();
virtual QList<IGroupHandle*> childs();
virtual QList<IGroupHandle*> children();
virtual int index();
virtual void setIndex(int index);
virtual int level();
@@ -128,7 +129,7 @@ public:
quint16 Index;
StdGroup* Parent;
GroupHandle* Handle;
QList<StdGroup*> Childs;
QList<StdGroup*> Children;
QList<StdEntry*> Entries;
};
@@ -187,6 +188,7 @@ public:
virtual void deleteGroup(IGroupHandle* group);
virtual void moveGroup(IGroupHandle* Group,IGroupHandle* NewParent,int Position);
virtual IGroupHandle* addGroup(const CGroup* Group,IGroupHandle* Parent);
virtual IGroupHandle* backupGroup(bool create=false);
virtual bool isParent(IGroupHandle* parent, IGroupHandle* child);
virtual void generateMasterKey();
@@ -212,8 +214,8 @@ private:
quint32 getNewGroupId();
void serializeEntries(QList<StdEntry>& EntryList,char* buffer,unsigned int& pos);
void serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsigned int& pos);
void appendChildsToGroupList(QList<StdGroup*>& list,StdGroup& group);
void appendChildsToGroupList(QList<IGroupHandle*>& list,StdGroup& group);
void appendChildrenToGroupList(QList<StdGroup*>& list,StdGroup& group);
void appendChildrenToGroupList(QList<IGroupHandle*>& list,StdGroup& group);
bool searchStringContains(const QString& search, const QString& string,bool Cs, bool RegExp);
void getEntriesRecursive(IGroupHandle* Group, QList<IEntryHandle*>& EntryList);
void rebuildIndices(QList<StdGroup*>& list);

View File

@@ -73,6 +73,9 @@ public:
bool openLastFile(){return settings.value("Options/OpenLastFile",true).toBool();}
bool autoSave(){return settings.value("Options/AutoSave",false).toBool();}
bool autoSaveChange(){return settings.value("Options/AutoSaveChange",false).toBool();}
bool backup(){return settings.value("Options/Backup",true).toBool();}
bool backupDelete(){return settings.value("Options/BackupDelete",false).toBool();}
int backupDeleteAfter(){return settings.value("Options/BackupDeleteAfter",14).toInt();}
int pwGenCategory(){return settings.value("Options/PwGenCategory",0).toInt();}
QString pwGenCharList(){return settings.value("Options/PwGenCharList").toString();}
bool pwGenExcludeLookAlike(){return settings.value("Options/PwGenExcludeLookAlike").toBool();}
@@ -105,7 +108,8 @@ public:
Shortcut globalShortcut();
bool entryTitlesMatch(){return settings.value("Options/EntryTitlesMatch",true).toBool();}
#endif
bool featureBookmarks(){return settings.value("Features/Bookmarks",true).toBool();}
//bool featureBookmarks(){return settings.value("Features/Bookmarks",true).toBool();}
bool featureBookmarks(){return true;}
void setAlternatingRowColors(bool value){settings.setValue("Options/AlternatingRowColors",value);}
void setBannerColor1(const QColor& value){settings.setValue("Options/BannerColor1",colorToString(value));}
@@ -136,6 +140,9 @@ public:
void setOpenLastFile(bool value){settings.setValue("Options/OpenLastFile",value);}
void setAutoSave(bool value){settings.setValue("Options/AutoSave",value);}
void setAutoSaveChange(bool value){settings.setValue("Options/AutoSaveChange",value);}
void setBackup(bool value){settings.setValue("Options/Backup",value);}
void setBackupDelete(bool value){settings.setValue("Options/BackupDelete",value);}
void setBackupDeleteAfter(int value){settings.setValue("Options/BackupDeleteAfter",value);}
void setPwGenCategory(int value){settings.setValue("Options/PwGenCategory",value);}
void setPwGenCharList(const QString& value){settings.setValue("Options/PwGenCharList",value);}
void setPwGenExcludeLookAlike(bool value){settings.setValue("Options/PwGenExcludeLookAlike",value);}
@@ -168,7 +175,7 @@ public:
void setGlobalShortcut(const Shortcut& s);
void setEntryTitlesMatch(bool value){settings.setValue("Options/EntryTitlesMatch",value);}
#endif
void setFeatureBookmarks(bool value){settings.setValue("Features/Bookmarks",value);}
//void setFeatureBookmarks(bool value){settings.setValue("Features/Bookmarks",value);}
unsigned fileDlgHistorySize();
void clearFileDlgHistory(){settings.remove("FileDlgHistory");};

View File

@@ -1,29 +0,0 @@
/***************************************************************************
* Copyright (C) 2007 by Tarek Saidi *
* tarek.saidi@arcor.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; version 2 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "KpxFirefox.h"
/*
KpxFirefoxAdaptor::KpxFirefoxAdaptor(KpxFirefox* obj): QDBusAbstractAdaptor(obj)
{ kpx=obj; }
*/

View File

@@ -1,61 +0,0 @@
/***************************************************************************
* Copyright (C) 2007 by Tarek Saidi *
* tarek.saidi@arcor.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; version 2 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef KPXFIREFOX_H
#define KPXFIREFOX_H
/*
#include <QtDBus/QtDBus>
#include <QObject>
#include "Database.h"
class KpxFirefox:public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.keepassx.DBus.KpxFirefox")
public:
KpxFirefox(IDatabase* db){};
//~KpxFirefox(){};
public slots:
QString getMyValue(int Zahl){return QString("You sent the number %1 over DBUS").arg(Zahl);}
};
class KpxFirefoxAdaptor:public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.keepassx.DBus.KpxFirefox")
public:
KpxFirefoxAdaptor(KpxFirefox* kpx);
~KpxFirefoxAdaptor(){};
public slots:
QString getMyValue(int Zahl){
QString serv=QDBusConnection::sender().baseService();
QDBusConnectionInterface *inter=QDBusConnection::sender().interface();
qDebug("PID=%i",inter->servicePid(serv).value());
return kpx->getMyValue(Zahl);
}
private:
KpxFirefox* kpx;
};
*/
#endif

View File

@@ -211,18 +211,20 @@ void CEditEntryDlg::OnButtonOK()
pw.setString(password,true);
entry->setPassword(pw);
entry->setComment(Edit_Comment->toPlainText());
entry->setImage(IconIndex);
}
if(Combo_Group->currentIndex()!=GroupIndex){
db->moveEntry(entry,groups[Combo_Group->currentIndex()]);
EntryMoved=true; ModFlag=true;
EntryMoved=true;
ModFlag=true;
}
// MX-COMMENT: Should not this line go inside the if(Modflag) block?
entry->setImage(IconIndex);
if(ModFlag&&EntryMoved)done(2);
else if(ModFlag)done(1);
else done(0);
if(EntryMoved)
done(ModFlag?2:3);
else if (ModFlag)
done(1);
else
done(0);
}
void CEditEntryDlg::OnButtonCancel()

View File

@@ -51,6 +51,10 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
connect(Button_CustomizeEntryDetails,SIGNAL(clicked()),this,SLOT(OnCustomizeEntryDetails()));
connect(CheckBox_InactivityLock, SIGNAL(toggled(bool)), SLOT(OnInactivityLockChange(bool)));
connect(CheckBox_Backup, SIGNAL( toggled(bool) ), CheckBox_BackupDelete, SLOT( setEnabled(bool) ) );
connect(CheckBox_Backup, SIGNAL( toggled(bool) ), SLOT( OnBackupDeleteChange() ) );
connect(CheckBox_BackupDelete, SIGNAL( toggled(bool) ), SLOT( OnBackupDeleteChange() ) );
connect(CheckBox_AutoSave, SIGNAL(toggled(bool)), SLOT(OnAutoSaveToggle(bool)));
connect(CheckBox_AutoSaveChange, SIGNAL(toggled(bool)), SLOT(OnAutoSaveChangeToggle(bool)));
@@ -68,7 +72,7 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
connect(this,SIGNAL(rejected()),SLOT(resetGlobalShortcut()));
#endif
//General
//General (1)
CheckBox_OpenLast->setChecked(config->openLastFile());
CheckBox_RememberLastKey->setChecked(config->rememberLastKey());
CheckBox_ShowSysTrayIcon->setChecked(config->showSysTrayIcon());
@@ -77,9 +81,14 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
CheckBox_StartMinimized->setChecked(config->startMinimized());
CheckBox_StartLocked->setChecked(config->startLocked());
checkBox_SaveFileDlgHistory->setChecked(config->saveFileDlgHistory());
checkBox_AskBeforeDelete->setChecked(config->askBeforeDelete());
//General (2)
CheckBox_Backup->setChecked(config->backup());
CheckBox_BackupDelete->setChecked(config->backupDelete());
SpinBox_BackupDeleteAfter->setValue(config->backupDeleteAfter());
CheckBox_AutoSave->setChecked(config->autoSave());
CheckBox_AutoSaveChange->setChecked(config->autoSaveChange());
checkBox_AskBeforeDelete->setChecked(config->askBeforeDelete());
switch(config->groupTreeState()){
case KpxConfig::RestoreLast:
@@ -123,7 +132,8 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
SpinBox_InacitivtyTime->setValue(config->lockAfterSec());
//Features
CheckBox_FeatureBookmarks->setChecked(config->featureBookmarks());
tabWidgetSettings->removeTab(tabWidgetSettings->indexOf(tabFeatures));
//CheckBox_FeatureBookmarks->setChecked(config->featureBookmarks());
// TODO Desktop Integration
@@ -201,7 +211,7 @@ void CSettingsDlg::OnOtherButton(QAbstractButton* button){
void CSettingsDlg::apply(){
//General
//General (1)
config->setShowSysTrayIcon(CheckBox_ShowSysTrayIcon->isChecked());
config->setMinimizeToTray(CheckBox_CloseToTray->isChecked());
config->setMinimizeTray(CheckBox_MinimizeTray->isChecked());
@@ -213,9 +223,14 @@ void CSettingsDlg::apply(){
else config->setGroupTreeState(KpxConfig::DoNothing);
config->setOpenLastFile(CheckBox_OpenLast->isChecked());
config->setRememberLastKey(CheckBox_RememberLastKey->isChecked());
config->setAskBeforeDelete(checkBox_AskBeforeDelete->isChecked());
//General (2)
config->setBackup(CheckBox_Backup->isChecked());
config->setBackupDelete(CheckBox_BackupDelete->isChecked());
config->setBackupDeleteAfter(SpinBox_BackupDeleteAfter->value());
config->setAutoSave(CheckBox_AutoSave->isChecked());
config->setAutoSaveChange(CheckBox_AutoSaveChange->isChecked());
config->setAskBeforeDelete(checkBox_AskBeforeDelete->isChecked());
//Appearence
config->setBannerColor1(color1);
@@ -232,7 +247,7 @@ void CSettingsDlg::apply(){
config->setLockAfterSec(SpinBox_InacitivtyTime->value());
//Features
config->setFeatureBookmarks(CheckBox_FeatureBookmarks->isChecked());
//config->setFeatureBookmarks(CheckBox_FeatureBookmarks->isChecked());
//TODO Desktop Integration
/*PluginsModified=Label_IntPlugin_Info->isVisible();
@@ -342,6 +357,10 @@ void CSettingsDlg::OnAutoSaveChangeToggle(bool checked){
CheckBox_AutoSave->setEnabled(!checked);
}
void CSettingsDlg::OnBackupDeleteChange(){
SpinBox_BackupDeleteAfter->setEnabled(CheckBox_Backup->isChecked() && CheckBox_BackupDelete->isChecked());
}
#ifdef GLOBAL_AUTOTYPE
void CSettingsDlg::resetGlobalShortcut(){
AutoType::unregisterGlobalShortcut();

View File

@@ -47,6 +47,7 @@ class CSettingsDlg : public QDialog, private Ui_SettingsDialog
void OnInactivityLockChange(bool checked);
void OnAutoSaveToggle(bool checked);
void OnAutoSaveChangeToggle(bool checked);
void OnBackupDeleteChange();
#ifdef GLOBAL_AUTOTYPE
private slots:

View File

@@ -48,9 +48,9 @@ void Export_KeePassX_Xml::addGroup(IGroupHandle* group,QDomElement& parent,QDomD
Icon.appendChild(doc.createTextNode(QString::number(group->image())));
GroupElement.appendChild(Title);
GroupElement.appendChild(Icon);
QList<IGroupHandle*> childs=group->childs();
for(int i=0;i<childs.size();i++){
addGroup(childs[i],GroupElement,doc);
QList<IGroupHandle*> children=group->children();
for(int i=0;i<children.size();i++){
addGroup(children[i],GroupElement,doc);
}
QList<IEntryHandle*> entries=db->entries(group);
for(int i=0;i<entries.size();i++){

View File

@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>606</width>
<height>479</height>
<height>455</height>
</rect>
</property>
<property name="windowTitle" >
@@ -46,20 +46,17 @@
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="TabGeneral" >
<widget class="QWidget" name="TabGeneral1" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<property name="whatsThis" >
<string>The integration plugins provide features like usage of the native file dialogs and message boxes of the particular desktop environments.</string>
</property>
<attribute name="title" >
<string>General</string>
<string>General (1)</string>
</attribute>
<layout class="QVBoxLayout" >
<item>
@@ -283,20 +280,6 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_AutoSave" >
<property name="text" >
<string>Automatically save database on exit and workspace locking</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_AutoSaveChange" >
<property name="text" >
<string>Automatically save database after every change</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_AskBeforeDelete" >
<property name="text" >
@@ -319,13 +302,118 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="TabGeneral2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>321</height>
</rect>
</property>
<attribute name="title" >
<string>General (2)</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QCheckBox" name="CheckBox_Backup" >
<property name="text" >
<string>Save backups of modified entries into the 'Backup' group</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="spacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>25</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_BackupDelete" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Delete backup entries older than:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="SpinBox_BackupDeleteAfter" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>999</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>days</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_AutoSave" >
<property name="text" >
<string>Automatically save database on exit and workspace locking</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_AutoSaveChange" >
<property name="text" >
<string>Automatically save database after every change</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<attribute name="title" >
@@ -685,7 +773,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<attribute name="title" >
@@ -847,7 +935,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<attribute name="title" >
@@ -892,7 +980,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<attribute name="title" >
@@ -1012,7 +1100,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>345</height>
<height>321</height>
</rect>
</property>
<attribute name="title" >
@@ -1239,8 +1327,12 @@
<tabstop>CheckBox_StartLocked</tabstop>
<tabstop>checkBox_SaveFileDlgHistory</tabstop>
<tabstop>Button_ClearFileDlgHistory</tabstop>
<tabstop>CheckBox_AutoSave</tabstop>
<tabstop>checkBox_AskBeforeDelete</tabstop>
<tabstop>CheckBox_Backup</tabstop>
<tabstop>CheckBox_BackupDelete</tabstop>
<tabstop>SpinBox_BackupDeleteAfter</tabstop>
<tabstop>CheckBox_AutoSave</tabstop>
<tabstop>CheckBox_AutoSaveChange</tabstop>
<tabstop>ButtonColor1</tabstop>
<tabstop>ButtonColor2</tabstop>
<tabstop>ButtonTextColor</tabstop>

View File

@@ -170,17 +170,18 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entry->username());}
if (Columns.at(2)){item->setText(j++,entry->url());}
if (Columns.at(3)){
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entry->password();
password.unlock();
item->setText(j++,password.string());
}
item->setText(j++,entry->username());
}
if (Columns.at(2)){item->setText(j++,entry->url());}
if (Columns.at(3)){
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entry->password();
password.unlock();
item->setText(j++,password.string());
}
}
if (Columns.at(4)){
item->setText(j++,entry->comment().section('\n',0,0));}
if (Columns.at(5)){
@@ -195,25 +196,40 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
item->setText(j++,entry->binaryDesc());}
if(Columns.at(10) && ViewMode==ShowSearchResults){
item->setText(j,entry->group()->title());
item->setIcon(j++,db->icon(entry->group()->image()));}
item->setIcon(j++,db->icon(entry->group()->image()));
}
}
void KeepassEntryView::editEntry(EntryViewItem* item){
CEntry old = item->EntryHandle->data();
CEditEntryDlg dlg(db,item->EntryHandle,this,true);
switch(dlg.exec()){
int result = dlg.exec();
switch(result){
case 0: //canceled or no changes
break;
case 1: //modifications but same group
updateEntry(item);
emit fileModified();
break;
case 2: //entry moved to another group
//entry moved to another group
case 2: //modified
case 3: //not modified
delete item;
Items.removeAt(Items.indexOf(item));
emit fileModified();
break;
}
if ((result==1 || result==2) && config->backup()){
old.LastAccess = QDateTime::currentDateTime();
old.LastMod = QDateTime::currentDateTime();
IGroupHandle* bGroup = db->backupGroup();
if (bGroup==NULL)
emit requestCreateGroup("Backup", 4, NULL);
if ((bGroup = db->backupGroup())!=NULL)
db->addEntry(&old, bGroup);
}
}

View File

@@ -26,6 +26,7 @@
#define NUM_COLUMNS 11
class EntryViewItem;
class GroupViewItem;
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
class KeepassEntryView:public QTreeWidget{
@@ -44,6 +45,7 @@ class KeepassEntryView:public QTreeWidget{
QMenu *ContextMenu;
QBitArray Columns;
void setCurrentEntry(IEntryHandle* entry);
inline IGroupHandle* getCurrentGroup() { return CurrentGroup; };
private:
void setEntry(IEntryHandle* entry);
void updateEntry(EntryViewItem*);
@@ -97,6 +99,7 @@ class KeepassEntryView:public QTreeWidget{
signals:
void fileModified();
void selectionChanged(SelectionState);
void requestCreateGroup(QString title, quint32 image, GroupViewItem* parent);
};

View File

@@ -46,7 +46,7 @@ void KeepassGroupView::createItems(){
Items.append(new GroupViewItem(this));
Items.back()->setText(0,groups[i]->title());
Items.back()->GroupHandle=groups[i];
addChilds(Items.back());
addChildren(Items.back());
}
}
for(int i=0;i<Items.size();i++){
@@ -71,15 +71,15 @@ void KeepassGroupView::showSearchResults(){
emit searchResultsSelected();
}
void KeepassGroupView::addChilds(GroupViewItem* item){
QList<IGroupHandle*>childs=item->GroupHandle->childs();
if(!childs.size())
void KeepassGroupView::addChildren(GroupViewItem* item){
QList<IGroupHandle*>children=item->GroupHandle->children();
if(!children.size())
return;
for(int i=0; i<childs.size(); i++){
for(int i=0; i<children.size(); i++){
Items.push_back(new GroupViewItem(item));
Items.back()->setText(0,childs[i]->title());
Items.back()->GroupHandle=childs[i];
addChilds(Items.back());
Items.back()->setText(0,children[i]->title());
Items.back()->GroupHandle=children[i];
addChildren(Items.back());
}
}
@@ -106,50 +106,39 @@ void KeepassGroupView::OnNewGroup(){
GroupViewItem* parent=(GroupViewItem*)currentItem();
CGroup NewGroup;
CEditGroupDialog dlg(db,&NewGroup,parentWidget(),true);
if(dlg.exec()){
IGroupHandle* group;
if(parent){
group=db->addGroup(&NewGroup,parent->GroupHandle);
Items.append(new GroupViewItem(parent));
}
else{
if(topLevelItemCount()){
if(topLevelItem(topLevelItemCount()-1)==SearchResultItem)
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-2)));
else
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-1)));
}
else
Items.append(new GroupViewItem(this));
group=db->addGroup(&NewGroup,NULL);
}
Items.back()->GroupHandle=group;
Items.back()->setText(0,group->title());
Items.back()->setIcon(0,db->icon(group->image()));
}
emit fileModified();
if(dlg.exec())
createGroup(NewGroup.Title, NewGroup.Image, parent);
}
void KeepassGroupView::createGroup(const QString& title, quint32 image){
void KeepassGroupView::createGroup(const QString& title, quint32 image, GroupViewItem* parent){
CGroup NewGroup;
NewGroup.Title = title;
NewGroup.Image = image;
IGroupHandle* group;
if(topLevelItemCount()){
if(topLevelItem(topLevelItemCount()-1)==SearchResultItem)
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-2)));
else
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-1)));
if(parent){
group=db->addGroup(&NewGroup,parent->GroupHandle);
Items.append(new GroupViewItem(parent));
}
else{
if(topLevelItemCount()){
int i=1;
if(topLevelItem(topLevelItemCount()-i)==SearchResultItem)
i++;
if(title!="Backup" && topLevelItem(topLevelItemCount()-i)->text(0)=="Backup")
i++;
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-i)));
}
else
Items.append(new GroupViewItem(this));
group = db->addGroup(&NewGroup,NULL);
}
else
Items.append(new GroupViewItem(this));
group = db->addGroup(&NewGroup,NULL);
Items.back()->GroupHandle = group;
Items.back()->setText(0, group->title());
Items.back()->setIcon(0, db->icon(group->image()));
emit fileModified();
}
void KeepassGroupView::OnEditGroup(){

View File

@@ -36,7 +36,9 @@ class KeepassGroupView:public QTreeWidget{
void createItems();
void showSearchResults();
void setCurrentGroup(IGroupHandle* group);
void createGroup(const QString& title, quint32 image);
public slots:
void createGroup(const QString& title, quint32 image, GroupViewItem* group=NULL);
private:
virtual void dragEnterEvent(QDragEnterEvent* event);
@@ -49,7 +51,7 @@ class KeepassGroupView:public QTreeWidget{
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void paintEvent ( QPaintEvent * event );
virtual void contextMenuEvent(QContextMenuEvent *event);
void addChilds(GroupViewItem* item);
void addChildren(GroupViewItem* item);
QPoint DragStartPos;
GroupViewItem* DragItem;
GroupViewItem* LastHoverItem;

View File

@@ -77,6 +77,7 @@ int main(int argc, char **argv)
fileDlgHistory.load();
// PlugIns
/*
#ifdef Q_WS_X11
if(config->integrPlugin()!=KpxConfig::NoIntegr){
QString LibName="libkeepassx-";
@@ -121,6 +122,7 @@ int main(int argc, char **argv)
}
}
#endif
*/
if(!app){
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
app = new KeepassApplication(argc,argv);
@@ -158,7 +160,7 @@ int main(int argc, char **argv)
else{
if(loc.name()!="en_US")
qWarning(CSTR(
QString("Kpx: No Translation found for '%1 (%2)' using 'English (UnitedStates)'")
QString("Kpx: No Translation found for '%1 (%2)' using 'English (United States)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country()))
));
@@ -175,7 +177,7 @@ int main(int argc, char **argv)
else{
if(loc.name()!="en_US")
qWarning(CSTR(
QString("Qt: No Translation found for '%1 (%2)' using 'English (UnitedStates)'")
QString("Qt: No Translation found for '%1 (%2)' using 'English (United States)'")
.arg(QLocale::languageToString(loc.language()))
.arg(QLocale::countryToString(loc.country()))
));

View File

@@ -152,6 +152,7 @@ void KeepassMainWindow::setupConnections(){
connect(EditDeleteGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnDeleteGroup()));
connect(EditNewEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnNewEntry()));
connect(EditEditEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnEditEntry()));
connect(EntryView, SIGNAL(requestCreateGroup(QString,quint32,GroupViewItem*)), GroupView, SLOT(createGroup(QString,quint32,GroupViewItem*)));
connect(EditCloneEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnCloneEntry()));
connect(EditDeleteEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnDeleteEntry()));
connect(EditUsernameToClipboardAction, SIGNAL(triggered()), EntryView, SLOT(OnUsernameToClipboard()));
@@ -860,13 +861,19 @@ bool KeepassMainWindow::OnFileSave(){
if(!db->file())
return OnFileSaveAs();
saveLastFilename(db->file()->fileName());
if(db->save())
if(db->save()){
setStateFileModified(false);
if (config->backup() && config->backupDelete() && config->backupDeleteAfter()>0){
IGroupHandle* backupGroup = db->backupGroup();
if (backupGroup && backupGroup==EntryView->getCurrentGroup())
EntryView->showGroup(backupGroup);
}
return true;
}
else{
showErrMsg(QString("%1\n%2").arg(tr("File could not be saved.")).arg(db->getError()));
return false;
}
return true;
}
bool KeepassMainWindow::OnFileSaveAs(){