git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@4 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 95b9a258a1
commit 192dbba0e4
  1. BIN
      share/keepass/i18n/english.qm
  2. 4
      src/Database.h
  3. 59
      src/PwManager.cpp
  4. 5
      src/PwManager.h
  5. 2
      src/PwmConfig.cpp
  6. 1
      src/PwmConfig.h
  7. 2
      src/crypto/blowfish.cpp
  8. 5
      src/crypto/blowfish.h
  9. 4
      src/crypto/sha1.cpp
  10. 2
      src/crypto/sha1.h
  11. 2
      src/dialogs/ChangeKeyDlg.cpp
  12. 3
      src/dialogs/EditEntryDlg.cpp
  13. 6
      src/dialogs/LanguageDlg.cpp
  14. 2
      src/dialogs/PasswordDlg.cpp
  15. 32
      src/dialogs/SearchDlg.cpp
  16. 38
      src/dialogs/SettingsDlg.cpp
  17. 13
      src/forms/ui_EditEntryDlg.ui
  18. 3
      src/global.h
  19. 8
      src/lib/KdePlugin.cpp
  20. 13
      src/lib/KdePlugin.h
  21. 136
      src/main.cpp
  22. 196
      src/mainwindow.cpp
  23. 5
      src/mainwindow.h
  24. 33
      src/pwsafe.cpp
  25. 4
      src/pwsafe.h
  26. 29
      src/src.pro

Binary file not shown.

@ -85,8 +85,8 @@ public:
class Database:public AbstractDatabase{
public:
int CryptoAlgorithmus;
int KeyEncRounds;
UINT32 CryptoAlgorithmus;
UINT32 KeyEncRounds;
QString filename;
bool modflag;
int SearchGroupID;

@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "global.h"
#include <iostream.h>
#include <time.h>
#include <qfile.h>
@ -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
}

@ -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 <qcolor.h>
#include <qobject.h>
@ -77,4 +77,7 @@ private:
bool convHexToBinaryKey(char* HexKey, char* dst);
};
void memcpyFromLEnd32(UINT32* dst,char* src);
void memcpyFromLEnd16(UINT16* dst,char* src);
#endif

@ -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;
}

@ -45,6 +45,7 @@ public:
int PwGenLength;
QString PwGenCharList;
bool ExpandGroupTree;
bool EnableKdePlugin;
bool loadFromIni(QString filename);
bool saveToIni(QString filename);

@ -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];

@ -15,6 +15,7 @@
#ifndef BLOWFISH_H
#define BLOWFISH_H
#include "global.h"
#include <stdint.h>
#include <string>
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

@ -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

@ -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

@ -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()){

@ -33,6 +33,7 @@
#include <qpen.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qtoolbutton.h>
#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");

@ -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;j<pItems.size();j++){
if(j==i)pItems[j]->setPixmap(0,*parentwnd->Icon_Ok16x16);

@ -57,7 +57,7 @@ Combo_Dirs->insertItem(0,Paths[i]);
IsFile.append(false);
}
if(!parentwnd->config.ShowPasswords)ChangeEchoMode();
if(!parentwnd->config->ShowPasswords)ChangeEchoMode();
}

@ -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()

@ -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();
}

@ -80,7 +80,7 @@
<string>120 Bits</string>
</property>
</widget>
<widget class="QPushButton">
<widget class="QToolButton">
<property name="name">
<cstring>ButtonDeleteAttachment</cstring>
</property>
@ -99,7 +99,7 @@
<pixmap>image0</pixmap>
</property>
</widget>
<widget class="QPushButton">
<widget class="QToolButton">
<property name="name">
<cstring>ButtonGenPw</cstring>
</property>
@ -205,7 +205,7 @@
<string>Icon:</string>
</property>
</widget>
<widget class="QPushButton">
<widget class="QToolButton">
<property name="name">
<cstring>ButtonEchoMode</cstring>
</property>
@ -220,11 +220,8 @@
<property name="text">
<string>...</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton">
<widget class="QToolButton">
<property name="name">
<cstring>ButtonSaveAttachment</cstring>
</property>
@ -243,7 +240,7 @@
<pixmap>image1</pixmap>
</property>
</widget>
<widget class="QPushButton">
<widget class="QToolButton">
<property name="name">
<cstring>ButtonOpenAttachment</cstring>
</property>

@ -0,0 +1,3 @@
#define KEEPASS_LITTLE_ENDIAN
//#define KEEPASS_BIG_ENDIAN

@ -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;
}

@ -0,0 +1,13 @@
#ifndef _KDEPLUGIN_H_
#define _KDEPLUGIN_H_
#include <qlibrary.h>
#include <qapplication.h>
class CKdePlugin{
public:
bool resolveSymbols(QLibrary& lib);
QApplication*(*getAppObj)(int,char**);
};
#endif

@ -19,24 +19,144 @@
***************************************************************************/
#include <iostream.h>
#include "pwsafe.h"
#include <qapplication.h>
#include <qlibrary.h>
#include <qlocale.h>
#include <qdir.h>
#include <qmessagebox.h>
#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; i<argc;i++){
if(QString(argv[i])=="-h"){
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);
}
else if(QString(argv[i])=="-cfg"){
if(i-1==argc) cout << "No configuration file specified." << endl;
else{ArgCfg=QString::fromUtf8(argv[i+1]); i++;}
}
else{cout << "** Unrecognized option: " << argv[i] << endl;
exit(1);}
}
}
}
int main(int argc, char **argv)
{
QApplication app(argc,argv);
PwSafe *mainWin = 0;
/// @todo do something with the command line args here
mainWin = new PwSafe(&app);
app.setMainWidget( mainWin );
mainWin->show();
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 <kapplication.h>

@ -37,6 +37,7 @@
#include <qvaluelist.h>
#include <qlocale.h>
#include <qmessagebox.h>
#include <qlibrary.h>
//STD
#include <time.h>
//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;i<NumColumns;i++)EntryView->removeColumn(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("<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);
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))

@ -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();

@ -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; 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);
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);
}

@ -24,6 +24,7 @@
#include <qapplication.h>
#include <qmainwindow.h>
#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_

@ -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