changed data type of group and entry list from vector (STL) to QList (Qt)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@19 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
tariq
2006-01-22 20:34:15 +00:00
parent 16060b08e4
commit 3c4ac74af1
8 changed files with 111 additions and 82 deletions

View File

@@ -127,29 +127,29 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
void KeepassGroupView::updateItems(){
clear();
Items.clear();
for(GroupItr i=db->Groups.begin();i!=db->Groups.end();i++){
if((*i).Level==0){
for(int i=0; i<db->Groups.size();i++){
if(db->Groups[i].Level==0){
if(Items.size()) Items.push_back(new GroupViewItem(this,getLastSameLevelItem(0)));
else Items.push_back(new GroupViewItem(this));
Items.back()->setText(0,(*i).Name);
Items.back()->pGroup=&(*i);
Items.back()->setText(0,db->Groups[i].Name);
Items.back()->pGroup=&db->Groups[i];
}
else{
if((*i).Level>(*(i-1)).Level){
Items.push_back(new GroupViewItem(Items.back(),getLastSameLevelItem((*i).Level)));
Items.back()->setText(0,(*i).Name);
Items.back()->pGroup=&(*i);
if(db->Groups[i].Level>db->Groups[i-1].Level){
Items.push_back(new GroupViewItem(Items.back(),getLastSameLevelItem(db->Groups[i].Level)));
Items.back()->setText(0,db->Groups[i].Name);
Items.back()->pGroup=&db->Groups[i];
}
if((*i).Level<=(*(i-1)).Level){
if(db->Groups[i].Level<=db->Groups[i-1].Level){
GroupItemItr j;
for(j=Items.end()-1;j!=Items.begin();j--){
if((*j)->pGroup->Level<(*i).Level)break;}
Items.push_back(new GroupViewItem((*j),getLastSameLevelItem((*i).Level)));
Items.back()->setText(0,(*i).Name);
Items.back()->pGroup=&(*i);
if((*j)->pGroup->Level<db->Groups[i].Level)break;}
Items.push_back(new GroupViewItem((*j),getLastSameLevelItem(db->Groups[i].Level)));
Items.back()->setText(0,db->Groups[i].Name);
Items.back()->pGroup=&db->Groups[i];
}
}
Items.back()->setIcon(0,EntryIcons[(*i).ImageID]);
Items.back()->setIcon(0,EntryIcons[db->Groups[i].ImageID]);
}
for(int i=0;i<Items.size();i++){

View File

@@ -26,25 +26,22 @@ using namespace std;
Q_UINT8 SecString::Key[32]={0};
SecString::SecString(){
data=NULL;
len=0;
cryptlen=0;
}
SecString::~SecString(){
//if(data)delete [] data; ///@FIXME zerschießt den Stack, aber warum???
overwrite(plaintext);
}
void SecString::getString(QString & str){
if(data){
if(data.size()){
Rijndael aes;
int r=aes.init(Rijndael::CBC, Rijndael::Decrypt,Key,Rijndael::Key32Bytes);
if(r){ cout << "AES error, code " << r << endl;
exit(-1);}
char* out=new char[len];
r=aes.padDecrypt((unsigned char*)data,cryptlen,(unsigned char*)out);
r=aes.padDecrypt((unsigned char*)data.data(),data.size(),(unsigned char*)out);
if(r!=len){ cout << "AES error in SecString::getString(), r!=length, r=" << r << endl;
exit(-1);}
str=QString::fromUtf8(out,len);
@@ -74,10 +71,8 @@ memcpy(input,str.utf8(),il);
r=aes.padEncrypt((unsigned char*)input,il,(unsigned char*)output);
if(r<0){ cout << "AES error, code " << r << endl;
exit(-1);}
cryptlen=r;
len=il;
if(data)delete [] data;
data=output;
data=QByteArray(output,r);
overwrite(input,il);
delete [] input;
if(DelSrc)overwrite(str);
@@ -103,3 +98,4 @@ return len;
void SecString::generateSessionKey(){
getRandomBytes(Key,32,1,false);
}

View File

@@ -20,6 +20,7 @@
#ifndef _SECSTRING_H_
#define _SECSTRING_H_
#include <QByteArray>
#include <qstring.h>
#include <qglobal.h>
#include "crypto/rijndael.h"
@@ -42,9 +43,8 @@ public:
private:
static Q_UINT8 Key[32];
QString plaintext;
char* data;
QByteArray data;
int len;
int cryptlen;
};