added KeePassX_XML export,

PwManager import works again,
text export works again.

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@125 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 28ba242090
commit 50a39d726a
  1. 5
      src/dialogs/EditEntryDlg.cpp
  2. 52
      src/dialogs/SimplePasswordDlg.cpp
  3. 20
      src/dialogs/SimplePasswordDlg.h
  4. 7
      src/export/Export_Txt.cpp
  5. 11
      src/export/Export_Txt.h
  6. 474
      src/forms/EditEntryDlg.ui
  7. 84
      src/forms/MainWindow.ui
  8. 156
      src/forms/SimplePasswordDlg.ui
  9. 12
      src/import/Import_KWalletXml.cpp
  10. 274
      src/import/Import_PwManager.cpp
  11. 35
      src/import/Import_PwManager.h
  12. 174
      src/mainwindow.cpp
  13. 7
      src/mainwindow.h
  14. 12
      src/src.pro

@ -60,12 +60,12 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
connect(Edit_Password_w, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordwTextChanged(const QString&))); connect(Edit_Password_w, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordwTextChanged(const QString&)));
connect(Edit_Password, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordTextChanged(const QString&))); connect(Edit_Password, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordTextChanged(const QString&)));
connect(ButtonEchoMode, SIGNAL(clicked()), this, SLOT( ChangeEchoMode())); connect(ButtonEchoMode, SIGNAL(clicked()), this, SLOT( ChangeEchoMode()));
connect(ButtonCancel, SIGNAL(clicked()), this, SLOT( OnButtonCancel())); connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT( OnButtonCancel()));
connect(ButtonOpenAttachment, SIGNAL(clicked()), this, SLOT( OnNewAttachment())); connect(ButtonOpenAttachment, SIGNAL(clicked()), this, SLOT( OnNewAttachment()));
connect(ButtonDeleteAttachment, SIGNAL(clicked()), this, SLOT( OnDeleteAttachment())); connect(ButtonDeleteAttachment, SIGNAL(clicked()), this, SLOT( OnDeleteAttachment()));
connect(ButtonSaveAttachment, SIGNAL(clicked()), this, SLOT( OnSaveAttachment())); connect(ButtonSaveAttachment, SIGNAL(clicked()), this, SLOT( OnSaveAttachment()));
connect(ButtonGenPw, SIGNAL(clicked()), this, SLOT( OnButtonGenPw())); connect(ButtonGenPw, SIGNAL(clicked()), this, SLOT( OnButtonGenPw()));
connect(ButtonOK, SIGNAL(clicked()),this,SLOT(OnButtonOK())); connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()),this,SLOT(OnButtonOK()));
connect(CheckBox_ExpiresNever,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxExpiresNeverChanged(int))); connect(CheckBox_ExpiresNever,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxExpiresNeverChanged(int)));
connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons())); connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons()));
@ -139,6 +139,7 @@ if(event->spontaneous()==false){
//Added resize event //Added resize event
void CEditEntryDlg::resizeEvent(QResizeEvent *event){ void CEditEntryDlg::resizeEvent(QResizeEvent *event){
createBanner(&BannerPixmap,Icon_Key32x32,tr("Test 2"),width()); createBanner(&BannerPixmap,Icon_Key32x32,tr("Test 2"),width());
QDialog::resizeEvent(event);
} }

@ -1,6 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005 by Tarek Saidi * * Copyright (C) 2005-2007 by Tarek Saidi *
* mail@tarek-saidi.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 *
* 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 *
@ -18,46 +18,50 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <qlineedit.h> #include <QLineEdit>
#include <qpushbutton.h> #include <QPushButton>
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "PwmConfig.h"
#include "SimplePasswordDlg.h" #include "SimplePasswordDlg.h"
CSimplePasswordDialog::CSimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl) SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl)
: QDialog(parent,fl) : QDialog(parent,fl)
{ {
setupUi(this); setupUi(this);
if(!config.ShowPasswords)Button_HidePassword->toggle(); if(!config.ShowPasswords)Button_HidePassword->toggle();
connect(ButtonOK,SIGNAL(clicked()),this,SLOT(OnOK())); connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnOK()));
connect(ButtonCancel,SIGNAL(clicked()),this,SLOT(OnCancel())); connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(OnCancel()));
connect(Button_HidePassword,SIGNAL(toggled(bool)),this,SLOT(OnHidePasswordToggled(bool))); connect(Button_HidePassword,SIGNAL(toggled(bool)),this,SLOT(OnHidePasswordToggled(bool)));
connect(EditPassword,SIGNAL(textChanged(const QString&)),this,SLOT(OnTextChanged(const QString&)));
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
} }
CSimplePasswordDialog::~CSimplePasswordDialog() SimplePasswordDialog::~SimplePasswordDialog()
{ {
} }
void CSimplePasswordDialog::OnCancel() void SimplePasswordDialog::OnTextChanged(const QString& txt){
{ if(txt==QString())
done(0); buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
else
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
} }
void SimplePasswordDialog::OnCancel()
void CSimplePasswordDialog::OnOK()
{ {
password=EditPassword->text(); done(0);
done(1);
} }
void CSimplePasswordDialog::OnHidePasswordToggled(bool state) void SimplePasswordDialog::OnOK()
{ {
if(state)EditPassword->setEchoMode(QLineEdit::Password); password=EditPassword->text();
else EditPassword->setEchoMode(QLineEdit::Normal); done(1);
} }
/*$SPECIALIZATION$*/ void SimplePasswordDialog::OnHidePasswordToggled(bool state)
{
if(state)EditPassword->setEchoMode(QLineEdit::Password);
else EditPassword->setEchoMode(QLineEdit::Normal);
}

@ -23,31 +23,21 @@
#include "ui_SimplePasswordDlg.h" #include "ui_SimplePasswordDlg.h"
class CSimplePasswordDialog : public QDialog, public Ui_SimplePasswordDialog class SimplePasswordDialog : public QDialog, public Ui_SimplePasswordDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CSimplePasswordDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); SimplePasswordDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
~CSimplePasswordDialog(); ~SimplePasswordDialog();
/*$PUBLIC_FUNCTIONS$*/
public slots: public: QString password;
/*$PUBLIC_SLOTS$*/
protected:
/*$PROTECTED_FUNCTIONS$*/
protected slots:
/*$PROTECTED_SLOTS$*/
public: QString password;
public slots: public slots:
virtual void OnCancel(); virtual void OnCancel();
public slots:
virtual void OnOK(); virtual void OnOK();
public slots:
virtual void OnHidePasswordToggled(bool state); virtual void OnHidePasswordToggled(bool state);
virtual void OnTextChanged(const QString&);
}; };
#endif #endif

