git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@2 b624d157-de02-0410-bad0-e51aec6abb33

master
tariq 19 years ago
parent 434e6a5aa3
commit a8a9a64142
  1. 27
      src/PwManager.cpp
  2. 1
      src/PwManager.h
  3. 8
      src/PwmConfig.cpp
  4. 4
      src/PwmConfig.h
  5. 298
      src/forms/ui_MainWindow.ui
  6. 2
      src/main.cpp
  7. 128
      src/mainwindow.cpp
  8. 8
      src/mainwindow.h
  9. 33
      src/pwsafe.cpp
  10. 1
      src/pwsafe.h

@ -93,7 +93,8 @@ if(CryptoAlgorithmus == ALGO_AES)
// Initialize Rijndael algorithm
if(aes.init(Rijndael::CBC, Rijndael::Decrypt, FinalKey,
Rijndael::Key32Bytes, EncryptionIV) != RIJNDAEL_SUCCESS)
{return false;}
{err=trUtf8("AES-Initialisierung fehlgeschlagen");
return false;}
// Decrypt! The first bytes aren't encrypted (that's the header)
crypto_size = (unsigned long)aes.padDecrypt((UINT8 *)buffer + DB_HEADER_SIZE,
total_size - DB_HEADER_SIZE, (UINT8 *)buffer + DB_HEADER_SIZE);
@ -106,7 +107,7 @@ else if(CryptoAlgorithmus == ALGO_TWOFISH)
total_size - DB_HEADER_SIZE, (UINT8 *)buffer + DB_HEADER_SIZE);
}
if((crypto_size > 2147483446) || (crypto_size == 0)){return false;}
if((crypto_size > 2147483446) || (crypto_size == 0)){err=trUtf8("Unerwarteter Wert für 'crypto_size'"); return false;}
sha256_starts(&sha32);
sha256_update(&sha32,(unsigned char *)buffer + DB_HEADER_SIZE,crypto_size);
@ -257,6 +258,15 @@ if(FileSize == 32){
file.close();
return false;}
}
else if(FileSize == 64){
char hex[64];
if(file.readBlock(hex,64) != 64){
file.close();
return false;}
file.close();
if(!convHexToBinaryKey(hex,(char*)MasterKey)) return false;
}
else
{
sha256_context sha32;
@ -913,3 +923,16 @@ if(!isEntrySidInUse(sid))break;
}
return sid;
}
bool PwDatabase::convHexToBinaryKey(char* HexKey, char* dst){
QString hex=QString::fromAscii(HexKey,64);
for(int i=0; i<64; i+=2){
bool err;
UINT8 bin;
bin=hex.mid(i,2).toUInt(&err,16);
if(!err){
qWarning("Invalid Hex Key\n");
return false;}
memcpy(dst+(i/2),&bin,1);
}
}

@ -74,6 +74,7 @@ private:
bool isEntrySidInUse(UINT32 sID);
UINT32 getNewGroupId();
UINT32 getNewEntrySid();
bool convHexToBinaryKey(char* HexKey, char* dst);
};
#endif

