By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 2791
Collapse All | Expand All

(-)tdeutils.orig/kgpg/keyinfowidget.cpp (-85 / +150 lines)
Lines 4-9 Link Here
4
    begin                : Mon Nov 18 2002
4
    begin                : Mon Nov 18 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 90-125 Link Here
90
94
91
void KgpgKeyInfo::slotDisableKey(bool isOn)
95
void KgpgKeyInfo::slotDisableKey(bool isOn)
92
{
96
{
93
TDEProcess kp;
97
//	kdDebug(2100) << k_funcinfo << endl;
98
	TDEProcess kp;
94
99
95
	kp<<"gpg"
100
	kp<<"gpg" <<"--no-tty" <<"--edit-key" <<displayedKeyID;
96
        <<"--no-tty"
101
	if (isOn) kp<<"disable";
97
	<<"--edit-key"
102
	else kp<<"enable";
98
        <<displayedKeyID;
99
if (isOn) kp<<"disable";
100
else kp<<"enable";
101
	kp<<"save";
103
	kp<<"save";
102
        kp.start(TDEProcess::Block);
104
        kp.start(TDEProcess::Block);
103
loadKey(displayedKeyID);
105
	loadKey(displayedKeyID);
104
keyWasChanged=true;
106
	keyWasChanged=true;
105
}
107
}
106
108
107
void KgpgKeyInfo::loadKey(TQString Keyid)
109
void KgpgKeyInfo::loadKey(TQString Keyid)
108
{
110
{
109
TQColor trustColor;
111
//	kdDebug(2100) << k_funcinfo << endl;
110
TQString fingervalue=TQString();
112
	FILE *pass;
111
FILE *pass;
113
	char line[200]="";
112
char line[200]="";
114
	TQString currentKey;
113
TQString gpgOutput,fullID;
115
	TQMap<TQString,TQStringList> hashMap;
114
116
115
TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --with-fingerprint --list-key "+KShellProcess::quote(Keyid);
117
	TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --with-fingerprint --list-key "+KShellProcess::quote(Keyid);
116
118
117
        pass=popen(TQFile::encodeName(gpgcmd),"r");
119
        pass=popen(TQFile::encodeName(gpgcmd),"r");
118
        while ( fgets( line, sizeof(line), pass)) {
120
	while ( fgets( line, sizeof(line), pass) ) {
119
                gpgOutput=TQString::fromUtf8(line);
121
		TQString tst=TQString::fromUtf8(line);
122
                if ( tst.startsWith("pub")  ) {
123
                	currentKey = tst.section(':',4,4);
124
                	TQStringList lst; lst << tst;
125
			hashMap.insert(currentKey,lst);
126
                }
127
		else
128
			hashMap.find(currentKey).data().append(tst);
129
130
	}
131
	pclose(pass);
132
133
	TQMap<TQString,TQStringList>::Iterator ite;
134
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
135
		TQStringList::Iterator it;
136
		TQString fullname,gpgOutput;
137
		TQColor trustColor;
138
		TQString fingervalue=TQString();
139
140
		for (it = ite.data().begin(); it != ite.data().end(); it++) {	
141
			TQString gpgOutput =  (*it);
142
120
                if (gpgOutput.startsWith("uat"))
143
                if (gpgOutput.startsWith("uat"))
121
                        hasPhoto=true;
144
                        hasPhoto=true;
122
                if (gpgOutput.startsWith("pub")) {
145
			if ( gpgOutput.startsWith("pub") ) {
123
                        TQString algo=gpgOutput.section(':',3,3);
146
                        TQString algo=gpgOutput.section(':',3,3);
124
                        switch( algo.toInt() ) {
147
                        switch( algo.toInt() ) {
125
                        case  1:
148
                        case  1:
Lines 198-216 Link Here
198
                        prop->kLTrust->setText(tr);
221
                        prop->kLTrust->setText(tr);
199
                        prop->pixmapTrust->setPaletteBackgroundColor(trustColor);
222
                        prop->pixmapTrust->setPaletteBackgroundColor(trustColor);
200
223
201
			fullID=gpgOutput.section(':',4,4);
224
				TQString fullID=gpgOutput.section(':',4,4);
202
                        displayedKeyID=fullID.right(8);
225
                        displayedKeyID=fullID.right(8);
203
                        prop->tLID->setText(fullID);
226
                        prop->tLID->setText(fullID);
204
227
205
                        TQString fullname=gpgOutput.section(':',9,9);
228
				fullname=gpgOutput.section(':',9,9);
206
229
207
                        TQDate date = TQDate::fromString(gpgOutput.section(':',5,5), Qt::ISODate);
208
                        prop->tLCreation->setText(TDEGlobal::locale()->formatDate(date));
209
230
231
				TQDate date;
232
				if (KgpgInterface::getGpgVersion() >= 210 ) {
233
					TQDateTime timestamp;
234
					timestamp.setTime_t(gpgOutput.section(':',5,5).toInt());
235
					date = timestamp.date();
236
				}
237
				else {
238
					date = TQDate::fromString(gpgOutput.section(':',5,5), Qt::ISODate);
239
				}
240
				Q_ASSERT ( date.isValid())/*  tqWarning("create date is not valid")*/;
241
	
242
				prop->tLCreation->setText(TDEGlobal::locale()->formatDate(date));
210
			if (gpgOutput.section(':',6,6).isEmpty()) expirationDate=i18n("Unlimited");
243
			if (gpgOutput.section(':',6,6).isEmpty()) expirationDate=i18n("Unlimited");
211
			else
244
			else
212
			{
245
			{
246
					if (KgpgInterface::getGpgVersion() >= 210 ) {
247
						TQDateTime timestamp;
248
						timestamp.setTime_t(gpgOutput.section(':',6,6).toInt());
249
						date = timestamp.date();
250
					}
251
					else {
213
			date = TQDate::fromString(gpgOutput.section(':',6,6), Qt::ISODate);
252
			date = TQDate::fromString(gpgOutput.section(':',6,6), Qt::ISODate);
253
					}
254
					Q_ASSERT (date.isValid()) /* tqWarning("Expirationdate date is not valid")*/;
214
			expirationDate=TDEGlobal::locale()->formatDate(date);
255
			expirationDate=TDEGlobal::locale()->formatDate(date);
215
			}
256
			}
216
                        prop->tLExpiration->setText(expirationDate);
257
                        prop->tLExpiration->setText(expirationDate);
Lines 240-246 Link Here
240
                                break;
281
                                break;
241
                        }
282
                        }
242
                        prop->kCOwnerTrust->setCurrentItem(ownerTrust);
283
                        prop->kCOwnerTrust->setCurrentItem(ownerTrust);
284
			}
285
	
286
 			if ( gpgOutput.startsWith("uid") && fullname.isEmpty() )
287
 				fullname = gpgOutput.section(':',9,9);
288
289
			if (gpgOutput.startsWith("fpr") && (fingervalue.isNull())) {
290
				fingervalue=gpgOutput.section(':',9,9);
291
				// format fingervalue in 4-digit groups
292
				uint len = fingervalue.length();
293
				if ((len > 0) && (len % 4 == 0))
294
					for (uint n = 0; 4*(n+1) < len; n++)
295
						fingervalue.insert(5*n+4, ' ');
296
						prop->lEFinger->setText(fingervalue);
297
			}
298
		}
243
299
300
		if (!fullname.isEmpty()) {
244
                        if (fullname.find("<")!=-1) {
301
                        if (fullname.find("<")!=-1) {
245
                                TQString kmail=fullname;
302
                                TQString kmail=fullname;
246
				if (fullname.find(")")!=-1)
303
				if (fullname.find(")")!=-1)
Lines 266-294 Link Here
266
                                prop->tLComment->setText(i18n("none"));
323
                                prop->tLComment->setText(i18n("none"));
267
324
268
			prop->tLName->setText("<qt><b>"+KgpgInterface::checkForUtf8(kname).replace(TQRegExp("<"),"&lt;")+"</b></qt>");
325
			prop->tLName->setText("<qt><b>"+KgpgInterface::checkForUtf8(kname).replace(TQRegExp("<"),"&lt;")+"</b></qt>");
269
270
                }
271
		if (gpgOutput.startsWith("fpr") && (fingervalue.isNull())) {
272
                        fingervalue=gpgOutput.section(':',9,9);
273
                        // format fingervalue in 4-digit groups
274
                        uint len = fingervalue.length();
275
                        if ((len > 0) && (len % 4 == 0))
276
                                for (uint n = 0; 4*(n+1) < len; n++)
277
                                        fingervalue.insert(5*n+4, ' ');
278
					prop->lEFinger->setText(fingervalue);
279
                }
326
                }
280
        }
327
        }
281
        pclose(pass);
282
}
328
}
283
329
284
void KgpgKeyInfo::slotSetMainPhoto(TQStringList list)
330
void KgpgKeyInfo::slotSetMainPhoto(TQStringList list)
285
{
331
{
332
//	kdDebug(2100) << k_funcinfo << endl;
286
prop->comboId->insertStringList(list);
333
prop->comboId->insertStringList(list);
287
reloadMainPhoto(prop->comboId->currentText());
334
reloadMainPhoto(prop->comboId->currentText());
288
}
335
}
289
336
290
void KgpgKeyInfo::reloadMainPhoto(const TQString &uid)
337
void KgpgKeyInfo::reloadMainPhoto(const TQString &uid)
291
{
338
{
339
//	kdDebug(2100) << k_funcinfo << endl;
292
340
293
                kgpginfotmp=new KTempFile();
341
                kgpginfotmp=new KTempFile();
294
                kgpginfotmp->setAutoDelete(true);
342
                kgpginfotmp->setAutoDelete(true);
Lines 305-310 Link Here
305
353
306
void KgpgKeyInfo::slotMainImageRead(TDEProcess *p)
354
void KgpgKeyInfo::slotMainImageRead(TDEProcess *p)
307
{
355
{
356
//	kdDebug(2100) << k_funcinfo << endl;
308
	p->deleteLater();
357
	p->deleteLater();
309
	TQPixmap pixmap;
358
	TQPixmap pixmap;
310
        pixmap.load(kgpginfotmp->name());
359
        pixmap.load(kgpginfotmp->name());
Lines 319-328 Link Here
319
368
320
void KgpgKeyInfo::slotSetPhoto(const TQPixmap &pix)
369
void KgpgKeyInfo::slotSetPhoto(const TQPixmap &pix)
321
{
370
{
322
TQImage dup=pix.convertToImage();
371
//	kdDebug(2100) << k_funcinfo << endl;
323
TQPixmap dup2;
372
	TQImage dup=pix.convertToImage();
324
dup2.convertFromImage(dup.scale(prop->pLPhoto->width(),prop->pLPhoto->height(),TQ_ScaleMin));
373
	TQPixmap dup2;
325
prop->pLPhoto->setPixmap(dup2);
374
	dup2.convertFromImage(dup.scale(prop->pLPhoto->width(),prop->pLPhoto->height(),TQ_ScaleMin));
375
	prop->pLPhoto->setPixmap(dup2);
326
}
376
}
327
377
328
378
Lines 330-335 Link Here
330
380
331
void KgpgKeyInfo::finishphotoreadprocess(KProcIO *p)
381
void KgpgKeyInfo::finishphotoreadprocess(KProcIO *p)
332
{
382
{
383
//	kdDebug(2100) << k_funcinfo << endl;
333
        TQString required=TQString();
384
        TQString required=TQString();
334
        while (p->readln(required,true)!=-1)
385
        while (p->readln(required,true)!=-1)
335
		if (required.find("keyedit.prompt")!=-1) {
386
		if (required.find("keyedit.prompt")!=-1) {
Lines 342-347 Link Here
342
393
343
void KgpgKeyInfo::openPhoto()
394
void KgpgKeyInfo::openPhoto()
344
{
395
{
396
//	kdDebug(2100) << k_funcinfo << endl;
345
			 TDETrader::OfferList offers = TDETrader::self()->query("image/jpeg", "Type == 'Application'");
397
			 TDETrader::OfferList offers = TDETrader::self()->query("image/jpeg", "Type == 'Application'");
346
 			KService::Ptr ptr = offers.first();
398
 			KService::Ptr ptr = offers.first();
347
 			//KMessageBox::sorry(0,ptr->desktopEntryName());
399
 			//KMessageBox::sorry(0,ptr->desktopEntryName());
Lines 352-389 Link Here
352
404
353
void KgpgKeyInfo::slotChangeExp()
405
void KgpgKeyInfo::slotChangeExp()
354
{
406
{
355
chdate=new KDialogBase( this, "choose_date", true,i18n("Choose New Expiration"),KDialogBase::Ok | KDialogBase::Cancel);
407
//	kdDebug(2100) << k_funcinfo << endl;
356
TQWidget *page = new TQWidget(chdate);
408
	chdate=new KDialogBase( this, "choose_date", true,i18n("Choose New Expiration"),KDialogBase::Ok | KDialogBase::Cancel);
357
kb= new TQCheckBox(i18n("Unlimited"),page );
409
	TQWidget *page = new TQWidget(chdate);
358
410
	kb= new TQCheckBox(i18n("Unlimited"),page );
359
if (prop->tLExpiration->text()==i18n("Unlimited"))
411
	
360
{
412
	if (prop->tLExpiration->text()==i18n("Unlimited"))
361
kdt= new KDatePicker( page );
413
	{
362
kb->setChecked(true);
414
		kdt= new KDatePicker( page );
363
kdt->setEnabled(false);
415
		kb->setChecked(true);
364
}
416
		kdt->setEnabled(false);
365
else
417
	}
366
kdt= new KDatePicker(page,TDEGlobal::locale()->readDate(prop->tLExpiration->text()));
418
	else
367
TQVBoxLayout *vbox=new TQVBoxLayout(page,3);
419
		kdt= new KDatePicker(page,TDEGlobal::locale()->readDate(prop->tLExpiration->text()));
368
vbox->addWidget(kdt);
420
	TQVBoxLayout *vbox=new TQVBoxLayout(page,3);
369
vbox->addWidget(kb);
421
	vbox->addWidget(kdt);
370
connect(kb,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableDate(bool)));
422
	vbox->addWidget(kb);
371
connect(chdate,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotChangeDate()));
423
	connect(kb,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableDate(bool)));
372
connect(kdt,TQT_SIGNAL(dateChanged(TQDate)),this,TQT_SLOT(slotCheckDate(TQDate)));
424
	connect(chdate,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotChangeDate()));
373
connect(kdt,TQT_SIGNAL(dateEntered(TQDate)),this,TQT_SLOT(slotCheckDate(TQDate)));
425
	connect(kdt,TQT_SIGNAL(dateChanged(TQDate)),this,TQT_SLOT(slotCheckDate(TQDate)));
426
	connect(kdt,TQT_SIGNAL(dateEntered(TQDate)),this,TQT_SLOT(slotCheckDate(TQDate)));
374
427
375
chdate->setMainWidget(page);
428
	chdate->setMainWidget(page);
376
chdate->show();
429
	chdate->show();
377
}
430
}
378
431
379
void KgpgKeyInfo::slotCheckDate(TQDate date)
432
void KgpgKeyInfo::slotCheckDate(TQDate date)
380
{
433
{
381
chdate->enableButtonOK(date>=TQDate::currentDate ());
434
//	kdDebug(2100) << k_funcinfo << endl;
435
//kdDebug(2100) << "slotCheckDate" << date<<endl;
436
	chdate->enableButtonOK(date>=TQDate::currentDate ());
382
}
437
}
383
438
384
void KgpgKeyInfo::slotChangeDate()
439
void KgpgKeyInfo::slotChangeDate()
385
{
440
{
386
KgpgInterface *KeyExpirationProcess=new KgpgInterface();
441
//	kdDebug(2100) << k_funcinfo << endl;
442
	KgpgInterface *KeyExpirationProcess=new KgpgInterface();
443
//kdDebug(2100) << "slotChangeDate" << kdt->date()<<endl;
387
		if (kb->isChecked())
444
		if (kb->isChecked())
388
                KeyExpirationProcess->KgpgKeyExpire(displayedKeyID,TQDate::currentDate(),true);
445
                KeyExpirationProcess->KgpgKeyExpire(displayedKeyID,TQDate::currentDate(),true);
389
		else
446
		else
Lines 393-412 Link Here
393
450
394
void KgpgKeyInfo::slotEnableDate(bool isOn)
451
void KgpgKeyInfo::slotEnableDate(bool isOn)
395
{
452
{
396
if (isOn)
453
//	kdDebug(2100) << k_funcinfo << endl;
397
{
454
	if (isOn)
398
kdt->setEnabled(false);
455
	{
399
chdate->enableButtonOK(true);
456
		kdt->setEnabled(false);
400
}
457
		chdate->enableButtonOK(true);
401
else
458
	}
402
{
459
	else
403
kdt->setEnabled(true);
460
	{
404
chdate->enableButtonOK(kdt->date()>=TQDate::currentDate ());
461
		kdt->setEnabled(true);
405
}
462
		//kdDebug(2100) << "slotEnableDate" << kdt->date()<<endl;
463
		chdate->enableButtonOK(kdt->date()>=TQDate::currentDate ());
464
	}
406
}
465
}
407
466
408
void KgpgKeyInfo::slotinfoimgread(TDEProcess *)
467
void KgpgKeyInfo::slotinfoimgread(TDEProcess *)
409
{
468
{
469
//	kdDebug(2100) << k_funcinfo << endl;
410
	TQPixmap pixmap;
470
	TQPixmap pixmap;
411
        pixmap.load(kgpginfotmp->name());
471
        pixmap.load(kgpginfotmp->name());
412
	emit signalPhotoId(pixmap);
472
	emit signalPhotoId(pixmap);
Lines 415-420 Link Here
415
475
416
void KgpgKeyInfo::slotChangePass()
476
void KgpgKeyInfo::slotChangePass()
417
{
477
{
478
//	kdDebug(2100) << k_funcinfo << endl;
418
        KgpgInterface *ChangeKeyPassProcess=new KgpgInterface();
479
        KgpgInterface *ChangeKeyPassProcess=new KgpgInterface();
419
        ChangeKeyPassProcess->KgpgChangePass(displayedKeyID);
480
        ChangeKeyPassProcess->KgpgChangePass(displayedKeyID);
420
	connect(ChangeKeyPassProcess,TQT_SIGNAL(passwordChanged()),this,TQT_SLOT(slotInfoPasswordChanged()));
481
	connect(ChangeKeyPassProcess,TQT_SIGNAL(passwordChanged()),this,TQT_SLOT(slotInfoPasswordChanged()));
Lines 422-427 Link Here
422
483
423
void KgpgKeyInfo::slotChangeTrust(int newTrust)
484
void KgpgKeyInfo::slotChangeTrust(int newTrust)
424
{
485
{
486
//	kdDebug(2100) << k_funcinfo << endl;
425
        KgpgInterface *KeyTrustProcess=new KgpgInterface();
487
        KgpgInterface *KeyTrustProcess=new KgpgInterface();
426
                KeyTrustProcess->KgpgTrustExpire(displayedKeyID,newTrust);
488
                KeyTrustProcess->KgpgTrustExpire(displayedKeyID,newTrust);
427
                connect(KeyTrustProcess,TQT_SIGNAL(trustfinished()),this,TQT_SLOT(slotInfoTrustChanged()));
489
                connect(KeyTrustProcess,TQT_SIGNAL(trustfinished()),this,TQT_SLOT(slotInfoTrustChanged()));
Lines 430-465 Link Here
430
492
431
void KgpgKeyInfo::slotInfoPasswordChanged()
493
void KgpgKeyInfo::slotInfoPasswordChanged()
432
{
494
{
495
// 	kdDebug(2100) << k_funcinfo << endl;
433
KPassivePopup::message(i18n("Passphrase for the key was changed"),TQString(),TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this);
496
KPassivePopup::message(i18n("Passphrase for the key was changed"),TQString(),TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this);
434
}
497
}
435
498
436
void KgpgKeyInfo::slotInfoTrustChanged()
499
void KgpgKeyInfo::slotInfoTrustChanged()
437
{
500
{
438
keyWasChanged=true;
501
	keyWasChanged=true;
439
loadKey(displayedKeyID);
502
	loadKey(displayedKeyID);
440
//KPassivePopup::message(i18n("Owner trust of the key was changed"),TQString(),TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this,0,600);
503
//KPassivePopup::message(i18n("Owner trust of the key was changed"),TQString(),TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this,0,600);
441
}
504
}
442
505
443
void KgpgKeyInfo::slotInfoExpirationChanged(int res)
506
void KgpgKeyInfo::slotInfoExpirationChanged(int res)
444
{
507
{
445
TQString infoMessage,infoText;
508
// 	kdDebug(2100) << k_funcinfo << endl;
446
if (res==3)
509
	TQString infoMessage,infoText;
447
{
510
	if (res==3)
448
keyWasChanged=true;
511
	{
449
if (kb->isChecked()) prop->tLExpiration->setText(i18n("Unlimited"));
512
		keyWasChanged=true;
450
else prop->tLExpiration->setText(TDEGlobal::locale()->formatDate(kdt->date()));
513
		if (kb->isChecked()) prop->tLExpiration->setText(i18n("Unlimited"));
451
}
514
		else prop->tLExpiration->setText(TDEGlobal::locale()->formatDate(kdt->date()));
452
if (res==2) {
515
	}
453
infoMessage=i18n("Could not change expiration");infoText=i18n("Bad passphrase");
516
	if (res==2) {
454
KPassivePopup::message(infoMessage,infoText,TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this);
517
		infoMessage=i18n("Could not change expiration");infoText=i18n("Bad passphrase");
455
}
518
		KPassivePopup::message(infoMessage,infoText,TDEGlobal::iconLoader()->loadIcon("kgpg",TDEIcon::Desktop),this);
519
	}
456
}
520
}
457
521
458
522
459
void KgpgKeyInfo::slotPreOk()
523
void KgpgKeyInfo::slotPreOk()
460
{
524
{
461
if (keyWasChanged) emit keyNeedsRefresh();
525
// 	kdDebug(2100) << k_funcinfo << endl;
462
accept();
526
	if (keyWasChanged) emit keyNeedsRefresh();
527
	accept();
463
}
528
}
464
529
465
#include "keyinfowidget.moc"
530
#include "keyinfowidget.moc"
(-)tdeutils.orig/kgpg/keyservers.cpp (-101 / +378 lines)
Lines 4-9 Link Here
4
    begin                : Tue Nov 26 2002
4
    begin                : Tue Nov 26 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 61-76 Link Here
61
65
62
        syncCombobox();
66
        syncCombobox();
63
        page->kLEimportid->setFocus();
67
        page->kLEimportid->setFocus();
68
	currentKey = TQString();
69
	hashMap.clear();
64
70
65
        connect(page->Buttonimport,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotImport()));
71
        connect(page->Buttonimport,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotImport()));
66
        connect(page->Buttonsearch,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotSearch()));
72
        connect(page->Buttonsearch,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotSearch()));
67
        connect(page->Buttonexport,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotPreExport()));
73
        connect(page->Buttonexport,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotPreExport()));
68
        connect(this,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotOk()));
74
        connect(this,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotOk()));
69
75
76
	if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
70
        connect(page->cBproxyI,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableProxyI(bool)));
77
        connect(page->cBproxyI,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableProxyI(bool)));
71
        connect(page->cBproxyE,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableProxyE(bool)));
78
        connect(page->cBproxyE,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotEnableProxyE(bool)));
79
	}
72
80
73
        connect(page->kLEimportid,  TQT_SIGNAL( textChanged ( const TQString & )), this,  TQT_SLOT( slotTextChanged( const TQString &)));
81
        connect(page->kLEimportid,  TQT_SIGNAL( textChanged ( const TQString & )), this,  TQT_SLOT( slotTextChanged( const TQString &)));
82
	if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
74
	page->cBproxyI->setChecked(KGpgSettings::useProxy());
83
	page->cBproxyI->setChecked(KGpgSettings::useProxy());
75
        page->cBproxyE->setChecked(KGpgSettings::useProxy());
84
        page->cBproxyE->setChecked(KGpgSettings::useProxy());
76
        const char *httpproxy = getenv("http_proxy");
85
        const char *httpproxy = getenv("http_proxy");
Lines 80-94 Link Here
80
                page->kLEproxyI->setText(httpproxy);
89
                page->kLEproxyI->setText(httpproxy);
81
                page->kLEproxyE->setText(httpproxy);
90
                page->kLEproxyE->setText(httpproxy);
82
        }
91
        }
92
        }
83
93
84
94
85
        KProcIO *encid=new KProcIO(TQTextCodec::codecForLocale());
95
        KProcIO *encid=new KProcIO(TQTextCodec::codecForLocale());
86
        *encid << "gpg"<<"--no-secmem-warning"<<"--no-tty"<<"--with-colon"<<"--list-keys";
96
        *encid << "gpg"<<"--no-secmem-warning"<<"--no-tty"<<"--with-colon"<<"--list-keys";
97
        TQObject::connect(encid, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotprocresult(TDEProcess *)));
87
        TQObject::connect(encid, TQT_SIGNAL(readReady(KProcIO *)),this, TQT_SLOT(slotprocread(KProcIO *)));
98
        TQObject::connect(encid, TQT_SIGNAL(readReady(KProcIO *)),this, TQT_SLOT(slotprocread(KProcIO *)));
88
        encid->start(TDEProcess::NotifyOnExit,true);
99
        encid->start(TDEProcess::NotifyOnExit,true);
89
        page->Buttonimport->setEnabled( !page->kLEimportid->text().isEmpty());
100
        page->Buttonimport->setEnabled( !page->kLEimportid->text().isEmpty());
90
        page->Buttonsearch->setEnabled( !page->kLEimportid->text().isEmpty());
101
        page->Buttonsearch->setEnabled( !page->kLEimportid->text().isEmpty());
91
setMinimumSize(sizeHint());
102
	setMinimumSize(sizeHint());
92
}
103
}
93
104
94
105
Lines 98-103 Link Here
98
109
99
void keyServer::slotTextChanged( const TQString &text)
110
void keyServer::slotTextChanged( const TQString &text)
100
{
111
{
112
//	kdDebug(2100) << k_funcinfo << endl;
101
    page->Buttonimport->setEnabled( !text.isEmpty());
113
    page->Buttonimport->setEnabled( !text.isEmpty());
102
    page->Buttonsearch->setEnabled( !text.isEmpty());
114
    page->Buttonsearch->setEnabled( !text.isEmpty());
103
115
Lines 112-130 Link Here
112
        page->kLEproxyE->setEnabled(on);
124
        page->kLEproxyE->setEnabled(on);
113
}
125
}
114
126
115
116
117
void keyServer::slotprocread(KProcIO *p)
127
void keyServer::slotprocread(KProcIO *p)
118
{
128
{
129
//	kdDebug(2100) << k_funcinfo << endl;
119
        ///////////////////////////////////////////////////////////////// extract  encryption keys
130
        ///////////////////////////////////////////////////////////////// extract  encryption keys
120
        bool dead;
131
//         bool dead;
121
        TQString tst;
132
        TQString tst;
122
	//TQPixmap pixkeySingle(TDEGlobal::iconLoader()->loadIcon("kgpg_key1",TDEIcon::Small,20));
133
	//TQPixmap pixkeySingle(TDEGlobal::iconLoader()->loadIcon("kgpg_key1",TDEIcon::Small,20));
123
        while (p->readln(tst)!=-1) {
134
        while (p->readln(tst)!=-1) {
124
                //tst=tst.stripWhiteSpace();
135
//               kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
125
                if (tst.startsWith("pub")) {
136
                if ( tst.startsWith("pub")  ) {
126
                        const TQString trust=tst.section(':',1,1);
137
                	currentKey = tst.section(':',4,4).right(8);
127
                        TQString id=TQString("0x"+tst.section(':',4,4).right(8));
138
                	TQStringList lst; lst << tst;
139
			hashMap.insert(currentKey,tst);
140
                }
141
		else
142
			hashMap.find(currentKey).data().append(tst);
143
144
	}
145
146
}
147
148
void keyServer::slotprocresult(TDEProcess *) {
149
150
	TQMap<TQString,TQString> hashImportList;
151
152
	TQMap<TQString,TQStringList>::Iterator ite;
153
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
154
		TQString fullname,id;
155
		bool dead;
156
157
		for (TQStringList::Iterator it = ite.data().begin(); it != ite.data().end(); it++) {
158
			TQString line =  (*it);
159
//	kdDebug(2100) << k_funcinfo << "Export line: " <<line<< endl;
160
			if (line.startsWith("pub")) {
161
				const TQString trust=line.section(':',1,1);
128
                        switch( trust[0] ) {
162
                        switch( trust[0] ) {
129
                        case 'i':
163
                        case 'i':
130
                                dead=true;
164
                                dead=true;
Lines 142-161 Link Here
142
                                dead=false;
176
                                dead=false;
143
                                break;
177
                                break;
144
                        }
178
                        }
145
                        tst=tst.section(':',9,9);
179
				fullname = line.section(':',9,9);
146
                        if (tst.length()>35) {
180
				id = "0x"+line.section(':',4,4).right(8);
147
                                tst.remove(35,tst.length());
148
                                tst+="...";
149
                        }
150
                        if ((!dead) && (!tst.isEmpty()))
151
//                                page->kCBexportkey->insertItem(pixkeySingle,id+": "+tst);
152
                                page->kCBexportkey->insertItem(id+": "+tst);
153
                }
181
                }
182
 			if ( line.startsWith("uid") && fullname.isEmpty() )
183
 				fullname = line.section(':',9,9);
154
        }
184
        }
185
// 		if (fullname.length()>35) {
186
// 			fullname.remove(35,fullname.length());
187
// 			fullname+="...";
188
// 		}
189
190
		TQString tst;
191
		if (fullname.find("<",0)!=-1)
192
			tst=fullname.section('<',0,0);
193
194
		if (!tst.isEmpty())
195
			fullname = tst;
196
197
		if ((!dead) && (!fullname.isEmpty()))
198
			if ( hashImportList.find(id) == hashImportList.end() )
199
				hashImportList.insert(fullname,id);
200
201
        }
202
203
	for (TQMap<TQString,TQString>::Iterator ite = hashImportList.begin(); ite != hashImportList.end() ; ite++) {
204
	//	page->kCBexportkey->insertItem(pixkeySingle,id+": "+tst);
205
		page->kCBexportkey->insertItem(ite.data()+": "+ite.key());
206
	}
207
155
}
208
}
156
209
157
void keyServer::slotSearch()
210
void keyServer::slotSearch()
158
{
211
{
212
//	kdDebug(2100) << k_funcinfo << endl;
159
        if (page->kCBimportks->currentText().isEmpty())
213
        if (page->kCBimportks->currentText().isEmpty())
160
                return;
214
                return;
161
215
Lines 164-170 Link Here
164
                return;
218
                return;
165
        }
219
        }
166
220
221
	currentKey = TQString();
167
        //listpop = new KeyServer( this,"result",WType_Dialog | WShowModal);
222
        //listpop = new KeyServer( this,"result",WType_Dialog | WShowModal);
223
        hashMap.clear();
224
	invalidKeys.clear();
225
	keyNumbers=0;
226
        count=0;
227
        readmessage=TQString();
168
228
169
	dialogServer=new KDialogBase(KDialogBase::Swallow, i18n("Import Key From Keyserver"),  KDialogBase::Ok | KDialogBase::Close,KDialogBase::Ok,this,0,true);
229
	dialogServer=new KDialogBase(KDialogBase::Swallow, i18n("Import Key From Keyserver"),  KDialogBase::Ok | KDialogBase::Close,KDialogBase::Ok,this,0,true);
170
230
Lines 182-205 Link Here
182
242
183
        connect(dialogServer,TQT_SIGNAL(closeClicked()),this,TQT_SLOT(handleQuit()));
243
        connect(dialogServer,TQT_SIGNAL(closeClicked()),this,TQT_SLOT(handleQuit()));
184
        connect( listpop , TQT_SIGNAL( destroyed() ) , this, TQT_SLOT( abortSearch()));
244
        connect( listpop , TQT_SIGNAL( destroyed() ) , this, TQT_SLOT( abortSearch()));
185
        count=0;
245
186
        cycle=false;
246
187
        readmessage=TQString();
188
        searchproc=new KProcIO(TQTextCodec::codecForLocale());
247
        searchproc=new KProcIO(TQTextCodec::codecForLocale());
189
        TQString keyserv=page->kCBimportks->currentText();
248
        TQString keyserv=page->kCBimportks->currentText();
190
        *searchproc<<"gpg"<<"--utf8-strings";
249
250
        *searchproc<<"gpg"<<"--utf8-strings"/*<<"--no-tty"*/;
251
	if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
191
        if (page->cBproxyI->isChecked()) {
252
        if (page->cBproxyI->isChecked()) {
192
                searchproc->setEnvironment("http_proxy",page->kLEproxyI->text());
253
                searchproc->setEnvironment("http_proxy",page->kLEproxyI->text());
193
                *searchproc<<	"--keyserver-options"<<"honor-http-proxy";
254
                *searchproc<<	"--keyserver-options"<<"honor-http-proxy";
194
        } else
255
        } else
195
                *searchproc<<	"--keyserver-options"<<"no-honor-http-proxy";
