removed CChangeKeyDlg git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@55 b624d157-de02-0410-bad0-e51aec6abb33master
parent
e0a2197b53
commit
416c7d70d3
@ -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 <qlineedit.h> |
||||
#include <qcombobox.h> |
||||
#include <qpushbutton.h> |
||||
#include <qcheckbox.h> |
||||
#include <qdir.h> |
||||
#include <q3filedialog.h> |
||||
#include <qmessagebox.h> |
||||
|
||||
|
||||
|
||||
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<Paths.count();i++){ |
||||
Paths[i]="/media/"+Paths[i]; |
||||
} |
||||
Paths.prepend("< none >"); |
||||
} |
||||
for(int i=0;i<Paths.count();i++){ |
||||
Combo_Dirs->insertItem(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"
|
||||
|
@ -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 <qstringlist.h> |
||||
#include <q3valuelist.h> |
||||
#include <qfile.h> |
||||
#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<bool> IsFile; |
||||
|
||||
public: |
||||
QString keyfile; |
||||
QFile* pKeyFile; |
||||
QString password; |
||||
}; |
||||
|
||||
#endif |
||||
|
@ -1,264 +0,0 @@ |
||||
<ui version="4.0" > |
||||
<author></author> |
||||
<comment></comment> |
||||
<exportmacro></exportmacro> |
||||
<class>ChangeKeyDialog</class> |
||||
<widget class="QDialog" name="ChangeKeyDialog" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>560</width> |
||||
<height>270</height> |
||||
</rect> |
||||
</property> |
||||
<property name="sizePolicy" > |
||||
<sizepolicy> |
||||
<hsizetype>0</hsizetype> |
||||
<vsizetype>0</vsizetype> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize" > |
||||
<size> |
||||
<width>560</width> |
||||
<height>270</height> |
||||
</size> |
||||
</property> |
||||
<property name="maximumSize" > |
||||
<size> |
||||
<width>560</width> |
||||
<height>270</height> |
||||
</size> |
||||
</property> |
||||
<property name="windowTitle" > |
||||
<string>Change Master Key</string> |
||||
</property> |
||||
<widget class="QLabel" name="Banner" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>560</width> |
||||
<height>50</height> |
||||
</rect> |
||||
</property> |
||||
<property name="sizePolicy" > |
||||
<sizepolicy> |
||||
<hsizetype>0</hsizetype> |
||||
<vsizetype>0</vsizetype> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="pixmap" > |
||||
<pixmap/> |
||||
</property> |
||||
<property name="scaledContents" > |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
<widget class="Q3GroupBox" name="groupBox1" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>10</x> |
||||
<y>80</y> |
||||
<width>540</width> |
||||
<height>150</height> |
||||
</rect> |
||||
</property> |
||||
<property name="title" > |
||||
<string>Key</string> |
||||
</property> |
||||
<property name="orientation" > |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<widget class="QLineEdit" name="Edit_Password" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>200</x> |
||||
<y>30</y> |
||||
<width>310</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLineEdit" name="Edit_Password_2" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>200</x> |
||||
<y>60</y> |
||||
<width>310</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
</widget> |
||||
<widget class="QCheckBox" name="CheckBox_Both" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>10</x> |
||||
<y>120</y> |
||||
<width>521</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>Use password AND key file</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="textLabel3" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>10</x> |
||||
<y>90</y> |
||||
<width>191</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>Key file or directory:</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="textLabel1_3" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>10</x> |
||||
<y>60</y> |
||||
<width>191</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>Password Repetition:</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QLabel" name="textLabel2" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>10</x> |
||||
<y>30</y> |
||||
<width>191</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>Password:</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QPushButton" name="ButtonChangeEchoMode" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>510</x> |
||||
<y>30</y> |
||||
<width>20</width> |
||||
<height>20</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>...</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QPushButton" name="Button_Browse" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>450</x> |
||||
<y>90</y> |
||||
<width>80</width> |
||||
<height>22</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>&Browse...</string> |
||||
</property> |
||||
<property name="shortcut" > |
||||
<string>Alt+B</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QComboBox" name="Combo_Dirs" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>201</x> |
||||
<y>90</y> |
||||
<width>240</width> |
||||
<height>21</height> |
||||
</rect> |
||||
</property> |
||||
</widget> |
||||
</widget> |
||||
<widget class="QLabel" name="textLabel1" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>0</x> |
||||
<y>56</y> |
||||
<width>450</width> |
||||
<height>16</height> |
||||
</rect> |
||||
</property> |
||||
<property name="frameShape" > |
||||
<enum>QFrame::NoFrame</enum> |
||||
</property> |
||||
<property name="frameShadow" > |
||||
<enum>QFrame::Plain</enum> |
||||
</property> |
||||
<property name="text" > |
||||
<string>Enter a Password and/or choose a key file.</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QPushButton" name="ButtonCancel" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>457</x> |
||||
<y>240</y> |
||||
<width>90</width> |
||||
<height>26</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>&Cancel</string> |
||||
</property> |
||||
<property name="shortcut" > |
||||
<string>Alt+C</string> |
||||
</property> |
||||
</widget> |
||||
<widget class="QPushButton" name="ButtonOK" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>360</x> |
||||
<y>240</y> |
||||
<width>90</width> |
||||
<height>26</height> |
||||
</rect> |
||||
</property> |
||||
<property name="text" > |
||||
<string>O&K</string> |
||||
</property> |
||||
<property name="shortcut" > |
||||
<string>Alt+K</string> |
||||
</property> |
||||
</widget> |
||||
</widget> |
||||
<layoutdefault spacing="6" margin="11" /> |
||||
<pixmapfunction></pixmapfunction> |
||||
<customwidgets> |
||||
<customwidget> |
||||
<class>Q3GroupBox</class> |
||||
<extends></extends> |
||||
<header>Qt3Support/Q3GroupBox</header> |
||||
<container>1</container> |
||||
<pixmap></pixmap> |
||||
</customwidget> |
||||
</customwidgets> |
||||
<tabstops> |
||||
<tabstop>Edit_Password</tabstop> |
||||
<tabstop>Edit_Password_2</tabstop> |
||||
<tabstop>Combo_Dirs</tabstop> |
||||
<tabstop>Button_Browse</tabstop> |
||||
<tabstop>CheckBox_Both</tabstop> |
||||
<tabstop>ButtonOK</tabstop> |
||||
<tabstop>ButtonCancel</tabstop> |
||||
<tabstop>ButtonChangeEchoMode</tabstop> |
||||
</tabstops> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
Reference in new issue