- 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
master
tarek_saidi 17 years ago
parent 97bac939dd
commit bdec5c8450
  1. 12
      changelog
  2. 1
      src/Application_X11.cpp
  3. 1
      src/Application_X11.h
  4. 4
      src/Database.cpp
  5. 28
      src/Database.h
  6. 82
      src/Kdb3Database.cpp
  7. 22
      src/Kdb3Database.h
  8. 5
      src/KpxConfig.cpp
  9. 9
      src/KpxConfig.h
  10. 2
      src/crypto/twofish.cpp
  11. 4
      src/crypto/twofish.h
  12. 4
      src/crypto/yarrow.cpp
  13. 5
      src/dialogs/AboutDlg.cpp
  14. 4
      src/dialogs/AboutDlg.h
  15. 5
      src/dialogs/AddBookmarkDlg.cpp
  16. 4
      src/dialogs/AddBookmarkDlg.h
  17. 6
      src/dialogs/AutoTypeDlg.cpp
  18. 1
      src/dialogs/AutoTypeDlg.h
  19. 3
      src/dialogs/CalendarDlg.cpp
  20. 1
      src/dialogs/CalendarDlg.h
  21. 5
      src/dialogs/CollectEntropyDlg.cpp
  22. 6
      src/dialogs/CollectEntropyDlg.h
  23. 8
      src/dialogs/CustomizeDetailViewDlg.cpp
  24. 2
      src/dialogs/CustomizeDetailViewDlg.h
  25. 9
      src/dialogs/DatabaseSettingsDlg.cpp
  26. 3
      src/dialogs/DatabaseSettingsDlg.h
  27. 16
      src/dialogs/EditEntryDlg.cpp
  28. 4
      src/dialogs/EditEntryDlg.h
  29. 2
      src/dialogs/EditGroupDlg.cpp
  30. 3
      src/dialogs/EditGroupDlg.h
  31. 7
      src/dialogs/ExpiredEntriesDlg.cpp
  32. 4
      src/dialogs/ExpiredEntriesDlg.h
  33. 7
      src/dialogs/ManageBookmarksDlg.cpp
  34. 3
      src/dialogs/ManageBookmarksDlg.h
  35. 478
      src/dialogs/PasswordDlg.cpp
  36. 79
      src/dialogs/PasswordDlg.h
  37. 14
      src/dialogs/PasswordGenDlg.cpp
  38. 3
      src/dialogs/PasswordGenDlg.h
  39. 10
      src/dialogs/SearchDlg.cpp
  40. 4
      src/dialogs/SearchDlg.h
  41. 11
      src/dialogs/SelectIconDlg.cpp
  42. 5
      src/dialogs/SelectIconDlg.h
  43. 12
      src/dialogs/SettingsDlg.cpp
  44. 5
      src/dialogs/SettingsDlg.h
  45. 5
      src/dialogs/SimplePasswordDlg.cpp
  46. 6
      src/export/Export.cpp
  47. 4
      src/export/Export.h
  48. 1
      src/export/Export_KeePassX_Xml.cpp
  49. 1
      src/export/Export_KeePassX_Xml.h
  50. 5
      src/export/Export_Txt.cpp
  51. 1
      src/export/Export_Txt.h
  52. 195
      src/forms/PasswordDlg.ui
  53. 6
      src/import/Import.cpp
  54. 5
      src/import/Import.h
  55. 5
      src/import/Import_KWalletXml.cpp
  56. 2
      src/import/Import_KWalletXml.h
  57. 4
      src/import/Import_KeePassX_Xml.cpp
  58. 1
      src/import/Import_KeePassX_Xml.h
  59. 11
      src/import/Import_PwManager.cpp
  60. 4
      src/import/Import_PwManager.h
  61. 3
      src/lib/AutoType.h
  62. 10
      src/lib/AutoType_X11.cpp
  63. 20
      src/lib/EntryView.cpp
  64. 10
      src/lib/EntryView.h
  65. 6
      src/lib/FileDialogs.cpp
  66. 4
      src/lib/FileDialogs.h
  67. 19
      src/lib/GroupView.cpp
  68. 5
      src/lib/GroupView.h
  69. 1
      src/lib/HelperX11.cpp
  70. 5
      src/lib/SecString.cpp
  71. 5
      src/lib/SecString.h
  72. 1
      src/lib/ShortcutWidget.h
  73. 9
      src/lib/UrlLabel.cpp
  74. 2
      src/lib/UrlLabel.h
  75. 5
      src/lib/WaitAnimationWidget.cpp
  76. 5
      src/lib/WaitAnimationWidget.h
  77. 4
      src/lib/bookmarks.cpp
  78. 3
      src/lib/bookmarks.h
  79. 6
      src/lib/random.h
  80. 41
      src/lib/tools.cpp
  81. 6
      src/lib/tools.h
  82. 34
      src/main.cpp
  83. 32
      src/main.h
  84. 4
      src/main_macx.cpp
  85. 56
      src/main_unix.cpp
  86. 2
      src/main_win32.cpp
  87. 85
      src/mainwindow.cpp
  88. 20
      src/mainwindow.h
  89. 26
      src/src.pro

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

@ -17,6 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "Application_X11.h" #include "Application_X11.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
#include "lib/HelperX11.h" #include "lib/HelperX11.h"

