diff options
author | Emanoil Kotsev <[email protected]> | 2017-12-09 15:54:36 +0100 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2017-12-09 15:54:36 +0100 |
commit | 9125ead96055376ab2b48f8b5780524c0ee244ac (patch) | |
tree | ae094b5757d75c020f26f57cd0f27b06bce79bf1 /kgpg/popuppublic.cpp | |
parent | 96765e0aa27a58e8747b8f867713fd1cc45c19b4 (diff) | |
download | tdeutils-9125ead96055376ab2b48f8b5780524c0ee244ac.tar.gz tdeutils-9125ead96055376ab2b48f8b5780524c0ee244ac.zip |
Add support for GnuPG 2.1
This resolves Bug 2791
Sort keys by name on export
Fix the twice display of the default key server
Signed-off-by: Emanoil Kotsev <[email protected]>
Additional formatting adjustments
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'kgpg/popuppublic.cpp')
-rw-r--r-- | kgpg/popuppublic.cpp | 184 |
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 : [email protected] + + updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017 + copyright : (C) 2017 by Emanoil Kotsev + email : [email protected] ***************************************************************************/ /*************************************************************************** @@ -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()) |