summaryrefslogtreecommitdiffstats
path: root/kgpg/popuppublic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kgpg/popuppublic.cpp')
-rw-r--r--kgpg/popuppublic.cpp184
1 files changed, 113 insertions, 71 deletions
diff --git a/kgpg/popuppublic.cpp b/kgpg/popuppublic.cpp
index 7ae2eb3..07eb33e 100644
--- a/kgpg/popuppublic.cpp
+++ b/kgpg/popuppublic.cpp
@@ -4,6 +4,10 @@
begin : Sat Jun 29 2002
copyright : (C) 2002 by Jean-Baptiste Mardelle
email : bj@altern.org
+
+ updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
+ copyright : (C) 2017 by Emanoil Kotsev
+ email : deloptes@yahoo.com
***************************************************************************/
/***************************************************************************
@@ -322,6 +326,8 @@ void popupPublic::refresh(bool state)
void popupPublic::refreshkeys()
{
keysList->clear();
+ currentKey = TQString();
+ hashMap.clear();
TQStringList groups= TQStringList::split(",", KGpgSettings::groups());
if (!groups.isEmpty())
{
@@ -366,80 +372,115 @@ void popupPublic::slotSetVisible()
void popupPublic::slotprocread(KProcIO *p)
{
+// kdDebug(2100) << k_funcinfo << endl;
///////////////////////////////////////////////////////////////// extract encryption keys
- bool dead;
- TQString tst,keyname,keymail;
+ TQString tst;
TQString defaultKey = KGpgSettings::defaultKey().right(8);
- while (p->readln(tst)!=-1) {
- if (tst.startsWith("pub")) {
- TQStringList keyString=TQStringList::split(":",tst,true);
- dead=false;
- const TQString trust=keyString[1];
- TQString val=keyString[6];
- TQString id=TQString("0x"+keyString[4].right(8));
- if (val.isEmpty())
- val=i18n("Unlimited");
- TQString tr;
- switch( trust[0] ) {
- case 'o':
- untrustedList<<id;
- break;
- case 'i':
- dead=true;
- break;
- case 'd':
- dead=true;
- break;
- case 'r':
- dead=true;
- break;
- case 'e':
- dead=true;
- break;
- case 'q':
- untrustedList<<id;
- break;
- case 'n':
- untrustedList<<id;
- break;
- case 'm':
- untrustedList<<id;
- break;
- case 'f':
- break;
- case 'u':
- break;
- default:
- untrustedList<<id;
- break;
- }
- if (keyString[11].find('D')!=-1) dead=true;
- tst=keyString[9];
- if (tst.find("<")!=-1) {
- keymail=tst.section('<',-1,-1);
- keymail.truncate(keymail.length()-1);
- keyname=tst.section('<',0,0);
- //if (keyname.find("(")!=-1)
- // keyname=keyname.section('(',0,0);
- } else {
- keymail=TQString();
- keyname=tst;//.section('(',0,0);
- }
- if ((!dead) && (!tst.isEmpty())) {
- bool isDefaultKey=false;
- if (id.right(8)==defaultKey) isDefaultKey=true;
- UpdateViewItem2 *item=new UpdateViewItem2(keysList,keyname,keymail,id,isDefaultKey);
- //TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, validity: %3").arg(id).arg(tr).arg(val));
- //sub->setSelectable(false);
- if (seclist.find(tst,0,FALSE)!=-1)
- item->setPixmap(0,keyPair);
- else
- item->setPixmap(0,keySingle);
- }
- }
- }
+ while (p->readln(tst)!=-1) {
+// kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
+ if ( tst.startsWith("pub") ) {
+ currentKey = tst.section(':',4,4);
+ TQStringList lst; lst << tst;
+ hashMap.insert(currentKey,tst);
+ }
+ else {
+ hashMap.find(currentKey).data().append(tst);
+ }
+ }
+
+ TQMap<TQString,TQStringList>::Iterator ite;
+ for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
+ TQStringList::Iterator it;
+ TQString fullname,keyname,keymail,val,id;
+ bool dead;
+
+ for (it = ite.data().begin(); it != ite.data().end(); it++) {
+ TQString line = (*it);
+
+ if (line.startsWith("pub")) {
+ TQStringList keyString=TQStringList::split(":",line,true);
+ dead=false;
+ const TQString trust=keyString[1];
+ val=keyString[6];
+ id=TQString("0x"+keyString[4].right(8));
+ if (val.isEmpty()) {
+ val=i18n("Unlimited");
+ }
+ TQString tr;
+ switch( trust[0] ) {
+ case 'o':
+ untrustedList<<id;
+ break;
+ case 'i':
+ dead=true;
+ break;
+ case 'd':
+ dead=true;
+ break;
+ case 'r':
+ dead=true;
+ break;
+ case 'e':
+ dead=true;
+ break;
+ case 'q':
+ untrustedList<<id;
+ break;
+ case 'n':
+ untrustedList<<id;
+ break;
+ case 'm':
+ untrustedList<<id;
+ break;
+ case 'f':
+ break;
+ case 'u':
+ break;
+ default:
+ untrustedList<<id;
+ break;
+ }
+ if (keyString[11].find('D')!=-1) {
+ dead=true;
+ }
+ fullname=keyString[9];
+ }
+
+ if ( line.startsWith("uid") && fullname.isEmpty() ) {
+ fullname = line.section(':',9,9);
+ }
+ }
+
+ if (fullname.find("<")!=-1) {
+ keymail=fullname.section('<',-1,-1);
+ keymail.truncate(keymail.length()-1);
+ keyname=fullname.section('<',0,0);
+ //if (keyname.find("(")!=-1) {
+ // keyname=keyname.section('(',0,0);
+ //}
+ }
+ else {
+ keymail=TQString();
+ keyname=fullname;//.section('(',0,0);
+ }
+ if ((!dead) && (!fullname.isEmpty())) {
+ bool isDefaultKey=false;
+ if (id.right(8)==defaultKey) {
+ isDefaultKey=true;
+ }
+ UpdateViewItem2 *item=new UpdateViewItem2(keysList,keyname,keymail,id,isDefaultKey);
+ //TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, validity: %3").arg(id).arg(tr).arg(val));
+ //sub->setSelectable(false);
+ if (seclist.find(fullname,0,FALSE)!=-1) {
+ item->setPixmap(0,keyPair);
+ }
+ else {
+ item->setPixmap(0,keySingle);
+ }
+ }
+ }
}
@@ -459,8 +500,9 @@ kdDebug(2100)<<"Ok pressed"<<endl;
if (selectedKeys.isEmpty() && !CBsymmetric->isChecked())
return;
if (CBsymmetric->isChecked()) selectedKeys=NULL;
-kdDebug(2100)<<"Selected Key:"<<selectedKeys<<endl;
+// kdDebug(2100)<<"Selected Key:"<<selectedKeys<<endl;
TQStringList returnOptions;
+
if (CBuntrusted->isChecked())
returnOptions<<"--always-trust";
if (CBarmor->isChecked())