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,118 +1118,10 @@ - MainFrame - pixmapSizeChanged(bool) - MainFrame - OnMainWinResize() - - - File_Open + DEBUG_DbStructure activated() MainFrame - OnFileOpen() - - - GroupView - selectionChanged(QListViewItem*) - MainFrame - OnGroupChanged(QListViewItem*) - - - File_Close - activated() - MainFrame - OnMenu_closeDB() - - - File_Save - activated() - MainFrame - OnFileSave() - - - File_SaveAs - activated() - MainFrame - OnFileSaveAs() - - - tooButtonOpen - clicked() - MainFrame - OnFileOpen() - - - toolButtonSave - clicked() - MainFrame - OnFileSave() - - - File_Exit - activated() - MainFrame - OnMenuExit() - - - EntryView - selectionChanged(QListViewItem*) - MainFrame - OnEntryChanged(QListViewItem*) - - - EntryView - doubleClicked(QListViewItem*,const QPoint&,int) - MainFrame - OnEntryDoubleClicked(QListViewItem*,const QPoint&,int) - - - Edit_NewGroup - activated() - MainFrame - OnAddGroup() - - - Edit_NewSubGroup - activated() - MainFrame - OnAddSubGroup() - - - Edit_GroupProperties - activated() - MainFrame - OnEditGroup() - - - Edit_DeleteGroup - activated() - MainFrame - OnDeleteGroup() - - - Edit_PasswordToClipboard - activated() - MainFrame - OnPasswordToClipboard() - - - Edit_UserNameToClipboard - activated() - MainFrame - OnUserNameToClipboard() - - - Edit_OpenURL - activated() - MainFrame - OnOpenURL() - - - Edit_SaveAttachment - activated() - MainFrame - OnSaveAttachment() + DEBUG_OnPrintDbStucture() Edit_AddEntry @@ -1237,12 +1129,6 @@ MainFrame OnAddEntry() - - Edit_EditEntry - activated() - MainFrame - OnEditEntry() - Edit_CopyEntry activated() @@ -1255,6 +1141,30 @@ MainFrame OnDeleteEntry() + + Edit_DeleteGroup + activated() + MainFrame + OnDeleteGroup() + + + Edit_EditEntry + activated() + MainFrame + OnEditEntry() + + + Edit_GlobalSearch + activated() + MainFrame + OnGlobalSearch() + + + Edit_GroupProperties + activated() + MainFrame + OnEditGroup() + Edit_GroupSearch activated() @@ -1262,35 +1172,53 @@ OnGroupSearch() - toolButtonAddEntry - clicked() + Edit_NewGroup + activated() MainFrame - OnAddEntry() + OnAddGroup() - toolButtonEditEntry - clicked() + Edit_NewSubGroup + activated() MainFrame - OnEditEntry() + OnAddSubGroup() - toolButtonDeleteEntry - clicked() + Edit_OpenURL + activated() MainFrame - OnDeleteEntry() + OnOpenURL() - toolButtonPasswordToClipboard - clicked() + Edit_PasswordToClipboard + activated() MainFrame OnPasswordToClipboard() - toolButtonUserNameToClipboard - clicked() + Edit_SaveAttachment + activated() + MainFrame + OnSaveAttachment() + + + Edit_UserNameToClipboard + activated() MainFrame OnUserNameToClipboard() + + EntryView + selectionChanged(QListViewItem*) + MainFrame + OnEntryChanged(QListViewItem*) + + + EntryView + doubleClicked(QListViewItem*,const QPoint&,int) + MainFrame + OnEntryDoubleClicked(QListViewItem*,const QPoint&,int) + EntryView rightButtonClicked(QListViewItem*,const QPoint&,int) @@ -1298,46 +1226,10 @@ OnEntryRightClicked(QListViewItem*,const QPoint&,int) - GroupView - rightButtonClicked(QListViewItem*,const QPoint&,int) - MainFrame - OnGroupRightClicked(QListViewItem*,const QPoint&,int) - - - File_Settings + Extras_Language activated() MainFrame - OnDbSettings() - - - File_ChangeKey - activated() - MainFrame - OnChangeDbKey() - - - File_New - activated() - MainFrame - OnFileNew() - - - View_ShowToolBar - toggled(bool) - MainFrame - OnViewToolbarToggled(bool) - - - View_ShowEntryDetails - toggled(bool) - MainFrame - OnViewEntryDetailsToggled(bool) - - - toolButtonNew - clicked() - MainFrame - OnFileNew() + OnExtrasLanguage() Extras_Settings @@ -1345,6 +1237,84 @@ MainFrame OnSettings() + + File_ChangeKey + activated() + MainFrame + OnChangeDbKey() + + + File_Close + activated() + MainFrame + OnMenu_closeDB() + + + File_Exit + activated() + MainFrame + OnMenuExit() + + + File_ImportKWalletXML + activated() + MainFrame + OnImportKWalletXML() + + + File_Import_PwManager + activated() + MainFrame + OnImportPwManagerFile() + + + File_New + activated() + MainFrame + OnFileNew() + + + File_Open + activated() + MainFrame + OnFileOpen() + + + File_Save + activated() + MainFrame + OnFileSave() + + + File_SaveAs + activated() + MainFrame + OnFileSaveAs() + + + File_Settings + activated() + MainFrame + OnDbSettings() + + + GroupView + selectionChanged(QListViewItem*) + MainFrame + OnGroupChanged(QListViewItem*) + + + GroupView + rightButtonClicked(QListViewItem*,const QPoint&,int) + MainFrame + OnGroupRightClicked(QListViewItem*,const QPoint&,int) + + + GroupView + dropped(QDropEvent*) + MainFrame + OnGroupViewDrop(QDropEvent*) + Help_About activated() @@ -1352,10 +1322,76 @@ OnHelpAbout() - View_Column_Expire - toggled(bool) + Help_AboutQt + activated() MainFrame - OnView_ColumnExpireToggled(bool) + OnHelpAboutQt() + + + MainFrame + pixmapSizeChanged(bool) + MainFrame + OnMainWinResize() + + + tooButtonOpen + clicked() + MainFrame + OnFileOpen() + + + toolButtonAddEntry + clicked() + MainFrame + OnAddEntry() + + + toolButtonDeleteEntry + clicked() + MainFrame + OnDeleteEntry() + + + toolButtonEditEntry + clicked() + MainFrame + OnEditEntry() + + + toolButtonNew + clicked() + MainFrame + OnFileNew() + + + toolButtonPasswordToClipboard + clicked() + MainFrame + OnPasswordToClipboard() + + + toolButtonSave + clicked() + MainFrame + OnFileSave() + + + toolButtonSearch + clicked() + MainFrame + OnGlobalSearch() + + + toolButtonUserNameToClipboard + clicked() + MainFrame + OnUserNameToClipboard() + + + toolSearch + returnPressed() + MainFrame + OnQickSearch() View_Column_Attachment @@ -1363,12 +1399,6 @@ MainFrame OnView_ColumnAttachmentToggled(bool) - - View_Column_Username - toggled(bool) - MainFrame - OnView_ColumnUsernameToggled(bool) - View_Column_Comment toggled(bool) @@ -1381,6 +1411,18 @@ MainFrame OnView_ColumnCreationToggled(bool) + + View_Column_Expire + toggled(bool) + MainFrame + OnView_ColumnExpireToggled(bool) + + + View_Column_LastAccess + toggled(bool) + MainFrame + OnView_ColumnLastAccessToggled(bool) + View_Column_LastMod toggled(bool) @@ -1394,10 +1436,10 @@ OnView_ColumnPasswordToggled(bool) - View_Column_LastAccess + View_Column_Title toggled(bool) MainFrame - OnView_ColumnLastAccessToggled(bool) + OnView_ColumnTitleToggled(bool) View_Column_URL @@ -1406,46 +1448,10 @@ OnView_ColumnUrlToggled(bool) - View_Column_Title + View_Column_Username toggled(bool) MainFrame - OnView_ColumnTitleToggled(bool) - - - Edit_GlobalSearch - activated() - MainFrame - OnGlobalSearch() - - - Extras_Language - activated() - MainFrame - OnExtrasLanguage() - - - toolButtonSearch - clicked() - MainFrame - OnGlobalSearch() - - - toolSearch - returnPressed() - MainFrame - OnQickSearch() - - - DEBUG_DbStructure - activated() - MainFrame - DEBUG_OnPrintDbStucture() - - - File_Import_PwManager - activated() - MainFrame - OnImportPwManagerFile() + OnView_ColumnUsernameToggled(bool) View_HidePasswords @@ -1460,22 +1466,16 @@ OnView_HideUsernamesToggled(bool) - GroupView - dropped(QDropEvent*) + View_ShowEntryDetails + toggled(bool) MainFrame - OnGroupViewDrop(QDropEvent*) + OnViewEntryDetailsToggled(bool) - Help_AboutQt - activated() + View_ShowToolBar + toggled(bool) MainFrame - OnHelpAboutQt() - - - File_ImportKWalletXML - activated() - 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); } -config.loadFromIni(); +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("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_