@ -20,7 +20,6 @@
#ifndef APPLICATION_X11_H #ifndef APPLICATION_X11_H
#define APPLICATION_X11_H #define APPLICATION_X11_H
#include <QApplication>
class KeepassApplication : public QApplication class KeepassApplication : public QApplication
{ {

@ -18,9 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "Database.h"
#include "lib/random.h"
#include <QCoreApplication>
KpxUuid::KpxUuid(){ KpxUuid::KpxUuid(){
Data.fill(0,16); Data.fill(0,16);

@ -21,14 +21,6 @@
#ifndef _DATABASE_H_ #ifndef _DATABASE_H_
#define _DATABASE_H_ #define _DATABASE_H_
#include <QList>
#include <QDateTime>
#include <QFile>
#include <QPixmap>
#include <QByteArray>
#include "lib/SecString.h"
using namespace std;
extern const QDateTime Date_Never; extern const QDateTime Date_Never;
typedef enum CryptAlgorithm{ typedef enum CryptAlgorithm{
@ -247,6 +239,9 @@ class IDatabase:public QObject{
public: public:
virtual ~IDatabase(){}; virtual ~IDatabase(){};
virtual bool setKey(const QString& password,const QString& keyfile)=0;
virtual bool isKeyError()=0;
//! Loads a database. //! Loads a database.
/*! It is not allowed to call this function if a database is already loaded. /*! It is not allowed to call this function if a database is already loaded.
\param identifier Normally this is the filename of the database but it can also be an IP address or something else if the database is not file based. \param identifier Normally this is the filename of the database but it can also be an IP address or something else if the database is not file based.
@ -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{ class IKdbSettings{
public: public:
virtual void setCryptAlgorithm(CryptAlgorithm algo)=0; virtual void setCryptAlgorithm(CryptAlgorithm algo)=0;

@ -17,23 +17,9 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "global.h"
#include <iostream>
#include <time.h>
#include <QFile>
#include <QStringList>
#include <QDateTime>
#include <QSysInfo>
#include <QBuffer> #include <QBuffer>
#include <QDir>
#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 "Kdb3Database.h"
#include "KpxConfig.h"
#define UNEXP_ERROR error=QString("Unexpected error in: %1, Line:%2").arg(__FILE__).arg(__LINE__); #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; return true;
} }
/* bool Kdb3Database::setKey(const QString& password,const QString& keyfile){
void Kdb3Database::authByPwd(QString& Password){ if(!password.isEmpty() && !keyfile.isEmpty())
if(!Password.size()) { return setCompositeKey(password,keyfile);
memcpy(RawMasterKey,QByteArray(32,'\0').data(),32); if(!password.isEmpty())
return; return setPasswordKey(password);
if(!keyfile.isEmpty())
return setFileKey(keyfile);
assert(false);
} }
SHA256::hashBuffer(Password.toUtf8().data(),RawMasterKey,Password.toUtf8().size());
return;
}*/
void Kdb3Database::authByPwd(QString& Password){ bool Kdb3Database::setPasswordKey(const QString& Password){
if(!Password.size()) { assert(Password.size());
memcpy(RawMasterKey,QByteArray(32,'\0').data(),32);
return;
}
SHA256::hashBuffer(Password.toLatin1().data(),RawMasterKey,Password.toLatin1().size()); SHA256::hashBuffer(Password.toLatin1().data(),RawMasterKey,Password.toLatin1().size());
QByteArray lat,utf; QByteArray lat,utf;
utf=Password.toUtf8(); utf=Password.toUtf8();
lat=Password.toLatin1(); lat=Password.toLatin1();
return; return true;
} }
bool Kdb3Database::authByFile(QString& filename){ bool Kdb3Database::setFileKey(const QString& filename){
QFile file(filename); QFile file(filename);
if(!file.open(QIODevice::ReadOnly|QIODevice::Unbuffered)){ if(!file.open(QIODevice::ReadOnly|QIODevice::Unbuffered)){
error=decodeFileError(file.error()); error=decodeFileError(file.error());
@ -799,14 +782,13 @@ bool Kdb3Database::authByFile(QString& filename){
return true; return true;
} }
bool Kdb3Database::authByFileAndPwd(QString& Password, QString& filename){ bool Kdb3Database::setCompositeKey(const QString& Password,const QString& filename){
unsigned char PasswordKey[32]; unsigned char PasswordKey[32];
unsigned char FileKey[32]; unsigned char FileKey[32];
if(!authByFile(filename))return false; if(!setFileKey(filename))return false;
memcpy(FileKey,RawMasterKey,32); memcpy(FileKey,RawMasterKey,32);
authByPwd(Password); setPasswordKey(Password);
memcpy(PasswordKey,RawMasterKey,32); memcpy(PasswordKey,RawMasterKey,32);
SHA256 sha; SHA256 sha;
sha.update(PasswordKey,32); sha.update(PasswordKey,32);
sha.update(FileKey,32); sha.update(FileKey,32);
@ -1637,38 +1619,6 @@ void Kdb3Database::rebuildIndices(QList<StdGroup*>& 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; i<length; i+=2){
unsigned char dig1,dig2;
dig1=key[i]/16;
key[i]-=(16*dig1);
dig2=key[i];
if(dig1>9)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){ void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,int Pos){
StdGroup* Parent; StdGroup* Parent;

@ -30,25 +30,13 @@
#define PWM_FLAG_TWOFISH 8 #define PWM_FLAG_TWOFISH 8
#define PWM_STD_KEYENCROUNDS 6000 #define PWM_STD_KEYENCROUNDS 6000
#include <QColor>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QStringList>
#include <QPixmap>
#include <QMap>
#include "main.h"
#include "lib/SecString.h"
#include "Database.h"
void memcpyFromLEnd32(quint32* dst,const char* src); void memcpyFromLEnd32(quint32* dst,const char* src);
void memcpyFromLEnd16(quint16* dst,const char* src); void memcpyFromLEnd16(quint16* dst,const char* src);
void memcpyToLEnd32(char* src,const quint32* dst); void memcpyToLEnd32(char* src,const quint32* dst);
void memcpyToLEnd16(char* src,const quint16* dst); void memcpyToLEnd16(char* src,const quint16* dst);
//! Implementation of the standard KeePassX database. //! 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 Q_OBJECT
public: public:
class StdGroup; class StdGroup;
@ -169,10 +157,6 @@ public:
virtual void removeIcon(int index); virtual void removeIcon(int index);
virtual void replaceIcon(int index,const QPixmap& icon); virtual void replaceIcon(int index,const QPixmap& icon);
virtual int builtinIcons(){return BUILTIN_ICONS;}; 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<IEntryHandle*> search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields); virtual QList<IEntryHandle*> search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields);
virtual QFile* file(){return File;} virtual QFile* file(){return File;}
virtual bool changeFile(const QString& filename); virtual bool changeFile(const QString& filename);
@ -180,6 +164,10 @@ public:
virtual CryptAlgorithm cryptAlgorithm(){return Algorithm;} virtual CryptAlgorithm cryptAlgorithm(){return Algorithm;}
virtual unsigned int keyTransfRounds(){return KeyTransfRounds;} virtual unsigned int keyTransfRounds(){return KeyTransfRounds;}
virtual void setKeyTransfRounds(unsigned int rounds){KeyTransfRounds=rounds;} 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<IEntryHandle*> entries(); virtual QList<IEntryHandle*> entries();
virtual QList<IEntryHandle*> entries(IGroupHandle* Group); virtual QList<IEntryHandle*> entries(IGroupHandle* Group);

@ -21,12 +21,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "KpxConfig.h"
#include <QApplication>
#include <QSettings>
#include <QDir>
#include <QLayout> #include <QLayout>
#include <QWidget>
KpxConfig::KpxConfig(const QString& filePath) : settings(filePath,QSettings::IniFormat){ KpxConfig::KpxConfig(const QString& filePath) : settings(filePath,QSettings::IniFormat){
configFile=filePath; configFile=filePath;

@ -23,14 +23,7 @@
#ifndef _KPXCONFIG_H_ #ifndef _KPXCONFIG_H_
#define _KPXCONFIG_H_ #define _KPXCONFIG_H_
#include "lib/tools.h" #include "lib/AutoType.h"
#include "AutoType.h"
#include <QBitArray>
#include <QByteArray>
#include <QColor>
#include <QList>
#include <QSettings>
#include <QString>
#if defined(Q_WS_MAC) #if defined(Q_WS_MAC)
# define DEFAULT_MOUNT_DIR "/Volumes/" # define DEFAULT_MOUNT_DIR "/Volumes/"

@ -171,7 +171,7 @@
* Standard include files will probably be ok. * Standard include files will probably be ok.
*/ */
#include <QString> /* for memset(), memcpy(), and memcmp() */ //#include <QString> /* for memset(), memcpy(), and memcmp() */
#include <cstdlib> #include <cstdlib>
#include "twofish.h" #include "twofish.h"

@ -1,3 +1,5 @@
#ifndef TWOFISH_H_
#define TWOFISH_H_
/* /*
* Fast, portable, and easy-to-use Twofish implementation, * Fast, portable, and easy-to-use Twofish implementation,
* Version 0.3. * Version 0.3.
@ -177,3 +179,5 @@ extern void Twofish_decrypt(
Twofish_Byte c[16], Twofish_Byte c[16],
Twofish_Byte p[16] Twofish_Byte p[16]
); );
#endif

@ -20,10 +20,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

@ -17,10 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QMessageBox>
#include <QPainter>
#include <QFile>
#include "lib/tools.h"
#include "AboutDlg.h" #include "AboutDlg.h"

@ -20,11 +20,7 @@
#ifndef _ABOUTDIALOG_H_ #ifndef _ABOUTDIALOG_H_
#define _ABOUTDIALOG_H_ #define _ABOUTDIALOG_H_
#include <QPaintEvent>
#include "ui_AboutDlg.h" #include "ui_AboutDlg.h"
#include "lib/UrlLabel.h"
#include "main.h"
class AboutDialog : public QDialog, public Ui_AboutDlg class AboutDialog : public QDialog, public Ui_AboutDlg
{ {

@ -17,11 +17,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QFileInfo>
#include <QPainter>
#include "lib/tools.h"
#include "lib/FileDialogs.h"
#include "lib/bookmarks.h"
#include "AddBookmarkDlg.h" #include "AddBookmarkDlg.h"

@ -20,12 +20,8 @@
#ifndef _ADDBOOKMARKDLG_H_ #ifndef _ADDBOOKMARKDLG_H_
#define _ADDBOOKMARKDLG_H_ #define _ADDBOOKMARKDLG_H_
#include <QDialog>
#include <QPaintEvent>
#include "ui_AddBookmarkDlg.h" #include "ui_AddBookmarkDlg.h"
#include "main.h"
class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg
{ {
Q_OBJECT Q_OBJECT

@ -17,12 +17,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h"
#include "AutoTypeDlg.h"
#include "KpxConfig.h"
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QPainter> #include "AutoTypeDlg.h"
#include <QPaintEvent>
AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){ AutoTypeDlg::AutoTypeDlg(QList<IEntryHandle*> entries, QList<int> numbers){
setupUi(this); setupUi(this);

@ -18,7 +18,6 @@
***************************************************************************/ ***************************************************************************/
#include "ui_AutoTypeDlg.h" #include "ui_AutoTypeDlg.h"
#include "Database.h"
class AutoTypeDlg : public QWidget, private Ui::AutoTypeDlg class AutoTypeDlg : public QWidget, private Ui::AutoTypeDlg
{ {

@ -18,8 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "lib/tools.h"
#include "main.h"
#include "CalendarDlg.h" #include "CalendarDlg.h"
CalendarDialog::CalendarDialog(QWidget* parent, const QDate& Start):QDialog(parent){ CalendarDialog::CalendarDialog(QWidget* parent, const QDate& Start):QDialog(parent){

@ -20,7 +20,6 @@
#ifndef _CALENDAR_DLG_H_ #ifndef _CALENDAR_DLG_H_
#define _CALENDAR_DLG_H_ #define _CALENDAR_DLG_H_
#include <QDate>
#include "ui_CalendarDlg.h" #include "ui_CalendarDlg.h"
class CalendarDialog:public QDialog, public Ui_CalendarDialog{ class CalendarDialog:public QDialog, public Ui_CalendarDialog{

@ -18,13 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QPainter>
#include <QCursor>
#include <QFile>
#include "lib/tools.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
#include "CollectEntropyDlg.h" #include "CollectEntropyDlg.h"

@ -22,12 +22,6 @@
#define _COLLECT_ENTROPY_DLG_H_ #define _COLLECT_ENTROPY_DLG_H_
#include "ui_CollectEntropyDlg.h" #include "ui_CollectEntropyDlg.h"
#include <QDialog>
#include <QPaintEvent>
#include <QShowEvent>
#include "main.h"
class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{ class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{
Q_OBJECT Q_OBJECT

@ -18,16 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QTextCursor>
#include <QTextBlockFormat>
#include <QLineEdit>
#include <QPushButton>
#include <QColorDialog> #include <QColorDialog>
#include <QPixmap>
#include <QMenu>
#include "main.h"
#include "CustomizeDetailViewDlg.h" #include "CustomizeDetailViewDlg.h"
#include "KpxConfig.h"
bool DisableButtonSlots=false; bool DisableButtonSlots=false;

@ -21,8 +21,6 @@
#define _CUSTOMIZE_DETAIL_VIEW_H_ #define _CUSTOMIZE_DETAIL_VIEW_H_
#include "ui_CustomizeDetailViewDlg.h" #include "ui_CustomizeDetailViewDlg.h"
#include <QColor>
#include <QAction>
class CustomizeDetailViewDialog : public QDialog, public Ui_CustomizeDetailViewDialog{ class CustomizeDetailViewDialog : public QDialog, public Ui_CustomizeDetailViewDialog{
Q_OBJECT Q_OBJECT

@ -18,14 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QPainter>
#include <QComboBox>
#include <QLineEdit>
#include <QMessageBox>
#include <QShowEvent>
#include <QFile>
#include "lib/tools.h"
#include "main.h"
#include "DatabaseSettingsDlg.h" #include "DatabaseSettingsDlg.h"

@ -22,9 +22,6 @@
#define DBSETTINGSDLG_H #define DBSETTINGSDLG_H
#include "ui_DatabaseSettingsDlg.h" #include "ui_DatabaseSettingsDlg.h"
#include "main.h"
#include "Database.h"
#include <QPaintEvent>
class CDbSettingsDlg : public QDialog, public Ui_DatabaseSettingsDlg class CDbSettingsDlg : public QDialog, public Ui_DatabaseSettingsDlg
{ {

@ -18,29 +18,13 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h"
#include "KpxConfig.h"
#include <QPalette>
#include <QFont>
#include <QProgressBar>
#include <QPixmap>
#include <QColor>
#include <QPainter>
#include <QPen>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox>
#include <QToolButton>
#include <QShowEvent>
#include <QResizeEvent>
#include <math.h>
#include "SelectIconDlg.h" #include "SelectIconDlg.h"
#include "PasswordGenDlg.h" #include "PasswordGenDlg.h"
#include "EditEntryDlg.h" #include "EditEntryDlg.h"
#include "CalendarDlg.h" #include "CalendarDlg.h"
CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent, bool modal, bool newEntry) CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent, bool modal, bool newEntry)
: QDialog(parent) : QDialog(parent)
{ {

@ -20,10 +20,8 @@
#ifndef EDITENTRYDLG_H #ifndef EDITENTRYDLG_H
#define EDITENTRYDLG_H #define EDITENTRYDLG_H
#include "ui_EditEntryDlg.h" #include "ui_EditEntryDlg.h"
#include <QPixmap>
#include <QShowEvent>
#include "main.h"
#include "Kdb3Database.h" #include "Kdb3Database.h"
class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog

@ -18,9 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h"
#include <QShowEvent>
#include "EditGroupDlg.h" #include "EditGroupDlg.h"
#include "SelectIconDlg.h" #include "SelectIconDlg.h"

@ -22,9 +22,6 @@
#define EDITGROUPDLG_H #define EDITGROUPDLG_H
#include "ui_EditGroupDlg.h" #include "ui_EditGroupDlg.h"
#include <QString>
#include <QShowEvent>
#include "Database.h"
class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog
{ {

@ -18,12 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QTreeWidget>
#include <QPainter>
#include <QPaintEvent>
#include <QResizeEvent>
#include "lib/tools.h"
#include "main.h"
#include "ExpiredEntriesDlg.h" #include "ExpiredEntriesDlg.h"
ExpiredEntriesDialog::ExpiredEntriesDialog(QWidget* parent,IDatabase* database,const QList<IEntryHandle*>& ExpiredEntries):QDialog(parent){ ExpiredEntriesDialog::ExpiredEntriesDialog(QWidget* parent,IDatabase* database,const QList<IEntryHandle*>& ExpiredEntries):QDialog(parent){

@ -21,10 +21,8 @@
#ifndef _EXP_ENTRIES_DLG_ #ifndef _EXP_ENTRIES_DLG_
#define _EXP_ENTRIES_DLG_ #define _EXP_ENTRIES_DLG_
#include <QList>
#include <QPixmap>
#include "ui_ExpiredEntriesDlg.h" #include "ui_ExpiredEntriesDlg.h"
#include "Database.h"
class ExpiredEntriesDialog:public QDialog, public Ui_ExpiredEntriesDialog{ class ExpiredEntriesDialog:public QDialog, public Ui_ExpiredEntriesDialog{
Q_OBJECT Q_OBJECT

@ -17,11 +17,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QListWidget>
#include <QPainter> #include "dialogs/ManageBookmarksDlg.h"
#include "lib/tools.h"
#include "ManageBookmarksDlg.h"
#include "lib/bookmarks.h"
#include "dialogs/AddBookmarkDlg.h" #include "dialogs/AddBookmarkDlg.h"
ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent) ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent)

@ -20,9 +20,6 @@
#ifndef MANAGEBOOKMARKSDLG_H #ifndef MANAGEBOOKMARKSDLG_H
#define MANAGEBOOKMARKSDLG_H #define MANAGEBOOKMARKSDLG_H
#include <QDialog>
#include <QCloseEvent>
#include <QPaintEvent>
#include "ui_ManageBookmarksDlg.h" #include "ui_ManageBookmarksDlg.h"
#include "main.h" #include "main.h"

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005-2007 by Tarek Saidi * * Copyright (C) 2005-2008 by Tarek Saidi *
* tarek.saidi@arcor.de * * tarek.saidi@arcor.de *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -17,63 +17,97 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QFileDialog> #include <QTimer>
#include <QDir> #include "dialogs/PasswordDlg.h"
#include <QStringList>
#include <QCheckBox> PasswordDialog::PasswordDialog(QWidget* parent,DlgMode mode,DlgFlags flags,const QString& filename)
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QMessageBox>
#include <QPainter>
#include <QPalette>
#include <QMenu>
#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)
: QDialog(parent) : QDialog(parent)
{ {
setupUi(this); setupUi(this);
createBanner(&BannerPixmap,getPixmap("key"),tr("Database Key"),width()); Mode=mode;
Button_Bookmarks->setIcon(getIcon("bookmark")); Filename=filename;
db=DB; QString BannerTitle;
LastFile=filename; if(Mode==Mode_Ask){
if (ChangeKeyMode) BannerTitle=tr("Enter Master Key");
setWindowTitle(tr("Change Master Key")); }
else else if(Mode==Mode_Set){
setWindowTitle(LastFile); BannerTitle=tr("Set Master Key");
QString mountDir=config->mountDir(); }
QDir media(mountDir); else if(Mode==Mode_Change){
if(media.exists()){ 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; QStringList Paths;
Paths=media.entryList(QStringList()<<"*",QDir::Dirs | QDir::NoDotAndDotDot); Paths=mountDir.entryList(QStringList()<<"*",QDir::Dirs | QDir::NoDotAndDotDot);
for(int i=0;i<Paths.count();i++) for(int i=0;i<Paths.count();i++)
Combo_Dirs->addItem(mountDir+Paths[i]); Combo_KeyFile->addItem(config->mountDir()+Paths[i]);
} }
Combo_KeyFile->setEditText(QString());
Combo_Dirs->setEditText(QString()); if(config->rememberLastKey() && Mode!=Mode_Change && Mode!=Mode_Set){
if(config->rememberLastKey() && config->openLastFile() && !ChangeKeyMode){
switch(config->lastKeyType()){ switch(config->lastKeyType()){
case PASSWORD:
Check_Password->setChecked(true);
Check_KeyFile->setChecked(false);
Combo_KeyFile->setEditText("");
break;
case KEYFILE: case KEYFILE:
setStateKeyFileOnly(); Check_Password->setChecked(false);
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); 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; 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:
Check_Password->setChecked(false);
Check_KeyFile->setChecked(true);
Combo_KeyFile->setEditText(config->lastKeyLocation());
break;
case BOTH: case BOTH:
setStateBoth(); Check_Password->setChecked(true);
CheckBox_Both->setChecked(true); Check_KeyFile->setChecked(true);
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation()))); Combo_KeyFile->setEditText(config->lastKeyLocation());
break;
}
} }
// if(LastKeyType==Password){... is not required because it is already the default state.
} }
// Bookmarks // // Setting up the bookmark button
if(Mode==Mode_Ask && config->featureBookmarks()){
// Button Color
QPalette palette=Button_Bookmarks->palette(); QPalette palette=Button_Bookmarks->palette();
palette.setColor(QPalette::Active,QPalette::Button,config->bannerColor1()); palette.setColor(QPalette::Active,QPalette::Button,config->bannerColor1());
palette.setColor(QPalette::Active,QPalette::Window,config->bannerColor2()); palette.setColor(QPalette::Active,QPalette::Window,config->bannerColor2());
@ -81,7 +115,7 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,
palette=Label_Bookmark->palette(); palette=Label_Bookmark->palette();
palette.setColor(QPalette::Active,QPalette::WindowText,config->bannerTextColor()); palette.setColor(QPalette::Active,QPalette::WindowText,config->bannerTextColor());
Label_Bookmark->setPalette(palette); Label_Bookmark->setPalette(palette);
// Create menu and add "last file" menu entry
QMenu* BookmarkMenu=new QMenu(this); QMenu* BookmarkMenu=new QMenu(this);
QAction* action=new QAction(this); QAction* action=new QAction(this);
action->setData(QString()); action->setData(QString());
@ -89,6 +123,7 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,
action->setIcon(getIcon("document")); action->setIcon(getIcon("document"));
BookmarkMenu->addAction(action); BookmarkMenu->addAction(action);
BookmarkMenu->addSeparator(); BookmarkMenu->addSeparator();
// Adding all existing bookmarks
for(int i=0;i<KpxBookmarks::count();i++){ for(int i=0;i<KpxBookmarks::count();i++){
QAction* action=new QAction(this); QAction* action=new QAction(this);
action->setData(KpxBookmarks::path(i)); action->setData(KpxBookmarks::path(i));
@ -97,292 +132,219 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,
BookmarkMenu->addAction(action); BookmarkMenu->addAction(action);
} }
Button_Bookmarks->setMenu(BookmarkMenu); Button_Bookmarks->setMenu(BookmarkMenu);
if(!IsAuto || !config->featureBookmarks()){ connect(BookmarkMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnBookmarkTriggered(QAction*)));
}
else {
Button_Bookmarks->hide(); Button_Bookmarks->hide();
Label_Bookmark->hide(); Label_Bookmark->hide();
} }
connect(Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&))); connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
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(ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoModeDatabaseKey() ) ); connect(ButtonChangeEchoMode, SIGNAL( clicked() ), this, SLOT( ChangeEchoModeDatabaseKey() ) );
connect(Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); connect(Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect(Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); connect(Edit_PwRepeat, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect(BookmarkMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnBookmarkTriggered(QAction*))); connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect(Button_Browse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse() ) );
Mode_Set=ChangeKeyMode; connect(Button_GenKeyFile,SIGNAL(clicked()),this,SLOT(OnGenKeyFile()));
if(!ChangeKeyMode){ connect(Check_Password,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxesChanged(int)));
Edit_PasswordRep->hide(); connect(Check_KeyFile,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxesChanged(int)));
Label_PasswordRep->hide(); connect(Button_Back,SIGNAL(clicked()),this,SLOT(OnButtonBack()));
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() ) );
}
if(!config->showPasswordsPasswordDlg())ChangeEchoModeDatabaseKey(); if(!config->showPasswordsPasswordDlg())ChangeEchoModeDatabaseKey();
}
void CPasswordDialog::setStatePasswordOnly(){ adjustSize();
Combo_Dirs->setEnabled(false); setMaximumSize(size());
ButtonBrowse->setEnabled(false); setMinimumSize(size());
Label_KeyFile->setEnabled(false); createBanner(&BannerPixmap,getPixmap("key"),BannerTitle,width());
Label_Password->setEnabled(true); Button_Bookmarks->setIcon(getIcon("bookmark"));
Label_PasswordRep->setEnabled(true); OnCheckBoxesChanged(0);
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"), QString filename=KpxFileDialogs::openExistingFile(this,"PasswordDlg",tr("Select a Key File"),
QStringList() << tr("Key Files (*.key)") << tr("All Files (*)")); QStringList() << tr("All Files (*)")
if(filename!=QString()){ << tr("Key Files (*.key)"));
Combo_Dirs->setEditText(filename); if(filename!=QString())
} Combo_KeyFile->setEditText(filename);
return;
} }
void CPasswordDialog::OnButtonBrowse_Set() void PasswordDialog::OnCancel()
{ {
QString filename=KpxFileDialogs::saveFile(this,"PasswordDlg",tr("Select a Key File"), done(Exit_Cancel);
QStringList() << tr("Key Files (*.key)") << tr("All Files (*)"), }
false);
if(filename!=QString()){ void PasswordDialog::OnOK(){
Combo_Dirs->setEditText(filename); 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; return;
} }
void CPasswordDialog::OnCancel() Password=Edit_Password->text();
{ KeyFile=Combo_KeyFile->currentText();
done(0);
}
void CPasswordDialog::OnOK(){ if(!Check_Password->isChecked() && !Check_KeyFile->isChecked()){
password=Edit_Password->text(); showErrMsg(tr("Please enter a Password or select a key file."),this);
keyfile=Combo_Dirs->currentText(); return;
}
if(password.isEmpty() && keyfile.isEmpty()){ if(Check_Password->isChecked() && Password.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0); showErrMsg(tr("Please enter a Password."));
return; return;
} }
if(KeyType==BOTH){ if(Check_KeyFile->isChecked() && KeyFile.isEmpty()){
if(password.isEmpty()){ showErrMsg(tr("Please provide a key file."));
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0); return;
return;}
if(keyfile.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
return;}
} }
if(KeyType==BOTH || KeyType==KEYFILE){ if(Check_KeyFile->isChecked()){
QFileInfo fileinfo(keyfile); /* Check wether key path exists and is readable */
QFileInfo fileinfo(KeyFile);
if(!fileinfo.exists()){ 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; return;
} }
if(!fileinfo.isReadable()){ 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; return;
} }
/* If the given path is a directory, we need to find the key file in it */
if(fileinfo.isDir()){ if(fileinfo.isDir()){
if(keyfile.right(1)!="/")keyfile+="/"; if(KeyFile.right(1)!="/")KeyFile+="/";
QFile file(keyfile+"pwsafe.key"); // First, we try to find $path/pwsafe.key
if(!file.exists()){ QFile file(KeyFile+"pwsafe.key");
QDir dir(keyfile); 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; QStringList files;
files=dir.entryList(QStringList()<<"*.key",QDir::Files); files=dir.entryList(QStringList()<<"*.key",QDir::Files);
// No Key Files
if(!files.size()){ if(!files.size()){
QMessageBox::warning(this,tr("Error"),tr("The given directory does not contain any key files."),tr("OK"),"","",0,0); showErrMsg(tr("The given directory does not contain any key files."),this);
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];
}
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";
}
}
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; return;
} }
keyfile=Combo_Dirs->currentText(); // More than one key file
if(password.isEmpty() && keyfile.isEmpty()){ if(files.size()>1){
QMessageBox::warning(this,tr("Error"),tr("Please enter a password or select a key file."),tr("OK"),"","",0,0); showErrMsg(tr("The given directory contains more then one key files.\n"
"Please specify the key file directly."),this);
return; return;
} }
KeyFile+=files[0];
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?"), // Check again whether the found file exists and is readable
tr("Use"),tr("Overwrite"),tr("Cancel"),0,2)){ QFileInfo fileinfo(KeyFile);
case 0: if(!fileinfo.exists()){
OverwriteKeyFile=false; showErrMsg(tr("%1:\nNo such file or directory.").arg(KeyFile),this);
break;
case 1:
OverwriteKeyFile=true;
break;
case 2:
return; return;
} }
} if(!fileinfo.isReadable()){
IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db); showErrMsg(tr("%1:\nFile is not readable."),this);
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);
return; return;
} }
} }
}
if(doAuth())done(1);
} }
bool CPasswordDialog::doAuth(){ if(Check_Password->isChecked() && (Mode==Mode_Set || Mode==Mode_Change)){
IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db); Edit_PwRepeat->clear();
if(!password.isEmpty() && keyfile.isEmpty()){ Label_Unequal->hide();
DbAuth->authByPwd(password); stackedWidget->setCurrentIndex(1);
Edit_PwRepeat->setFocus(Qt::OtherFocusReason);
return;
} }
else if(password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFile(keyfile))return false; done(Exit_Ok);
} }
else if(!password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFileAndPwd(password, keyfile))return false; 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());
} }
if(config->rememberLastKey() && config->openLastFile()){ void PasswordDialog::ChangeEchoModeDatabaseKey(){
QString KeyLocation=keyfile; if(Edit_Password->echoMode()==QLineEdit::Normal){
if(config->saveRelativePaths()){ Edit_Password->setEchoMode(QLineEdit::Password);
KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/")); Edit_PwRepeat->setEchoMode(QLineEdit::Password);
KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1); }
else{
Edit_Password->setEchoMode(QLineEdit::Normal);
Edit_PwRepeat->setEchoMode(QLineEdit::Normal);
} }
config->setLastKeyLocation(KeyLocation);
config->setLastKeyType(KeyType);
} }
return true;
void PasswordDialog::OnButtonQuit(){
done(Exit_Quit);
} }
void CPasswordDialog::OnPasswordChanged(const QString &txt){ void PasswordDialog::paintEvent(QPaintEvent* event){
Edit_PasswordRep->setText(QString()); QDialog::paintEvent(event);
if(CheckBox_Both->isChecked() || txt.isEmpty()) QPainter painter(this);
setStateBoth(); painter.setClipRegion(event->region());
else painter.drawPixmap(QPoint(0,0),BannerPixmap);
setStatePasswordOnly();
} }
void CPasswordDialog::OnComboTextChanged(const QString& txt){ void PasswordDialog::OnBookmarkTriggered(QAction* action){
if(CheckBox_Both->isChecked() || txt.isEmpty()) if(action->data().toString()==QString())
setStateBoth(); setWindowTitle(Filename);
else else
setStateKeyFileOnly(); 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..."),
void CPasswordDialog::OnCheckBox_BothChanged(int state){ QStringList() << tr("All Files (*)")
if(state==Qt::Checked) << tr("Key Files (*.key)"));
setStateBoth(); if(!filename.isEmpty()){
if(state==Qt::Unchecked){ QString error;
if(!Edit_Password->text().isEmpty() && !Combo_Dirs->currentText().isEmpty()){ if(!createKeyFile(filename,&error,32,true)){
Combo_Dirs->setEditText(QString()); showErrMsg(error,this);
setStatePasswordOnly(); return;
} }
else { else {
if(Edit_Password->text().isEmpty()) if(Check_KeyFile->isChecked())
setStateKeyFileOnly(); Combo_KeyFile->setEditText(filename);
else return;
setStatePasswordOnly(); }
} }
} }
QString PasswordDialog::password(){
if(Check_Password->isChecked())
return Edit_Password->text();
else
return QString();
} }
void CPasswordDialog::ChangeEchoModeDatabaseKey(){
if(Edit_Password->echoMode()==QLineEdit::Normal){ QString PasswordDialog::keyFile(){
Edit_Password->setEchoMode(QLineEdit::Password); if(Check_KeyFile->isChecked())
Edit_PasswordRep->setEchoMode(QLineEdit::Password);} return Combo_KeyFile->currentText();
else{ else
Edit_Password->setEchoMode(QLineEdit::Normal); return QString();
Edit_PasswordRep->setEchoMode(QLineEdit::Normal);}
} }
void CPasswordDialog::paintEvent(QPaintEvent* event){ QString PasswordDialog::selectedBookmark(){
QDialog::paintEvent(event); return BookmarkFilename;
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
} }
void CPasswordDialog::OnBookmarkTriggered(QAction* action){ void PasswordDialog::OnButtonBack(){
BookmarkFilename=action->data().toString(); stackedWidget->setCurrentIndex(0);
if(action->data().toString()==QString()) Edit_PwRepeat->clear();
setWindowTitle(LastFile);
else
setWindowTitle(action->data().toString());
Label_Bookmark->setText(action->text());
} }