@ -37,7 +37,9 @@ QString GroupTemplate=QString("\n\
*** Group: %1 ***\n\ *** Group: %1 ***\n\
"); ");
QString Export_Txt::exportDatabase(QWidget* GuiParent, IDatabase* db, QIODevice* file){ bool Export_Txt::exportDatabase(QWidget* GuiParent, IDatabase* db){
QFile *file=openFile(GuiParent,identifier(),QStringList()<<tr("All Files (*)") << tr("Text Files (*.txt)"));
if(!file)return false;
QList<IGroupHandle*> groups=db->sortedGroups(); QList<IGroupHandle*> groups=db->sortedGroups();
for(int g=0;g<groups.size();g++){ for(int g=0;g<groups.size();g++){
file->write(GroupTemplate.arg(groups[g]->title()).toUtf8()); file->write(GroupTemplate.arg(groups[g]->title()).toUtf8());
@ -54,5 +56,6 @@ QString Export_Txt::exportDatabase(QWidget* GuiParent, IDatabase* db, QIODevice*
password.lock(); password.lock();
} }
} }
return QString(); delete file;
return true;
} }

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi * * Copyright (C) 2005-2007 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 *
@ -21,12 +21,13 @@
#define _EXPORT_TXT_H_ #define _EXPORT_TXT_H_
#include <QObject> #include <QObject>
#include "IExport.h" #include "Export.h"
class Export_Txt:public QObject, public IExport{ class Export_Txt:public IExport, public ExporterBase{
public: public:
virtual QString exportDatabase(QWidget* GuiParent, IDatabase* Database, QIODevice* Dest); virtual bool exportDatabase(QWidget* GuiParent, IDatabase* Database);
virtual QString name(){return QString("Txt");} virtual QString identifier(){return "e_txt";}
virtual QString title(){return "Text File";}
}; };
#endif #endif

