summaryrefslogtreecommitdiffstats
path: root/kgpg
diff options
context:
space:
mode:
authorEmanoil Kotsev <[email protected]>2020-05-13 23:23:39 +0200
committerMichele Calgaro <[email protected]>2020-05-14 12:16:53 +0900
commitcf2173ef8592ba504787c4069d11b98540aeb23e (patch)
tree959dc94a4a9bfbbe1f4da26b78f4a8a10a29d044 /kgpg
parent794095d25fa9470ef8c8075690dbaa46590accea (diff)
downloadtdeutils-cf2173ef8592ba504787c4069d11b98540aeb23e.tar.gz
tdeutils-cf2173ef8592ba504787c4069d11b98540aeb23e.zip
fixes #22 multiple entries in kgpg public key list
Signed-off-by: Emanoil Kotsev <[email protected]> (cherry picked from commit 1df6286ec0e2e2a44ec9c398b13b3324ab5f8912)
Diffstat (limited to 'kgpg')
-rw-r--r--kgpg/popuppublic.cpp208
1 files 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<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);
+ 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<<id; // untrustedList used in sort
+ break;
+ case 'i': // invalid
+ case 'd': // disabled
+ case 'r': // revoked
+ case 'e': // expired
+ dead=true;
+ break;
+ case 'q': // undefined
+ case 'n': // none
+ case 'm': // marginal
+ untrustedList<<id;
+ break;
+ case 'f': // full
+ case 'u': // ultimate
+ break;
+ default:
+ untrustedList<<id;
+ break;
+ }
+ if (keyString[11].find('D')!=-1) { // disabled
+ 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);
+ }
+ }
+ }
+ //
+ 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<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);
- }
- }
- }
}