256
                *searchproc<<	"--keyserver-options"<<"no-honor-http-proxy";
196
        *searchproc<<"--keyserver"<<keyserv<<"--command-fd=0"<<"--status-fd=2"<<"--search-keys"<<page->kLEimportid->text().stripWhiteSpace();
257
        }
258
        *searchproc<<"--keyserver"<<keyserv<<"--command-fd=0"<<"--with-colon";
259
	*searchproc<<"--status-fd=2"<<"--search-keys"<<page->kLEimportid->text().stripWhiteSpace();
197
260
198
        keyNumbers=0;
261
        keyNumbers=0;
262
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
199
        TQObject::connect(searchproc, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotsearchresult(TDEProcess *)));
263
        TQObject::connect(searchproc, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotsearchresult(TDEProcess *)));
200
        TQObject::connect(searchproc, TQT_SIGNAL(readReady(KProcIO *)),this, TQT_SLOT(slotsearchread(KProcIO *)));
264
        TQObject::connect(searchproc, TQT_SIGNAL(readReady(KProcIO *)),this, TQT_SLOT(slotsearchread(KProcIO *)));
265
	searchproc->setUsePty(TDEProcess::Stdout,false); // EKO: very important line - it took me a day to find out why I should use it
201
        searchproc->start(TDEProcess::NotifyOnExit,true);
266
        searchproc->start(TDEProcess::NotifyOnExit,true);
202
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
267
203
	dialogServer->setMainWidget(listpop);
268
	dialogServer->setMainWidget(listpop);
204
	listpop->setMinimumSize(listpop->sizeHint());
269
	listpop->setMinimumSize(listpop->sizeHint());
205
	listpop->setMinimumWidth(550);
270
	listpop->setMinimumWidth(550);