@ -23,8 +23,8 @@
#include <qdir.h>
#include <iostream.h>
bool CConfig::loadFromIni(){
CIniFile ini(QDir::homeDirPath()+"/.keepass/config");
bool CConfig::loadFromIni(QString filename){
CIniFile ini(filename);
ini.ReadFile();
ClipboardTimeOut=ini.GetValueI("Options","ClipboardTimeOut",20);
Toolbar=ini.GetValueB("UI","ShowToolbar",true);
@ -48,8 +48,8 @@ ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
return true;
}
bool CConfig::saveToIni(){
CIniFile ini(QDir::homeDirPath()+"/.keepass/config");
bool CConfig::saveToIni(QString filename){
CIniFile ini(filename);
ini.ReadFile();
ini.SetValueI("Options","ClipboardTimeOut",ClipboardTimeOut);
ini.SetValueB("UI","ShowToolbar",Toolbar);

@ -46,8 +46,8 @@ public:
QString PwGenCharList;
bool ExpandGroupTree;
bool loadFromIni();
bool saveToIni();
bool loadFromIni(QString filename);
bool saveToIni(QString filename);
private:
void ParseColumnString(QString str, bool* dst);

@ -1118,70 +1118,58 @@
</images>
<connections>
<connection>
<sender>MainFrame</sender>
<signal>pixmapSizeChanged(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnMainWinResize()</slot>
</connection>
<connection>
<sender>File_Open</sender>
<sender>DEBUG_DbStructure</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileOpen()</slot>
</connection>
<connection>
<sender>GroupView</sender>
<signal>selectionChanged(QListViewItem*)</signal>
<receiver>MainFrame</receiver>
<slot>OnGroupChanged(QListViewItem*)</slot>
<slot>DEBUG_OnPrintDbStucture()</slot>
</connection>
<connection>
<sender>File_Close</sender>
<sender>Edit_AddEntry</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnMenu_closeDB()</slot>
<slot>OnAddEntry()</slot>
</connection>
<connection>
<sender>File_Save</sender>
<sender>Edit_CopyEntry</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileSave()</slot>
<slot>OnCopyEntry()</slot>
</connection>
<connection>
<sender>File_SaveAs</sender>
<sender>Edit_DeleteEntry</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileSaveAs()</slot>
<slot>OnDeleteEntry()</slot>
</connection>
<connection>
<sender>tooButtonOpen</sender>
<signal>clicked()</signal>
<sender>Edit_DeleteGroup</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileOpen()</slot>
<slot>OnDeleteGroup()</slot>
</connection>
<connection>
<sender>toolButtonSave</sender>
<signal>clicked()</signal>
<sender>Edit_EditEntry</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileSave()</slot>
<slot>OnEditEntry()</slot>
</connection>
<connection>
<sender>File_Exit</sender>
<sender>Edit_GlobalSearch</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnMenuExit()</slot>
<slot>OnGlobalSearch()</slot>
</connection>
<connection>
<sender>EntryView</sender>
<signal>selectionChanged(QListViewItem*)</signal>
<sender>Edit_GroupProperties</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryChanged(QListViewItem*)</slot>
<slot>OnEditGroup()</slot>
</connection>
<connection>
<sender>EntryView</sender>
<signal>doubleClicked(QListViewItem*,const QPoint&amp;,int)</signal>
<sender>Edit_GroupSearch</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryDoubleClicked(QListViewItem*,const QPoint&amp;,int)</slot>
<slot>OnGroupSearch()</slot>
</connection>
<connection>
<sender>Edit_NewGroup</sender>
@ -1196,22 +1184,22 @@
<slot>OnAddSubGroup()</slot>
</connection>
<connection>
<sender>Edit_GroupProperties</sender>
<sender>Edit_OpenURL</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnEditGroup()</slot>
<slot>OnOpenURL()</slot>
</connection>
<connection>
<sender>Edit_DeleteGroup</sender>
<sender>Edit_PasswordToClipboard</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnDeleteGroup()</slot>
<slot>OnPasswordToClipboard()</slot>
</connection>
<connection>
<sender>Edit_PasswordToClipboard</sender>
<sender>Edit_SaveAttachment</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnPasswordToClipboard()</slot>
<slot>OnSaveAttachment()</slot>
</connection>
<connection>
<sender>Edit_UserNameToClipboard</sender>
@ -1220,82 +1208,100 @@
<slot>OnUserNameToClipboard()</slot>
</connection>
<connection>
<sender>Edit_OpenURL</sender>
<sender>EntryView</sender>
<signal>selectionChanged(QListViewItem*)</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryChanged(QListViewItem*)</slot>
</connection>
<connection>
<sender>EntryView</sender>
<signal>doubleClicked(QListViewItem*,const QPoint&amp;,int)</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryDoubleClicked(QListViewItem*,const QPoint&amp;,int)</slot>
</connection>
<connection>
<sender>EntryView</sender>
<signal>rightButtonClicked(QListViewItem*,const QPoint&amp;,int)</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryRightClicked(QListViewItem*,const QPoint&amp;,int)</slot>
</connection>
<connection>
<sender>Extras_Language</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnOpenURL()</slot>
<slot>OnExtrasLanguage()</slot>
</connection>
<connection>
<sender>Edit_SaveAttachment</sender>
<sender>Extras_Settings</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnSaveAttachment()</slot>
<slot>OnSettings()</slot>
</connection>
<connection>
<sender>Edit_AddEntry</sender>
<sender>File_ChangeKey</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnAddEntry()</slot>
<slot>OnChangeDbKey()</slot>
</connection>
<connection>
<sender>Edit_EditEntry</sender>
<sender>File_Close</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnEditEntry()</slot>
<slot>OnMenu_closeDB()</slot>
</connection>
<connection>
<sender>Edit_CopyEntry</sender>
<sender>File_Exit</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnCopyEntry()</slot>
<slot>OnMenuExit()</slot>
</connection>
<connection>
<sender>Edit_DeleteEntry</sender>
<sender>File_ImportKWalletXML</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnDeleteEntry()</slot>
<slot>OnImportKWalletXML()</slot>
</connection>
<connection>
<sender>Edit_GroupSearch</sender>
<sender>File_Import_PwManager</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnGroupSearch()</slot>
<slot>OnImportPwManagerFile()</slot>
</connection>
<connection>
<sender>toolButtonAddEntry</sender>
<signal>clicked()</signal>
<sender>File_New</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnAddEntry()</slot>
<slot>OnFileNew()</slot>
</connection>
<connection>
<sender>toolButtonEditEntry</sender>
<signal>clicked()</signal>
<sender>File_Open</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnEditEntry()</slot>
<slot>OnFileOpen()</slot>
</connection>
<connection>
<sender>toolButtonDeleteEntry</sender>
<signal>clicked()</signal>
<sender>File_Save</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnDeleteEntry()</slot>
<slot>OnFileSave()</slot>
</connection>
<connection>
<sender>toolButtonPasswordToClipboard</sender>
<signal>clicked()</signal>
<sender>File_SaveAs</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnPasswordToClipboard()</slot>
<slot>OnFileSaveAs()</slot>
</connection>
<connection>
<sender>toolButtonUserNameToClipboard</sender>
<signal>clicked()</signal>
<sender>File_Settings</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnUserNameToClipboard()</slot>
<slot>OnDbSettings()</slot>
</connection>
<connection>
<sender>EntryView</sender>
<signal>rightButtonClicked(QListViewItem*,const QPoint&amp;,int)</signal>
<sender>GroupView</sender>
<signal>selectionChanged(QListViewItem*)</signal>
<receiver>MainFrame</receiver>
<slot>OnEntryRightClicked(QListViewItem*,const QPoint&amp;,int)</slot>
<slot>OnGroupChanged(QListViewItem*)</slot>
</connection>
<connection>
<sender>GroupView</sender>
@ -1304,148 +1310,148 @@
<slot>OnGroupRightClicked(QListViewItem*,const QPoint&amp;,int)</slot>
</connection>
<connection>
<sender>File_Settings</sender>
<signal>activated()</signal>
<sender>GroupView</sender>
<signal>dropped(QDropEvent*)</signal>
<receiver>MainFrame</receiver>
<slot>OnDbSettings()</slot>
<slot>OnGroupViewDrop(QDropEvent*)</slot>
</connection>
<connection>
<sender>File_ChangeKey</sender>
<sender>Help_About</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnChangeDbKey()</slot>
<slot>OnHelpAbout()</slot>
</connection>
<connection>
<sender>File_New</sender>
<sender>Help_AboutQt</sender>
<signal>activated()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileNew()</slot>
<slot>OnHelpAboutQt()</slot>
</connection>
<connection>
<sender>View_ShowToolBar</sender>
<signal>toggled(bool)</signal>
<sender>MainFrame</sender>
<signal>pixmapSizeChanged(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnViewToolbarToggled(bool)</slot>
<slot>OnMainWinResize()</slot>
</connection>
<connection>
<sender>View_ShowEntryDetails</sender>
<signal>toggled(bool)</signal>
<sender>tooButtonOpen</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnViewEntryDetailsToggled(bool)</slot>
<slot>OnFileOpen()</slot>
</connection>
<connection>
<sender>toolButtonNew</sender>
<sender>toolButtonAddEntry</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnFileNew()</slot>
<slot>OnAddEntry()</slot>
</connection>
<connection>
<sender>Extras_Settings</sender>
<signal>activated()</signal>
<sender>toolButtonDeleteEntry</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnSettings()</slot>
<slot>OnDeleteEntry()</slot>
</connection>
<connection>
<sender>Help_About</sender>
<signal>activated()</signal>
<sender>toolButtonEditEntry</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnHelpAbout()</slot>
<slot>OnEditEntry()</slot>
</connection>
<connection>
<sender>View_Column_Expire</sender>
<signal>toggled(bool)</signal>
<sender>toolButtonNew</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnExpireToggled(bool)</slot>
<slot>OnFileNew()</slot>
</connection>
<connection>
<sender>View_Column_Attachment</sender>
<signal>toggled(bool)</signal>
<sender>toolButtonPasswordToClipboard</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnAttachmentToggled(bool)</slot>
<slot>OnPasswordToClipboard()</slot>
</connection>
<connection>
<sender>View_Column_Username</sender>
<signal>toggled(bool)</signal>
<sender>toolButtonSave</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnUsernameToggled(bool)</slot>
<slot>OnFileSave()</slot>
</connection>
<connection>
<sender>View_Column_Comment</sender>
<signal>toggled(bool)</signal>
<sender>toolButtonSearch</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnCommentToggled(bool)</slot>
<slot>OnGlobalSearch()</slot>
</connection>
<connection>
<sender>View_Column_Creation</sender>
<signal>toggled(bool)</signal>
<sender>toolButtonUserNameToClipboard</sender>
<signal>clicked()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnCreationToggled(bool)</slot>
<slot>OnUserNameToClipboard()</slot>
</connection>
<connection>
<sender>View_Column_LastMod</sender>
<signal>toggled(bool)</signal>
<sender>toolSearch</sender>
<signal>returnPressed()</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnLastModToggled(bool)</slot>
<slot>OnQickSearch()</slot>
</connection>
<connection>
<sender>View_Column_Password</sender>
<sender>View_Column_Attachment</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnPasswordToggled(bool)</slot>
<slot>OnView_ColumnAttachmentToggled(bool)</slot>
</connection>
<connection>
<sender>View_Column_LastAccess</sender>
<sender>View_Column_Comment</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnLastAccessToggled(bool)</slot>
<slot>OnView_ColumnCommentToggled(bool)</slot>
</connection>
<connection>
<sender>View_Column_URL</sender>
<sender>View_Column_Creation</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnUrlToggled(bool)</slot>
<slot>OnView_ColumnCreationToggled(bool)</slot>
</connection>
<connection>
<sender>View_Column_Title</sender>
<sender>View_Column_Expire</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnView_ColumnTitleToggled(bool)</slot>
<slot>OnView_ColumnExpireToggled(bool)</slot>
</connection>
<connection>
<sender>Edit_GlobalSearch</sender>
<signal>activated()</signal>
<sender>View_Column_LastAccess</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnGlobalSearch()</slot>
<slot>OnView_ColumnLastAccessToggled(bool)</slot>
</connection>
<connection>
<sender>Extras_Language</sender>
<signal>activated()</signal>
<sender>View_Column_LastMod</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnExtrasLanguage()</slot>
<slot>OnView_ColumnLastModToggled(bool)</slot>
</connection>
<connection>
<sender>toolButtonSearch</sender>
<signal>clicked()</signal>
<sender>View_Column_Password</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnGlobalSearch()</slot>
<slot>OnView_ColumnPasswordToggled(bool)</slot>
</connection>
<connection>
<sender>toolSearch</sender>
<signal>returnPressed()</signal>
<sender>View_Column_Title</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnQickSearch()</slot>
<slot>OnView_ColumnTitleToggled(bool)</slot>
</connection>
<connection>
<sender>DEBUG_DbStructure</sender>
<signal>activated()</signal>
<sender>View_Column_URL</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>DEBUG_OnPrintDbStucture()</slot>
<slot>OnView_ColumnUrlToggled(bool)</slot>
</connection>
<connection>
<sender>File_Import_PwManager</sender>
<signal>activated()</signal>
<sender>View_Column_Username</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnImportPwManagerFile()</slot>
<slot>OnView_ColumnUsernameToggled(bool)</slot>
</connection>
<connection>
<sender>View_HidePasswords</sender>
@ -1460,22 +1466,16 @@
<slot>OnView_HideUsernamesToggled(bool)</slot>
</connection>
<connection>
<sender>GroupView</sender>
<signal>dropped(QDropEvent*)</signal>
<receiver>MainFrame</receiver>
<slot>OnGroupViewDrop(QDropEvent*)</slot>
</connection>
<connection>
<sender>Help_AboutQt</sender>
<signal>activated()</signal>
<sender>View_ShowEntryDetails</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnHelpAboutQt()</slot>
<slot>OnViewEntryDetailsToggled(bool)</slot>
</connection>
<connection>
<sender>File_ImportKWalletXML</sender>
<signal>activated()</signal>
<sender>View_ShowToolBar</sender>
<signal>toggled(bool)</signal>
<receiver>MainFrame</receiver>
<slot>OnImportKWalletXML()</slot>
<slot>OnViewToolbarToggled(bool)</slot>
</connection>
</connections>
<slots>

@ -18,7 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <iostream.h>
#include "pwsafe.h"
#include <qapplication.h>

@ -60,7 +60,7 @@
#include "import/Import_PwManager.h"
#include "import/Import_KWalletXml.h"
CMainWindow::CMainWindow(QApplication* app,QWidget* parent,const char* name, WFlags fl)
CMainWindow::CMainWindow(QApplication* app,QString ArgFile,QString ArgCfg,QWidget* parent,const char* name, WFlags fl)
: MainFrame(parent,name,fl)
{
FileOpen=false;
@ -70,12 +70,23 @@ parentWidget()->setCaption(tr("Keepass Passwortsafe"));
SecString::generateSessionKey();
// Config //
if(ArgCfg==""){
if(!QDir(QDir::homeDirPath()+"/.keepass").exists()){
QDir conf(QDir::homeDirPath());
if(!conf.mkdir(".keepass")){
cout << trUtf8("Warnung: Verzeichnis ~/.keepass konnte nicht erstellt werden.") << endl;}
}
config.loadFromIni();
IniFilename=QDir::homeDirPath()+"/.keepass/config";
config.loadFromIni(IniFilename);
}
else
{
IniFilename=ArgCfg;
config.loadFromIni(IniFilename);
}
CGroup::UI_ExpandByDefault=config.ExpandGroupTree;
// Language //
@ -154,7 +165,6 @@ connect(GroupView,SIGNAL(expanded(QListViewItem*)),this, SLOT(OnGroupItemExpande
// MainWnd //
CurrentGroup=NULL;
CurrentEntry=NULL;
Clipboard=QApplication::clipboard();
GroupView->setSorting(-1);
@ -229,6 +239,26 @@ if(config.ListView_HideUsernames){
else{
View_HideUsernames->setOn(false);}
////////////////////////////////////////////////
GroupView->addColumn(trUtf8("Gruppen"));
GroupView->setColumnWidth(0,GroupView->width()-4);
SetupColumns();
InitMenus();
if(ArgFile==""){
if(config.OpenLast && config.LastFile!="")
{QFileInfo file(config.LastFile);
if(file.exists() && file.isFile())OpenDatabase(config.LastFile);
else config.LastFile="";}
}
else
{
QFileInfo file(ArgFile);
if(file.exists() && file.isFile())OpenDatabase(ArgFile);
else cout << "file not found "<< ArgFile << endl;
}
}
void CMainWindow::LoadImg(QString name,QImage& tmpImg){
@ -245,7 +275,7 @@ if(tmpImg.load(appdir+"/../share/keepass/"+name)==false){
CMainWindow::~CMainWindow()
{
OnClose();
if(!config.saveToIni())
if(!config.saveToIni(IniFilename))
QMessageBox::warning(this,tr("Warnung"),trUtf8("Die Konfigurationsdatei konnte nicht gespeichert werden.Stellen Sie sicher, dass\nSie Schreibrechte im Verzeichnis ~/.keepass besitzen."),tr("OK"),"","",0.0);
if(translator)delete translator;
delete [] EntryIcons;
@ -406,10 +436,6 @@ EntryView->setColumnWidth(i,width);
void CMainWindow::updateEntryView(){
// Achtung:
// Die ->pEntry bzw ->pGroup Zeiger sind zu diesem Zeitpunkt ungültig!
if(CurrentEntry){
}
EntryView->clear();
EntryItems.clear();
if(!CurrentGroup)return;
@ -452,24 +478,9 @@ tmp->setText(j++,entry->BinaryDesc);}
}
void CMainWindow::OnEntryChanged(QListViewItem* item){
SetEditMenuState(STATE_SingleEntrySelected);
CEntry& entry=*((EntryItem*)item)->pEntry;
QString str=trUtf8("<B>Gruppe: </B>%1 <B>Titel: </B>%2 <B>Benutzername: </B>%3 <B>URL: </B>%4 <B>Passwort: </B>%5 <B>Erstellt: </B>%6 <B>letzte Änderung: </B>%7 <B>letzter Zugriff: </B>%8 <B>gültig bis: </B>%9");
str= str.arg(CurrentGroup->pGroup->Name)
.arg(entry.Title)
.arg(entry.UserName)
.arg(entry.URL)
.arg(entry.Password.getString())
.arg(entry.Creation.GetString(0))
.arg(entry.LastMod.GetString(0))
.arg(entry.LastAccess.GetString(0))
.arg(entry.Expire.GetString(0));
SummaryField->setText(str);
entry.Password.delRef();
CurrentEntry=(EntryItem*)item;
if(item)SetEditMenuState(STATE_SingleEntrySelected);
else SetEditMenuState(STATE_NoEntrySelected);
updateEntryDetails((EntryItem*)item);
}
@ -480,14 +491,8 @@ QValueList<int> s;
s.push_back(25); s.push_back(100);
parentWidget()->resize(750,450);
splitter->setSizes(s);
GroupView->addColumn(trUtf8("Gruppen"));
GroupView->setColumnWidth(0,GroupView->width()-4);
SetupColumns();
InitMenus();
if(config.OpenLast && config.LastFile!="")
{ QFileInfo file(config.LastFile);
if(file.exists() && file.isFile())OpenDatabase(config.LastFile);
else config.LastFile="";}
////////////////////////////////////
/*Beim öffnen der Datenbank ist ein Fehler aufgetreten.
@ -761,14 +766,14 @@ setModFlag(true);
void CMainWindow::OnPasswordToClipboard()
{
Clipboard->setText(CurrentEntry->pEntry->Password.getString(),QClipboard::Clipboard);
Clipboard->setText(currentEntry()->Password.getString(),QClipboard::Clipboard);
ClipboardTimer.start(config.ClipboardTimeOut*1000,true);
CurrentEntry->pEntry->Password.delRef();
currentEntry()->Password.delRef();
}
void CMainWindow::OnUserNameToClipboard()
{
Clipboard->setText(CurrentEntry->pEntry->UserName, QClipboard::Clipboard);
Clipboard->setText(currentEntry()->UserName, QClipboard::Clipboard);
ClipboardTimer.start(config.ClipboardTimeOut*1000,true);
}
@ -778,7 +783,7 @@ Clipboard->clear(QClipboard::Clipboard); //löscht nicht den KDE-Klipper
void CMainWindow::OnOpenURL()
{
OpenURL(CurrentEntry->pEntry->URL);
OpenURL(currentEntry()->URL);
}
void CMainWindow::OpenURL(QString url){
@ -789,7 +794,7 @@ browser.start();
void CMainWindow::OnSaveAttachment()
{
CEntry& entry=*CurrentEntry->pEntry;
CEntry& entry=*currentEntry();
if(entry.BinaryDataLength==0){
QMessageBox::information(NULL,trUtf8("Hinweis"),trUtf8("Dieser Eintrag hat keinen Dateianhang."),"OK");
return;
@ -864,7 +869,7 @@ if(pDlg->exec()){
void CMainWindow::OnEditEntry()
{
CEditEntryDlg* pDlg= new CEditEntryDlg(this,0,true);
pDlg->entry=CurrentEntry->pEntry;
pDlg->entry=currentEntry();
pDlg->exec();
updateEntryView();
if(pDlg->ModFlag)setModFlag(true);
@ -872,7 +877,7 @@ if(pDlg->ModFlag)setModFlag(true);
void CMainWindow::OnCopyEntry()
{
CEntry &src=*CurrentEntry->pEntry;
CEntry &src=*currentEntry();
CEntry entry=src;
entry.sID=(*(db->Entries.end()-1)).sID+1;
while(1){
@ -900,7 +905,7 @@ setModFlag(true);
void CMainWindow::OnDeleteEntry()
{
db->deleteEntry(CurrentEntry->pEntry);
db->deleteEntry(currentEntry());
updateEntryView();
setModFlag(true);
}
@ -1311,6 +1316,7 @@ void CMainWindow::OnView_HideUsernamesToggled(bool state)
{
config.ListView_HideUsernames=state;
updateEntryView();
updateEntryDetails();
}
@ -1318,6 +1324,7 @@ void CMainWindow::OnView_HidePasswordsToggled(bool state)
{
config.ListView_HidePasswords=state;
updateEntryView();
updateEntryDetails();
}
void CMainWindow::OnGroupViewDrop(QDropEvent* e)
@ -1375,4 +1382,41 @@ FileOpen=true;
}
void CMainWindow::updateEntryDetails(EntryItem* pItem){
if(pItem==NULL){
SummaryField->setText("");
return;}
CEntry& entry=*pItem->pEntry;
QString str=trUtf8("<B>Gruppe: </B>%1 <B>Titel: </B>%2 <B>Benutzername: </B>%3 <B>URL: </B>%4 <B>Passwort: </B>%5 <B>Erstellt: </B>%6 <B>letzte Änderung: </B>%7 <B>letzter Zugriff: </B>%8 <B>gültig bis: </B>%9");
str=str.arg(CurrentGroup->pGroup->Name).arg(entry.Title);
if(!config.ListView_HideUsernames) str=str.arg(entry.UserName);
else str=str.arg("****");
str=str.arg(entry.URL);
if(!config.ListView_HidePasswords) str=str.arg(entry.Password.getString());
else str=str.arg("****");
str=str.arg(entry.Creation.GetString(0))
.arg(entry.LastMod.GetString(0))
.arg(entry.LastAccess.GetString(0))
.arg(entry.Expire.GetString(0));
SummaryField->setText(str);
entry.Password.delRef();
}
void CMainWindow::updateEntryDetails(){
updateEntryDetails( (EntryItem*)EntryView->currentItem() );
}
EntryItem* CMainWindow::currentEntryItem(){
return (EntryItem*)EntryView->currentItem();
}
CEntry* CMainWindow::currentEntry(){
return ((EntryItem*)EntryView->currentItem())->pEntry;
}

@ -40,7 +40,7 @@ Q_OBJECT
public:
/*$PUBLIC_FUNCTIONS$*/
CMainWindow(QApplication* app, QWidget* parent = 0,const char* name = 0, WFlags fl = 0 );
CMainWindow(QApplication* app,QString ArgFile,QString ArgCfg, QWidget* parent = 0,const char* name = 0, WFlags fl = 0 );
~CMainWindow();
protected:
/*$PROTECTED_FUNCTIONS$*/
@ -149,8 +149,11 @@ public:
void setCurrentGroup(GroupItem* item);
void updateEntryView();
void updateGroupView();
void updateEntryDetails();
void updateEntryDetails(EntryItem* item);
inline EntryItem* currentEntryItem();
inline CEntry* currentEntry();
GroupItem* CurrentGroup;
EntryItem* CurrentEntry;
QClipboard* Clipboard;
private:
@ -161,6 +164,7 @@ private:
bool modflag;
void setModFlag(bool);
bool FileOpen;
QString IniFilename;
};
#endif

@ -22,8 +22,32 @@
#include "pwsafe.h"
PwSafe::PwSafe(QApplication* app):QMainWindow( 0, "Keepass",WDestructiveClose)
{ mainWin=new CMainWindow(app,this);
{
QString ArgFile,ArgCfg;
if(app->argc()>1){
int i=1;
if(app->argv()[i][0]!='-'){
ArgFile=app->argv()[i];
i++;
}
for(i; i<app->argc();i++){
if(QString(app->argv()[i])=="-h")
argHelp();
else if(QString(app->argv()[i])=="-cfg"){
if(i-1==app->argc()) cout << "No configuration file specified" << endl;
else{ArgCfg=app->argv()[i];}
}
else{cout << "** Unrecognized option: " << app->argv()[i] << endl;
exit(1);}
}
}
mainWin=new CMainWindow(app,ArgFile,ArgCfg,this);
setCentralWidget( mainWin );
}
PwSafe::~PwSafe()
@ -31,3 +55,10 @@ PwSafe::~PwSafe()
delete mainWin;
}
void PwSafe::argHelp(){
cout << "Keepass 0.1.3 (Alpha)" << endl;
cout << "Usage: keepass [Filename] [Options]" << endl;
cout << " -h This Help" << endl;
cout << " -cfg ConfigFile Use specified configuration" << endl;
exit(0);
}

@ -43,6 +43,7 @@ public:
private:
CMainWindow *mainWin;
void argHelp();
};
#endif // _PWSAFE_H_