@ -1,7 +1,5 @@
<ui version="4.0" > <ui version="4.0" >
<author>Tarek Saidi</author> <author>Tarek Saidi</author>
<comment></comment>
<exportmacro></exportmacro>
<class>EditEntryDialog</class> <class>EditEntryDialog</class>
<widget class="QDialog" name="EditEntryDialog" > <widget class="QDialog" name="EditEntryDialog" >
<property name="geometry" > <property name="geometry" >
@ -48,23 +46,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" > <item rowspan="2" row="5" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>50</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3" >
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="margin" >
<number>0</number> <number>0</number>
@ -72,22 +54,8 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="6" column="0" > <item row="1" column="1" >
<widget class="QLabel" name="textLabel9" > <widget class="QToolButton" name="ButtonGenPw" >
<property name="text" >
<string>Quality:</string>
</property>
</widget>
</item>
<item row="9" column="0" >
<widget class="QLabel" name="textLabel12" >
<property name="text" >
<string>Attachment:</string>
</property>
</widget>
</item>
<item row="4" column="5" >
<widget class="QToolButton" name="ButtonEchoMode" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>1</hsizetype> <hsizetype>1</hsizetype>
@ -109,53 +77,15 @@
</size> </size>
</property> </property>
<property name="text" > <property name="text" >
<string>...</string> <string>Ge&amp;n.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QLabel" name="textLabel4" > <widget class="QLineEdit" name="Edit_Password_w" />
<property name="text" >
<string>Title:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabel5" >
<property name="text" >
<string>Username:</string>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="textLabel10" >
<property name="text" >
<string>Comment:</string>
</property>
</widget>
</item>
<item row="8" column="1" >
<widget class="QDateTimeEdit" name="DateTime_Expire" />
</item>
<item row="10" column="1" >
<widget class="QLabel" name="Label_AttachmentSize" >
<property name="text" >
<string>%1</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="4" >
<widget class="QLineEdit" name="Edit_Password" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel7" >
<property name="text" >
<string>URL:</string>
</property>
</widget>
</item> </item>
<item row="5" column="5" > <item row="0" column="1" >
<widget class="QToolButton" name="ButtonGenPw" > <widget class="QToolButton" name="ButtonEchoMode" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>1</hsizetype> <hsizetype>1</hsizetype>
@ -177,24 +107,203 @@
</size> </size>
</property> </property>
<property name="text" > <property name="text" >
<string>Ge&amp;n.</string> <string>...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" colspan="4" >
<widget class="QLineEdit" name="Edit_Password_w" />
</item>
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="textLabel3" > <widget class="QLineEdit" name="Edit_Password" />
<property name="text" >
<string>Group:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="5" >
<widget class="QLineEdit" name="Edit_Title" />
</item> </item>
<item row="9" column="1" colspan="3" > </layout>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="textLabel9" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Quality:</string>
</property>
</widget>
</item>
<item row="10" column="0" >
<widget class="QLabel" name="textLabel12" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Attachment:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabel4" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Title:</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel5" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Username:</string>
</property>
</widget>
</item>
<item row="8" column="0" >
<widget class="QLabel" name="textLabel10" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Comment:</string>
</property>
</widget>
</item>
<item row="11" column="1" >
<widget class="QLabel" name="Label_AttachmentSize" >
<property name="text" >
<string>%1</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel7" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>URL:</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel3" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Group:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="Edit_Title" />
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="Edit_UserName" />
</item>
<item row="6" column="0" >
<widget class="QLabel" name="textLabel8" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Password Repet.:</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabel6" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Password:</string>
</property>
</widget>
</item>
<item row="9" column="0" >
<widget class="QLabel" name="textLabel11" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Expires:</string>
</property>
</widget>
</item>
<item row="8" column="1" >
<widget class="QTextEdit" name="Edit_Comment" />
</item>
<item row="12" column="0" colspan="2" >
<widget class="Line" name="line1" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="Edit_Attachment" > <widget class="QLineEdit" name="Edit_Attachment" >
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
@ -209,107 +318,67 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="5" > <item>
<widget class="QLineEdit" name="Edit_UserName" /> <widget class="QToolButton" name="ButtonOpenAttachment" >
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabel8" >
<property name="text" > <property name="text" >
<string>Password Repet.:</string> <string/>
</property> </property>
</widget> <property name="icon" >
</item> <iconset/>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="Combo_Group" />
</item>
<item row="3" column="1" colspan="5" >
<widget class="QLineEdit" name="Edit_URL" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel6" >
<property name="text" >
<string>Password:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" > <item>
<widget class="QLabel" name="textLabel11" > <widget class="QToolButton" name="ButtonSaveAttachment" >
<property name="text" > <property name="text" >
<string>Expires:</string> <string/>
</property>
<property name="icon" >
<iconset/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="5" > <item>
<widget class="QTextEdit" name="Edit_Comment" /> <widget class="QToolButton" name="ButtonDeleteAttachment" >
</item> <property name="text" >
<item row="11" column="0" colspan="6" > <string/>
<widget class="Line" name="line1" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
</property> </property>
<property name="frameShadow" > <property name="icon" >
<enum>QFrame::Sunken</enum> <iconset/>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="4" colspan="2" > </layout>
<layout class="QHBoxLayout" > </item>
<property name="margin" > <item row="9" column="1" >
<number>0</number> <layout class="QHBoxLayout" >
</property> <property name="margin" >
<property name="spacing" > <number>0</number>
<number>6</number> </property>
</property> <property name="spacing" >
<item> <number>6</number>
<widget class="QToolButton" name="ButtonOpenAttachment" > </property>
<property name="text" > <item>
<string/> <widget class="QDateTimeEdit" name="DateTime_Expire" />
</property>
<property name="icon" >
<iconset/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="ButtonSaveAttachment" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="ButtonDeleteAttachment" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset/>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="8" column="2" colspan="4" > <item>
<widget class="QCheckBox" name="CheckBox_ExpiresNever" > <widget class="QCheckBox" name="CheckBox_ExpiresNever" >
<property name="text" > <property name="text" >
<string>Never</string> <string>Never</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="5" > </layout>
<widget class="QLabel" name="Label_Bits" > </item>
<property name="text" > <item row="7" column="1" >
<string>%1 Bit</string> <layout class="QHBoxLayout" >
</property> <property name="margin" >
</widget> <number>0</number>
</item> </property>
<item row="6" column="1" colspan="4" > <property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QProgressBar" name="Progress_Quali" > <widget class="QProgressBar" name="Progress_Quali" >
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
@ -334,7 +403,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3" > <item>
<widget class="QLabel" name="Label_Bits" >
<property name="text" >
<string>%1 Bit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="Edit_URL" />
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="Combo_Group" />
</item>
<item>
<widget class="QLabel" name="textLabel1" > <widget class="QLabel" name="textLabel1" >
<property name="text" > <property name="text" >
<string>Icon:</string> <string>Icon:</string>
@ -344,10 +436,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4" > <item>
<widget class="QComboBox" name="Combo_IconPicker" /> <widget class="QComboBox" name="Combo_IconPicker" />
</item> </item>
<item row="0" column="5" > <item>
<widget class="QToolButton" name="Button_CustomIcons" > <widget class="QToolButton" name="Button_CustomIcons" >
<property name="text" > <property name="text" >
<string>></string> <string>></string>
@ -356,35 +448,28 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="2" > <item row="13" column="0" colspan="2" >
<widget class="QPushButton" name="ButtonCancel" > <widget class="QDialogButtonBox" name="buttonBox" >
<property name="text" > <property name="orientation" >
<string>&amp;Cancel</string> <enum>Qt::Horizontal</enum>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QPushButton" name="ButtonOK" >
<property name="text" >
<string>O&amp;K</string>
</property> </property>
<property name="shortcut" > <property name="standardButtons" >
<string>Alt+K</string> <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="0" column="0" colspan="2" >
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>40</width> <width>20</width>
<height>20</height> <height>50</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -392,7 +477,6 @@
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<tabstops> <tabstops>
<tabstop>Combo_Group</tabstop> <tabstop>Combo_Group</tabstop>
<tabstop>Combo_IconPicker</tabstop> <tabstop>Combo_IconPicker</tabstop>

