merged sniperbeamer's patches
fixed bug #1828965 git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@149 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -34,6 +34,8 @@ class IImport{
|
||||
};
|
||||
|
||||
class ImporterBase:public QObject{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
virtual QFile* openFile(QWidget* GuiParent,QString id,QStringList Filter);
|
||||
virtual QString getPassword(QWidget* GuiParent);
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "Database.h"
|
||||
|
||||
class Import_GnuKeyRing:public QObject,public IImport{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual QString importDatabase(QWidget* GuiParent, IDatabase* Database);
|
||||
virtual QString name(){return "GnuKeyRing";}
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
#include "Database.h"
|
||||
#include "Import.h"
|
||||
|
||||
class Import_KWalletXml:public IImport, public ImporterBase{
|
||||
class Import_KWalletXml:public ImporterBase, public IImport{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual bool importDatabase(QWidget* GuiParent, IDatabase* Database);
|
||||
virtual QString identifier(){return "KWalletXml";}
|
||||
|
||||
@@ -47,7 +47,7 @@ bool Import_KeePassX_Xml::importDatabase(QWidget* Parent, IDatabase* database){
|
||||
QStringList GroupNames;
|
||||
for(int i=0;i<TopLevelGroupNodes.count();i++){
|
||||
if(TopLevelGroupNodes.at(i).toElement().tagName()!="group"){
|
||||
qWarning("Import_KeePassX_Xml: Error: Unknow tag '%s'",TopLevelGroupNodes.at(i).toElement().tagName());
|
||||
qWarning("Import_KeePassX_Xml: Error: Unknow tag '%s'",TopLevelGroupNodes.at(i).toElement().tagName().toUtf8().constData());
|
||||
QMessageBox::critical(GuiParent,tr("Import Failed"),tr("Parsing error: File is no valid KeePassX XML file."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include "Import.h"
|
||||
|
||||
|
||||
class Import_KeePassX_Xml:public IImport, public ImporterBase{
|
||||
class Import_KeePassX_Xml:public ImporterBase, public IImport{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual bool importDatabase(QWidget* GuiParent, IDatabase* Database);
|
||||
virtual QString identifier(){return "KeePassX_Xml";}
|
||||
|
||||
@@ -32,12 +32,18 @@ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
|
||||
QFile* file=openFile(GuiParent,identifier(),QStringList()<<tr("PwManager Files (*.pwm)")<<tr("All Files (*)"));
|
||||
if(!file)return false;
|
||||
QString password=getPassword(GuiParent);
|
||||
if(password==QString()){delete file; return false;}
|
||||
if(password.isEmpty()){delete file; return false;}
|
||||
char* buffer=NULL;
|
||||
int offset=0;
|
||||
int len=0;
|
||||
if(len=file->size()) buffer=new char[len];
|
||||
else {QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is empty.")); delete file; return false;}
|
||||
if(len=file->size()){
|
||||
buffer=new char[len];
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is empty."));
|
||||
delete file;
|
||||
return false;
|
||||
}
|
||||
file->read(buffer,len);
|
||||
file->close();
|
||||
delete file;
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#include "Import.h"
|
||||
|
||||
|
||||
class Import_PwManager:public IImport, public ImporterBase{
|
||||
class Import_PwManager:public ImporterBase, public IImport{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual bool importDatabase(QWidget* GuiParent, IDatabase* Database);
|
||||
virtual QString identifier(){return "PwManager";}
|
||||
|
||||
Reference in New Issue
Block a user