Lines 208-216 Link Here
208
273
209
void keyServer::handleQuit()
274
void keyServer::handleQuit()
210
{
275
{
276
//	kdDebug(2100) << k_funcinfo << endl;
211
	if (searchproc->isRunning())
277
	if (searchproc->isRunning())
212
	{
278
	{
213
	    TQApplication::restoreOverrideCursor();
279
	    TQApplication::restoreOverrideCursor();
280
	    searchproc->closePty();
214
	    disconnect(searchproc,0,0,0);
281
	    disconnect(searchproc,0,0,0);
215
	    searchproc->kill();
282
	    searchproc->kill();
216
	}
283
	}
Lines 220-225 Link Here
220
287
221
void keyServer::abortSearch()
288
void keyServer::abortSearch()
222
{
289
{
290
//	kdDebug(2100) << k_funcinfo << endl;
223
        if (dialogServer) {
291
        if (dialogServer) {
224
                delete dialogServer;
292
                delete dialogServer;
225
                dialogServer=0L;
293
                dialogServer=0L;
Lines 228-233 Link Here
228
296
229
void keyServer::preimport()
297
void keyServer::preimport()
230
{
298
{
299
//	kdDebug(2100) << k_funcinfo << endl;
231
        transferKeyID();
300
        transferKeyID();
232
        if (listpop->kLEID->text().isEmpty()) {
301
        if (listpop->kLEID->text().isEmpty()) {
233
                KMessageBox::sorry(this,i18n("You must choose a key."));
302
                KMessageBox::sorry(this,i18n("You must choose a key."));
Lines 240-245 Link Here
240
309
241
void keyServer::transferKeyID()
310
void keyServer::transferKeyID()
242
{
311
{
312
//	kdDebug(2100) << k_funcinfo << endl;
243
        if (!listpop->kLVsearch->firstChild())
313
        if (!listpop->kLVsearch->firstChild())
244
                return;
314
                return;
245
        TQString kid,keysToSearch;
315
        TQString kid,keysToSearch;
Lines 255-355 Link Here
255
	listpop->kLEID->setText(keysToSearch.stripWhiteSpace());
325
	listpop->kLEID->setText(keysToSearch.stripWhiteSpace());
256
}
326
}
257
327
258
void keyServer::slotsearchresult(TDEProcess *)
259
{
260
        TQString nb;
261
	dialogServer->enableButtonOK(true);
262
	TQApplication::restoreOverrideCursor();
263
        nb=nb.setNum(keyNumbers);
264
        //listpop->kLVsearch->setColumnText(0,i18n("Found %1 matching keys").arg(nb));
265
        listpop->statusText->setText(i18n("Found %1 matching keys").arg(nb));
266
267
        if (listpop->kLVsearch->firstChild()!=NULL) {
268
                listpop->kLVsearch->setSelected(listpop->kLVsearch->firstChild(),true);
269
		listpop->kLVsearch->setCurrentItem(listpop->kLVsearch->firstChild());
270
                transferKeyID();
271
        }
272
}
273
274
void keyServer::slotsearchread(KProcIO *p)
328
void keyServer::slotsearchread(KProcIO *p)
275
{
329
{
276
        TQString required;
330
//	kdDebug(2100) << k_funcinfo << endl;
277
	TQString keymail,keyname;
331
        TQString required = TQString();
278
        while (p->readln(required,true)!=-1) {
279
                //required=TQString::fromUtf8(required);
280
332
333
        while (p->readln(required,true)!=-1) {
334
	//	kdDebug(2100) << "\tRead one search key line: " << required << endl;
281
                if (required.find("keysearch.prompt")!=-1) {
335
                if (required.find("keysearch.prompt")!=-1) {
282
                        if (count<4)
336
			p->setComm(TDEProcess::Stdin);
337
			if (KgpgInterface::getGpgVersion() < 210) {
338
				if (count != 1)
283
                                p->writeStdin(TQString("N"));
339
                                p->writeStdin(TQString("N"));
284
                        else {
340
                        else {
285
                                p->writeStdin(TQString("Q"));
341
                                p->writeStdin(TQString("Q"));
286
                                p->closeWhenDone();
342
                                p->closeWhenDone();
287
                        }
343
                        }
288
                        required=TQString();
344
			} else {
345
				p->writeStdin(TQString("N")); // in 2.1 pressing N ends the session if output is empty
346
// 				if (count == 1)
347
// 					p->closeWhenDone();
348
			}
349
			p->setComm(TDEProcess::Stdout);
350
			required = TQString();
351
			continue;
352
		}
353
		if ( required.isEmpty() ) {
354
			continue;
355
		}
356
		if ( required.find("GOT_IT")!=-1 ) {
357
			required = TQString();
358
			continue;
359
		}
360
361
		if ( required.startsWith("info") ) {
362
			count = required.section(':',2,2).toInt();
363
			required = TQString();
364
			continue;
365
		}
366
		if ( required.startsWith("pub") ) {
367
			currentKey = required.section(':',1,1).right(8);
368
			if ( hashMap.find(currentKey) == hashMap.end() ) {
369
				TQStringList lst; lst.append(required.simplifyWhiteSpace());
370
				hashMap.insert(currentKey,lst);
371
				count--;
372
			}
373
			else
374
				hashMap.find(currentKey).data().append(required.simplifyWhiteSpace());
375
		required = TQString();
376
		}
377
		else {
378
			hashMap.find(currentKey).data().append(required.simplifyWhiteSpace());
379
		required = TQString();
289
                }
380
                }
290
291
                if (required.find("GOT_IT")!=-1) {
292
                        count++;
293
                        required=TQString();
294
                }
381
                }
382
}
295
383
296
                if (required.find("(")==0) {
384
void keyServer::slotsearchresult(TDEProcess *)
297
                        cycle=true;
385
{
298
			TQString fullname=required.remove(0,required.find(")")+1).stripWhiteSpace();
386
//	kdDebug(2100) << k_funcinfo << endl;
299
			if (fullname.find("<")!=-1) {
387
        TQString nb;
300
	                keymail=fullname.section('<',-1,-1);
388
301
			if (keymail.endsWith(">")) keymail.truncate(keymail.length()-1);
389
	// check if key is valid
302
                	keyname=fullname.section('<',0,0);
390
	for (TQMap<TQString,TQStringList>::Iterator ite = hashMap.begin(); ite != hashMap.end() ; ite++) {
303
        		} else {
391
		TQStringList::Iterator it;
304
                	keymail=TQString();
392
		bool skip=false;
305
			keyname=fullname;
393
		// this is to prevent offering to import expired or revoked keys 
394
		//  first find out if key is revoked or expired
395
		for (it = ite.data().begin(); it != ite.data().end();  it++ ) {
396
397
			TQStringList keyString=TQStringList::split(":",(*it),true);
398
		//	kdDebug(2100) << k_funcinfo << "Key line: " << (*it) << endl;
399
			if (keyString[0] == "pub") {
400
				if (! keyString[6].isEmpty() ) {
401
					if (keyString[6] == "r")
402
						skip = true;
403
				}
404
				if (! keyString[5].isEmpty() ) { // expiration date
405
					TQDate date;
406
					if (KgpgInterface::getGpgVersion() >= 210 ) {
407
						TQDateTime timestamp;
408
						timestamp.setTime_t( keyString[5].toInt() );
409
						date = timestamp.date();
410
					}
411
					else {
412
						date = TQDate::fromString(keyString[5], Qt::ISODate);
413
					}
414
					Q_ASSERT (date.isValid()) /*tqWarning("create date is not valid")*/;
415
					if (date < TQDate::currentDate() )
416
						skip = true;
306
		        }
417
		        }
307
                        kitem=new TDEListViewItem(listpop->kLVsearch,keyname,keymail,TQString(),TQString());
418
			}
419
		}
420
		if (skip)
421
			invalidKeys<<ite.key();
422
	}
423
424
	for (TQMap<TQString,TQStringList>::Iterator ite = hashMap.begin(); ite != hashMap.end() ; ite++) {
425
		if (invalidKeys.find(ite.key()) != invalidKeys.end() )
426
			continue;
427
		// very good our keys is neither revoken nor expired  - we can offer it for download
428
		for (TQStringList::Iterator it = ite.data().begin(); it != ite.data().end();  it++ ) {
429
			TQStringList keyString=TQStringList::split(":",(*it),true);
430
		//	kdDebug(2100) << k_funcinfo << "Processing key line: " << (*it) << endl;
431
			TQString created;
432
			if (keyString[0] == "pub") {
433
				if (! keyString[4].isEmpty() ) {
434
					TQDate date;
435
					if (KgpgInterface::getGpgVersion() >= 210 ) {
436
						TQDateTime timestamp;
437
						timestamp.setTime_t( keyString[4].toInt() );
438
						date = timestamp.date();
439
					}
440
					else {
441
						date = TQDate::fromString(keyString[4], Qt::ISODate);
442
					}
443
					created=TDEGlobal::locale()->formatDate(date, true);
444
				}
445
				kitem=new TDEListViewItem(listpop->kLVsearch,TQString(),TQString(), created, keyString[1]);
308
                        keyNumbers++;
446
                        keyNumbers++;
309
                        count=0;
310
                        required=TQString();
311
                }
447
                }
448
			if (keyString[0] == "uid") {
449
				TQString keymail,keyname;
312
450
313
                if ((cycle) && (!required.isEmpty())) {
451
				if (! keyString[2].isEmpty() ) {
314
                        TQString subkey=required.stripWhiteSpace();
452
					TQDate date;
315
			if (subkey.find(" key ")!=-1 && subkey.at(0).isDigit ())
453
					if (KgpgInterface::getGpgVersion() >= 210 ) {
316
			{
454
						TQDateTime timestamp;
317
                        TQString kid=subkey.section(",",0,0).stripWhiteSpace();
455
						timestamp.setTime_t( keyString[2].toInt() );
318
                        kid=kid.right(8);
456
						date = timestamp.date();
319
			kitem->setText(3,kid);
320
			TQString creation=subkey.section("created",1,1);
321
			if (creation.startsWith(":")) creation=creation.right(creation.length()-1);
322
			kitem->setText(2,creation);
323
			cycle=false;
324
			}
457
			}
325
			else
458
					else {
326
			{
459
						date = TQDate::fromString(keyString[2], Qt::ISODate);
327
			if (subkey.find("<")!=-1) {
460
					}
328
	                keymail=subkey.section('<',-1,-1);
461
					created=TDEGlobal::locale()->formatDate(date, true);
462
				}
463
				if (keyString[1].find("<")!=-1) {
464
					keymail=keyString[1].section('<',-1,-1);
329
        	        if (keymail.endsWith(">")) keymail.truncate(keymail.length()-1);
465
        	        if (keymail.endsWith(">")) keymail.truncate(keymail.length()-1);
330
                	keyname=subkey.section('<',0,0);
466
					keyname=keyString[1].section('<',0,0);
331
        		} else {
467
				}
468
				else {
332
                	keymail=TQString();
469
                	keymail=TQString();
333
			keyname=subkey;
470
					keyname=keyString[1];
334
		        }
471
		        }
335
			TDEListViewItem *subk = new TDEListViewItem(kitem,keyname,keymail,TQString(),TQString());
472
				if (kitem != 0 ) {
473
					kitem->setText(0,keyname);
474
					//if ( kitem->getText(1).isEmpty() ) kitem->setText(1,keymail);
475
					TDEListViewItem *subk = new TDEListViewItem(kitem,keyname,keymail,created,TQString());
336
			subk->setSelectable(false);
476
			subk->setSelectable(false);
337
			}
477
			}
338
                        required=TQString();
339
                }
478
                }
340
        }
479
        }
480
	}
481
482
	dialogServer->enableButtonOK(true);
483
	TQApplication::restoreOverrideCursor();
484
        nb=nb.setNum(keyNumbers);
485
        //listpop->kLVsearch->setColumnText(0,i18n("Found %1 matching keys").arg(nb));
486
        listpop->statusText->setText(i18n("Found %1 matching keys").arg(nb));
487
488
        if (listpop->kLVsearch->firstChild()!=NULL) {
489
                listpop->kLVsearch->setSelected(listpop->kLVsearch->firstChild(),true);
490
		listpop->kLVsearch->setCurrentItem(listpop->kLVsearch->firstChild());
491
                transferKeyID();
492
        }
341
}
493
}
342
494
343
void keyServer::slotPreExport()
495
void keyServer::slotPreExport()
344
{
496
{
497
//	kdDebug(2100) << k_funcinfo << endl;
345
	slotExport(TQStringList(page->kCBexportkey->currentText().section(':', 0, 0)));
498
	slotExport(TQStringList(page->kCBexportkey->currentText().section(':', 0, 0)));
346
}
499
}
347
500
348
void keyServer::slotExport(TQStringList keyIds)
501
void keyServer::slotExport(TQStringList keyIds)
349
{
502
{
503
//	kdDebug(2100) << k_funcinfo << endl;
350
        if (page->kCBexportks->currentText().isEmpty())
504
        if (page->kCBexportks->currentText().isEmpty())
351
                return;
505
                return;
352
        readmessage=TQString();
506
        readmessage=TQString();
507
        hashMap.clear();
353
        exportproc=new KProcIO(TQTextCodec::codecForLocale());
508
        exportproc=new KProcIO(TQTextCodec::codecForLocale());
354
        TQString keyserv=page->kCBexportks->currentText();
509
        TQString keyserv=page->kCBexportks->currentText();
355
510
Lines 357-367 Link Here
357
	if (!page->exportAttributes->isChecked())
512
	if (!page->exportAttributes->isChecked())
358
                *exportproc<<"--export-options"<<"no-include-attributes";
513
                *exportproc<<"--export-options"<<"no-include-attributes";
359
514
515
	if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
360
        if (page->cBproxyE->isChecked()) {
516
        if (page->cBproxyE->isChecked()) {
361
                exportproc->setEnvironment("http_proxy",page->kLEproxyE->text());
517
                exportproc->setEnvironment("http_proxy",page->kLEproxyE->text());
362
                *exportproc<<	"--keyserver-options"<<"honor-http-proxy";
518
                *exportproc<<	"--keyserver-options"<<"honor-http-proxy";
363
        } else
519
        } else
364
                *exportproc<<	"--keyserver-options"<<"no-honor-http-proxy";
520
                *exportproc<<	"--keyserver-options"<<"no-honor-http-proxy";
521
	}
365
        *exportproc << "--status-fd=2" << "--keyserver" << keyserv << "--send-keys" << keyIds;
522
        *exportproc << "--status-fd=2" << "--keyserver" << keyserv << "--send-keys" << keyIds;
366
523
367
        TQObject::connect(exportproc, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotexportresult(TDEProcess *)));
524
        TQObject::connect(exportproc, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotexportresult(TDEProcess *)));
Lines 384-389 Link Here
384
541
385
void keyServer::abortExport()
542
void keyServer::abortExport()
386
{
543
{
544
//	kdDebug(2100) << k_funcinfo << endl;
387
	TQApplication::restoreOverrideCursor();
545
	TQApplication::restoreOverrideCursor();
388
        if (exportproc->isRunning())
546
        if (exportproc->isRunning())
389
	{
547
	{
Lines 394-441 Link Here
394
552
395
void keyServer::slotexportresult(TDEProcess*)
553
void keyServer::slotexportresult(TDEProcess*)
396
{
554
{
555
//	kdDebug(2100) << k_funcinfo << endl;
397
	TQApplication::restoreOverrideCursor();
556
	TQApplication::restoreOverrideCursor();
398
        KMessageBox::information(0,readmessage);
557
        KMessageBox::information(0,readmessage);
399
        if (importpop)
558
        if (importpop)
400
                delete importpop;
559
                delete importpop;
401
}
560
}
402
561
403
404
void keyServer::slotImport()
562
void keyServer::slotImport()
405
{
563
{
564
//	kdDebug(2100) << k_funcinfo << endl;
406
        if (page->kCBimportks->currentText().isEmpty())
565
        if (page->kCBimportks->currentText().isEmpty())
407
                return;
566
                return;
408
        if (page->kLEimportid->text().isEmpty()) {
567
        if (page->kLEimportid->text().isEmpty()) {
409
                KMessageBox::sorry(this,i18n("You must enter a search string."));
568
                KMessageBox::sorry(this,i18n("You must select a valid key for import"));
410
                return;
569
                return;
411
        }
570
        }
571
572
//	kdDebug(2100) << k_funcinfo << "Asked for import: " <<page->kLEimportid->text() <<endl;
573
412
        readmessage=TQString();
574
        readmessage=TQString();
413
        importproc=new KProcIO(TQTextCodec::codecForLocale());
575
	count=0;
576
        hashMap.clear();
577
        invalidKeys.clear();
578
        keysToImport.clear();
414
        TQString keyserv=page->kCBimportks->currentText();
579
        TQString keyserv=page->kCBimportks->currentText();
580
/*
581
 *
582
 * This function is called from search and from signature import
583
 * so we need to make sure we have a valid keys for import
584
 * When import is triggered from the search key dialog, we alread have the full ids
585
 * When import is triggered from the signature import popup, we have names, but only 
586
 * if single signature is select we can import from the server
587
 * 
588
 * search the keys first and pass the full pub key ids to the importproc
589
 * to prevent importing pub keys for revocation and normal pub keys together
590
 * we check to see if key is marked as revoc and look for another key that would
591
 * be associated with the revoking one, so we skip both key and everything that 
592
 * belongs to this public key
593
 * 
594
 * we also check the expiration date and refuse to import expired keys
595
 * 
596
 */
415
597
416
        *importproc<<"gpg"<<"--utf8-strings";
417
        if (page->cBproxyI->isChecked()) {
418
                importproc->setEnvironment("http_proxy",page->kLEproxyI->text());
419
                *importproc<<	"--keyserver-options"<<"honor-http-proxy";
420
        } else
421
                *importproc<<	"--keyserver-options"<<"no-honor-http-proxy";
422
423
        *importproc<<"--status-fd=2"<<"--keyserver"<<keyserv<<"--recv-keys";
424
        TQString keyNames=page->kLEimportid->text();
598
        TQString keyNames=page->kLEimportid->text();
425
        keyNames=keyNames.stripWhiteSpace();
599
        keyNames=keyNames.stripWhiteSpace();
426
        keyNames=keyNames.simplifyWhiteSpace();
600
        keyNames=keyNames.simplifyWhiteSpace();
601
602
603
	if ( keyNames.startsWith("0x") ) {
604
		searchproc=new KProcIO(TQTextCodec::codecForLocale());
605
		*searchproc << "gpg"<<"--utf8-strings"<<"--no-secmem-warning";
606
		if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
607
			if (page->cBproxyI->isChecked()) {
608
				searchproc->setEnvironment("http_proxy",page->kLEproxyI->text());
609
				*searchproc << "--keyserver-options"<<"honor-http-proxy";
610
			} else
611
				*searchproc << "--keyserver-options"<<"no-honor-http-proxy";
612
		}
613
		*searchproc << "--keyserver" << keyserv << "--status-fd=2" /*<<"--debug-level"<<"guru"*/;
614
		*searchproc << "--command-fd=0" << "--with-colon" << "--search-keys";
615
	
427
        while (!keyNames.isEmpty()) {
616
        while (!keyNames.isEmpty()) {
428
                TQString fkeyNames=keyNames.section(' ',0,0);
617
                TQString fkeyNames=keyNames.section(' ',0,0);
429
                keyNames.remove(0,fkeyNames.length());
618
                keyNames.remove(0,fkeyNames.length());
430
                keyNames=keyNames.stripWhiteSpace();
619
                keyNames=keyNames.stripWhiteSpace();
431
                *importproc<<TQString(TQFile::encodeName(fkeyNames));
620
			*searchproc<< TQString(TQFile::encodeName(fkeyNames));
432
        }
621
        }
622
		TQObject::connect(searchproc, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(slotksearchprocresult(TDEProcess *)));
623
		TQObject::connect(searchproc, TQT_SIGNAL(readReady(KProcIO *)),TQT_TQOBJECT(this), TQT_SLOT(slotsearchread(KProcIO *)));
624
		TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
625
		searchproc->setUsePty(TDEProcess::Stdout,false); // EKO: very important line - it took me a day to find out why I should use it
626
		searchproc->start(TDEProcess::Block,true);
627
		if (searchproc->isRunning())
628
		{
629
			searchproc->closePty();
630
			disconnect(searchproc,0,0,0);
631
			searchproc->kill();
632
		}
633
	}
634
	else {
635
		keysToImport = TQStringList::split(" ",keyNames,true);
636
	}
637
638
        importproc=new KProcIO(TQTextCodec::codecForLocale());
639
        *importproc<<"gpg"<<"--utf8-strings";
640
	if (KgpgInterface::getGpgVersion() < 210 ) { // was removed in 2.1
641
		if (page->cBproxyI->isChecked()) {
642
			importproc->setEnvironment("http_proxy",page->kLEproxyI->text());
643
			*importproc<<	"--keyserver-options"<<"honor-http-proxy";
644
		} else
645
			*importproc<<	"--keyserver-options"<<"no-honor-http-proxy";
646
	}
647
        *importproc<<"--status-fd=2"<<"--keyserver"<<keyserv<<"--recv-keys";
648
649
	for (TQStringList::Iterator it = keysToImport.begin(); it != keysToImport.end();  it++ ) 
650
		*importproc<< (*it) ;
651
652
        TQObject::connect(importproc, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(slotimportresult(TDEProcess *)));
653
        TQObject::connect(importproc, TQT_SIGNAL(readReady(KProcIO *)),TQT_TQOBJECT(this), TQT_SLOT(slotimportread(KProcIO *)));
433
654
434
        TQObject::connect(importproc, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(slotimportresult(TDEProcess *)));
435
        TQObject::connect(importproc, TQT_SIGNAL(readReady(KProcIO *)),this, TQT_SLOT(slotimportread(KProcIO *)));
436
        importproc->start(TDEProcess::NotifyOnExit,true);
655
        importproc->start(TDEProcess::NotifyOnExit,true);
437
	importproc->closeWhenDone();
656
	importproc->closeWhenDone();
438
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
657
439
        importpop = new TQDialog( this,0,true,TQt::WDestructiveClose);
658
        importpop = new TQDialog( this,0,true,TQt::WDestructiveClose);
440
        TQVBoxLayout *vbox=new TQVBoxLayout(importpop,3);
659
        TQVBoxLayout *vbox=new TQVBoxLayout(importpop,3);
441
        TQLabel *tex=new TQLabel(importpop);
660
        TQLabel *tex=new TQLabel(importpop);
Lines 450-457 Link Here
450
	connect(importpop,TQT_SIGNAL(destroyed ()),this,TQT_SLOT(abortImport()));
669
	connect(importpop,TQT_SIGNAL(destroyed ()),this,TQT_SLOT(abortImport()));
451
}
670
}
452
671
672
453
void keyServer::abortImport()
673
void keyServer::abortImport()
454
{
674
{
675
//	kdDebug(2100) << k_funcinfo << endl;
455
	TQApplication::restoreOverrideCursor();
676
	TQApplication::restoreOverrideCursor();
456
	if (importproc->isRunning())
677
	if (importproc->isRunning())
457
	{
678
	{
Lines 462-469 Link Here
462
	if (autoCloseWindow) close();
683
	if (autoCloseWindow) close();
463
}
684
}
464
685
686
void keyServer::slotksearchprocresult(TDEProcess *) {
687
//	kdDebug(2100) << k_funcinfo << k_funcinfo << endl;
688
	// leave only valid keys in the list
689
	for (TQMap<TQString,TQStringList>::Iterator ite = hashMap.begin(); ite != hashMap.end() ; ite++) {
690
691
		bool exp=false;
692
		bool rev=false;
693
		for (TQStringList::Iterator it = ite.data().begin(); it != ite.data().end();  it++ ) {
694
			TQStringList keyString=TQStringList::split(":",(*it),true);
695
		//	kdDebug(2100) << k_funcinfo << "Read one key line: " << (*it) << endl;
696
			if (keyString[0] == "pub") {
697
				if (! keyString[6].isEmpty() ) {
698
					if (keyString[6] == "r")
699
						rev = true;
700
				}
701
				if (! keyString[5].isEmpty() ) { // expiration date
702
					TQDate date;
703
					if (KgpgInterface::getGpgVersion() >= 210 ) {
704
						TQDateTime timestamp;
705
						timestamp.setTime_t( keyString[5].toInt() );
706
						date = timestamp.date();
707
					}
708
					else {
709
						date = TQDate::fromString(keyString[5], Qt::ISODate);
710
					}
711
					Q_ASSERT (date.isValid()) /*tqWarning("create date is not valid")*/;
712
					if (date < TQDate::currentDate() )
713
						exp = true;
714
				}
715
			}
716
		}
717
		if (exp || rev) {
718
			invalidKeys<<ite.key();
719
			readmessage += "<qt>"+i18n("Public Key")+": <i>0x";
720
			if (rev)
721
				readmessage += ite.key() + " (" + i18n("Revoked");
722
			if (exp)
723
				readmessage += ", "+i18n("Expired");
724
			readmessage += ")</i><br></qt>\n";
725
		}
726
	}
727
728
	for (TQMap<TQString,TQStringList>::Iterator ite = hashMap.begin(); ite != hashMap.end() ; ite++) {
729
		if (invalidKeys.find(ite.key()) == invalidKeys.end() )
730
		// keys are neither revoked nor expired
731
			for (TQStringList::Iterator it = ite.data().begin(); it != ite.data().end();  it++ )
732
				if ( (*it).startsWith("pub") )
733
					keysToImport << (*it).section(":",1,1);
734
	}
735
}
736
465
void keyServer::slotimportresult(TDEProcess*)
737
void keyServer::slotimportresult(TDEProcess*)
466
{
738
{
739
//	kdDebug(2100) << k_funcinfo << endl;
467
	TQApplication::restoreOverrideCursor();
740
	TQApplication::restoreOverrideCursor();
468
        TQString importedNb,importedNbSucess,importedNbProcess,resultMessage, parsedOutput,importedNbUnchanged,importedNbSig;
741
        TQString importedNb,importedNbSucess,importedNbProcess,resultMessage, parsedOutput,importedNbUnchanged,importedNbSig;
469
	TQString notImportesNbSec,importedNbMissing,importedNbRSA,importedNbUid,importedNbSub,importedNbRev,readNbSec;
742
	TQString notImportesNbSec,importedNbMissing,importedNbRSA,importedNbUid,importedNbSub,importedNbRev,readNbSec;
Lines 471-476 Link Here
471
744
472
        parsedOutput=readmessage;
745
        parsedOutput=readmessage;
473
	TQStringList importedKeys;
746
	TQStringList importedKeys;
747
	TQApplication::restoreOverrideCursor();
474
748
475
        while (parsedOutput.find("IMPORTED")!=-1) {
749
        while (parsedOutput.find("IMPORTED")!=-1) {
476
                parsedOutput.remove(0,parsedOutput.find("IMPORTED")+8);
750
                parsedOutput.remove(0,parsedOutput.find("IMPORTED")+8);
Lines 518-528 Link Here
518
		resultMessage+=i18n("<qt>One secret key not imported.<br></qt>","<qt>%n secret keys not imported.<br></qt>",notImportesNbSec.toULong());
792
		resultMessage+=i18n("<qt>One secret key not imported.<br></qt>","<qt>%n secret keys not imported.<br></qt>",notImportesNbSec.toULong());
519
		if (importedNbSucess!="0")
793
		if (importedNbSucess!="0")
520
		resultMessage+=i18n("<qt><b>One key imported:</b><br></qt>","<qt><b>%n keys imported:</b><br></qt>",importedNbSucess.toULong());
794
		resultMessage+=i18n("<qt><b>One key imported:</b><br></qt>","<qt><b>%n keys imported:</b><br></qt>",importedNbSucess.toULong());
521
        } else
795
        }
796
	else
522
                resultMessage=i18n("No key imported... \nCheck detailed log for more infos");
797
                resultMessage=i18n("No key imported... \nCheck detailed log for more infos");
523
798
524
	TQString lastID=TQString("0x"+importedKeys.last().section(" ",0,0).right(8));
799
	TQString lastID=TQString( importedKeys.last().section(" ",0,0).right(8));
525
	if (!lastID.isEmpty())
800
	if ( !lastID.isEmpty() )
526
	{
801
	{
527
	//kdDebug(2100)<<"++++++++++imported key"<<lastID<<endl;
802
	//kdDebug(2100)<<"++++++++++imported key"<<lastID<<endl;
528
	emit importFinished(lastID);
803
	emit importFinished(lastID);
Lines 535-540 Link Here
535
        if (importpop)
810
        if (importpop)
536
                delete importpop;
811
                delete importpop;
537
	if (autoCloseWindow) close();
812
	if (autoCloseWindow) close();
813
538
}
814
}
539
815
540
void keyServer::slotimportread(KProcIO *p)
816
void keyServer::slotimportread(KProcIO *p)
Lines 546-551 Link Here
546
822
547
void keyServer::syncCombobox()
823
void keyServer::syncCombobox()
548
{
824
{
825
//	kdDebug(2100) << k_funcinfo << endl;
549
        config->setGroup("Servers");
826
        config->setGroup("Servers");
550
        TQString serverList=config->readEntry("Server_List");
827
        TQString serverList=config->readEntry("Server_List");
551
828
Lines 555-562 Link Here
555
	page->kCBimportks->clear();
832
	page->kCBimportks->clear();
556
833
557
	if (!optionsServer.isEmpty()) {
834
	if (!optionsServer.isEmpty()) {
558
		page->kCBexportks->insertItem(optionsServer);
835
		page->kCBexportks->insertItem(optionsServer + " (Default)");
559
		page->kCBimportks->insertItem(optionsServer);
836
		page->kCBimportks->insertItem(optionsServer + " (Default)");
560
	}
837
	}
561
	else if ( serverList.isEmpty() )
838
	else if ( serverList.isEmpty() )
562
		serverList = "hkp://wwwkeys.eu.pgp.net,hkp://search.keyserver.net,hkp://wwwkeys.pgp.net,hkp://pgp.dtype.org,hkp://wwwkeys.us.pgp.net"; // same as ini kgpgoptions.cpp
839
		serverList = "hkp://wwwkeys.eu.pgp.net,hkp://search.keyserver.net,hkp://wwwkeys.pgp.net,hkp://pgp.dtype.org,hkp://wwwkeys.us.pgp.net"; // same as ini kgpgoptions.cpp
(-)tdeutils.orig/kgpg/keyservers.h (-1 / +6 lines)
Lines 51-56 Link Here
51
	void slotexportresult(TDEProcess*);
51
	void slotexportresult(TDEProcess*);
52
        void slotimportread(KProcIO *p);
52
        void slotimportread(KProcIO *p);
53
        void slotprocread(KProcIO *p);
53
        void slotprocread(KProcIO *p);
54
	void slotprocresult(TDEProcess *);
54
        void slotPreExport();
55
        void slotPreExport();
55
	void slotExport(TQStringList keyIds);
56
	void slotExport(TQStringList keyIds);
56
        void preimport();
57
        void preimport();
Lines 59-71 Link Here
59
        void slotEnableProxyE(bool on);
60
        void slotEnableProxyE(bool on);
60
        void handleQuit();
61
        void handleQuit();
61
    	void slotTextChanged( const TQString &text);
62
    	void slotTextChanged( const TQString &text);
63
//     	void slotksearchprocread(KProcIO *p);
64
    	void slotksearchprocresult(TDEProcess *);
62
65
63
private:
66
private:
64
67
65
        TQDialog *importpop;
68
        TQDialog *importpop;
66
        KSimpleConfig *config;
69
        KSimpleConfig *config;
67
        uint keyNumbers;
70
        uint keyNumbers;
68
        TQString readmessage;
71
        TQString readmessage, currentKey;;
72
        TQStringList keysToImport, invalidKeys;
73
	TQMap<TQString,TQStringList> hashMap;
69
        KProcIO *importproc,*exportproc;
74
        KProcIO *importproc,*exportproc;
70
	KProcIO *searchproc;
75
	KProcIO *searchproc;
71
        searchRes *listpop;
76
        searchRes *listpop;
(-)tdeutils.orig/kgpg/kgpg.cpp (-16 / +74 lines)
Lines 4-9 Link Here
4
    begin                : Mon Nov 18 2002
4
    begin                : Mon Nov 18 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 174-180 Link Here
174
178
175
void MyView::startFolderEncode(TQStringList selec,TQStringList encryptOptions,bool ,bool symetric)
179
void MyView::startFolderEncode(TQStringList selec,TQStringList encryptOptions,bool ,bool symetric)
176
{
180
{
177
TQString extension;
181
TQString extension="";
178
182
179
if (compressionScheme==0)
183
if (compressionScheme==0)
180
	extension=".zip";
184
	extension=".zip";
Lines 646-678 Link Here
646
        wiz->kURLRequester2->setMode(2);*/
650
        wiz->kURLRequester2->setMode(2);*/
647
651
648
        FILE *fp,*fp2;
652
        FILE *fp,*fp2;
649
        TQString tst,tst2,name,trustedvals="idre-";
653
        TQString trustedvals="idre-";
650
        TQString firstKey=TQString();
654
        TQString firstKey=TQString();
651
        char line[300];
655
        char line[300];
652
        bool counter=false;
656
        bool counter=false;
657
	TQString currentKey;
658
	TQMap<TQString,TQStringList> hashMap;
653
659
654
        fp = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-secret-keys", "r");
660
        fp = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-secret-keys", "r");
655
        while ( fgets( line, sizeof(line), fp)) {
661
        while ( fgets( line, sizeof(line), fp)) {
656
                tst=TQString::fromUtf8(line);
662
                TQString tst=TQString::fromUtf8(line);
657
                if (tst.startsWith("sec")) {
663
                kdDebug(2100) << k_funcinfo << "Read one secret key line: " << tst << endl;
664
                if ( tst.startsWith("sec")  ) {
665
                	currentKey = tst.section(':',4,4);
666
                	TQStringList lst; lst << tst;
667
			hashMap.insert(currentKey,lst);
668
                }
669
		else
670
			hashMap.find(currentKey).data().append(tst);
671
672
	}
673
	pclose(fp);
674
675
	TQMap<TQString,TQStringList>::Iterator ite;
676
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
677
		TDEListViewItem *item;
678
		TQStringList::Iterator it;
679
680
		TQString name,id;
681
682
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
683
			TQString tst =  (*it);
684
			if (tst.startsWith("sec") ) {
685
				if ( KgpgInterface::getGpgVersion() < 210)
658
                        name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
686
                        name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
687
				id = tst.section(':',4,4);
688
			}
689
			if ( tst.startsWith("uid") && KgpgInterface::getGpgVersion() >= 210 )
690
				name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
691
		}
692
659
                        if (!name.isEmpty()) {
693
                        if (!name.isEmpty()) {
660
                                fp2 = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-keys "+TQFile::encodeName(tst.section(':',4,4)), "r");
694
			fp2 = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-keys "+TQFile::encodeName(id), "r");
661
                                while ( fgets( line, sizeof(line), fp2)) {
695
                                while ( fgets( line, sizeof(line), fp2)) {
662
                                        tst2=TQString::fromUtf8(line);
696
				TQString tst2=TQString::fromUtf8(line);
663
                                        if (tst2.startsWith("pub") && (trustedvals.find(tst2.section(':',1,1))==-1)) {
697
                                        if (tst2.startsWith("pub") && (trustedvals.find(tst2.section(':',1,1))==-1)) {
664
                                                counter=true;
698
                                                counter=true;
665
                                                wiz->CBdefault->insertItem(tst.section(':',4,4).right(8)+": "+name);
699
					wiz->CBdefault->insertItem(id.right(8)+": "+name);
666
                                                if (firstKey.isEmpty())
700
                                                if (firstKey.isEmpty())
667
                                                        firstKey=tst.section(':',4,4).right(8)+": "+name;
701
						firstKey=id.right(8)+": "+name;
668
						break;
702
						break;
669
                                        }
703
                                        }
670
                                }
704
                                }
671
                                pclose(fp2);
705
                                pclose(fp2);
672
                        }
706
                        }
673
                }
707
                }
674
        }
708
675
        pclose(fp);
676
	wiz->CBdefault->setCurrentItem(firstKey);
709
	wiz->CBdefault->setCurrentItem(firstKey);
677
        //connect(wiz->pushButton4,TQT_SIGNAL(clicked()),TQT_TQOBJECT(this),TQT_SLOT(slotGenKey()));
710
        //connect(wiz->pushButton4,TQT_SIGNAL(clicked()),TQT_TQOBJECT(this),TQT_SLOT(slotGenKey()));
678
        if (!counter)
711
        if (!counter)
Lines 692-714 Link Here
692
725
693
void  MyView::slotWizardChange()
726
void  MyView::slotWizardChange()
694
{
727
{
695
        TQString tst,name;
696
        char line[300];
697
        FILE *fp;
698
728
699
        if (wiz->indexOf(wiz->currentPage())==2) {
729
        if (wiz->indexOf(wiz->currentPage())==2) {
700
                TQString defaultID=KgpgInterface::getGpgSetting("default-key",wiz->kURLRequester1->url());
730
                TQString defaultID=KgpgInterface::getGpgSetting("default-key",wiz->kURLRequester1->url());
701
                if (defaultID.isEmpty())
731
                if (defaultID.isEmpty())
702
                        return;
732
                        return;
733
734
		char line[300];
735
		FILE *fp;
736
		TQString id, name, currentKey;
737
		TQMap<TQString,TQStringList> hashMap;
703
                fp = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-secret-keys "+TQFile::encodeName(defaultID), "r");
738
                fp = popen("gpg --display-charset=utf-8 --no-tty --with-colon --list-secret-keys "+TQFile::encodeName(defaultID), "r");
704
                while ( fgets( line, sizeof(line), fp)) {
739
                while ( fgets( line, sizeof(line), fp)) {
740
			TQString tst=TQString::fromUtf8(line);
741
			kdDebug(2100) << k_funcinfo << "Read one secret key line: " << tst << endl;
742
			if ( tst.startsWith("sec")  ) {
743
				currentKey = tst.section(':',4,4);
744
				TQStringList lst; lst << tst;
745
				hashMap.insert(currentKey,lst);
746
			}
747
			else
748
				hashMap.find(currentKey).data().append(tst);
749
	
750
		}
751
		pclose(fp);
752
753
754
		TQMap<TQString,TQStringList>::Iterator ite;
755
		for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
756
			for (TQStringList::Iterator it = ite.data().begin(); it != ite.data().end(); it++) {
757
				TQString tst =  (*it);
705
                        tst=TQString::fromUtf8(line);
758
                        tst=TQString::fromUtf8(line);
706
                        if (tst.startsWith("sec")) {
759
				if ( tst.startsWith("sec") ) {
760
					if (KgpgInterface::getGpgVersion() < 210)
707
				name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
761
				name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
708
                                wiz->CBdefault->setCurrentItem(tst.section(':',4,4).right(8)+": "+name);
762
					id=tst.section(':',4,4).right(8);
709
                        }
763
                        }
764
				if ( (tst.startsWith("uid") && KgpgInterface::getGpgVersion() >= 210) ) {
765
					name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
710
                }
766
                }
711
                pclose(fp);
767
			}
768
		}
769
		wiz->CBdefault->setCurrentItem(id+": "+name);
712
        }
770
        }
713
}
771
}
714
772
(-)tdeutils.orig/kgpg/kgpginterface.cpp (-14 / +220 lines)
Lines 4-9 Link Here
4
    begin                : Mon Jul 8 2002
4
    begin                : Mon Jul 8 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 44-49 Link Here
44
#include <kled.h>
48
#include <kled.h>
45
#include <kdebug.h>
49
#include <kdebug.h>
46
#include <tdetempfile.h>
50
#include <tdetempfile.h>
51
#include <tqcursor.h>
47
52
48
#include "kgpginterface.h"
53
#include "kgpginterface.h"
49
#include "listkeys.h"
54
#include "listkeys.h"
Lines 76-81 Link Here
76
81
77
void KgpgInterface::updateIDs(TQString txtString)
82
void KgpgInterface::updateIDs(TQString txtString)
78
{
83
{
84
//	kdDebug(2100) << k_funcinfo << endl;
79
 int cut=txtString.find(' ',22,false);
85
 int cut=txtString.find(' ',22,false);
80
          txtString.remove(0,cut);
86
          txtString.remove(0,cut);
81
          if (txtString.find("(",0,false)!=-1)
87
          if (txtString.find("(",0,false)!=-1)
Lines 91-96 Link Here
91
97
92
void KgpgInterface::KgpgEncryptFile(TQStringList encryptKeys,KURL srcUrl,KURL destUrl, TQStringList Options, bool symetrical)
98
void KgpgInterface::KgpgEncryptFile(TQStringList encryptKeys,KURL srcUrl,KURL destUrl, TQStringList Options, bool symetrical)
93
{
99
{
100
//	kdDebug(2100) << k_funcinfo << endl;
94
        sourceFile=srcUrl;
101
        sourceFile=srcUrl;
95
        message=TQString();
102
        message=TQString();
96
103
Lines 123-128 Link Here
123
130
124
void KgpgInterface::encryptfin(TDEProcess *)
131
void KgpgInterface::encryptfin(TDEProcess *)
125
{
132
{
133
//	kdDebug(2100) << k_funcinfo << endl;
126
        if (message.find("END_ENCRYPTION")!=-1)
134
        if (message.find("END_ENCRYPTION")!=-1)
127
                emit encryptionfinished(sourceFile);
135
                emit encryptionfinished(sourceFile);
128
        else {
136
        else {
Lines 132-137 Link Here
132
140
133
void KgpgInterface::readencprocess(KProcIO *p)
141
void KgpgInterface::readencprocess(KProcIO *p)
134
{
142
{
143
//	kdDebug(2100) << k_funcinfo << endl;
135
        TQString required;
144
        TQString required;
136
        while (p->readln(required,true)!=-1) {
145
        while (p->readln(required,true)!=-1) {
137
                if (required.find("BEGIN_ENCRYPTION",0,false)!=-1)
146
                if (required.find("BEGIN_ENCRYPTION",0,false)!=-1)
Lines 162-167 Link Here
162
171
163
void KgpgInterface::KgpgDecryptFile(KURL srcUrl,KURL destUrl,TQStringList Options)
172
void KgpgInterface::KgpgDecryptFile(KURL srcUrl,KURL destUrl,TQStringList Options)
164
{
173
{
174
//	kdDebug(2100) << k_funcinfo << endl;
165
        message=TQString();
175
        message=TQString();
166
        step=3;
176
        step=3;
167
	decryptUrl=srcUrl.path();
177
	decryptUrl=srcUrl.path();
Lines 187-192 Link Here
187
197
188
void KgpgInterface::decryptfin(TDEProcess *)
198
void KgpgInterface::decryptfin(TDEProcess *)
189
{
199
{
200
//	kdDebug(2100) << k_funcinfo << endl;
190
        if ((message.find("DECRYPTION_OKAY")!=-1) && (message.find("END_DECRYPTION")!=-1)) //&& (message.find("GOODMDC")!=-1)
201
        if ((message.find("DECRYPTION_OKAY")!=-1) && (message.find("END_DECRYPTION")!=-1)) //&& (message.find("GOODMDC")!=-1)
191
                emit decryptionfinished();
202
                emit decryptionfinished();
192
        else
203
        else
Lines 196-201 Link Here
196
207
197
void KgpgInterface::readdecprocess(KProcIO *p)
208
void KgpgInterface::readdecprocess(KProcIO *p)
198
{
209
{
210
//	kdDebug(2100) << k_funcinfo << endl;
199
        TQString required;
211
        TQString required;
200
        while (p->readln(required,true)!=-1) {
212
        while (p->readln(required,true)!=-1) {
201
                if (required.find("BEGIN_DECRYPTION",0,false)!=-1)
213
                if (required.find("BEGIN_DECRYPTION",0,false)!=-1)
Lines 247-252 Link Here
247
259
248
void KgpgInterface::KgpgEncryptText(TQString text,TQStringList userIDs, TQStringList Options)
260
void KgpgInterface::KgpgEncryptText(TQString text,TQStringList userIDs, TQStringList Options)
249
{
261
{
262
//	kdDebug(2100) << k_funcinfo << endl;
250
        message=TQString();
263
        message=TQString();
251
	//TQTextCodec *codec = TDEGlobal::charsets()->codecForName(TDEGlobal::locale()->encoding());
264
	//TQTextCodec *codec = TDEGlobal::charsets()->codecForName(TDEGlobal::locale()->encoding());
252
	TQTextCodec *codec =TQTextCodec::codecForLocale ();
265
	TQTextCodec *codec =TQTextCodec::codecForLocale ();
Lines 279-284 Link Here
279
292
280
void KgpgInterface::txtencryptfin(TDEProcess *)
293
void KgpgInterface::txtencryptfin(TDEProcess *)
281
{
294
{
295
//	kdDebug(2100) << k_funcinfo << endl;
282
        if (!message.isEmpty())
296
        if (!message.isEmpty())
283
                emit txtencryptionfinished(message);
297
                emit txtencryptionfinished(message);
284
        else
298
        else
Lines 287-292 Link Here
287
301
288
void KgpgInterface::txtreadencprocess(KProcIO *p)
302
void KgpgInterface::txtreadencprocess(KProcIO *p)
289
{
303
{
304
//	kdDebug(2100) << k_funcinfo << endl;
290
        TQString required;
305
        TQString required;
291
        while (p->readln(required,true)!=-1) {
306
        while (p->readln(required,true)!=-1) {
292
	  if (required.find("BEGIN_ENCRYPTION",0,false)!=-1)
307
	  if (required.find("BEGIN_ENCRYPTION",0,false)!=-1)
Lines 318-323 Link Here
318
333
319
void KgpgInterface::KgpgDecryptText(TQString text,TQStringList Options)
334
void KgpgInterface::KgpgDecryptText(TQString text,TQStringList Options)
320
{
335
{
336
//	kdDebug(2100) << k_funcinfo << endl;
321
  gpgOutput=TQString();
337
  gpgOutput=TQString();
322
  log=TQString();
338
  log=TQString();
323
339
Lines 345-350 Link Here
345
361
346
void KgpgInterface::txtdecryptfin(TDEProcess *)
362
void KgpgInterface::txtdecryptfin(TDEProcess *)
347
{
363
{
364
//	kdDebug(2100) << k_funcinfo << endl;
348
if ((decok) && (!badmdc))
365
if ((decok) && (!badmdc))
349
emit txtdecryptionfinished(message);
366
emit txtdecryptionfinished(message);
350
367
Lines 360-371 Link Here
360
377
361
void KgpgInterface::getOutput(TDEProcess *, char *data, int )
378
void KgpgInterface::getOutput(TDEProcess *, char *data, int )
362
{
379
{
380
//	kdDebug(2100) << k_funcinfo << endl;
363
	message.append(TQString::fromUtf8(data));
381
	message.append(TQString::fromUtf8(data));
364
}
382
}
365
383
366
384
367
void KgpgInterface::getCmdOutput(TDEProcess *p, char *data, int )
385
void KgpgInterface::getCmdOutput(TDEProcess *p, char *data, int )
368
{
386
{
387
//	kdDebug(2100) << k_funcinfo << endl;
369
  gpgOutput.append(TQString::fromUtf8(data));
388
  gpgOutput.append(TQString::fromUtf8(data));
370
  log.append(data);
389
  log.append(data);
371
390
Lines 434-439 Link Here
434
453
435
void KgpgInterface::KgpgSignText(TQString text,TQString userIDs, TQStringList Options)
454
void KgpgInterface::KgpgSignText(TQString text,TQString userIDs, TQStringList Options)
436
{
455
{
456
//	kdDebug(2100) << k_funcinfo << endl;
437
        message=TQString();
457
        message=TQString();
438
	step=4;
458
	step=4;
439
	TQString txtprocess;
459
	TQString txtprocess;
Lines 450-456 Link Here
450
470
451
        /////////  when process ends, update dialog infos
471
        /////////  when process ends, update dialog infos
452
472
453
        TQObject::connect(proc, TQT_SIGNAL(processExited(TDEProcess *)),this,TQT_SLOT(txtsignfin(TDEProcess *)));
473
        TQObject::connect(proc,TQT_SIGNAL(processExited(TDEProcess *)),this,TQT_SLOT(txtsignfin(TDEProcess *)));
454
        TQObject::connect(proc,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(txtsignprocess(KProcIO *)));
474
        TQObject::connect(proc,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(txtsignprocess(KProcIO *)));
455
475
456
	//emit txtsigningstarted();
476
	//emit txtsigningstarted();
Lines 458-464 Link Here
458
	proc->start(TDEProcess::NotifyOnExit,false);
478
	proc->start(TDEProcess::NotifyOnExit,false);
459
	/*if (useAgent)
479
	/*if (useAgent)
460
	{
480
	{
461
	kdDebug(2100)<<"Using Agent+++++++++++++"<<endl;
481
//	kdDebug(2100)<<"Using Agent+++++++++++++"<<endl;
462
	//KMessageBox::sorry(0,"using agent");
482
	//KMessageBox::sorry(0,"using agent");
463
	proc->writeStdin(txtprocess,true);
483
	proc->writeStdin(txtprocess,true);
464
	proc->closeWhenDone();
484
	proc->closeWhenDone();
Lines 470-475 Link Here
470
490
471
void KgpgInterface::txtsignfin(TDEProcess *)
491
void KgpgInterface::txtsignfin(TDEProcess *)
472
{
492
{
493
//	kdDebug(2100) << k_funcinfo << "MSG: " << message<<endl;
473
        if (!message.isEmpty())
494
        if (!message.isEmpty())
474
                emit txtSignOver(message);
495
                emit txtSignOver(message);
475
        else
496
        else
Lines 478-484 Link Here
478
499
479
void KgpgInterface::txtsignprocess(KProcIO *p)
500
void KgpgInterface::txtsignprocess(KProcIO *p)
480
{
501
{
502
//	kdDebug(2100) << k_funcinfo << endl;
481
        TQString required;
503
        TQString required;
504
482
        while (p->readln(required,true)!=-1) {
505
        while (p->readln(required,true)!=-1) {
483
//	kdDebug(2100)<<"SIGNING: "<<required<<endl;
506
//	kdDebug(2100)<<"SIGNING: "<<required<<endl;
484
507
Lines 492-497 Link Here
492
	p->closeWhenDone();
515
	p->closeWhenDone();
493
	}
516
	}
494
517
518
		if (required.find("BEGIN_SIGNING")!=-1) {
519
			p->writeStdin(message,true);
520
			message=TQString();
521
			p->closeWhenDone();
522
		}
523
	
495
	if ((required.find("passphrase.enter")!=-1))
524
	if ((required.find("passphrase.enter")!=-1))
496
            {
525
            {
497
	      if (step>1) step--;
526
	      if (step>1) step--;
Lines 513-518 Link Here
513
            }
542
            }
514
	    else
543
	    else
515
		if (!required.startsWith("[GNUPG:]")) message+=required+"\n";
544
		if (!required.startsWith("[GNUPG:]")) message+=required+"\n";
545
//	//	kdDebug(2100)<<"SIGNING: "<<message<<endl;
516
        }
546
        }
517
}
547
}
518
548
Lines 521-534 Link Here
521
551
522
void KgpgInterface::KgpgDecryptFileToText(KURL srcUrl,TQStringList Options)
552
void KgpgInterface::KgpgDecryptFileToText(KURL srcUrl,TQStringList Options)
523
{
553
{
554
//	kdDebug(2100) << k_funcinfo << endl;
524
555
525
  message=TQString();
556
  message=TQString();
526
  userIDs=TQString();
557
  userIDs=TQString();
527
  step=3;
558
  step=3;
528
  anonymous=false;
559
  anonymous=false;
529
decfinished=false;
560
  decfinished=false;
530
decok=false;
561
  decok=false;
531
badmdc=false;
562
  badmdc=false;
532
563
533
  TDEProcess *proc=new TDEProcess();
564
  TDEProcess *proc=new TDEProcess();
534
  *proc<<"gpg"<<"--no-tty"<<"--utf8-strings"<<"--no-secmem-warning"<<"--command-fd=0"<<"--status-fd=2"<<"--no-batch"<<"-o"<<"-";
565
  *proc<<"gpg"<<"--no-tty"<<"--utf8-strings"<<"--no-secmem-warning"<<"--command-fd=0"<<"--status-fd=2"<<"--no-batch"<<"-o"<<"-";
Lines 551-556 Link Here
551
582
552
void KgpgInterface::KgpgVerifyText(TQString text)
583
void KgpgInterface::KgpgVerifyText(TQString text)
553
{
584
{
585
//	kdDebug(2100) << k_funcinfo << endl;
554
586
555
		TQTextCodec *codec =TQTextCodec::codecForLocale ();
587
		TQTextCodec *codec =TQTextCodec::codecForLocale ();
556
		if (!codec->canEncode(text)) text=text.utf8();
588
		if (!codec->canEncode(text)) text=text.utf8();
Lines 569-574 Link Here
569
601
570
void KgpgInterface::slotverifyresult(TDEProcess*)
602
void KgpgInterface::slotverifyresult(TDEProcess*)
571
{
603
{
604
//	kdDebug(2100) << k_funcinfo << endl;
572
if (signmiss) emit missingSignature(signID);
605
if (signmiss) emit missingSignature(signID);
573
    else {
606
    else {
574
	if (signID.isEmpty()) signID=i18n("No signature found.");
607
	if (signID.isEmpty()) signID=i18n("No signature found.");
Lines 579-584 Link Here
579
612
580
void KgpgInterface::slotverifyread(KProcIO *p)
613
void KgpgInterface::slotverifyread(KProcIO *p)
581
{
614
{
615
//	kdDebug(2100) << k_funcinfo << endl;
582
TQString required;
616
TQString required;
583
  while (p->readln(required,true)!=-1)
617
  while (p->readln(required,true)!=-1)
584
    {
618
    {
Lines 613-618 Link Here
613
647
614
Md5Widget::Md5Widget(TQWidget *parent, const char *name,KURL url):KDialogBase( parent, name, true,i18n("MD5 Checksum"),Apply | Close)
648
Md5Widget::Md5Widget(TQWidget *parent, const char *name,KURL url):KDialogBase( parent, name, true,i18n("MD5 Checksum"),Apply | Close)
615
{
649
{
650
//	kdDebug(2100) << k_funcinfo << endl;
616
        setButtonApply(i18n("Compare MD5 with Clipboard"));
651
        setButtonApply(i18n("Compare MD5 with Clipboard"));
617
        mdSum=TQString();
652
        mdSum=TQString();
618
        TQFile f(url.path());
653
        TQFile f(url.path());
Lines 664-669 Link Here
664
699
665
void Md5Widget::slotApply()
700
void Md5Widget::slotApply()
666
{
701
{
702
//	kdDebug(2100) << k_funcinfo << endl;
667
        TQClipboard *cb = TQApplication::clipboard();
703
        TQClipboard *cb = TQApplication::clipboard();
668
        TQString text;
704
        TQString text;
669
        // Copy text from the clipboard (paste)
705
        // Copy text from the clipboard (paste)
Lines 692-697 Link Here
692
728
693
void KgpgInterface::KgpgSignFile(TQString keyID,KURL srcUrl,TQStringList Options)
729
void KgpgInterface::KgpgSignFile(TQString keyID,KURL srcUrl,TQStringList Options)
694
{
730
{
731
//	kdDebug(2100) << k_funcinfo << endl;
695
        //////////////////////////////////////   create a detached signature for a chosen file
732
        //////////////////////////////////////   create a detached signature for a chosen file
696
        message=TQString();
733
        message=TQString();
697
        step=3;
734
        step=3;
Lines 714-719 Link Here
714
751
715
void KgpgInterface::signfin(TDEProcess *)
752
void KgpgInterface::signfin(TDEProcess *)
716
{
753
{
754
//	kdDebug(2100) << k_funcinfo << endl;
717
        if (message.find("SIG_CREATED")!=-1)
755
        if (message.find("SIG_CREATED")!=-1)
718
                KMessageBox::information(0,i18n("The signature file %1 was successfully created.").arg(file.fileName()));
756
                KMessageBox::information(0,i18n("The signature file %1 was successfully created.").arg(file.fileName()));
719
        else if (message.find("BAD_PASSPHRASE")!=-1)
757
        else if (message.find("BAD_PASSPHRASE")!=-1)
Lines 726-731 Link Here
726
764
727
void KgpgInterface::readsignprocess(KProcIO *p)
765
void KgpgInterface::readsignprocess(KProcIO *p)
728
{
766
{
767
//	kdDebug(2100) << k_funcinfo << endl;
729
        TQString required;
768
        TQString required;
730
        while (p->readln(required,true)!=-1) {
769
        while (p->readln(required,true)!=-1) {
731
                if (required.find("USERID_HINT",0,false)!=-1)
770
                if (required.find("USERID_HINT",0,false)!=-1)
Lines 766-771 Link Here
766
805
767
void KgpgInterface::KgpgVerifyFile(KURL sigUrl,KURL srcUrl)
806
void KgpgInterface::KgpgVerifyFile(KURL sigUrl,KURL srcUrl)
768
{
807
{
808
//	kdDebug(2100) << k_funcinfo << endl;
769
        //////////////////////////////////////   verify signature for a chosen file
809
        //////////////////////////////////////   verify signature for a chosen file
770
        message=TQString();
810
        message=TQString();
771
	signID=TQString();
811
	signID=TQString();
Lines 786-792 Link Here
786
826
787
void KgpgInterface::readprocess(KProcIO *p)
827
void KgpgInterface::readprocess(KProcIO *p)
788
{
828
{
789
TQString required;
829
//	kdDebug(2100) << k_funcinfo << endl;
830
	TQString required;
790
  while (p->readln(required,true)!=-1)
831
  while (p->readln(required,true)!=-1)
791
    {
832
    {
792
    message+=required+"\n";
833
    message+=required+"\n";
Lines 821-826 Link Here
821
862
822
void KgpgInterface::verifyfin(TDEProcess *)
863
void KgpgInterface::verifyfin(TDEProcess *)
823
{
864
{
865
//	kdDebug(2100) << k_funcinfo << endl;
824
    if (!signmiss) {
866
    if (!signmiss) {
825
        if (signID.isEmpty()) signID=i18n("No signature found.");
867
        if (signID.isEmpty()) signID=i18n("No signature found.");
826
        (void) new KDetailedInfo(0,"verify_result",signID,message);
868
        (void) new KDetailedInfo(0,"verify_result",signID,message);
Lines 839-844 Link Here
839
881
840
void KgpgInterface::KgpgSignKey(TQString keyID,TQString signKeyID,TQString signKeyMail,bool local,int checking)
882
void KgpgInterface::KgpgSignKey(TQString keyID,TQString signKeyID,TQString signKeyMail,bool local,int checking)
841
{
883
{
884
//	kdDebug(2100) << k_funcinfo << endl;
842
        signKeyMail.replace(TQRegExp("<"),"&lt;");
885
        signKeyMail.replace(TQRegExp("<"),"&lt;");
843
        konsChecked=checking;
886
        konsChecked=checking;
844
        konsLocal=local;
887
        konsLocal=local;
Lines 861-914 Link Here
861
	else *conprocess<<"sign";
904
	else *conprocess<<"sign";
862
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(sigprocess(KProcIO *)));
905
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(sigprocess(KProcIO *)));
863
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(signover(TDEProcess *)));
906
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(signover(TDEProcess *)));
907
        TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
864
        conprocess->start(TDEProcess::NotifyOnExit,true);
908
        conprocess->start(TDEProcess::NotifyOnExit,true);
865
}
909
}
866
910
867
void KgpgInterface::sigprocess(KProcIO *p)
911
void KgpgInterface::sigprocess(KProcIO *p)
868
{
912
{
913
//	kdDebug(2100) << k_funcinfo << endl;
869
        TQString required=TQString();
914
        TQString required=TQString();
870
915
871
        while (p->readln(required,true)!=-1)
916
        while (p->readln(required,true)!=-1)
872
        {
917
        {
873
874
                output+=required+"\n";
918
                output+=required+"\n";
919
920
		if ( KgpgInterface::getGpgVersion() >= 210 ) {
921
		//	kdDebug(2100) << k_funcinfo << " line " << required << endl;
875
                if (required.find("USERID_HINT",0,false)!=-1)
922
                if (required.find("USERID_HINT",0,false)!=-1)
876
		updateIDs(required);
923
		updateIDs(required);
877
924
878
                if (signSuccess==4) {
925
	//                    if (KgpgInterface::getGpgVersion() < 210) {
879
                        if (required.find("GET_")!=-1)
926
			if (signSuccess==4 && required.find("GET_")!=-1) {
927
			//	kdDebug(2100) << k_funcinfo << " success quit" << endl;
880
                                p->writeStdin(TQString("quit"));
928
                                p->writeStdin(TQString("quit"));
881
                        p->closeWhenDone();
929
                        p->closeWhenDone();
882
                        return;
930
                        return;
883
                }
931
                }
884
932
885
                if ((required.find("GOOD_PASSPHRASE")!=-1)) {
933
                if ((required.find("GOOD_PASSPHRASE")!=-1)) {
934
			//	kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE" << endl;
886
                        signSuccess=3;
935
                        signSuccess=3;
887
                        step=2;
936
                        step=2;
888
                }
937
                }
889
938
890
                if (required.find("sign_uid.expire")!=-1) {
939
                if (required.find("sign_uid.expire")!=-1) {
940
			//	kdDebug(2100) << k_funcinfo << " sign_uid.expire" << endl;
891
                        p->writeStdin(TQString("Never"));
941
                        p->writeStdin(TQString("Never"));
892
                        required=TQString();
942
                        required=TQString();
893
                }
943
                }
894
                if (required.find("sign_uid.class")!=-1) {
944
                if (required.find("sign_uid.class")!=-1) {
945
			//	kdDebug(2100) << k_funcinfo << " sign_uid.class" << endl;
895
                        p->writeStdin(TQString::number(konsChecked));
946
                        p->writeStdin(TQString::number(konsChecked));
896
                        required=TQString();
947
                        required=TQString();
897
                }
948
                }
898
                if (required.find("sign_uid.okay")!=-1) {
949
			if (required.find("sign_all.okay")!=-1 || required.find("sign_uid.okay")!=-1 ) {
950
			//	kdDebug(2100) << k_funcinfo << " sign_uid.okay" << endl;
951
				step=2;
899
                        p->writeStdin(TQString("Y"));
952
                        p->writeStdin(TQString("Y"));
900
                        required=TQString();
953
                        required=TQString();
901
                }
954
                }
955
			if (required.find("PINENTRY_LAUNCHED")!=-1) {
956
			//	kdDebug(2100) << k_funcinfo << "PINENTRY_LAUNCHED" << endl;
957
	//                        p->writeStdin(TQString::number(konsChecked));
958
				required=TQString();
959
			}
960
	
961
			if (required.find("passphrase.enter")!=-1) {
962
				TQCString signpass;
963
			//	kdDebug(2100) << k_funcinfo << "passphrase.enter" << endl;
964
				TQApplication::restoreOverrideCursor();
965
				int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>")
966
								.arg(errMessage).arg(userIDs));
967
				TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
968
				if (code!=TQDialog::Accepted) {
969
					signSuccess=4;  /////  aborted by user mode
970
					required=TQString();
971
					p->writeStdin(TQString("quit"));
972
					p->closeWhenDone();
973
					return;
974
				}
975
				p->writeStdin(signpass,true);
976
				required=TQString();
977
				//               step=2;
978
			}
979
			if ((step==2) && (required.find("keyedit.prompt")!=-1) ) {
980
			//	kdDebug(2100) << k_funcinfo << "key sign" << endl;
981
				p->writeStdin(TQString("save"));
982
					p->closeWhenDone();
983
					signSuccess=4;  
984
				required=TQString();
985
			}
986
			if (required.find("BAD_PASSPHRASE")!=-1) {
987
			//	kdDebug(2100) << k_funcinfo << "BAD_PASSPHRASE" << endl;
988
				errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>");
989
				required=TQString();
990
				signSuccess=2;  /////  bad passphrase
991
			}
992
// 			if (required.find("GET_")!=-1) /////// gpg asks for something unusal, turn to konsole mode
993
// 			{
994
// 			//	kdDebug(2100) << k_funcinfo << "GET_ " << required << endl;
995
// 				if (signSuccess!=2)
996
// 					signSuccess=1;  /////  switching to console mode
997
// 	
998
// 			}
999
		}
1000
		else {
1001
	//	kdDebug(2100) << k_funcinfo << " line " << required << endl;
1002
			if (required.find("USERID_HINT",0,false)!=-1)
1003
			updateIDs(required);
1004
	
1005
	//                    if (KgpgInterface::getGpgVersion() < 210) {
1006
			if (signSuccess==4) {
1007
	//	kdDebug(2100) << k_funcinfo << " success quit" << endl;
1008
				if (required.find("GET_")!=-1)
1009
					p->writeStdin(TQString("quit"));
1010
				p->closeWhenDone();
1011
				return;
1012
			}
1013
	
1014
			if ((required.find("GOOD_PASSPHRASE")!=-1)) {
1015
	//	kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE" << endl;
1016
				signSuccess=3;
1017
				step=2;
1018
			}
902
1019
903
		if (required.find("sign_all.okay")!=-1) {
1020
			if (required.find("sign_uid.expire")!=-1) {
1021
	//	kdDebug(2100) << k_funcinfo << " sign_uid.expire" << endl;
1022
				p->writeStdin(TQString("Never"));
1023
				required=TQString();
1024
			}
1025
			if (required.find("sign_uid.class")!=-1) {
1026
	//	kdDebug(2100) << k_funcinfo << " sign_uid.class" << endl;
1027
				p->writeStdin(TQString::number(konsChecked));
1028
				required=TQString();
1029
			}
1030
			if (required.find("sign_all.okay")!=-1 || required.find("sign_uid.okay")!=-1 ) {
1031
	//	kdDebug(2100) << k_funcinfo << " sign_uid.okay" << endl;
904
                        p->writeStdin(TQString("Y"));
1032
                        p->writeStdin(TQString("Y"));
905
                        required=TQString();
1033
                        required=TQString();
906
                }
1034
                }
1035
			if (required.find("PINENTRY_LAUNCHED")!=-1) {
1036
	//	kdDebug(2100) << k_funcinfo << "PINENTRY_LAUNCHED" << endl;
1037
	//                        p->writeStdin(TQString::number(konsChecked));
1038
				required=TQString();
1039
			}
907
1040
908
                if (required.find("passphrase.enter")!=-1) {
1041
                if (required.find("passphrase.enter")!=-1) {
1042
				TQApplication::restoreOverrideCursor();
909
                        TQCString signpass;
1043
                        TQCString signpass;
1044
	//	kdDebug(2100) << k_funcinfo << "passphrase.enter" << endl;
910
                        int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>")
1045
                        int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>")
911
                                                              .arg(errMessage).arg(userIDs));
1046
                                                              .arg(errMessage).arg(userIDs));
1047
       				 TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
912
                        if (code!=TQDialog::Accepted) {
1048
                        if (code!=TQDialog::Accepted) {
913
                                signSuccess=4;  /////  aborted by user mode
1049
                                signSuccess=4;  /////  aborted by user mode
914
                                required=TQString();
1050
                                required=TQString();
Lines 920-936 Link Here
920
                        required=TQString();
1056
                        required=TQString();
921
                        //               step=2;
1057
                        //               step=2;
922
                }
1058
                }
923
                if ((step==2) && (required.find("keyedit.prompt")!=-1)) {
1059
			if ((step==2) && (required.find("keyedit.prompt")!=-1) ) {
1060
	//	kdDebug(2100) << k_funcinfo << "key save" << endl;
924
                        p->writeStdin(TQString("save"));
1061
                        p->writeStdin(TQString("save"));
925
                        required=TQString();
1062
                        required=TQString();
926
                }
1063
                }
927
                if (required.find("BAD_PASSPHRASE")!=-1) {
1064
                if (required.find("BAD_PASSPHRASE")!=-1) {
1065
	//	kdDebug(2100) << k_funcinfo << "BAD_PASSPHRASE" << endl;
928
                        errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>");
1066
                        errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>");
929
                        required=TQString();
1067
                        required=TQString();
930
                        signSuccess=2;  /////  bad passphrase
1068
                        signSuccess=2;  /////  bad passphrase
931
                }
1069
                }
932
                if (required.find("GET_")!=-1) /////// gpg asks for something unusal, turn to konsole mode
1070
                if (required.find("GET_")!=-1) /////// gpg asks for something unusal, turn to konsole mode
933
                {
1071
                {
1072
	//	kdDebug(2100) << k_funcinfo << "GET_ " << required << endl;
934
                        if (signSuccess!=2)
1073
                        if (signSuccess!=2)
935
                                signSuccess=1;  /////  switching to console mode
1074
                                signSuccess=1;  /////  switching to console mode
936
                        p->writeStdin(TQString("quit"));
1075
                        p->writeStdin(TQString("quit"));
Lines 938-948 Link Here
938
1077
939
                }
1078
                }
940
        }
1079
        }
1080
        }
941
}
1081
}
942
1082
943
1083
944
void KgpgInterface::signover(TDEProcess *)
1084
void KgpgInterface::signover(TDEProcess *)
945
{
1085
{
1086
//	kdDebug(2100) << k_funcinfo << endl;
1087
	TQApplication::restoreOverrideCursor();
946
        if (signSuccess>1)
1088
        if (signSuccess>1)
947
                emit signatureFinished(signSuccess);  ////   signature successful or bad passphrase
1089
                emit signatureFinished(signSuccess);  ////   signature successful or bad passphrase
948
        else {
1090
        else {
Lines 957-962 Link Here
957
1099
958
void KgpgInterface::openSignConsole()
1100
void KgpgInterface::openSignConsole()
959
{
1101
{
1102
//	kdDebug(2100) << k_funcinfo << endl;
960
        TDEProcess conprocess;
1103
        TDEProcess conprocess;
961
	TDEConfig *config = TDEGlobal::config();
1104
	TDEConfig *config = TDEGlobal::config();
962
	config->setGroup("General");
1105
	config->setGroup("General");
Lines 977-982 Link Here
977
1120
978
void KgpgInterface::KgpgDelSignature(TQString keyID,TQString signKeyID)
1121
void KgpgInterface::KgpgDelSignature(TQString keyID,TQString signKeyID)
979
{
1122
{
1123
//	kdDebug(2100) << k_funcinfo << endl;
980
        if (checkuid(keyID)>0) {
1124
        if (checkuid(keyID)>0) {
981
                KMessageBox::sorry(0,i18n("This key has more than one user ID.\nEdit the key manually to delete signature."));
1125
                KMessageBox::sorry(0,i18n("This key has more than one user ID.\nEdit the key manually to delete signature."));
982
                return;
1126
                return;
Lines 992-997 Link Here
992
        signb=0;
1136
        signb=0;
993
        sigsearch=0;
1137
        sigsearch=0;
994
1138
1139
// >>> HERE
1140
995
        TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --list-sigs "+keyID;
1141
        TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --list-sigs "+keyID;
996
        fp = popen(TQFile::encodeName(gpgcmd), "r");
1142
        fp = popen(TQFile::encodeName(gpgcmd), "r");
997
        while ( fgets( buffer, sizeof(buffer), fp)) {
1143
        while ( fgets( buffer, sizeof(buffer), fp)) {
Lines 1009-1020 Link Here
1009
        *conprocess<<"--edit-key"<<keyID<<"uid 1"<<"delsig";
1155
        *conprocess<<"--edit-key"<<keyID<<"uid 1"<<"delsig";
1010
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(delsigprocess(KProcIO *)));
1156
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(delsigprocess(KProcIO *)));
1011
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(delsignover(TDEProcess *)));
1157
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(delsignover(TDEProcess *)));
1158
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
1012
        conprocess->start(TDEProcess::NotifyOnExit,true);
1159
        conprocess->start(TDEProcess::NotifyOnExit,true);
1013
}
1160
}
1014
1161
1015
1162
1016
void KgpgInterface::delsigprocess(KProcIO *p)
1163
void KgpgInterface::delsigprocess(KProcIO *p)
1017
{
1164
{
1165
//	kdDebug(2100) << k_funcinfo << endl;
1018
1166
1019
        TQString required=TQString();
1167
        TQString required=TQString();
1020
        while (p->readln(required,true)!=-1)
1168
        while (p->readln(required,true)!=-1)
Lines 1044-1049 Link Here
1044
1192
1045
void KgpgInterface::delsignover(TDEProcess *)
1193
void KgpgInterface::delsignover(TDEProcess *)
1046
{
1194
{
1195
//	kdDebug(2100) << k_funcinfo << endl;
1196
	TQApplication::restoreOverrideCursor();
1047
        emit delsigfinished(deleteSuccess);
1197
        emit delsigfinished(deleteSuccess);
1048
}
1198
}
1049
1199
Lines 1051-1060 Link Here
1051
1201
1052
int KgpgInterface::checkuid(TQString KeyID)
1202
int KgpgInterface::checkuid(TQString KeyID)
1053
{
1203
{
1204
//	kdDebug(2100) << k_funcinfo << "KeyID: " << KeyID<< endl;
1054
        FILE *fp;
1205
        FILE *fp;
1055
        TQString encResult;
1206
        TQString encResult;
1056
        char buffer[200];
1207
        char buffer[200];
1057
        int  uidcnt=0;
1208
        int  uidcnt=0;
1209
	if (KgpgInterface::getGpgVersion() > 210 )  uidcnt=-1; // there is always one uid in the new version
1058
1210
1059
        TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --list-sigs "+KeyID;
1211
        TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --list-sigs "+KeyID;
1060
        //////////   encode with untrusted keys or armor if checked by user
1212
        //////////   encode with untrusted keys or armor if checked by user
Lines 1064-1069 Link Here
1064
                if (encResult.startsWith("uid"))
1216
                if (encResult.startsWith("uid"))
1065
                        uidcnt++;
1217
                        uidcnt++;
1066
        }
1218
        }
1219
//	kdDebug(2100) << k_funcinfo << "uid count: " << uidcnt<< endl;
1067
        pclose(fp);
1220
        pclose(fp);
1068
        return uidcnt;
1221
        return uidcnt;
1069
}
1222
}
Lines 1074-1085 Link Here
1074
1227
1075
void KgpgInterface::KgpgKeyExpire(TQString keyID,TQDate date,bool unlimited)
1228
void KgpgInterface::KgpgKeyExpire(TQString keyID,TQDate date,bool unlimited)
1076
{
1229
{
1230
//	kdDebug(2100) << k_funcinfo << endl;
1231
1232
//	kdDebug(2100) << "KgpgKeyExpire date: " << date;
1233
	
1077
        expSuccess=0;
1234
        expSuccess=0;
1078
        step=0;
1235
        step=0;
1079
        if (unlimited)
1236
        if (unlimited)
1080
                expirationDelay=0;
1237
                expirationDelay=0;
1081
        else
1238
        else
1082
                expirationDelay=TQDate::currentDate().daysTo(date);
1239
                expirationDelay=TQDate::currentDate().daysTo(date);
1240
//	kdDebug(2100) << "KgpgKeyExpire date: " << TQDate::currentDate().daysTo(date) <<endl;
1083
        output=TQString();
1241
        output=TQString();
1084
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
1242
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
1085
        *conprocess<<"gpg"<<"--no-secmem-warning"<<"--no-tty"<<"--command-fd=0"<<"--status-fd=2"<<"--utf8-strings";
1243
        *conprocess<<"gpg"<<"--no-secmem-warning"<<"--no-tty"<<"--command-fd=0"<<"--status-fd=2"<<"--utf8-strings";
Lines 1092-1097 Link Here
1092
1250
1093
void KgpgInterface::expprocess(KProcIO *p)
1251
void KgpgInterface::expprocess(KProcIO *p)
1094
{
1252
{
1253
//	kdDebug(2100) << k_funcinfo << endl;
1095
        TQString required=TQString();
1254
        TQString required=TQString();
1096
1255
1097
        while (p->readln(required,true)!=-1) {
1256
        while (p->readln(required,true)!=-1) {
Lines 1152-1157 Link Here
1152
1311
1153
void KgpgInterface::expover(TDEProcess *)
1312
void KgpgInterface::expover(TDEProcess *)
1154
{
1313
{
1314
//	kdDebug(2100) << k_funcinfo << endl;
1155
        if ((expSuccess==3) || (expSuccess==2))
1315
        if ((expSuccess==3) || (expSuccess==2))
1156
                emit expirationFinished(expSuccess);  ////   signature successful or bad passphrase
1316
                emit expirationFinished(expSuccess);  ////   signature successful or bad passphrase
1157
        else {
1317
        else {
Lines 1171-1176 Link Here
1171
1331
1172
void KgpgInterface::KgpgTrustExpire(TQString keyID,int keyTrust)
1332
void KgpgInterface::KgpgTrustExpire(TQString keyID,int keyTrust)
1173
{
1333
{
1334
//	kdDebug(2100) << k_funcinfo << endl;
1174
	trustValue=keyTrust+1;
1335
	trustValue=keyTrust+1;
1175
/*	Don't know=1; Do NOT trust=2; Marginally=3; Fully=4; Ultimately=5;   */
1336
/*	Don't know=1; Do NOT trust=2; Marginally=3; Fully=4; Ultimately=5;   */
1176
1337
Lines 1186-1191 Link Here
1186
1347
1187
void KgpgInterface::trustprocess(KProcIO *p)
1348
void KgpgInterface::trustprocess(KProcIO *p)
1188
{
1349
{
1350
//	kdDebug(2100) << k_funcinfo << endl;
1189
        TQString required=TQString();
1351
        TQString required=TQString();
1190
        while (p->readln(required,true)!=-1) {
1352
        while (p->readln(required,true)!=-1) {
1191
                output+=required+"\n";
1353
                output+=required+"\n";
Lines 1219-1224 Link Here
1219
1381
1220
void KgpgInterface::trustover(TDEProcess *)
1382
void KgpgInterface::trustover(TDEProcess *)
1221
{
1383
{
1384
//	kdDebug(2100) << k_funcinfo << endl;
1222
        emit trustfinished();
1385
        emit trustfinished();
1223
}
1386
}
1224
1387
Lines 1228-1233 Link Here
1228
1391
1229
void KgpgInterface::KgpgChangePass(TQString keyID)
1392
void KgpgInterface::KgpgChangePass(TQString keyID)
1230
{
1393
{
1394
//	kdDebug(2100) << k_funcinfo << endl;
1231
        step=1;
1395
        step=1;
1232
        output=TQString();
1396
        output=TQString();
1233
        message=TQString();
1397
        message=TQString();
Lines 1242-1247 Link Here
1242
1406
1243
void KgpgInterface::passprocess(KProcIO *p)
1407
void KgpgInterface::passprocess(KProcIO *p)
1244
{
1408
{
1409
//	kdDebug(2100) << k_funcinfo << endl;
1245
        TQString required=TQString();
1410
        TQString required=TQString();
1246
1411
1247
        while (p->readln(required,true)!=-1) {
1412
        while (p->readln(required,true)!=-1) {
Lines 1320-1325 Link Here
1320
1485
1321
void KgpgInterface::passover(TDEProcess *)
1486
void KgpgInterface::passover(TDEProcess *)
1322
{
1487
{
1488
//	kdDebug(2100) << k_funcinfo << endl;
1323
        //emit trustfinished();
1489
        //emit trustfinished();
1324
}
1490
}
1325
1491
Lines 1329-1334 Link Here
1329
1495
1330
TQString KgpgInterface::getKey(TQStringList IDs, bool attributes)
1496
TQString KgpgInterface::getKey(TQStringList IDs, bool attributes)
1331
{
1497
{
1498
//	kdDebug(2100) << k_funcinfo << endl;
1332
        keyString=TQString();
1499
        keyString=TQString();
1333
        KProcIO *proc=new KProcIO(TQTextCodec::codecForLocale());
1500
        KProcIO *proc=new KProcIO(TQTextCodec::codecForLocale());
1334
        *proc<< "gpg"<<"--no-tty"<<"--no-secmem-warning"<<"--utf8-strings";
1501
        *proc<< "gpg"<<"--no-tty"<<"--no-secmem-warning"<<"--utf8-strings";
Lines 1346-1351 Link Here
1346
1513
1347
void KgpgInterface::slotReadKey(KProcIO *p)
1514
void KgpgInterface::slotReadKey(KProcIO *p)
1348
{
1515
{
1516
//	kdDebug(2100) << k_funcinfo << endl;
1349
        TQString outp;
1517
        TQString outp;
1350
        while (p->readln(outp)!=-1)
1518
        while (p->readln(outp)!=-1)
1351
                if (!outp.startsWith("gpg:")) keyString+=outp+"\n";
1519
                if (!outp.startsWith("gpg:")) keyString+=outp+"\n";
Lines 1358-1363 Link Here
1358
{
1526
{
1359
        /////////////      import a key
1527
        /////////////      import a key
1360
1528
1529
//	kdDebug(2100) << k_funcinfo << endl;
1361
        if( TDEIO::NetAccess::download( url, tempKeyFile,0) ) {
1530
        if( TDEIO::NetAccess::download( url, tempKeyFile,0) ) {
1362
                message=TQString();
1531
                message=TQString();
1363
                KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
1532
                KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
Lines 1386-1391 Link Here
1386
1555
1387
void KgpgInterface::importover(TDEProcess *)
1556
void KgpgInterface::importover(TDEProcess *)
1388
{
1557
{
1558
//	kdDebug(2100) << k_funcinfo << endl;
1389
TQStringList importedKeysIds;
1559
TQStringList importedKeysIds;
1390
TQStringList messageList;
1560
TQStringList messageList;
1391
TQString resultMessage;
1561
TQString resultMessage;
Lines 1450-1455 Link Here
1450
1620
1451
void KgpgInterface::importURLover(TDEProcess *p)
1621
void KgpgInterface::importURLover(TDEProcess *p)
1452
{
1622
{
1623
//	kdDebug(2100) << k_funcinfo << endl;
1453
        TDEIO::NetAccess::removeTempFile(tempKeyFile);
1624
        TDEIO::NetAccess::removeTempFile(tempKeyFile);
1454
        importover(p);
1625
        importover(p);
1455
        //KMessageBox::information(0,message);
1626
        //KMessageBox::information(0,message);
Lines 1458-1463 Link Here
1458
1629
1459
void KgpgInterface::importprocess(KProcIO *p)
1630
void KgpgInterface::importprocess(KProcIO *p)
1460
{
1631
{
1632
//	kdDebug(2100) << k_funcinfo << endl;
1461
        TQString outp;
1633
        TQString outp;
1462
        while (p->readln(outp)!=-1) {
1634
        while (p->readln(outp)!=-1) {
1463
                if (outp.find("http-proxy")==-1)
1635
                if (outp.find("http-proxy")==-1)
Lines 1471-1476 Link Here
1471
1643
1472
void KgpgInterface::KgpgAddUid(TQString keyID,TQString name,TQString email,TQString comment)
1644
void KgpgInterface::KgpgAddUid(TQString keyID,TQString name,TQString email,TQString comment)
1473
{
1645
{
1646
//	kdDebug(2100) << k_funcinfo << endl;
1474
uidName=name;
1647
uidName=name;
1475
uidComment=comment;
1648
uidComment=comment;
1476
uidEmail=email;
1649
uidEmail=email;
Lines 1487-1498 Link Here
1487
1660
1488
void KgpgInterface::adduidover(TDEProcess *)
1661
void KgpgInterface::adduidover(TDEProcess *)
1489
{
1662
{
1663
//	kdDebug(2100) << k_funcinfo << endl;
1490
if (addSuccess) emit addUidFinished();
1664
if (addSuccess) emit addUidFinished();
1491
else emit addUidError(output);
1665
else emit addUidError(output);
1492
}
1666
}
1493
1667
1494
void KgpgInterface::adduidprocess(KProcIO *p)
1668
void KgpgInterface::adduidprocess(KProcIO *p)
1495
{
1669
{
1670
//	kdDebug(2100) << k_funcinfo << endl;
1496
        TQString required=TQString();
1671
        TQString required=TQString();
1497
        while (p->readln(required,true)!=-1) {
1672
        while (p->readln(required,true)!=-1) {
1498
                output+=required+"\n";
1673
                output+=required+"\n";
Lines 1556-1561 Link Here
1556
1731
1557
void KgpgInterface::KgpgGetPhotoList(TQString keyID)
1732
void KgpgInterface::KgpgGetPhotoList(TQString keyID)
1558
{
1733
{
1734
//	kdDebug(2100) << k_funcinfo << endl;
1559
photoList.clear();
1735
photoList.clear();
1560
output=TQString();
1736
output=TQString();
1561
photoCount=1;
1737
photoCount=1;
Lines 1571-1576 Link Here
1571
1747
1572
void KgpgInterface::photoreadprocess(KProcIO *p)
1748
void KgpgInterface::photoreadprocess(KProcIO *p)
1573
{
1749
{
1750
//	kdDebug(2100) << k_funcinfo << endl;
1574
        TQString required=TQString();
1751
        TQString required=TQString();
1575
        while (p->readln(required,true)!=-1) {
1752
        while (p->readln(required,true)!=-1) {
1576
                output+=required+"\n";
1753
                output+=required+"\n";
Lines 1581-1586 Link Here
1581
1758
1582
void KgpgInterface::photoreadover(TDEProcess *)
1759
void KgpgInterface::photoreadover(TDEProcess *)
1583
{
1760
{
1761
//	kdDebug(2100) << k_funcinfo << endl;
1584
for (int i=1;i<photoCount+1;i++)
1762
for (int i=1;i<photoCount+1;i++)
1585
if (isPhotoId(i)) photoList+=TQString::number(i);
1763
if (isPhotoId(i)) photoList+=TQString::number(i);
1586
1764
Lines 1589-1594 Link Here
1589
1767
1590
bool KgpgInterface::isPhotoId(int uid)
1768
bool KgpgInterface::isPhotoId(int uid)
1591
{
1769
{
1770
//	kdDebug(2100) << k_funcinfo << endl;
1592
KTempFile *kgpginfotmp=new KTempFile();
1771
KTempFile *kgpginfotmp=new KTempFile();
1593
                kgpginfotmp->setAutoDelete(true);
1772
                kgpginfotmp->setAutoDelete(true);
1594
                TQString pgpgOutput="cp %i "+kgpginfotmp->name();
1773
                TQString pgpgOutput="cp %i "+kgpginfotmp->name();
Lines 1608-1613 Link Here
1608
1787
1609
void KgpgInterface::KgpgDeletePhoto(TQString keyID,TQString uid)
1788
void KgpgInterface::KgpgDeletePhoto(TQString keyID,TQString uid)
1610
{
1789
{
1790
//	kdDebug(2100) << k_funcinfo << endl;
1611
	delSuccess=true;
1791
	delSuccess=true;
1612
	output=TQString();
1792
	output=TQString();
1613
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
1793
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
Lines 1620-1631 Link Here
1620
1800
1621
void KgpgInterface::delphotoover(TDEProcess *)
1801
void KgpgInterface::delphotoover(TDEProcess *)
1622
{
1802
{
1803
//	kdDebug(2100) << k_funcinfo << endl;
1623
if (delSuccess) emit delPhotoFinished();
1804
if (delSuccess) emit delPhotoFinished();
1624
else emit delPhotoError(output);
1805
else emit delPhotoError(output);
1625
}
1806
}
1626
1807
1627
void KgpgInterface::delphotoprocess(KProcIO *p)
1808
void KgpgInterface::delphotoprocess(KProcIO *p)
1628
{
1809
{
1810
//	kdDebug(2100) << k_funcinfo << endl;
1629
        TQString required=TQString();
1811
        TQString required=TQString();
1630
        while (p->readln(required,true)!=-1) {
1812
        while (p->readln(required,true)!=-1) {
1631
                output+=required+"\n";
1813
                output+=required+"\n";
Lines 1670-1675 Link Here
1670
1852
1671
void KgpgInterface::KgpgAddPhoto(TQString keyID,TQString imagePath)
1853
void KgpgInterface::KgpgAddPhoto(TQString keyID,TQString imagePath)
1672
{
1854
{
1855
//	kdDebug(2100) << k_funcinfo << endl;
1673
photoUrl=imagePath;
1856
photoUrl=imagePath;
1674
output=TQString();
1857
output=TQString();
1675
addSuccess=true;
1858
addSuccess=true;
Lines 1683-1694 Link Here
1683
1866
1684
void KgpgInterface::addphotoover(TDEProcess *)
1867
void KgpgInterface::addphotoover(TDEProcess *)
1685
{
1868
{
1869
//	kdDebug(2100) << k_funcinfo << endl;
1686
if (addSuccess) emit addPhotoFinished();
1870
if (addSuccess) emit addPhotoFinished();
1687
else emit addPhotoError(output);
1871
else emit addPhotoError(output);
1688
}
1872
}
1689
1873
1690
void KgpgInterface::addphotoprocess(KProcIO *p)
1874
void KgpgInterface::addphotoprocess(KProcIO *p)
1691
{
1875
{
1876
//	kdDebug(2100) << k_funcinfo << endl;
1692
        TQString required=TQString();
1877
        TQString required=TQString();
1693
        while (p->readln(required,true)!=-1) {
1878
        while (p->readln(required,true)!=-1) {
1694
                output+=required+"\n";
1879
                output+=required+"\n";
Lines 1747-1752 Link Here
1747
1932
1748
void KgpgInterface::KgpgRevokeKey(TQString keyID,TQString revokeUrl,int reason,TQString description)
1933
void KgpgInterface::KgpgRevokeKey(TQString keyID,TQString revokeUrl,int reason,TQString description)
1749
{
1934
{
1935
//	kdDebug(2100) << k_funcinfo << endl;
1750
        revokeReason=reason;
1936
        revokeReason=reason;
1751
        revokeSuccess=false;
1937
        revokeSuccess=false;
1752
        revokeDescription=description;
1938
        revokeDescription=description;
Lines 1764-1769 Link Here
1764
1950
1765
void KgpgInterface::revokeover(TDEProcess *)
1951
void KgpgInterface::revokeover(TDEProcess *)
1766
{
1952
{
1953
//	kdDebug(2100) << k_funcinfo << endl;
1767
        if (!revokeSuccess)
1954
        if (!revokeSuccess)
1768
                KMessageBox::detailedSorry(0,i18n("Creation of the revocation certificate failed..."),output);
1955
                KMessageBox::detailedSorry(0,i18n("Creation of the revocation certificate failed..."),output);
1769
        else {
1956
        else {
Lines 1778-1804 Link Here
1778
1965
1779
void KgpgInterface::revokeprocess(KProcIO *p)
1966
void KgpgInterface::revokeprocess(KProcIO *p)
1780
{
1967
{
1968
//	kdDebug(2100) << k_funcinfo << endl;
1781
        TQString required=TQString();
1969
        TQString required=TQString();
1782
        while (p->readln(required,true)!=-1) {
1970
        while (p->readln(required,true)!=-1) {
1783
                output+=required+"\n";
1971
                output+=required+"\n";
1972
		//	kdDebug(2100) << k_funcinfo << " line " << required << endl;
1784
1973
1785
                if (required.find("USERID_HINT",0,false)!=-1)
1974
                if (required.find("USERID_HINT",0,false)!=-1)
1786
		updateIDs(required);
1975
		updateIDs(required);
1787
1976
1788
                if ((required.find("GOOD_PASSPHRASE")!=-1))
1977
                if ((required.find("GOOD_PASSPHRASE")!=-1))
1978
		//	kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE " << endl;
1789
                        revokeSuccess=true;
1979
                        revokeSuccess=true;
1790
1980
1791
                if ((required.find("gen_revoke.okay")!=-1) || (required.find("ask_revocation_reason.okay")!=-1) || (required.find("openfile.overwrite.okay")!=-1)) {
1981
                if ((required.find("gen_revoke.okay")!=-1) || (required.find("ask_revocation_reason.okay")!=-1) || (required.find("openfile.overwrite.okay")!=-1)) {
1982
		//	kdDebug(2100) << k_funcinfo << " gen_revoke.okay " << endl;
1792
                        p->writeStdin(TQString("YES"));
1983
                        p->writeStdin(TQString("YES"));
1793
                        required=TQString();
1984
                        required=TQString();
1794
                }
1985
                }
1795
1986
1796
                if (required.find("ask_revocation_reason.code")!=-1) {
1987
                if (required.find("ask_revocation_reason.code")!=-1) {
1988
		//	kdDebug(2100) << k_funcinfo << " ask_revocation_reason.code " << endl;
1797
                        p->writeStdin(TQString::number(revokeReason));
1989
                        p->writeStdin(TQString::number(revokeReason));
1798
                        required=TQString();
1990
                        required=TQString();
1799
                }
1991
                }
1800
1992
1801
                if (required.find("passphrase.enter")!=-1) {
1993
                if (required.find("passphrase.enter")!=-1) {
1994
		//	kdDebug(2100) << k_funcinfo << " passphrase.enter " << endl;
1802
                        TQCString signpass;
1995
                        TQCString signpass;
1803
                        int code=KPasswordDialog::getPassword(signpass,i18n("<qt>Enter passphrase for <b>%1</b>:</qt>").arg(userIDs));
1996
                        int code=KPasswordDialog::getPassword(signpass,i18n("<qt>Enter passphrase for <b>%1</b>:</qt>").arg(userIDs));
1804
                        if (code!=TQDialog::Accepted) {
1997
                        if (code!=TQDialog::Accepted) {
Lines 1812-1818 Link Here
1812
2005
1813
                }
2006
                }
1814
                if (required.find("ask_revocation_reason.text")!=-1) {
2007
                if (required.find("ask_revocation_reason.text")!=-1) {
1815
                        //		kdDebug(2100)<<"description"<<endl;
2008
		//	kdDebug(2100) << k_funcinfo << " ask_revocation_reason.text " << endl;
2009
                        //	//	kdDebug(2100)<<"description"<<endl;
1816
                        p->writeStdin(revokeDescription);
2010
                        p->writeStdin(revokeDescription);
1817
                        revokeDescription=TQString();
2011
                        revokeDescription=TQString();
1818
                        required=TQString();
2012
                        required=TQString();
Lines 1833-1838 Link Here
1833
2027
1834
TQString KgpgInterface::getGpgSetting(TQString name,TQString configFile)
2028
TQString KgpgInterface::getGpgSetting(TQString name,TQString configFile)
1835
{
2029
{
2030
//	kdDebug(2100) << k_funcinfo << endl;
1836
        name=name.stripWhiteSpace()+" ";
2031
        name=name.stripWhiteSpace()+" ";
1837
        TQFile qfile(TQFile::encodeName(configFile));
2032
        TQFile qfile(TQFile::encodeName(configFile));
1838
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
2033
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
Lines 1855-1860 Link Here
1855
2050
1856
TQString KgpgInterface::getGpgMultiSetting(TQString name,TQString configFile)
2051
TQString KgpgInterface::getGpgMultiSetting(TQString name,TQString configFile)
1857
{
2052
{
2053
//	kdDebug(2100) << k_funcinfo << endl;
1858
// get GnuPG setting for item that can have multiple entries (eg. encrypt-to)
2054
// get GnuPG setting for item that can have multiple entries (eg. encrypt-to)
1859
2055
1860
TQString parsedResult=TQString();
2056
TQString parsedResult=TQString();
Lines 1884-1889 Link Here
1884
2080
1885
void KgpgInterface::delGpgGroup(TQString name, TQString configFile)
2081
void KgpgInterface::delGpgGroup(TQString name, TQString configFile)
1886
{
2082
{
2083
//	kdDebug(2100) << k_funcinfo << endl;
1887
        TQString textToWrite;
2084
        TQString textToWrite;
1888
        TQFile qfile(TQFile::encodeName(configFile));
2085
        TQFile qfile(TQFile::encodeName(configFile));
1889
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
2086
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
Lines 1912-1917 Link Here
1912
2109
1913
void KgpgInterface::setGpgGroupSetting(TQString name,TQStringList values, TQString configFile)
2110
void KgpgInterface::setGpgGroupSetting(TQString name,TQStringList values, TQString configFile)
1914
{
2111
{
2112
//	kdDebug(2100) << k_funcinfo << endl;
1915
        TQString textToWrite;
2113
        TQString textToWrite;
1916
        bool found=false;
2114
        bool found=false;
1917
        TQFile qfile(TQFile::encodeName(configFile));
2115
        TQFile qfile(TQFile::encodeName(configFile));
Lines 1951-1956 Link Here
1951
2149
1952
TQStringList KgpgInterface::getGpgGroupSetting(TQString name,TQString configFile)
2150
TQStringList KgpgInterface::getGpgGroupSetting(TQString name,TQString configFile)
1953
{
2151
{
2152
//	kdDebug(2100) << k_funcinfo << endl;
1954
2153
1955
        TQFile qfile(TQFile::encodeName(configFile));
2154
        TQFile qfile(TQFile::encodeName(configFile));
1956
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
2155
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
Lines 1978-1983 Link Here
1978
2177
1979
TQStringList KgpgInterface::getGpgGroupNames(TQString configFile)
2178
TQStringList KgpgInterface::getGpgGroupNames(TQString configFile)
1980
{
2179
{
2180
//	kdDebug(2100) << k_funcinfo << endl;
1981
        TQStringList groups;
2181
        TQStringList groups;
1982
        TQFile qfile(TQFile::encodeName(configFile));
2182
        TQFile qfile(TQFile::encodeName(configFile));
1983
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
2183
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
Lines 2000-2005 Link Here
2000
2200
2001
bool KgpgInterface::getGpgBoolSetting(TQString name,TQString configFile)
2201
bool KgpgInterface::getGpgBoolSetting(TQString name,TQString configFile)
2002
{
2202
{
2203
//	kdDebug(2100) << k_funcinfo << endl;
2003
        name=name;
2204
        name=name;
2004
        TQFile qfile(TQFile::encodeName(configFile));
2205
        TQFile qfile(TQFile::encodeName(configFile));
2005
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
2206
        if (qfile.open(IO_ReadOnly) && (qfile.exists())) {
Lines 2019-2024 Link Here
2019
2220
2020
void KgpgInterface::setGpgSetting(TQString name,TQString value,TQString url)
2221
void KgpgInterface::setGpgSetting(TQString name,TQString value,TQString url)
2021
{
2222
{
2223
//	kdDebug(2100) << k_funcinfo << endl;
2022
        name=name+" ";
2224
        name=name+" ";
2023
        TQString textToWrite;
2225
        TQString textToWrite;
2024
        bool found=false;
2226
        bool found=false;
Lines 2045-2051 Link Here
2045
2247
2046
                if (qfile.open(IO_WriteOnly)) {
2248
                if (qfile.open(IO_WriteOnly)) {
2047
                        TQTextStream t( &qfile);
2249
                        TQTextStream t( &qfile);
2048
                        t << textToWrite;
2250
                        t << textToWrite; // FIXME: this shouldn't write at the end of the gpg.conf file
2049
                        qfile.close();
2251
                        qfile.close();
2050
                }
2252
                }
2051
        }
2253
        }
Lines 2054-2059 Link Here
2054
2256
2055
void KgpgInterface::setGpgMultiSetting(TQString name,TQStringList values,TQString url)
2257
void KgpgInterface::setGpgMultiSetting(TQString name,TQStringList values,TQString url)
2056
{
2258
{
2259
//	kdDebug(2100) << k_funcinfo << endl;
2057
        name=name+" ";
2260
        name=name+" ";
2058
        TQString textToWrite;
2261
        TQString textToWrite;
2059
        bool found=false;
2262
        bool found=false;
Lines 2086-2091 Link Here
2086
2289
2087
void KgpgInterface::setGpgBoolSetting(TQString name,bool enable,TQString url)
2290
void KgpgInterface::setGpgBoolSetting(TQString name,bool enable,TQString url)
2088
{
2291
{
2292
//	kdDebug(2100) << k_funcinfo << endl;
2089
        TQString textToWrite;
2293
        TQString textToWrite;
2090
        bool found=false;
2294
        bool found=false;
2091
        TQFile qfile(TQFile::encodeName(url));
2295
        TQFile qfile(TQFile::encodeName(url));
Lines 2119-2124 Link Here
2119
2323
2120
TQString KgpgInterface::checkForUtf8bis(TQString txt)
2324
TQString KgpgInterface::checkForUtf8bis(TQString txt)
2121
{
2325
{
2326
//	kdDebug(2100) << k_funcinfo << endl;
2122
    if (strchr (txt.ascii(), 0xc3) || (txt.find("\\x")!=-1))
2327
    if (strchr (txt.ascii(), 0xc3) || (txt.find("\\x")!=-1))
2123
	txt=checkForUtf8(txt);
2328
	txt=checkForUtf8(txt);
2124
    else {
2329
    else {
Lines 2131-2136 Link Here
2131
2336
2132
TQString KgpgInterface::checkForUtf8(TQString txt)
2337
TQString KgpgInterface::checkForUtf8(TQString txt)
2133
{
2338
{
2339
//	kdDebug(2100) << k_funcinfo << endl;
2134
        //    code borrowed from gpa
2340
        //    code borrowed from gpa
2135
        const char *s;
2341
        const char *s;
2136
2342
(-)tdeutils.orig/kgpg/kgpgoptions.cpp (-51 / +110 lines)
Lines 65-79 Link Here
65
kgpgOptions::kgpgOptions(TQWidget *parent, const char *name)
65
kgpgOptions::kgpgOptions(TQWidget *parent, const char *name)
66
 : TDEConfigDialog( parent, name, KGpgSettings::self())
66
 : TDEConfigDialog( parent, name, KGpgSettings::self())
67
{
67
{
68
	defaultServerList="hkp://wwwkeys.eu.pgp.net ";
68
	defaultKeyServer="hkp://wwwkeys.eu.pgp.net";
69
	defaultServerList+=i18n("(Default)");
69
	defaultServerList=defaultKeyServer;
70
//	defaultServerList+=i18n("(Default)");
70
	defaultServerList+=",hkp://search.keyserver.net,hkp://wwwkeys.pgp.net,hkp://pgp.dtype.org,hkp://wwwkeys.us.pgp.net";
71
	defaultServerList+=",hkp://search.keyserver.net,hkp://wwwkeys.pgp.net,hkp://pgp.dtype.org,hkp://wwwkeys.us.pgp.net";
71
	config = new TDEConfig ("kgpgrc");
72
	config = new TDEConfig ("kgpgrc");
72
	config->setGroup("Servers");
73
	config->setGroup("Servers");
74
	defaultKeyServer=config->readEntry("Default_Server",defaultKeyServer);
75
	TQString keyServer = KgpgInterface::getGpgSetting("keyserver", KGpgSettings::gpgConfigPath());
76
77
//	TQString serversTmp = config->readEntry("Server_List",defaultServerList);
78
79
	if (!keyServer.isEmpty() )
80
		defaultKeyServer=keyServer;
81
82
// 	if (serverTmp.find(defaultKeyServer,0))
83
// 		int idx = 0;
84
// 	while  ( serverTmp.find(defaultKeyServer,0) )
85
// 		serverList.prepend(defaultKeyServer+" "+i18n("(Default)"));
86
// 	else {
87
// 		TQStringList l = serverList.grep(defaultKeyServer);
88
// 		for (TQStringList::Iterator it = l.begin(); it = l.end(); it++ )
89
// 			
90
// 	}
91
92
73
	serverList=TQStringList::split (",",config->readEntry("Server_List",defaultServerList));
93
	serverList=TQStringList::split (",",config->readEntry("Server_List",defaultServerList));
74
	keyServer = KgpgInterface::getGpgSetting("keyserver", KGpgSettings::gpgConfigPath());
75
94
76
	if (!keyServer.isEmpty()) serverList.prepend(keyServer+" "+i18n("(Default)"));
95
96
//	kdDebug(2100)<<"Servers: "<< serverList.join(", ")<<endl;
77
97
78
	defaultHomePath=TQDir::homeDirPath()+"/.gnupg/";
98
	defaultHomePath=TQDir::homeDirPath()+"/.gnupg/";
79
	if (TQFile(defaultHomePath+"options").exists()) defaultConfigPath="options";
99
	if (TQFile(defaultHomePath+"options").exists()) defaultConfigPath="options";
Lines 83-89 Link Here
83
		else defaultConfigPath=TQString();
103
		else defaultConfigPath=TQString();
84
		}
104
		}
85
105
86
kdDebug(2100)<<"Adding pages"<<endl;
106
//	kdDebug(2100)<<"Adding pages"<<endl;
87
        page1=new Encryption();
107
        page1=new Encryption();
88
        page2=new Decryption();
108
        page2=new Decryption();
89
        page3=new UIConf();
109
        page3=new UIConf();
Lines 185-193 Link Here
185
205
186
void kgpgOptions::slotChangeHome()
206
void kgpgOptions::slotChangeHome()
187
{
207
{
188
TQString gpgHome=KFileDialog::getExistingDirectory(page4->gpg_home_path->text(),this,i18n("New GnuPG Home Location"));
208
	TQString gpgHome=KFileDialog::getExistingDirectory(page4->gpg_home_path->text(),this,i18n("New GnuPG Home Location"));
189
if (gpgHome.isEmpty()) return;
209
	if (gpgHome.isEmpty()) return;
190
if (!gpgHome.endsWith("/")) gpgHome.append("/");
210
	if (!gpgHome.endsWith("/")) gpgHome.append("/");
191
	TQString confPath="options";
211
	TQString confPath="options";
192
        if (!TQFile(gpgHome+confPath).exists()) {
212
        if (!TQFile(gpgHome+confPath).exists()) {
193
                confPath="gpg.conf";
213
                confPath="gpg.conf";
Lines 201-207 Link Here
201
		confPath="gpg.conf";
221
		confPath="gpg.conf";
202
		TQFile confFile(gpgHome+confPath);
222
		TQFile confFile(gpgHome+confPath);
203
		if (!confFile.open(IO_WriteOnly))
223
		if (!confFile.open(IO_WriteOnly))
204
		{KMessageBox::sorry(this,i18n("Cannot create configuration file. Please check if destination media is mounted and if you have write access"));
224
				{
225
					KMessageBox::sorry(this,i18n("Cannot create configuration file. Please check if destination media is mounted and if you have write access"));
205
		return;
226
		return;
206
		}
227
		}
207
		else
228
		else
Lines 220-226 Link Here
220
241
221
void kgpgOptions::updateWidgets()
242
void kgpgOptions::updateWidgets()
222
{
243
{
223
TQString pubKeyring,privKeyring;
244
	TQString pubKeyring,privKeyring;
224
245
225
        gpgConfigPath = KGpgSettings::gpgConfigPath();
246
        gpgConfigPath = KGpgSettings::gpgConfigPath();
226
	page4->gpg_conf_path->setText(KURL(gpgConfigPath).fileName());
247
	page4->gpg_conf_path->setText(KURL(gpgConfigPath).fileName());
Lines 254-270 Link Here
254
275
255
        page4->use_agent->setChecked( useAgent );
276
        page4->use_agent->setChecked( useAgent );
256
277
257
        keyServer = KgpgInterface::getGpgSetting("keyserver", gpgConfigPath);
278
        TQString keyServer = KgpgInterface::getGpgSetting("keyserver", gpgConfigPath);
279
//        defaultKeyServer = "hkp://wwwkeys.pgp.net";
280
281
        if (!keyServer.isEmpty())
282
		defaultKeyServer = keyServer;
283
	else
258
        defaultKeyServer = "hkp://wwwkeys.pgp.net";
284
        defaultKeyServer = "hkp://wwwkeys.pgp.net";
259
285
260
        if (keyServer.isEmpty())
286
	serverList.prepend(defaultKeyServer+" "+i18n("(Default)"));
261
		keyServer = defaultKeyServer;
262
287
263
	page6->ServerBox->clear();
288
	page6->ServerBox->clear();
264
	page6->ServerBox->insertStringList(serverList);
289
	page6->ServerBox->insertStringList(serverList);
265
290
266
291
267
	kdDebug(2100)<<"Finishing options"<<endl;
292
//	kdDebug(2100)<<"Finishing options"<<endl;
268
}
293
}
269
294
270
void kgpgOptions::updateWidgetsDefault()
295
void kgpgOptions::updateWidgetsDefault()
Lines 288-294 Link Here
288
	page6->ServerBox->clear();
313
	page6->ServerBox->clear();
289
	page6->ServerBox->insertStringList(TQStringList::split(",",defaultServerList));
314
	page6->ServerBox->insertStringList(TQStringList::split(",",defaultServerList));
290
315
291
	kdDebug(2100)<<"Finishing default options"<<endl;
316
//	kdDebug(2100)<<"Finishing default options"<<endl;
292
}
317
}
293
318
294
bool kgpgOptions::isDefault()
319
bool kgpgOptions::isDefault()
Lines 413-431 Link Here
413
438
414
	TQString currList;
439
	TQString currList;
415
	serverList=TQStringList ();
440
	serverList=TQStringList ();
416
	for (uint i=0;i<page6->ServerBox->count();i++)
441
	for (uint i=0;i<page6->ServerBox->count();i++) // 0 is always the default
417
	{
442
	{
418
	TQString currItem=page6->ServerBox->text(i);
443
	TQString currItem=page6->ServerBox->text(i);
419
	if (currItem.find(" ")!=-1) // it is the default keyserver
444
		if (currItem.find(" ")!=-1) {// it is the default keyserver
420
	keyServer=currItem.section(" ",0,0);
445
			defaultKeyServer = currItem.section(" ",0,0);
446
		}
421
	else
447
	else
422
	{
423
	serverList.append(currItem);
448
	serverList.append(currItem);
424
	}
449
	}
425
	}
426
450
427
	KgpgInterface::setGpgSetting("keyserver",keyServer, KGpgSettings::gpgConfigPath());
451
	KgpgInterface::setGpgSetting("keyserver",defaultKeyServer, KGpgSettings::gpgConfigPath());
428
	serverList.prepend(keyServer+" "+i18n("(Default)"));
452
	//serverList.prepend(keyServer+" "+i18n("(Default)"));
429
	currList=serverList.join(",");
453
	currList=serverList.join(",");
430
454
431
	if (keyGood!=page3->kcfg_ColorGood->color()) 
455
	if (keyGood!=page3->kcfg_ColorGood->color()) 
Lines 437-442 Link Here
437
461
438
//	KGpgSettings::writeConfig();
462
//	KGpgSettings::writeConfig();
439
	config->setGroup("Servers");
463
	config->setGroup("Servers");
464
	config->writeEntry("Default_Server",defaultKeyServer);
440
	config->writeEntry("Server_List",currList);
465
	config->writeEntry("Server_List",currList);
441
	emit settingsUpdated();
466
	emit settingsUpdated();
442
	if (emitReload) emit reloadKeyList();
467
	if (emitReload) emit reloadKeyList();
Lines 485-494 Link Here
485
        TQFile qfile(path);
510
        TQFile qfile(path);
486
        if (qfile.exists())
511
        if (qfile.exists())
487
                qfile.remove();
512
                qfile.remove();
488
        {
513
//         {
489
                //if (!qfile.remove()) KMessageBox::sorry(this,i18n("Cannot remove service menu. Check permissions"));
514
                //if (!qfile.remove()) KMessageBox::sorry(this,i18n("Cannot remove service menu. Check permissions"));
490
                //else KMessageBox::information(this,i18n("Service menu 'Decrypt File' has been removed."));
515
                //else KMessageBox::information(this,i18n("Service menu 'Decrypt File' has been removed."));
491
        }
516
//         }
492
        //else KMessageBox::sorry(this,i18n("No service menu found"));
517
        //else KMessageBox::sorry(this,i18n("No service menu found"));
493
518
494
}
519
}
Lines 518-526 Link Here
518
543
519
        ////////   update display of keys in main management window
544
        ////////   update display of keys in main management window
520
        FILE *fp;
545
        FILE *fp;
521
        TQString tst,name,trustedvals="idre-",issec;
546
        TQString name,trustedvals="idre-",issec;
522
        int counter=0;
547
        int counter=0;
523
        char line[300];
548
        char line[300];
549
	TQString currentKey;
550
	TQMap<TQString,TQStringList> hashMap;
524
551
525
	FILE *fp2;
552
	FILE *fp2;
526
553
Lines 535-552 Link Here
535
562
536
        fp = popen("gpg --no-tty --with-colon --list-keys", "r");
563
        fp = popen("gpg --no-tty --with-colon --list-keys", "r");
537
        while ( fgets( line, sizeof(line), fp)) {
564
        while ( fgets( line, sizeof(line), fp)) {
538
                tst=line;
565
                TQString tst=TQString::fromUtf8(line);
539
                if (tst.startsWith("pub")) {
566
                kdDebug(2100) << k_funcinfo << "Read one secret key line: " << tst << endl;
567
                if ( tst.startsWith("pub")  ) {
568
                	currentKey = tst.section(':',4,4);
569
                	TQStringList lst; lst << tst;
570
			hashMap.insert(currentKey,lst);
571
                }
572
		else
573
			hashMap.find(currentKey).data().append(tst);
574
575
	}
576
	pclose(fp);
577
578
// process the list
579
580
	TQMap<TQString,TQStringList>::Iterator ite;
581
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
582
		TDEListViewItem *item;
583
		TQStringList::Iterator it;
584
		bool dead = true;	
585
		TQString name,id,val;
586
587
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
588
			TQString tst =  (*it);
589
			if ( tst.startsWith("pub") ) {
590
				if ( KgpgInterface::getGpgVersion() < 210 )
540
                        name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
591
                        name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
541
                        if ((!name.isEmpty()) && (trustedvals.find(tst.section(':',1,1))==-1)) {
592
				val = tst.section(':',1,1);
593
				id = tst.section(':',4,4);
594
			}
595
			if ( tst.startsWith("uid") && KgpgInterface::getGpgVersion() >= 210 )
596
				name=KgpgInterface::checkForUtf8(tst.section(':',9,9));
597
		}
598
599
		if ((!name.isEmpty()) && (trustedvals.find(val)==-1)) {
542
                                counter++;
600
                                counter++;
543
                                //name=name.section('<',-1,-1);
601
                                //name=name.section('<',-1,-1);
544
                                //  name=name.section('>',0,0);
602
                                //  name=name.section('>',0,0);
545
                                names+=name;
603
                                names+=name;
546
                                ids+=tst.section(':',4,4);
604
			ids+=id;
547
                                if (tst.section(':',4,4).right(8)==alwaysKeyID)
605
			if (id.right(8)==alwaysKeyID)
548
                                        alwaysKeyName=tst.section(':',4,4).right(8)+":"+name;
606
				alwaysKeyName=id.right(8)+":"+name;
549
				if (issec.find(tst.section(':',4,4).right(8),0,FALSE)!=-1)
607
			if (issec.find(id.right(8),0,FALSE)!=-1)
550
				{
608
				{
551
//***                           page1->file_key->insertItem(pixkeyDouble,tst.section(':',4,4).right(8)+":"+name);
609
//***                           page1->file_key->insertItem(pixkeyDouble,tst.section(':',4,4).right(8)+":"+name);
552
//***                           page1->always_key->insertItem(pixkeyDouble,tst.section(':',4,4).right(8)+":"+name);
610
//***                           page1->always_key->insertItem(pixkeyDouble,tst.section(':',4,4).right(8)+":"+name);
Lines 558-565 Link Here
558
				}
616
				}
559
                        }
617
                        }
560
                }
618
                }
561
        }
619
562
        pclose(fp);
563
        if (counter==0) {
620
        if (counter==0) {
564
                ids+="0";
621
                ids+="0";
565
//***                           page1->file_key->insertItem(i18n("none"));
622
//***                           page1->file_key->insertItem(i18n("none"));
Lines 569-600 Link Here
569
626
570
void kgpgOptions::slotAddKeyServer()
627
void kgpgOptions::slotAddKeyServer()
571
{
628
{
572
TQString newServer=KInputDialog::getText(i18n("Add New Key Server"),i18n("Server URL:"));
629
	TQString newServer=KInputDialog::getText(i18n("Add New Key Server"),i18n("Server URL:"));
573
if (!newServer.isEmpty())
630
	if (!newServer.isEmpty())
574
page6->ServerBox->insertItem(newServer.stripWhiteSpace());
631
		page6->ServerBox->insertItem(newServer.stripWhiteSpace());
575
page6->ServerBox->setSelected(page6->ServerBox->findItem(newServer.stripWhiteSpace()),true);
632
	page6->ServerBox->setSelected(page6->ServerBox->findItem(newServer.stripWhiteSpace()),true);
576
}
633
}
577
634
578
void kgpgOptions::slotDelKeyServer()
635
void kgpgOptions::slotDelKeyServer()
579
{
636
{
580
bool defaultDeleted=false;
637
	bool defaultDeleted=false;
581
if (page6->ServerBox->currentText().find(" ")!=-1) defaultDeleted=true;
638
	if (page6->ServerBox->currentText().find(" ")!=-1) 
582
page6->ServerBox->removeItem(page6->ServerBox->currentItem());
639
		defaultDeleted=true;
583
page6->ServerBox->setSelected(0,true);
640
	page6->ServerBox->removeItem(page6->ServerBox->currentItem());
584
if (defaultDeleted) page6->ServerBox->changeItem(page6->ServerBox->currentText().section(" ",0,0)+" "+i18n("(Default)"),0);
641
	page6->ServerBox->setSelected(0,true);
642
	if (defaultDeleted) 
643
		page6->ServerBox->changeItem(page6->ServerBox->currentText().section(" ",0,0)+" "+i18n("(Default)"),0);
585
}
644
}
586
645
587
void kgpgOptions::slotDefaultKeyServer()
646
void kgpgOptions::slotDefaultKeyServer()
588
{
647
{
589
uint curr=page6->ServerBox->currentItem();
648
	uint curr=page6->ServerBox->currentItem();
590
page6->ServerBox->changeItem(page6->ServerBox->currentText ().section(" ",0,0)+" "+i18n("(Default)"),curr);
649
	page6->ServerBox->changeItem(page6->ServerBox->currentText ().section(" ",0,0)+" "+i18n("(Default)"),curr);
591
650
592
for (uint i=0;i<page6->ServerBox->count();i++)
651
	for (uint i=0;i<page6->ServerBox->count();i++)
593
{
652
	{
594
if (i!=curr)
653
		if (i!=curr)
595
page6->ServerBox->changeItem(page6->ServerBox->text(i).section(" ",0,0),i);
654
			page6->ServerBox->changeItem(page6->ServerBox->text(i).section(" ",0,0),i);
596
}
655
	}
597
page6->ServerBox->setSelected(curr,true);
656
	page6->ServerBox->setSelected(curr,true);
598
}
657
}
599
658
600
#include "kgpgoptions.moc"
659
#include "kgpgoptions.moc"
(-)tdeutils.orig/kgpg/kgpgoptions.h (-1 / +1 lines)
Lines 60-66 Link Here
60
	TQPixmap pixkeySingle,pixkeyDouble;
60
	TQPixmap pixkeySingle,pixkeyDouble;
61
        TQString fileEncryptionKey;
61
        TQString fileEncryptionKey;
62
        TQString gpgConfigPath;
62
        TQString gpgConfigPath;
63
        TQString keyServer,defaultServerList;
63
        TQString defaultServerList;
64
        TQString defaultKeyServer;
64
        TQString defaultKeyServer;
65
	TQFont startFont;
65
	TQFont startFont;
66
        bool useAgent;
66
        bool useAgent;
(-)tdeutils.orig/kgpg/listkeys.cpp (-191 / +553 lines)
Lines 4-9 Link Here
4
    begin                : Thu Jul 4 2002
4
    begin                : Thu Jul 4 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 47-52 Link Here
47
#include <tqtoolbutton.h>
51
#include <tqtoolbutton.h>
48
#include <tqradiobutton.h>
52
#include <tqradiobutton.h>
49
#include <tqpopupmenu.h>
53
#include <tqpopupmenu.h>
54
#include <tqcursor.h>
50
55
51
#include <kurlrequester.h>
56
#include <kurlrequester.h>
52
#include <tdeio/netaccess.h>
57
#include <tdeio/netaccess.h>
Lines 216-222 Link Here
216
KgpgSelKey::KgpgSelKey(TQWidget *parent, const char *name,bool allowMultipleSelection, TQString preselected):
221
KgpgSelKey::KgpgSelKey(TQWidget *parent, const char *name,bool allowMultipleSelection, TQString preselected):
217
KDialogBase( parent, name, true,i18n("Private Key List"),Ok | Cancel)
222
KDialogBase( parent, name, true,i18n("Private Key List"),Ok | Cancel)
218
{
223
{
219
        TQString keyname;
224
// not used ???        TQString keyname;
220
        page = new TQWidget(this);
225
        page = new TQWidget(this);
221
        TQLabel *labeltxt;
226
        TQLabel *labeltxt;
222
        TDEIconLoader *loader = TDEGlobal::iconLoader();
227
        TDEIconLoader *loader = TDEGlobal::iconLoader();
Lines 239-266 Link Here
239
        if (preselected==TQString()) preselected = KGpgSettings::defaultKey();
244
        if (preselected==TQString()) preselected = KGpgSettings::defaultKey();
240
245
241
        FILE *fp,*fp2;
246
        FILE *fp,*fp2;
242
        TQString fullname,tst,tst2;
243
        char line[300];
247
        char line[300];
244
248
245
        bool selectedok=false;
249
        bool selectedok=false;
246
	bool warn=false;
250
	bool warn=false;
247
	TDEListViewItem *item;
251
	TQString currentKey;
252
	TQMap<TQString,TQStringList> hashMap;
248
253
249
        fp = popen("gpg --no-tty --with-colons --list-secret-keys", "r");
254
        fp = popen("gpg --no-tty --with-colons --list-secret-keys", "r");
250
        while ( fgets( line, sizeof(line), fp)) {
255
        while ( fgets( line, sizeof(line), fp)) {
251
                tst=TQString::fromUtf8(line);
256
                TQString tst=TQString::fromUtf8(line);
252
                if (tst.startsWith("sec")) {
257
//        //	kdDebug(2100) << k_funcinfo << "Read one secret key line: " << tst << endl;
258
                if ( tst.startsWith("sec")  ) {
259
                	currentKey = tst.section(':',4,4);
260
                	TQStringList lst; lst << tst;
261
			hashMap.insert(currentKey,lst);
262
                }
263
		else
264
			hashMap.find(currentKey).data().append(tst);
265
266
	}
267
	pclose(fp);
268
269
// process the list
270
271
	TQMap<TQString,TQStringList>::Iterator ite;
272
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
273
		TDEListViewItem *item;
274
		TQStringList::Iterator it;
275
		bool dead = true;	
276
		TQString fullname,val,id;
277
278
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
279
			TQString tst =  (*it);
253
                        TQStringList keyString=TQStringList::split(":",tst,true);
280
                        TQStringList keyString=TQStringList::split(":",tst,true);
254
                        TQString val=keyString[6];
281
			if (tst.startsWith("sec")) {		
255
                        TQString id=TQString("0x"+keyString[4].right(8));
282
				val=keyString[6];
283
				id=TQString("0x"+keyString[4].right(8));
256
                        if (val.isEmpty())
284
                        if (val.isEmpty())
257
                                val=i18n("Unlimited");
285
                                val=i18n("Unlimited");
258
                        fullname=keyString[9];
286
                        fullname=keyString[9];
259
287
260
                        fp2 = popen(TQFile::encodeName(TQString("gpg --no-tty --with-colons --list-key %1").arg(KShellProcess::quote(id))), "r");
288
                        fp2 = popen(TQFile::encodeName(TQString("gpg --no-tty --with-colons --list-key %1").arg(KShellProcess::quote(id))), "r");
261
                        bool dead=true;
289
				dead=true;
262
                        while ( fgets( line, sizeof(line), fp2)) {
290
                        while ( fgets( line, sizeof(line), fp2)) {
263
                                tst2=TQString::fromUtf8(line);
291
					TQString tst2=TQString::fromUtf8(line);
264
                                if (tst2.startsWith("pub")) {
292
                                if (tst2.startsWith("pub")) {
265
                         const TQString trust2=tst2.section(':',1,1);
293
                         const TQString trust2=tst2.section(':',1,1);
266
                        switch( trust2[0] ) {
294
                        switch( trust2[0] ) {
Lines 282-287 Link Here
282
                                }
310
                                }
283
                        }
311
                        }
284
                        pclose(fp2);
312
                        pclose(fp2);
313
			}
314
			if ( tst.startsWith("uid") && fullname.isEmpty() )
315
				fullname = tst.section(':',9,9);
316
317
                }
318
285
                        if (!fullname.isEmpty() && (!dead)) {
319
                        if (!fullname.isEmpty() && (!dead)) {
286
			TQString keyMail,keyName;
320
			TQString keyMail,keyName;
287
			if (fullname.find("<")!=-1) {
321
			if (fullname.find("<")!=-1) {
Lines 295-301 Link Here
295
329
296
        		keyName=KgpgInterface::checkForUtf8(keyName);
330
        		keyName=KgpgInterface::checkForUtf8(keyName);
297
331
298
299
                                item=new TDEListViewItem(keysListpr,keyName,keyMail,id);
332
                                item=new TDEListViewItem(keysListpr,keyName,keyMail,id);
300
                                //TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, expiration: %3").arg(id).arg(trust).arg(val));
333
                                //TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, expiration: %3").arg(id).arg(trust).arg(val));
301
				TDEListViewItem *sub= new TDEListViewItem(item,i18n("Expiration:"),val);
334
				TDEListViewItem *sub= new TDEListViewItem(item,i18n("Expiration:"),val);
Lines 308-315 Link Here
308
                                }
341
                                }
309
                        }
342
                        }
310
                }
343
                }
311
        }
312
        pclose(fp);
313
344
314
	if (warn)
345
	if (warn)
315
	{
346
	{
Lines 395-400 Link Here
395
KeyView::KeyView( TQWidget *parent, const char *name )
426
KeyView::KeyView( TQWidget *parent, const char *name )
396
                : TDEListView( parent, name )
427
                : TDEListView( parent, name )
397
{
428
{
429
// //	kdDebug(2100) << k_funcinfo << endl;
398
        TDEIconLoader *loader = TDEGlobal::iconLoader();
430
        TDEIconLoader *loader = TDEGlobal::iconLoader();
399
431
400
        pixkeyOrphan=loader->loadIcon("kgpg_key4",TDEIcon::Small,20);
432
        pixkeyOrphan=loader->loadIcon("kgpg_key4",TDEIcon::Small,20);
Lines 434-439 Link Here
434
466
435
void  KeyView::droppedfile (KURL url)
467
void  KeyView::droppedfile (KURL url)
436
{
468
{
469
// //	kdDebug(2100) << k_funcinfo << endl;
437
        if (KMessageBox::questionYesNo(this,i18n("<p>Do you want to import file <b>%1</b> into your key ring?</p>").arg(url.path()), TQString(), i18n("Import"), i18n("Do Not Import"))!=KMessageBox::Yes)
470
        if (KMessageBox::questionYesNo(this,i18n("<p>Do you want to import file <b>%1</b> into your key ring?</p>").arg(url.path()), TQString(), i18n("Import"), i18n("Do Not Import"))!=KMessageBox::Yes)
438
                return;
471
                return;
439
472
Lines 479-502 Link Here
479
mySearchLine::mySearchLine(TQWidget *parent, KeyView *listView, const char *name)
512
mySearchLine::mySearchLine(TQWidget *parent, KeyView *listView, const char *name)
480
:TDEListViewSearchLine(parent,listView,name)
513
:TDEListViewSearchLine(parent,listView,name)
481
{
514
{
482
searchListView=listView;
515
	searchListView=listView;
483
setKeepParentsVisible(false);
516
	setKeepParentsVisible(false);
484
}
517
}
485
518
486
mySearchLine::~ mySearchLine()
519
mySearchLine::~ mySearchLine()
487
{}
520
{}
488
521
489
490
bool mySearchLine::itemMatches(const TQListViewItem *item, const TQString & s) const
522
bool mySearchLine::itemMatches(const TQListViewItem *item, const TQString & s) const
491
{
523
{
492
if (item->depth()!=0) return true;
524
if (item->depth()!=0) return true;
493
else return TDEListViewSearchLine::itemMatches(item,s);
525
else return TDEListViewSearchLine::itemMatches(item,s);
494
}
526
}
495
527
496
497
498
void mySearchLine::updateSearch(const TQString& s)
528
void mySearchLine::updateSearch(const TQString& s)
499
{
529
{
530
// //	kdDebug(2100) << k_funcinfo << endl;
500
    TDEListViewSearchLine::updateSearch(s);
531
    TDEListViewSearchLine::updateSearch(s);
501
    if (searchListView->displayOnlySecret || !searchListView->displayDisabled)
532
    if (searchListView->displayOnlySecret || !searchListView->displayDisabled)
502
    {
533
    {
Lines 521-528 Link Here
521
552
522
listKeys::listKeys(TQWidget *parent, const char *name) : DCOPObject( "KeyInterface" ), TDEMainWindow(parent, name,0)
553
listKeys::listKeys(TQWidget *parent, const char *name) : DCOPObject( "KeyInterface" ), TDEMainWindow(parent, name,0)
523
{
554
{
555
// //	kdDebug(2100) << k_funcinfo << endl;
524
        //KWin::setType(TQt::WDestructiveClose);
556
        //KWin::setType(TQt::WDestructiveClose);
525
557
558
526
        keysList2 = new KeyView(this);
559
        keysList2 = new KeyView(this);
527
        keysList2->photoKeysList=TQString();
560
        keysList2->photoKeysList=TQString();
528
        keysList2->groupNb=0;
561
        keysList2->groupNb=0;
Lines 725-730 Link Here
725
        connect(s_kgpgEditor,TQT_SIGNAL(refreshImported(TQStringList)),keysList2,TQT_SLOT(slotReloadKeys(TQStringList)));
758
        connect(s_kgpgEditor,TQT_SIGNAL(refreshImported(TQStringList)),keysList2,TQT_SLOT(slotReloadKeys(TQStringList)));
726
        connect(this,TQT_SIGNAL(fontChanged(TQFont)),s_kgpgEditor,TQT_SLOT(slotSetFont(TQFont)));
759
        connect(this,TQT_SIGNAL(fontChanged(TQFont)),s_kgpgEditor,TQT_SLOT(slotSetFont(TQFont)));
727
        connect(s_kgpgEditor->view->editor,TQT_SIGNAL(refreshImported(TQStringList)),keysList2,TQT_SLOT(slotReloadKeys(TQStringList)));
760
        connect(s_kgpgEditor->view->editor,TQT_SIGNAL(refreshImported(TQStringList)),keysList2,TQT_SLOT(slotReloadKeys(TQStringList)));
761
762
763
//	kdDebug(2100) << k_funcinfo << "getGpgversion" << KgpgInterface::getGpgVersion() <<endl;
728
}
764
}
729
765
730
766
Lines 849-854 Link Here
849
885
850
void listKeys::refreshKeyFromServer()
886
void listKeys::refreshKeyFromServer()
851
{
887
{
888
// //	kdDebug(2100) << k_funcinfo << endl;
852
        if (keysList2->currentItem()==NULL)
889
        if (keysList2->currentItem()==NULL)
853
                return;
890
                return;
854
        TQString keyIDS;
891
        TQString keyIDS;
Lines 874-879 Link Here
874
911
875
void listKeys::refreshFinished()
912
void listKeys::refreshFinished()
876
{
913
{
914
// //	kdDebug(2100) << k_funcinfo << endl;
877
        if (kServer)
915
        if (kServer)
878
                kServer=0L;
916
                kServer=0L;
879
917
Lines 902-907 Link Here
902
940
903
void listKeys::slotregenerate()
941
void listKeys::slotregenerate()
904
{
942
{
943
// //	kdDebug(2100) << k_funcinfo << endl;
905
        FILE *fp;
944
        FILE *fp;
906
        TQString tst;
945
        TQString tst;
907
        char line[300];
946
        char line[300];
Lines 1029-1034 Link Here
1029
1068
1030
void listKeys::findKey()
1069
void listKeys::findKey()
1031
{
1070
{
1071
 ////	kdDebug(2100) << k_funcinfo << endl;
1032
        KFindDialog fd(this,"find_dialog",0,"");
1072
        KFindDialog fd(this,"find_dialog",0,"");
1033
        if ( fd.exec() != TQDialog::Accepted )
1073
        if ( fd.exec() != TQDialog::Accepted )
1034
                return;
1074
                return;
Lines 1039-1044 Link Here
1039
1079
1040
void listKeys::findFirstKey()
1080
void listKeys::findFirstKey()
1041
{
1081
{
1082
// //	kdDebug(2100) << k_funcinfo << endl;
1042
        if (searchString.isEmpty())
1083
        if (searchString.isEmpty())
1043
                return;
1084
                return;
1044
        bool foundItem=true;
1085
        bool foundItem=true;
Lines 1075-1080 Link Here
1075
1116
1076
void listKeys::findNextKey()
1117
void listKeys::findNextKey()
1077
{
1118
{
1119
// //	kdDebug(2100) << k_funcinfo << endl;
1078
				//kdDebug(2100)<<"find next"<<endl;
1120
				//kdDebug(2100)<<"find next"<<endl;
1079
        if (searchString.isEmpty()) {
1121
        if (searchString.isEmpty()) {
1080
                findKey();
1122
                findKey();
Lines 1119-1124 Link Here
1119
1161
1120
void listKeys::addToKAB()
1162
void listKeys::addToKAB()
1121
{
1163
{
1164
// //	kdDebug(2100) << k_funcinfo << endl;
1122
        TDEABC::Key key;
1165
        TDEABC::Key key;
1123
	if (!keysList2->currentItem()) return;
1166
	if (!keysList2->currentItem()) return;
1124
        //TQString email=extractKeyMail(keysList2->currentItem()).stripWhiteSpace();
1167
        //TQString email=extractKeyMail(keysList2->currentItem()).stripWhiteSpace();
Lines 1200-1205 Link Here
1200
1243
1201
void listKeys::showKeyServer()
1244
void listKeys::showKeyServer()
1202
{
1245
{
1246
// //	kdDebug(2100) << k_funcinfo << endl;
1203
        keyServer *ks=new keyServer(this);
1247
        keyServer *ks=new keyServer(this);
1204
	connect(ks,TQT_SIGNAL( importFinished(TQString) ) , keysList2, TQT_SLOT(refreshcurrentkey(TQString)));
1248
	connect(ks,TQT_SIGNAL( importFinished(TQString) ) , keysList2, TQT_SLOT(refreshcurrentkey(TQString)));
1205
        ks->exec();
1249
        ks->exec();
Lines 1211-1216 Link Here
1211
1255
1212
void listKeys::checkList()
1256
void listKeys::checkList()
1213
{
1257
{
1258
// //	kdDebug(2100) << k_funcinfo << endl;
1214
        TQPtrList<TQListViewItem> exportList=keysList2->selectedItems();
1259
        TQPtrList<TQListViewItem> exportList=keysList2->selectedItems();
1215
        if (exportList.count()>1)
1260
        if (exportList.count()>1)
1216
                {
1261
                {
Lines 1266-1271 Link Here
1266
void listKeys::readOptions()
1311
void listKeys::readOptions()
1267
{
1312
{
1268
1313
1314
//	kdDebug(2100) << k_funcinfo << endl;
1269
        clipboardMode=TQClipboard::Clipboard;
1315
        clipboardMode=TQClipboard::Clipboard;
1270
        if (KGpgSettings::useMouseSelection() && (kapp->clipboard()->supportsSelection()))
1316
        if (KGpgSettings::useMouseSelection() && (kapp->clipboard()->supportsSelection()))
1271
                clipboardMode=TQClipboard::Selection;
1317
                clipboardMode=TQClipboard::Selection;
Lines 1488-1493 Link Here
1488
1534
1489
void listKeys::slotexport()
1535
void listKeys::slotexport()
1490
{
1536
{
1537
// //	kdDebug(2100) << k_funcinfo << endl;
1491
        /////////////////////  export key
1538
        /////////////////////  export key
1492
        if (keysList2->currentItem()==NULL)
1539
        if (keysList2->currentItem()==NULL)
1493
                return;
1540
                return;
Lines 1599-1604 Link Here
1599
1646
1600
void listKeys::showKeyInfo(TQString keyID)
1647
void listKeys::showKeyInfo(TQString keyID)
1601
{
1648
{
1649
////	kdDebug(2100) << k_funcinfo << endl;
1602
        KgpgKeyInfo *opts=new KgpgKeyInfo(this,"key_props",keyID);
1650
        KgpgKeyInfo *opts=new KgpgKeyInfo(this,"key_props",keyID);
1603
        opts->show();
1651
        opts->show();
1604
}
1652
}
Lines 1606-1621 Link Here
1606
1654
1607
void listKeys::slotShowPhoto()
1655
void listKeys::slotShowPhoto()
1608
{
1656
{
1657
// //	kdDebug(2100) << k_funcinfo << endl;
1609
        TDETrader::OfferList offers = TDETrader::self()->query("image/jpeg", "Type == 'Application'");
1658
        TDETrader::OfferList offers = TDETrader::self()->query("image/jpeg", "Type == 'Application'");
1610
        KService::Ptr ptr = offers.first();
1659
        KService::Ptr ptr = offers.first();
1611
        //KMessageBox::sorry(0,ptr->desktopEntryName());
1660
        //KMessageBox::sorry(0,ptr->desktopEntryName());
1612
        KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
1661
        KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
1613
        *p<<"gpg"<<"--no-tty"<<"--photo-viewer"<<TQString(TQFile::encodeName(ptr->desktopEntryName()+" %i"))<<"--edit-key"<<keysList2->currentItem()->parent()->text(6)<<"uid"<<keysList2->currentItem()->text(6)<<"showphoto"<<"quit";
1662
        *p<<"gpg"<<"--no-tty"
1663
        	<<"--photo-viewer"<<TQString(TQFile::encodeName(ptr->desktopEntryName()+" %i"))
1664
        	<<"--edit-key"<<keysList2->currentItem()->parent()->text(6)
1665
		<<"uid"<<keysList2->currentItem()->text(6)
1666
		<<"showphoto"<<"quit";
1614
        p->start(TDEProcess::DontCare,true);
1667
        p->start(TDEProcess::DontCare,true);
1615
}
1668
}
1616
1669
1617
void listKeys::listsigns()
1670
void listKeys::listsigns()
1618
{
1671
{
1672
// //	kdDebug(2100) << k_funcinfo << endl;
1619
        //kdDebug(2100)<<"Edit -------------------------------"<<endl;
1673
        //kdDebug(2100)<<"Edit -------------------------------"<<endl;
1620
        if (keysList2->currentItem()==NULL)
1674
        if (keysList2->currentItem()==NULL)
1621
                return;
1675
                return;
Lines 1646-1651 Link Here
1646
1700
1647
void listKeys::groupAdd()
1701
void listKeys::groupAdd()
1648
{
1702
{
1703
// //	kdDebug(2100) << k_funcinfo << endl;
1649
        TQPtrList<TQListViewItem> addList=gEdit->availableKeys->selectedItems();
1704
        TQPtrList<TQListViewItem> addList=gEdit->availableKeys->selectedItems();
1650
        for ( uint i = 0; i < addList.count(); ++i )
1705
        for ( uint i = 0; i < addList.count(); ++i )
1651
                if ( addList.at(i) ) {
1706
                if ( addList.at(i) ) {
Lines 1655-1660 Link Here
1655
1710
1656
void listKeys::groupRemove()
1711
void listKeys::groupRemove()
1657
{
1712
{
1713
// //	kdDebug(2100) << k_funcinfo << endl;
1658
        TQPtrList<TQListViewItem> remList=gEdit->groupKeys->selectedItems();
1714
        TQPtrList<TQListViewItem> remList=gEdit->groupKeys->selectedItems();
1659
        for ( uint i = 0; i < remList.count(); ++i )
1715
        for ( uint i = 0; i < remList.count(); ++i )
1660
                if ( remList.at(i) ) {
1716
                if ( remList.at(i) ) {
Lines 1664-1669 Link Here
1664
1720
1665
void listKeys::deleteGroup()
1721
void listKeys::deleteGroup()
1666
{
1722
{
1723
// //	kdDebug(2100) << k_funcinfo << endl;
1667
        if (!keysList2->currentItem() || !keysList2->currentItem()->text(6).isEmpty())
1724
        if (!keysList2->currentItem() || !keysList2->currentItem()->text(6).isEmpty())
1668
                return;
1725
                return;
1669
1726
Lines 1686-1691 Link Here
1686
1743
1687
void listKeys::groupChange()
1744
void listKeys::groupChange()
1688
{
1745
{
1746
// //	kdDebug(2100) << k_funcinfo << endl;
1689
        TQStringList selected;
1747
        TQStringList selected;
1690
        TQListViewItem *item=gEdit->groupKeys->firstChild();
1748
        TQListViewItem *item=gEdit->groupKeys->firstChild();
1691
        while (item) {
1749
        while (item) {
Lines 1697-1702 Link Here
1697
1755
1698
void listKeys::createNewGroup()
1756
void listKeys::createNewGroup()
1699
{
1757
{
1758
// //	kdDebug(2100) << k_funcinfo << endl;
1700
        TQStringList badkeys,keysGroup;
1759
        TQStringList badkeys,keysGroup;
1701
1760
1702
        if (keysList2->selectedItems().count()>0) {
1761
        if (keysList2->selectedItems().count()>0) {
Lines 1745-1751 Link Here
1745
1804
1746
void listKeys::groupInit(TQStringList keysGroup)
1805
void listKeys::groupInit(TQStringList keysGroup)
1747
{
1806
{
1748
        kdDebug(2100)<<"preparing group"<<endl;
1807
// //	kdDebug(2100) << k_funcinfo << endl;
1808
//	kdDebug(2100)<<"preparing group"<<endl;
1749
        TQStringList lostKeys;
1809
        TQStringList lostKeys;
1750
        bool foundId;
1810
        bool foundId;
1751
1811
Lines 1754-1760 Link Here
1754
                TQListViewItem *item=gEdit->availableKeys->firstChild();
1814
                TQListViewItem *item=gEdit->availableKeys->firstChild();
1755
                foundId=false;
1815
                foundId=false;
1756
                while (item) {
1816
                while (item) {
1757
                        kdDebug(2100)<<"Searching in key: "<<item->text(0)<<endl;
1817
                //	kdDebug(2100)<<"Searching in key: "<<item->text(0)<<endl;
1758
                        if (TQString(*it).right(8).lower()==item->text(2).right(8).lower()) {
1818
                        if (TQString(*it).right(8).lower()==item->text(2).right(8).lower()) {
1759
                                gEdit->groupKeys->insertItem(item);
1819
                                gEdit->groupKeys->insertItem(item);
1760
                                foundId=true;
1820
                                foundId=true;
Lines 1771-1776 Link Here
1771
1831
1772
void listKeys::editGroup()
1832
void listKeys::editGroup()
1773
{
1833
{
1834
// //	kdDebug(2100) << k_funcinfo << endl;
1774
  if (!keysList2->currentItem() || !keysList2->currentItem()->text(6).isEmpty())
1835
  if (!keysList2->currentItem() || !keysList2->currentItem()->text(6).isEmpty())
1775
                return;
1836
                return;
1776
        TQStringList keysGroup;
1837
        TQStringList keysGroup;
Lines 1826-1831 Link Here
1826
1887
1827
void listKeys::signkey()
1888
void listKeys::signkey()
1828
{
1889
{
1890
// >> HERE
1891
//	kdDebug(2100) << k_funcinfo << endl;
1829
        ///////////////  sign a key
1892
        ///////////////  sign a key
1830
        if (keysList2->currentItem()==NULL)
1893
        if (keysList2->currentItem()==NULL)
1831
                return;
1894
                return;
Lines 1833-1849 Link Here
1833
                return;
1896
                return;
1834
1897
1835
        signList=keysList2->selectedItems();
1898
        signList=keysList2->selectedItems();
1899
1900
       for ( uint i = 0; i < signList.count(); ++i ) {
1901
	//	kdDebug(2100) << k_funcinfo << "List at: " << signList.at(i)->text(6) << endl;
1902
	}
1903
1836
        bool keyDepth=true;
1904
        bool keyDepth=true;
1837
        for ( uint i = 0; i < signList.count(); ++i )
1905
        for ( uint i = 0; i < signList.count(); ++i ) {
1838
                if ( signList.at(i) )
1906
                if ( signList.at(i) )
1839
                        if (signList.at(i)->depth()!=0)
1907
                        if (signList.at(i)->depth()!=0)
1840
                                keyDepth=false;
1908
                                keyDepth=false;
1909
	//	kdDebug(2100) << k_funcinfo << "List at: " << signList.at(i)->text(6) << endl;
1910
	}
1841
        if (!keyDepth) {
1911
        if (!keyDepth) {
1842
                KMessageBox::sorry(this,i18n("You can only sign primary keys. Please check your selection."));
1912
                KMessageBox::sorry(this,i18n("You can only sign primary keys. Please check your selection."));
1843
                return;
1913
                return;
1844
        }
1914
        }
1845
1915
1846
1847
        if (signList.count()==1) {
1916
        if (signList.count()==1) {
1848
                FILE *pass;
1917
                FILE *pass;
1849
                char line[200]="";
1918
                char line[200]="";
Lines 1859-1864 Link Here
1859
                                if ((len > 0) && (len % 4 == 0))
1928
                                if ((len > 0) && (len % 4 == 0))
1860
                                        for (uint n = 0; 4*(n+1) < len; n++)
1929
                                        for (uint n = 0; 4*(n+1) < len; n++)
1861
                                                fingervalue.insert(5*n+4, ' ');
1930
                                                fingervalue.insert(5*n+4, ' ');
1931
			break;
1862
                        }
1932
                        }
1863
                }
1933
                }
1864
                pclose(pass);
1934
                pclose(pass);
Lines 1916-1921 Link Here
1916
        keyCount=0;
1986
        keyCount=0;
1917
        delete opts;
1987
        delete opts;
1918
        globalCount=signList.count();
1988
        globalCount=signList.count();
1989
1990
//	kdDebug(2100) << k_funcinfo << "Terminal sign checked: " << terminalSign->isChecked() << endl;
1991
//	kdDebug(2100) << k_funcinfo << "globalCount          : " << globalCount << endl;
1992
//	kdDebug(2100) << k_funcinfo << "signList Count       : " << globalCount << endl;
1993
1919
        if (!terminalSign->isChecked())
1994
        if (!terminalSign->isChecked())
1920
                signLoop();
1995
                signLoop();
1921
        else {
1996
        else {
Lines 1924-1949 Link Here
1924
                TDEConfig *config = TDEGlobal::config();
1999
                TDEConfig *config = TDEGlobal::config();
1925
                config->setGroup("General");
2000
                config->setGroup("General");
1926
                kp<< config->readPathEntry("TerminalApplication","konsole");
2001
                kp<< config->readPathEntry("TerminalApplication","konsole");
1927
                kp<<"-e"
2002
                kp<<"-e" <<"gpg" <<"--no-secmem-warning" 
1928
                <<"gpg"
2003
			<<"-u" <<globalkeyID <<"--edit-key" <<signList.at(0)->text(6);
1929
                <<"--no-secmem-warning"
1930
                <<"-u"
1931
                <<globalkeyID
1932
                <<"--edit-key"
1933
                <<signList.at(0)->text(6);
1934
                if (globalisLocal)
2004
                if (globalisLocal)
1935
                        kp<<"lsign";
2005
                        kp<<"lsign";
1936
                else
2006
                else
1937
                        kp<<"sign";
2007
                        kp<<"sign";
2008
 
2009
		TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
1938
                kp.start(TDEProcess::Block);
2010
                kp.start(TDEProcess::Block);
1939
                keysList2->refreshcurrentkey(keysList2->currentItem());
2011
                keysList2->refreshcurrentkey(keysList2->currentItem());
2012
		TQApplication::restoreOverrideCursor();
1940
        }
2013
        }
1941
}
2014
}
1942
2015
1943
void listKeys::signLoop()
2016
void listKeys::signLoop()
1944
{
2017
{
2018
2019
// >> HERE
2020
//	kdDebug(2100) << k_funcinfo << endl;
1945
        if (keyCount<globalCount) {
2021
        if (keyCount<globalCount) {
1946
                kdDebug(2100)<<"Sign process for key: "<<keyCount<<" on a total of "<<signList.count()<<endl;
2022
        //	kdDebug(2100)<<"Sign process for key: "<<keyCount<<" on a total of "<<signList.count()<<endl;
1947
                if ( signList.at(keyCount) ) {
2023
                if ( signList.at(keyCount) ) {
1948
                        KgpgInterface *signKeyProcess=new KgpgInterface();
2024
                        KgpgInterface *signKeyProcess=new KgpgInterface();
1949
			TQObject::connect(signKeyProcess,TQT_SIGNAL(signatureFinished(int)),TQT_TQOBJECT(this),TQT_SLOT(signatureResult(int)));
2025
			TQObject::connect(signKeyProcess,TQT_SIGNAL(signatureFinished(int)),TQT_TQOBJECT(this),TQT_SLOT(signatureResult(int)));
Lines 1954-1962 Link Here
1954
2030
1955
void listKeys::signatureResult(int success)
2031
void listKeys::signatureResult(int success)
1956
{
2032
{
1957
        if (success==3)
2033
//	kdDebug(2100) << k_funcinfo << endl;
2034
//	kdDebug(2100) << k_funcinfo << "success" << success << endl;
2035
        if ( success>=3 )
1958
                keysList2->refreshcurrentkey(signList.at(keyCount));
2036
                keysList2->refreshcurrentkey(signList.at(keyCount));
1959
1960
        else if (success==2)
2037
        else if (success==2)
1961
                KMessageBox::sorry(this,i18n("<qt>Bad passphrase, key <b>%1</b> not signed.</qt>").arg(signList.at(keyCount)->text(0)+i18n(" (")+signList.at(keyCount)->text(1)+i18n(")")));
2038
                KMessageBox::sorry(this,i18n("<qt>Bad passphrase, key <b>%1</b> not signed.</qt>").arg(signList.at(keyCount)->text(0)+i18n(" (")+signList.at(keyCount)->text(1)+i18n(")")));
1962
2039
Lines 1967-1972 Link Here
1967
2044
1968
void listKeys::importallsignkey()
2045
void listKeys::importallsignkey()
1969
{
2046
{
2047
////	kdDebug(2100) << k_funcinfo << endl;
1970
        if (keysList2->currentItem()==NULL)
2048
        if (keysList2->currentItem()==NULL)
1971
                return;
2049
                return;
1972
        if (! keysList2->currentItem()->firstChild()) {
2050
        if (! keysList2->currentItem()->firstChild()) {
Lines 1989-1994 Link Here
1989
2067
1990
void listKeys::preimportsignkey()
2068
void listKeys::preimportsignkey()
1991
{
2069
{
2070
// //	kdDebug(2100) << k_funcinfo << endl;
1992
        if (keysList2->currentItem()==NULL)
2071
        if (keysList2->currentItem()==NULL)
1993
                return;
2072
                return;
1994
        else
2073
        else
Lines 1997-2003 Link Here
1997
2076
1998
bool listKeys::importRemoteKey(TQString keyID)
2077
bool listKeys::importRemoteKey(TQString keyID)
1999
{
2078
{
2000
2079
//	kdDebug(2100) << k_funcinfo << endl;
2001
        kServer=new keyServer(0,"server_dialog",false,true);
2080
        kServer=new keyServer(0,"server_dialog",false,true);
2002
        kServer->page->kLEimportid->setText(keyID);
2081
        kServer->page->kLEimportid->setText(keyID);
2003
        kServer->page->Buttonimport->setDefault(true);
2082
        kServer->page->Buttonimport->setDefault(true);
Lines 2013-2018 Link Here
2013
2092
2014
void listKeys::dcopImportFinished()
2093
void listKeys::dcopImportFinished()
2015
{
2094
{
2095
//	kdDebug(2100) << k_funcinfo << endl;
2016
        if (kServer)
2096
        if (kServer)
2017
                kServer=0L;
2097
                kServer=0L;
2018
    TQByteArray params;
2098
    TQByteArray params;
Lines 2024-2034 Link Here
2024
2104
2025
void listKeys::importsignkey(TQString importKeyId)
2105
void listKeys::importsignkey(TQString importKeyId)
2026
{
2106
{
2107
//	kdDebug(2100) << k_funcinfo << endl;
2027
        ///////////////  sign a key
2108
        ///////////////  sign a key
2028
        kServer=new keyServer(0,"server_dialog",false);
2109
        kServer=new keyServer(0,"server_dialog",false);
2029
        kServer->page->kLEimportid->setText(importKeyId);
2110
        kServer->page->kLEimportid->setText(importKeyId);
2030
        //kServer->Buttonimport->setDefault(true);
2111
        //kServer->Buttonimport->setDefault(true);
2031
        kServer->slotImport();
2112
        kServer->slotImport();
2113
//        kServer->slotSearch();
2032
        //kServer->show();
2114
        //kServer->show();
2033
        connect( kServer, TQT_SIGNAL( importFinished(TQString) ) , this, TQT_SLOT( importfinished()));
2115
        connect( kServer, TQT_SIGNAL( importFinished(TQString) ) , this, TQT_SLOT( importfinished()));
2034
}
2116
}
Lines 2036-2041 Link Here
2036
2118
2037
void listKeys::importfinished()
2119
void listKeys::importfinished()
2038
{
2120
{
2121
//	kdDebug(2100) << k_funcinfo << endl;
2039
        if (kServer)
2122
        if (kServer)
2040
                kServer=0L;
2123
                kServer=0L;
2041
        refreshkey();
2124
        refreshkey();
Lines 2044-2053 Link Here
2044
2127
2045
void listKeys::delsignkey()
2128
void listKeys::delsignkey()
2046
{
2129
{
2130
//	kdDebug(2100) << k_funcinfo << endl;
2047
        ///////////////  sign a key
2131
        ///////////////  sign a key
2048
        if (keysList2->currentItem()==NULL)
2132
        if (keysList2->currentItem()==NULL)
2049
                return;
2133
                return;
2050
        if (keysList2->currentItem()->depth()>1) {
2134
        if ( (keysList2->currentItem()->depth()>1 && KgpgInterface::getGpgVersion() < 210 ) 
2135
        	|| (keysList2->currentItem()->depth()>2 && KgpgInterface::getGpgVersion() >= 210 ) ) {
2051
                KMessageBox::sorry(this,i18n("Edit key manually to delete this signature."));
2136
                KMessageBox::sorry(this,i18n("Edit key manually to delete this signature."));
2052
                return;
2137
                return;
2053
        }
2138
        }
Lines 2055-2063 Link Here
2055
        TQString signID,parentKey,signMail,parentMail;
2140
        TQString signID,parentKey,signMail,parentMail;
2056
2141
2057
        //////////////////  open a key selection dialog (KgpgSelKey, see begining of this file)
2142
        //////////////////  open a key selection dialog (KgpgSelKey, see begining of this file)
2058
        parentKey=keysList2->currentItem()->parent()->text(6);
2143
        parentKey=( KgpgInterface::getGpgVersion() < 210 ) ? keysList2->currentItem()->parent()->text(6) : keysList2->currentItem()->parent()->parent()->text(6);
2059
        signID=keysList2->currentItem()->text(6);
2144
        signID=keysList2->currentItem()->text(6);
2060
        parentMail=keysList2->currentItem()->parent()->text(0)+" ("+keysList2->currentItem()->parent()->text(1)+")";
2145
        parentMail=( KgpgInterface::getGpgVersion() < 210 ) ? keysList2->currentItem()->parent()->text(0)+" ("+keysList2->currentItem()->parent()->text(1)+")" : keysList2->currentItem()->parent()->parent()->text(0)+" ("+keysList2->currentItem()->parent()->parent()->text(1)+")";
2061
        signMail=keysList2->currentItem()->text(0)+" ("+keysList2->currentItem()->text(1)+")";
2146
        signMail=keysList2->currentItem()->text(0)+" ("+keysList2->currentItem()->text(1)+")";
2062
2147
2063
        if (parentKey==signID) {
2148
        if (parentKey==signID) {
Lines 2075-2080 Link Here
2075
2160
2076
void listKeys::delsignatureResult(bool success)
2161
void listKeys::delsignatureResult(bool success)
2077
{
2162
{
2163
// //	kdDebug(2100) << k_funcinfo << endl;
2078
        if (success) {
2164
        if (success) {
2079
                TQListViewItem *top=keysList2->currentItem();
2165
                TQListViewItem *top=keysList2->currentItem();
2080
                while (top->depth()!=0)
2166
                while (top->depth()!=0)
Lines 2088-2093 Link Here
2088
2174
2089
void listKeys::slotedit()
2175
void listKeys::slotedit()
2090
{
2176
{
2177
// //	kdDebug(2100) << k_funcinfo << endl;
2091
        if (!keysList2->currentItem())
2178
        if (!keysList2->currentItem())
2092
                return;
2179
                return;
2093
        if (keysList2->currentItem()->depth()!=0)
2180
        if (keysList2->currentItem()->depth()!=0)
Lines 2100-2111 Link Here
2100
        TDEConfig *config = TDEGlobal::config();
2187
        TDEConfig *config = TDEGlobal::config();
2101
        config->setGroup("General");
2188
        config->setGroup("General");
2102
        kp<< config->readPathEntry("TerminalApplication","konsole");
2189
        kp<< config->readPathEntry("TerminalApplication","konsole");
2103
        kp<<"-e"
2190
        kp<<"-e" <<"gpg" <<"--no-secmem-warning" <<"--utf8-strings"
2104
        <<"gpg"
2191
		<<"--edit-key" <<keysList2->currentItem()->text(6)
2105
        <<"--no-secmem-warning"
2106
        <<"--utf8-strings"
2107
        <<"--edit-key"
2108
        <<keysList2->currentItem()->text(6)
2109
        <<"help";
2192
        <<"help";
2110
        kp.start(TDEProcess::Block);
2193
        kp.start(TDEProcess::Block);
2111
        keysList2->refreshcurrentkey(keysList2->currentItem());
2194
        keysList2->refreshcurrentkey(keysList2->currentItem());
Lines 2114-2119 Link Here
2114
2197
2115
void listKeys::slotgenkey()
2198
void listKeys::slotgenkey()
2116
{
2199
{
2200
// //	kdDebug(2100) << k_funcinfo << endl;
2117
        //////////  generate key
2201
        //////////  generate key
2118
        keyGenerate *genkey=new keyGenerate(this,0);
2202
        keyGenerate *genkey=new keyGenerate(this,0);
2119
        if (genkey->exec()==TQDialog::Accepted) {
2203
        if (genkey->exec()==TQDialog::Accepted) {
Lines 2230-2252 Link Here
2230
2314
2231
void listKeys::readgenprocess(KProcIO *p)
2315
void listKeys::readgenprocess(KProcIO *p)
2232
{
2316
{
2317
// //	kdDebug(2100) << k_funcinfo << endl;
2233
        TQString required;
2318
        TQString required;
2234
        while (p->readln(required,true)!=-1) {
2319
        while (p->readln(required,true)!=-1) {
2235
                if (required.find("KEY_CREATED")!=-1)
2320
                if (required.find("KEY_CREATED")!=-1)
2236
                        newkeyFinger=required.stripWhiteSpace().section(' ',-1);
2321
                        newkeyFinger=required.stripWhiteSpace().section(' ',-1);
2237
                message+=required+"\n";
2322
                message+=required+"\n";
2238
        }
2323
        }
2239
2240
        //  sample:   [GNUPG:] KEY_CREATED B 156A4305085A58C01E2988229282910254D1B368
2324
        //  sample:   [GNUPG:] KEY_CREATED B 156A4305085A58C01E2988229282910254D1B368
2241
}
2325
}
2242
2326
2243
void listKeys::genover(TDEProcess *)
2327
void listKeys::genover(TDEProcess *)
2244
{
2328
{
2329
// //	kdDebug(2100) << k_funcinfo << endl;
2245
        newkeyID=TQString();
2330
        newkeyID=TQString();
2246
        continueSearch=true;
2331
        continueSearch=true;
2247
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
2332
        KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale());
2333
	TQString fpropt = (KgpgInterface::getGpgVersion() < 210 ) ? "--fingerprint" : "--with-fingerprint";
2248
        *conprocess<< "gpg";
2334
        *conprocess<< "gpg";
2249
        *conprocess<<"--no-secmem-warning"<<"--with-colons"<<"--fingerprint"<<"--list-keys"<<newKeyName;
2335
	*conprocess<<"--no-secmem-warning"
2336
		<<"--with-colons"
2337
		<< fpropt
2338
		<<"--list-keys"<<newKeyName;
2250
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),TQT_TQOBJECT(this),TQT_SLOT(slotReadFingerProcess(KProcIO *)));
2339
        TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),TQT_TQOBJECT(this),TQT_SLOT(slotReadFingerProcess(KProcIO *)));
2251
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(newKeyDone(TDEProcess *)));
2340
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(newKeyDone(TDEProcess *)));
2252
        conprocess->start(TDEProcess::NotifyOnExit,true);
2341
        conprocess->start(TDEProcess::NotifyOnExit,true);
Lines 2255-2270 Link Here
2255
2344
2256
void listKeys::slotReadFingerProcess(KProcIO *p)
2345
void listKeys::slotReadFingerProcess(KProcIO *p)
2257
{
2346
{
2347
// //	kdDebug(2100) << k_funcinfo << endl;
2258
        TQString outp;
2348
        TQString outp;
2259
        while (p->readln(outp)!=-1) {
2349
        while (p->readln(outp)!=-1) {
2260
                if (outp.startsWith("pub") && (continueSearch)) {
2350
		if ( outp.startsWith("pub") && (continueSearch)) {
2261
                        newkeyID=outp.section(':',4,4).right(8).prepend("0x");
2351
                        newkeyID=outp.section(':',4,4).right(8).prepend("0x");
2262
2352
2263
                }
2353
                }
2264
                if (outp.startsWith("fpr")) {
2354
                if (outp.startsWith("fpr")) {
2265
                        if (newkeyFinger.lower()==outp.section(':',9,9).lower())
2355
                        if (newkeyFinger.lower()==outp.section(':',9,9).lower())
2266
                                continueSearch=false;
2356
                                continueSearch=false;
2267
                        //			kdDebug(2100)<<newkeyFinger<<" test:"<<outp.section(':',9,9)<<endl;
2357
			//		//	kdDebug(2100)<<newkeyFinger<<" test:"<<outp.section(':',9,9)<<endl;
2268
                }
2358
                }
2269
        }
2359
        }
2270
}
2360
}
Lines 2272-2277 Link Here
2272
2362
2273
void listKeys::newKeyDone(TDEProcess *)
2363
void listKeys::newKeyDone(TDEProcess *)
2274
{
2364
{
2365
// //	kdDebug(2100) << k_funcinfo << endl;
2275
        changeMessage(i18n("Ready"),0);
2366
        changeMessage(i18n("Ready"),0);
2276
        //        refreshkey();
2367
        //        refreshkey();
2277
        if (newkeyID.isEmpty()) {
2368
        if (newkeyID.isEmpty()) {
Lines 2321-2326 Link Here
2321
2412
2322
void listKeys::doFilePrint(TQString url)
2413
void listKeys::doFilePrint(TQString url)
2323
{
2414
{
2415
// //	kdDebug(2100) << k_funcinfo << endl;
2324
        TQFile qfile(url);
2416
        TQFile qfile(url);
2325
        if (qfile.open(IO_ReadOnly)) {
2417
        if (qfile.open(IO_ReadOnly)) {
2326
                TQTextStream t( &qfile );
2418
                TQTextStream t( &qfile );
Lines 2331-2336 Link Here
2331
2423
2332
void listKeys::doPrint(TQString txt)
2424
void listKeys::doPrint(TQString txt)
2333
{
2425
{
2426
// //	kdDebug(2100) << k_funcinfo << endl;
2334
        KPrinter prt;
2427
        KPrinter prt;
2335
        //kdDebug(2100)<<"Printing..."<<endl;
2428
        //kdDebug(2100)<<"Printing..."<<endl;
2336
        if (prt.setup(this)) {
2429
        if (prt.setup(this)) {
Lines 2355-2362 Link Here
2355
        TDEConfig *config = TDEGlobal::config();
2448
        TDEConfig *config = TDEGlobal::config();
2356
        config->setGroup("General");
2449
        config->setGroup("General");
2357
        *conprocess<< config->readPathEntry("TerminalApplication","konsole");
2450
        *conprocess<< config->readPathEntry("TerminalApplication","konsole");
2358
        *conprocess<<"-e"<<"gpg"
2451
	*conprocess<<"-e"<<"gpg" <<"--no-secmem-warning"
2359
        <<"--no-secmem-warning"
2360
        <<"--delete-secret-key"<<keysList2->currentItem()->text(6);
2452
        <<"--delete-secret-key"<<keysList2->currentItem()->text(6);
2361
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(reloadSecretKeys()));
2453
        TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),TQT_TQOBJECT(this), TQT_SLOT(reloadSecretKeys()));
2362
        conprocess->start(TDEProcess::NotifyOnExit,TDEProcess::AllOutput);
2454
        conprocess->start(TDEProcess::NotifyOnExit,TDEProcess::AllOutput);
Lines 2364-2369 Link Here
2364
2456
2365
void listKeys::reloadSecretKeys()
2457
void listKeys::reloadSecretKeys()
2366
{
2458
{
2459
// //	kdDebug(2100) << k_funcinfo << endl;
2367
        FILE *fp;
2460
        FILE *fp;
2368
        char line[300];
2461
        char line[300];
2369
        keysList2->secretList=TQString();
2462
        keysList2->secretList=TQString();
Lines 2379-2384 Link Here
2379
2472
2380
void listKeys::confirmdeletekey()
2473
void listKeys::confirmdeletekey()
2381
{
2474
{
2475
// //	kdDebug(2100) << k_funcinfo << endl;
2382
        if (keysList2->currentItem()->depth()!=0) {
2476
        if (keysList2->currentItem()->depth()!=0) {
2383
                if ((keysList2->currentItem()->depth()==1) && (keysList2->currentItem()->text(4)=="-") && (keysList2->currentItem()->text(6).startsWith("0x")))
2477
                if ((keysList2->currentItem()->depth()==1) && (keysList2->currentItem()->text(4)=="-") && (keysList2->currentItem()->text(6).startsWith("0x")))
2384
                        delsignkey();
2478
                        delsignkey();
Lines 2422-2445 Link Here
2422
2516
2423
void listKeys::deletekey()
2517
void listKeys::deletekey()
2424
{
2518
{
2519
//	kdDebug(2100) << k_funcinfo << endl;
2425
        TQPtrList<TQListViewItem> exportList=keysList2->selectedItems();
2520
        TQPtrList<TQListViewItem> exportList=keysList2->selectedItems();
2521
//	kdDebug(2100) << k_funcinfo << "Delete list count: " << exportList.count() << endl;
2426
        if (exportList.count()==0)
2522
        if (exportList.count()==0)
2427
                return;
2523
                return;
2428
        TDEProcess gp;
2524
        TDEProcess gp;
2429
        gp << "gpg"
2525
	gp << "gpg" << "--no-tty" << "--no-secmem-warning" << "--batch" << "--yes" << "--delete-key";
2430
        << "--no-tty"
2431
        << "--no-secmem-warning"
2432
        << "--batch"
2433
        << "--yes"
2434
        << "--delete-key";
2435
        for ( uint i = 0; i < exportList.count(); ++i )
2526
        for ( uint i = 0; i < exportList.count(); ++i )
2436
                if ( exportList.at(i) )
2527
                if ( exportList.at(i) )
2437
                        gp<<(exportList.at(i)->text(6)).stripWhiteSpace();
2528
                        gp<<(exportList.at(i)->text(6)).stripWhiteSpace();
2438
        gp.start(TDEProcess::Block);
2529
        gp.start(TDEProcess::Block);
2439
2530
2440
        for ( uint i = 0; i < exportList.count(); ++i )
2531
// FIXME: this produces an error when key was successfully removed
2441
                if ( exportList.at(i) )
2532
// 	for ( uint i = 0; i < exportList.count(); ++i )
2442
                        keysList2->refreshcurrentkey(exportList.at(i));
2533
// 		if ( exportList.at(i) )
2534
// 			keysList2->refreshcurrentkey(exportList.at(i));
2535
2443
        if (keysList2->currentItem()) {
2536
        if (keysList2->currentItem()) {
2444
                TQListViewItem * myChild = keysList2->currentItem();
2537
                TQListViewItem * myChild = keysList2->currentItem();
2445
                while(!myChild->isVisible()) {
2538
                while(!myChild->isVisible()) {
Lines 2460-2472 Link Here
2460
                        keysList2->setCurrentItem(myChild);
2553
                        keysList2->setCurrentItem(myChild);
2461
                }
2554
                }
2462
        }
2555
        }
2463
	else stateChanged("empty_list");
2556
	else
2557
		stateChanged("empty_list");
2558
2559
	keysList2->refreshkeylist(); // update the list to remove signitures from the deleted key
2464
        changeMessage(i18n("%1 Keys, %2 Groups").arg(keysList2->childCount()-keysList2->groupNb).arg(keysList2->groupNb),1);
2560
        changeMessage(i18n("%1 Keys, %2 Groups").arg(keysList2->childCount()-keysList2->groupNb).arg(keysList2->groupNb),1);
2465
}
2561
}
2466
2562
2467
2563
2468
void listKeys::slotPreImportKey()
2564
void listKeys::slotPreImportKey()
2469
{
2565
{
2566
// //	kdDebug(2100) << k_funcinfo << endl;
2470
        KDialogBase *dial=new KDialogBase( KDialogBase::Swallow, i18n("Key Import"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, this, "key_import",true);
2567
        KDialogBase *dial=new KDialogBase( KDialogBase::Swallow, i18n("Key Import"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, this, "key_import",true);
2471
2568
2472
        SrcSelect *page=new SrcSelect();
2569
        SrcSelect *page=new SrcSelect();
Lines 2504-2512 Link Here
2504
2601
2505
void KeyView::expandGroup(TQListViewItem *item)
2602
void KeyView::expandGroup(TQListViewItem *item)
2506
{
2603
{
2507
2604
// //	kdDebug(2100) << k_funcinfo << endl;
2508
        TQStringList keysGroup=KgpgInterface::getGpgGroupSetting(item->text(0),KGpgSettings::gpgConfigPath());
2605
        TQStringList keysGroup=KgpgInterface::getGpgGroupSetting(item->text(0),KGpgSettings::gpgConfigPath());
2509
        kdDebug(2100)<<keysGroup<<endl;
2606
//	kdDebug(2100)<<keysGroup<<endl;
2510
        for ( TQStringList::Iterator it = keysGroup.begin(); it != keysGroup.end(); ++it ) {
2607
        for ( TQStringList::Iterator it = keysGroup.begin(); it != keysGroup.end(); ++it ) {
2511
                UpdateViewItem *item2=new UpdateViewItem(item,TQString(*it),TQString(),TQString(),TQString(),TQString(),TQString(),TQString());
2608
                UpdateViewItem *item2=new UpdateViewItem(item,TQString(*it),TQString(),TQString(),TQString(),TQString(),TQString(),TQString());
2512
                item2->setPixmap(0,pixkeyGroup);
2609
                item2->setPixmap(0,pixkeyGroup);
Lines 2516-2525 Link Here
2516
2613
2517
TQPixmap KeyView::slotGetPhoto(TQString photoId,bool mini)
2614
TQPixmap KeyView::slotGetPhoto(TQString photoId,bool mini)
2518
{
2615
{
2616
// //	kdDebug(2100) << k_funcinfo << endl;
2519
        KTempFile *phototmp=new KTempFile();
2617
        KTempFile *phototmp=new KTempFile();
2520
        TQString popt="cp %i "+phototmp->name();
2618
        TQString popt="cp %i "+phototmp->name();
2521
        KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
2619
        KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
2522
        *p<<"gpg"<<"--show-photos"<<"--photo-viewer"<<TQString(TQFile::encodeName(popt))<<"--list-keys"<<photoId;
2620
	*p<<"gpg"<<"--show-photos"
2621
		<<"--photo-viewer"<<TQString(TQFile::encodeName(popt))
2622
		<<"--list-keys"<<photoId;
2523
        p->start(TDEProcess::Block);
2623
        p->start(TDEProcess::Block);
2524
2624
2525
        TQPixmap pixmap;
2625
        TQPixmap pixmap;
Lines 2538-2585 Link Here
2538
2638
2539
void KeyView::expandKey(TQListViewItem *item)
2639
void KeyView::expandKey(TQListViewItem *item)
2540
{
2640
{
2541
2641
// //	kdDebug(2100) << k_funcinfo << endl;
2542
        if (item->childCount()!=0)
2642
        if (item->childCount()!=0)
2543
                return;   // key has already been expanded
2643
                return;   // key has already been expanded
2544
        FILE *fp;
2644
        FILE *fp;
2545
        TQString cycle;
2645
2546
        TQStringList tst;
2646
2547
        char tmpline[300];
2647
        char line[300];
2648
	TQString currentKey;
2649
	TQMap<TQString,TQStringList> hashMap;
2650
//	kdDebug(2100)<<"Expanding Key: "<<item->text(6)<<endl;
2651
2652
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
2653
        fp = popen(TQFile::encodeName(TQString("gpg --no-secmem-warning --no-tty --with-colons --list-sigs "+item->text(6))), "r");
2654
2655
        while ( fgets( line, sizeof(line), fp)) {
2656
                TQString tst=TQString::fromUtf8(line);
2657
//	//	kdDebug(2100) << k_funcinfo << "Read one public sig line: " << tst;
2658
                if ( tst.startsWith("pub")  ) {
2659
                	currentKey = tst.section(':',4,4).right(8);
2660
                	TQStringList lst; lst << tst;
2661
			hashMap.insert(currentKey,lst);
2662
                }
2663
		else
2664
			hashMap.find(currentKey).data().append(tst);
2665
2666
	}
2667
	pclose(fp);
2668
2669
	TQMap<TQString,TQStringList>::Iterator ite;
2670
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
2671
		TQStringList::Iterator it;
2672
		TQString cycle="pub";
2673
		bool noID = (KgpgInterface::getGpgVersion() < 210 ) ? false : true;
2674
2548
        UpdateViewItem *itemsub=NULL;
2675
        UpdateViewItem *itemsub=NULL;
2549
        UpdateViewItem *itemuid=NULL;
2676
        UpdateViewItem *itemuid=NULL;
2550
        UpdateViewItem *itemsig=NULL;
2677
        UpdateViewItem *itemsig=NULL;
2551
        UpdateViewItem *itemrev=NULL;
2678
        UpdateViewItem *itemrev=NULL;
2552
        TQPixmap keyPhotoId;
2679
        TQPixmap keyPhotoId;
2553
        int uidNumber=2;
2680
        int uidNumber=2;
2554
        bool dropFirstUid=false;
2555
2556
        kdDebug(2100)<<"Expanding Key: "<<item->text(6)<<endl;
2557
2681
2558
        cycle="pub";
2682
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
2559
        bool noID=false;
2683
			TQString line = (*it);
2560
        fp = popen(TQFile::encodeName(TQString("gpg --no-secmem-warning --no-tty --with-colons --list-sigs "+item->text(6))), "r");
2684
			TQStringList tst=TQStringList::split(":",line,true);
2561
2685
//		//	kdDebug(2100)<<"Loop: "<< tst[0] << " : " << tst[9] <<endl;
2562
        while ( fgets( tmpline, sizeof(tmpline), fp)) {
2686
			if ((tst[0]=="pub") && (tst[9].isEmpty())) {/// Primary User Id is separated from public key
2563
                TQString line = TQString::fromUtf8( tmpline );
2687
				noID=true;
2564
                tst=TQStringList::split(":",line,true);
2688
				continue;
2565
                if ((tst[0]=="pub") && (tst[9].isEmpty())) /// Primary User Id is separated from public key
2689
			}
2566
                        uidNumber=1;
2567
                if (tst[0]=="uid" || tst[0]=="uat") {
2690
                if (tst[0]=="uid" || tst[0]=="uat") {
2568
                        if (dropFirstUid) {
2569
                                dropFirstUid=false;
2570
                        } else {
2571
                                gpgKey uidKey=extractKey(line);
2691
                                gpgKey uidKey=extractKey(line);
2572
2692
2573
                                if (tst[0]=="uat") {
2693
                                if (tst[0]=="uat") {
2574
                                        kdDebug(2100)<<"Found photo at uid "<<uidNumber<<endl;
2694
				//	kdDebug(2100)<<"Found photo at uid "<<uidNumber<<endl;
2575
                                        itemuid= new UpdateViewItem(item,i18n("Photo id"),TQString(),TQString(),"-","-","-",TQString::number(uidNumber));
2695
                                        itemuid= new UpdateViewItem(item,i18n("Photo id"),TQString(),TQString(),"-","-","-",TQString::number(uidNumber));
2576
                                        if (displayPhoto) {
2696
                                        if (displayPhoto) {
2577
                                                kgpgphototmp=new KTempFile();
2697
                                                kgpgphototmp=new KTempFile();
2578
                                                kgpgphototmp->setAutoDelete(true);
2698
                                                kgpgphototmp->setAutoDelete(true);
2579
                                                TQString pgpgOutput="cp %i "+kgpgphototmp->name();
2699
                                                TQString pgpgOutput="cp %i "+kgpgphototmp->name();
2580
                                                KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
2700
                                                KProcIO *p=new KProcIO(TQTextCodec::codecForLocale());
2581
                                                *p<<"gpg"<<"--no-tty"<<"--photo-viewer"<<TQString(TQFile::encodeName(pgpgOutput));
2701
						*p<<"gpg"<<"--no-tty"
2582
                                                *p<<"--edit-key"<<item->text(6)<<"uid"<<TQString::number(uidNumber)<<"showphoto"<<"quit";
2702
							<<"--photo-viewer"<<TQString(TQFile::encodeName(pgpgOutput))
2703
							<<"--edit-key"<<item->text(6)
2704
							<<"uid"<<TQString::number(uidNumber)
2705
							<<"showphoto"<<"quit";
2583
                                                p->start(TDEProcess::Block);
2706
                                                p->start(TDEProcess::Block);
2584
                                                TQPixmap pixmap;
2707
                                                TQPixmap pixmap;
2585
                                                pixmap.load(kgpgphototmp->name());
2708
                                                pixmap.load(kgpgphototmp->name());
Lines 2592-2626 Link Here
2592
                                        } else
2715
                                        } else
2593
                                                itemuid->setPixmap(0,pixuserphoto);
2716
                                                itemuid->setPixmap(0,pixuserphoto);
2594
                                        itemuid->setPixmap(2,uidKey.trustpic);
2717
                                        itemuid->setPixmap(2,uidKey.trustpic);
2595
                                        cycle="uid";
2596
                                } else {
2718
                                } else {
2597
                                        kdDebug(2100)<<"Found uid at "<<uidNumber<<endl;
2719
				//	kdDebug(2100)<<"Found uid at "<<uidNumber<<endl;
2598
                                        itemuid= new UpdateViewItem(item,uidKey.gpgkeyname,uidKey.gpgkeymail,TQString(),"-","-","-","-");
2720
					itemuid= new UpdateViewItem(item,uidKey.gpgkeyname,uidKey.gpgkeymail,TQString(),"-","-",uidKey.gpgkeycreation,uidKey.gpgkeyid);
2599
                                        itemuid->setPixmap(2,uidKey.trustpic);
2721
                                        itemuid->setPixmap(2,uidKey.trustpic);
2722
					// FIXME not sure if first item is oldest item - the one set when key was generated
2723
					// but in my opinion the identity of the oldest item should be assigned to the pub/main entry
2600
                                        if (noID) {
2724
                                        if (noID) {
2601
                                                item->setText(0,uidKey.gpgkeyname);
2725
                                                item->setText(0,uidKey.gpgkeyname);
2602
                                                item->setText(1,uidKey.gpgkeymail);
2726
                                                item->setText(1,uidKey.gpgkeymail);
2603
                                                noID=false;
2727
                                                noID=false;
2604
                                        }
2728
                                        }
2605
                                        itemuid->setPixmap(0,pixuserid);
2729
                                        itemuid->setPixmap(0,pixuserid);
2606
                                        cycle="uid";
2607
                                }
2608
                        }
2730
                        }
2731
				cycle="uid";
2609
                        uidNumber++;
2732
                        uidNumber++;
2610
                } else
2733
			}
2611
                        if (tst[0]=="rev") {
2734
                        if (tst[0]=="rev") {
2612
                                gpgKey revKey=extractKey(line);
2735
                                gpgKey revKey=extractKey(line);
2613
                                if (cycle=="uid" || cycle=="uat")
2736
				if (cycle=="uid")
2614
                                        itemrev= new UpdateViewItem(itemuid,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2737
                                        itemrev= new UpdateViewItem(itemuid,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2615
                                else if (cycle=="pub") { //////////////public key revoked
2738
				if (cycle=="pub") //////////////public key revoked
2616
                                        itemrev= new UpdateViewItem(item,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2739
                                        itemrev= new UpdateViewItem(item,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2617
                                        dropFirstUid=true;
2740
					//dropFirstUid=true;
2618
                                } else if (cycle=="sub")
2741
				if (cycle=="sub")
2619
                                        itemrev= new UpdateViewItem(itemsub,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2742
                                        itemrev= new UpdateViewItem(itemsub,revKey.gpgkeyname,revKey.gpgkeymail+i18n(" [Revocation signature]"),"-","-","-",revKey.gpgkeycreation,revKey.gpgkeyid);
2620
                                itemrev->setPixmap(0,pixRevoke);
2743
                                itemrev->setPixmap(0,pixRevoke);
2621
                        } else
2744
			}
2622
2623
2624
                                if (tst[0]=="sig") {
2745
                                if (tst[0]=="sig") {
2625
                                        gpgKey sigKey=extractKey(line);
2746
                                        gpgKey sigKey=extractKey(line);
2626
2747
Lines 2628-2673 Link Here
2628
                                                sigKey.gpgkeymail+=i18n(" [local]");
2749
                                                sigKey.gpgkeymail+=i18n(" [local]");
2629
2750
2630
                                        if (cycle=="pub")
2751
                                        if (cycle=="pub")
2631
                                                itemsig= new UpdateViewItem(item,sigKey.gpgkeyname,sigKey.gpgkeymail,"-",sigKey.gpgkeyexpiration,"-",sigKey.gpgkeycreation,sigKey.gpgkeyid);
2752
					itemsig= new UpdateViewItem(
2753
						item,
2754
						sigKey.gpgkeyname,
2755
						sigKey.gpgkeymail,
2756
						"-",
2757
						sigKey.gpgkeyexpiration,
2758
						"-",
2759
						sigKey.gpgkeycreation,
2760
						sigKey.gpgkeyid);
2632
                                        if (cycle=="sub")
2761
                                        if (cycle=="sub")
2633
                                                itemsig= new UpdateViewItem(itemsub,sigKey.gpgkeyname,sigKey.gpgkeymail,"-",sigKey.gpgkeyexpiration,"-",sigKey.gpgkeycreation,sigKey.gpgkeyid);
2762
					itemsig= new UpdateViewItem(
2763
						itemsub,
2764
						sigKey.gpgkeyname,
2765
						sigKey.gpgkeymail,
2766
						"-",
2767
						sigKey.gpgkeyexpiration,
2768
						"-",
2769
						sigKey.gpgkeycreation,
2770
						sigKey.gpgkeyid);
2634
                                        if (cycle=="uid")
2771
                                        if (cycle=="uid")
2635
                                                itemsig= new UpdateViewItem(itemuid,sigKey.gpgkeyname,sigKey.gpgkeymail,"-",sigKey.gpgkeyexpiration,"-",sigKey.gpgkeycreation,sigKey.gpgkeyid);
2772
					itemsig= new UpdateViewItem(
2636
2773
						itemuid,
2774
						sigKey.gpgkeyname,
2775
						sigKey.gpgkeymail,
2776
						"-",
2777
						sigKey.gpgkeyexpiration,
2778
						"-",
2779
						sigKey.gpgkeycreation,
2780
						sigKey.gpgkeyid);
2637
                                        itemsig->setPixmap(0,pixsignature);
2781
                                        itemsig->setPixmap(0,pixsignature);
2638
                                } else
2782
			}
2639
                                        if (tst[0]=="sub") {
2783
                                        if (tst[0]=="sub") {
2640
                                                gpgKey subKey=extractKey(line);
2784
                                                gpgKey subKey=extractKey(line);
2641
                                                itemsub= new UpdateViewItem(item,i18n("%1 subkey").arg(subKey.gpgkeyalgo),TQString(),TQString(),subKey.gpgkeyexpiration,subKey.gpgkeysize,subKey.gpgkeycreation,subKey.gpgkeyid);
2785
				itemsub= new UpdateViewItem(
2786
						item,
2787
						i18n("%1 subkey").arg(subKey.gpgkeyalgo),
2788
						TQString(),
2789
						TQString(),
2790
						subKey.gpgkeyexpiration,
2791
						subKey.gpgkeysize,
2792
						subKey.gpgkeycreation,
2793
						subKey.gpgkeyid
2794
					);
2642
                                                itemsub->setPixmap(0,pixkeySingle);
2795
                                                itemsub->setPixmap(0,pixkeySingle);
2643
                                                itemsub->setPixmap(2,subKey.trustpic);
2796
                                                itemsub->setPixmap(2,subKey.trustpic);
2644
                                                cycle="sub";
2797
                                                cycle="sub";
2645
2646
                                        }
2798
                                        }
2647
        }
2799
        }
2648
        pclose(fp);
2800
	}
2801
	TQApplication::restoreOverrideCursor();
2649
}
2802
}
2650
2803
2651
2804
2652
void listKeys::refreshkey()
2805
void listKeys::refreshkey()
2653
{
2806
{
2807
//	kdDebug(2100) << k_funcinfo << endl;
2654
        keysList2->refreshkeylist();
2808
        keysList2->refreshkeylist();
2655
	listViewSearch->updateSearch(listViewSearch->text());
2809
	listViewSearch->updateSearch(listViewSearch->text());
2656
}
2810
}
2657
2811
2658
void KeyView::refreshkeylist()
2812
void KeyView::refreshkeylist()
2659
{
2813
{
2814
// //	kdDebug(2100) << k_funcinfo << endl;
2660
        emit statusMessage(i18n("Loading Keys..."),0,true);
2815
        emit statusMessage(i18n("Loading Keys..."),0,true);
2661
        kapp->processEvents();
2816
        kapp->processEvents();
2662
        ////////   update display of keys in main management window
2817
        ////////   update display of keys in main management window
2663
        kdDebug(2100)<<"Refreshing key list"<<endl;
2818
//	kdDebug(2100)<<"Refreshing key list"<<endl;
2664
        TQString tst;
2819
2665
        char line[300];
2820
        char line[300];
2666
        UpdateViewItem *item=NULL;
2821
        UpdateViewItem *item=NULL;
2667
        bool noID=false;
2668
        bool emptyList=true;
2669
        TQString openKeys;
2822
        TQString openKeys;
2823
        bool emptyList=true;
2824
	TQMap<TQString,TQStringList> hashMap;
2670
2825
2826
	TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
2671
        // get current position.
2827
        // get current position.
2672
        TQListViewItem *current = currentItem();
2828
        TQListViewItem *current = currentItem();
2673
        if(current != NULL) {
2829
        if(current != NULL) {
Lines 2686-2717 Link Here
2686
        fp2 = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2842
        fp2 = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2687
        while ( fgets( line, sizeof(line), fp2)) {
2843
        while ( fgets( line, sizeof(line), fp2)) {
2688
                TQString lineRead=TQString::fromUtf8(line);
2844
                TQString lineRead=TQString::fromUtf8(line);
2689
                kdDebug(2100) << k_funcinfo << "Read one secret key line: " << lineRead << endl;
2845
//        //	kdDebug(2100) << k_funcinfo << "Read one secret key line: " << lineRead << endl;
2690
                if (lineRead.startsWith("sec"))
2846
                if (lineRead.startsWith("sec"))
2691
                        issec<<lineRead.section(':',4,4).right(8);
2847
                        issec<<lineRead.section(':',4,4).right(8);
2692
        }
2848
        }
2693
        pclose(fp2);
2849
        pclose(fp2);
2694
2850
2695
        TQString defaultKey = KGpgSettings::defaultKey();
2851
        TQString defaultKey = KGpgSettings::defaultKey();
2852
	TQString currentKey;
2853
2696
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-keys", "r");
2854
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-keys", "r");
2697
        while ( fgets( line, sizeof(line), fp)) {
2855
        while ( fgets( line, sizeof(line), fp)) {
2698
                tst=TQString::fromUtf8(line);
2856
                TQString tst=TQString::fromUtf8(line);
2699
                kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
2857
//        //	kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
2700
                if (tst.startsWith("pub")) {
2858
                if ( tst.startsWith("pub")  ) {
2701
                        emptyList=false;
2859
                	currentKey = tst.section(':',4,4);
2702
                        noID=false;
2860
                	TQStringList lst; lst << tst;
2703
                        gpgKey pubKey=extractKey(tst);
2861
			hashMap.insert(currentKey,lst);
2862
                }
2863
		else
2864
			hashMap.find(currentKey).data().append(tst);
2704
2865
2866
	}
2867
	pclose(fp);
2868
2869
// process the list
2870
2871
	TQMap<TQString,TQStringList>::Iterator ite;
2872
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
2873
		TQStringList::Iterator it;
2874
		gpgKey pubKey;
2705
                        bool isbold=false;
2875
                        bool isbold=false;
2706
                        bool isexpired=false;
2876
                        bool isexpired=false;
2877
2878
		for (it = ite.data().begin(); it != ite.data().end(); it++) {	
2879
			TQString tst =  (*it);
2880
			if ( tst.startsWith("pub") ){
2881
				emptyList=false;
2882
				pubKey=extractKey(tst);
2707
                        if (pubKey.gpgkeyid==defaultKey)
2883
                        if (pubKey.gpgkeyid==defaultKey)
2708
                                isbold=true;
2884
                                isbold=true;
2709
                        if (pubKey.gpgkeytrust==i18n("Expired"))
2885
                        if (pubKey.gpgkeytrust==i18n("Expired"))
2710
                                isexpired=true;
2886
                                isexpired=true;
2711
                        if (pubKey.gpgkeyname.isEmpty())
2887
			}
2712
                                noID=true;
2888
			if ( tst.startsWith("uid") && pubKey.gpgkeyname.isEmpty() ){
2889
				gpgKey tmpKey=extractKey(tst);
2890
				pubKey.gpgkeyname = tmpKey.gpgkeyname;
2891
				pubKey.gpgkeymail = tmpKey.gpgkeymail;
2892
			}
2893
		}
2713
2894
2714
                        item=new UpdateViewItem(this,pubKey.gpgkeyname,pubKey.gpgkeymail,TQString(),pubKey.gpgkeyexpiration,pubKey.gpgkeysize,pubKey.gpgkeycreation,pubKey.gpgkeyid,isbold,isexpired);
2895
		item=new UpdateViewItem(
2896
			this,
2897
			pubKey.gpgkeyname,
2898
			pubKey.gpgkeymail,
2899
			TQString(),
2900
			pubKey.gpgkeyexpiration,
2901
			pubKey.gpgkeysize,
2902
			pubKey.gpgkeycreation,
2903
			pubKey.gpgkeyid,
2904
			isbold,
2905
			isexpired);
2715
2906
2716
                        item->setPixmap(2,pubKey.trustpic);
2907
                        item->setPixmap(2,pubKey.trustpic);
2717
                        item->setExpandable(true);
2908
                        item->setExpandable(true);
Lines 2729-2753 Link Here
2729
                                item->setOpen(true);
2920
                                item->setOpen(true);
2730
                }
2921
                }
2731
2922
2732
        }
2923
2733
        pclose(fp);
2734
        if (!issec.isEmpty())
2924
        if (!issec.isEmpty())
2735
                insertOrphanedKeys(issec);
2925
                insertOrphanedKeys(issec);
2736
        if (emptyList) {
2926
        if (emptyList) {
2737
                kdDebug(2100)<<"No key found"<<endl;
2927
	//	kdDebug(2100)<<"No key found"<<endl;
2738
                emit statusMessage(i18n("Ready"),0);
2928
                emit statusMessage(i18n("Ready"),0);
2739
                return;
2929
                return;
2740
        }
2930
        }
2741
        kdDebug(2100)<<"Checking Groups"<<endl;
2931
//	kdDebug(2100)<<"Checking Groups"<<endl;
2742
        TQStringList groups=KgpgInterface::getGpgGroupNames(KGpgSettings::gpgConfigPath());
2932
        TQStringList groups=KgpgInterface::getGpgGroupNames(KGpgSettings::gpgConfigPath());
2743
        groupNb=groups.count();
2933
        groupNb=groups.count();
2744
        for ( TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it )
2934
        for ( TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it )
2745
                if (!TQString(*it).isEmpty()) {
2935
                if (!TQString(*it).isEmpty()) {
2746
                        item=new UpdateViewItem(this,TQString(*it),TQString(),TQString(),TQString(),TQString(),TQString(),TQString(),false,false);
2936
			item=new UpdateViewItem(
2937
				this,
2938
				TQString(*it),
2939
				TQString(),
2940
				TQString(),
2941
				TQString(),
2942
				TQString(),
2943
				TQString(),
2944
				TQString(),
2945
				false,
2946
				false);
2747
                        item->setPixmap(0,pixkeyGroup);
2947
                        item->setPixmap(0,pixkeyGroup);
2748
                        item->setExpandable(false);
2948
                        item->setExpandable(false);
2749
                }
2949
                }
2750
        kdDebug(2100)<<"Finished Groups"<<endl;
2950
//	kdDebug(2100)<<"Finished Groups"<<endl;
2751
2951
2752
        TQListViewItem *newPos=0L;
2952
        TQListViewItem *newPos=0L;
2753
        if(current != NULL) {
2953
        if(current != NULL) {
Lines 2770-2792 Link Here
2770
2970
2771
        emit statusMessage(i18n("%1 Keys, %2 Groups").arg(childCount()-groupNb).arg(groupNb),1);
2971
        emit statusMessage(i18n("%1 Keys, %2 Groups").arg(childCount()-groupNb).arg(groupNb),1);
2772
        emit statusMessage(i18n("Ready"),0);
2972
        emit statusMessage(i18n("Ready"),0);
2773
        kdDebug(2100)<<"Refresh Finished"<<endl;
2973
	TQApplication::restoreOverrideCursor();
2974
//	kdDebug(2100)<<"Refresh Finished"<<endl;
2774
}
2975
}
2775
2976
2776
void KeyView::insertOrphan(TQString currentID)
2977
void KeyView::insertOrphan(TQString currentID)
2777
{
2978
{
2979
// //	kdDebug(2100) << k_funcinfo << endl;
2778
        FILE *fp;
2980
        FILE *fp;
2779
        char line[300];
2981
        char line[300];
2780
        UpdateViewItem *item=NULL;
2982
        UpdateViewItem *item=NULL;
2781
        bool keyFound=false;
2983
        bool keyFound=false;
2984
	TQString currentKey;
2985
	TQMap<TQString,TQStringList> hashMap;
2986
2782
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2987
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2783
        while ( fgets( line, sizeof(line), fp)) {
2988
        while ( fgets( line, sizeof(line), fp)) {
2784
                TQString lineRead=TQString::fromUtf8(line);
2989
		TQString tst=TQString::fromUtf8(line);
2785
                if ((lineRead.startsWith("sec")) && (lineRead.section(':',4,4).right(8))==currentID.right(8)) {
2990
//	//	kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
2786
                        gpgKey orphanedKey=extractKey(lineRead);
2991
		if ( tst.startsWith("sec")  ) {
2787
                        keyFound=true;
2992
			currentKey = tst.section(':',4,4);
2993
			TQStringList lst; lst << tst;
2994
			hashMap.insert(currentKey,lst);
2995
		}
2996
		else
2997
			hashMap.find(currentKey).data().append(tst);
2998
2999
	}
3000
	pclose(fp);
3001
// process the list
3002
3003
	TQMap<TQString,TQStringList>::Iterator ite;
3004
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
3005
		TQStringList::Iterator it;
3006
		gpgKey orphanedKey;
3007
		keyFound=false;
2788
                        bool isbold=false;
3008
                        bool isbold=false;
2789
                        bool isexpired=false;
3009
                        bool isexpired=false;
3010
3011
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
3012
			TQString tmp = (*it);
3013
			if ((tmp.startsWith("sec")) && (tmp.section(':',4,4).right(8))==currentID.right(8)) {
3014
				orphanedKey=extractKey(tmp);
3015
				keyFound=true;
2790
                        //           if (orphanedKey.gpgkeyid==defaultKey)
3016
                        //           if (orphanedKey.gpgkeyid==defaultKey)
2791
                        //               isbold=true;
3017
                        //               isbold=true;
2792
                        if (orphanedKey.gpgkeytrust==i18n("Expired"))
3018
                        if (orphanedKey.gpgkeytrust==i18n("Expired"))
Lines 2794-2804 Link Here
2794
                        //          if (orphanedKey.gpgkeyname.isEmpty())
3020
                        //          if (orphanedKey.gpgkeyname.isEmpty())
2795
                        //              noID=true;
3021
                        //              noID=true;
2796
3022
2797
                        item=new UpdateViewItem(this,orphanedKey.gpgkeyname,orphanedKey.gpgkeymail,TQString(),orphanedKey.gpgkeyexpiration,orphanedKey.gpgkeysize,orphanedKey.gpgkeycreation,orphanedKey.gpgkeyid,isbold,isexpired);
2798
                        item->setPixmap(0,pixkeyOrphan);
2799
                }
3023
                }
3024
			if ( tmp.startsWith("uid") && orphanedKey.gpgkeyname.isEmpty() ){
3025
				gpgKey tmpKey=extractKey(tmp);
3026
				orphanedKey.gpgkeyname = tmpKey.gpgkeyname;
3027
				orphanedKey.gpgkeymail = tmpKey.gpgkeymail;
2800
        }
3028
        }
2801
        pclose(fp);
3029
		}
3030
		item=new UpdateViewItem(
3031
			this,
3032
			orphanedKey.gpgkeyname,
3033
			orphanedKey.gpgkeymail,
3034
			TQString(),
3035
			orphanedKey.gpgkeyexpiration,
3036
			orphanedKey.gpgkeysize,
3037
			orphanedKey.gpgkeycreation,
3038
			orphanedKey.gpgkeyid,
3039
			isbold,
3040
			isexpired);
3041
		item->setPixmap(0,pixkeyOrphan);
3042
	}
3043
2802
        if (!keyFound) {
3044
        if (!keyFound) {
2803
                orphanList.remove(currentID);
3045
                orphanList.remove(currentID);
2804
                setSelected(currentItem(),true);
3046
                setSelected(currentItem(),true);
Lines 2811-2842 Link Here
2811
3053
2812
void KeyView::insertOrphanedKeys(TQStringList orphans)
3054
void KeyView::insertOrphanedKeys(TQStringList orphans)
2813
{
3055
{
3056
// //	kdDebug(2100) << k_funcinfo << endl;
2814
        FILE *fp;
3057
        FILE *fp;
2815
        char line[300];
3058
        char line[300];
3059
	TQString currentKey;
3060
	TQMap<TQString,TQStringList> hashMap;
3061
2816
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
3062
        fp = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2817
        while ( fgets( line, sizeof(line), fp)) {
3063
        while ( fgets( line, sizeof(line), fp)) {
2818
                TQString lineRead=TQString::fromUtf8(line);
3064
                TQString tst=TQString::fromUtf8(line);
2819
                if ((lineRead.startsWith("sec")) && (orphans.find(lineRead.section(':',4,4).right(8))!=orphans.end())) {
3065
//        //	kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
2820
                        gpgKey orphanedKey=extractKey(lineRead);
3066
                if ( tst.startsWith("sec")  ) {
3067
                	currentKey = tst.section(':',4,4);
3068
                	TQStringList lst; lst << tst;
3069
			hashMap.insert(currentKey,lst);
3070
                }
3071
		else
3072
			hashMap.find(currentKey).data().append(tst);
2821
3073
3074
	}
3075
        pclose(fp);
3076
// process the list
3077
3078
	TQMap<TQString,TQStringList>::Iterator ite;
3079
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
3080
		TQStringList::Iterator it;
3081
		gpgKey orphanedKey;
2822
                        bool isbold=false;
3082
                        bool isbold=false;
2823
                        bool isexpired=false;
3083
                        bool isexpired=false;
2824
                        //           if (orphanedKey.gpgkeyid==defaultKey)
3084
2825
                        //               isbold=true;
3085
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
3086
			TQString tmp = (*it);
3087
			if ((tmp.startsWith("sec")) && (orphans.find(tmp.section(':',4,4).right(8))!=orphans.end())) {
3088
				orphanedKey=extractKey(tmp);
3089
// 				if (orphanedKey.gpgkeyid==defaultKey)
3090
// 					isbold=true;
2826
                        if (orphanedKey.gpgkeytrust==i18n("Expired"))
3091
                        if (orphanedKey.gpgkeytrust==i18n("Expired"))
2827
                                isexpired=true;
3092
                                isexpired=true;
2828
                        //          if (orphanedKey.gpgkeyname.isEmpty())
2829
                        //              noID=true;
2830
                        orphanList+=orphanedKey.gpgkeyid+",";
3093
                        orphanList+=orphanedKey.gpgkeyid+",";
2831
                        UpdateViewItem *item=new UpdateViewItem(this,orphanedKey.gpgkeyname,orphanedKey.gpgkeymail,TQString(),orphanedKey.gpgkeyexpiration,orphanedKey.gpgkeysize,orphanedKey.gpgkeycreation,orphanedKey.gpgkeyid,isbold,isexpired);
2832
                        item->setPixmap(0,pixkeyOrphan);
2833
                }
3094
                }
3095
			if ( tmp.startsWith("uid") && orphanedKey.gpgkeyname.isEmpty() ){
3096
				gpgKey tmpKey=extractKey(tmp);
3097
				orphanedKey.gpgkeyname = tmpKey.gpgkeyname;
3098
				orphanedKey.gpgkeymail = tmpKey.gpgkeymail;
3099
			}
3100
		}
3101
		UpdateViewItem *item=new UpdateViewItem(
3102
			this,
3103
			orphanedKey.gpgkeyname,
3104
			orphanedKey.gpgkeymail,
3105
			TQString(),
3106
			orphanedKey.gpgkeyexpiration,
3107
			orphanedKey.gpgkeysize,
3108
			orphanedKey.gpgkeycreation,
3109
			orphanedKey.gpgkeyid,
3110
			isbold,
3111
			isexpired);
3112
		item->setPixmap(0,pixkeyOrphan);
2834
        }
3113
        }
2835
        pclose(fp);
2836
}
3114
}
2837
3115
2838
void KeyView::refreshgroups()
3116
void KeyView::refreshgroups()
2839
{
3117
{
3118
// //	kdDebug(2100) << k_funcinfo << endl;
2840
        TQListViewItem *item=firstChild();
3119
        TQListViewItem *item=firstChild();
2841
        while (item) {
3120
        while (item) {
2842
                if (item->text(6).isEmpty()) {
3121
                if (item->text(6).isEmpty()) {
Lines 2851-2857 Link Here
2851
        groupNb=groups.count();
3130
        groupNb=groups.count();
2852
        for ( TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it )
3131
        for ( TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it )
2853
                if (!TQString(*it).isEmpty()) {
3132
                if (!TQString(*it).isEmpty()) {
2854
                        item=new UpdateViewItem(this,TQString(*it),TQString(),TQString(),TQString(),TQString(),TQString(),TQString(),false,false);
3133
                        item=new UpdateViewItem(
3134
				this,
3135
				TQString(*it),
3136
				TQString(),
3137
				TQString(),
3138
				TQString(),
3139
				TQString(),
3140
				TQString(),
3141
				TQString(),
3142
				false,
3143
				false);
2855
                        item->setPixmap(0,pixkeyGroup);
3144
                        item->setPixmap(0,pixkeyGroup);
2856
                        item->setExpandable(false);
3145
                        item->setExpandable(false);
2857
                }
3146
                }
Lines 2861-2867 Link Here
2861
3150
2862
void KeyView::refreshselfkey()
3151
void KeyView::refreshselfkey()
2863
{
3152
{
2864
        kdDebug(2100)<<"Refreshing key"<<endl;
3153
// //	kdDebug(2100) << k_funcinfo << endl;
3154
//	kdDebug(2100)<<"Refreshing key"<<endl;
2865
        if (currentItem()->depth()==0)
3155
        if (currentItem()->depth()==0)
2866
                refreshcurrentkey(currentItem());
3156
                refreshcurrentkey(currentItem());
2867
        else
3157
        else
Lines 2870-2875 Link Here
2870
3160
2871
void KeyView::slotReloadKeys(TQStringList keyIDs)
3161
void KeyView::slotReloadKeys(TQStringList keyIDs)
2872
{
3162
{
3163
// //	kdDebug(2100) << k_funcinfo << endl;
2873
        if (keyIDs.isEmpty())
3164
        if (keyIDs.isEmpty())
2874
                return;
3165
                return;
2875
	if (keyIDs.first()=="ALL")
3166
	if (keyIDs.first()=="ALL")
Lines 2880-2886 Link Here
2880
        for ( TQStringList::Iterator it = keyIDs.begin(); it != keyIDs.end(); ++it ) {
3171
        for ( TQStringList::Iterator it = keyIDs.begin(); it != keyIDs.end(); ++it ) {
2881
                refreshcurrentkey(*it);
3172
                refreshcurrentkey(*it);
2882
        }
3173
        }
2883
        kdDebug(2100)<<"Refreshing key:--------"<<TQString((keyIDs.last()).right(8).prepend("0x"))<<endl;
3174
//	kdDebug(2100)<<"Refreshing key:--------"<<TQString((keyIDs.last()).right(8).prepend("0x"))<<endl;
2884
        ensureItemVisible(this->findItem((keyIDs.last()).right(8).prepend("0x"),6));
3175
        ensureItemVisible(this->findItem((keyIDs.last()).right(8).prepend("0x"),6));
2885
        emit statusMessage(i18n("%1 Keys, %2 Groups").arg(childCount()-groupNb).arg(groupNb),1);
3176
        emit statusMessage(i18n("%1 Keys, %2 Groups").arg(childCount()-groupNb).arg(groupNb),1);
2886
        emit statusMessage(i18n("Ready"),0);
3177
        emit statusMessage(i18n("Ready"),0);
Lines 2888-2893 Link Here
2888
3179
2889
void KeyView::slotReloadOrphaned()
3180
void KeyView::slotReloadOrphaned()
2890
{
3181
{
3182
// //	kdDebug(2100) << k_funcinfo << endl;
2891
        TQStringList issec;
3183
        TQStringList issec;
2892
        FILE *fp,*fp2;
3184
        FILE *fp,*fp2;
2893
        char line[300];
3185
        char line[300];
Lines 2923-2934 Link Here
2923
3215
2924
void KeyView::refreshcurrentkey(TQString currentID)
3216
void KeyView::refreshcurrentkey(TQString currentID)
2925
{
3217
{
3218
//	kdDebug(2100) << k_funcinfo << endl;
2926
	if (currentID.isNull()) return;
3219
	if (currentID.isNull()) return;
2927
        UpdateViewItem *item=NULL;
2928
        TQString issec=TQString();
2929
        FILE *fp,*fp2;
3220
        FILE *fp,*fp2;
2930
        char line[300];
3221
        char line[300];
3222
	TQString issec=TQString();
2931
3223
3224
        TQString defaultKey = KGpgSettings::defaultKey();
3225
        TQString currentKey;
3226
	TQMap<TQString,TQStringList> hashMap;
3227
3228
        TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor));
2932
        fp2 = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
3229
        fp2 = popen("gpg --no-secmem-warning --no-tty --with-colons --list-secret-keys", "r");
2933
        while ( fgets( line, sizeof(line), fp2)) {
3230
        while ( fgets( line, sizeof(line), fp2)) {
2934
                TQString lineRead=TQString::fromUtf8(line);
3231
                TQString lineRead=TQString::fromUtf8(line);
Lines 2937-2960 Link Here
2937
        }
3234
        }
2938
        pclose(fp2);
3235
        pclose(fp2);
2939
3236
2940
        TQString defaultKey = KGpgSettings::defaultKey();
3237
//	kdDebug(2100) << "currentID: " << currentID <<endl;
2941
2942
        TQString tst;
2943
        bool keyFound=false;
2944
        TQString cmd="gpg --no-secmem-warning --no-tty --with-colons --list-keys "+currentID;
3238
        TQString cmd="gpg --no-secmem-warning --no-tty --with-colons --list-keys "+currentID;
2945
        fp = popen(TQFile::encodeName(cmd), "r");
3239
        fp = popen(TQFile::encodeName(cmd), "r");
2946
        while ( fgets( line, sizeof(line), fp)) {
3240
        while ( fgets( line, sizeof(line), fp)) {
2947
                tst=TQString::fromUtf8(line);
3241
                TQString tst=TQString::fromUtf8(line);
2948
                if (tst.startsWith("pub")) {
3242
//        //	kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
2949
                        gpgKey pubKey=extractKey(tst);
3243
                if ( tst.startsWith("pub")  ) {
2950
                        keyFound=true;
3244
                	currentKey = tst.section(':',4,4);
3245
                	TQStringList lst; lst << tst;
3246
			hashMap.insert(currentKey,lst);
3247
                }
3248
		else
3249
			hashMap.find(currentKey).data().append(tst);
3250
3251
	}
3252
	pclose(fp);
3253
	if (hashMap.isEmpty()) return; // deleted keys do not exist
3254
3255
// process the list
3256
3257
	TQMap<TQString,TQStringList>::Iterator ite;
3258
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
3259
		UpdateViewItem *item=NULL;
3260
		TQStringList::Iterator it;
3261
		gpgKey pubKey;
3262
		bool keyFound=false;
2951
                        bool isbold=false;
3263
                        bool isbold=false;
2952
                        bool isexpired=false;
3264
                        bool isexpired=false;
3265
3266
		for (it = ite.data().begin(); it != ite.data().end(); it++) {	
3267
			TQString tst =  (*it);
3268
			if ( tst.startsWith("pub") ){
3269
                        	keyFound=true;
3270
				pubKey=extractKey(tst);
2953
                        if (pubKey.gpgkeyid==defaultKey)
3271
                        if (pubKey.gpgkeyid==defaultKey)
2954
                                isbold=true;
3272
                                isbold=true;
2955
                        if (pubKey.gpgkeytrust==i18n("Expired"))
3273
                        if (pubKey.gpgkeytrust==i18n("Expired"))
2956
                                isexpired=true;
3274
                                isexpired=true;
2957
                        item=new UpdateViewItem(this,pubKey.gpgkeyname,pubKey.gpgkeymail,TQString(),pubKey.gpgkeyexpiration,pubKey.gpgkeysize,pubKey.gpgkeycreation,pubKey.gpgkeyid,isbold,isexpired);
3275
			}
3276
			if ( tst.startsWith("uid") && pubKey.gpgkeyname.isEmpty() ){
3277
				gpgKey tmpKey=extractKey(tst);
3278
				pubKey.gpgkeyname = tmpKey.gpgkeyname;
3279
				pubKey.gpgkeymail = tmpKey.gpgkeymail;
3280
			}
3281
		}
3282
3283
		item=new UpdateViewItem(
3284
			this,
3285
			pubKey.gpgkeyname,
3286
			pubKey.gpgkeymail,
3287
			TQString(),
3288
			pubKey.gpgkeyexpiration,
3289
			pubKey.gpgkeysize,
3290
			pubKey.gpgkeycreation,
3291
			pubKey.gpgkeyid,
3292
			isbold,
3293
			isexpired);
2958
                        item->setPixmap(2,pubKey.trustpic);
3294
                        item->setPixmap(2,pubKey.trustpic);
2959
			item->setVisible(true);
3295
			item->setVisible(true);
2960
                        item->setExpandable(true);
3296
                        item->setExpandable(true);
Lines 2964-2972 Link Here
2964
                        } else {
3300
                        } else {
2965
                                item->setPixmap(0,pixkeySingle);
3301
                                item->setPixmap(0,pixkeySingle);
2966
                        }
3302
                        }
2967
                }
2968
        }
2969
        pclose(fp);
2970
3303
2971
        if (!keyFound) {
3304
        if (!keyFound) {
2972
                if (orphanList.find(currentID)==-1)
3305
                if (orphanList.find(currentID)==-1)
Lines 2979-2989 Link Here
2979
3312
2980
        clearSelection();
3313
        clearSelection();
2981
        setCurrentItem(item);
3314
        setCurrentItem(item);
3315
	}
3316
	TQApplication::restoreOverrideCursor();
2982
3317
2983
}
3318
}
2984
3319
2985
void KeyView::refreshcurrentkey(TQListViewItem *current)
3320
void KeyView::refreshcurrentkey(TQListViewItem *current)
2986
{
3321
{
3322
//	kdDebug(2100) << k_funcinfo << endl;
2987
        if (!current)
3323
        if (!current)
2988
                return;
3324
                return;
2989
        bool keyIsOpen=false;
3325
        bool keyIsOpen=false;
Lines 3002-3034 Link Here
3002
3338
3003
void KeyView::refreshTrust(int color,TQColor newColor)
3339
void KeyView::refreshTrust(int color,TQColor newColor)
3004
{
3340
{
3005
if (!newColor.isValid()) return;
3341
//	kdDebug(2100) << k_funcinfo << endl;
3006
TQPixmap blankFrame,newtrust;
3342
	if (!newColor.isValid()) return;
3007
int trustFinger=0;
3343
	TQPixmap blankFrame,newtrust;
3008
blankFrame.load(locate("appdata", "pics/kgpg_blank.png"));
3344
	int trustFinger=0;
3009
newtrust.load(locate("appdata", "pics/kgpg_fill.png"));
3345
	blankFrame.load(locate("appdata", "pics/kgpg_blank.png"));
3010
newtrust.fill(newColor);
3346
	newtrust.load(locate("appdata", "pics/kgpg_fill.png"));
3011
bitBlt(&newtrust,0,0,&blankFrame,0,0,50,15);
3347
	newtrust.fill(newColor);
3012
switch (color)
3348
	bitBlt(&newtrust,0,0,&blankFrame,0,0,50,15);
3013
{
3349
	switch (color)
3014
case GoodColor:
3350
	{
3015
trustFinger=trustgood.serialNumber();
3351
		case GoodColor:
3016
trustgood=newtrust;
3352
			trustFinger=trustgood.serialNumber();
3017
break;
3353
			trustgood=newtrust;
3018
case BadColor:
3354
			break;
3019
trustFinger=trustbad.serialNumber();
3355
		case BadColor:
3020
trustbad=newtrust;
3356
			trustFinger=trustbad.serialNumber();
3021
break;
3357
			trustbad=newtrust;
3022
case UnknownColor:
3358
			break;
3023
trustFinger=trustunknown.serialNumber();
3359
		case UnknownColor:
3024
trustunknown=newtrust;
3360
			trustFinger=trustunknown.serialNumber();
3025
break;
3361
			trustunknown=newtrust;
3026
case RevColor:
3362
			break;
3027
trustFinger=trustrevoked.serialNumber();
3363
		case RevColor:
3028
trustrevoked=newtrust;
3364
			trustFinger=trustrevoked.serialNumber();
3029
break;
3365
			trustrevoked=newtrust;
3030
}
3366
			break;
3031
TQListViewItem *item=firstChild();
3367
	}
3368
	TQListViewItem *item=firstChild();
3032
                while (item) {
3369
                while (item) {
3033
			if (item->pixmap(2))
3370
			if (item->pixmap(2))
3034
			{
3371
			{
Lines 3040-3064 Link Here
3040
3377
3041
gpgKey KeyView::extractKey(TQString keyColon)
3378
gpgKey KeyView::extractKey(TQString keyColon)
3042
{
3379
{
3380
//	kdDebug(2100) << k_funcinfo << "keyColon: " << keyColon<<endl;
3043
        TQStringList keyString=TQStringList::split(":",keyColon,true);
3381
        TQStringList keyString=TQStringList::split(":",keyColon,true);
3044
        gpgKey ret;
3045
3382
3383
	gpgKey ret;
3046
        ret.gpgkeysize=keyString[2];
3384
        ret.gpgkeysize=keyString[2];
3047
        ret.gpgkeycreation=keyString[5];
3385
        ret.gpgkeycreation=keyString[5];
3048
        if(!ret.gpgkeycreation.isEmpty()) {
3386
        if(!ret.gpgkeycreation.isEmpty()) {
3049
                TQDate date = TQDate::fromString(ret.gpgkeycreation, Qt::ISODate);
3387
		TQDate date;
3388
		if (KgpgInterface::getGpgVersion() >= 210 ) {
3389
			TQDateTime timestamp;
3390
			timestamp.setTime_t( ret.gpgkeycreation.toInt());
3391
			date = timestamp.date();
3392
		}
3393
		else {
3394
			date = TQDate::fromString(ret.gpgkeycreation, Qt::ISODate);
3395
		}
3396
		Q_ASSERT (date.isValid()) /*tqWarning("create date is not valid")*/;
3050
                ret.gpgkeycreation=TDEGlobal::locale()->formatDate(date, true);
3397
                ret.gpgkeycreation=TDEGlobal::locale()->formatDate(date, true);
3051
        }
3398
        }
3052
        TQString tid=keyString[4];
3399
	TQString tid= (keyColon.startsWith("uid")) ? keyString[7] : keyString[4];
3053
        ret.gpgkeyid=TQString("0x"+tid.right(8));
3400
        ret.gpgkeyid=TQString("0x"+tid.right(8));
3401
//	ret.gpgkeyid=(keyColon.startsWith("uid")) ? keyString[7] : keyString[4];
3054
        ret.gpgkeyexpiration=keyString[6];
3402
        ret.gpgkeyexpiration=keyString[6];
3055
        if (ret.gpgkeyexpiration.isEmpty())
3403
        if (ret.gpgkeyexpiration.isEmpty())
3056
                ret.gpgkeyexpiration=i18n("Unlimited");
3404
                ret.gpgkeyexpiration=i18n("Unlimited");
3057
        else {
3405
        else {
3058
                TQDate date = TQDate::fromString(ret.gpgkeyexpiration, Qt::ISODate);
3406
		TQDate date;
3407
		if (KgpgInterface::getGpgVersion() >= 210 ) {
3408
			TQDateTime timestamp;
3409
			timestamp.setTime_t(ret.gpgkeyexpiration.toInt());
3410
			date = timestamp.date();
3411
		}
3412
		else {
3413
			date = TQDate::fromString(ret.gpgkeyexpiration, Qt::ISODate);
3414
		}
3415
		Q_ASSERT (date.isValid()) /*tqWarning("expire date is not valid")*/;
3059
                ret.gpgkeyexpiration=TDEGlobal::locale()->formatDate(date, true);
3416
                ret.gpgkeyexpiration=TDEGlobal::locale()->formatDate(date, true);
3060
        }
3417
        }
3418
3419
	// search for Fullname
3420
	if ( ! keyString[9].isEmpty() ) {
3421
		
3061
        TQString fullname=keyString[9];
3422
        TQString fullname=keyString[9];
3423
3062
        if (fullname.find("<")!=-1) {
3424
        if (fullname.find("<")!=-1) {
3063
                ret.gpgkeymail=fullname.section('<',-1,-1);
3425
                ret.gpgkeymail=fullname.section('<',-1,-1);
3064
                ret.gpgkeymail.truncate(ret.gpgkeymail.length()-1);
3426
                ret.gpgkeymail.truncate(ret.gpgkeymail.length()-1);
Lines 3069-3075 Link Here
3069
		ret.gpgkeyname=fullname;
3431
		ret.gpgkeyname=fullname;
3070
                //ret.gpgkeyname=fullname.section('(',0,0);
3432
                //ret.gpgkeyname=fullname.section('(',0,0);
3071
        }
3433
        }
3072
3434
	}
3073
        //ret.gpgkeyname=KgpgInterface::checkForUtf8(ret.gpgkeyname); // FIXME lukas
3435
        //ret.gpgkeyname=KgpgInterface::checkForUtf8(ret.gpgkeyname); // FIXME lukas
3074
3436
3075
        TQString algo=keyString[3];
3437
        TQString algo=keyString[3];
(-)tdeutils.orig/kgpg/main.cpp (-1 / +3 lines)
Lines 4-9 Link Here
4
    begin                : Mon Jul 8 2002
4
    begin                : Mon Jul 8 2002
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright          : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated main version : Sun Jul 30 10:18:29 CEST 2017
7
 ***************************************************************************/
9
 ***************************************************************************/
8
10
9
/***************************************************************************
11
/***************************************************************************
Lines 29-35 Link Here
29
static const char description[] =
31
static const char description[] =
30
        I18N_NOOP("Kgpg - simple gui for gpg\n\nKgpg was designed to make gpg very easy to use.\nI tried to make it as secure as possible.\nHope you enjoy it.");
32
        I18N_NOOP("Kgpg - simple gui for gpg\n\nKgpg was designed to make gpg very easy to use.\nI tried to make it as secure as possible.\nHope you enjoy it.");
31
33
32
static const char version[] = "1.2.2";
34
static const char version[] = "1.3.0";
33
35
34
static TDECmdLineOptions options[] =
36
static TDECmdLineOptions options[] =
35
        {
37
        {
(-)tdeutils.orig/kgpg/popuppublic.cpp (-15 / +49 lines)
Lines 4-9 Link Here
4
    begin                : Sat Jun 29 2002
4
    begin                : Sat Jun 29 2002
5
    copyright            : (C) 2002 by Jean-Baptiste Mardelle
5
    copyright            : (C) 2002 by Jean-Baptiste Mardelle
6
    email                : bj@altern.org
6
    email                : bj@altern.org
7
8
    updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017
9
    copyright          : (C) 2017 by Emanoil Kotsev
10
    email              : deloptes@yahoo.com
7
 ***************************************************************************/
11
 ***************************************************************************/
8
12
9
/***************************************************************************
13
/***************************************************************************
Lines 322-327 Link Here
322
void popupPublic::refreshkeys()
326
void popupPublic::refreshkeys()
323
{
327
{
324
	keysList->clear();
328
	keysList->clear();
329
	currentKey = TQString();
330
	hashMap.clear();
325
	TQStringList groups= TQStringList::split(",", KGpgSettings::groups());
331
	TQStringList groups= TQStringList::split(",", KGpgSettings::groups());
326
	if (!groups.isEmpty())
332
	if (!groups.isEmpty())
327
	{
333
	{
Lines 366-384 Link Here
366
372
367
void popupPublic::slotprocread(KProcIO *p)
373
void popupPublic::slotprocread(KProcIO *p)
368
{
374
{
375
//	kdDebug(2100) << k_funcinfo << endl;
369
        ///////////////////////////////////////////////////////////////// extract  encryption keys
376
        ///////////////////////////////////////////////////////////////// extract  encryption keys
370
        bool dead;
377
        TQString tst;
371
        TQString tst,keyname,keymail;
372
378
373
        TQString defaultKey = KGpgSettings::defaultKey().right(8);
379
        TQString defaultKey = KGpgSettings::defaultKey().right(8);
374
380
375
        while (p->readln(tst)!=-1) {
381
        while (p->readln(tst)!=-1) {
376
                if (tst.startsWith("pub")) {
382
        //	kdDebug(2100) << k_funcinfo << "Read one public key line: " << tst << endl;
377
			TQStringList keyString=TQStringList::split(":",tst,true);
383
                if ( tst.startsWith("pub")  ) {
384
                	currentKey = tst.section(':',4,4);
385
                	TQStringList lst; lst << tst;
386
			hashMap.insert(currentKey,tst);
387
                }
388
		else
389
			hashMap.find(currentKey).data().append(tst);
390
391
	}
392
393
	TQMap<TQString,TQStringList>::Iterator ite;
394
	for (ite = hashMap.begin(); ite != hashMap.end(); ite++) {
395
		TQStringList::Iterator it;
396
		TQString fullname,keyname,keymail,val,id;
397
		bool dead;
398
399
		for (it = ite.data().begin(); it != ite.data().end(); it++) {
400
			TQString line =  (*it);
401
402
			if (line.startsWith("pub")) {
403
				TQStringList keyString=TQStringList::split(":",line,true);
378
                        dead=false;
404
                        dead=false;
379
                        const TQString trust=keyString[1];
405
                        const TQString trust=keyString[1];
380
                        TQString val=keyString[6];
406
				val=keyString[6];
381
                        TQString id=TQString("0x"+keyString[4].right(8));
407
				id=TQString("0x"+keyString[4].right(8));
382
                        if (val.isEmpty())
408
                        if (val.isEmpty())
383
                                val=i18n("Unlimited");
409
                                val=i18n("Unlimited");
384
                        TQString tr;
410
                        TQString tr;
Lines 416-445 Link Here
416
                                break;
442
                                break;
417
                        }
443
                        }
418
			if (keyString[11].find('D')!=-1) dead=true;
444
			if (keyString[11].find('D')!=-1) dead=true;
419
                        tst=keyString[9];
445
				fullname=keyString[9];
420
			if (tst.find("<")!=-1) {
446
			}
421
                keymail=tst.section('<',-1,-1);
447
448
	
449
 			if ( line.startsWith("uid") && fullname.isEmpty() )
450
 				fullname = line.section(':',9,9);
451
452
		}
453
454
		if (fullname.find("<")!=-1) {
455
			keymail=fullname.section('<',-1,-1);
422
                keymail.truncate(keymail.length()-1);
456
                keymail.truncate(keymail.length()-1);
423
                keyname=tst.section('<',0,0);
457
			keyname=fullname.section('<',0,0);
424
                //if (keyname.find("(")!=-1)
458
                //if (keyname.find("(")!=-1)
425
                 //       keyname=keyname.section('(',0,0);
459
                 //       keyname=keyname.section('(',0,0);
426
        } else {
460
        } else {
427
                keymail=TQString();
461
                keymail=TQString();
428
                keyname=tst;//.section('(',0,0);
462
			keyname=fullname;//.section('(',0,0);
429
        }
463
        }
430
                        if ((!dead) && (!tst.isEmpty())) {
464
		if ((!dead) && (!fullname.isEmpty())) {
431
				bool isDefaultKey=false;
465
				bool isDefaultKey=false;
432
                                if (id.right(8)==defaultKey) isDefaultKey=true;
466
                                if (id.right(8)==defaultKey) isDefaultKey=true;
433
                                        UpdateViewItem2 *item=new UpdateViewItem2(keysList,keyname,keymail,id,isDefaultKey);
467
                                        UpdateViewItem2 *item=new UpdateViewItem2(keysList,keyname,keymail,id,isDefaultKey);
434
					//TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, validity: %3").arg(id).arg(tr).arg(val));
468
					//TDEListViewItem *sub= new TDEListViewItem(item,i18n("ID: %1, trust: %2, validity: %3").arg(id).arg(tr).arg(val));
435
                                        //sub->setSelectable(false);
469
                                        //sub->setSelectable(false);
436
                                        if (seclist.find(tst,0,FALSE)!=-1)
470
			if (seclist.find(fullname,0,FALSE)!=-1)
437
                                                item->setPixmap(0,keyPair);
471
                                                item->setPixmap(0,keyPair);
438
                                        else
472
                                        else
439
                                                item->setPixmap(0,keySingle);
473
                                                item->setPixmap(0,keySingle);
440
                        }
474
                        }
441
                }
475
                }
442
        }
443
}
476
}
444
477
445
478
Lines 459-466 Link Here
459
        if (selectedKeys.isEmpty() && !CBsymmetric->isChecked())
492
        if (selectedKeys.isEmpty() && !CBsymmetric->isChecked())
460
                return;
493
                return;
461
	if (CBsymmetric->isChecked()) selectedKeys=NULL;
494
	if (CBsymmetric->isChecked()) selectedKeys=NULL;
462
kdDebug(2100)<<"Selected Key:"<<selectedKeys<<endl;
495
//	kdDebug(2100)<<"Selected Key:"<<selectedKeys<<endl;
463
        TQStringList returnOptions;
496
        TQStringList returnOptions;
497
464
        if (CBuntrusted->isChecked())
498
        if (CBuntrusted->isChecked())
465
                returnOptions<<"--always-trust";
499
                returnOptions<<"--always-trust";
466
        if (CBarmor->isChecked())
500
        if (CBarmor->isChecked())
(-)tdeutils.orig/kgpg/popuppublic.h (-1 / +2 lines)
Lines 41-48 Link Here
41
        TQCheckBox *CBarmor,*CBuntrusted,*CBshred,*CBsymmetric,*CBhideid;
41
        TQCheckBox *CBarmor,*CBuntrusted,*CBshred,*CBsymmetric,*CBhideid;
42
        bool fmode,trusted;
42
        bool fmode,trusted;
43
        TQPixmap keyPair,keySingle,keyGroup;
43
        TQPixmap keyPair,keySingle,keyGroup;
44
        TQString seclist;
44
        TQString seclist, currentKey;
45
	TQStringList untrustedList;
45
	TQStringList untrustedList;
46
	TQMap<TQString,TQStringList> hashMap;
46
47
47
private:
48
private:
48
        TDEConfig *config;
49
        TDEConfig *config;

Return to bug 2791