@ -137,38 +137,6 @@
<addaction name="EditSearchAction" /> <addaction name="EditSearchAction" />
<addaction name="EditGroupSearchAction" /> <addaction name="EditGroupSearchAction" />
</widget> </widget>
<widget class="QMenu" name="menuDatei" >
<property name="title" >
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menuImportieren_aus" >
<property name="title" >
<string>&amp;Import from...</string>
</property>
<addaction name="FileImpPwmAction" />
<addaction name="FileImpKWalletXmlAction" />
</widget>
<widget class="QMenu" name="menuExport_to" >
<property name="title" >
<string>&amp;Export to...</string>
</property>
<addaction name="FileExpPlainTextAction" />
</widget>
<addaction name="FileNewAction" />
<addaction name="FileOpenAction" />
<addaction name="FileCloseAction" />
<addaction name="separator" />
<addaction name="FileSaveAction" />
<addaction name="FileSaveAsAction" />
<addaction name="separator" />
<addaction name="FileSettingsAction" />
<addaction name="FileChangeKeyAction" />
<addaction name="separator" />
<addaction name="menuImportieren_aus" />
<addaction name="menuExport_to" />
<addaction name="separator" />
<addaction name="FileExitAction" />
</widget>
<widget class="QMenu" name="ViewMenu" > <widget class="QMenu" name="ViewMenu" >
<property name="title" > <property name="title" >
<string>&amp;View</string> <string>&amp;View</string>
@ -221,6 +189,35 @@
<addaction name="ExtrasSettingsAction" /> <addaction name="ExtrasSettingsAction" />
<addaction name="ExtrasPasswordGenAction" /> <addaction name="ExtrasPasswordGenAction" />
</widget> </widget>
<widget class="QMenu" name="menuDatei" >
<property name="title" >
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menuExport" >
<property name="title" >
<string>&amp;Export to...</string>
</property>
</widget>
<widget class="QMenu" name="menuImport" >
<property name="title" >
<string>&amp;Import from...</string>
</property>
</widget>
<addaction name="FileNewAction" />
<addaction name="FileOpenAction" />
<addaction name="FileCloseAction" />
<addaction name="separator" />
<addaction name="FileSaveAction" />
<addaction name="FileSaveAsAction" />
<addaction name="separator" />
<addaction name="FileSettingsAction" />
<addaction name="FileChangeKeyAction" />
<addaction name="separator" />
<addaction name="menuImport" />
<addaction name="menuExport" />
<addaction name="separator" />
<addaction name="FileExitAction" />
</widget>
<addaction name="menuDatei" /> <addaction name="menuDatei" />
<addaction name="menuBearbeiten" /> <addaction name="menuBearbeiten" />
<addaction name="ViewMenu" /> <addaction name="ViewMenu" />
@ -262,16 +259,6 @@
<string>E&amp;xit</string> <string>E&amp;xit</string>
</property> </property>
</action> </action>
<action name="FileImpPwmAction" >
<property name="text" >
<string>PwManager File (*.pwm)</string>
</property>
</action>
<action name="FileImpKWalletXmlAction" >
<property name="text" >
<string>KWallet XML-File (*.xml)</string>
</property>
</action>
<action name="EditNewGroupAction" > <action name="EditNewGroupAction" >
<property name="text" > <property name="text" >
<string>Add New Group...</string> <string>Add New Group...</string>
@ -464,11 +451,6 @@
<string>&amp;KeePassX Handbook...</string> <string>&amp;KeePassX Handbook...</string>
</property> </property>
</action> </action>
<action name="FileExpPlainTextAction" >
<property name="text" >
<string>Plain Text (*.txt)</string>
</property>
</action>
<action name="HideSearchResultsAction" > <action name="HideSearchResultsAction" >
<property name="text" > <property name="text" >
<string>Hide</string> <string>Hide</string>
@ -526,14 +508,14 @@
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>KeepassGroupView</class> <class>KeepassEntryView</class>
<extends>QTreeWidget</extends> <extends>QTreeWidget</extends>
<header>../../src/lib/GroupView.h</header> <header>../../src/lib/EntryView.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>KeepassEntryView</class> <class>KeepassGroupView</class>
<extends>QTreeWidget</extends> <extends>QTreeWidget</extends>
<header>../../src/lib/EntryView.h</header> <header>../../src/lib/GroupView.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>

@ -1,7 +1,4 @@
<ui version="4.0" > <ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>SimplePasswordDialog</class> <class>SimplePasswordDialog</class>
<widget class="QDialog" name="SimplePasswordDialog" > <widget class="QDialog" name="SimplePasswordDialog" >
<property name="geometry" > <property name="geometry" >
@ -15,7 +12,7 @@
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>0</hsizetype> <hsizetype>0</hsizetype>
<vsizetype>0</vsizetype> <vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -28,87 +25,92 @@
</property> </property>
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>345</width> <width>16777215</width>
<height>90</height> <height>90</height>
</size> </size>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Enter your Password</string> <string>Enter your Password</string>
</property> </property>
<widget class="QLabel" name="textLabel1" > <layout class="QVBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>9</number>
<x>10</x>
<y>20</y>
<width>60</width>
<height>20</height>
</rect>
</property>
<property name="text" >
<string>Password:</string>
</property>
</widget>
<widget class="QPushButton" name="ButtonOK" >
<property name="geometry" >
<rect>
<x>170</x>
<y>60</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>O&amp;K</string>
</property>
<property name="shortcut" >
<string>Alt+K</string>
</property>
</widget>
<widget class="QPushButton" name="ButtonCancel" >
<property name="geometry" >
<rect>
<x>257</x>
<y>60</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
</widget>
<widget class="QLineEdit" name="EditPassword" >
<property name="geometry" >
<rect>
<x>80</x>
<y>20</y>
<width>240</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="Button_HidePassword" >
<property name="geometry" >
<rect>
<x>320</x>
<y>20</y>
<width>20</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="shortcut" >
<string/>
</property> </property>
<property name="checkable" > <property name="spacing" >
<bool>true</bool> <number>6</number>
</property> </property>
</widget> <item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="textLabel1" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="EditPassword" />
</item>
<item>
<widget class="QPushButton" name="Button_HidePassword" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>28</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>28</width>
<height>16777215</height>
</size>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>

