From bdec5c8450c56bb344e8a91d24e57ec2935fea21 Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Thu, 6 Mar 2008 20:11:29 +0000 Subject: [PATCH] - support for precompiled headers - made password dialog more userfriendly (especially key file creation/selection) - database file as command line argument is recognized again - fixed bug #1825446 (commandline option -cfg does NOT take relative path) - fixed mac buid problem (see item #1908868) git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@174 b624d157-de02-0410-bad0-e51aec6abb33 --- changelog | 12 + src/Application_X11.cpp | 1 + src/Application_X11.h | 1 - src/Database.cpp | 4 +- src/Database.h | 28 +- src/Kdb3Database.cpp | 84 +--- src/Kdb3Database.h | 22 +- src/KpxConfig.cpp | 5 - src/KpxConfig.h | 9 +- src/crypto/twofish.cpp | 2 +- src/crypto/twofish.h | 4 + src/crypto/yarrow.cpp | 4 - src/dialogs/AboutDlg.cpp | 5 +- src/dialogs/AboutDlg.h | 4 - src/dialogs/AddBookmarkDlg.cpp | 5 - src/dialogs/AddBookmarkDlg.h | 4 - src/dialogs/AutoTypeDlg.cpp | 6 +- src/dialogs/AutoTypeDlg.h | 1 - src/dialogs/CalendarDlg.cpp | 3 +- src/dialogs/CalendarDlg.h | 1 - src/dialogs/CollectEntropyDlg.cpp | 5 - src/dialogs/CollectEntropyDlg.h | 6 - src/dialogs/CustomizeDetailViewDlg.cpp | 8 - src/dialogs/CustomizeDetailViewDlg.h | 2 - src/dialogs/DatabaseSettingsDlg.cpp | 9 +- src/dialogs/DatabaseSettingsDlg.h | 3 - src/dialogs/EditEntryDlg.cpp | 16 - src/dialogs/EditEntryDlg.h | 4 +- src/dialogs/EditGroupDlg.cpp | 2 - src/dialogs/EditGroupDlg.h | 3 - src/dialogs/ExpiredEntriesDlg.cpp | 7 +- src/dialogs/ExpiredEntriesDlg.h | 4 +- src/dialogs/ManageBookmarksDlg.cpp | 7 +- src/dialogs/ManageBookmarksDlg.h | 3 - src/dialogs/PasswordDlg.cpp | 548 ++++++++++++------------- src/dialogs/PasswordDlg.h | 93 +++-- src/dialogs/PasswordGenDlg.cpp | 14 +- src/dialogs/PasswordGenDlg.h | 3 - src/dialogs/SearchDlg.cpp | 10 +- src/dialogs/SearchDlg.h | 4 - src/dialogs/SelectIconDlg.cpp | 13 +- src/dialogs/SelectIconDlg.h | 5 - src/dialogs/SettingsDlg.cpp | 12 +- src/dialogs/SettingsDlg.h | 5 - src/dialogs/SimplePasswordDlg.cpp | 5 +- src/export/Export.cpp | 6 +- src/export/Export.h | 4 - src/export/Export_KeePassX_Xml.cpp | 3 +- src/export/Export_KeePassX_Xml.h | 1 - src/export/Export_Txt.cpp | 5 +- src/export/Export_Txt.h | 1 - src/forms/PasswordDlg.ui | 345 +++++++++------- src/import/Import.cpp | 6 +- src/import/Import.h | 5 - src/import/Import_KWalletXml.cpp | 5 +- src/import/Import_KWalletXml.h | 2 +- src/import/Import_KeePassX_Xml.cpp | 4 +- src/import/Import_KeePassX_Xml.h | 1 - src/import/Import_PwManager.cpp | 11 +- src/import/Import_PwManager.h | 4 +- src/lib/AutoType.h | 3 - src/lib/AutoType_X11.cpp | 12 +- src/lib/EntryView.cpp | 20 +- src/lib/EntryView.h | 10 +- src/lib/FileDialogs.cpp | 6 +- src/lib/FileDialogs.h | 6 +- src/lib/GroupView.cpp | 19 +- src/lib/GroupView.h | 5 +- src/lib/HelperX11.cpp | 1 - src/lib/SecString.cpp | 5 +- src/lib/SecString.h | 5 - src/lib/ShortcutWidget.h | 1 - src/lib/UrlLabel.cpp | 9 - src/lib/UrlLabel.h | 2 - src/lib/WaitAnimationWidget.cpp | 5 +- src/lib/WaitAnimationWidget.h | 7 +- src/lib/bookmarks.cpp | 4 +- src/lib/bookmarks.h | 3 - src/lib/random.h | 6 + src/lib/tools.cpp | 41 +- src/lib/tools.h | 6 +- src/main.cpp | 34 +- src/main.h | 32 +- src/main_macx.cpp | 4 +- src/main_unix.cpp | 56 ++- src/main_win32.cpp | 2 - src/mainwindow.cpp | 111 ++--- src/mainwindow.h | 20 - src/src.pro | 122 +++--- 89 files changed, 811 insertions(+), 1145 deletions(-) diff --git a/changelog b/changelog index a405b91..93dd7d4 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,15 @@ +--------------- + 0.3.1 +--------------- +- made key/password dialog more user friendly +- program accepts Qt command line switches like "-style" again + +--------------- + 0.3.0a +--------------- +- fixed bug which prevented MacOS X bundle from starting (Bug #1906517) +- fixed error message about missing license file when opening about dialog (Bug #1906696) + --------------- 0.3.0 --------------- diff --git a/src/Application_X11.cpp b/src/Application_X11.cpp index ceb4966..5ed3f3f 100644 --- a/src/Application_X11.cpp +++ b/src/Application_X11.cpp @@ -17,6 +17,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + #include "Application_X11.h" #include "lib/AutoType.h" #include "lib/HelperX11.h" diff --git a/src/Application_X11.h b/src/Application_X11.h index f6dd374..8b7d4b1 100644 --- a/src/Application_X11.h +++ b/src/Application_X11.h @@ -20,7 +20,6 @@ #ifndef APPLICATION_X11_H #define APPLICATION_X11_H -#include class KeepassApplication : public QApplication { diff --git a/src/Database.cpp b/src/Database.cpp index d89d679..cdc434f 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -18,9 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "Database.h" -#include "lib/random.h" -#include + KpxUuid::KpxUuid(){ Data.fill(0,16); diff --git a/src/Database.h b/src/Database.h index d766a60..9e289a7 100644 --- a/src/Database.h +++ b/src/Database.h @@ -21,14 +21,6 @@ #ifndef _DATABASE_H_ #define _DATABASE_H_ -#include -#include -#include -#include -#include -#include "lib/SecString.h" -using namespace std; - extern const QDateTime Date_Never; typedef enum CryptAlgorithm{ @@ -246,6 +238,9 @@ This is the common base interface for databases. Every database class must imple class IDatabase:public QObject{ public: virtual ~IDatabase(){}; + + virtual bool setKey(const QString& password,const QString& keyfile)=0; + virtual bool isKeyError()=0; //! Loads a database. /*! It is not allowed to call this function if a database is already loaded. @@ -409,23 +404,6 @@ public: }; - -//! Interface for password/file based authentication -class IFilePasswordAuth{ -public: - virtual void authByPwd(QString& password)=0; - virtual bool authByFile(QString& filename)=0; - virtual bool authByFileAndPwd(QString& password, QString& filename)=0; - /*! Creates a key file. - \param filename Filename of the new key file. - \param length Length of the key file. - \param Hex Wether the key file should be binary or hexadecimal ASCII code. If Hex is true the real file size will be double of length. - \return TRUE if the creation was successfull, otherwise FALSE. - */ - virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false)=0; - virtual bool isKeyError()=0; -}; - class IKdbSettings{ public: virtual void setCryptAlgorithm(CryptAlgorithm algo)=0; diff --git a/src/Kdb3Database.cpp b/src/Kdb3Database.cpp index a9a06a7..00c5398 100644 --- a/src/Kdb3Database.cpp +++ b/src/Kdb3Database.cpp @@ -17,23 +17,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "global.h" -#include -#include -#include -#include -#include -#include #include -#include -#include "crypto/twoclass.h" -#include "crypto/aescpp.h" -#include "crypto/sha256.h" -#include "crypto/yarrow.h" -#include "lib/random.h" -using namespace std; #include "Kdb3Database.h" -#include "KpxConfig.h" + #define UNEXP_ERROR error=QString("Unexpected error in: %1, Line:%2").arg(__FILE__).arg(__LINE__); @@ -739,29 +725,26 @@ bool Kdb3Database::convHexToBinaryKey(char* HexKey, char* dst){ return true; } -/* -void Kdb3Database::authByPwd(QString& Password){ - if(!Password.size()) { - memcpy(RawMasterKey,QByteArray(32,'\0').data(),32); - return; - } - SHA256::hashBuffer(Password.toUtf8().data(),RawMasterKey,Password.toUtf8().size()); - return; -}*/ +bool Kdb3Database::setKey(const QString& password,const QString& keyfile){ + if(!password.isEmpty() && !keyfile.isEmpty()) + return setCompositeKey(password,keyfile); + if(!password.isEmpty()) + return setPasswordKey(password); + if(!keyfile.isEmpty()) + return setFileKey(keyfile); + assert(false); +} -void Kdb3Database::authByPwd(QString& Password){ - if(!Password.size()) { - memcpy(RawMasterKey,QByteArray(32,'\0').data(),32); - return; - } +bool Kdb3Database::setPasswordKey(const QString& Password){ + assert(Password.size()); SHA256::hashBuffer(Password.toLatin1().data(),RawMasterKey,Password.toLatin1().size()); QByteArray lat,utf; utf=Password.toUtf8(); lat=Password.toLatin1(); - return; + return true; } -bool Kdb3Database::authByFile(QString& filename){ +bool Kdb3Database::setFileKey(const QString& filename){ QFile file(filename); if(!file.open(QIODevice::ReadOnly|QIODevice::Unbuffered)){ error=decodeFileError(file.error()); @@ -799,14 +782,13 @@ bool Kdb3Database::authByFile(QString& filename){ return true; } -bool Kdb3Database::authByFileAndPwd(QString& Password, QString& filename){ +bool Kdb3Database::setCompositeKey(const QString& Password,const QString& filename){ unsigned char PasswordKey[32]; unsigned char FileKey[32]; - if(!authByFile(filename))return false; + if(!setFileKey(filename))return false; memcpy(FileKey,RawMasterKey,32); - authByPwd(Password); + setPasswordKey(Password); memcpy(PasswordKey,RawMasterKey,32); - SHA256 sha; sha.update(PasswordKey,32); sha.update(FileKey,32); @@ -1637,38 +1619,6 @@ void Kdb3Database::rebuildIndices(QList& list){ } } -bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){ - QFile file(filename); - if(!file.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Unbuffered)){ - error=decodeFileError(file.error()); - return false; - } - if(Hex)length*=2; - unsigned char* key=new unsigned char[length]; - randomize(key,length); - if(Hex){ - for(int i=0; i9)key[i]='A'+dig1-10; - else key[i]='0'+dig1; - if(dig2>9)key[i+1]='A'+dig2-10; - else key[i+1]='0'+dig2; - } - } - if(file.write((char*)key,length)==-1){ - delete [] key; - error=decodeFileError(file.error()); - file.close(); - return false; - } - file.close(); - delete [] key; - return true; -} - void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,int Pos){ StdGroup* Parent; diff --git a/src/Kdb3Database.h b/src/Kdb3Database.h index a20d92b..91a2f1b 100644 --- a/src/Kdb3Database.h +++ b/src/Kdb3Database.h @@ -30,25 +30,13 @@ #define PWM_FLAG_TWOFISH 8 #define PWM_STD_KEYENCROUNDS 6000 -#include -#include -#include -#include -#include -#include -#include -#include "main.h" -#include "lib/SecString.h" -#include "Database.h" - - void memcpyFromLEnd32(quint32* dst,const char* src); void memcpyFromLEnd16(quint16* dst,const char* src); void memcpyToLEnd32(char* src,const quint32* dst); void memcpyToLEnd16(char* src,const quint16* dst); //! Implementation of the standard KeePassX database. -class Kdb3Database:public ICustomIcons,public IDatabase, public IFilePasswordAuth, public IKdbSettings{ +class Kdb3Database:public ICustomIcons,public IDatabase, public IKdbSettings{ Q_OBJECT public: class StdGroup; @@ -169,10 +157,6 @@ public: virtual void removeIcon(int index); virtual void replaceIcon(int index,const QPixmap& icon); virtual int builtinIcons(){return BUILTIN_ICONS;}; - virtual void authByPwd(QString& password); - virtual bool authByFile(QString& filename); - virtual bool authByFileAndPwd(QString& password, QString& filename); - virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false); virtual QList search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields); virtual QFile* file(){return File;} virtual bool changeFile(const QString& filename); @@ -180,6 +164,10 @@ public: virtual CryptAlgorithm cryptAlgorithm(){return Algorithm;} virtual unsigned int keyTransfRounds(){return KeyTransfRounds;} virtual void setKeyTransfRounds(unsigned int rounds){KeyTransfRounds=rounds;} + virtual bool setKey(const QString& password, const QString& keyfile); + virtual bool setPasswordKey(const QString& password); + virtual bool setFileKey(const QString& filename); + virtual bool setCompositeKey(const QString& password,const QString& filename); virtual QList entries(); virtual QList entries(IGroupHandle* Group); diff --git a/src/KpxConfig.cpp b/src/KpxConfig.cpp index 55292c9..8b7dfab 100644 --- a/src/KpxConfig.cpp +++ b/src/KpxConfig.cpp @@ -21,12 +21,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "KpxConfig.h" -#include -#include -#include #include -#include KpxConfig::KpxConfig(const QString& filePath) : settings(filePath,QSettings::IniFormat){ configFile=filePath; diff --git a/src/KpxConfig.h b/src/KpxConfig.h index 97363b6..b394c0f 100644 --- a/src/KpxConfig.h +++ b/src/KpxConfig.h @@ -23,14 +23,7 @@ #ifndef _KPXCONFIG_H_ #define _KPXCONFIG_H_ -#include "lib/tools.h" -#include "AutoType.h" -#include -#include -#include -#include -#include -#include +#include "lib/AutoType.h" #if defined(Q_WS_MAC) # define DEFAULT_MOUNT_DIR "/Volumes/" diff --git a/src/crypto/twofish.cpp b/src/crypto/twofish.cpp index dddf87c..e0fec8e 100644 --- a/src/crypto/twofish.cpp +++ b/src/crypto/twofish.cpp @@ -171,7 +171,7 @@ * Standard include files will probably be ok. */ -#include /* for memset(), memcpy(), and memcmp() */ +//#include /* for memset(), memcpy(), and memcmp() */ #include #include "twofish.h" diff --git a/src/crypto/twofish.h b/src/crypto/twofish.h index f492016..0d0d2f7 100644 --- a/src/crypto/twofish.h +++ b/src/crypto/twofish.h @@ -1,3 +1,5 @@ +#ifndef TWOFISH_H_ +#define TWOFISH_H_ /* * Fast, portable, and easy-to-use Twofish implementation, * Version 0.3. @@ -177,3 +179,5 @@ extern void Twofish_decrypt( Twofish_Byte c[16], Twofish_Byte p[16] ); + +#endif \ No newline at end of file diff --git a/src/crypto/yarrow.cpp b/src/crypto/yarrow.cpp index ed13e60..92b60d6 100644 --- a/src/crypto/yarrow.cpp +++ b/src/crypto/yarrow.cpp @@ -20,10 +20,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#if HAVE_CONFIG_H -# include "config.h" -#endif - #include #include #include diff --git a/src/dialogs/AboutDlg.cpp b/src/dialogs/AboutDlg.cpp index a3723f4..ec7d14e 100644 --- a/src/dialogs/AboutDlg.cpp +++ b/src/dialogs/AboutDlg.cpp @@ -17,10 +17,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include "lib/tools.h" + #include "AboutDlg.h" diff --git a/src/dialogs/AboutDlg.h b/src/dialogs/AboutDlg.h index 56c5847..1c03b94 100644 --- a/src/dialogs/AboutDlg.h +++ b/src/dialogs/AboutDlg.h @@ -20,11 +20,7 @@ #ifndef _ABOUTDIALOG_H_ #define _ABOUTDIALOG_H_ -#include #include "ui_AboutDlg.h" -#include "lib/UrlLabel.h" - -#include "main.h" class AboutDialog : public QDialog, public Ui_AboutDlg { diff --git a/src/dialogs/AddBookmarkDlg.cpp b/src/dialogs/AddBookmarkDlg.cpp index ace4afe..74fb64a 100644 --- a/src/dialogs/AddBookmarkDlg.cpp +++ b/src/dialogs/AddBookmarkDlg.cpp @@ -17,11 +17,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "lib/tools.h" -#include "lib/FileDialogs.h" -#include "lib/bookmarks.h" #include "AddBookmarkDlg.h" diff --git a/src/dialogs/AddBookmarkDlg.h b/src/dialogs/AddBookmarkDlg.h index d7f2541..7786a62 100644 --- a/src/dialogs/AddBookmarkDlg.h +++ b/src/dialogs/AddBookmarkDlg.h @@ -20,12 +20,8 @@ #ifndef _ADDBOOKMARKDLG_H_ #define _ADDBOOKMARKDLG_H_ -#include -#include #include "ui_AddBookmarkDlg.h" -#include "main.h" - class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg { Q_OBJECT diff --git a/src/dialogs/AutoTypeDlg.cpp b/src/dialogs/AutoTypeDlg.cpp index b32e522..274f6c1 100644 --- a/src/dialogs/AutoTypeDlg.cpp +++ b/src/dialogs/AutoTypeDlg.cpp @@ -17,12 +17,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "main.h" -#include "AutoTypeDlg.h" -#include "KpxConfig.h" #include -#include -#include +#include "AutoTypeDlg.h" AutoTypeDlg::AutoTypeDlg(QList entries, QList numbers){ setupUi(this); diff --git a/src/dialogs/AutoTypeDlg.h b/src/dialogs/AutoTypeDlg.h index 056115b..201e261 100644 --- a/src/dialogs/AutoTypeDlg.h +++ b/src/dialogs/AutoTypeDlg.h @@ -18,7 +18,6 @@ ***************************************************************************/ #include "ui_AutoTypeDlg.h" -#include "Database.h" class AutoTypeDlg : public QWidget, private Ui::AutoTypeDlg { diff --git a/src/dialogs/CalendarDlg.cpp b/src/dialogs/CalendarDlg.cpp index 3216cc0..97868f7 100644 --- a/src/dialogs/CalendarDlg.cpp +++ b/src/dialogs/CalendarDlg.cpp @@ -18,8 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "lib/tools.h" -#include "main.h" + #include "CalendarDlg.h" CalendarDialog::CalendarDialog(QWidget* parent, const QDate& Start):QDialog(parent){ diff --git a/src/dialogs/CalendarDlg.h b/src/dialogs/CalendarDlg.h index 825a177..1fc0516 100644 --- a/src/dialogs/CalendarDlg.h +++ b/src/dialogs/CalendarDlg.h @@ -20,7 +20,6 @@ #ifndef _CALENDAR_DLG_H_ #define _CALENDAR_DLG_H_ -#include #include "ui_CalendarDlg.h" class CalendarDialog:public QDialog, public Ui_CalendarDialog{ diff --git a/src/dialogs/CollectEntropyDlg.cpp b/src/dialogs/CollectEntropyDlg.cpp index 208654a..63f747b 100644 --- a/src/dialogs/CollectEntropyDlg.cpp +++ b/src/dialogs/CollectEntropyDlg.cpp @@ -18,13 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include "lib/tools.h" #include "crypto/yarrow.h" - #include "CollectEntropyDlg.h" diff --git a/src/dialogs/CollectEntropyDlg.h b/src/dialogs/CollectEntropyDlg.h index e2c5cbb..015f8be 100644 --- a/src/dialogs/CollectEntropyDlg.h +++ b/src/dialogs/CollectEntropyDlg.h @@ -22,12 +22,6 @@ #define _COLLECT_ENTROPY_DLG_H_ #include "ui_CollectEntropyDlg.h" -#include -#include -#include - -#include "main.h" - class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{ Q_OBJECT diff --git a/src/dialogs/CustomizeDetailViewDlg.cpp b/src/dialogs/CustomizeDetailViewDlg.cpp index 9bb0622..9a033fb 100644 --- a/src/dialogs/CustomizeDetailViewDlg.cpp +++ b/src/dialogs/CustomizeDetailViewDlg.cpp @@ -18,16 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include #include -#include -#include -#include "main.h" #include "CustomizeDetailViewDlg.h" -#include "KpxConfig.h" bool DisableButtonSlots=false; diff --git a/src/dialogs/CustomizeDetailViewDlg.h b/src/dialogs/CustomizeDetailViewDlg.h index 1e7844d..6e6c499 100644 --- a/src/dialogs/CustomizeDetailViewDlg.h +++ b/src/dialogs/CustomizeDetailViewDlg.h @@ -21,8 +21,6 @@ #define _CUSTOMIZE_DETAIL_VIEW_H_ #include "ui_CustomizeDetailViewDlg.h" -#include -#include class CustomizeDetailViewDialog : public QDialog, public Ui_CustomizeDetailViewDialog{ Q_OBJECT diff --git a/src/dialogs/DatabaseSettingsDlg.cpp b/src/dialogs/DatabaseSettingsDlg.cpp index 2275423..61f4ebb 100644 --- a/src/dialogs/DatabaseSettingsDlg.cpp +++ b/src/dialogs/DatabaseSettingsDlg.cpp @@ -18,14 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "lib/tools.h" -#include "main.h" + #include "DatabaseSettingsDlg.h" diff --git a/src/dialogs/DatabaseSettingsDlg.h b/src/dialogs/DatabaseSettingsDlg.h index 0327192..f15c3dc 100644 --- a/src/dialogs/DatabaseSettingsDlg.h +++ b/src/dialogs/DatabaseSettingsDlg.h @@ -22,9 +22,6 @@ #define DBSETTINGSDLG_H #include "ui_DatabaseSettingsDlg.h" -#include "main.h" -#include "Database.h" -#include class CDbSettingsDlg : public QDialog, public Ui_DatabaseSettingsDlg { diff --git a/src/dialogs/EditEntryDlg.cpp b/src/dialogs/EditEntryDlg.cpp index ef461cd..5c519c4 100644 --- a/src/dialogs/EditEntryDlg.cpp +++ b/src/dialogs/EditEntryDlg.cpp @@ -18,29 +18,13 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "main.h" -#include "KpxConfig.h" -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include - #include "SelectIconDlg.h" #include "PasswordGenDlg.h" #include "EditEntryDlg.h" #include "CalendarDlg.h" - CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent, bool modal, bool newEntry) : QDialog(parent) { diff --git a/src/dialogs/EditEntryDlg.h b/src/dialogs/EditEntryDlg.h index 343f5f3..1dd80fc 100644 --- a/src/dialogs/EditEntryDlg.h +++ b/src/dialogs/EditEntryDlg.h @@ -20,10 +20,8 @@ #ifndef EDITENTRYDLG_H #define EDITENTRYDLG_H + #include "ui_EditEntryDlg.h" -#include -#include -#include "main.h" #include "Kdb3Database.h" class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog diff --git a/src/dialogs/EditGroupDlg.cpp b/src/dialogs/EditGroupDlg.cpp index b3b9a5d..8555db7 100644 --- a/src/dialogs/EditGroupDlg.cpp +++ b/src/dialogs/EditGroupDlg.cpp @@ -18,9 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "main.h" -#include #include "EditGroupDlg.h" #include "SelectIconDlg.h" diff --git a/src/dialogs/EditGroupDlg.h b/src/dialogs/EditGroupDlg.h index d57070a..b05e048 100644 --- a/src/dialogs/EditGroupDlg.h +++ b/src/dialogs/EditGroupDlg.h @@ -22,9 +22,6 @@ #define EDITGROUPDLG_H #include "ui_EditGroupDlg.h" -#include -#include -#include "Database.h" class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog { diff --git a/src/dialogs/ExpiredEntriesDlg.cpp b/src/dialogs/ExpiredEntriesDlg.cpp index 39c8d46..b91f9c2 100644 --- a/src/dialogs/ExpiredEntriesDlg.cpp +++ b/src/dialogs/ExpiredEntriesDlg.cpp @@ -18,12 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include "lib/tools.h" -#include "main.h" + #include "ExpiredEntriesDlg.h" ExpiredEntriesDialog::ExpiredEntriesDialog(QWidget* parent,IDatabase* database,const QList& ExpiredEntries):QDialog(parent){ diff --git a/src/dialogs/ExpiredEntriesDlg.h b/src/dialogs/ExpiredEntriesDlg.h index 8730d67..29c5122 100644 --- a/src/dialogs/ExpiredEntriesDlg.h +++ b/src/dialogs/ExpiredEntriesDlg.h @@ -21,10 +21,8 @@ #ifndef _EXP_ENTRIES_DLG_ #define _EXP_ENTRIES_DLG_ -#include -#include #include "ui_ExpiredEntriesDlg.h" -#include "Database.h" + class ExpiredEntriesDialog:public QDialog, public Ui_ExpiredEntriesDialog{ Q_OBJECT diff --git a/src/dialogs/ManageBookmarksDlg.cpp b/src/dialogs/ManageBookmarksDlg.cpp index 615cfc6..eeb6ad3 100644 --- a/src/dialogs/ManageBookmarksDlg.cpp +++ b/src/dialogs/ManageBookmarksDlg.cpp @@ -17,11 +17,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "lib/tools.h" -#include "ManageBookmarksDlg.h" -#include "lib/bookmarks.h" + +#include "dialogs/ManageBookmarksDlg.h" #include "dialogs/AddBookmarkDlg.h" ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent) diff --git a/src/dialogs/ManageBookmarksDlg.h b/src/dialogs/ManageBookmarksDlg.h index 85c4799..d670f51 100644 --- a/src/dialogs/ManageBookmarksDlg.h +++ b/src/dialogs/ManageBookmarksDlg.h @@ -20,9 +20,6 @@ #ifndef MANAGEBOOKMARKSDLG_H #define MANAGEBOOKMARKSDLG_H -#include -#include -#include #include "ui_ManageBookmarksDlg.h" #include "main.h" diff --git a/src/dialogs/PasswordDlg.cpp b/src/dialogs/PasswordDlg.cpp index b1dc280..524f849 100644 --- a/src/dialogs/PasswordDlg.cpp +++ b/src/dialogs/PasswordDlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2007 by Tarek Saidi * + * Copyright (C) 2005-2008 by Tarek Saidi * * tarek.saidi@arcor.de * * * * This program is free software; you can redistribute it and/or modify * @@ -17,372 +17,334 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include "dialogs/PasswordDlg.h" -#include "main.h" -#include "KpxConfig.h" -#include "PasswordDlg.h" -#include "lib/FileDialogs.h" -#include "lib/bookmarks.h" - - -CPasswordDialog::CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,bool IsAuto,bool ChangeKeyMode) +PasswordDialog::PasswordDialog(QWidget* parent,DlgMode mode,DlgFlags flags,const QString& filename) : QDialog(parent) { setupUi(this); - createBanner(&BannerPixmap,getPixmap("key"),tr("Database Key"),width()); - Button_Bookmarks->setIcon(getIcon("bookmark")); - db=DB; - LastFile=filename; - if (ChangeKeyMode) - setWindowTitle(tr("Change Master Key")); - else - setWindowTitle(LastFile); - QString mountDir=config->mountDir(); - QDir media(mountDir); - if(media.exists()){ + Mode=mode; + Filename=filename; + QString BannerTitle; + if(Mode==Mode_Ask){ + BannerTitle=tr("Enter Master Key"); + } + else if(Mode==Mode_Set){ + BannerTitle=tr("Set Master Key"); + } + else if(Mode==Mode_Change){ + BannerTitle=tr("Change Master Key"); + } + + if(filename==QString()){ + setWindowTitle(tr("Database Key")); + } + else { + setWindowTitle(filename); + } + + // Add list of subdirs in the mounting dir to the combobox. + // For example making /media/cd1 and /media/myflashdrive to two entries cd1 and myflashdrive in the combobox + QDir mountDir(config->mountDir()); + if(mountDir.exists()){ QStringList Paths; - Paths=media.entryList(QStringList()<<"*",QDir::Dirs | QDir::NoDotAndDotDot); + Paths=mountDir.entryList(QStringList()<<"*",QDir::Dirs | QDir::NoDotAndDotDot); for(int i=0;iaddItem(mountDir+Paths[i]); + Combo_KeyFile->addItem(config->mountDir()+Paths[i]); } - - Combo_Dirs->setEditText(QString()); - if(config->rememberLastKey() && config->openLastFile() && !ChangeKeyMode){ + Combo_KeyFile->setEditText(QString()); + + if(config->rememberLastKey() && Mode!=Mode_Change && Mode!=Mode_Set){ switch(config->lastKeyType()){ + case PASSWORD: + Check_Password->setChecked(true); + Check_KeyFile->setChecked(false); + Combo_KeyFile->setEditText(""); + break; + + case KEYFILE: + Check_Password->setChecked(false); + Check_KeyFile->setChecked(true); + Combo_KeyFile->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); + break; + + case BOTH: + Check_Password->setChecked(true); + Check_KeyFile->setChecked(true); + Combo_KeyFile->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); + break; + } + } + + if(Mode!=Mode_Set && Mode!=Mode_Change){ + Button_GenKeyFile->hide(); + } + if(flags & Flag_Auto){ + /* + QPushButton* Button_Quit = buttonBox->addButton(tr("Quit"),QDialogButtonBox::DestructiveRole); + connect(Button_Quit,SIGNAL(clicked()),this,SLOT(OnButtonQuit())); + */ + if(config->rememberLastKey()){ + switch(config->lastKeyType()){ + case PASSWORD: + Check_Password->setChecked(true); + Check_KeyFile->setChecked(false); + break; case KEYFILE: - setStateKeyFileOnly(); - Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); + Check_Password->setChecked(false); + Check_KeyFile->setChecked(true); + Combo_KeyFile->setEditText(config->lastKeyLocation()); break; - case BOTH: - setStateBoth(); - CheckBox_Both->setChecked(true); - Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); + Check_Password->setChecked(true); + Check_KeyFile->setChecked(true); + Combo_KeyFile->setEditText(config->lastKeyLocation()); + break; + } } - // if(LastKeyType==Password){... is not required because it is already the default state. } - // Bookmarks // - QPalette palette=Button_Bookmarks->palette(); - palette.setColor(QPalette::Active,QPalette::Button,config->bannerColor1()); - palette.setColor(QPalette::Active,QPalette::Window,config->bannerColor2()); - Button_Bookmarks->setPalette(palette); - palette=Label_Bookmark->palette(); - palette.setColor(QPalette::Active,QPalette::WindowText,config->bannerTextColor()); - Label_Bookmark->setPalette(palette); - - QMenu* BookmarkMenu=new QMenu(this); - QAction* action=new QAction(this); - action->setData(QString()); - action->setText(tr("Last File")); - action->setIcon(getIcon("document")); - BookmarkMenu->addAction(action); - BookmarkMenu->addSeparator(); - for(int i=0;ifeatureBookmarks()){ + // Button Color + QPalette palette=Button_Bookmarks->palette(); + palette.setColor(QPalette::Active,QPalette::Button,config->bannerColor1()); + palette.setColor(QPalette::Active,QPalette::Window,config->bannerColor2()); + Button_Bookmarks->setPalette(palette); + palette=Label_Bookmark->palette(); + palette.setColor(QPalette::Active,QPalette::WindowText,config->bannerTextColor()); + Label_Bookmark->setPalette(palette); + // Create menu and add "last file" menu entry + QMenu* BookmarkMenu=new QMenu(this); QAction* action=new QAction(this); - action->setData(KpxBookmarks::path(i)); - action->setText(KpxBookmarks::title(i)); + action->setData(QString()); + action->setText(tr("Last File")); action->setIcon(getIcon("document")); - BookmarkMenu->addAction(action); + BookmarkMenu->addAction(action); + BookmarkMenu->addSeparator(); + // Adding all existing bookmarks + for(int i=0;isetData(KpxBookmarks::path(i)); + action->setText(KpxBookmarks::title(i)); + action->setIcon(getIcon("document")); + BookmarkMenu->addAction(action); + } + Button_Bookmarks->setMenu(BookmarkMenu); + connect(BookmarkMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnBookmarkTriggered(QAction*))); } - Button_Bookmarks->setMenu(BookmarkMenu); - if(!IsAuto || !config->featureBookmarks()){ + else { Button_Bookmarks->hide(); Label_Bookmark->hide(); } - - connect(Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&))); - connect(ButtonBox, SIGNAL( rejected() ), this, SLOT( OnCancel() ) ); - connect(Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) ); - connect(CheckBox_Both, SIGNAL( stateChanged(int) ), this, SLOT( OnCheckBox_BothChanged(int) ) ); + + connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), this, SLOT( OnCancel() ) ); connect(ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoModeDatabaseKey() ) ); connect(Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); - connect(Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); - connect(BookmarkMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnBookmarkTriggered(QAction*))); - - Mode_Set=ChangeKeyMode; - if(!ChangeKeyMode){ - Edit_PasswordRep->hide(); - Label_PasswordRep->hide(); - connect( ButtonBox, SIGNAL( accepted() ), this, SLOT( OnOK() ) ); - connect( ButtonBrowse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse() ) ); - }else{ - connect( ButtonBox, SIGNAL( accepted() ), this, SLOT( OnOK_Set() ) ); - connect( ButtonBrowse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse_Set() ) ); - } - + connect(Edit_PwRepeat, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); + connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), this, SLOT( OnOK() ) ); + connect(Button_Browse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse() ) ); + connect(Button_GenKeyFile,SIGNAL(clicked()),this,SLOT(OnGenKeyFile())); + connect(Check_Password,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxesChanged(int))); + connect(Check_KeyFile,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxesChanged(int))); + connect(Button_Back,SIGNAL(clicked()),this,SLOT(OnButtonBack())); if(!config->showPasswordsPasswordDlg())ChangeEchoModeDatabaseKey(); + + adjustSize(); + setMaximumSize(size()); + setMinimumSize(size()); + createBanner(&BannerPixmap,getPixmap("key"),BannerTitle,width()); + Button_Bookmarks->setIcon(getIcon("bookmark")); + OnCheckBoxesChanged(0); } -void CPasswordDialog::setStatePasswordOnly(){ - Combo_Dirs->setEnabled(false); - ButtonBrowse->setEnabled(false); - Label_KeyFile->setEnabled(false); - Label_Password->setEnabled(true); - Label_PasswordRep->setEnabled(true); - Edit_Password->setEnabled(true); - Edit_PasswordRep->setEnabled(true); - ButtonChangeEchoMode->setEnabled(true); - KeyType=PASSWORD; -} - - -void CPasswordDialog::setStateKeyFileOnly(){ - Combo_Dirs->setEnabled(true); - ButtonBrowse->setEnabled(true); - Label_KeyFile->setEnabled(true); - Label_Password->setEnabled(false); - Label_PasswordRep->setEnabled(false); - Edit_Password->setEnabled(false); - Edit_PasswordRep->setEnabled(false); - ButtonChangeEchoMode->setEnabled(false); - KeyType=KEYFILE; -} - - -void CPasswordDialog::setStateBoth(){ - Combo_Dirs->setEnabled(true); - ButtonBrowse->setEnabled(true); - Label_KeyFile->setEnabled(true); - Label_Password->setEnabled(true); - Label_PasswordRep->setEnabled(true); - Edit_Password->setEnabled(true); - Edit_PasswordRep->setEnabled(true); - ButtonChangeEchoMode->setEnabled(true); - KeyType=BOTH; -} - - -void CPasswordDialog::OnButtonBrowse() +void PasswordDialog::OnButtonBrowse() { QString filename=KpxFileDialogs::openExistingFile(this,"PasswordDlg",tr("Select a Key File"), - QStringList() << tr("Key Files (*.key)") << tr("All Files (*)")); - if(filename!=QString()){ - Combo_Dirs->setEditText(filename); - } - return; + QStringList() << tr("All Files (*)") + << tr("Key Files (*.key)")); + if(filename!=QString()) + Combo_KeyFile->setEditText(filename); } -void CPasswordDialog::OnButtonBrowse_Set() +void PasswordDialog::OnCancel() { - QString filename=KpxFileDialogs::saveFile(this,"PasswordDlg",tr("Select a Key File"), - QStringList() << tr("Key Files (*.key)") << tr("All Files (*)"), - false); - if(filename!=QString()){ - Combo_Dirs->setEditText(filename); - } - return; + done(Exit_Cancel); } -void CPasswordDialog::OnCancel() -{ - done(0); -} - -void CPasswordDialog::OnOK(){ - password=Edit_Password->text(); - keyfile=Combo_Dirs->currentText(); - - if(password.isEmpty() && keyfile.isEmpty()){ - QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0); +void PasswordDialog::OnOK(){ + if(stackedWidget->currentIndex()==1){ + if(Password==Edit_PwRepeat->text()){ + done(Exit_Ok); + } + Edit_PwRepeat->clear(); + Edit_PwRepeat->setFocus(Qt::OtherFocusReason); + Label_Unequal->show(); + QTimer::singleShot(2000,Label_Unequal,SLOT(hide())); return; } - - if(KeyType==BOTH){ - if(password.isEmpty()){ - QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0); - return;} - if(keyfile.isEmpty()){ - QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0); - return;} + + Password=Edit_Password->text(); + KeyFile=Combo_KeyFile->currentText(); + + if(!Check_Password->isChecked() && !Check_KeyFile->isChecked()){ + showErrMsg(tr("Please enter a Password or select a key file."),this); + return; + } + + if(Check_Password->isChecked() && Password.isEmpty()){ + showErrMsg(tr("Please enter a Password.")); + return; + } + + if(Check_KeyFile->isChecked() && KeyFile.isEmpty()){ + showErrMsg(tr("Please provide a key file.")); + return; } - if(KeyType==BOTH || KeyType==KEYFILE){ - QFileInfo fileinfo(keyfile); + if(Check_KeyFile->isChecked()){ + /* Check wether key path exists and is readable */ + QFileInfo fileinfo(KeyFile); if(!fileinfo.exists()){ - QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory does not exist."),tr("OK"),"","",0,0); + showErrMsg(tr("%1:\nNo such file or directory.").arg(KeyFile),this); return; } if(!fileinfo.isReadable()){ - QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); + showErrMsg(tr("The selected key file or directory is not readable."),this); return; } + + /* If the given path is a directory, we need to find the key file in it */ if(fileinfo.isDir()){ - if(keyfile.right(1)!="/")keyfile+="/"; - QFile file(keyfile+"pwsafe.key"); - if(!file.exists()){ - QDir dir(keyfile); + if(KeyFile.right(1)!="/")KeyFile+="/"; + // First, we try to find $path/pwsafe.key + QFile file(KeyFile+"pwsafe.key"); + if(file.exists()) + KeyFile+="pwsafe.key"; + else{ + // If pwsafe.key does not exist, we try to see if there is exactly one file in the + // given directory which has the extension *.key. + QDir dir(KeyFile); QStringList files; files=dir.entryList(QStringList()<<"*.key",QDir::Files); + // No Key Files if(!files.size()){ - QMessageBox::warning(this,tr("Error"),tr("The given directory does not contain any key files."),tr("OK"),"","",0,0); - return;} - if(files.size()>1){ - QMessageBox::warning(this,tr("Error"),tr("The given directory contains more then one key file.\nPlease specify the key file directly."),tr("OK"),"","",0,0); - return;} - QFile file(keyfile+files[0]); - Q_ASSERT(file.exists()); - if(!QFileInfo(file).isReadable()){ - QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); - return;} - keyfile+=files[0]; + showErrMsg(tr("The given directory does not contain any key files."),this); + return; } - else{ /* pwsafe.key exists */ - if(!QFileInfo(file).isReadable()){ - QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); - return;} - keyfile+="pwsafe.key"; + // More than one key file + if(files.size()>1){ + showErrMsg(tr("The given directory contains more then one key files.\n" + "Please specify the key file directly."),this); + return; } - } - else{ /* not a directory */ - QFile file(keyfile); - if(!file.exists()){ - QMessageBox::warning(this,tr("Error"),tr("Key file could not be found."),tr("OK"),"","",0,0); - return;} - if(!QFileInfo(file).isReadable()){ - QMessageBox::warning(this,tr("Error"),tr("Key file is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); - return;} - } - - } -if(doAuth())done(1); -} - -void CPasswordDialog::OnOK_Set(){ - password=Edit_Password->text(); - if(password!=Edit_PasswordRep->text()){ - QMessageBox::warning(this,tr("Warning"),tr("Password an password repetition are not equal.\nPlease check your input."),tr("OK"),"","",0,0); - return; - } - keyfile=Combo_Dirs->currentText(); - if(password.isEmpty() && keyfile.isEmpty()){ - QMessageBox::warning(this,tr("Error"),tr("Please enter a password or select a key file."),tr("OK"),"","",0,0); - return; - } - - if(!keyfile.isEmpty()){ - QFile file(keyfile); - if(QFileInfo(file).isDir()){ - if(keyfile.right(1)!="/")keyfile+="/"; - keyfile+="pwsafe.key"; - } - if(file.exists()){ - switch(QMessageBox::question(this,tr("File exists."),tr("A file with the selected name already exists, should this file be used as key file or do you want to overwrite it with a newly generated one?"), - tr("Use"),tr("Overwrite"),tr("Cancel"),0,2)){ - case 0: - OverwriteKeyFile=false; - break; - case 1: - OverwriteKeyFile=true; - break; - case 2: - return; + KeyFile+=files[0]; } - } - IFilePasswordAuth* DbAuth=dynamic_cast(db); - if(OverwriteKeyFile){ - if(!DbAuth->createKeyFile(keyfile,32,true)){ - QMessageBox::warning(this,tr("Error"),tr("Key file could not be created.\n%1").arg(db->getError()),tr("OK"),"","",0,0); + + // Check again whether the found file exists and is readable + QFileInfo fileinfo(KeyFile); + if(!fileinfo.exists()){ + showErrMsg(tr("%1:\nNo such file or directory.").arg(KeyFile),this); return; } - } - } - if(doAuth())done(1); -} + if(!fileinfo.isReadable()){ + showErrMsg(tr("%1:\nFile is not readable."),this); + return; + } + } -bool CPasswordDialog::doAuth(){ - IFilePasswordAuth* DbAuth=dynamic_cast(db); - if(!password.isEmpty() && keyfile.isEmpty()){ - DbAuth->authByPwd(password); } - else if(password.isEmpty() && !keyfile.isEmpty()){ - if(!DbAuth->authByFile(keyfile))return false; - } - else if(!password.isEmpty() && !keyfile.isEmpty()){ - if(!DbAuth->authByFileAndPwd(password, keyfile))return false; - } - - if(config->rememberLastKey() && config->openLastFile()){ - QString KeyLocation=keyfile; - if(config->saveRelativePaths()){ - KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/")); - KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1); - } - config->setLastKeyLocation(KeyLocation); - config->setLastKeyType(KeyType); + + if(Check_Password->isChecked() && (Mode==Mode_Set || Mode==Mode_Change)){ + Edit_PwRepeat->clear(); + Label_Unequal->hide(); + stackedWidget->setCurrentIndex(1); + Edit_PwRepeat->setFocus(Qt::OtherFocusReason); + return; } - return true; - -} - -void CPasswordDialog::OnPasswordChanged(const QString &txt){ -Edit_PasswordRep->setText(QString()); -if(CheckBox_Both->isChecked() || txt.isEmpty()) - setStateBoth(); -else - setStatePasswordOnly(); + + done(Exit_Ok); } -void CPasswordDialog::OnComboTextChanged(const QString& txt){ -if(CheckBox_Both->isChecked() || txt.isEmpty()) - setStateBoth(); -else - setStateKeyFileOnly(); +void PasswordDialog::OnCheckBoxesChanged(int state){ + Edit_Password->setEnabled(Check_Password->isChecked()); + Combo_KeyFile->setEnabled(Check_KeyFile->isChecked()); + Button_Browse->setEnabled(Check_KeyFile->isChecked()); + Button_GenKeyFile->setEnabled(Check_KeyFile->isChecked()); } - - -void CPasswordDialog::OnCheckBox_BothChanged(int state){ -if(state==Qt::Checked) - setStateBoth(); -if(state==Qt::Unchecked){ - if(!Edit_Password->text().isEmpty() && !Combo_Dirs->currentText().isEmpty()){ - Combo_Dirs->setEditText(QString()); - setStatePasswordOnly(); +void PasswordDialog::ChangeEchoModeDatabaseKey(){ + if(Edit_Password->echoMode()==QLineEdit::Normal){ + Edit_Password->setEchoMode(QLineEdit::Password); + Edit_PwRepeat->setEchoMode(QLineEdit::Password); } else{ - if(Edit_Password->text().isEmpty()) - setStateKeyFileOnly(); - else - setStatePasswordOnly(); + Edit_Password->setEchoMode(QLineEdit::Normal); + Edit_PwRepeat->setEchoMode(QLineEdit::Normal); } } +void PasswordDialog::OnButtonQuit(){ + done(Exit_Quit); } -void CPasswordDialog::ChangeEchoModeDatabaseKey(){ -if(Edit_Password->echoMode()==QLineEdit::Normal){ - Edit_Password->setEchoMode(QLineEdit::Password); - Edit_PasswordRep->setEchoMode(QLineEdit::Password);} -else{ - Edit_Password->setEchoMode(QLineEdit::Normal); - Edit_PasswordRep->setEchoMode(QLineEdit::Normal);} -} - -void CPasswordDialog::paintEvent(QPaintEvent* event){ +void PasswordDialog::paintEvent(QPaintEvent* event){ QDialog::paintEvent(event); QPainter painter(this); painter.setClipRegion(event->region()); painter.drawPixmap(QPoint(0,0),BannerPixmap); } -void CPasswordDialog::OnBookmarkTriggered(QAction* action){ - BookmarkFilename=action->data().toString(); +void PasswordDialog::OnBookmarkTriggered(QAction* action){ if(action->data().toString()==QString()) - setWindowTitle(LastFile); + setWindowTitle(Filename); else setWindowTitle(action->data().toString()); Label_Bookmark->setText(action->text()); + BookmarkFilename=action->data().toString(); } + +void PasswordDialog::OnGenKeyFile(){ + QString filename=KpxFileDialogs::saveFile(this,"PasswordDlg",tr("Create Key File..."), + QStringList() << tr("All Files (*)") + << tr("Key Files (*.key)")); + if(!filename.isEmpty()){ + QString error; + if(!createKeyFile(filename,&error,32,true)){ + showErrMsg(error,this); + return; + } + else { + if(Check_KeyFile->isChecked()) + Combo_KeyFile->setEditText(filename); + return; + } + } +} + +QString PasswordDialog::password(){ + if(Check_Password->isChecked()) + return Edit_Password->text(); + else + return QString(); +} + + +QString PasswordDialog::keyFile(){ + if(Check_KeyFile->isChecked()) + return Combo_KeyFile->currentText(); + else + return QString(); +} + +QString PasswordDialog::selectedBookmark(){ + return BookmarkFilename; +} + +void PasswordDialog::OnButtonBack(){ + stackedWidget->setCurrentIndex(0); + Edit_PwRepeat->clear(); +} + diff --git a/src/dialogs/PasswordDlg.h b/src/dialogs/PasswordDlg.h index d8bef29..18abb91 100644 --- a/src/dialogs/PasswordDlg.h +++ b/src/dialogs/PasswordDlg.h @@ -1,11 +1,10 @@ /*************************************************************************** - * Copyright (C) 2005 by Tarek Saidi * - * tarek@linux * + * Copyright (C) 2005-2007 by Tarek Saidi * + * tarek.saidi@arcor.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; version 2 of the License. * - * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -17,51 +16,69 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + #ifndef PASSWORDDIALOG_H #define PASSWORDDIALOG_H + +#include +#include #include "ui_PasswordDlg.h" #include "main.h" -#include "lib/tools.h" #include "lib/UrlLabel.h" #include "Database.h" -#include -#include - -class CPasswordDialog : public QDialog, public Ui_PasswordDlg -{ - Q_OBJECT - private: - bool Mode_Set; //true = Set, false = Get - IDatabase* db; - QPixmap BannerPixmap; - void setStatePasswordOnly(); - void setStateKeyFileOnly(); - void setStateBoth(); - bool doAuth(); - virtual void paintEvent(QPaintEvent*); - QString LastFile; +class PasswordDialog : public QDialog, public Ui_PasswordDlg { +Q_OBJECT +public: + enum DlgMode { + Mode_Ask, // Normal password entry when opening a database + Mode_Set, // Setting password for the first time after creating a new database + Mode_Change // Changing the password of a database + }; + + enum DlgFlags { + Flag_None = 0x00, + Flag_Auto = 0x01 // Dialog was automatically opened on start-up + }; - public: - QString keyfile; - QString password; - QString BookmarkFilename; - tKeyType KeyType; - bool OverwriteKeyFile; - CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,bool IsAuto=false,bool ChangeKeyMode=false); + enum DlgExit { + Exit_Ok, + Exit_Cancel, + Exit_Quit + }; - private slots: - void OnOK(); - void OnOK_Set(); - void OnCancel(); - void OnButtonBrowse(); - void OnButtonBrowse_Set(); - void OnPasswordChanged(const QString &txt); - void OnCheckBox_BothChanged(int state); - void ChangeEchoModeDatabaseKey(); - void OnComboTextChanged(const QString&); - void OnBookmarkTriggered(QAction* action); + typedef bool (KeyFileGenProc)(const QString& filename,QString* error); + + PasswordDialog(QWidget* parent,DlgMode mode,DlgFlags flags,const QString& filename=QString()); + + // result functions + QString selectedBookmark(); + QString keyFile(); + QString password(); + +public slots: + void OnOK(); + void OnCancel(); + void OnButtonBrowse(); + void OnButtonQuit(); + void OnGenKeyFile(); + void OnButtonBack(); + void ChangeEchoModeDatabaseKey(); + void OnBookmarkTriggered(QAction* action); + void OnCheckBoxesChanged(int state); + +private: + DlgMode Mode; + QPixmap BannerPixmap; + QString BookmarkFilename; + QString Filename; + QString Password; + QString KeyFile; + void setStatePasswordOnly(); + void setStateKeyFileOnly(); + void setStateBoth(); + virtual void paintEvent(QPaintEvent*); }; #endif diff --git a/src/dialogs/PasswordGenDlg.cpp b/src/dialogs/PasswordGenDlg.cpp index d211a7a..13d5838 100644 --- a/src/dialogs/PasswordGenDlg.cpp +++ b/src/dialogs/PasswordGenDlg.cpp @@ -18,18 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "PasswordGenDlg.h" -#include "CollectEntropyDlg.h" + +#include "dialogs/PasswordGenDlg.h" +#include "dialogs/CollectEntropyDlg.h" #include "crypto/yarrow.h" -#include "KpxConfig.h" bool CGenPwDialog::EntropyCollected=false; diff --git a/src/dialogs/PasswordGenDlg.h b/src/dialogs/PasswordGenDlg.h index ef8c464..2b84c02 100644 --- a/src/dialogs/PasswordGenDlg.h +++ b/src/dialogs/PasswordGenDlg.h @@ -21,10 +21,7 @@ #ifndef GENPWDIALOG_H #define GENPWDIALOG_H -#include -#include #include "ui_PasswordGenDlg.h" -#include "main.h" #include "EditEntryDlg.h" class CGenPwDialog : public QDialog, public Ui_GenPwDlg diff --git a/src/dialogs/SearchDlg.cpp b/src/dialogs/SearchDlg.cpp index bcb4acd..e9472d1 100644 --- a/src/dialogs/SearchDlg.cpp +++ b/src/dialogs/SearchDlg.cpp @@ -19,15 +19,7 @@ ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "main.h" -#include "KpxConfig.h" -#include "SearchDlg.h" +#include "dialogs/SearchDlg.h" SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* parent):QDialog(parent) diff --git a/src/dialogs/SearchDlg.h b/src/dialogs/SearchDlg.h index 26c2ca2..c4eae2c 100644 --- a/src/dialogs/SearchDlg.h +++ b/src/dialogs/SearchDlg.h @@ -20,11 +20,7 @@ #ifndef SEARCHDLG_H #define SEARCHDLG_H -#include -#include #include "ui_SearchDlg.h" -#include "main.h" -#include "Database.h" class SearchDialog : public QDialog, public Ui_Search_Dlg { diff --git a/src/dialogs/SelectIconDlg.cpp b/src/dialogs/SelectIconDlg.cpp index 13064c7..229a25f 100644 --- a/src/dialogs/SelectIconDlg.cpp +++ b/src/dialogs/SelectIconDlg.cpp @@ -16,18 +16,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include + #include -#include -#include -#include -#include -#include -#include -#include -#include "lib/tools.h" -#include "SelectIconDlg.h" +#include "dialogs/SelectIconDlg.h" CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, bool modal, Qt::WFlags fl):QDialog(parent,fl){ diff --git a/src/dialogs/SelectIconDlg.h b/src/dialogs/SelectIconDlg.h index 4eab889..5882063 100644 --- a/src/dialogs/SelectIconDlg.h +++ b/src/dialogs/SelectIconDlg.h @@ -21,11 +21,6 @@ #ifndef _SELECT_ICON_DLG_ #define _SELECT_ICON_DLG_ -#include -#include -#include -#include "main.h" -#include "Database.h" #include "ui_SelectIconDlg.h" class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{ diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index 91f8dd2..3b861ad 100644 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -17,16 +17,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "main.h" -#include "KpxConfig.h" -#include -#include #include -#include -#include -#include "SettingsDlg.h" -#include "CustomizeDetailViewDlg.h" -#include "FileDialogs.h" +#include +#include "dialogs/SettingsDlg.h" +#include "dialogs/CustomizeDetailViewDlg.h" bool CSettingsDlg::PluginsModified=false; diff --git a/src/dialogs/SettingsDlg.h b/src/dialogs/SettingsDlg.h index bef32af..4fff3fc 100644 --- a/src/dialogs/SettingsDlg.h +++ b/src/dialogs/SettingsDlg.h @@ -21,12 +21,7 @@ #ifndef SETTINGSDLG_H #define SETTINGSDLG_H - -#include -#include -#include #include "ui_SettingsDlg.h" -#include "main.h" #include "lib/AutoType.h" class CSettingsDlg : public QDialog, public Ui_SettingsDialog diff --git a/src/dialogs/SimplePasswordDlg.cpp b/src/dialogs/SimplePasswordDlg.cpp index 8706591..3974c3d 100644 --- a/src/dialogs/SimplePasswordDlg.cpp +++ b/src/dialogs/SimplePasswordDlg.cpp @@ -18,10 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "main.h" -#include "KpxConfig.h" + #include "SimplePasswordDlg.h" SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 97b72f4..f04035a 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -18,12 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "lib/tools.h" -#include "main.h" + #include "Export.h" -#include "lib/FileDialogs.h" #include "dialogs/SimplePasswordDlg.h" QFile* ExporterBase::openFile(QWidget* parent, QString id, QStringList Filters){ diff --git a/src/export/Export.h b/src/export/Export.h index 2423b14..da1ff86 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -20,10 +20,6 @@ #ifndef _EXPORT_H_ #define _EXPORT_H_ -#include -#include - -#include "Database.h" class IExport{ public: diff --git a/src/export/Export_KeePassX_Xml.cpp b/src/export/Export_KeePassX_Xml.cpp index 9e86e04..1ca5de1 100644 --- a/src/export/Export_KeePassX_Xml.cpp +++ b/src/export/Export_KeePassX_Xml.cpp @@ -17,8 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include + #include "Export_KeePassX_Xml.h" bool Export_KeePassX_Xml::exportDatabase(QWidget* GuiParent,IDatabase* database){ diff --git a/src/export/Export_KeePassX_Xml.h b/src/export/Export_KeePassX_Xml.h index 800c648..7e53c69 100644 --- a/src/export/Export_KeePassX_Xml.h +++ b/src/export/Export_KeePassX_Xml.h @@ -21,7 +21,6 @@ #ifndef _EXPORT_KPX_XML_H_ #define _EXPORT_KPX_XML_H_ -#include #include "Export.h" class Export_KeePassX_Xml:public ExporterBase, public IExport{ diff --git a/src/export/Export_Txt.cpp b/src/export/Export_Txt.cpp index 10f1129..466709b 100644 --- a/src/export/Export_Txt.cpp +++ b/src/export/Export_Txt.cpp @@ -18,10 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "main.h" -#include "lib/SecString.h" + #include "Export_Txt.h" diff --git a/src/export/Export_Txt.h b/src/export/Export_Txt.h index 42b8c22..af4f3a9 100644 --- a/src/export/Export_Txt.h +++ b/src/export/Export_Txt.h @@ -20,7 +20,6 @@ #ifndef _EXPORT_TXT_H_ #define _EXPORT_TXT_H_ -#include #include "Export.h" class Export_Txt:public ExporterBase, public IExport{ diff --git a/src/forms/PasswordDlg.ui b/src/forms/PasswordDlg.ui index 200a6cc..24d8122 100644 --- a/src/forms/PasswordDlg.ui +++ b/src/forms/PasswordDlg.ui @@ -6,11 +6,11 @@ 0 0 578 - 280 + 255 - + 0 0 @@ -18,13 +18,7 @@ 578 - 280 - - - - - 578 - 280 + 0 @@ -37,6 +31,9 @@ true + + 9 + @@ -115,150 +112,187 @@ Key - - - - 10 - 20 - 541 - 124 - + + + 0 - - - 6 - - - - - 6 - - - 6 - - - - - Password Repet.: - - - - - - - - - - - 0 - 0 - - - - Password: - - - - - - - ... - - - - - - - - - - - - 6 - - - - - - 0 - 0 - - - - Key file or directory: - - - - - - - - 0 - 0 - - - - true - - - - - - - - 0 - 0 - - - - &Browse... - - - Alt+B - - - - - - - - - 6 - - - - - - 0 - 0 - - - - Use Password AND Key File - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + + + Password: + + + true + + + + + + + + + + + + ... + + + + + + + + + Key File: + + + + + + + + + + 0 + 0 + + + + true + + + + + + + + 0 + 0 + + + + &Browse... + + + Alt+B + + + + + + + + + Generate Key File... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Please repeat your password: + + + + + + + + + + + + Back + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 9 + 75 + true + + + + Passwords are not equal. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + - + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok @@ -269,13 +303,16 @@ Edit_Password + Combo_KeyFile + Check_Password + Check_KeyFile ButtonChangeEchoMode - Edit_PasswordRep - Combo_Dirs - ButtonBrowse - CheckBox_Both - ButtonBox + Button_Browse Button_Bookmarks + buttonBox + Button_GenKeyFile + Button_Back + Edit_PwRepeat diff --git a/src/import/Import.cpp b/src/import/Import.cpp index f689d2e..5814d3b 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -18,12 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "lib/tools.h" -#include "main.h" + #include "Import.h" -#include "lib/FileDialogs.h" #include "dialogs/SimplePasswordDlg.h" QFile* ImporterBase::openFile(QWidget* parent, QString id, QStringList Filters){ diff --git a/src/import/Import.h b/src/import/Import.h index e097e9e..0e5f2ff 100644 --- a/src/import/Import.h +++ b/src/import/Import.h @@ -19,11 +19,6 @@ ***************************************************************************/ #ifndef _IMPORT_H_ #define _IMPORT_H_ - -#include -#include - -#include "Database.h" class IImport{ public: diff --git a/src/import/Import_KWalletXml.cpp b/src/import/Import_KWalletXml.cpp index 0d9e1fb..0153928 100644 --- a/src/import/Import_KWalletXml.cpp +++ b/src/import/Import_KWalletXml.cpp @@ -18,11 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "Import_KWalletXml.h" -#include -#include -#include +#include "Import_KWalletXml.h" bool Import_KWalletXml::importDatabase(QWidget* GuiParent, IDatabase* db){ QFile* file=openFile(GuiParent,identifier(),QStringList()< -#include -#include + #include "Import_KeePassX_Xml.h" bool Import_KeePassX_Xml::importDatabase(QWidget* Parent, IDatabase* database){ diff --git a/src/import/Import_KeePassX_Xml.h b/src/import/Import_KeePassX_Xml.h index 41aaefa..cccee1f 100644 --- a/src/import/Import_KeePassX_Xml.h +++ b/src/import/Import_KeePassX_Xml.h @@ -21,7 +21,6 @@ #ifndef _IMPORT_KPX_XML_H_ #define _IMPORT_KPX_XML_H_ -#include #include "Import.h" diff --git a/src/import/Import_PwManager.cpp b/src/import/Import_PwManager.cpp index 43d6a65..55dbd03 100644 --- a/src/import/Import_PwManager.cpp +++ b/src/import/Import_PwManager.cpp @@ -18,14 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include "crypto/blowfish.h" -#include "crypto/sha1.h" + #include "Import_PwManager.h" -using namespace std; + bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){ database=db; @@ -115,7 +110,7 @@ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){ if(!parseXmlContent((char*)xml)){ delete [] xml; QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Invalid XML data (see stdout for details).")); return false;} - dynamic_cast(database)->authByPwd(password); + database->setKey(password,QString()); return true; } diff --git a/src/import/Import_PwManager.h b/src/import/Import_PwManager.h index 36f05a0..d1b40c1 100644 --- a/src/import/Import_PwManager.h +++ b/src/import/Import_PwManager.h @@ -20,9 +20,7 @@ #ifndef _IMPORT_PWMANAGER_ #define _IMPORT_PWMANAGER_ -#include -#include -#include "Database.h" + #include "Import.h" diff --git a/src/lib/AutoType.h b/src/lib/AutoType.h index 3a00462..1a7d47d 100644 --- a/src/lib/AutoType.h +++ b/src/lib/AutoType.h @@ -21,9 +21,6 @@ #ifndef _AUTOTYPE_H_ #define _AUTOTYPE_H_ -#include -#include "Database.h" - #ifdef GLOBAL_AUTOTYPE struct Shortcut{ bool ctrl, shift, alt, altgr, win; diff --git a/src/lib/AutoType_X11.cpp b/src/lib/AutoType_X11.cpp index 7cfd66f..801b65e 100644 --- a/src/lib/AutoType_X11.cpp +++ b/src/lib/AutoType_X11.cpp @@ -18,18 +18,14 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include "KpxConfig.h" -#include "AutoType.h" -#include "mainwindow.h" -#include -#include #include -#include "HelperX11.h" #include +#include "mainwindow.h" +#include "HelperX11.h" +#include "AutoType.h" #ifdef GLOBAL_AUTOTYPE -#include "dialogs/AutoTypeDlg.h" + #include "dialogs/AutoTypeDlg.h" #endif enum AutoTypeActionType{ diff --git a/src/lib/EntryView.cpp b/src/lib/EntryView.cpp index d6c7af3..be3af59 100644 --- a/src/lib/EntryView.cpp +++ b/src/lib/EntryView.cpp @@ -18,24 +18,12 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include "main.h" -#include "KpxConfig.h" -#include "EntryView.h" -#include "dialogs/EditEntryDlg.h" +#include +#include #include "lib/AutoType.h" -#include "Database.h" +#include "lib/EntryView.h" +#include "dialogs/EditEntryDlg.h" // just for the lessThan funtion QList* pItems; diff --git a/src/lib/EntryView.h b/src/lib/EntryView.h index 7a6a9ca..1dfccbf 100644 --- a/src/lib/EntryView.h +++ b/src/lib/EntryView.h @@ -21,15 +21,7 @@ #ifndef _ENTRY_VIEW_H_ #define _ENTRY_VIEW_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include "../Kdb3Database.h" +#include "Kdb3Database.h" #define NUM_COLUMNS 11 diff --git a/src/lib/FileDialogs.cpp b/src/lib/FileDialogs.cpp index 158d1b0..32aff6b 100644 --- a/src/lib/FileDialogs.cpp +++ b/src/lib/FileDialogs.cpp @@ -18,11 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include "main.h" -#include "KpxConfig.h" -#include "FileDialogs.h" - +#include IFileDialog* KpxFileDialogs::iFileDialog=NULL; QtStandardFileDialogs DefaultQtDlgs; diff --git a/src/lib/FileDialogs.h b/src/lib/FileDialogs.h index f69e44c..2d10da4 100644 --- a/src/lib/FileDialogs.h +++ b/src/lib/FileDialogs.h @@ -19,11 +19,7 @@ ***************************************************************************/ #ifndef _FILE_DIALOGS_H_ #define _FILE_DIALOGS_H_ - -#include -#include -#include -#include + #include "plugins/interfaces/IFileDialog.h" diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp index 83ae590..c9256e5 100644 --- a/src/lib/GroupView.cpp +++ b/src/lib/GroupView.cpp @@ -17,24 +17,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "KpxConfig.h" -#include "main.h" + #include "EntryView.h" #include "GroupView.h" #include "dialogs/EditGroupDlg.h" diff --git a/src/lib/GroupView.h b/src/lib/GroupView.h index 7e3ce26..b62149c 100644 --- a/src/lib/GroupView.h +++ b/src/lib/GroupView.h @@ -20,10 +20,7 @@ #ifndef _GROUP_VIEW_H_ #define _GROUP_VIEW_H_ -#include -#include -#include -#include "../Kdb3Database.h" +#include "Kdb3Database.h" class GroupViewItem; diff --git a/src/lib/HelperX11.cpp b/src/lib/HelperX11.cpp index 6ecfffd..c267e13 100644 --- a/src/lib/HelperX11.cpp +++ b/src/lib/HelperX11.cpp @@ -19,7 +19,6 @@ ***************************************************************************/ #include "HelperX11.h" - #include int HelperX11::getModifiers(Display *d,KeySym keysym, int keycode){ diff --git a/src/lib/SecString.cpp b/src/lib/SecString.cpp index b74ad63..9fd1688 100644 --- a/src/lib/SecString.cpp +++ b/src/lib/SecString.cpp @@ -18,10 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "SecString.h" -#include -#include "crypto/arcfour.h" -#include "crypto/yarrow.h" + using namespace std; CArcFour SecString::RC4; diff --git a/src/lib/SecString.h b/src/lib/SecString.h index e73ee64..b3ddb51 100644 --- a/src/lib/SecString.h +++ b/src/lib/SecString.h @@ -20,11 +20,6 @@ #ifndef _SECSTRING_H_ #define _SECSTRING_H_ -#include -#include -#include -#include "crypto/arcfour.h" - //! QString based class with in-memory encryption of its content. /*! This class can hold a QString object in an encrypted buffer. To get access to the string it is neccassary to unlock the SecString object. diff --git a/src/lib/ShortcutWidget.h b/src/lib/ShortcutWidget.h index 1e47acc..581d7ef 100644 --- a/src/lib/ShortcutWidget.h +++ b/src/lib/ShortcutWidget.h @@ -20,7 +20,6 @@ #ifndef SHORTCUT_WIDGET_H #define SHORTCUT_WIDGET_H -#include #if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_X11) #include "lib/AutoType.h" diff --git a/src/lib/UrlLabel.cpp b/src/lib/UrlLabel.cpp index 0408ecd..af9697d 100644 --- a/src/lib/UrlLabel.cpp +++ b/src/lib/UrlLabel.cpp @@ -20,15 +20,6 @@ #include "UrlLabel.h" -#include "main.h" -#include "lib/tools.h" -#include -#include -#include -#include -#include -#include -#include LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){ QFont font(parentWidget()->font()); font.setUnderline(true); diff --git a/src/lib/UrlLabel.h b/src/lib/UrlLabel.h index 850a8a1..a34f748 100644 --- a/src/lib/UrlLabel.h +++ b/src/lib/UrlLabel.h @@ -20,8 +20,6 @@ #ifndef _LINKLABEL_H_ #define _LINKLABEL_H_ -#include -#include class LinkLabel : public QLabel{ Q_OBJECT diff --git a/src/lib/WaitAnimationWidget.cpp b/src/lib/WaitAnimationWidget.cpp index 564ac36..98d8c4f 100644 --- a/src/lib/WaitAnimationWidget.cpp +++ b/src/lib/WaitAnimationWidget.cpp @@ -18,10 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include "main.h" + #include "WaitAnimationWidget.h" diff --git a/src/lib/WaitAnimationWidget.h b/src/lib/WaitAnimationWidget.h index 33a0feb..5305319 100644 --- a/src/lib/WaitAnimationWidget.h +++ b/src/lib/WaitAnimationWidget.h @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include -#include -#include -#include -#include + class WaitAnimationWidget:public QWidget{ Q_OBJECT diff --git a/src/lib/bookmarks.cpp b/src/lib/bookmarks.cpp index f2fe5ae..1c3b748 100644 --- a/src/lib/bookmarks.cpp +++ b/src/lib/bookmarks.cpp @@ -17,9 +17,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "bookmarks.h" -#include "main.h" -#include "KpxConfig.h" + QList KpxBookmarks::Bookmarks; diff --git a/src/lib/bookmarks.h b/src/lib/bookmarks.h index 7bcacc2..6d8d56d 100644 --- a/src/lib/bookmarks.h +++ b/src/lib/bookmarks.h @@ -19,9 +19,6 @@ #ifndef _BOOKMARKS_H_ #define _BOOKMARKS_H_ -#include -#include - class KpxBookmarks { public: static void load(); diff --git a/src/lib/random.h b/src/lib/random.h index e042438..0423399 100644 --- a/src/lib/random.h +++ b/src/lib/random.h @@ -17,4 +17,10 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef RANDOM_H_ +#define RANDOM_H_ + extern void getRandomBytes(void* buffer,int NumBlocks,int BlockSize=1,bool Strong=false); + + +#endif \ No newline at end of file diff --git a/src/lib/tools.cpp b/src/lib/tools.cpp index 6d91e34..3be420b 100644 --- a/src/lib/tools.cpp +++ b/src/lib/tools.cpp @@ -16,12 +16,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include "KpxConfig.h" -#include "main.h" -#include "lib/tools.h" +#include +#include void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width){ createBanner(Pixmap,IconAlpha,Text,Width,config->bannerColor1(),config->bannerColor2(),config->bannerTextColor()); @@ -177,3 +174,37 @@ const QPixmap* getPixmap(const QString& name){ } +bool createKeyFile(const QString& filename,QString* error,int length, bool Hex){ + QFile file(filename); + if(!file.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Unbuffered)){ + *error=decodeFileError(file.error()); + return false; + } + if(Hex)length*=2; + unsigned char* key=new unsigned char[length]; + randomize(key,length); + if(Hex){ + // convert binary data to hex code (8 bit ==> 2 digits) + for(int i=0; i9)key[i]='A'+dig1-10; + else key[i]='0'+dig1; + if(dig2>9)key[i+1]='A'+dig2-10; + else key[i+1]='0'+dig2; + } + } + if(file.write((char*)key,length)==-1){ + delete [] key; + *error=decodeFileError(file.error()); + file.close(); + return false; + } + file.close(); + delete [] key; + return true; +} + + diff --git a/src/lib/tools.h b/src/lib/tools.h index 950ab4f..6d63bbc 100644 --- a/src/lib/tools.h +++ b/src/lib/tools.h @@ -19,11 +19,6 @@ #ifndef TOOLS_H #define TOOLS_H -#include -#include -#include -#include - #define CSTR(x)(x.toLocal8Bit().constData()) class IEntryHandle; typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2}; @@ -37,5 +32,6 @@ void showErrMsg(const QString& msg,QWidget* parent=NULL); QString decodeFileError(QFile::FileError Code); QString makePathRelative(const QString& Abs,const QString& Cur); QString getImageFile(const QString& name); +bool createKeyFile(const QString& filename,QString* err, int length=32, bool Hex=true); #endif //TOOLS_H diff --git a/src/main.cpp b/src/main.cpp index a0b6156..24c747c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,10 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include - /* #include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IKdeInit.h" @@ -31,12 +27,10 @@ #include "lib/FileDialogs.h" */ -#include "main.h" -#include "lib/FileDialogs.h" -#include "lib/bookmarks.h" -#include "KpxConfig.h" -#include "Kdb3Database.h" +#include +#include #include "mainwindow.h" +#include "main.h" #include "crypto/yarrow.h" #if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE) #include "Application_X11.h" @@ -55,10 +49,6 @@ QString DetailViewTemplate; QPixmap* EntryIcons; //IIconTheme* IconLoader=NULL; //TODO plugins -inline void loadImages(); -inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang,bool& ArgMin,bool& ArgLock); -bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths); -void initAppPaths(); int main(int argc, char **argv) { @@ -68,7 +58,7 @@ int main(int argc, char **argv) #else app = new QApplication(argc,argv); #endif - initAppPaths(); + initAppPaths(argc,argv); CmdLineArgs args; args.parse(QApplication::arguments()); qDebug(CSTR(AppDir)); @@ -243,7 +233,8 @@ bool CmdLineArgs::parse(const QStringList& argv){ Error=QString("Expected a path as argument for '-cfg' but got '%1.'").arg(argv[i+1]); return false; } - ConfigLocation=argv[i+1]; + QFileInfo file(argv[i+1]); + ConfigLocation=file.absolutePath(); i++; continue; } @@ -268,6 +259,10 @@ bool CmdLineArgs::parse(const QStringList& argv){ StartLocked=true; continue; } + if(i==1){ + File=argv[1]; + continue; + } Error=QString("** Unrecognized argument: '%1'").arg(argv[i]); return false; } @@ -288,6 +283,10 @@ void CmdLineArgs::printHelp(){ cout << " pt_BR Portuguese(Brazil)"< -#include -#include -#include -#include -#include - -#define APP_DISPLAY_NAME "KeePassX" -#define APP_CODE_NAME "keepassx" - -#define APP_SHORT_FUNC "Password Manager" -#define APP_LONG_FUNC "Cross Platform Password Manager" - -#define APP_VERSION "0.3.0a" - -#define BUILTIN_ICONS 65 - - //QString findPlugin(const QString& filename); //TODO Plugins - -class KpxConfig; -extern QString PluginLoadError; -extern KpxConfig *config; -extern QString AppDir; -extern QString HomeDir; -extern QString DataDir; -extern bool TrActive; -extern QString DetailViewTemplate; -extern QPixmap *EntryIcons; - +void loadImages(); +bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths); +void initAppPaths(int argc, char **argv); class CmdLineArgs { public: diff --git a/src/main_macx.cpp b/src/main_macx.cpp index f3e6c9e..1fc18a2 100644 --- a/src/main_macx.cpp +++ b/src/main_macx.cpp @@ -19,12 +19,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include #include #include "main.h" -void initAppPaths() { +void initAppPaths(int argc,char** argv) { CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle())); //assert(bundleURL); CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle)); diff --git a/src/main_unix.cpp b/src/main_unix.cpp index c4aa9b8..cb2a1a9 100644 --- a/src/main_unix.cpp +++ b/src/main_unix.cpp @@ -19,14 +19,56 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include + #include "main.h" -void initAppPaths() { - AppDir = QApplication::applicationDirPath(); - DataDir = QDir(AppDir+"/../share/keepassx").canonicalPath(); +void initAppPaths(int argc,char** argv) { + // Try looking for a /proc//exe symlink first which points to + // the absolute path of the executable + QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid())); + if (pfi.exists() && pfi.isSymLink()) { + AppDir = pfi.canonicalFilePath(); + } + else { + QString argv0 = QFile::decodeName(QByteArray(argv[0])); + QString absPath; + + if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) { + /* + If argv0 starts with a slash, it is already an absolute + file path. + */ + absPath = argv0; + } else if (argv0.contains(QLatin1Char('/'))) { + /* + If argv0 contains one or more slashes, it is a file path + relative to the current directory. + */ + absPath = QDir::current().absoluteFilePath(argv0); + } else { + /* + Otherwise, the file path has to be determined using the + PATH environment variable. + */ + QByteArray pEnv = qgetenv("PATH"); + QDir currentDir = QDir::current(); + QStringList paths = QString::fromLocal8Bit(pEnv.constData()).split(QLatin1String(":")); + for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { + if ((*p).isEmpty()) + continue; + QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); + QFileInfo candidate_fi(candidate); + if (candidate_fi.exists() && !candidate_fi.isDir()) { + absPath = candidate; + break; + } + } + } + absPath = QDir::cleanPath(absPath); + QFileInfo fi(absPath); + AppDir = fi.exists() ? fi.canonicalFilePath() : QString(); + } + AppDir.truncate(AppDir.lastIndexOf("/")); + DataDir=AppDir+"/../share/keepassx"; HomeDir = QDir::homePath()+"/.keepassx"; } diff --git a/src/main_win32.cpp b/src/main_win32.cpp index fe4acca..f936b2e 100644 --- a/src/main_win32.cpp +++ b/src/main_win32.cpp @@ -19,8 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include #include #include "main.h" diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 93769b6..c2bde17 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,53 +17,18 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "mainwindow.h" - -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include - - -//#include "KpxFirefox.h" -#include "lib/random.h" +#include "mainwindow.h" #include "lib/AutoType.h" #include "lib/FileDialogs.h" -#include "lib/bookmarks.h" #include "import/Import_PwManager.h" #include "import/Import_KWalletXml.h" #include "import/Import_KeePassX_Xml.h" #include "export/Export_Txt.h" #include "export/Export_KeePassX_Xml.h" -#include "dialogs/AboutDlg.h" -#include "dialogs/SearchDlg.h" -#include "dialogs/SettingsDlg.h" -#include "dialogs/DatabaseSettingsDlg.h" -#include "dialogs/PasswordDlg.h" -#include "dialogs/SimplePasswordDlg.h" -#include "dialogs/PasswordGenDlg.h" -#include "dialogs/CollectEntropyDlg.h" -#include "dialogs/CustomizeDetailViewDlg.h" -#include "dialogs/ExpiredEntriesDlg.h" -//#include "dialogs/TrashCanDlg.h" //TODO TrashCan -#include "dialogs/AddBookmarkDlg.h" -#include "dialogs/ManageBookmarksDlg.h" - -#include +#include "dialogs/dialogs.h" Import_KeePassX_Xml import_KeePassX_Xml; Import_PwManager import_PwManager; @@ -408,25 +373,29 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ config->setLastKeyType(PASSWORD); } db=dynamic_cast(new Kdb3Database()); - CPasswordDialog PasswordDlg(this,filename,db,(IsAuto&&!InUnLock),false); + PasswordDialog::DlgFlags flags=PasswordDialog::Flag_None; + if(IsAuto) + flags = PasswordDialog::Flag_Auto; + PasswordDialog dlg(this,PasswordDialog::Mode_Ask,flags,filename); if (InUnLock){ - PasswordDlg.setWindowModality(Qt::WindowModal); - unlockDlg = &PasswordDlg; + dlg.setWindowModality(Qt::WindowModal); + unlockDlg = &dlg; } - bool rejected = (PasswordDlg.exec()==QDialog::Rejected); + bool rejected = (dlg.exec()==PasswordDialog::Exit_Cancel); if (InUnLock) unlockDlg = NULL; if (rejected) return false; - if(PasswordDlg.BookmarkFilename!=QString()) - filename=PasswordDlg.BookmarkFilename; + if(dlg.selectedBookmark()!=QString()) + filename=dlg.selectedBookmark(); GroupView->db=db; EntryView->db=db; setupDatabaseConnections(db); QString err; StatusBarGeneral->setText(tr("Loading Database...")); + db->setKey(dlg.password(),dlg.keyFile()); if(db->load(filename)==true){ if (IsLocked) resetLock(); @@ -442,10 +411,10 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ StatusBarGeneral->setText(tr("Loading Failed")); QString error=db->getError(); if(error.isEmpty())error=tr("Unknown error while loading database."); - QMessageBox::critical(this,tr("Error") - ,QString("%1\n%2").arg(tr("The following error occured while opening the database:")) - .arg(error)); - if(dynamic_cast(db)->isKeyError()){ + QMessageBox::critical(this,tr("Error"), + QString("%1\n%2").arg(tr("The following error occured while opening the database:")) + .arg(error)); + if(db->isKeyError()){ delete db; return openDatabase(filename,IsAuto); } @@ -510,14 +479,14 @@ bool KeepassMainWindow::closeDatabase(bool lock){ void KeepassMainWindow::OnFileNewKdb(){ IDatabase* db_new=dynamic_cast(new Kdb3Database()); db_new->create(); - CPasswordDialog dlg(this,QString(),db_new,false,true); - dlg.setWindowTitle(tr("New Database")); - if(dlg.exec()==1){ + PasswordDialog dlg(this,PasswordDialog::Mode_Set,PasswordDialog::Flag_None,"New Database"); + if(dlg.exec()==PasswordDialog::Exit_Ok){ if(FileOpen) if(!closeDatabase())return; if (IsLocked) resetLock(); - db=dynamic_cast(db_new); + db=db_new; + db->setKey(dlg.password(),dlg.keyFile()); setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); GroupView->db=db; EntryView->db=db; @@ -533,7 +502,6 @@ void KeepassMainWindow::OnFileNewKdb(){ else{ delete db_new; } - } // TODO Kxdb @@ -854,9 +822,13 @@ void KeepassMainWindow::OnFileSettings(){ } void KeepassMainWindow::OnFileChangeKey(){ - CPasswordDialog dlg(this,QString(),db,false,true); - if(dlg.exec()) + QFile* file=db->file(); + QString filename = file ? file->fileName() : QString(); + PasswordDialog dlg(this,PasswordDialog::Mode_Change,PasswordDialog::Flag_None,filename); + if(dlg.exec()==PasswordDialog::Exit_Ok){ setStateFileModified(true); + db->setKey(dlg.password(),dlg.keyFile()); + } } void KeepassMainWindow::OnFileExit(){ @@ -875,25 +847,24 @@ void KeepassMainWindow::OnImport(QAction* action){ IDatabase* tmpdb=dynamic_cast(new Kdb3Database()); tmpdb->create(); if(dynamic_cast(action->data().value())->importDatabase(this,tmpdb)){ - CPasswordDialog dlg(this,QString(),tmpdb,false,true); - dlg.setWindowTitle(tr("Set Master Key")); - if(!dlg.exec()){ - delete tmpdb; - return; - } - db=tmpdb; - GroupView->db=db; - EntryView->db=db; - setupDatabaseConnections(db); - setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); - GroupView->createItems(); - EntryView->showGroup(NULL); - setStateFileOpen(true); - setStateFileModified(true); + PasswordDialog dlg(this,PasswordDialog::Mode_Set,PasswordDialog::Flag_None,QString()); + if(dlg.exec()!=PasswordDialog::Exit_Ok){ + delete tmpdb; + return; + } + db=tmpdb; + db->setKey(dlg.password(),dlg.keyFile()); + GroupView->db=db; + EntryView->db=db; + setupDatabaseConnections(db); + setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); + GroupView->createItems(); + EntryView->showGroup(NULL); + setStateFileOpen(true); + setStateFileModified(true); } else delete tmpdb; - } /* diff --git a/src/mainwindow.h b/src/mainwindow.h index fc811c1..0ed6126 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -21,27 +21,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -//#include //TODO HelpBrowser -#include - -#include "Kdb3Database.h" -#include "KpxConfig.h" #include "lib/EntryView.h" #include "lib/GroupView.h" #include "export/Export.h" diff --git a/src/src.pro b/src/src.pro index 02538f8..ec20952 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,5 @@ -CONFIG = qt uic resources thread stl warn_off +CONFIG = qt uic resources thread stl warn_off precompile_header QT += xml DEPENDPATH += crypto dialogs export forms import lib translations res @@ -10,102 +10,102 @@ UI_DIR = ../build/ui OBJECTS_DIR = ../build RCC_DIR = ../build/rcc -isEqual(DEBUG,1) { - CONFIG += debug +isEqual(DEBUG,1){ + CONFIG += debug } else { - CONFIG += release + CONFIG += release } -win32:QMAKE_WIN32 = 1 +win32 : QMAKE_WIN32 = 1 #------------------------------------------------------------------------------- # Platform Specific: Unix (except MacOS X) #------------------------------------------------------------------------------- -unix : !macx : !isEqual(QMAKE_WIN32,1) { - isEmpty(PREFIX):PREFIX = /usr - !isEqual(AUTOTYPE,0) { - DEFINES += AUTOTYPE - !isEqual(GLOBAL_AUTOTYPE,0) { - DEFINES += GLOBAL_AUTOTYPE +unix : !macx : !isEqual(QMAKE_WIN32,1){ + isEmpty(PREFIX): PREFIX = /usr + !isEqual(AUTOTYPE,0){ + DEFINES += AUTOTYPE + !isEqual(GLOBAL_AUTOTYPE,0){ + DEFINES += GLOBAL_AUTOTYPE + } + } + TARGET = ../bin/keepassx + target.path = $${PREFIX}/bin + data.files += ../share/keepassx + data.path = $${PREFIX}/share + pixmaps.files = ../share/pixmaps/* + pixmaps.path = $${PREFIX}/share/pixmaps + desktop.files = ../share/applications/* + desktop.path = $${PREFIX}/share/applications + INSTALLS += pixmaps desktop + contains(DEFINES,AUTOTYPE){ + LIBS += -lXtst + SOURCES += lib/HelperX11.cpp lib/AutoType_X11.cpp + HEADERS += lib/HelperX11.h + } + contains(DEFINES,GLOBAL_AUTOTYPE){ + SOURCES += Application_X11.cpp + HEADERS += Application_X11.h + } + SOURCES += main_unix.cpp } - } - TARGET = ../bin/keepassx - target.path = $${PREFIX}/bin - data.files = ../share/keepassx - data.path = $${PREFIX}/share - pixmaps.files = ../share/pixmaps/* - pixmaps.path = $${PREFIX}/share/pixmaps - desktop.files = ../share/applications/* - desktop.path = $${PREFIX}/share/applications - INSTALLS += pixmaps desktop - contains(DEFINES,AUTOTYPE) { - LIBS += -lXtst - SOURCES += lib/HelperX11.cpp lib/AutoType_X11.cpp - HEADERS += lib/HelperX11.h - } - contains(DEFINES,GLOBAL_AUTOTYPE) { - SOURCES += Application_X11.cpp - HEADERS += Application_X11.h - } - SOURCES += main_unix.cpp -} #------------------------------------------------------------------------------- # Platform Specific: MacOS X #------------------------------------------------------------------------------- macx { - isEmpty(PREFIX):PREFIX = /Applications + isEmpty(PREFIX): PREFIX = /Applications TARGET = ../bin/KeePassX target.path = $${PREFIX} - data.files = ../share/keepassx + data.files += ../share/keepassx data.path = Contents/Resources LIBS += -framework CoreFoundation - isEqual(LINK,DYNAMIC) { - isEmpty(QT_FRAMEWORK_DIR) : QT_FRAMEWORK_DIR = /Library/Frameworks - private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtCore.framework - private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtGui.framework - private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtXml.framework - private_frameworks.path = Contents/Frameworks - QMAKE_BUNDLE_DATA += private_frameworks + isEqual(LINK,DYNAMIC){ + isEmpty(QT_FRAMEWORK_DIR): QT_FRAMEWORK_DIR = /Library/Frameworks + private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtCore.framework + private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtGui.framework + private_frameworks.files += $${QT_FRAMEWORK_DIR}/QtXml.framework + private_frameworks.path = Contents/Frameworks + QMAKE_BUNDLE_DATA += private_frameworks } isEqual(LINK,STATIC){ - LIBS += -framework Carbon -framework AppKit -lz + LIBS += -framework Carbon -framework AppKit -lz } QMAKE_BUNDLE_DATA += data ICON = ../share/macx_bundle/icon.icns CONFIG += app_bundle - isEqual(ARCH,UNIVERSAL) : CONFIG += x86 ppc - isEqual(ARCH,INTEL) : CONFIG += x86 - isEqual(ARCH,PPC) : CONFIG += ppc - SOURCES += main_macx.cpp + isEqual(ARCH,UNIVERSAL): CONFIG += x86 ppc + isEqual(ARCH,INTEL): CONFIG += x86 + isEqual(ARCH,PPC): CONFIG += ppc + SOURCES += main_macx.cpp } #------------------------------------------------------------------------------- # Platform Specific: Windows #------------------------------------------------------------------------------- -isEqual(QMAKE_WIN32,1) { +isEqual(QMAKE_WIN32,1){ CONFIG += windows - isEmpty(PREFIX):PREFIX = "C:/Program files/KeePassX" + isEmpty(PREFIX): PREFIX = "C:/Program files/KeePassX" TARGET = ../bin/KeePassX target.path = $${PREFIX} - data.files = ../share/keepassx/* + data.files += ../share/keepassx/* data.path = $${PREFIX}/share - !isEqual(INSTALL_QTLIB,0) { + !isEqual(INSTALL_QTLIB,0){ qt_libs.files = $${QMAKE_LIBDIR_QT}/QtCore4.dll $${QMAKE_LIBDIR_QT}/QtGui4.dll $${QMAKE_LIBDIR_QT}/QtXml4.dll qt_libs.path = $${PREFIX} INSTALLS += qt_libs } RC_FILE = ../share/win_ico/keepassx.rc QMAKE_LINK_OBJECT_SCRIPT = $${OBJECTS_DIR}/$${QMAKE_LINK_OBJECT_SCRIPT} - SOURCES += main_win32.cpp + SOURCES += main_win32.cpp } INSTALLS += target data -contains(DEFINES,GLOBAL_AUTOTYPE) { +contains(DEFINES,GLOBAL_AUTOTYPE){ FORMS += forms/AutoTypeDlg.ui HEADERS += dialogs/AutoTypeDlg.h SOURCES += dialogs/AutoTypeDlg.cpp @@ -180,7 +180,6 @@ HEADERS += lib/UrlLabel.h \ lib/GroupView.h \ lib/EntryView.h \ crypto/arcfour.h \ - lib/KpFileIconProvider.h \ crypto/aes_edefs.h \ crypto/aes_tdefs.h \ crypto/aes.h \ @@ -200,7 +199,9 @@ HEADERS += lib/UrlLabel.h \ # KpxFirefox.h \ dialogs/AddBookmarkDlg.h \ lib/bookmarks.h \ - dialogs/ManageBookmarksDlg.h + dialogs/ManageBookmarksDlg.h \ + dialogs/dialogs.h + SOURCES += lib/UrlLabel.cpp \ main.cpp \ mainwindow.cpp \ @@ -240,12 +241,7 @@ SOURCES += lib/UrlLabel.cpp \ lib/EntryView.cpp \ lib/FileDialogs.cpp \ crypto/arcfour.cpp \ - lib/KpFileIconProvider.cpp \ lib/ShortcutWidget.cpp \ - crypto/aescrypt.c \ - crypto/aeskey.c \ - crypto/aestab.c \ - crypto/aes_modes.c \ crypto/sha256.cpp \ crypto/yarrow.cpp \ lib/WaitAnimationWidget.cpp \ @@ -253,6 +249,12 @@ SOURCES += lib/UrlLabel.cpp \ # KpxFirefox.cpp \ dialogs/AddBookmarkDlg.cpp \ lib/bookmarks.cpp \ - dialogs/ManageBookmarksDlg.cpp + dialogs/ManageBookmarksDlg.cpp \ + crypto/aescrypt.c \ + crypto/aeskey.c \ + crypto/aes_modes.c \ + crypto/aestab.c + +PRECOMPILED_HEADER = keepassx.h RESOURCES += res/resources.qrc