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. 332
      src/forms/EditEntryDlg.ui
  7. 84
      src/forms/MainWindow.ui
  8. 120
      src/forms/SimplePasswordDlg.ui
  9. 12
      src/import/Import_KWalletXml.cpp
  10. 190
      src/import/Import_PwManager.cpp
  11. 23
      src/import/Import_PwManager.h
  12. 158
      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,21 +54,37 @@
<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" > <property name="sizePolicy" >
<string>Quality:</string> <sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>23</height>
</size>
</property> </property>
</widget>
</item>
<item row="9" column="0" >
<widget class="QLabel" name="textLabel12" >
<property name="text" > <property name="text" >
<string>Attachment:</string> <string>Ge&amp;n.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="5" > <item row="1" column="0" >
<widget class="QLineEdit" name="Edit_Password_w" />
</item>
<item row="0" column="1" >
<widget class="QToolButton" name="ButtonEchoMode" > <widget class="QToolButton" name="ButtonEchoMode" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
@ -113,136 +111,178 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="0" column="0" >
<widget class="QLineEdit" name="Edit_Password" />
</item>
</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" > <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" > <property name="text" >
<string>Title:</string> <string>Title:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="3" column="0" >
<widget class="QLabel" name="textLabel5" > <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" > <property name="text" >
<string>Username:</string> <string>Username:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" > <item row="8" column="0" >
<widget class="QLabel" name="textLabel10" > <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" > <property name="text" >
<string>Comment:</string> <string>Comment:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1" > <item row="11" column="1" >
<widget class="QDateTimeEdit" name="DateTime_Expire" />
</item>
<item row="10" column="1" >
<widget class="QLabel" name="Label_AttachmentSize" > <widget class="QLabel" name="Label_AttachmentSize" >
<property name="text" > <property name="text" >
<string>%1</string> <string>%1</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="4" > <item row="4" column="0" >
<widget class="QLineEdit" name="Edit_Password" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel7" > <widget class="QLabel" name="textLabel7" >
<property name="text" >
<string>URL:</string>
</property>
</widget>
</item>
<item row="5" column="5" >
<widget class="QToolButton" name="ButtonGenPw" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>1</hsizetype> <hsizetype>4</hsizetype>
<vsizetype>0</vsizetype> <vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>23</height>
</size>
</property>
<property name="text" > <property name="text" >
<string>Ge&amp;n.</string> <string>URL:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" colspan="4" > <item row="1" column="0" >
<widget class="QLineEdit" name="Edit_Password_w" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel3" > <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" > <property name="text" >
<string>Group:</string> <string>Group:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="5" > <item row="2" column="1" >
<widget class="QLineEdit" name="Edit_Title" /> <widget class="QLineEdit" name="Edit_Title" />
</item> </item>
<item row="9" column="1" colspan="3" > <item row="3" column="1" >
<widget class="QLineEdit" name="Edit_Attachment" > <widget class="QLineEdit" name="Edit_UserName" />
<property name="enabled" > </item>
<bool>false</bool> <item row="6" column="0" >
</property> <widget class="QLabel" name="textLabel8" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>1</hsizetype> <hsizetype>4</hsizetype>
<vsizetype>0</vsizetype> <vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
</widget>
</item>
<item row="2" column="1" colspan="5" >
<widget class="QLineEdit" name="Edit_UserName" />
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabel8" >
<property name="text" > <property name="text" >
<string>Password Repet.:</string> <string>Password Repet.:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="2" > <item row="5" column="0" >
<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" > <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" > <property name="text" >
<string>Password:</string> <string>Password:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" > <item row="9" column="0" >
<widget class="QLabel" name="textLabel11" > <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" > <property name="text" >
<string>Expires:</string> <string>Expires:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="5" > <item row="8" column="1" >
<widget class="QTextEdit" name="Edit_Comment" /> <widget class="QTextEdit" name="Edit_Comment" />
</item> </item>
<item row="11" column="0" colspan="6" > <item row="12" column="0" colspan="2" >
<widget class="Line" name="line1" > <widget class="Line" name="line1" >
<property name="frameShape" > <property name="frameShape" >
<enum>QFrame::HLine</enum> <enum>QFrame::HLine</enum>
@ -255,7 +295,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="4" colspan="2" > <item row="10" column="1" >
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" > <property name="margin" >
<number>0</number> <number>0</number>
@ -263,6 +303,21 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item>
<widget class="QLineEdit" name="Edit_Attachment" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="ButtonOpenAttachment" > <widget class="QToolButton" name="ButtonOpenAttachment" >
<property name="text" > <property name="text" >
@ -295,21 +350,35 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="2" colspan="4" > <item row="9" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QDateTimeEdit" name="DateTime_Expire" />
</item>
<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" >
<property name="text" >
<string>%1 Bit</string>
</property>
</widget>
</item> </item>
<item row="6" column="1" colspan="4" > <item row="7" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<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,76 +25,67 @@
</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>
<property name="text" > <property name="spacing" >
<string>Password:</string> <number>6</number>
</property> </property>
</widget> <item>
<widget class="QPushButton" name="ButtonOK" > <layout class="QHBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>0</number>
<x>170</x>
<y>60</y>
<width>80</width>
<height>23</height>
</rect>
</property> </property>
<property name="text" > <property name="spacing" >
<string>O&amp;K</string> <number>6</number>
</property> </property>
<property name="shortcut" > <item>
<string>Alt+K</string> <widget class="QLabel" name="textLabel1" >
</property> <property name="sizePolicy" >
</widget> <sizepolicy>
<widget class="QPushButton" name="ButtonCancel" > <hsizetype>4</hsizetype>
<property name="geometry" > <vsizetype>5</vsizetype>
<rect> <horstretch>0</horstretch>
<x>257</x> <verstretch>0</verstretch>
<y>60</y> </sizepolicy>
<width>80</width>
<height>23</height>
</rect>
</property> </property>
<property name="text" > <property name="text" >
<string>&amp;Cancel</string> <string>Password:</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> </property>
</widget> </widget>
</item>
<item>
<widget class="QLineEdit" name="EditPassword" />
</item>
<item>
<widget class="QPushButton" name="Button_HidePassword" > <widget class="QPushButton" name="Button_HidePassword" >
<property name="geometry" > <property name="sizePolicy" >
<rect> <sizepolicy>
<x>320</x> <hsizetype>5</hsizetype>
<y>20</y> <vsizetype>0</vsizetype>
<width>20</width> <horstretch>0</horstretch>
<height>21</height> <verstretch>0</verstretch>
</rect> </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>
<property name="text" > <property name="text" >
<string>...</string> <string>...</string>
@ -109,6 +97,20 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </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,66 +18,67 @@
* 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++;
if(buffer[offset]==0x00)Compression=0;
if(buffer[offset]==0x01)Compression=1;
if(buffer[offset]==0x02)Compression=2;
///@TODO Compression ///@TODO Compression
if(buffer[offset]) if(buffer[offset])
{err+=QObject::tr("Compressed files are not supported yet."); return false;} {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Compressed files are not supported yet.")); return false;}
offset++; offset++;
if(buffer[offset]==0x00)KeyFlag=true; if(buffer[offset]==0x00)KeyFlag=true;
else KeyFlag=false; else KeyFlag=false;
offset++; offset++;
//Reserved Bytes (64) //Reserved Bytes (64)
offset+=64; offset+=64;
memcpy(KeyHash,buffer+offset,20); memcpy(KeyHash,buffer+offset,20);
offset+=20; offset+=20;
memcpy(DataHash,buffer+offset,20); memcpy(DataHash,buffer+offset,20);
offset+=20; offset+=20;
Blowfish blowfish; Blowfish blowfish;
int pwlen=password.length(); int pwlen=password.length();
byte* Key=new byte[pwlen]; byte* Key=new byte[pwlen];
byte* xml=new byte[len-offset+1]; byte* xml=new byte[len-offset+1];
xml[len-offset]=0; xml[len-offset]=0;
memcpy(Key,password.toAscii(),pwlen); memcpy(Key,password.toAscii(),pwlen);
char* key_hash=new char[20]; char* key_hash=new char[20];
CSHA1 sha; CSHA1 sha;
sha.Update(Key,pwlen); sha.Update(Key,pwlen);
@ -85,14 +86,14 @@ memcpy(Key,password.toAscii(),pwlen);
sha.GetHash((unsigned char*)key_hash); sha.GetHash((unsigned char*)key_hash);
if(memcmp(key_hash,KeyHash,20)){ if(memcmp(key_hash,KeyHash,20)){
delete[] Key; delete [] key_hash; delete [] buffer; delete[] Key; delete [] key_hash; delete [] buffer;
err+=QObject::tr("Wrong password."); QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Wrong password."));
return false; return false;
} }
delete [] key_hash; delete [] key_hash;
blowfish.bf_setkey(Key,password.length()); blowfish.bf_setkey(Key,password.length());
blowfish.bf_decrypt(xml,(byte*)buffer+offset,len-offset); blowfish.bf_decrypt(xml,(byte*)buffer+offset,len-offset);
delete [] Key; delete [] Key;
delete [] buffer; delete [] buffer;
char* content_hash=new char[20]; char* content_hash=new char[20];
sha.Reset(); sha.Reset();
sha.Update(xml,strlen((char*)xml)-1); sha.Update(xml,strlen((char*)xml)-1);
@ -100,42 +101,42 @@ delete [] buffer;
sha.GetHash((unsigned char*)content_hash); sha.GetHash((unsigned char*)content_hash);
if(memcmp(content_hash,DataHash,20)){ if(memcmp(content_hash,DataHash,20)){
delete [] content_hash; delete [] xml; delete [] content_hash; delete [] xml;
err+=QObject::tr("File is damaged (hash test failed)."); QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is damaged (hash test failed)."));
return false; return false;
} }
delete[] content_hash; delete[] content_hash;
if(!parseXmlContent((char*)xml)){ if(!parseXmlContent((char*)xml)){
delete [] xml; delete [] xml;
err+=QObject::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;}
database->CalcMasterKeyByPassword(password); dynamic_cast<IFilePasswordAuth*>(database)->authByPwd(password);
return true; 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){ while(1){
QDomElement CurrGroup; QDomElement CurrGroup;
if(!groups.elementsByTagName("c"+QString::number(i)).length())break; 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)).length()>1)return false;
if(!groups.elementsByTagName("c"+QString::number(i)).item(0).isElement())return false; if(!groups.elementsByTagName("c"+QString::number(i)).item(0).isElement())return false;
CurrGroup=groups.elementsByTagName("c"+QString::number(i)).item(0).toElement(); CurrGroup=groups.elementsByTagName("c"+QString::number(i)).item(0).toElement();
if(!CurrGroup.hasAttribute("n"))return false; if(!CurrGroup.hasAttribute("n"))return false;
IGroupHandle* NewGroup=database->addGroup(NULL); IGroupHandle* NewGroup=database->addGroup(&CGroup(),NULL);
NewGroup->Name=CurrGroup.attribute("n"); NewGroup->setTitle(CurrGroup.attribute("n"));
int j=0; int j=0;
while(1){ while(1){
QDomElement CurrEntry; QDomElement CurrEntry;
@ -147,21 +148,22 @@ while(1){
j++; j++;
} }
i++; i++;
} }
return true; return true;
} }
bool Import_PwManager::xml_parseEntryAttributes(QDomElement* EntryElement,IGroupHandle* NewGroup){/* bool Import_PwManager::xml_parseEntryAttributes(QDomElement* EntryElement,IGroupHandle* NewGroup){
IEntryHandle* e=database->addEntry(); IEntryHandle* e=database->newEntry(NewGroup);
e->Title=EntryElement->elementsByTagName("d").item(0).toElement().text(); e->setTitle(EntryElement->elementsByTagName("d").item(0).toElement().text());
e->UserName=EntryElement->elementsByTagName("n").item(0).toElement().text(); e->setUsername(EntryElement->elementsByTagName("n").item(0).toElement().text());
QString pw=EntryElement->elementsByTagName("p").item(0).toElement().text(); QString pw(EntryElement->elementsByTagName("p").item(0).toElement().text());
e->Password.setString(pw,true); SecString spw;
e->Additional=EntryElement->elementsByTagName("c").item(0).toElement().text(); spw.setString(pw,true);
e->Additional=e->Additional.replace("$>--endl--<$","\n"); e->setPassword(spw);
e->URL=EntryElement->elementsByTagName("u").item(0).toElement().text(); QString comment=EntryElement->elementsByTagName("c").item(0).toElement().text();
e->GroupID=NewGroup->ID; comment.replace("$>--endl--<$","\n");
return true; e->setComment(comment);
e->setUrl(EntryElement->elementsByTagName("u").item(0).toElement().text());
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{ class Import_PwManager:public IImport, public ImporterBase{
public: public:
bool importFile(QString FileName, QString Password,StandardDatabase* db,QString& err); virtual bool importDatabase(QWidget* GuiParent, IDatabase* Database);
private: virtual QString identifier(){return "PwManager";}
virtual QString title(){return "PwManager File (*.pwm)";}
private:
bool KeyFlag; // true=Password, false=Chipcard bool KeyFlag; // true=Password, false=Chipcard
int Compression; // 0=none, 1=gzip, 2=bzip2 int Compression; // 0=none, 1=gzip, 2=bzip2
unsigned char KeyHash[20]; unsigned char KeyHash[20];
unsigned char DataHash[20]; unsigned char DataHash[20];
StandardDatabase* database; IDatabase* database;
bool parseXmlContent(char* content); bool parseXmlContent(char* content);
bool xml_parseEntryAttributes(QDomElement* EntryTag,IGroupHandle* parent); 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"));
@ -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::OnExport(QAction* action){
dynamic_cast<IExport*>(action->data().value<QObject*>())->exportDatabase(this,db);
} }
void KeepassMainWindow::OnImportFromPwm(){ void KeepassMainWindow::OnImport(QAction* action){
/* if(FileOpen)
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(){
/*
if(FileOpen)
if(!closeDatabase())return; if(!closeDatabase())return;
QString filename=QFileDialog::getOpenFileName(this,tr("Open Database..."),QDir::homePath(),"*.pwm"); IDatabase* tmpdb=dynamic_cast<IDatabase*>(new StandardDatabase());
if(filename!=QString::null){ tmpdb->create();
Q_ASSERT(!FileOpen); if(dynamic_cast<IImport*>(action->data().value<QObject*>())->importDatabase(this,tmpdb)){
db = new PwDatabase(); db=tmpdb;
db->newDatabase();
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
QString err; setupDatabaseConnections(db);
StatusBarGeneral->setText(tr("Loading Database...")); setWindowTitle(tr("* - KeePassX"));
Import_KWalletXml import; GroupView->createItems();
if(import.importFile(filename,db,err)==true){ EntryView->showGroup(NULL);
//SUCCESS
setWindowTitle(tr("KeePassX [new]"));
GroupView->updateItems();
EntryView->updateItems(0);
setStateFileOpen(true); setStateFileOpen(true);
setStateFileModified(true); setStateFileModified(true);
} }
else{ else
//ERROR delete tmpdb;
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"));
}
*/
}
/*
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){

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