From 1df6286ec0e2e2a44ec9c398b13b3324ab5f8912 Mon Sep 17 00:00:00 2001 From: Emanoil Kotsev Date: Wed, 13 May 2020 23:23:39 +0200 Subject: [PATCH] fixes #22 multiple entries in kgpg public key list Signed-off-by: Emanoil Kotsev --- kgpg/popuppublic.cpp | 208 ++++++++++++++++++++----------------------- 1 file changed, 99 insertions(+), 109 deletions(-) diff --git a/kgpg/popuppublic.cpp b/kgpg/popuppublic.cpp index 07eb33e..8ee67fb 100644 --- a/kgpg/popuppublic.cpp +++ b/kgpg/popuppublic.cpp @@ -350,19 +350,104 @@ void popupPublic::refreshkeys() void popupPublic::slotpreselect() { -TQListViewItem *it=NULL; -if (!keysList->firstChild()) return; - if (fmode) it=keysList->findItem(KGpgSettings::defaultKey(),2); -if (!trusted) - sort(); -if (fmode) -{ - keysList->clearSelection(); - keysList->setSelected(it,true); - keysList->setCurrentItem(it); - keysList->ensureItemVisible(it); -} -emit keyListFilled(); + + TQString defaultKey = KGpgSettings::defaultKey().right(8); + + // process the output to update dialog infos + TQMap::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); + kdDebug(2100) << k_funcinfo << line << endl; + + 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"); + } +// unused TQString tr; + switch( trust[0] ) { + case 'o': // unknown + untrustedList<setSelectable(false); + if (seclist.find(fullname,0,FALSE)!=-1) { + item->setPixmap(0,keyPair); + } + else { + item->setPixmap(0,keySingle); + } + } + } + // + TQListViewItem *it=NULL; + if (!keysList->firstChild()) return; + if (fmode) it=keysList->findItem(KGpgSettings::defaultKey(),2); + if (!trusted) + sort(); + if (fmode) + { + keysList->clearSelection(); + keysList->setSelected(it,true); + keysList->setCurrentItem(it); + keysList->ensureItemVisible(it); + } + emit keyListFilled(); } void popupPublic::slotSetVisible() @@ -372,14 +457,11 @@ void popupPublic::slotSetVisible() void popupPublic::slotprocread(KProcIO *p) { +// collect all data (output starts with pub line followed by related) // kdDebug(2100) << k_funcinfo << endl; - ///////////////////////////////////////////////////////////////// extract encryption keys TQString tst; - TQString defaultKey = KGpgSettings::defaultKey().right(8); - 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; @@ -389,98 +471,6 @@ void popupPublic::slotprocread(KProcIO *p) hashMap.find(currentKey).data().append(tst); } } - - TQMap::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<setSelectable(false); - if (seclist.find(fullname,0,FALSE)!=-1) { - item->setPixmap(0,keyPair); - } - else { - item->setPixmap(0,keySingle); - } - } - } }