diff --git a/src/PwManager.cpp b/src/PwManager.cpp index 9d1dc2d..d203ebf 100755 --- a/src/PwManager.cpp +++ b/src/PwManager.cpp @@ -1065,6 +1065,22 @@ for(i=NumSubGroups; i>=0; i--) Groups.insert(DstIndex,tmp[i]); } +bool PwDatabase::createKeyFile(const QString& filename){ +QFile file(filename); +if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)){ + Errors << tr("Could not open key file."); + return false;} +char* pKeyData=new char[32]; +getRandomBytes(pKeyData,32); +if(file.write(pKeyData,32)!=32){ + Errors << tr("Key file could not be written."); + file.close(); + return false; +} +file.close(); +return true; + +} int PwDatabase::getNumberOfChilds(CGroup* group){ if(!group)return Groups.size(); diff --git a/src/PwManager.h b/src/PwManager.h index 8546e4f..498141a 100755 --- a/src/PwManager.h +++ b/src/PwManager.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Tarek Saidi * + * Copyright (C) 2005-2006 by Tarek Saidi * * tarek.saidi@arcor.de * * * * This program is free software; you can redistribute it and/or modify * @@ -53,6 +53,7 @@ public: bool CalcMasterKeyByPassword(QString& password); bool CalcMasterKeyByFile(QString filename); bool CalcMasterKeyByFileAndPw(QString filename, QString& password); + bool createKeyFile(const QString& filename); CGroup* addGroup(CGroup* parent); void deleteGroup(CGroup* pGroup); diff --git a/src/dialogs/ChangeKeyDlg.cpp b/src/dialogs/ChangeKeyDlg.cpp deleted file mode 100755 index f248b11..0000000 --- a/src/dialogs/ChangeKeyDlg.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Tarek Saidi * - * tarek@linux * - * * - * 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 of the License, or * - * (at your option) any later version. * - * * - * 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 "main.h" -#include "PwmConfig.h" -#include "PwManager.h" -#include "../lib/random.h" -#include "ChangeKeyDlg.h" -//QT -#include -#include -#include -#include -#include -#include -#include - - - -CChangeKeyDlg::CChangeKeyDlg(QWidget* parent,PwDatabase* _db,const char* name, bool modal, Qt::WFlags fl) -: QDialog(parent,name, modal,fl) -{ -setupUi(this); -connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) ); -connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) ); -connect( Button_Browse, SIGNAL( clicked() ), this, SLOT( OnBrowse() ) ); -connect( Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) ); -connect( Edit_Password_2, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPassword2Changed(const QString&) ) ); -connect( Combo_Dirs, SIGNAL( activated(int) ), this, SLOT( OnComboChanged(int) ) ); -connect( CheckBox_Both, SIGNAL( stateChanged(int) ), this, SLOT( OnCheckBoxChanged(int) ) ); -connect( ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoMode() ) ); - -db=_db; -createBanner(Banner,Icon_Key32x32,tr("Change Master Key")); -if(!config.ShowPasswords)ChangeEchoMode(); -///@PlatformSpecific -QDir media("/media"); -if(media.exists()){ -Paths=media.entryList("*",QDir::Dirs); -Paths.erase(Paths.begin()); // delete "." -Paths.erase(Paths.begin()); // delete ".." - -for(int i=0;i"); -} -for(int i=0;iinsertItem(0,Paths[i]); -IsFile.append(false); -} -} - -CChangeKeyDlg::~CChangeKeyDlg() -{ -} - -void CChangeKeyDlg::OnOK() -{ -if(CheckBox_Both->isChecked()){ - if(password==""){QMessageBox::warning(this,tr("Error"),tr("Please enter a password.") - ,tr("OK"),"","",0,0); - return;} - if(keyfile==""){QMessageBox::warning(this,tr("Error"),tr("Please choose a key file.") - ,tr("OK"),"","",0,0); - return;} -} -else -{ - if(password=="" && keyfile==""){QMessageBox::warning(this,tr("Error"),tr("Please select a key file or enter a password.") - ,tr("OK"),"","",0,0); - return;} -} - -Q_UINT8 file_key[32]={0}; -Q_UINT8 pw_key[32]={0}; - -if(keyfile!=""){ -QFile file(keyfile); -if(file.exists()){ -int r=QMessageBox::warning(this,tr("Overwrite?"),tr("A key file with this name already exists.\nDo you want to replace it?"),"Yes","No",NULL,1,1); -if(r==1)return;} -getRandomBytes(file_key,1,32,true); -if(file.open(QIODevice::WriteOnly | QIODevice::Truncate)==false){ -QMessageBox::critical(this,tr("Error"),tr("Could not open key file for writing."),"OK",0,0,2,1); -return; -} -if(file.writeBlock((char*)file_key,32)!=32){ -file.close(); -QMessageBox::critical(this,tr("Error"),tr("Key file could not be written."),"OK",0,0,2,1); -return; -} -file.close(); -} - -if(CheckBox_Both->isChecked() || keyfile==""){ - if(password!=Edit_Password_2->text()){ - QMessageBox::critical(this,tr("Error"),tr("Password and password repetition are not equal.\nPlease check your input.")); - return;}} - -if(CheckBox_Both->isChecked())db->CalcMasterKeyByFileAndPw(keyfile, password); - else if(password=="")db->CalcMasterKeyByFile(keyfile); - else if(keyfile==""){db->CalcMasterKeyByPassword(password);} - -done(1); -} - -void CChangeKeyDlg::OnSelect() -{ -if(Button_Browse->isEnabled()){ -keyfile=Q3FileDialog::getSaveFileName(QDir::homeDirPath(),"",this,tr("Open key file")); -if(keyfile=="")return; -Combo_Dirs->insertItem(keyfile); -Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1); -if(!CheckBox_Both->isChecked()){ - Edit_Password->setDisabled(true); - Edit_Password->setText(""); - password=""; -} -Paths.append(keyfile); -IsFile.append(true); -} -} - - -void CChangeKeyDlg::OnBrowse() -{ -QString dir=Q3FileDialog::getExistingDirectory(QDir::homeDirPath(),NULL,tr("Choose Directory")); -if(dir=="")return; -keyfile=dir+"/pwsafe.key"; -Combo_Dirs->insertItem(dir); -Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1); -if(!CheckBox_Both->isChecked()){ - Edit_Password->setDisabled(true); - Edit_Password_2->setDisabled(true); - Edit_Password->setText(""); - Edit_Password_2->setText(""); - password=""; -} -Paths.append(dir); -IsFile.append(false); -} - - -void CChangeKeyDlg::OnCancel() -{ -done(0); -} - -void CChangeKeyDlg::OnPasswordChanged(const QString& str) -{ -if(str!="" && !(CheckBox_Both->isChecked())){ -Combo_Dirs->setDisabled(true); -Button_Browse->setDisabled(true);} -else{ -Combo_Dirs->setEnabled(true); -Button_Browse->setEnabled(true);} -Edit_Password_2->setText(""); -password=str; -} - -void CChangeKeyDlg::OnPassword2Changed(const QString& str) -{ -} - -void CChangeKeyDlg::OnComboChanged(int i) -{ -if(i==0){ -keyfile=""; -Edit_Password->setEnabled(true); -Edit_Password_2->setEnabled(true); -return; -} -if(IsFile[i]==true)keyfile=Paths[i]; -else keyfile=Paths[i]+"/pwsafe.key"; - -if(!CheckBox_Both->isChecked()){ -Edit_Password->setText(""); -Edit_Password->setDisabled(true); -Edit_Password_2->setText(""); -Edit_Password_2->setDisabled(true);} - -} - -void CChangeKeyDlg::OnCheckBoxChanged(int i) -{ -if(i==QCheckBox::NoChange)return; -if(i==QCheckBox::On){ -Combo_Dirs->setEnabled(true); -Button_Browse->setEnabled(true); -Edit_Password->setEnabled(true); -Edit_Password_2->setEnabled(true); -} -} - -void CChangeKeyDlg::ChangeEchoMode() -{ -if(Edit_Password->echoMode()==QLineEdit::Normal){ -Edit_Password->setEchoMode(QLineEdit::Password); -Edit_Password_2->setEchoMode(QLineEdit::Password); -} -else -{ -Edit_Password->setEchoMode(QLineEdit::Normal); -Edit_Password_2->setEchoMode(QLineEdit::Normal); -} - -} - - - - - - -/*$SPECIALIZATION$*/ - - -//#include "changekeydlg.moc" - diff --git a/src/dialogs/ChangeKeyDlg.h b/src/dialogs/ChangeKeyDlg.h deleted file mode 100755 index e461967..0000000 --- a/src/dialogs/ChangeKeyDlg.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Tarek Saidi * - * tarek@linux * - * * - * 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 of the License, or * - * (at your option) any later version. * - * * - * 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 _CHANGEKEYDLG_H_ -#define _CHANGEKEYDLG_H_ -#include "ui_ChangeKeyDlg.h" -#include -#include -#include -#include "main.h" -#include "PwManager.h" - -class CChangeKeyDlg : public QDialog, public Ui_ChangeKeyDialog -{ - Q_OBJECT - -public: - CChangeKeyDlg(QWidget* parent,PwDatabase* db, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); - ~CChangeKeyDlg(); - /*$PUBLIC_FUNCTIONS$*/ - -public slots: - /*$PUBLIC_SLOTS$*/ - -protected: - /*$PROTECTED_FUNCTIONS$*/ - -protected slots: - /*$PROTECTED_SLOTS$*/ - -public slots: - virtual void OnSelect(); - virtual void OnBrowse(); - virtual void OnCancel(); - virtual void OnOK(); - virtual void OnComboChanged(int i); - virtual void OnCheckBoxChanged(int i); - virtual void OnPasswordChanged(const QString& str); - virtual void OnPassword2Changed(const QString& str); - virtual void ChangeEchoMode(); - - -private: -PwDatabase* db; -QStringList Paths; -Q3ValueList IsFile; - -public: -QString keyfile; -QFile* pKeyFile; -QString password; -}; - -#endif - diff --git a/src/dialogs/PasswordDlg.cpp b/src/dialogs/PasswordDlg.cpp index b4d3c4c..9897b70 100755 --- a/src/dialogs/PasswordDlg.cpp +++ b/src/dialogs/PasswordDlg.cpp @@ -196,9 +196,35 @@ done(1); } void CPasswordDialog::OnOK_Set(){ +password=Edit_Password->text(); +keyfile=Combo_Dirs->currentText(); +if(password=="" && keyfile==""){ + QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0); + return;} - - +QFile file(keyfile); +if(QFileInfo(file).isDir()){ + if(keyfile.right(1)!="/")keyfile+="/"; + QFile file(keyfile+"pwsafe.key"); + if(file.exists()){ + int r=QMessageBox::warning(this,tr("Warning"),tr("A file with the name 'pwsafe.key' already exisits in the given directory.\nDo you want to replace it?"),tr("Yes"),tr("No"),"",1,1); + if(r)return; + if(!QFileInfo(file).isWritable()){ + QMessageBox::warning(this,tr("Error"),tr("The exisiting file is not writable."),tr("OK"),"","",0,0); + return;} + } + keyfile+="pwsafe.key"; +}else{ + QFile file(keyfile); + if(file.exists()){ + int r=QMessageBox::warning(this,tr("Warning"),tr("A file with the this name already exisits.\nDo you want to replace it?"),tr("Yes"),tr("No"),"",1,1); + if(r)return; + if(!QFileInfo(file).isWritable()){ + QMessageBox::warning(this,tr("Error"),tr("The exisiting file is not writable."),tr("OK"),"","",0,0); + return;} + } +} +done(1); } void CPasswordDialog::OnPasswordChanged(const QString &txt){ diff --git a/src/dialogs/SimplePasswordDlg.cpp b/src/dialogs/SimplePasswordDlg.cpp index 8631719..2ce5598 100755 --- a/src/dialogs/SimplePasswordDlg.cpp +++ b/src/dialogs/SimplePasswordDlg.cpp @@ -21,6 +21,7 @@ #include #include #include "main.h" +#include "PwmConfig.h" #include "SimplePasswordDlg.h" CSimplePasswordDialog::CSimplePasswordDialog(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) diff --git a/src/forms/ChangeKeyDlg.ui b/src/forms/ChangeKeyDlg.ui deleted file mode 100644 index 113f556..0000000 --- a/src/forms/ChangeKeyDlg.ui +++ /dev/null @@ -1,264 +0,0 @@ - - - - - ChangeKeyDialog - - - - 0 - 0 - 560 - 270 - - - - - 0 - 0 - 0 - 0 - - - - - 560 - 270 - - - - - 560 - 270 - - - - Change Master Key - - - - - 0 - 0 - 560 - 50 - - - - - 0 - 0 - 0 - 0 - - - - - - - true - - - - - - 10 - 80 - 540 - 150 - - - - Key - - - Qt::Vertical - - - - - 200 - 30 - 310 - 20 - - - - - - - 200 - 60 - 310 - 20 - - - - - - - 10 - 120 - 521 - 16 - - - - Use password AND key file - - - - - - 10 - 90 - 191 - 20 - - - - Key file or directory: - - - - - - 10 - 60 - 191 - 20 - - - - Password Repetition: - - - - - - 10 - 30 - 191 - 20 - - - - Password: - - - - - - 510 - 30 - 20 - 20 - - - - ... - - - - - - 450 - 90 - 80 - 22 - - - - &Browse... - - - Alt+B - - - - - - 201 - 90 - 240 - 21 - - - - - - - - 0 - 56 - 450 - 16 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Enter a Password and/or choose a key file. - - - - - - 457 - 240 - 90 - 26 - - - - &Cancel - - - Alt+C - - - - - - 360 - 240 - 90 - 26 - - - - O&K - - - Alt+K - - - - - - - - Q3GroupBox - -
Qt3Support/Q3GroupBox
- 1 - -
-
- - Edit_Password - Edit_Password_2 - Combo_Dirs - Button_Browse - CheckBox_Both - ButtonOK - ButtonCancel - ButtonChangeEchoMode - - - -
diff --git a/src/forms/SettingsDlg.ui b/src/forms/SettingsDlg.ui index e430803..5165da0 100644 --- a/src/forms/SettingsDlg.ui +++ b/src/forms/SettingsDlg.ui @@ -86,7 +86,7 @@ - Securi&try + Securi&ty @@ -448,27 +448,11 @@ &Other - - - - 10 - 20 - 380 - 20 - - - - Remember last opend file - - - Alt+Ö - - - + 10 - 50 + 70 531 58 @@ -509,6 +493,35 @@ + + + + 10 + 20 + 521 + 20 + + + + Remember last opend file + + + Alt+Ö + + + + + + 30 + 40 + 501 + 22 + + + + Remember last key type and location + + diff --git a/src/lib/EntryView.cpp b/src/lib/EntryView.cpp index 776551a..ed260b6 100644 --- a/src/lib/EntryView.cpp +++ b/src/lib/EntryView.cpp @@ -91,18 +91,21 @@ resizeColumns(); e->accept(); } +void KeepassEntryView::updateItems(){ +updateItems(CurrentGroup); +} -void KeepassEntryView::updateItems(unsigned int GroupID){ +void KeepassEntryView::updateItems(unsigned int GroupID){ clear(); Items.clear(); if(!db)return; if(!GroupID)return; +CurrentGroup=GroupID; for(int i=0;iEntries.size();i++){ if(db->Entries[i].GroupID==GroupID) setEntry(&db->Entries[i]); } - } void KeepassEntryView::showSearchResults(QList& results){ diff --git a/src/lib/EntryView.h b/src/lib/EntryView.h index cd13a45..eb39a97 100644 --- a/src/lib/EntryView.h +++ b/src/lib/EntryView.h @@ -38,8 +38,8 @@ public: KeepassEntryView(QWidget* parent=0); ~KeepassEntryView(); void updateItems(unsigned int group); - void refreshItems(); void updateColumns(); + void refreshItems(); void showSearchResults(QList& results); PwDatabase* db; vectorItems; @@ -57,14 +57,11 @@ protected: virtual void contextMenuEvent(QContextMenuEvent *event); virtual void paintEvent(QPaintEvent* event); virtual void resizeEvent(QResizeEvent* event); -// virtual void dragEnterEvent ( QDragEnterEvent * event ); -// virtual void dragMoveEvent ( QDragMoveEvent * event ); -// virtual void dragLeaveEvent ( QDragLeaveEvent * event ); -// virtual void dropEvent ( QDropEvent * event ); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); public slots: void OnColumnResized(int index,int OldSize, int NewSize); + void updateItems(); }; diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp index 7bfa2d3..deacf1c 100644 --- a/src/lib/GroupView.cpp +++ b/src/lib/GroupView.cpp @@ -157,18 +157,15 @@ if(DragType==GROUP){ } } else db->moveGroup(DragItem->pGroup,NULL); + updateItems(); }else{ Q_ASSERT(item); QList* pDragItems=(QList*)*((QList**)event->mimeData()->data("keepass/entry").data()); for(int i=0;isize();i++){ db->moveEntry(((EntryViewItem*)(*pDragItems)[i])->pEntry,item->pGroup); } - - + emit entryDropped(); } - - -updateItems(); } diff --git a/src/lib/GroupView.h b/src/lib/GroupView.h index 7edece1..ec85452 100644 --- a/src/lib/GroupView.h +++ b/src/lib/GroupView.h @@ -42,6 +42,7 @@ public: signals: void fileModified(); + void entryDropped(); protected: virtual void dragEnterEvent ( QDragEnterEvent * event ); diff --git a/src/lib/random.h b/src/lib/random.h index 7ec491f..407d961 100755 --- a/src/lib/random.h +++ b/src/lib/random.h @@ -17,4 +17,4 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -extern void getRandomBytes(void* buffer,int NumBlocks,int BlockSize,bool Strong=false); \ No newline at end of file +extern void getRandomBytes(void* buffer,int NumBlocks,int BlockSize=1,bool Strong=false); \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fe745d0..cbff4af 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -46,7 +46,6 @@ #include "dialogs/AboutDlg.h" #include "dialogs/EditGroupDlg.h" #include "dialogs/SearchDlg.h" -#include "dialogs/ChangeKeyDlg.h" #include "dialogs/SettingsDlg.h" #include "dialogs/DatabaseSettingsDlg.h" #include "dialogs/PasswordDlg.h" @@ -133,6 +132,7 @@ void KeepassMainWindow::setupConnections(){ connect(HelpAboutAction,SIGNAL(triggered()),this,SLOT(OnHelpAbout())); + connect(GroupView,SIGNAL(entryDropped()),EntryView,SLOT(updateItems())); connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut())); connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this, SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*))); @@ -251,15 +251,12 @@ Q_ASSERT(r==1); db = new PwDatabase(); GroupView->db=db; EntryView->db=db; -if(PasswordDlg.password!="" && PasswordDlg.keyfile==""){ -db->CalcMasterKeyByPassword(PasswordDlg.password); -} -if(PasswordDlg.password=="" && PasswordDlg.keyfile!=""){ -db->CalcMasterKeyByFile(PasswordDlg.keyfile); -} -if(PasswordDlg.password!="" && PasswordDlg.keyfile!=""){ -db->CalcMasterKeyByFileAndPw(PasswordDlg.keyfile,PasswordDlg.password); -} +if(PasswordDlg.password!="" && PasswordDlg.keyfile=="") + db->CalcMasterKeyByPassword(PasswordDlg.password); +if(PasswordDlg.password=="" && PasswordDlg.keyfile!="") + db->CalcMasterKeyByFile(PasswordDlg.keyfile); +if(PasswordDlg.password!="" && PasswordDlg.keyfile!="") + db->CalcMasterKeyByFileAndPw(PasswordDlg.keyfile,PasswordDlg.password); QString err; StatusBarGeneral->setText(tr("Loading Database...")); if(db->loadDatabase(filename,err)==true){ @@ -312,17 +309,31 @@ return true; void KeepassMainWindow::OnFileNew(){ if(FileOpen) if(!closeDatabase())return; +CPasswordDialog dlg(this,"PasswordDlg",true,false,true); +dlg.setCaption("New Database"); db=new PwDatabase(); -CChangeKeyDlg dlg(this,db); if(dlg.exec()==1){ -setCaption(tr("KeePassX - %1").arg(tr("[new]"))); -GroupView->db=db; -EntryView->db=db; -GroupView->updateItems(); -EntryView->updateItems(0); -setStateFileOpen(true); -setStateFileModified(true); -FileOpen=true; + if(dlg.KeyType==BOTH || dlg.KeyType==KEYFILE){ + if(!db->createKeyFile(dlg.keyfile)){ + QMessageBox::warning(this,tr("Error"),tr("Could not create key file. The following error occured:\n%1").arg(db->getError()),tr("OK"),"","",0,0); + delete db; db=NULL; + return; + } + } + if(dlg.password!="" && dlg.keyfile=="") + db->CalcMasterKeyByPassword(dlg.password); + if(dlg.password=="" && dlg.keyfile!="") + db->CalcMasterKeyByFile(dlg.keyfile); + if(dlg.password!="" && dlg.keyfile!="") + db->CalcMasterKeyByFileAndPw(dlg.keyfile,dlg.password); + setCaption(tr("KeePassX - %1").arg(tr("[new]"))); + GroupView->db=db; + EntryView->db=db; + GroupView->updateItems(); + EntryView->updateItems(0); + setStateFileOpen(true); + setStateFileModified(true); + FileOpen=true; } else delete db; } @@ -552,8 +563,23 @@ if(dlg.exec())setStateFileModified(true); } void KeepassMainWindow::OnFileChangeKey(){ -CChangeKeyDlg dlg(this,db,"ChangeKeyDialog"); -if(dlg.exec()) setStateFileModified(true); +CPasswordDialog dlg(this,"PasswordDlg",true,false,true); +dlg.setCaption(db->filename); +if(dlg.exec()==1){ + if(dlg.KeyType==BOTH || dlg.KeyType==KEYFILE){ + if(!db->createKeyFile(dlg.keyfile)){ + QMessageBox::warning(this,tr("Error"),tr("Could not create key file. The following error occured:\n%1").arg(db->getError()),tr("OK"),"","",0,0); + return; + } + } + if(dlg.password!="" && dlg.keyfile=="") + db->CalcMasterKeyByPassword(dlg.password); + if(dlg.password=="" && dlg.keyfile!="") + db->CalcMasterKeyByFile(dlg.keyfile); + if(dlg.password!="" && dlg.keyfile!="") + db->CalcMasterKeyByFileAndPw(dlg.keyfile,dlg.password); + setStateFileModified(true); +} } diff --git a/src/src.pro b/src/src.pro index 8c0de9c..69f6bc9 100755 --- a/src/src.pro +++ b/src/src.pro @@ -16,7 +16,6 @@ FORMS += forms/EditGroupDlg.ui \ forms/SearchDlg.ui \ forms/AboutDlg.ui \ forms/SettingsDlg.ui \ - forms/ChangeKeyDlg.ui \ forms/MainWindow.ui \ forms/SimplePasswordDlg.ui \ forms/DatabaseSettingsDlg.ui \ @@ -43,7 +42,6 @@ HEADERS += lib/IniReader.h \ dialogs/AboutDlg.h \ dialogs/EditGroupDlg.h \ dialogs/SearchDlg.h \ - dialogs/ChangeKeyDlg.h \ dialogs/SettingsDlg.h \ dialogs/DatabaseSettingsDlg.h \ dialogs/PasswordDlg.h \ @@ -77,7 +75,6 @@ SOURCES += lib/IniReader.cpp \ dialogs/AboutDlg.cpp \ dialogs/EditGroupDlg.cpp \ dialogs/SearchDlg.cpp \ - dialogs/ChangeKeyDlg.cpp \ dialogs/SettingsDlg.cpp \ dialogs/DatabaseSettingsDlg.cpp \ dialogs/PasswordDlg.cpp \