@ -1,6 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005 by Tarek Saidi * * Copyright (C) 2005-2007 by Tarek Saidi *
* mail@tarek-saidi.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 *
* 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 *
@ -19,11 +19,9 @@
***************************************************************************/ ***************************************************************************/
#include "Import_KWalletXml.h" #include "Import_KWalletXml.h"
#include <iostream> #include <QFile>
#include <qobject.h> #include <QtXml>
#include <qfile.h>
#include <qdom.h>
using namespace std;
/* /*
bool Import_KWalletXml::importFile(QString FileName,StandardDatabase* pwm,QString& err){ bool Import_KWalletXml::importFile(QString FileName,StandardDatabase* pwm,QString& err){

@ -18,150 +18,152 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <qobject.h> #include <QFile>
#include <qfile.h>
#include <iostream> #include <iostream>
#include <qdom.h> #include <QMessageBox>
//#include "crypto/blowfish.h" #include <QtXml>
//#include "crypto/sha1.h" #include "crypto/blowfish.h"
#include "crypto/sha1.h"
#include "Import_PwManager.h" #include "Import_PwManager.h"
using namespace std; using namespace std;
/*
bool Import_PwManager::importFile(QString filename, QString password, StandardDatabase* db, QString& err){
database=db; bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
QFile file(filename); database=db;
char* buffer=NULL; QFile* file=openFile(GuiParent,identifier(),QStringList()<<tr("PwManager Files (*.pwm)")<<tr("All Files (*)"));
int offset=0; if(!file)return false;
int len=0; QString password=getPassword(GuiParent);
if(!file.exists()){err+=QObject::tr("File not found."); return false;} if(password==QString()){delete file; return false;}
if(!file.open(QIODevice::ReadOnly)){err+=QObject::tr("Could not open file."); return false;} char* buffer=NULL;
if(len=file.size()) buffer=new char[len]; int offset=0;
else {err+=QObject::tr("File is empty."); return false;} int len=0;
file.read(buffer,len); if(len=file->size()) buffer=new char[len];
file.close(); else {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is empty.")); delete file; return false;}
if(QString::fromAscii(buffer,17)!="PWM_PASSWORD_FILE") file->read(buffer,len);
{err+=QObject::tr("File is no valid PwManager file."); return false;} file->close();
offset+=17; delete file;
if(buffer[offset]!=0x05) if(QString::fromAscii(buffer,17)!="PWM_PASSWORD_FILE")
{err+=QObject::tr("Unsupported file version."); return false;} {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is no valid PwManager file.")); return false;}
offset++; offset+=17;
if(buffer[offset]!=0x01) if(buffer[offset]!=0x05)
{err+=QObject::tr("Unsupported hash algorithm."); return false;} {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Unsupported file version.")); return false;}
offset++; offset++;
if(buffer[offset]!=0x01) if(buffer[offset]!=0x01)
{err+=QObject::tr("Unsupported hash algorithm."); return false;} {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Unsupported hash algorithm.")); return false;}
offset++; offset++;
if(buffer[offset]!=0x01) if(buffer[offset]!=0x01)
{err+=QObject::tr("Unsupported encryption algorithm."); return false;} {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Unsupported hash algorithm.")); return false;}
offset++; offset++;
if(buffer[offset]==0x00)Compression=0; if(buffer[offset]!=0x01)
if(buffer[offset]==0x01)Compression=1; {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Unsupported encryption algorithm.")); return false;}
if(buffer[offset]==0x02)Compression=2; offset++;
///@TODO Compression if(buffer[offset]==0x00)Compression=0;
if(buffer[offset]) if(buffer[offset]==0x01)Compression=1;
{err+=QObject::tr("Compressed files are not supported yet."); return false;} if(buffer[offset]==0x02)Compression=2;
offset++; ///@TODO Compression
if(buffer[offset]==0x00)KeyFlag=true; if(buffer[offset])
else KeyFlag=false; {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Compressed files are not supported yet.")); return false;}
offset++; offset++;
//Reserved Bytes (64) if(buffer[offset]==0x00)KeyFlag=true;
offset+=64; else KeyFlag=false;
memcpy(KeyHash,buffer+offset,20); offset++;
offset+=20; //Reserved Bytes (64)
memcpy(DataHash,buffer+offset,20); offset+=64;
offset+=20; memcpy(KeyHash,buffer+offset,20);
offset+=20;
Blowfish blowfish; memcpy(DataHash,buffer+offset,20);
int pwlen=password.length(); offset+=20;
byte* Key=new byte[pwlen];
byte* xml=new byte[len-offset+1]; Blowfish blowfish;
xml[len-offset]=0; int pwlen=password.length();
memcpy(Key,password.toAscii(),pwlen); byte* Key=new byte[pwlen];
char* key_hash=new char[20]; byte* xml=new byte[len-offset+1];
CSHA1 sha; xml[len-offset]=0;
sha.Update(Key,pwlen); memcpy(Key,password.toAscii(),pwlen);
sha.Final(); char* key_hash=new char[20];
sha.GetHash((unsigned char*)key_hash); CSHA1 sha;
if(memcmp(key_hash,KeyHash,20)){ sha.Update(Key,pwlen);
delete[] Key; delete [] key_hash; delete [] buffer; sha.Final();
err+=QObject::tr("Wrong password."); sha.GetHash((unsigned char*)key_hash);
return false; if(memcmp(key_hash,KeyHash,20)){
} delete[] Key; delete [] key_hash; delete [] buffer;
delete [] key_hash; QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Wrong password."));
blowfish.bf_setkey(Key,password.length()); return false;
blowfish.bf_decrypt(xml,(byte*)buffer+offset,len-offset); }
delete [] Key; delete [] key_hash;
delete [] buffer; blowfish.bf_setkey(Key,password.length());
char* content_hash=new char[20]; blowfish.bf_decrypt(xml,(byte*)buffer+offset,len-offset);
sha.Reset(); delete [] Key;
sha.Update(xml,strlen((char*)xml)-1); delete [] buffer;
sha.Final(); char* content_hash=new char[20];
sha.GetHash((unsigned char*)content_hash); sha.Reset();
if(memcmp(content_hash,DataHash,20)){ sha.Update(xml,strlen((char*)xml)-1);
delete [] content_hash; delete [] xml; sha.Final();
err+=QObject::tr("File is damaged (hash test failed)."); sha.GetHash((unsigned char*)content_hash);
return false; if(memcmp(content_hash,DataHash,20)){
} delete [] content_hash; delete [] xml;
delete[] content_hash; QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is damaged (hash test failed)."));
return false;
if(!parseXmlContent((char*)xml)){ }
delete [] xml; delete[] content_hash;
err+=QObject::tr("Invalid XML data (see stdout for details)."); return false;}
database->CalcMasterKeyByPassword(password); if(!parseXmlContent((char*)xml)){
return true; delete [] xml;
QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Invalid XML data (see stdout for details).")); return false;}
dynamic_cast<IFilePasswordAuth*>(database)->authByPwd(password);
return true;
} }
bool Import_PwManager::parseXmlContent(char* content){ bool Import_PwManager::parseXmlContent(char* content){
QDomDocument db; QDomDocument db;
QString err; QString err;
int col,line; int col,line;
if(!db.setContent(QString::fromUtf8(content,strlen(content)-1),false,&err,&line,&col)){ if(!db.setContent(QString::fromUtf8(content,strlen(content)-1),false,&err,&line,&col)){
qWarning("Import_PwManager::parseXmlContent():\n"); qWarning("Import_PwManager::parseXmlContent():\n");
qWarning(((err+" (Line:%1 Column:%2)").arg(line).arg(col)+QString('\n')).toAscii()); qWarning(((err+" (Line:%1 Column:%2)").arg(line).arg(col)+QString('\n')).toAscii());
return false;} return false;}
QDomElement root=db.documentElement(); QDomElement root=db.documentElement();
if(root.tagName()!="P")return false; if(root.tagName()!="P")return false;
//Achtung! Kommentare und Kategorien haben das selbe Tag "c" //Achtung! Kommentare und Kategorien haben das selbe Tag "c"
if(!root.elementsByTagName("c").item(0).isElement())return false; if(!root.elementsByTagName("c").item(0).isElement())return false;
QDomElement groups=root.elementsByTagName("c").item(0).toElement(); QDomElement groups=root.elementsByTagName("c").item(0).toElement();
int i=0; int i=0;
while(1){
QDomElement CurrGroup;
if(!groups.elementsByTagName("c"+QString::number(i)).length())break;
if(groups.elementsByTagName("c"+QString::number(i)).length()>1)return false;
if(!groups.elementsByTagName("c"+QString::number(i)).item(0).isElement())return false;
CurrGroup=groups.elementsByTagName("c"+QString::number(i)).item(0).toElement();
if(!CurrGroup.hasAttribute("n"))return false;
IGroupHandle* NewGroup=database->addGroup(NULL);
NewGroup->Name=CurrGroup.attribute("n");
int j=0;
while(1){ while(1){
QDomElement CurrEntry; QDomElement CurrGroup;
if(!CurrGroup.elementsByTagName("e"+QString::number(j)).length())break; if(!groups.elementsByTagName("c"+QString::number(i)).length())break;
if(CurrGroup.elementsByTagName("e"+QString::number(j)).length()>1)return false; if(groups.elementsByTagName("c"+QString::number(i)).length()>1)return false;
if(!CurrGroup.elementsByTagName("e"+QString::number(j)).item(0).isElement())return false; if(!groups.elementsByTagName("c"+QString::number(i)).item(0).isElement())return false;
CurrEntry=CurrGroup.elementsByTagName("e"+QString::number(j)).item(0).toElement(); CurrGroup=groups.elementsByTagName("c"+QString::number(i)).item(0).toElement();
if(!xml_parseEntryAttributes(&CurrEntry,NewGroup))return false; if(!CurrGroup.hasAttribute("n"))return false;
j++; IGroupHandle* NewGroup=database->addGroup(&CGroup(),NULL);
NewGroup->setTitle(CurrGroup.attribute("n"));
int j=0;
while(1){
QDomElement CurrEntry;
if(!CurrGroup.elementsByTagName("e"+QString::number(j)).length())break;
if(CurrGroup.elementsByTagName("e"+QString::number(j)).length()>1)return false;
if(!CurrGroup.elementsByTagName("e"+QString::number(j)).item(0).isElement())return false;
CurrEntry=CurrGroup.elementsByTagName("e"+QString::number(j)).item(0).toElement();
if(!xml_parseEntryAttributes(&CurrEntry,NewGroup))return false;
j++;
}
i++;
} }
i++;
return true;
} }
return true; bool Import_PwManager::xml_parseEntryAttributes(QDomElement* EntryElement,IGroupHandle* NewGroup){
} IEntryHandle* e=database->newEntry(NewGroup);
e->setTitle(EntryElement->elementsByTagName("d").item(0).toElement().text());
bool Import_PwManager::xml_parseEntryAttributes(QDomElement* EntryElement,IGroupHandle* NewGroup){/* e->setUsername(EntryElement->elementsByTagName("n").item(0).toElement().text());
IEntryHandle* e=database->addEntry(); QString pw(EntryElement->elementsByTagName("p").item(0).toElement().text());
e->Title=EntryElement->elementsByTagName("d").item(0).toElement().text(); SecString spw;
e->UserName=EntryElement->elementsByTagName("n").item(0).toElement().text(); spw.setString(pw,true);
QString pw=EntryElement->elementsByTagName("p").item(0).toElement().text(); e->setPassword(spw);
e->Password.setString(pw,true); QString comment=EntryElement->elementsByTagName("c").item(0).toElement().text();
e->Additional=EntryElement->elementsByTagName("c").item(0).toElement().text(); comment.replace("$>--endl--<$","\n");
e->Additional=e->Additional.replace("$>--endl--<$","\n"); e->setComment(comment);
e->URL=EntryElement->elementsByTagName("u").item(0).toElement().text(); e->setUrl(EntryElement->elementsByTagName("u").item(0).toElement().text());
e->GroupID=NewGroup->ID; return true;
return true; }
}
*/

