From 192dbba0e4ada286634d2ebb974427cb4d3b41a8 Mon Sep 17 00:00:00 2001 From: tariq Date: Tue, 15 Nov 2005 18:57:56 +0000 Subject: [PATCH] 0.1.3b git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@4 b624d157-de02-0410-bad0-e51aec6abb33 --- share/keepass/i18n/english.qm | Bin 20735 -> 20788 bytes src/Database.h | 4 +- src/PwManager.cpp | 59 +++++++--- src/PwManager.h | 5 +- src/PwmConfig.cpp | 2 + src/PwmConfig.h | 1 + src/crypto/blowfish.cpp | 2 +- src/crypto/blowfish.h | 5 +- src/crypto/sha1.cpp | 4 +- src/crypto/sha1.h | 2 +- src/dialogs/ChangeKeyDlg.cpp | 2 +- src/dialogs/EditEntryDlg.cpp | 3 +- src/dialogs/LanguageDlg.cpp | 6 +- src/dialogs/PasswordDlg.cpp | 2 +- src/dialogs/SearchDlg.cpp | 32 +++--- src/dialogs/SettingsDlg.cpp | 38 +++---- src/forms/ui_EditEntryDlg.ui | 13 +-- src/global.h | 3 + src/lib/KdePlugin.cpp | 8 ++ src/lib/KdePlugin.h | 13 +++ src/main.cpp | 136 +++++++++++++++++++++-- src/mainwindow.cpp | 196 +++++++++++++--------------------- src/mainwindow.h | 5 +- src/pwsafe.cpp | 33 +----- src/pwsafe.h | 4 +- src/src.pro | 29 ++--- 26 files changed, 355 insertions(+), 252 deletions(-) create mode 100644 src/global.h create mode 100644 src/lib/KdePlugin.cpp create mode 100644 src/lib/KdePlugin.h diff --git a/share/keepass/i18n/english.qm b/share/keepass/i18n/english.qm index 870e0a400b9078175e17c6bb619b199f418a4828..2d76aa68ab54bcac040d66ae994bb336e0aa00a1 100755 GIT binary patch delta 3109 zcmXZedt8k99tZI6Jo7v=&ph+YOjpz8(Lg;+WX@)mGOLJE_oMtg^NC%~fr<9Ea&98Ch`Em_eGc+ZFmDrA zZHwDT7}X8mlI2}O=|#exP9kL}>3p+c0_p3|!E6e;&;rY8=+~a`7fQU=LBwllMEFY> z!^~!uFpn~u?Fu^hnn*A*M>F#+EU|@oiuus4iZxW(26{uJN`+m}HXv4@TFNY=5fL2X zD#*j1na`j=q*gNfK^5X?sD_pgk&uwcVy>nUn>HcdMk6j|!XGH97>`d~Ph)Zv@D7bB z!d9tY(3n-%h(r}7N8f^8l)}}*JWAQ)4!@+y(n+|Ld77r(wIaSoGn*TUG(>ZAvE3F; zBo!6I-RwiwwMn65QRY(pqiL{);ldpsU3a`?k66q$2lmIW#MZ#*Kq(6em)xWFdK<;^ZvsrTnYn zin17XD(()iCL9EgyXFGZIGquDuUo~r_c6mVE^Jv1{D~VK-U#n=tF%@k{Sa>5)Ml8$ zZJO!>3%NskD`5q9#3LCta6j6fi2fn>^D;Ah%{6Y$v=AA_a$T=5fMJP}pM#2q3Z+>1 z2%b{9euzV9XtwL1SDJ24B60{&t~fXVmMB*qLpw(;bFy-~)r5Gf@<6H{)+$e1u@#PO z5L@Gq>#_IF9lZZ~oCy~_-@gJAb(z3NJ-!d~`RIOFp-U+rBO-Qn;1fM?Yg_}E16QM-L%xz8OXfBj!JZ8A5u!Endq!C8Xcmiuk@Tc?j$sCd~R3 z<-K!-{kDbl-pgzh4(-^DxJ5X;zY|*C*b|=qLfzgBBF|XiYOg*pUwD%J43;xnRE}M4 zM17o8&h=}F`mRzrU$R-D@+oYD4Jtp|BlQ}j8Xto9g;$~~BRmtXQ%yf!29K)d&8vjX zs@jf^h>VV^x-P^PW0a~XX$CSrQMJ6m1dJ7`wsv%6yr%lkepE1as-Ab6iM)F==c-;x z$oH;LhnqQgLme%k+()HOzKPTA6QKU0OApi3rGYEqQuQ~Ft?+>Q@bqTbp#HvE!?Y0Mj%Mfm|l!7-YGj!Iar zS$oR_?`RIZ!GOUpHPsWliTax*nt<~DUrC&E4Q#U;Vq{KXmPkrVQU+1TQAz&sGSPru zlGAW>I3QB$5#bK=q?qx~;WlY%30}nm&PubQp22%kLE%yON~-uaj40Gus*J^H4h?2z zFiV&<(&3YhD8DWJR1OD{bgm*921u6LHd`W1y6_UO+<^fef@n~j)+4w8j@SAYH^UX$Y=2CA&^~Sc?htrJyWVXWysj<#YbAWH-LYXgQJBn3 z*Y4hi1%_?Z9)|2hTRCk7-W%a2dBT%UB}!EWRLT~rqOiCm^jJc2E?L>|}8Jca=xZ|WAmsv(MU(=C-y zAu3+CW=c<(!~DChcoV)Fq7Lddw06T*-FI&IREv76`z{hj_thO+fPSLmbSFxxVVdqj zY9pMhyY83)&+2YRn2BOi^vXC-_?h0n$`|)P=6n6nQZ$UI(I;f$&<&fQpUY!_VFmg{ zZ6e&FFF0$0)%udtRj@_>wQcWAq55z0aV<@wAnKbk_1z){FclhvI|;Ck`KR63Am$W< z`$Bvl#1WAED%MDK?hqI1jOY-WiewzUTFUgj0Mab);lA?n4wXBascf4^}< z4dY+#f|Ct-rb<}MtT9wr@g9l0YdCN@ktp8B&~V-g6AZs?!UW@Y<=_)I{#?~Xt+ztP z2LXwxDVe!hGZt0dmH#GJU3Y8pj*p>nWTq@Cp!xWnL5uJ^llqb$(s@*f+(k5xrqM#m zp-)lfhq8Q{PIG86WeK+1RJCK6MNouQ^-Z|M`FK(sCDKQzG!otBpmATyM)e#tK*xgZ L3{c3r5nJ5gVT!xn0iRMrSUVB#&P-(H zGRv9gnJ?fwB06Gf;iXETn{R4sjXe;X&qA zC?I}lRV_gkk-7&|!~Rf$reQ2Gn-a=!yVc7m;mRbqg%XQTz(X{0h60|Yk@;9E^>rG# z>Nh>y{*_OfEetVkj`P%*P@FC3%D|Kt;xtvHcf0@o={O>ZX?$qkBMl*Pzs zQQVEMBhqO&?z#hv;B=l?d)+L~rAH1dwJxl4Cj^nY)i!s zrMUPZk&UEu9F5Is(~Fs^H2#{3I9Iv+P#<_(S#%87*`_e}DJx5ih#x2qChLjpY?Nn9 zuq1Zj5KCk?MtQOCBbcqc)`mS`SFF6hz?6wZ4H6b#C?9y?2-2b_u z?&OEP!~h*n^2w&=pNKwk;xqCxU?@Mep$m@YmoI9Di)=|?m?aFFn*&!033Knm143G(CB9+RRT9$vy_Lu{P)HB8 zSRhRQ56WGS3N@CAxW2UN<}7@>vx>+qSU6ns7MkK&V!m*3e*)~f7b+GG-2faZ#2eE*jv_&^G$@|%q5yhtp$jytp<2% zau?!N9k5E1*I|awHEVw}5(W0u9DI)s1C5%x30?4nMB`B&*dlTEXNZErnc2+!%-fRE zl$c4>ha~yrRrr}?7mo(}6iFY2yTH>@bjqKwP0A?6BRNZ zDVbxjn}ZiI4=`_A4be!4Pc`A2!dE)I*Wz&LLUj_%l}rs!EQw0#Qac{GA*ZBwAL5%* z*Dwq$A?okTOwqR7I)iu_vzGZ#`*0reLshcc z3mt~K%IcRDFhUL(Wr@ei(IY+JY->l}YJ!hcyE&`%dR1?>!2s*5{TOy$# z(p9%+VmJ6PbB?aKOoMo}ZbK^u7I{v$#~Gh!k+*bv23UNjJN7vmi0ZC8QCbK4=q@EU z!35n6TMRI2hwgTG4pFqfUOC7OrtAG`ajK$=^bs3zU39sA$Rrn>|Cqk|Y#trNjMe8p z5n--A@4OLi)|Z~Gg=h6!ENf=e>bEb%F*N!@)HlZHyF_$g9A^;j41v3t*Q~~>nBfMO z`S>1)onQ!X#-l#=wAF!HL)6R)od1DCEeSZw5ZihN7BbDu+lHa@E#3DICT!yjcB;Nbij_^VJ7K7h$z0R9SP zZJX9nQR}QLlx-){c*>%AltVLU8by-(CPkRzrt%2=re8vBUCEsaa8QG27EQr#E~?JQ hFG#R_71eHWzUEc?UCbAPqHk@$kSkoR`%nk%{{i{<7jFOn diff --git a/src/Database.h b/src/Database.h index bd7939f..94af547 100644 --- a/src/Database.h +++ b/src/Database.h @@ -85,8 +85,8 @@ public: class Database:public AbstractDatabase{ public: - int CryptoAlgorithmus; - int KeyEncRounds; + UINT32 CryptoAlgorithmus; + UINT32 KeyEncRounds; QString filename; bool modflag; int SearchGroupID; diff --git a/src/PwManager.cpp b/src/PwManager.cpp index 22d8b53..cf33803 100755 --- a/src/PwManager.cpp +++ b/src/PwManager.cpp @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "global.h" #include #include #include @@ -31,6 +32,8 @@ #include "PwManager.h" + + bool PwDatabase::loadDatabase(QString _filename, QString& err){ unsigned long total_size,crypto_size; UINT32 Signature1,Signature2,Version,NumGroups,NumEntries,Flags; @@ -51,17 +54,17 @@ if(total_size < DB_HEADER_SIZE){ err=trUtf8("Unerwartete Dateigröße (Dateigröße < DB_HEADER_SIZE)"); return false; } -memcpy(&Signature1,buffer,4); -memcpy(&Signature2,buffer+4,4); -memcpy(&Flags,buffer+8,4); -memcpy(&Version,buffer+12,4); +memcpyFromLEnd32(&Signature1,buffer); +memcpyFromLEnd32(&Signature2,buffer+4); +memcpyFromLEnd32(&Flags,buffer+8); +memcpyFromLEnd32(&Version,buffer+12); memcpy(FinalRandomSeed,buffer+16,16); memcpy(EncryptionIV,buffer+32,16); -memcpy(&NumGroups,buffer+48,4); -memcpy(&NumEntries,buffer+52,4); +memcpyFromLEnd32(&NumGroups,buffer+48); +memcpyFromLEnd32(&NumEntries,buffer+52); memcpy(ContentsHash,buffer+56,32); memcpy(TrafoRandomSeed,buffer+88,32); -memcpy(&KeyEncRounds,buffer+120,4); +memcpyFromLEnd32(&KeyEncRounds,buffer+120); if((Signature1!=PWM_DBSIG_1) || (Signature2!=PWM_DBSIG_2)){ err=trUtf8("Falsche Signatur"); @@ -134,12 +137,12 @@ bool bRet; { pField = buffer+pos; - memcpy(&FieldType, pField, 2); + memcpyFromLEnd16(&FieldType, pField); pField += 2; pos += 2; if(pos >= total_size) { return false; } - memcpy(&FieldSize, pField, 4); + memcpyFromLEnd32(&FieldSize, pField); pField += 4; pos += 4; if(pos >= (total_size + FieldSize)) { return false;} @@ -158,12 +161,12 @@ bool bRet; { pField = buffer+pos; - memcpy(&FieldType, pField, 2); + memcpyFromLEnd16(&FieldType, pField); pField += 2; pos += 2; if(pos >= total_size){ return false;} - memcpy(&FieldSize, pField, 4); + memcpyFromLEnd32(&FieldSize, pField); pField += 4; pos += 4; if(pos >= (total_size + FieldSize)) { return false; } @@ -408,7 +411,7 @@ bool CGroup::ReadGroupField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData) // Ignore field break; case 0x0001: - memcpy(&ID, pData, 4); + memcpyFromLEnd32(&ID, (char*)pData); break; case 0x0002: //Name.fromUtf8((char*)pData); @@ -427,13 +430,13 @@ bool CGroup::ReadGroupField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData) Expire.Set(pData); break; case 0x0007: - memcpy(&ImageID, pData, 4); + memcpyFromLEnd32(&ImageID, (char*)pData); break; case 0x0008: - memcpy(&Level, pData, 2); + memcpyFromLEnd16(&Level, (char*)pData); break; case 0x0009: - memcpy(&Flags, pData, 4); + memcpyFromLEnd32(&Flags, (char*)pData); break; case 0xFFFF: break; @@ -465,10 +468,10 @@ switch(FieldType) memcpy(ID, pData, 16); break; case 0x0002: - memcpy(&GroupID, pData, 4); + memcpyFromLEnd32(&GroupID, (char*)pData); break; case 0x0003: - memcpy(&ImageID, pData, 4); + memcpyFromLEnd32(&ImageID, (char*)pData); break; case 0x0004: //Title=(char*)pData; @@ -936,3 +939,25 @@ for(int i=0; i<64; i+=2){ memcpy(dst+(i/2),&bin,1); } } + +void memcpyFromLEnd32(UINT32* dst,char* src){ +#ifdef KEEPASS_LITTLE_ENDIAN + memcpy(dst,src,4); +#endif +#ifdef KEEPASS_BIG_ENDIAN + memcpy(dst+3,src+0,1); + memcpy(dst+2,src+1,1); + memcpy(dst+1,src+2,1); + memcpy(dst+0,src+3,1); +#endif +} + +void memcpyFromLEnd16(UINT16* dst,char* src){ +#ifdef KEEPASS_LITTLE_ENDIAN + memcpy(dst,src,2); +#endif +#ifdef KEEPASS_BIG_ENDIAN + memcpy(dst+1,src+0,1); + memcpy(dst+0,src+1,1); +#endif +} \ No newline at end of file diff --git a/src/PwManager.h b/src/PwManager.h index fe184b2..d1b845e 100755 --- a/src/PwManager.h +++ b/src/PwManager.h @@ -30,7 +30,7 @@ #define PWM_STD_KEYENCROUNDS 6000 #define ALGO_AES 0 #define ALGO_TWOFISH 1 - #define KEEPASS_VERSION "0.1.2" + #define KEEPASS_VERSION "0.1.3" #include #include @@ -77,4 +77,7 @@ private: bool convHexToBinaryKey(char* HexKey, char* dst); }; + void memcpyFromLEnd32(UINT32* dst,char* src); + void memcpyFromLEnd16(UINT16* dst,char* src); + #endif diff --git a/src/PwmConfig.cpp b/src/PwmConfig.cpp index 136255a..bba0305 100755 --- a/src/PwmConfig.cpp +++ b/src/PwmConfig.cpp @@ -45,6 +45,7 @@ ParseBoolString(ini.GetValue("Options","PwGenOptions","1111100001"),PwGenOptions PwGenLength=ini.GetValueI("Options","PwGenLength",25); PwGenCharList=ini.GetValue("Options","PwGenCharList",""); ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true); +EnableKdePlugin=ini.GetValueB("KDE Plugin","Enabled",false); return true; } @@ -70,6 +71,7 @@ ini.SetValue("Options","PwGenOptions",CreateBoolString(PwGenOptions,10),true); ini.SetValueI("Options","PwGenLength",PwGenLength,true); ini.SetValue("Options","PwGenCharList",PwGenCharList,true); ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true); +ini.SetValueB("KDE Plugin","Enabled",EnableKdePlugin,true); if(!ini.WriteFile())return false; else return true; } diff --git a/src/PwmConfig.h b/src/PwmConfig.h index 00f935e..f6444ac 100755 --- a/src/PwmConfig.h +++ b/src/PwmConfig.h @@ -45,6 +45,7 @@ public: int PwGenLength; QString PwGenCharList; bool ExpandGroupTree; + bool EnableKdePlugin; bool loadFromIni(QString filename); bool saveToIni(QString filename); diff --git a/src/crypto/blowfish.cpp b/src/crypto/blowfish.cpp index 1ed0248..2495ee3 100755 --- a/src/crypto/blowfish.cpp +++ b/src/crypto/blowfish.cpp @@ -431,7 +431,7 @@ int Blowfish::do_bf_setkey(byte * key, unsigned int keylen) } for (i = j = 0; i < BLOWFISH_ROUNDS + 2; ++i) { -#ifdef BIG_ENDIAN_HOST +#ifdef KEEPASS_BIG_ENDIAN ((byte *) & data)[0] = key[j]; ((byte *) & data)[1] = key[(j + 1) % keylen]; ((byte *) & data)[2] = key[(j + 2) % keylen]; diff --git a/src/crypto/blowfish.h b/src/crypto/blowfish.h index 6c64287..1c71148 100755 --- a/src/crypto/blowfish.h +++ b/src/crypto/blowfish.h @@ -15,6 +15,7 @@ #ifndef BLOWFISH_H #define BLOWFISH_H +#include "global.h" #include #include using std::string; @@ -68,7 +69,7 @@ protected: uint32_t function_F( uint32_t x) { uint16_t a, b, c, d; - #ifdef BIG_ENDIAN_HOST + #ifdef KEEPASS_BIG_ENDIAN a = ((byte *) & x)[0]; b = ((byte *) & x)[1]; c = ((byte *) & x)[2]; @@ -86,7 +87,7 @@ protected: uint32_t *s0, uint32_t *s1, uint32_t *s2, uint32_t *s3) { l ^= p[i]; - #ifdef BIG_ENDIAN_HOST + #ifdef KEEPASS_BIG_ENDIAN r ^= (( s0[((byte*)&l)[0]] + s1[((byte*)&l)[1]]) ^ s2[((byte*)&l)[2]]) + s3[((byte*)&l)[3]]; #else diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index c6693c1..9033f9a 100755 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -19,7 +19,7 @@ SHA1(A million repetitions of "a") = 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ - +#include "global.h" #include "sha1.h" #define SHA1_MAX_FILE_BUFFER 8000 @@ -33,7 +33,7 @@ #endif #endif -#ifdef SHA1_LITTLE_ENDIAN +#ifdef KEEPASS_LITTLE_ENDIAN #define SHABLK0(i) (m_block->l[i] = \ (ROL32(m_block->l[i],24) & 0xFF00FF00) | (ROL32(m_block->l[i],8) & 0x00FF00FF)) #else diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h index c5c8f44..fb82927 100755 --- a/src/crypto/sha1.h +++ b/src/crypto/sha1.h @@ -29,7 +29,7 @@ // If you're compiling big endian, just comment out the following line -#define SHA1_LITTLE_ENDIAN + // #define or #undef this, if you want the CSHA1 class to wipe all // temporary variables after processing diff --git a/src/dialogs/ChangeKeyDlg.cpp b/src/dialogs/ChangeKeyDlg.cpp index 6fdf023..2365c9a 100755 --- a/src/dialogs/ChangeKeyDlg.cpp +++ b/src/dialogs/ChangeKeyDlg.cpp @@ -38,7 +38,7 @@ CChangeKeyDlg::CChangeKeyDlg(QWidget* parent,PwDatabase* _db,const char* name, b db=_db; parentwnd=((CMainWindow*)parentWidget()); parentwnd->CreateBanner(Banner,parentwnd->Icon_Key32x32,trUtf8("Hauptschlüssel ändern")); -if(!parentwnd->config.ShowPasswords)ChangeEchoMode(); +if(!parentwnd->config->ShowPasswords)ChangeEchoMode(); ///@PlatformSpecific QDir media("/media"); if(media.exists()){ diff --git a/src/dialogs/EditEntryDlg.cpp b/src/dialogs/EditEntryDlg.cpp index 60fb2d0..0225771 100755 --- a/src/dialogs/EditEntryDlg.cpp +++ b/src/dialogs/EditEntryDlg.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "PasswordGenDlg.h" @@ -72,7 +73,7 @@ Edit_URL->setText(entry->URL); Edit_Password->setText(entry->Password.getString()); Edit_Password_w->setText(entry->Password.getString()); entry->Password.delRef(); -if(!mainwnd->config.ShowPasswords)ChangeEchoMode(); +if(!mainwnd->config->ShowPasswords)ChangeEchoMode(); OnPasswordwLostFocus(); int bits=(entry->Password.length()*8); Label_Bits->setText(QString::number(bits)+" Bit"); diff --git a/src/dialogs/LanguageDlg.cpp b/src/dialogs/LanguageDlg.cpp index 6fd6591..bda049a 100755 --- a/src/dialogs/LanguageDlg.cpp +++ b/src/dialogs/LanguageDlg.cpp @@ -42,7 +42,7 @@ parentwnd=((CMainWindow*)parentWidget()); parentwnd->CreateBanner(Banner,parentwnd->Icon_I18n32x32,trUtf8("Spracheinstellungen")); QListViewItem* item; -QString& config_lang=parentwnd->config.Language; +QString& config_lang=parentwnd->config->Language; QStringList files; QString langdir=parentwnd->appdir+"/../share/keepass/i18n/"; @@ -111,10 +111,10 @@ if(!translator.load(langdir+filenames[i])){ QMessageBox::information(this,translator.findMessage("_MSG",msg[2]).translation() ,translator.findMessage("_MSG",msg[0]).translation() ,translator.findMessage("_MSG",msg[1]).translation() - ,0,0,2,1); + ,0,0); } else QMessageBox::information(this,QString::fromUtf8(msg[2]),QString::fromUtf8(msg[0]),QString::fromUtf8(msg[1]),0,0,2,1); -parentwnd->config.Language=filenames[i]; +parentwnd->config->Language=filenames[i]; for(int j=0;jsetPixmap(0,*parentwnd->Icon_Ok16x16); diff --git a/src/dialogs/PasswordDlg.cpp b/src/dialogs/PasswordDlg.cpp index 3d411d0..3f1bc30 100755 --- a/src/dialogs/PasswordDlg.cpp +++ b/src/dialogs/PasswordDlg.cpp @@ -57,7 +57,7 @@ Combo_Dirs->insertItem(0,Paths[i]); IsFile.append(false); } -if(!parentwnd->config.ShowPasswords)ChangeEchoMode(); +if(!parentwnd->config->ShowPasswords)ChangeEchoMode(); } diff --git a/src/dialogs/SearchDlg.cpp b/src/dialogs/SearchDlg.cpp index 8df4d62..e81799a 100755 --- a/src/dialogs/SearchDlg.cpp +++ b/src/dialogs/SearchDlg.cpp @@ -33,26 +33,26 @@ parentwnd->CreateBanner(Banner,parentwnd->Icon_Search32x32,tr("Suchen")); group=pGroup; pw=parentwnd->db; -checkBox_Cs->setChecked(parentwnd->config.SearchOptions[0]); -checkBox_regExp->setChecked(parentwnd->config.SearchOptions[1]); -checkBox_Title->setChecked(parentwnd->config.SearchOptions[2]); -checkBox_Username->setChecked(parentwnd->config.SearchOptions[3]); -checkBox_Password->setChecked(parentwnd->config.SearchOptions[4]); -checkBox_Comment->setChecked(parentwnd->config.SearchOptions[5]); -checkBox_URL->setChecked(parentwnd->config.SearchOptions[6]); -checkBox_Attachment->setChecked(parentwnd->config.SearchOptions[7]); +checkBox_Cs->setChecked(parentwnd->config->SearchOptions[0]); +checkBox_regExp->setChecked(parentwnd->config->SearchOptions[1]); +checkBox_Title->setChecked(parentwnd->config->SearchOptions[2]); +checkBox_Username->setChecked(parentwnd->config->SearchOptions[3]); +checkBox_Password->setChecked(parentwnd->config->SearchOptions[4]); +checkBox_Comment->setChecked(parentwnd->config->SearchOptions[5]); +checkBox_URL->setChecked(parentwnd->config->SearchOptions[6]); +checkBox_Attachment->setChecked(parentwnd->config->SearchOptions[7]); } CSearchDlg::~CSearchDlg() { -parentwnd->config.SearchOptions[0]=checkBox_Cs->isChecked(); -parentwnd->config.SearchOptions[1]=checkBox_regExp->isChecked(); -parentwnd->config.SearchOptions[2]=checkBox_Title->isChecked(); -parentwnd->config.SearchOptions[3]=checkBox_Username->isChecked(); -parentwnd->config.SearchOptions[4]=checkBox_Password->isChecked(); -parentwnd->config.SearchOptions[5]=checkBox_Comment->isChecked(); -parentwnd->config.SearchOptions[6]=checkBox_URL->isChecked(); -parentwnd->config.SearchOptions[7]=checkBox_Attachment->isChecked(); +parentwnd->config->SearchOptions[0]=checkBox_Cs->isChecked(); +parentwnd->config->SearchOptions[1]=checkBox_regExp->isChecked(); +parentwnd->config->SearchOptions[2]=checkBox_Title->isChecked(); +parentwnd->config->SearchOptions[3]=checkBox_Username->isChecked(); +parentwnd->config->SearchOptions[4]=checkBox_Password->isChecked(); +parentwnd->config->SearchOptions[5]=checkBox_Comment->isChecked(); +parentwnd->config->SearchOptions[6]=checkBox_URL->isChecked(); +parentwnd->config->SearchOptions[7]=checkBox_Attachment->isChecked(); } void CSearchDlg::OnButtonClose() diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index 330bb1e..3488939 100755 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -33,24 +33,24 @@ pw=((CMainWindow*)parentWidget())->db; mainwnd=((CMainWindow*)parentWidget()); mainwnd->CreateBanner(Banner,mainwnd->Icon_Settings32x32,trUtf8("Einstellungen")); -CheckBox_OpenLast->setChecked(mainwnd->config.OpenLast); -SpinBox_ClipboardTime->setValue(mainwnd->config.ClipboardTimeOut); +CheckBox_OpenLast->setChecked(mainwnd->config->OpenLast); +SpinBox_ClipboardTime->setValue(mainwnd->config->ClipboardTimeOut); pixmTextColor->setPixmap(*(new QPixmap(pixmTextColor->width(),pixmTextColor->height()))); -pixmTextColor->pixmap()->fill(mainwnd->config.BannerTextColor); +pixmTextColor->pixmap()->fill(mainwnd->config->BannerTextColor); pixmColor1->setPixmap(*(new QPixmap(pixmColor1->width(),pixmColor1->height()))); -pixmColor1->pixmap()->fill(mainwnd->config.BannerColor1); +pixmColor1->pixmap()->fill(mainwnd->config->BannerColor1); pixmColor2->setPixmap(*(new QPixmap(pixmColor2->width(),pixmColor2->height()))); -pixmColor2->pixmap()->fill(mainwnd->config.BannerColor2); +pixmColor2->pixmap()->fill(mainwnd->config->BannerColor2); -color1=mainwnd->config.BannerColor1; -color2=mainwnd->config.BannerColor2; -textcolor=mainwnd->config.BannerTextColor; +color1=mainwnd->config->BannerColor1; +color2=mainwnd->config->BannerColor2; +textcolor=mainwnd->config->BannerTextColor; -CheckBox_ShowPasswords->setChecked(mainwnd->config.ShowPasswords); -Edit_BrowserCmd->setText(mainwnd->config.OpenUrlCommand); -CheckBox_ExpandGroupTree->setChecked(mainwnd->config.ExpandGroupTree); +CheckBox_ShowPasswords->setChecked(mainwnd->config->ShowPasswords); +Edit_BrowserCmd->setText(mainwnd->config->OpenUrlCommand); +CheckBox_ExpandGroupTree->setChecked(mainwnd->config->ExpandGroupTree); } @@ -60,14 +60,14 @@ CSettingsDlg::~CSettingsDlg() void CSettingsDlg::OnOK() { -mainwnd->config.OpenLast=CheckBox_OpenLast->isChecked(); -mainwnd->config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); -mainwnd->config.BannerColor1=color1; -mainwnd->config.BannerColor2=color2; -mainwnd->config.BannerTextColor=textcolor; -mainwnd->config.ShowPasswords=CheckBox_ShowPasswords->isChecked(); -mainwnd->config.OpenUrlCommand=Edit_BrowserCmd->text(); -mainwnd->config.ExpandGroupTree=CheckBox_ExpandGroupTree->isChecked(); +mainwnd->config->OpenLast=CheckBox_OpenLast->isChecked(); +mainwnd->config->ClipboardTimeOut=SpinBox_ClipboardTime->value(); +mainwnd->config->BannerColor1=color1; +mainwnd->config->BannerColor2=color2; +mainwnd->config->BannerTextColor=textcolor; +mainwnd->config->ShowPasswords=CheckBox_ShowPasswords->isChecked(); +mainwnd->config->OpenUrlCommand=Edit_BrowserCmd->text(); +mainwnd->config->ExpandGroupTree=CheckBox_ExpandGroupTree->isChecked(); close(); } diff --git a/src/forms/ui_EditEntryDlg.ui b/src/forms/ui_EditEntryDlg.ui index d922141..4779f9b 100755 --- a/src/forms/ui_EditEntryDlg.ui +++ b/src/forms/ui_EditEntryDlg.ui @@ -80,7 +80,7 @@ 120 Bits - + ButtonDeleteAttachment @@ -99,7 +99,7 @@ image0 - + ButtonGenPw @@ -205,7 +205,7 @@ Icon: - + ButtonEchoMode @@ -220,11 +220,8 @@ ... - - false - - + ButtonSaveAttachment @@ -243,7 +240,7 @@ image1 - + ButtonOpenAttachment diff --git a/src/global.h b/src/global.h new file mode 100644 index 0000000..e9b952f --- /dev/null +++ b/src/global.h @@ -0,0 +1,3 @@ + +#define KEEPASS_LITTLE_ENDIAN +//#define KEEPASS_BIG_ENDIAN diff --git a/src/lib/KdePlugin.cpp b/src/lib/KdePlugin.cpp new file mode 100644 index 0000000..05f8365 --- /dev/null +++ b/src/lib/KdePlugin.cpp @@ -0,0 +1,8 @@ + +#include "KdePlugin.h" + +bool CKdePlugin::resolveSymbols(QLibrary& lib){ +getAppObj=(QApplication*(*)(int,char**))lib.resolve("getAppObj"); +if(getAppObj == NULL) return false; +return true; +} \ No newline at end of file diff --git a/src/lib/KdePlugin.h b/src/lib/KdePlugin.h new file mode 100644 index 0000000..5c6ed54 --- /dev/null +++ b/src/lib/KdePlugin.h @@ -0,0 +1,13 @@ +#ifndef _KDEPLUGIN_H_ +#define _KDEPLUGIN_H_ +#include +#include + +class CKdePlugin{ +public: + bool resolveSymbols(QLibrary& lib); + QApplication*(*getAppObj)(int,char**); +}; + + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 80dda95..010ef5d 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,24 +19,144 @@ ***************************************************************************/ #include -#include "pwsafe.h" #include +#include +#include +#include +#include +#include "pwsafe.h" +#include "PwmConfig.h" +#include "lib/KdePlugin.h" + +void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg){ +if(argc>1){ +int i=1; + if(argv[i][0]!='-'){ + ArgFile=QString::fromUtf8(argv[i]); + i++; + } + for(i; ishow(); - return app.exec(); +QString ArgFile,ArgCfg,IniFilename; +parseCmdLineArgs(argc,argv,ArgFile,ArgCfg); +CConfig config; + +//Load Config +if(ArgCfg==""){ + if(!QDir(QDir::homeDirPath()+"/.keepass").exists()){ + QDir conf(QDir::homeDirPath()); + if(!conf.mkdir(".keepass")){ + cout << "Warning: Could not create directory '~/.keepass'." << endl;} + } + IniFilename=QDir::homeDirPath()+"/.keepass/config"; + config.loadFromIni(IniFilename); +} +else +{ + IniFilename=ArgCfg; + config.loadFromIni(IniFilename); +} + +//KDE PlugIn +QApplication* app=NULL; +if(config.EnableKdePlugin){ +cout << "don't activate the kde plugin option" << endl; +exit(1); +/* + QLibrary lib("/home/tarek/Documents/keepass_kde/bin/libkeepass_kde.so"); + if(!lib.load()){ + cout << "Could not load KDE plugin." << endl; + exit(1); + } + CKdePlugin KdePlugin; + if(!KdePlugin.resolveSymbols(lib)){ + cout << "KDE plugin: Symbols could not be resolved." << endl; + exit(1); + } + app=KdePlugin.getAppObj(argc,argv); + QApplication*(*_getAppObj)(int,char**); + _getAppObj=(QApplication*(*)(int,char**))lib.resolve("getAppObj"); + app=_getAppObj(argc,argv**); + if(!app){cout << "app==NULL" << endl; + exit(1); + } +*/ +} +else{ +app=new QApplication(argc,argv); } +//Internationalization +QLocale loc=QLocale::system(); +QTranslator* translator = 0; +translator =new QTranslator; +if(config.Language==""){ + switch(loc.language()){ + case QLocale::German: + config.Language="_DEUTSCH_"; + break; + case QLocale::Russian: + config.Language="russian.qm"; + break; + case QLocale::English: + config.Language="english.qm"; + break; + default: + config.Language="english.qm"; + break;} +} +if(config.Language!="_DEUTSCH_"){ + if(!translator->load(app->applicationDirPath()+"/../share/keepass/i18n/"+config.Language)){ + if(!translator->load(app->applicationDirPath()+"/share/i18n/"+config.Language)){ + config.Language="_DEUTSCH_"; + QMessageBox::warning(NULL,"Warning", + QString("Translation file '%1' could not be loaded.") + .arg(config.Language),"OK",0,0,2,1); + delete translator; + translator=NULL;}} + else app->installTranslator(translator); +} + + PwSafe *mainWin = 0; + + mainWin = new PwSafe(app,ArgFile,&config); + app->setMainWidget( mainWin ); + mainWin->show(); + int ret=app->exec(); + if(!config.saveToIni(IniFilename)) + QMessageBox::warning(NULL,QObject::tr("Warnung"),QObject::trUtf8("Die Konfigurationsdatei konnte nicht gespeichert werden.Stellen Sie sicher, dass\nSie Schreibrechte im Verzeichnis ~/.keepass besitzen."),QObject::tr("OK"),"","",0.0); + delete app; + return ret; +} + + + + + + + /********* KDE ************** #include diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 85f8ed4..256006f 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -37,6 +37,7 @@ #include #include #include +#include //STD #include //local @@ -60,65 +61,16 @@ #include "import/Import_PwManager.h" #include "import/Import_KWalletXml.h" -CMainWindow::CMainWindow(QApplication* app,QString ArgFile,QString ArgCfg,QWidget* parent,const char* name, WFlags fl) +CMainWindow::CMainWindow(QApplication* app,QString ArgFile,CConfig* cfg,QWidget* parent,const char* name, WFlags fl) : MainFrame(parent,name,fl) { +config=cfg; FileOpen=false; App=app; appdir=app->applicationDirPath(); 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;} - } - IniFilename=QDir::homeDirPath()+"/.keepass/config"; - config.loadFromIni(IniFilename); -} -else -{ - IniFilename=ArgCfg; - config.loadFromIni(IniFilename); -} - - - -CGroup::UI_ExpandByDefault=config.ExpandGroupTree; - -// Language // -QLocale loc=QLocale::system(); -translator = 0; -translator =new QTranslator; - -if(config.Language==""){ - switch(loc.language()){ - case QLocale::German: - config.Language="_DEUTSCH_"; - break; - case QLocale::English: - config.Language="english.qm"; - break; - default: - config.Language="english.qm"; - break;} -} - -if(config.Language!="_DEUTSCH_"){ - if(!translator->load(appdir+"/../share/keepass/i18n/"+config.Language)){ - if(!translator->load(appdir+"/share/i18n/"+config.Language)){ - config.Language="_DEUTSCH_"; - QMessageBox::warning(this,tr("Warnung"), - trUtf8("Die Übersetzungsdatei '%1' konnte nicht geladen werden.\n Die Sprache wurde auf Deutsch zurückgesetzt.") - .arg(config.Language),tr("OK"),0,0,2,1); - delete translator; - translator=NULL;}} - else app->installTranslator(translator); -} - +CGroup::UI_ExpandByDefault=config->ExpandGroupTree; // Icons, Pixmaps // @@ -168,73 +120,73 @@ CurrentGroup=NULL; Clipboard=QApplication::clipboard(); GroupView->setSorting(-1); -if(config.Toolbar){ +if(config->Toolbar){ View_ShowToolBar->setOn(true);} else{ Toolbar->hide(); View_ShowToolBar->setOn(false);} -if(config.EntryDetails){ +if(config->EntryDetails){ View_ShowEntryDetails->setOn(true);} else{ SummaryField->hide(); View_ShowEntryDetails->setOn(false);} -if(config.Columns[0]){ +if(config->Columns[0]){ View_Column_Title->setOn(true);} else{ View_Column_Title->setOn(false);} -if(config.Columns[1]){ +if(config->Columns[1]){ View_Column_Username->setOn(true);} else{ View_Column_Username->setOn(false);} -if(config.Columns[2]){ +if(config->Columns[2]){ View_Column_URL->setOn(true);} else{ View_Column_URL->setOn(false);} -if(config.Columns[3]){ +if(config->Columns[3]){ View_Column_Password->setOn(true);} else{ View_Column_Password->setOn(false);} -if(config.Columns[4]){ +if(config->Columns[4]){ View_Column_Comment->setOn(true);} else{ View_Column_Comment->setOn(false);} -if(config.Columns[5]){ +if(config->Columns[5]){ View_Column_Expire->setOn(true);} else{ View_Column_Expire->setOn(false);} -if(config.Columns[6]){ +if(config->Columns[6]){ View_Column_Creation->setOn(true);} else{ View_Column_Creation->setOn(false);} -if(config.Columns[7]){ +if(config->Columns[7]){ View_Column_LastMod->setOn(true);} else{ View_Column_LastMod->setOn(false);} -if(config.Columns[8]){ +if(config->Columns[8]){ View_Column_LastAccess->setOn(true);} else{ View_Column_LastAccess->setOn(false);} -if(config.Columns[9]){ +if(config->Columns[9]){ View_Column_Attachment->setOn(true);} else{ View_Column_Attachment->setOn(false);} -if(config.ListView_HidePasswords){ +if(config->ListView_HidePasswords){ View_HidePasswords->setOn(true);} else{ View_HidePasswords->setOn(false);} -if(config.ListView_HideUsernames){ +if(config->ListView_HideUsernames){ View_HideUsernames->setOn(true);} else{ View_HideUsernames->setOn(false);} @@ -246,16 +198,16 @@ SetupColumns(); InitMenus(); if(ArgFile==""){ - if(config.OpenLast && config.LastFile!="") - {QFileInfo file(config.LastFile); - if(file.exists() && file.isFile())OpenDatabase(config.LastFile); - else config.LastFile="";} + 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; + else {cout << "file not found "<< ArgFile << endl;} } @@ -275,9 +227,6 @@ if(tmpImg.load(appdir+"/../share/keepass/"+name)==false){ CMainWindow::~CMainWindow() { OnClose(); -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; delete Icon_Key32x32; delete Icon_Settings32x32; @@ -400,25 +349,25 @@ int NumColumns=EntryView->columns(); for(int i=0;iremoveColumn(0); int columnID[10]; int i=0; -if(config.Columns[0]){ +if(config->Columns[0]){ columnID[0]=EntryView->addColumn(trUtf8("Titel"),0); i++;} -if(config.Columns[1]){ +if(config->Columns[1]){ columnID[1]=EntryView->addColumn(trUtf8("Benutzername"),0); i++;} -if(config.Columns[2]){ +if(config->Columns[2]){ columnID[2]=EntryView->addColumn(trUtf8("URL"),0); i++;} -if(config.Columns[3]){ +if(config->Columns[3]){ columnID[3]=EntryView->addColumn(trUtf8("Passwort"),0); i++;} -if(config.Columns[4]){ +if(config->Columns[4]){ columnID[4]=EntryView->addColumn(trUtf8("Kommentare"),0); i++;} -if(config.Columns[5]){ +if(config->Columns[5]){ columnID[5]=EntryView->addColumn(trUtf8("Gültig bis"),0); i++;} -if(config.Columns[6]){ +if(config->Columns[6]){ columnID[6]=EntryView->addColumn(trUtf8("Erstellung"),0); i++;} -if(config.Columns[7]){ +if(config->Columns[7]){ columnID[7]=EntryView->addColumn(trUtf8("letzte Änderung"),0); i++;} -if(config.Columns[8]){ +if(config->Columns[8]){ columnID[8]=EntryView->addColumn(trUtf8("letzter Zugriff"),0); i++;} -if(config.Columns[9]){ +if(config->Columns[9]){ columnID[9]=EntryView->addColumn(trUtf8("Anhang"),0); i++;} ResizeColumns(); @@ -445,32 +394,32 @@ CEntry* entry=&db->Entries[i]; if((CurrentGroup->pGroup->ID==entry->GroupID) || (CurrentGroup->pGroup->ID==db->SearchGroupID && isInSearchResults(entry))){ EntryItems.push_back(tmp=new EntryItem(entry,EntryView)); int j=0; -if(config.Columns[0]){ +if(config->Columns[0]){ tmp->setText(j++,entry->Title);} -if(config.Columns[1]){ - if(config.ListView_HideUsernames) +if(config->Columns[1]){ + if(config->ListView_HideUsernames) tmp->setText(j++,"******"); else tmp->setText(j++,entry->UserName);} -if(config.Columns[2]){ +if(config->Columns[2]){ tmp->setText(j++,entry->URL);} -if(config.Columns[3]){ - if(config.ListView_HidePasswords) +if(config->Columns[3]){ + if(config->ListView_HidePasswords) tmp->setText(j++,"******"); else{ tmp->setText(j++,entry->Password.getString()); entry->Password.delRef();}} -if(config.Columns[4]){ +if(config->Columns[4]){ tmp->setText(j++,entry->Additional.section('\n',0,0));} -if(config.Columns[5]){ +if(config->Columns[5]){ tmp->setText(j++,entry->Expire.GetString(0));} -if(config.Columns[6]){ +if(config->Columns[6]){ tmp->setText(j++,entry->Creation.GetString(0));} -if(config.Columns[7]){ +if(config->Columns[7]){ tmp->setText(j++,entry->LastMod.GetString(0));} -if(config.Columns[8]){ +if(config->Columns[8]){ tmp->setText(j++,entry->LastAccess.GetString(0));} -if(config.Columns[9]){ +if(config->Columns[9]){ tmp->setText(j++,entry->BinaryDesc);} (*(EntryItems.end()-1))->setPixmap(0,EntryIcons[entry->ImageID]); } @@ -509,6 +458,11 @@ updateGroupView(); SetFileMenuState(STATE_FileOpen); */ //////////////////////////////////// + + + + + } } @@ -520,9 +474,9 @@ OnEditEntry(); void CMainWindow::CreateBanner(QLabel *Banner,QPixmap* symbol,QString text){ -CreateBanner(Banner,symbol,text,config.BannerColor1 - ,config.BannerColor2 - ,config.BannerTextColor); //überladene Funktion wird aufgerufen +CreateBanner(Banner,symbol,text,config->BannerColor1 + ,config->BannerColor2 + ,config->BannerTextColor); //überladene Funktion wird aufgerufen } void CMainWindow::CreateBanner(QLabel *Banner,QPixmap* symbol,QString text,QColor color1,QColor color2,QColor textcolor){ @@ -582,7 +536,7 @@ EntryView->clear(); EntryItems.clear(); GroupView->clear(); GroupItems.clear(); -config.LastFile=db->filename; +config->LastFile=db->filename; db->CloseDataBase(); delete db; FileOpen=false; @@ -611,7 +565,7 @@ void CMainWindow::OnFileSaveAs() QString filename=QFileDialog::getSaveFileName(QDir::homeDirPath(),"*.kdb",this,trUtf8("Datenbank öffnen")); if(filename=="")return; db->filename=filename; -config.LastFile=filename; +config->LastFile=filename; db->SaveDataBase(filename); setModFlag(false); parentWidget()->setCaption(tr("Keepass - %1").arg(filename)); @@ -767,14 +721,14 @@ setModFlag(true); void CMainWindow::OnPasswordToClipboard() { Clipboard->setText(currentEntry()->Password.getString(),QClipboard::Clipboard); -ClipboardTimer.start(config.ClipboardTimeOut*1000,true); +ClipboardTimer.start(config->ClipboardTimeOut*1000,true); currentEntry()->Password.delRef(); } void CMainWindow::OnUserNameToClipboard() { Clipboard->setText(currentEntry()->UserName, QClipboard::Clipboard); -ClipboardTimer.start(config.ClipboardTimeOut*1000,true); +ClipboardTimer.start(config->ClipboardTimeOut*1000,true); } void CMainWindow::OnClipboardTimerEvent(){ @@ -788,7 +742,7 @@ OpenURL(currentEntry()->URL); void CMainWindow::OpenURL(QString url){ QProcess browser; -browser.setArguments(QStringList::split(' ',config.OpenUrlCommand.arg(url))); +browser.setArguments(QStringList::split(' ',config->OpenUrlCommand.arg(url))); browser.start(); } @@ -1077,7 +1031,7 @@ else delete db; void CMainWindow::OnViewToolbarToggled(bool toggled) { -config.Toolbar=toggled; +config->Toolbar=toggled; if(toggled){ Toolbar->show(); } @@ -1089,7 +1043,7 @@ Toolbar->hide(); void CMainWindow::OnViewEntryDetailsToggled(bool toggled) { -config.EntryDetails=toggled; +config->EntryDetails=toggled; if(toggled){ SummaryField->show(); } @@ -1115,7 +1069,7 @@ pDlg->show(); void CMainWindow::OnView_ColumnExpireToggled(bool value) { -config.Columns[5]=value; +config->Columns[5]=value; SetupColumns(); updateEntryView(); @@ -1123,14 +1077,14 @@ updateEntryView(); void CMainWindow::OnView_ColumnAttachmentToggled(bool value) { -config.Columns[9]=value; +config->Columns[9]=value; SetupColumns(); updateEntryView(); } void CMainWindow::OnView_ColumnUrlToggled(bool value) { -config.Columns[2]=value; +config->Columns[2]=value; SetupColumns(); updateEntryView(); } @@ -1138,7 +1092,7 @@ updateEntryView(); void CMainWindow::OnView_ColumnTitleToggled(bool value) { -config.Columns[0]=value; +config->Columns[0]=value; SetupColumns(); updateEntryView(); } @@ -1146,7 +1100,7 @@ updateEntryView(); void CMainWindow::OnView_ColumnCreationToggled(bool value) { -config.Columns[6]=value; +config->Columns[6]=value; SetupColumns(); updateEntryView(); } @@ -1154,7 +1108,7 @@ updateEntryView(); void CMainWindow::OnView_ColumnLastAccessToggled(bool value) { -config.Columns[8]=value; +config->Columns[8]=value; SetupColumns(); updateEntryView(); } @@ -1162,7 +1116,7 @@ updateEntryView(); void CMainWindow::OnView_ColumnLastModToggled(bool value) { -config.Columns[7]=value; +config->Columns[7]=value; SetupColumns(); updateEntryView(); } @@ -1170,7 +1124,7 @@ updateEntryView(); void CMainWindow::OnView_ColumnCommentToggled(bool value) { -config.Columns[4]=value; +config->Columns[4]=value; SetupColumns(); updateEntryView(); } @@ -1178,14 +1132,14 @@ updateEntryView(); void CMainWindow::OnView_ColumnPasswordToggled(bool value) { -config.Columns[3]=value; +config->Columns[3]=value; SetupColumns(); updateEntryView(); } void CMainWindow::OnView_ColumnUsernameToggled(bool value) { -config.Columns[1]=value; +config->Columns[1]=value; SetupColumns(); updateEntryView(); } @@ -1281,7 +1235,7 @@ switch(ret){ } QString filename=QFileDialog::getOpenFileName(QDir::homeDirPath(),"*.pwm",this,trUtf8("Datenbank importieren")); if(filename=="")return; -CSimplePasswordDialog dlg(!config.ShowPasswords,this,"SimplePasswordDlg",true); +CSimplePasswordDialog dlg(!config->ShowPasswords,this,"SimplePasswordDlg",true); if(!dlg.exec())return; Import_PwManager importer; QString err; @@ -1314,7 +1268,7 @@ FileOpen=true; void CMainWindow::OnView_HideUsernamesToggled(bool state) { -config.ListView_HideUsernames=state; +config->ListView_HideUsernames=state; updateEntryView(); updateEntryDetails(); } @@ -1322,7 +1276,7 @@ updateEntryDetails(); void CMainWindow::OnView_HidePasswordsToggled(bool state) { -config.ListView_HidePasswords=state; +config->ListView_HidePasswords=state; updateEntryView(); updateEntryDetails(); } @@ -1390,12 +1344,12 @@ 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); +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()); +if(!config->ListView_HidePasswords) str=str.arg(entry.Password.getString()); else str=str.arg("****"); str=str.arg(entry.Creation.GetString(0)) diff --git a/src/mainwindow.h b/src/mainwindow.h index d55d5c0..7c368d9 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -40,7 +40,7 @@ Q_OBJECT public: /*$PUBLIC_FUNCTIONS$*/ - CMainWindow(QApplication* app,QString ArgFile,QString ArgCfg, QWidget* parent = 0,const char* name = 0, WFlags fl = 0 ); + CMainWindow(QApplication* app,QString ArgFile,CConfig* config, QWidget* parent = 0,const char* name = 0, WFlags fl = 0 ); ~CMainWindow(); protected: /*$PROTECTED_FUNCTIONS$*/ @@ -125,7 +125,7 @@ public: QPixmap* Icon_Ok16x16; QTimer ClipboardTimer; QString appdir; - CConfig config; + CConfig* config; enum FileMenuState{STATE_FileOpen, STATE_NoFileOpen}; @@ -146,6 +146,7 @@ public: void OpenURL(QString url); GroupItem* getLastSameLevelItem(int i); + void setCurrentGroup(GroupItem* item); void updateEntryView(); void updateGroupView(); diff --git a/src/pwsafe.cpp b/src/pwsafe.cpp index da610bb..34648e1 100755 --- a/src/pwsafe.cpp +++ b/src/pwsafe.cpp @@ -21,31 +21,10 @@ #include "mainwindow.h" #include "pwsafe.h" -PwSafe::PwSafe(QApplication* app):QMainWindow( 0, "Keepass",WDestructiveClose) +PwSafe::PwSafe(QApplication* app,QString& ArgFile,CConfig* cfg):QMainWindow( 0, "Keepass") { -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); + mainWin=new CMainWindow(app,ArgFile,cfg,this); setCentralWidget( mainWin ); } @@ -53,12 +32,4 @@ int i=1; 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 0d87b5d..7ed33c5 100755 --- a/src/pwsafe.h +++ b/src/pwsafe.h @@ -24,6 +24,7 @@ #include #include +#include "PwmConfig.h" class CMainWindow; @@ -34,7 +35,7 @@ public: /** * Default Constructor */ - PwSafe(QApplication*); + PwSafe(QApplication*,QString&, CConfig*); /** * Default Destructor @@ -43,7 +44,6 @@ public: private: CMainWindow *mainWin; - void argHelp(); }; #endif // _PWSAFE_H_ diff --git a/src/src.pro b/src/src.pro index 145a71f..1b184bd 100755 --- a/src/src.pro +++ b/src/src.pro @@ -8,17 +8,6 @@ INSTALLS += Share \ target.path = /usr/local/bin Share.files += ../share/keepass/* Share.path = /usr/local/share/keepass -MOC_DIR = ../build/moc -UI_DIR = ../build/ui -OBJECTS_DIR = ../build/ -TARGET = ../bin/keepass -CONFIG += debug \ - warn_off \ - qt \ - thread \ - exceptions \ - stl -TEMPLATE = app FORMS += forms/ui_EditGroupDlg.ui \ forms/ui_SearchDlg.ui \ forms/ui_AboutDlg.ui \ @@ -62,7 +51,9 @@ HEADERS += lib/IniReader.h \ dialogs/PasswordGenDlg.h \ lib/random.h \ Database.h \ - lib/PwmTime.h + lib/PwmTime.h \ + lib/KdePlugin.h \ + global.h SOURCES += lib/IniReader.cpp \ lib/UrlLabel.cpp \ main.cpp \ @@ -93,4 +84,16 @@ SOURCES += lib/IniReader.cpp \ dialogs/PasswordGenDlg.cpp \ lib/random.cpp \ Database.cpp \ - lib/PwmTime.cpp + lib/PwmTime.cpp \ + lib/KdePlugin.cpp +MOC_DIR = ../build/moc +UI_DIR = ../build/ui +OBJECTS_DIR = ../build/ +TARGET = ../bin/keepass +CONFIG += debug \ +warn_off \ +qt \ +thread \ +exceptions \ +stl +TEMPLATE = app