/***************************************************************************
* Copyright (C) 2007 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "Export_KeePassX_Xml.h"
bool Export_KeePassX_Xml::exportDatabase(QWidget* GuiParent,IDatabase* database){
db=database;
QFile *file=openFile(GuiParent,identifier(),QStringList()<
Groups=db->sortedGroups();
for(int i=0;iparent()==NULL){
addGroup(Groups[i],root,doc);
}
}
file->write(doc.toByteArray());
file->close();
delete file;
return true;
}
void Export_KeePassX_Xml::addGroup(IGroupHandle* group,QDomElement& parent,QDomDocument& doc){
QDomElement GroupElement=doc.createElement("group");
parent.appendChild(GroupElement);
QDomElement Title=doc.createElement("title");
QDomElement Icon=doc.createElement("icon");
Title.appendChild(doc.createTextNode(group->title()));
Icon.appendChild(doc.createTextNode(QString::number(group->image())));
GroupElement.appendChild(Title);
GroupElement.appendChild(Icon);
QList children=group->children();
for(int i=0;i entries=db->entriesSortedStd(group);
for(int i=0;ititle()));
Username.appendChild(doc.createTextNode(entry->username()));
SecString password=entry->password();
password.unlock();
Password.appendChild(doc.createTextNode(password.string()));
password.lock();
Url.appendChild(doc.createTextNode(entry->url()));
QStringList CommentLines=entry->comment().split('\n');
for(int i=0;ibinary().isNull();
if(HasAttachment){
BinaryDesc.appendChild(doc.createTextNode(entry->binaryDesc()));
Binary.appendChild(doc.createTextNode(entry->binary().toBase64()));
}
Icon.appendChild(doc.createTextNode(QString::number(entry->image())));
Creation.appendChild(doc.createTextNode(entry->creation().toString(Qt::ISODate)));
LastAccess.appendChild(doc.createTextNode(entry->lastAccess().toString(Qt::ISODate)));
LastMod.appendChild(doc.createTextNode(entry->lastMod().toString(Qt::ISODate)));
Expire.appendChild(doc.createTextNode(entry->expire().toString(Qt::ISODate)));
GroupElement.appendChild(Title);
GroupElement.appendChild(Username);
GroupElement.appendChild(Password);
GroupElement.appendChild(Url);
GroupElement.appendChild(Comment);
if(HasAttachment){
GroupElement.appendChild(BinaryDesc);
GroupElement.appendChild(Binary);
}
GroupElement.appendChild(Icon);
GroupElement.appendChild(Creation);
GroupElement.appendChild(LastAccess);
GroupElement.appendChild(LastMod);
GroupElement.appendChild(Expire);
}