@ -20,23 +20,26 @@
#ifndef _IMPORT_PWMANAGER_ #ifndef _IMPORT_PWMANAGER_
#define _IMPORT_PWMANAGER_ #define _IMPORT_PWMANAGER_
#include <qdom.h> #include <QDomElement>
#include <qstring.h> #include <QString>
#include "StandardDatabase.h" #include "Database.h"
#include "Import.h"
/*
class Import_PwManager{
public:
bool importFile(QString FileName, QString Password,StandardDatabase* db,QString& err);
private:
bool KeyFlag; // true=Password, false=Chipcard
int Compression; // 0=none, 1=gzip, 2=bzip2
unsigned char KeyHash[20];
unsigned char DataHash[20];
StandardDatabase* database;
bool parseXmlContent(char* content); class Import_PwManager:public IImport, public ImporterBase{
bool xml_parseEntryAttributes(QDomElement* EntryTag,IGroupHandle* parent); public:
virtual bool importDatabase(QWidget* GuiParent, IDatabase* Database);
virtual QString identifier(){return "PwManager";}
virtual QString title(){return "PwManager File (*.pwm)";}
private:
bool KeyFlag; // true=Password, false=Chipcard
int Compression; // 0=none, 1=gzip, 2=bzip2
unsigned char KeyHash[20];
unsigned char DataHash[20];
IDatabase* database;
bool parseXmlContent(char* content);
bool xml_parseEntryAttributes(QDomElement* EntryTag,IGroupHandle* parent);
}; };
*/
#endif #endif

