QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0);
return;}
if(KeyType==BOTH){
if(password==""){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0);
return;}
if(keyfile==""){
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
return;}
}
if(KeyType==BOTH||KeyType==KEYFILE){
QFileInfofileinfo(keyfile);
if(!fileinfo.exists()){
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory does not exist."),tr("OK"),"","",0,0);
return;
}
if(!fileinfo.isReadable()){
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory is not readable\n.Please check your permissions."),tr("OK"),"","",0,0);
return;
}
if(fileinfo.isDir()){
if(keyfile.right(1)!="/")keyfile+="/";
QFilefile(keyfile+"pwsafe.key");
if(!file.exists()){
QDirdir(keyfile);
QStringListfiles;
files=dir.entryList("*.key",QDir::Files);
if(!files.size()){
QMessageBox::warning(this,tr("Error"),tr("The given directory does not contain any key files."),tr("OK"),"","",0,0);
return;}
if(files.size()>1){
QMessageBox::warning(this,tr("Error"),tr("The given directory contains more then one key file.\nPlease specify the key file directly."),tr("OK"),"","",0,0);
return;}
QFilefile(keyfile+files[0]);
Q_ASSERT(file.exists());
if(!QFileInfo(file).isReadable()){
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
return;}
keyfile+=files[0];
}else{
if(!QFileInfo(file).isReadable()){
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
return;}
keyfile+="pwsafe.key";
}
}else{
QFilefile(keyfile);
if(!file.exists()){
QMessageBox::warning(this,tr("Error"),tr("Key file could not be found."),tr("OK"),"","",0,0);
return;}
if(!QFileInfo(file).isReadable()){
QMessageBox::warning(this,tr("Error"),tr("Key file is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
intr=QMessageBox::warning(this,tr("Warning"),tr("A file with the name 'pwsafe.key' already exisits in the given directory.\nDo you want to replace it?"),tr("Yes"),tr("No"),"",1,1);
if(r)return;
if(!QFileInfo(file).isWritable()){
QMessageBox::warning(this,tr("Error"),tr("The exisiting file is not writable."),tr("OK"),"","",0,0);
return;}
}
keyfile+="pwsafe.key";
}else{
QFilefile(keyfile);
if(file.exists()){
intr=QMessageBox::warning(this,tr("Warning"),tr("A file with the this name already exisits.\nDo you want to replace it?"),tr("Yes"),tr("No"),"",1,1);
if(r)return;
if(!QFileInfo(file).isWritable()){
QMessageBox::warning(this,tr("Error"),tr("The exisiting file is not writable."),tr("OK"),"","",0,0);