@ -1,11 +1,10 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005 by Tarek Saidi * * Copyright (C) 2005-2007 by Tarek Saidi *
* tarek@linux * * tarek.saidi@arcor.de *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. * * the Free Software Foundation; version 2 of the License. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
@ -17,51 +16,69 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#ifndef PASSWORDDIALOG_H #ifndef PASSWORDDIALOG_H
#define PASSWORDDIALOG_H #define PASSWORDDIALOG_H
#include <QPixmap>
#include <QPaintEvent>
#include "ui_PasswordDlg.h" #include "ui_PasswordDlg.h"
#include "main.h" #include "main.h"
#include "lib/tools.h"
#include "lib/UrlLabel.h" #include "lib/UrlLabel.h"
#include "Database.h" #include "Database.h"
#include <QPixmap>
#include <QPaintEvent>
class CPasswordDialog : public QDialog, public Ui_PasswordDlg class PasswordDialog : public QDialog, public Ui_PasswordDlg {
{
Q_OBJECT 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
};
private: enum DlgFlags {
bool Mode_Set; //true = Set, false = Get Flag_None = 0x00,
IDatabase* db; Flag_Auto = 0x01 // Dialog was automatically opened on start-up
QPixmap BannerPixmap; };
void setStatePasswordOnly();
void setStateKeyFileOnly();
void setStateBoth();
bool doAuth();
virtual void paintEvent(QPaintEvent*);
QString LastFile;
public: enum DlgExit {
QString keyfile; Exit_Ok,
QString password; Exit_Cancel,
QString BookmarkFilename; Exit_Quit
tKeyType KeyType; };
bool OverwriteKeyFile;
CPasswordDialog(QWidget* parent,QString filename,IDatabase* DB,bool IsAuto=false,bool ChangeKeyMode=false);
private slots: 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 OnOK();
void OnOK_Set();
void OnCancel(); void OnCancel();
void OnButtonBrowse(); void OnButtonBrowse();
void OnButtonBrowse_Set(); void OnButtonQuit();
void OnPasswordChanged(const QString &txt); void OnGenKeyFile();
void OnCheckBox_BothChanged(int state); void OnButtonBack();
void ChangeEchoModeDatabaseKey(); void ChangeEchoModeDatabaseKey();
void OnComboTextChanged(const QString&);
void OnBookmarkTriggered(QAction* action); 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 #endif

@ -18,18 +18,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QSpinBox>
#include <QMessageBox> #include "dialogs/PasswordGenDlg.h"
#include <QRadioButton> #include "dialogs/CollectEntropyDlg.h"
#include <QLineEdit>
#include <QCheckBox>
#include <QProgressBar>
#include <QPainter>
#include <math.h>
#include "PasswordGenDlg.h"
#include "CollectEntropyDlg.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
#include "KpxConfig.h"
bool CGenPwDialog::EntropyCollected=false; bool CGenPwDialog::EntropyCollected=false;

@ -21,10 +21,7 @@
#ifndef GENPWDIALOG_H #ifndef GENPWDIALOG_H
#define GENPWDIALOG_H #define GENPWDIALOG_H
#include <QPixmap>
#include <QPaintEvent>
#include "ui_PasswordGenDlg.h" #include "ui_PasswordGenDlg.h"
#include "main.h"
#include "EditEntryDlg.h" #include "EditEntryDlg.h"
class CGenPwDialog : public QDialog, public Ui_GenPwDlg class CGenPwDialog : public QDialog, public Ui_GenPwDlg

@ -19,15 +19,7 @@
***************************************************************************/ ***************************************************************************/
#include <QLineEdit> #include "dialogs/SearchDlg.h"
#include <QCheckBox>
#include <QPushButton>
#include <QRegExp>
#include <QMessageBox>
#include <QPainter>
#include "main.h"
#include "KpxConfig.h"
#include "SearchDlg.h"
SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* parent):QDialog(parent) SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* parent):QDialog(parent)