@ -45,7 +45,9 @@
#include "lib/FileDialogs.h" #include "lib/FileDialogs.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 "export/Export_Txt.h" #include "export/Export_Txt.h"
#include "export/Export_KeePassX_Xml.h"
#include "dialogs/AboutDlg.h" #include "dialogs/AboutDlg.h"
#include "dialogs/SearchDlg.h" #include "dialogs/SearchDlg.h"
@ -62,6 +64,11 @@
QDBusServer* dbusServer; QDBusServer* dbusServer;
QDBusConnection* dbusCon; QDBusConnection* dbusCon;
Import_KeePassX_Xml import_KeePassX_Xml;
Import_PwManager import_PwManager;
Export_Txt export_Txt;
Export_KeePassX_Xml export_KeePassX_Xml;
KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt::WFlags flags):QMainWindow(parent,flags){ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt::WFlags flags):QMainWindow(parent,flags){
Start=true; Start=true;
@ -115,9 +122,8 @@ void KeepassMainWindow::setupConnections(){
connect(FileSettingsAction, SIGNAL(triggered()), this, SLOT(OnFileSettings())); connect(FileSettingsAction, SIGNAL(triggered()), this, SLOT(OnFileSettings()));
connect(FileChangeKeyAction, SIGNAL(triggered()), this, SLOT(OnFileChangeKey())); connect(FileChangeKeyAction, SIGNAL(triggered()), this, SLOT(OnFileChangeKey()));
connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit())); connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit()));
connect(FileImpPwmAction, SIGNAL(triggered()), this, SLOT(OnImportFromPwm())); connect(menuImport,SIGNAL(triggered(QAction*)),this,SLOT(OnImport(QAction*)));
connect(FileImpKWalletXmlAction, SIGNAL(triggered()), this,SLOT(OnImportFromKWalletXml())); connect(menuExport,SIGNAL(triggered(QAction*)),this,SLOT(OnExport(QAction*)));
connect(FileExpPlainTextAction,SIGNAL(triggered()),this,SLOT(OnExportToTxt()));
connect(EditNewGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewGroup())); connect(EditNewGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewGroup()));
connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup())); connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup()));
@ -274,6 +280,23 @@ void KeepassMainWindow::setupMenus(){
SysTrayMenu->addAction(FileExitAction); SysTrayMenu->addAction(FileExitAction);
SysTray->setContextMenu(SysTrayMenu); SysTray->setContextMenu(SysTrayMenu);
#define _add_import(name){\
QAction* import=new QAction(this);\
import->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\
import->setText(name.title());\
menuImport->addAction(import);}
#define _add_export(name){\
QAction* Export=new QAction(this);\
Export->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\
Export->setText(name.title());\
menuExport->addAction(Export);}
_add_import(import_KeePassX_Xml)
_add_import(import_PwManager)
_add_export(export_Txt);
_add_export(export_KeePassX_Xml);
//FileNewMenu->setShortcut(tr("Ctrl+N")); //FileNewMenu->setShortcut(tr("Ctrl+N"));
FileOpenAction->setShortcut(tr("Ctrl+O")); FileOpenAction->setShortcut(tr("Ctrl+O"));
FileSaveAction->setShortcut(tr("Ctrl+S")); FileSaveAction->setShortcut(tr("Ctrl+S"));
@ -317,7 +340,7 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
} }
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..."));
if(db->load(filename)==true){ if(db->load(filename)==true){
@ -431,8 +454,6 @@ FileSaveAsAction->setEnabled(IsOpen);
FileCloseAction->setEnabled(IsOpen); FileCloseAction->setEnabled(IsOpen);
FileSettingsAction->setEnabled(IsOpen); FileSettingsAction->setEnabled(IsOpen);
FileChangeKeyAction->setEnabled(IsOpen); FileChangeKeyAction->setEnabled(IsOpen);
FileExpPlainTextAction->setEnabled(IsOpen);
EditSearchAction->setEnabled(IsOpen); EditSearchAction->setEnabled(IsOpen);
GroupView->setEnabled(IsOpen); GroupView->setEnabled(IsOpen);
@ -618,6 +639,7 @@ switch(EntrySelection){
else Q_ASSERT(false); else Q_ASSERT(false);
} }
bool KeepassMainWindow::OnFileSave(){ bool KeepassMainWindow::OnFileSave(){
if(!db->file()) if(!db->file())
return OnFileSaveAs(); return OnFileSaveAs();
@ -661,129 +683,31 @@ void KeepassMainWindow::OnFileExit(){
close(); close();
} }
void KeepassMainWindow::OnExportToTxt(){
IExport* exporter=new Export_Txt();
QStringList Filters;
Filters << tr("All Files (*)");
Filters << tr("Text Files (*.txt)");
exportDatabase(exporter, Filters);
delete exporter;
}
void KeepassMainWindow::exportDatabase(IExport* exporter,QStringList Filters){
QString filename=KpxFileDialogs::saveFile(this,"Export_"+exporter->name(),tr("Export Database"),Filters,true);
if(filename==QString())return;
QFile file(filename);
if(!file.open(QIODevice::WriteOnly|QIODevice::Truncate)){
QMessageBox::critical(this,tr("Export Failed"),decodeFileError(file.error()));
return;
}
QString err=exporter->exportDatabase(this,db,&file);
if(err!=QString()){
QMessageBox::critical(this,tr("Export Failed"),err);
return;
}
file.close();
if(file.error()!=QFile::NoError){
QMessageBox::critical(this,tr("Export Failed"),decodeFileError(file.error()));
return;
}
}
void KeepassMainWindow::OnImportFromPwm(){ void KeepassMainWindow::OnExport(QAction* action){
/* dynamic_cast<IExport*>(action->data().value<QObject*>())->exportDatabase(this,db);
if(FileOpen)
if(!closeDatabase())return;
QString filename=QFileDialog::getOpenFileName(this,tr("Open Database..."),QDir::homePath(),"*.pwm");
if(filename!=QString::null){
Q_ASSERT(!FileOpen);
db = new PwDatabase();
db->newDatabase();
CSimplePasswordDialog dlg(this,true);
if(!dlg.exec()){
delete db;
db=NULL;
StatusBarGeneral->setText(tr("Ready"));
}
GroupView->db=db;
EntryView->db=db;
QString err;
StatusBarGeneral->setText(tr("Loading Database..."));
Import_PwManager import;
if(import.importFile(filename,dlg.password,db,err)==true){
//SUCCESS
setWindowTitle(tr("KeePassX [new]"));
GroupView->updateItems();
EntryView->updateItems(0);
setStateFileOpen(true);
setStateFileModified(true);
}
else{
//ERROR
delete db;
StatusBarGeneral->setText(tr("Loading Failed"));
if(err=="")err=tr("Unknown error in Import_PwManager::importFile()()");
QMessageBox::critical(this,tr("Error")
,tr("The following error occured while opening the database:\n%1")
.arg(err),tr("OK"));
}
StatusBarGeneral->setText(tr("Ready"));
}
*/
} }
void KeepassMainWindow::OnImportFromKWalletXml(){ void KeepassMainWindow::OnImport(QAction* action){
/* if(FileOpen)
if(FileOpen) if(!closeDatabase())return;
if(!closeDatabase())return; IDatabase* tmpdb=dynamic_cast<IDatabase*>(new StandardDatabase());
QString filename=QFileDialog::getOpenFileName(this,tr("Open Database..."),QDir::homePath(),"*.pwm"); tmpdb->create();
if(filename!=QString::null){ if(dynamic_cast<IImport*>(action->data().value<QObject*>())->importDatabase(this,tmpdb)){
Q_ASSERT(!FileOpen); db=tmpdb;
db = new PwDatabase(); GroupView->db=db;
db->newDatabase(); EntryView->db=db;
GroupView->db=db; setupDatabaseConnections(db);
EntryView->db=db; setWindowTitle(tr("* - KeePassX"));
QString err; GroupView->createItems();
StatusBarGeneral->setText(tr("Loading Database...")); EntryView->showGroup(NULL);
Import_KWalletXml import; setStateFileOpen(true);
if(import.importFile(filename,db,err)==true){ setStateFileModified(true);
//SUCCESS
setWindowTitle(tr("KeePassX [new]"));
GroupView->updateItems();
EntryView->updateItems(0);
setStateFileOpen(true);
setStateFileModified(true);
}
else{
//ERROR
delete db;
StatusBarGeneral->setText(tr("Loading Failed"));
if(err=="")err=tr("Unknown error in Import_KWalletXml::importFile()");
QMessageBox::critical(this,tr("Error")
,tr("The following error occured while opening the database:\n%1")
.arg(err),tr("OK"));
}
StatusBarGeneral->setText(tr("Ready"));
} }
*/ else
} delete tmpdb;
/*
void KeepassMainWindow::OnEntrySelectionChanged(){
updateDetailView();
if(EntryView->selectedItems().size()==0)
setStateEntrySelected(NONE);
if(EntryView->selectedItems().size()==1)
setStateEntrySelected(SINGLE);
if(EntryView->selectedItems().size()>1)
setStateEntrySelected(MULTIPLE);
} }
*/
void KeepassMainWindow::removeFromSearchResults(int id){ void KeepassMainWindow::removeFromSearchResults(int id){
@ -958,4 +882,4 @@ void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason rea
void KeepassMainWindow::OnExtrasPasswordGen(){ void KeepassMainWindow::OnExtrasPasswordGen(){
CGenPwDialog dlg(this,true); CGenPwDialog dlg(this,true);
dlg.exec(); dlg.exec();
} }

@ -43,7 +43,7 @@
#include "PwmConfig.h" #include "PwmConfig.h"
#include "lib/EntryView.h" #include "lib/EntryView.h"
#include "lib/GroupView.h" #include "lib/GroupView.h"
#include "export/IExport.h" #include "export/Export.h"
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
@ -67,9 +67,6 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnFileSettings(); void OnFileSettings();
void OnFileChangeKey(); void OnFileChangeKey();
void OnFileExit(); void OnFileExit();
void OnImportFromPwm();
void OnImportFromKWalletXml();
void OnExportToTxt();
void OnEditOpenUrl(); void OnEditOpenUrl();
void OnSearch(); void OnSearch();
void OnGroupSearch(); void OnGroupSearch();
@ -92,6 +89,8 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnShowSearchResults(); void OnShowSearchResults();
void OnEntryChanged(SelectionState); void OnEntryChanged(SelectionState);
void OnSysTrayActivated(QSystemTrayIcon::ActivationReason); void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
void OnImport(QAction*);
void OnExport(QAction*);
private: private:
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);

@ -61,8 +61,12 @@ HEADERS += lib/IniReader.h \
lib/SecString.h \ lib/SecString.h \
crypto/twoclass.h \ crypto/twoclass.h \
crypto/twofish.h \ crypto/twofish.h \
import/Import.h \
import/Import_KeePassX_Xml.h \
import/Import_PwManager.h \ import/Import_PwManager.h \
export/Export_Txt.h \ export/Export_Txt.h \
export/Export_KeePassX_Xml.h \
export/Export.h \
import/Import_KWalletXml.h \ import/Import_KWalletXml.h \
PwmConfig.h \ PwmConfig.h \
dialogs/AboutDlg.h \ dialogs/AboutDlg.h \
@ -95,6 +99,8 @@ HEADERS += lib/IniReader.h \
crypto/aescpp.h \ crypto/aescpp.h \
crypto/sha256.h \ crypto/sha256.h \
crypto/yarrow.h \ crypto/yarrow.h \
crypto/blowfish.h \
crypto/sha1.h \
lib/WaitAnimationWidget.h \ lib/WaitAnimationWidget.h \
plugins/interfaces/IFileDialog.h \ plugins/interfaces/IFileDialog.h \
plugins/interfaces/IKdeInit.h \ plugins/interfaces/IKdeInit.h \
@ -108,8 +114,14 @@ SOURCES += lib/IniReader.cpp \
lib/SecString.cpp \ lib/SecString.cpp \
crypto/twoclass.cpp \ crypto/twoclass.cpp \
crypto/twofish.cpp \ crypto/twofish.cpp \
crypto/blowfish.cpp \
crypto/sha1.cpp \
import/Import.cpp \
import/Import_PwManager.cpp \ import/Import_PwManager.cpp \
import/Import_KeePassX_Xml.cpp \
export/Export_Txt.cpp \ export/Export_Txt.cpp \
export/Export_KeePassX_Xml.cpp \
export/Export.cpp \
import/Import_KWalletXml.cpp \ import/Import_KWalletXml.cpp \
PwmConfig.cpp \ PwmConfig.cpp \
dialogs/AboutDlg.cpp \ dialogs/AboutDlg.cpp \