From a8a9a64142b8617ef23f8422a015ace6924dbed7 Mon Sep 17 00:00:00 2001 From: tariq Date: Tue, 25 Oct 2005 22:52:22 +0000 Subject: [PATCH] git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@2 b624d157-de02-0410-bad0-e51aec6abb33 --- src/PwManager.cpp | 31 +++- src/PwManager.h | 1 + src/PwmConfig.cpp | 8 +- src/PwmConfig.h | 4 +- src/forms/ui_MainWindow.ui | 298 ++++++++++++++++++------------------- src/main.cpp | 2 +- src/mainwindow.cpp | 130 ++++++++++------ src/mainwindow.h | 8 +- src/pwsafe.cpp | 35 ++++- src/pwsafe.h | 1 + 10 files changed, 311 insertions(+), 207 deletions(-) diff --git a/src/PwManager.cpp b/src/PwManager.cpp index 92b5d9b..22d8b53 100755 --- a/src/PwManager.cpp +++ b/src/PwManager.cpp @@ -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); @@ -254,8 +255,17 @@ unsigned long FileSize=file.size(); if(FileSize == 32){ if(file.readBlock((char*)MasterKey,32) != 32){ + file.close(); + return false;} +} +else if(FileSize == 64){ + char hex[64]; + if(file.readBlock(hex,64) != 64){ + file.close(); + return false;} file.close(); - return false;} + if(!convHexToBinaryKey(hex,(char*)MasterKey)) return false; + } else { @@ -275,7 +285,7 @@ delete [] buffer; file.close(); return true; - } +} CEntry* PwDatabase::addEntry(){ @@ -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); +} +} diff --git a/src/PwManager.h b/src/PwManager.h index 8d34aeb..fe184b2 100755 --- a/src/PwManager.h +++ b/src/PwManager.h @@ -74,6 +74,7 @@ private: bool isEntrySidInUse(UINT32 sID); UINT32 getNewGroupId(); UINT32 getNewEntrySid(); + bool convHexToBinaryKey(char* HexKey, char* dst); }; #endif diff --git a/src/PwmConfig.cpp b/src/PwmConfig.cpp index d6e6479..136255a 100755 --- a/src/PwmConfig.cpp +++ b/src/PwmConfig.cpp @@ -23,8 +23,8 @@ #include #include -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); diff --git a/src/PwmConfig.h b/src/PwmConfig.h index dbe6694..00f935e 100755 --- a/src/PwmConfig.h +++ b/src/PwmConfig.h @@ -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); diff --git a/src/forms/ui_MainWindow.ui b/src/forms/ui_MainWindow.ui index 2c8b245..ec2e402 100755 --- a/src/forms/ui_MainWindow.ui +++ b/src/forms/ui_MainWindow.ui @@ -1118,70 +1118,58 @@ - MainFrame - pixmapSizeChanged(bool) - MainFrame - OnMainWinResize() - - - File_Open + DEBUG_DbStructure activated() MainFrame - OnFileOpen() - - - GroupView - selectionChanged(QListViewItem*) - MainFrame - OnGroupChanged(QListViewItem*) + DEBUG_OnPrintDbStucture() - File_Close + Edit_AddEntry activated() MainFrame - OnMenu_closeDB() + OnAddEntry() - File_Save + Edit_CopyEntry activated() MainFrame - OnFileSave() + OnCopyEntry() - File_SaveAs + Edit_DeleteEntry activated() MainFrame - OnFileSaveAs() + OnDeleteEntry() - tooButtonOpen - clicked() + Edit_DeleteGroup + activated() MainFrame - OnFileOpen() + OnDeleteGroup() - toolButtonSave - clicked() + Edit_EditEntry + activated() MainFrame - OnFileSave() + OnEditEntry() - File_Exit + Edit_GlobalSearch activated() MainFrame - OnMenuExit() + OnGlobalSearch() - EntryView - selectionChanged(QListViewItem*) + Edit_GroupProperties + activated() MainFrame - OnEntryChanged(QListViewItem*) + OnEditGroup() - EntryView - doubleClicked(QListViewItem*,const QPoint&,int) + Edit_GroupSearch + activated() MainFrame - OnEntryDoubleClicked(QListViewItem*,const QPoint&,int) + OnGroupSearch() Edit_NewGroup @@ -1196,22 +1184,22 @@ OnAddSubGroup() - Edit_GroupProperties + Edit_OpenURL activated() MainFrame - OnEditGroup() + OnOpenURL() - Edit_DeleteGroup + Edit_PasswordToClipboard activated() MainFrame - OnDeleteGroup() + OnPasswordToClipboard() - Edit_PasswordToClipboard + Edit_SaveAttachment activated() MainFrame - OnPasswordToClipboard() + OnSaveAttachment() Edit_UserNameToClipboard @@ -1220,82 +1208,100 @@ OnUserNameToClipboard() - Edit_OpenURL + EntryView + selectionChanged(QListViewItem*) + MainFrame + OnEntryChanged(QListViewItem*) + + + EntryView + doubleClicked(QListViewItem*,const QPoint&,int) + MainFrame + OnEntryDoubleClicked(QListViewItem*,const QPoint&,int) + + + EntryView + rightButtonClicked(QListViewItem*,const QPoint&,int) + MainFrame + OnEntryRightClicked(QListViewItem*,const QPoint&,int) + + + Extras_Language activated() MainFrame - OnOpenURL() + OnExtrasLanguage() - Edit_SaveAttachment + Extras_Settings activated() MainFrame - OnSaveAttachment() + OnSettings() - Edit_AddEntry + File_ChangeKey activated() MainFrame - OnAddEntry() + OnChangeDbKey() - Edit_EditEntry + File_Close activated() MainFrame - OnEditEntry() + OnMenu_closeDB() - Edit_CopyEntry + File_Exit activated() MainFrame - OnCopyEntry() + OnMenuExit() - Edit_DeleteEntry + File_ImportKWalletXML activated() MainFrame - OnDeleteEntry() + OnImportKWalletXML() - Edit_GroupSearch + File_Import_PwManager activated() MainFrame - OnGroupSearch() + OnImportPwManagerFile() - toolButtonAddEntry - clicked() + File_New + activated() MainFrame - OnAddEntry() + OnFileNew() - toolButtonEditEntry - clicked() + File_Open + activated() MainFrame - OnEditEntry() + OnFileOpen() - toolButtonDeleteEntry - clicked() + File_Save + activated() MainFrame - OnDeleteEntry() + OnFileSave() - toolButtonPasswordToClipboard - clicked() + File_SaveAs + activated() MainFrame - OnPasswordToClipboard() + OnFileSaveAs() - toolButtonUserNameToClipboard - clicked() + File_Settings + activated() MainFrame - OnUserNameToClipboard() + OnDbSettings() - EntryView - rightButtonClicked(QListViewItem*,const QPoint&,int) + GroupView + selectionChanged(QListViewItem*) MainFrame - OnEntryRightClicked(QListViewItem*,const QPoint&,int) + OnGroupChanged(QListViewItem*) GroupView @@ -1304,148 +1310,148 @@ OnGroupRightClicked(QListViewItem*,const QPoint&,int) - File_Settings - activated() + GroupView + dropped(QDropEvent*) MainFrame - OnDbSettings() + OnGroupViewDrop(QDropEvent*) - File_ChangeKey + Help_About activated() MainFrame - OnChangeDbKey() + OnHelpAbout() - File_New + Help_AboutQt activated() MainFrame - OnFileNew() + OnHelpAboutQt() - View_ShowToolBar - toggled(bool) + MainFrame + pixmapSizeChanged(bool) MainFrame - OnViewToolbarToggled(bool) + OnMainWinResize() - View_ShowEntryDetails - toggled(bool) + tooButtonOpen + clicked() MainFrame - OnViewEntryDetailsToggled(bool) + OnFileOpen() - toolButtonNew + toolButtonAddEntry clicked() MainFrame - OnFileNew() + OnAddEntry() - Extras_Settings - activated() + toolButtonDeleteEntry + clicked() MainFrame - OnSettings() + OnDeleteEntry() - Help_About - activated() + toolButtonEditEntry + clicked() MainFrame - OnHelpAbout() + OnEditEntry() - View_Column_Expire - toggled(bool) + toolButtonNew + clicked() MainFrame - OnView_ColumnExpireToggled(bool) + OnFileNew() - View_Column_Attachment - toggled(bool) + toolButtonPasswordToClipboard + clicked() MainFrame - OnView_ColumnAttachmentToggled(bool) + OnPasswordToClipboard() - View_Column_Username - toggled(bool) + toolButtonSave + clicked() MainFrame - OnView_ColumnUsernameToggled(bool) + OnFileSave() - View_Column_Comment - toggled(bool) + toolButtonSearch + clicked() MainFrame - OnView_ColumnCommentToggled(bool) + OnGlobalSearch() - View_Column_Creation - toggled(bool) + toolButtonUserNameToClipboard + clicked() MainFrame - OnView_ColumnCreationToggled(bool) + OnUserNameToClipboard() - View_Column_LastMod - toggled(bool) + toolSearch + returnPressed() MainFrame - OnView_ColumnLastModToggled(bool) + OnQickSearch() - View_Column_Password + View_Column_Attachment toggled(bool) MainFrame - OnView_ColumnPasswordToggled(bool) + OnView_ColumnAttachmentToggled(bool) - View_Column_LastAccess + View_Column_Comment toggled(bool) MainFrame - OnView_ColumnLastAccessToggled(bool) + OnView_ColumnCommentToggled(bool) - View_Column_URL + View_Column_Creation toggled(bool) MainFrame - OnView_ColumnUrlToggled(bool) + OnView_ColumnCreationToggled(bool) - View_Column_Title + View_Column_Expire toggled(bool) MainFrame - OnView_ColumnTitleToggled(bool) + OnView_ColumnExpireToggled(bool) - Edit_GlobalSearch - activated() + View_Column_LastAccess + toggled(bool) MainFrame - OnGlobalSearch() + OnView_ColumnLastAccessToggled(bool) - Extras_Language - activated() + View_Column_LastMod + toggled(bool) MainFrame - OnExtrasLanguage() + OnView_ColumnLastModToggled(bool) - toolButtonSearch - clicked() + View_Column_Password + toggled(bool) MainFrame - OnGlobalSearch() + OnView_ColumnPasswordToggled(bool) - toolSearch - returnPressed() + View_Column_Title + toggled(bool) MainFrame - OnQickSearch() + OnView_ColumnTitleToggled(bool) - DEBUG_DbStructure - activated() + View_Column_URL + toggled(bool) MainFrame - DEBUG_OnPrintDbStucture() + OnView_ColumnUrlToggled(bool) - File_Import_PwManager - activated() + View_Column_Username + toggled(bool) MainFrame - OnImportPwManagerFile() + OnView_ColumnUsernameToggled(bool) View_HidePasswords @@ -1460,22 +1466,16 @@ OnView_HideUsernamesToggled(bool) - GroupView - dropped(QDropEvent*) - MainFrame - OnGroupViewDrop(QDropEvent*) - - - Help_AboutQt - activated() + View_ShowEntryDetails + toggled(bool) MainFrame - OnHelpAboutQt() + OnViewEntryDetailsToggled(bool) - File_ImportKWalletXML - activated() + View_ShowToolBar + toggled(bool) MainFrame - OnImportKWalletXML() + OnViewToolbarToggled(bool) diff --git a/src/main.cpp b/src/main.cpp index b6a81c2..80dda95 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - +#include #include "pwsafe.h" #include diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 71c18e4..85f8ed4 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(!QDir(QDir::homeDirPath()+"/.keepass").exists()){ +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;} + } + IniFilename=QDir::homeDirPath()+"/.keepass/config"; + config.loadFromIni(IniFilename); +} +else +{ + IniFilename=ArgCfg; + config.loadFromIni(IniFilename); } -config.loadFromIni(); + + + 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("Gruppe: %1 Titel: %2 Benutzername: %3 URL: %4 Passwort: %5 Erstellt: %6 letzte Änderung: %7 letzter Zugriff: %8 gültig bis: %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 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("Gruppe: %1 Titel: %2 Benutzername: %3 URL: %4 Passwort: %5 Erstellt: %6 letzte Änderung: %7 letzter Zugriff: %8 gültig bis: %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; +} \ No newline at end of file diff --git a/src/mainwindow.h b/src/mainwindow.h index 2e47e89..d55d5c0 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 diff --git a/src/pwsafe.cpp b/src/pwsafe.cpp index cecbea7..da610bb 100755 --- a/src/pwsafe.cpp +++ b/src/pwsafe.cpp @@ -22,8 +22,32 @@ #include "pwsafe.h" PwSafe::PwSafe(QApplication* app):QMainWindow( 0, "Keepass",WDestructiveClose) -{ mainWin=new CMainWindow(app,this); - setCentralWidget( mainWin ); +{ +QString ArgFile,ArgCfg; +if(app->argc()>1){ +int i=1; + if(app->argv()[i][0]!='-'){ + ArgFile=app->argv()[i]; + i++; + } + for(i; iargc();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); +} \ No newline at end of file diff --git a/src/pwsafe.h b/src/pwsafe.h index 768b0c1..0d87b5d 100755 --- a/src/pwsafe.h +++ b/src/pwsafe.h @@ -43,6 +43,7 @@ public: private: CMainWindow *mainWin; + void argHelp(); }; #endif // _PWSAFE_H_