@ -20,11 +20,7 @@
#ifndef SEARCHDLG_H #ifndef SEARCHDLG_H
#define SEARCHDLG_H #define SEARCHDLG_H
#include <QPaintEvent>
#include <QPixmap>
#include "ui_SearchDlg.h" #include "ui_SearchDlg.h"
#include "main.h"
#include "Database.h"
class SearchDialog : public QDialog, public Ui_Search_Dlg class SearchDialog : public QDialog, public Ui_Search_Dlg
{ {

@ -17,17 +17,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QStringList>
#include <QFileDialog> #include <QFileDialog>
#include <QDir> #include "dialogs/SelectIconDlg.h"
#include <QFile>
#include <QPixmap>
#include <QPushButton>
#include <QMessageBox>
#include <QShowEvent>
#include <QFile>
#include "lib/tools.h"
#include "SelectIconDlg.h"
CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, bool modal, Qt::WFlags fl):QDialog(parent,fl){ CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, bool modal, Qt::WFlags fl):QDialog(parent,fl){

@ -21,11 +21,6 @@
#ifndef _SELECT_ICON_DLG_ #ifndef _SELECT_ICON_DLG_
#define _SELECT_ICON_DLG_ #define _SELECT_ICON_DLG_
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
#include "main.h"
#include "Database.h"
#include "ui_SelectIconDlg.h" #include "ui_SelectIconDlg.h"
class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{ class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{

@ -17,16 +17,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h"
#include "KpxConfig.h"
#include <QPixmap>
#include <QColorDialog>
#include <QFileDialog> #include <QFileDialog>
#include <QDir> #include <QColorDialog>
#include <QPainter> #include "dialogs/SettingsDlg.h"
#include "SettingsDlg.h" #include "dialogs/CustomizeDetailViewDlg.h"
#include "CustomizeDetailViewDlg.h"
#include "FileDialogs.h"
bool CSettingsDlg::PluginsModified=false; bool CSettingsDlg::PluginsModified=false;

@ -21,12 +21,7 @@
#ifndef SETTINGSDLG_H #ifndef SETTINGSDLG_H
#define SETTINGSDLG_H #define SETTINGSDLG_H
#include <QColor>
#include <QPixmap>
#include <QPaintEvent>
#include "ui_SettingsDlg.h" #include "ui_SettingsDlg.h"
#include "main.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
class CSettingsDlg : public QDialog, public Ui_SettingsDialog class CSettingsDlg : public QDialog, public Ui_SettingsDialog

@ -18,10 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QLineEdit>
#include <QPushButton>
#include "main.h"
#include "KpxConfig.h"
#include "SimplePasswordDlg.h" #include "SimplePasswordDlg.h"
SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl) SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl)

@ -18,12 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QMessageBox>
#include <QFile>
#include "lib/tools.h"
#include "main.h"
#include "Export.h" #include "Export.h"
#include "lib/FileDialogs.h"
#include "dialogs/SimplePasswordDlg.h" #include "dialogs/SimplePasswordDlg.h"
QFile* ExporterBase::openFile(QWidget* parent, QString id, QStringList Filters){ QFile* ExporterBase::openFile(QWidget* parent, QString id, QStringList Filters){

@ -20,10 +20,6 @@
#ifndef _EXPORT_H_ #ifndef _EXPORT_H_
#define _EXPORT_H_ #define _EXPORT_H_
#include <QWidget>
#include <QFile>
#include "Database.h"
class IExport{ class IExport{
public: public:

@ -18,7 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QtXml>
#include "Export_KeePassX_Xml.h" #include "Export_KeePassX_Xml.h"
bool Export_KeePassX_Xml::exportDatabase(QWidget* GuiParent,IDatabase* database){ bool Export_KeePassX_Xml::exportDatabase(QWidget* GuiParent,IDatabase* database){

@ -21,7 +21,6 @@
#ifndef _EXPORT_KPX_XML_H_ #ifndef _EXPORT_KPX_XML_H_
#define _EXPORT_KPX_XML_H_ #define _EXPORT_KPX_XML_H_
#include <QDomElement>
#include "Export.h" #include "Export.h"
class Export_KeePassX_Xml:public ExporterBase, public IExport{ class Export_KeePassX_Xml:public ExporterBase, public IExport{

@ -18,10 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QString>
#include <QFile>
#include "main.h"
#include "lib/SecString.h"
#include "Export_Txt.h" #include "Export_Txt.h"

@ -20,7 +20,6 @@
#ifndef _EXPORT_TXT_H_ #ifndef _EXPORT_TXT_H_
#define _EXPORT_TXT_H_ #define _EXPORT_TXT_H_
#include <QObject>
#include "Export.h" #include "Export.h"
class Export_Txt:public ExporterBase, public IExport{ class Export_Txt:public ExporterBase, public IExport{

@ -6,11 +6,11 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>578</width> <width>578</width>
<height>280</height> <height>255</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" > <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -18,13 +18,7 @@
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>578</width> <width>578</width>
<height>280</height> <height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>578</width>
<height>280</height>
</size> </size>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -37,6 +31,9 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<item> <item>
@ -115,82 +112,61 @@
<property name="title" > <property name="title" >
<string>Key</string> <string>Key</string>
</property> </property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>541</width>
<height>124</height>
</rect>
</property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="spacing" > <property name="leftMargin" >
<number>6</number> <number>0</number>
</property> </property>
<item> <property name="topMargin" >
<layout class="QGridLayout" > <number>0</number>
<property name="horizontalSpacing" >
<number>6</number>
</property> </property>
<property name="verticalSpacing" > <property name="rightMargin" >
<number>6</number> <number>0</number>
</property> </property>
<item row="1" column="0" > <property name="bottomMargin" >
<widget class="QLabel" name="Label_PasswordRep" > <number>0</number>
<property name="text" >
<string>Password Repet.:</string>
</property> </property>
</widget> <item>
</item> <widget class="QStackedWidget" name="stackedWidget" >
<item row="0" column="1" > <property name="currentIndex" >
<widget class="QLineEdit" name="Edit_Password" /> <number>0</number>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="Label_Password" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<widget class="QWidget" name="pw_entry" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="Check_Password" >
<property name="text" > <property name="text" >
<string>Password:</string> <string>Password:</string>
</property> </property>
<property name="checked" >
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="2" > <item row="0" column="1" colspan="2" >
<layout class="QHBoxLayout" >
<item>
<widget class="QLineEdit" name="Edit_Password" />
</item>
<item>
<widget class="QToolButton" name="ButtonChangeEchoMode" > <widget class="QToolButton" name="ButtonChangeEchoMode" >
<property name="text" > <property name="text" >
<string>...</string> <string>...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" >
<widget class="QLineEdit" name="Edit_PasswordRep" />
</item>
</layout> </layout>
</item> </item>
<item> <item row="1" column="0" >
<layout class="QHBoxLayout" > <widget class="QCheckBox" name="Check_KeyFile" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="Label_KeyFile" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" > <property name="text" >
<string>Key file or directory:</string> <string>Key File:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2" >
<layout class="QHBoxLayout" >
<item> <item>
<widget class="QComboBox" name="Combo_Dirs" > <widget class="QComboBox" name="Combo_KeyFile" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -203,7 +179,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="ButtonBrowse" > <widget class="QPushButton" name="Button_Browse" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" > <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -220,21 +196,46 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="2" column="1" >
<layout class="QHBoxLayout" > <widget class="QPushButton" name="Button_GenKeyFile" >
<property name="spacing" > <property name="text" >
<number>6</number> <string>Generate Key File...</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="pw_repeat" >
<layout class="QVBoxLayout" >
<item> <item>
<widget class="QCheckBox" name="CheckBox_Both" > <widget class="QLabel" name="label" >
<property name="sizePolicy" > <property name="text" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" > <string>Please repeat your password:</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="Edit_PwRepeat" />
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="Button_Back" >
<property name="text" > <property name="text" >
<string>Use Password AND Key File</string> <string>Back</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -251,14 +252,47 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QLabel" name="Label_Unequal" >
<property name="font" >
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Passwords are not equal.</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="ButtonBox" > <widget class="QDialogButtonBox" name="buttonBox" >
<property name="standardButtons" > <property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property> </property>
@ -269,13 +303,16 @@
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<tabstops> <tabstops>
<tabstop>Edit_Password</tabstop> <tabstop>Edit_Password</tabstop>
<tabstop>Combo_KeyFile</tabstop>
<tabstop>Check_Password</tabstop>
<tabstop>Check_KeyFile</tabstop>
<tabstop>ButtonChangeEchoMode</tabstop> <tabstop>ButtonChangeEchoMode</tabstop>
<tabstop>Edit_PasswordRep</tabstop> <tabstop>Button_Browse</tabstop>
<tabstop>Combo_Dirs</tabstop>
<tabstop>ButtonBrowse</tabstop>
<tabstop>CheckBox_Both</tabstop>
<tabstop>ButtonBox</tabstop>
<tabstop>Button_Bookmarks</tabstop> <tabstop>Button_Bookmarks</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>Button_GenKeyFile</tabstop>
<tabstop>Button_Back</tabstop>
<tabstop>Edit_PwRepeat</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

@ -18,12 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QMessageBox>
#include <QFile>
#include "lib/tools.h"
#include "main.h"
#include "Import.h" #include "Import.h"
#include "lib/FileDialogs.h"
#include "dialogs/SimplePasswordDlg.h" #include "dialogs/SimplePasswordDlg.h"
QFile* ImporterBase::openFile(QWidget* parent, QString id, QStringList Filters){ QFile* ImporterBase::openFile(QWidget* parent, QString id, QStringList Filters){

@ -20,11 +20,6 @@
#ifndef _IMPORT_H_ #ifndef _IMPORT_H_
#define _IMPORT_H_ #define _IMPORT_H_
#include <QWidget>
#include <QFile>
#include "Database.h"
class IImport{ class IImport{
public: public:
virtual ~IImport(){}; virtual ~IImport(){};

@ -18,11 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "Import_KWalletXml.h"
#include <QFile>
#include <QtXml>
#include <QMessageBox>
#include "Import_KWalletXml.h"
bool Import_KWalletXml::importDatabase(QWidget* GuiParent, IDatabase* db){ bool Import_KWalletXml::importDatabase(QWidget* GuiParent, IDatabase* db){
QFile* file=openFile(GuiParent,identifier(),QStringList()<<tr("XML Files (*.xml)")<<tr("All Files (*)")); QFile* file=openFile(GuiParent,identifier(),QStringList()<<tr("XML Files (*.xml)")<<tr("All Files (*)"));

@ -20,7 +20,7 @@
#ifndef _IMPORT_KWALLET_H_ #ifndef _IMPORT_KWALLET_H_
#define _IMPORT_KWALLET_H_ #define _IMPORT_KWALLET_H_
#include "Database.h"
#include "Import.h" #include "Import.h"
class Import_KWalletXml:public ImporterBase, public IImport{ class Import_KWalletXml:public ImporterBase, public IImport{

@ -18,9 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QStringList>
#include <QMessageBox>
#include <QtXml>
#include "Import_KeePassX_Xml.h" #include "Import_KeePassX_Xml.h"
bool Import_KeePassX_Xml::importDatabase(QWidget* Parent, IDatabase* database){ bool Import_KeePassX_Xml::importDatabase(QWidget* Parent, IDatabase* database){

@ -21,7 +21,6 @@
#ifndef _IMPORT_KPX_XML_H_ #ifndef _IMPORT_KPX_XML_H_
#define _IMPORT_KPX_XML_H_ #define _IMPORT_KPX_XML_H_
#include <QDomElement>
#include "Import.h" #include "Import.h"

@ -18,14 +18,9 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QFile>
#include <iostream>
#include <QMessageBox>
#include <QtXml>
#include "crypto/blowfish.h"
#include "crypto/sha1.h"
#include "Import_PwManager.h" #include "Import_PwManager.h"
using namespace std;
bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
database=db; database=db;
@ -115,7 +110,7 @@ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
if(!parseXmlContent((char*)xml)){ if(!parseXmlContent((char*)xml)){
delete [] xml; delete [] xml;
QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Invalid XML data (see stdout for details).")); return false;} QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Invalid XML data (see stdout for details).")); return false;}
dynamic_cast<IFilePasswordAuth*>(database)->authByPwd(password); database->setKey(password,QString());
return true; return true;
} }

@ -20,9 +20,7 @@
#ifndef _IMPORT_PWMANAGER_ #ifndef _IMPORT_PWMANAGER_
#define _IMPORT_PWMANAGER_ #define _IMPORT_PWMANAGER_
#include <QDomElement>
#include <QString>
#include "Database.h"
#include "Import.h" #include "Import.h"

@ -21,9 +21,6 @@
#ifndef _AUTOTYPE_H_ #ifndef _AUTOTYPE_H_
#define _AUTOTYPE_H_ #define _AUTOTYPE_H_
#include <QString>
#include "Database.h"
#ifdef GLOBAL_AUTOTYPE #ifdef GLOBAL_AUTOTYPE
struct Shortcut{ struct Shortcut{
bool ctrl, shift, alt, altgr, win; bool ctrl, shift, alt, altgr, win;

@ -18,15 +18,11 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QtCore>
#include "KpxConfig.h"
#include "AutoType.h"
#include "mainwindow.h"
#include <QList>
#include <QChar>
#include <QX11Info> #include <QX11Info>
#include "HelperX11.h"
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "mainwindow.h"
#include "HelperX11.h"
#include "AutoType.h"
#ifdef GLOBAL_AUTOTYPE #ifdef GLOBAL_AUTOTYPE
#include "dialogs/AutoTypeDlg.h" #include "dialogs/AutoTypeDlg.h"

@ -18,24 +18,12 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDragLeaveEvent>
#include <QDropEvent>
#include <QMouseEvent>
#include <QHeaderView> #include <QHeaderView>
#include <QTime> #include <QClipboard>
#include <QApplication> #include <QFileDialog>
#include <QPainter>
#include <QPair>
#include <QMessageBox>
#include "main.h"
#include "KpxConfig.h"
#include "EntryView.h"
#include "dialogs/EditEntryDlg.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
#include "Database.h" #include "lib/EntryView.h"
#include "dialogs/EditEntryDlg.h"
// just for the lessThan funtion // just for the lessThan funtion
QList<EntryViewItem*>* pItems; QList<EntryViewItem*>* pItems;

@ -21,15 +21,7 @@
#ifndef _ENTRY_VIEW_H_ #ifndef _ENTRY_VIEW_H_
#define _ENTRY_VIEW_H_ #define _ENTRY_VIEW_H_
#include <QMenu> #include "Kdb3Database.h"
#include <QTreeWidget>
#include <QContextMenuEvent>
#include <QHeaderView>
#include <QTimer>
#include <QClipboard>
#include <QBitArray>
#include <QList>
#include "../Kdb3Database.h"
#define NUM_COLUMNS 11 #define NUM_COLUMNS 11

@ -18,11 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QDir> #include <QFileDialog>
#include "main.h"
#include "KpxConfig.h"
#include "FileDialogs.h"
IFileDialog* KpxFileDialogs::iFileDialog=NULL; IFileDialog* KpxFileDialogs::iFileDialog=NULL;
QtStandardFileDialogs DefaultQtDlgs; QtStandardFileDialogs DefaultQtDlgs;

@ -20,10 +20,6 @@
#ifndef _FILE_DIALOGS_H_ #ifndef _FILE_DIALOGS_H_
#define _FILE_DIALOGS_H_ #define _FILE_DIALOGS_H_
#include <QObject>
#include <QFileDialog>
#include <QList>
#include <QHash>
#include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IFileDialog.h"

@ -17,24 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDragLeaveEvent>
#include <QDropEvent>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QApplication>
#include <QFont>
#include <QFontMetrics>
#include <QSize>
#include <QPixmap>
#include <QPainter>
#include <QPen>
#include <QBrush>
#include <QMenu>
#include <QMessageBox>
#include "KpxConfig.h"
#include "main.h"
#include "EntryView.h" #include "EntryView.h"
#include "GroupView.h" #include "GroupView.h"
#include "dialogs/EditGroupDlg.h" #include "dialogs/EditGroupDlg.h"

@ -20,10 +20,7 @@
#ifndef _GROUP_VIEW_H_ #ifndef _GROUP_VIEW_H_
#define _GROUP_VIEW_H_ #define _GROUP_VIEW_H_
#include <QTreeWidget> #include "Kdb3Database.h"
#include <QLine>
#include <QContextMenuEvent>
#include "../Kdb3Database.h"
class GroupViewItem; class GroupViewItem;

@ -19,7 +19,6 @@
***************************************************************************/ ***************************************************************************/
#include "HelperX11.h" #include "HelperX11.h"
#include <QX11Info> #include <QX11Info>
int HelperX11::getModifiers(Display *d,KeySym keysym, int keycode){ int HelperX11::getModifiers(Display *d,KeySym keysym, int keycode){

@ -18,10 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "SecString.h"
#include <iostream>
#include "crypto/arcfour.h"
#include "crypto/yarrow.h"
using namespace std; using namespace std;
CArcFour SecString::RC4; CArcFour SecString::RC4;

@ -20,11 +20,6 @@
#ifndef _SECSTRING_H_ #ifndef _SECSTRING_H_
#define _SECSTRING_H_ #define _SECSTRING_H_
#include <QByteArray>
#include <QString>
#include <QGlobalStatic>
#include "crypto/arcfour.h"
//! QString based class with in-memory encryption of its content. //! 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. 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.

@ -20,7 +20,6 @@
#ifndef SHORTCUT_WIDGET_H #ifndef SHORTCUT_WIDGET_H
#define SHORTCUT_WIDGET_H #define SHORTCUT_WIDGET_H
#include <QLineEdit>
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_X11) #if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_X11)
#include "lib/AutoType.h" #include "lib/AutoType.h"

@ -20,15 +20,6 @@
#include "UrlLabel.h" #include "UrlLabel.h"
#include "main.h"
#include "lib/tools.h"
#include <QFont>
#include <QColor>
#include <QCursor>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QLabel>
#include <QPalette>
LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){ LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){
QFont font(parentWidget()->font()); font.setUnderline(true); QFont font(parentWidget()->font()); font.setUnderline(true);

@ -20,8 +20,6 @@
#ifndef _LINKLABEL_H_ #ifndef _LINKLABEL_H_
#define _LINKLABEL_H_ #define _LINKLABEL_H_
#include <QLabel>
#include <QMouseEvent>
class LinkLabel : public QLabel{ class LinkLabel : public QLabel{
Q_OBJECT Q_OBJECT

@ -18,10 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <math.h>
#include <QPainter>
#include <QRectF>
#include "main.h"
#include "WaitAnimationWidget.h" #include "WaitAnimationWidget.h"

@ -18,11 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QWidget>
#include <QPaintEvent>
#include <QResizeEvent>
#include <QTimer>
#include <QPointF>
class WaitAnimationWidget:public QWidget{ class WaitAnimationWidget:public QWidget{
Q_OBJECT Q_OBJECT

@ -17,9 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "bookmarks.h"
#include "main.h"
#include "KpxConfig.h"
QList<KpxBookmarks::BookmarkEntry> KpxBookmarks::Bookmarks; QList<KpxBookmarks::BookmarkEntry> KpxBookmarks::Bookmarks;

@ -19,9 +19,6 @@
#ifndef _BOOKMARKS_H_ #ifndef _BOOKMARKS_H_
#define _BOOKMARKS_H_ #define _BOOKMARKS_H_
#include <QString>
#include <QList>
class KpxBookmarks { class KpxBookmarks {
public: public:
static void load(); static void load();

@ -17,4 +17,10 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 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); extern void getRandomBytes(void* buffer,int NumBlocks,int BlockSize=1,bool Strong=false);
#endif

@ -16,12 +16,9 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QtCore>
#include <QtGui>
#include "KpxConfig.h"
#include "main.h"
#include "lib/tools.h"
#include <QProcess>
#include <QDesktopServices>
void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width){ void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width){
createBanner(Pixmap,IconAlpha,Text,Width,config->bannerColor1(),config->bannerColor2(),config->bannerTextColor()); 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; i<length; i+=2){
unsigned char dig1,dig2;
dig1=key[i]/16;
key[i]-=(16*dig1);
dig2=key[i];
if(dig1>9)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;
}

@ -19,11 +19,6 @@
#ifndef TOOLS_H #ifndef TOOLS_H
#define TOOLS_H #define TOOLS_H
#include <QFile>
#include <QString>
#include <QPixmap>
#include <QIcon>
#define CSTR(x)(x.toLocal8Bit().constData()) #define CSTR(x)(x.toLocal8Bit().constData())
class IEntryHandle; class IEntryHandle;
typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2}; 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 decodeFileError(QFile::FileError Code);
QString makePathRelative(const QString& Abs,const QString& Cur); QString makePathRelative(const QString& Abs,const QString& Cur);
QString getImageFile(const QString& name); QString getImageFile(const QString& name);
bool createKeyFile(const QString& filename,QString* err, int length=32, bool Hex=true);
#endif //TOOLS_H #endif //TOOLS_H

@ -19,10 +19,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QtCore>
#include <QMessageBox>
#include <iostream>
/* /*
#include "plugins/interfaces/IFileDialog.h" #include "plugins/interfaces/IFileDialog.h"
#include "plugins/interfaces/IKdeInit.h" #include "plugins/interfaces/IKdeInit.h"
@ -31,12 +27,10 @@
#include "lib/FileDialogs.h" #include "lib/FileDialogs.h"
*/ */
#include "main.h" #include <QTranslator>
#include "lib/FileDialogs.h" #include <QLibraryInfo>
#include "lib/bookmarks.h"
#include "KpxConfig.h"
#include "Kdb3Database.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE) #if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
#include "Application_X11.h" #include "Application_X11.h"
@ -55,10 +49,6 @@ QString DetailViewTemplate;
QPixmap* EntryIcons; QPixmap* EntryIcons;
//IIconTheme* IconLoader=NULL; //TODO plugins //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) int main(int argc, char **argv)
{ {
@ -68,7 +58,7 @@ int main(int argc, char **argv)
#else #else
app = new QApplication(argc,argv); app = new QApplication(argc,argv);
#endif #endif
initAppPaths(); initAppPaths(argc,argv);
CmdLineArgs args; CmdLineArgs args;
args.parse(QApplication::arguments()); args.parse(QApplication::arguments());
qDebug(CSTR(AppDir)); 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]); Error=QString("Expected a path as argument for '-cfg' but got '%1.'").arg(argv[i+1]);
return false; return false;
} }
ConfigLocation=argv[i+1]; QFileInfo file(argv[i+1]);
ConfigLocation=file.absolutePath();
i++; i++;
continue; continue;
} }
@ -268,6 +259,10 @@ bool CmdLineArgs::parse(const QStringList& argv){
StartLocked=true; StartLocked=true;
continue; continue;
} }
if(i==1){
File=argv[1];
continue;
}
Error=QString("** Unrecognized argument: '%1'").arg(argv[i]); Error=QString("** Unrecognized argument: '%1'").arg(argv[i]);
return false; return false;
} }
@ -288,6 +283,10 @@ void CmdLineArgs::printHelp(){
cout << " pt_BR Portuguese(Brazil)"<<endl; cout << " pt_BR Portuguese(Brazil)"<<endl;
} }
//TODO Plugins //TODO Plugins
/* /*
QString findPlugin(const QString& filename){ QString findPlugin(const QString& filename){
@ -300,3 +299,8 @@ QString findPlugin(const QString& filename){
return QString(); return QString();
} }
*/ */

@ -20,36 +20,10 @@
#ifndef _MAIN_H_ #ifndef _MAIN_H_
#define _MAIN_H_ #define _MAIN_H_
#include <QLabel>
#include <QPixmap>
#include <QString>
#include <QColor>
#include <QIcon>
#include <QFile>
#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 //QString findPlugin(const QString& filename); //TODO Plugins
void loadImages();
class KpxConfig; bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths);
extern QString PluginLoadError; void initAppPaths(int argc, char **argv);
extern KpxConfig *config;
extern QString AppDir;
extern QString HomeDir;
extern QString DataDir;
extern bool TrActive;
extern QString DetailViewTemplate;
extern QPixmap *EntryIcons;
class CmdLineArgs { class CmdLineArgs {
public: public:

@ -19,12 +19,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QVarLengthArray>
#include <QDir>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include "main.h" #include "main.h"
void initAppPaths() { void initAppPaths(int argc,char** argv) {
CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle())); CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
//assert(bundleURL); //assert(bundleURL);
CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle)); CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));

@ -19,14 +19,56 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QApplication>
#include <QByteArray>
#include <QDir>
#include <QFileInfo>
#include "main.h" #include "main.h"
void initAppPaths() { void initAppPaths(int argc,char** argv) {
AppDir = QApplication::applicationDirPath(); // Try looking for a /proc/<pid>/exe symlink first which points to
DataDir = QDir(AppDir+"/../share/keepassx").canonicalPath(); // 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"; HomeDir = QDir::homePath()+"/.keepassx";
} }

@ -19,8 +19,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <QApplication>
#include <QDir>
#include <windows.h> #include <windows.h>
#include "main.h" #include "main.h"

@ -17,53 +17,18 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "mainwindow.h"
#include <QToolButton>
#include <QToolBar> #include <QToolBar>
#include <QMenuBar>
#include <QAction>
#include <QImage>
#include <QClipboard>
#include <QApplication>
#include <QColor>
#include <QLocale>
#include <QMessageBox>
#include <QPixmap>
#include <QDropEvent>
#include <QLabel>
#include <QShowEvent>
#include <QWidget>
#include <QFileDialog>
#include <QStatusBar> #include <QStatusBar>
#include "mainwindow.h"
//#include "KpxFirefox.h"
#include "lib/random.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
#include "lib/FileDialogs.h" #include "lib/FileDialogs.h"
#include "lib/bookmarks.h"
#include "import/Import_PwManager.h" #include "import/Import_PwManager.h"
#include "import/Import_KWalletXml.h" #include "import/Import_KWalletXml.h"
#include "import/Import_KeePassX_Xml.h" #include "import/Import_KeePassX_Xml.h"
#include "export/Export_Txt.h" #include "export/Export_Txt.h"
#include "export/Export_KeePassX_Xml.h" #include "export/Export_KeePassX_Xml.h"
#include "dialogs/AboutDlg.h" #include "dialogs/dialogs.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 <iostream>
Import_KeePassX_Xml import_KeePassX_Xml; Import_KeePassX_Xml import_KeePassX_Xml;
Import_PwManager import_PwManager; Import_PwManager import_PwManager;
@ -408,25 +373,29 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
config->setLastKeyType(PASSWORD); config->setLastKeyType(PASSWORD);
} }
db=dynamic_cast<IDatabase*>(new Kdb3Database()); db=dynamic_cast<IDatabase*>(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){ if (InUnLock){
PasswordDlg.setWindowModality(Qt::WindowModal); dlg.setWindowModality(Qt::WindowModal);
unlockDlg = &PasswordDlg; unlockDlg = &dlg;
} }
bool rejected = (PasswordDlg.exec()==QDialog::Rejected); bool rejected = (dlg.exec()==PasswordDialog::Exit_Cancel);
if (InUnLock) if (InUnLock)
unlockDlg = NULL; unlockDlg = NULL;
if (rejected) if (rejected)
return false; return false;
if(PasswordDlg.BookmarkFilename!=QString()) if(dlg.selectedBookmark()!=QString())
filename=PasswordDlg.BookmarkFilename; filename=dlg.selectedBookmark();
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
setupDatabaseConnections(db); setupDatabaseConnections(db);
QString err; QString err;
StatusBarGeneral->setText(tr("Loading Database...")); StatusBarGeneral->setText(tr("Loading Database..."));
db->setKey(dlg.password(),dlg.keyFile());
if(db->load(filename)==true){ if(db->load(filename)==true){
if (IsLocked) if (IsLocked)
resetLock(); resetLock();
@ -442,10 +411,10 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
StatusBarGeneral->setText(tr("Loading Failed")); StatusBarGeneral->setText(tr("Loading Failed"));
QString error=db->getError(); QString error=db->getError();
if(error.isEmpty())error=tr("Unknown error while loading database."); if(error.isEmpty())error=tr("Unknown error while loading database.");
QMessageBox::critical(this,tr("Error") QMessageBox::critical(this,tr("Error"),
,QString("%1\n%2").arg(tr("The following error occured while opening the database:")) QString("%1\n%2").arg(tr("The following error occured while opening the database:"))
.arg(error)); .arg(error));
if(dynamic_cast<IFilePasswordAuth*>(db)->isKeyError()){ if(db->isKeyError()){
delete db; delete db;
return openDatabase(filename,IsAuto); return openDatabase(filename,IsAuto);
} }
@ -510,14 +479,14 @@ bool KeepassMainWindow::closeDatabase(bool lock){
void KeepassMainWindow::OnFileNewKdb(){ void KeepassMainWindow::OnFileNewKdb(){
IDatabase* db_new=dynamic_cast<IDatabase*>(new Kdb3Database()); IDatabase* db_new=dynamic_cast<IDatabase*>(new Kdb3Database());
db_new->create(); db_new->create();
CPasswordDialog dlg(this,QString(),db_new,false,true); PasswordDialog dlg(this,PasswordDialog::Mode_Set,PasswordDialog::Flag_None,"New Database");
dlg.setWindowTitle(tr("New Database")); if(dlg.exec()==PasswordDialog::Exit_Ok){
if(dlg.exec()==1){
if(FileOpen) if(FileOpen)
if(!closeDatabase())return; if(!closeDatabase())return;
if (IsLocked) if (IsLocked)
resetLock(); resetLock();
db=dynamic_cast<IDatabase*>(db_new); db=db_new;
db->setKey(dlg.password(),dlg.keyFile());
setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new"))); setWindowTitle(QString("[%1][*] - KeePassX").arg(tr("new")));
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
@ -533,7 +502,6 @@ void KeepassMainWindow::OnFileNewKdb(){
else{ else{
delete db_new; delete db_new;
} }
} }
// TODO Kxdb // TODO Kxdb
@ -854,9 +822,13 @@ void KeepassMainWindow::OnFileSettings(){
} }
void KeepassMainWindow::OnFileChangeKey(){ void KeepassMainWindow::OnFileChangeKey(){
CPasswordDialog dlg(this,QString(),db,false,true); QFile* file=db->file();
if(dlg.exec()) QString filename = file ? file->fileName() : QString();
PasswordDialog dlg(this,PasswordDialog::Mode_Change,PasswordDialog::Flag_None,filename);
if(dlg.exec()==PasswordDialog::Exit_Ok){
setStateFileModified(true); setStateFileModified(true);
db->setKey(dlg.password(),dlg.keyFile());
}
} }
void KeepassMainWindow::OnFileExit(){ void KeepassMainWindow::OnFileExit(){
@ -875,13 +847,13 @@ void KeepassMainWindow::OnImport(QAction* action){
IDatabase* tmpdb=dynamic_cast<IDatabase*>(new Kdb3Database()); IDatabase* tmpdb=dynamic_cast<IDatabase*>(new Kdb3Database());
tmpdb->create(); tmpdb->create();
if(dynamic_cast<IImport*>(action->data().value<QObject*>())->importDatabase(this,tmpdb)){ if(dynamic_cast<IImport*>(action->data().value<QObject*>())->importDatabase(this,tmpdb)){
CPasswordDialog dlg(this,QString(),tmpdb,false,true); PasswordDialog dlg(this,PasswordDialog::Mode_Set,PasswordDialog::Flag_None,QString());
dlg.setWindowTitle(tr("Set Master Key")); if(dlg.exec()!=PasswordDialog::Exit_Ok){
if(!dlg.exec()){
delete tmpdb; delete tmpdb;
return; return;
} }
db=tmpdb; db=tmpdb;
db->setKey(dlg.password(),dlg.keyFile());
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
setupDatabaseConnections(db); setupDatabaseConnections(db);
@ -893,7 +865,6 @@ void KeepassMainWindow::OnImport(QAction* action){
} }
else else
delete tmpdb; delete tmpdb;
} }
/* /*

@ -21,27 +21,7 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QFont>
#include <QLabel>
#include <QTime>
#include <QApplication>
#include <QShowEvent>
#include <QTranslator>
#include <QDropEvent>
#include <QListWidget>
#include <QTreeWidget>
#include <QClipboard>
#include <QTimer>
#include <QToolButton>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
//#include <QAssistantClient> //TODO HelpBrowser
#include <QUrl>
#include "Kdb3Database.h"
#include "KpxConfig.h"
#include "lib/EntryView.h" #include "lib/EntryView.h"
#include "lib/GroupView.h" #include "lib/GroupView.h"
#include "export/Export.h" #include "export/Export.h"

@ -1,5 +1,5 @@
CONFIG = qt uic resources thread stl warn_off CONFIG = qt uic resources thread stl warn_off precompile_header
QT += xml QT += xml
DEPENDPATH += crypto dialogs export forms import lib translations res DEPENDPATH += crypto dialogs export forms import lib translations res
@ -32,7 +32,7 @@ unix : !macx : !isEqual(QMAKE_WIN32,1) {
} }
TARGET = ../bin/keepassx TARGET = ../bin/keepassx
target.path = $${PREFIX}/bin target.path = $${PREFIX}/bin
data.files = ../share/keepassx data.files += ../share/keepassx
data.path = $${PREFIX}/share data.path = $${PREFIX}/share
pixmaps.files = ../share/pixmaps/* pixmaps.files = ../share/pixmaps/*
pixmaps.path = $${PREFIX}/share/pixmaps pixmaps.path = $${PREFIX}/share/pixmaps
@ -59,7 +59,7 @@ macx {
isEmpty(PREFIX): PREFIX = /Applications isEmpty(PREFIX): PREFIX = /Applications
TARGET = ../bin/KeePassX TARGET = ../bin/KeePassX
target.path = $${PREFIX} target.path = $${PREFIX}
data.files = ../share/keepassx data.files += ../share/keepassx
data.path = Contents/Resources data.path = Contents/Resources
LIBS += -framework CoreFoundation LIBS += -framework CoreFoundation
isEqual(LINK,DYNAMIC){ isEqual(LINK,DYNAMIC){
@ -90,7 +90,7 @@ isEqual(QMAKE_WIN32,1) {
isEmpty(PREFIX): PREFIX = "C:/Program files/KeePassX" isEmpty(PREFIX): PREFIX = "C:/Program files/KeePassX"
TARGET = ../bin/KeePassX TARGET = ../bin/KeePassX
target.path = $${PREFIX} target.path = $${PREFIX}
data.files = ../share/keepassx/* data.files += ../share/keepassx/*
data.path = $${PREFIX}/share 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.files = $${QMAKE_LIBDIR_QT}/QtCore4.dll $${QMAKE_LIBDIR_QT}/QtGui4.dll $${QMAKE_LIBDIR_QT}/QtXml4.dll
@ -180,7 +180,6 @@ HEADERS += lib/UrlLabel.h \
lib/GroupView.h \ lib/GroupView.h \
lib/EntryView.h \ lib/EntryView.h \
crypto/arcfour.h \ crypto/arcfour.h \
lib/KpFileIconProvider.h \
crypto/aes_edefs.h \ crypto/aes_edefs.h \
crypto/aes_tdefs.h \ crypto/aes_tdefs.h \
crypto/aes.h \ crypto/aes.h \
@ -200,7 +199,9 @@ HEADERS += lib/UrlLabel.h \
# KpxFirefox.h \ # KpxFirefox.h \
dialogs/AddBookmarkDlg.h \ dialogs/AddBookmarkDlg.h \
lib/bookmarks.h \ lib/bookmarks.h \
dialogs/ManageBookmarksDlg.h dialogs/ManageBookmarksDlg.h \
dialogs/dialogs.h
SOURCES += lib/UrlLabel.cpp \ SOURCES += lib/UrlLabel.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
@ -240,12 +241,7 @@ SOURCES += lib/UrlLabel.cpp \
lib/EntryView.cpp \ lib/EntryView.cpp \
lib/FileDialogs.cpp \ lib/FileDialogs.cpp \
crypto/arcfour.cpp \ crypto/arcfour.cpp \
lib/KpFileIconProvider.cpp \
lib/ShortcutWidget.cpp \ lib/ShortcutWidget.cpp \
crypto/aescrypt.c \
crypto/aeskey.c \
crypto/aestab.c \
crypto/aes_modes.c \
crypto/sha256.cpp \ crypto/sha256.cpp \
crypto/yarrow.cpp \ crypto/yarrow.cpp \
lib/WaitAnimationWidget.cpp \ lib/WaitAnimationWidget.cpp \
@ -253,6 +249,12 @@ SOURCES += lib/UrlLabel.cpp \
# KpxFirefox.cpp \ # KpxFirefox.cpp \
dialogs/AddBookmarkDlg.cpp \ dialogs/AddBookmarkDlg.cpp \
lib/bookmarks.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 RESOURCES += res/resources.qrc