diff options
author | Emanoil Kotsev <deloptes@gmail.com> | 2017-12-09 15:54:36 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2017-12-09 15:54:36 +0100 |
commit | 9125ead96055376ab2b48f8b5780524c0ee244ac (patch) | |
tree | ae094b5757d75c020f26f57cd0f27b06bce79bf1 /kgpg/kgpginterface.cpp | |
parent | 96765e0aa27a58e8747b8f867713fd1cc45c19b4 (diff) | |
download | tdeutils-9125ead96055376ab2b48f8b5780524c0ee244ac.tar.gz tdeutils-9125ead96055376ab2b48f8b5780524c0ee244ac.zip |
Add support for GnuPG 2.1
This resolves Bug 2791
Sort keys by name on export
Fix the twice display of the default key server
Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
Additional formatting adjustments
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'kgpg/kgpginterface.cpp')
-rw-r--r-- | kgpg/kgpginterface.cpp | 343 |
1 files changed, 274 insertions, 69 deletions
diff --git a/kgpg/kgpginterface.cpp b/kgpg/kgpginterface.cpp index 637198b..0d15df2 100644 --- a/kgpg/kgpginterface.cpp +++ b/kgpg/kgpginterface.cpp @@ -4,6 +4,10 @@ begin : Mon Jul 8 2002 copyright : (C) 2002 by Jean-Baptiste Mardelle email : bj@altern.org + + updated to handle gpg21 : Sun Jul 30 10:18:29 CEST 2017 + copyright : (C) 2017 by Emanoil Kotsev + email : deloptes@yahoo.com ***************************************************************************/ /*************************************************************************** @@ -44,6 +48,7 @@ #include <kled.h> #include <kdebug.h> #include <tdetempfile.h> +#include <tqcursor.h> #include "kgpginterface.h" #include "listkeys.h" @@ -76,6 +81,7 @@ FILE *fp; void KgpgInterface::updateIDs(TQString txtString) { +// kdDebug(2100) << k_funcinfo << endl; int cut=txtString.find(' ',22,false); txtString.remove(0,cut); if (txtString.find("(",0,false)!=-1) @@ -91,6 +97,7 @@ void KgpgInterface::updateIDs(TQString txtString) void KgpgInterface::KgpgEncryptFile(TQStringList encryptKeys,KURL srcUrl,KURL destUrl, TQStringList Options, bool symetrical) { +// kdDebug(2100) << k_funcinfo << endl; sourceFile=srcUrl; message=TQString(); @@ -123,6 +130,7 @@ KgpgInterface::~KgpgInterface() void KgpgInterface::encryptfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (message.find("END_ENCRYPTION")!=-1) emit encryptionfinished(sourceFile); else { @@ -132,6 +140,7 @@ void KgpgInterface::encryptfin(TDEProcess *) void KgpgInterface::readencprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; while (p->readln(required,true)!=-1) { if (required.find("BEGIN_ENCRYPTION",0,false)!=-1) @@ -162,6 +171,7 @@ void KgpgInterface::readencprocess(KProcIO *p) void KgpgInterface::KgpgDecryptFile(KURL srcUrl,KURL destUrl,TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; message=TQString(); step=3; decryptUrl=srcUrl.path(); @@ -187,6 +197,7 @@ void KgpgInterface::KgpgDecryptFile(KURL srcUrl,KURL destUrl,TQStringList Option void KgpgInterface::decryptfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if ((message.find("DECRYPTION_OKAY")!=-1) && (message.find("END_DECRYPTION")!=-1)) //&& (message.find("GOODMDC")!=-1) emit decryptionfinished(); else @@ -196,6 +207,7 @@ void KgpgInterface::decryptfin(TDEProcess *) void KgpgInterface::readdecprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; while (p->readln(required,true)!=-1) { if (required.find("BEGIN_DECRYPTION",0,false)!=-1) @@ -247,6 +259,7 @@ void KgpgInterface::readdecprocess(KProcIO *p) void KgpgInterface::KgpgEncryptText(TQString text,TQStringList userIDs, TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; message=TQString(); //TQTextCodec *codec = TDEGlobal::charsets()->codecForName(TDEGlobal::locale()->encoding()); TQTextCodec *codec =TQTextCodec::codecForLocale (); @@ -279,6 +292,7 @@ void KgpgInterface::KgpgEncryptText(TQString text,TQStringList userIDs, TQString void KgpgInterface::txtencryptfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (!message.isEmpty()) emit txtencryptionfinished(message); else @@ -287,6 +301,7 @@ void KgpgInterface::txtencryptfin(TDEProcess *) void KgpgInterface::txtreadencprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; while (p->readln(required,true)!=-1) { if (required.find("BEGIN_ENCRYPTION",0,false)!=-1) @@ -318,6 +333,7 @@ void KgpgInterface::txtreadencprocess(KProcIO *p) void KgpgInterface::KgpgDecryptText(TQString text,TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; gpgOutput=TQString(); log=TQString(); @@ -345,6 +361,7 @@ void KgpgInterface::KgpgDecryptText(TQString text,TQStringList Options) void KgpgInterface::txtdecryptfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if ((decok) && (!badmdc)) emit txtdecryptionfinished(message); @@ -360,12 +377,14 @@ emit txtdecryptionfailed(log); void KgpgInterface::getOutput(TDEProcess *, char *data, int ) { +// kdDebug(2100) << k_funcinfo << endl; message.append(TQString::fromUtf8(data)); } void KgpgInterface::getCmdOutput(TDEProcess *p, char *data, int ) { +// kdDebug(2100) << k_funcinfo << endl; gpgOutput.append(TQString::fromUtf8(data)); log.append(data); @@ -434,6 +453,7 @@ void KgpgInterface::getCmdOutput(TDEProcess *p, char *data, int ) void KgpgInterface::KgpgSignText(TQString text,TQString userIDs, TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; message=TQString(); step=4; TQString txtprocess; @@ -458,7 +478,7 @@ void KgpgInterface::KgpgSignText(TQString text,TQString userIDs, TQStringList Op proc->start(TDEProcess::NotifyOnExit,false); /*if (useAgent) { - kdDebug(2100)<<"Using Agent+++++++++++++"<<endl; +// kdDebug(2100)<<"Using Agent+++++++++++++"<<endl; //KMessageBox::sorry(0,"using agent"); proc->writeStdin(txtprocess,true); proc->closeWhenDone(); @@ -470,6 +490,7 @@ void KgpgInterface::KgpgSignText(TQString text,TQString userIDs, TQStringList Op void KgpgInterface::txtsignfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << "MSG: " << message<<endl; if (!message.isEmpty()) emit txtSignOver(message); else @@ -478,7 +499,9 @@ void KgpgInterface::txtsignfin(TDEProcess *) void KgpgInterface::txtsignprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; + while (p->readln(required,true)!=-1) { // kdDebug(2100)<<"SIGNING: "<<required<<endl; @@ -492,6 +515,12 @@ void KgpgInterface::txtsignprocess(KProcIO *p) p->closeWhenDone(); } + if (required.find("BEGIN_SIGNING")!=-1) { + p->writeStdin(message,true); + message=TQString(); + p->closeWhenDone(); + } + if ((required.find("passphrase.enter")!=-1)) { if (step>1) step--; @@ -513,6 +542,7 @@ void KgpgInterface::txtsignprocess(KProcIO *p) } else if (!required.startsWith("[GNUPG:]")) message+=required+"\n"; +// kdDebug(2100)<<"SIGNING: "<<message<<endl; } } @@ -521,14 +551,15 @@ void KgpgInterface::txtsignprocess(KProcIO *p) void KgpgInterface::KgpgDecryptFileToText(KURL srcUrl,TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; message=TQString(); userIDs=TQString(); step=3; anonymous=false; -decfinished=false; -decok=false; -badmdc=false; + decfinished=false; + decok=false; + badmdc=false; TDEProcess *proc=new TDEProcess(); *proc<<"gpg"<<"--no-tty"<<"--utf8-strings"<<"--no-secmem-warning"<<"--command-fd=0"<<"--status-fd=2"<<"--no-batch"<<"-o"<<"-"; @@ -551,6 +582,7 @@ badmdc=false; void KgpgInterface::KgpgVerifyText(TQString text) { +// kdDebug(2100) << k_funcinfo << endl; TQTextCodec *codec =TQTextCodec::codecForLocale (); if (!codec->canEncode(text)) text=text.utf8(); @@ -569,6 +601,7 @@ void KgpgInterface::KgpgVerifyText(TQString text) void KgpgInterface::slotverifyresult(TDEProcess*) { +// kdDebug(2100) << k_funcinfo << endl; if (signmiss) emit missingSignature(signID); else { if (signID.isEmpty()) signID=i18n("No signature found."); @@ -579,6 +612,7 @@ if (signmiss) emit missingSignature(signID); void KgpgInterface::slotverifyread(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; while (p->readln(required,true)!=-1) { @@ -613,6 +647,7 @@ TQString required; Md5Widget::Md5Widget(TQWidget *parent, const char *name,KURL url):KDialogBase( parent, name, true,i18n("MD5 Checksum"),Apply | Close) { +// kdDebug(2100) << k_funcinfo << endl; setButtonApply(i18n("Compare MD5 with Clipboard")); mdSum=TQString(); TQFile f(url.path()); @@ -664,6 +699,7 @@ Md5Widget::~Md5Widget() void Md5Widget::slotApply() { +// kdDebug(2100) << k_funcinfo << endl; TQClipboard *cb = TQApplication::clipboard(); TQString text; // Copy text from the clipboard (paste) @@ -692,6 +728,7 @@ void Md5Widget::slotApply() void KgpgInterface::KgpgSignFile(TQString keyID,KURL srcUrl,TQStringList Options) { +// kdDebug(2100) << k_funcinfo << endl; ////////////////////////////////////// create a detached signature for a chosen file message=TQString(); step=3; @@ -714,6 +751,7 @@ void KgpgInterface::KgpgSignFile(TQString keyID,KURL srcUrl,TQStringList Options void KgpgInterface::signfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (message.find("SIG_CREATED")!=-1) KMessageBox::information(0,i18n("The signature file %1 was successfully created.").arg(file.fileName())); else if (message.find("BAD_PASSPHRASE")!=-1) @@ -726,6 +764,7 @@ void KgpgInterface::signfin(TDEProcess *) void KgpgInterface::readsignprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required; while (p->readln(required,true)!=-1) { if (required.find("USERID_HINT",0,false)!=-1) @@ -766,6 +805,7 @@ void KgpgInterface::readsignprocess(KProcIO *p) void KgpgInterface::KgpgVerifyFile(KURL sigUrl,KURL srcUrl) { +// kdDebug(2100) << k_funcinfo << endl; ////////////////////////////////////// verify signature for a chosen file message=TQString(); signID=TQString(); @@ -786,7 +826,8 @@ void KgpgInterface::KgpgVerifyFile(KURL sigUrl,KURL srcUrl) void KgpgInterface::readprocess(KProcIO *p) { -TQString required; +// kdDebug(2100) << k_funcinfo << endl; + TQString required; while (p->readln(required,true)!=-1) { message+=required+"\n"; @@ -821,6 +862,7 @@ TQString required; void KgpgInterface::verifyfin(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (!signmiss) { if (signID.isEmpty()) signID=i18n("No signature found."); (void) new KDetailedInfo(0,"verify_result",signID,message); @@ -839,6 +881,7 @@ void KgpgInterface::verifyfin(TDEProcess *) void KgpgInterface::KgpgSignKey(TQString keyID,TQString signKeyID,TQString signKeyMail,bool local,int checking) { +// kdDebug(2100) << k_funcinfo << endl; signKeyMail.replace(TQRegExp("<"),"<"); konsChecked=checking; konsLocal=local; @@ -861,88 +904,186 @@ void KgpgInterface::KgpgSignKey(TQString keyID,TQString signKeyID,TQString signK else *conprocess<<"sign"; TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(sigprocess(KProcIO *))); TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(signover(TDEProcess *))); + TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor)); conprocess->start(TDEProcess::NotifyOnExit,true); } void KgpgInterface::sigprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); - while (p->readln(required,true)!=-1) - { + while (p->readln(required,true)!=-1) { + output+=required+"\n"; - output+=required+"\n"; - if (required.find("USERID_HINT",0,false)!=-1) - updateIDs(required); + if ( KgpgInterface::getGpgVersion() >= 210 ) { + // kdDebug(2100) << k_funcinfo << " line " << required << endl; + if (required.find("USERID_HINT",0,false)!=-1) { + updateIDs(required); + } - if (signSuccess==4) { - if (required.find("GET_")!=-1) - p->writeStdin(TQString("quit")); - p->closeWhenDone(); - return; - } + if (signSuccess==4 && required.find("GET_")!=-1) { + // kdDebug(2100) << k_funcinfo << " success quit" << endl; + p->writeStdin(TQString("quit")); + p->closeWhenDone(); + return; + } - if ((required.find("GOOD_PASSPHRASE")!=-1)) { - signSuccess=3; - step=2; - } + if ((required.find("GOOD_PASSPHRASE")!=-1)) { + // kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE" << endl; + signSuccess=3; + step=2; + } - if (required.find("sign_uid.expire")!=-1) { - p->writeStdin(TQString("Never")); - required=TQString(); - } - if (required.find("sign_uid.class")!=-1) { - p->writeStdin(TQString::number(konsChecked)); - required=TQString(); - } - if (required.find("sign_uid.okay")!=-1) { - p->writeStdin(TQString("Y")); - required=TQString(); - } + if (required.find("sign_uid.expire")!=-1) { + // kdDebug(2100) << k_funcinfo << " sign_uid.expire" << endl; + p->writeStdin(TQString("Never")); + required=TQString(); + } + if (required.find("sign_uid.class")!=-1) { + // kdDebug(2100) << k_funcinfo << " sign_uid.class" << endl; + p->writeStdin(TQString::number(konsChecked)); + required=TQString(); + } + if (required.find("sign_all.okay")!=-1 || required.find("sign_uid.okay")!=-1 ) { + // kdDebug(2100) << k_funcinfo << " sign_uid.okay" << endl; + step=2; + p->writeStdin(TQString("Y")); + required=TQString(); + } + if (required.find("PINENTRY_LAUNCHED")!=-1) { + // kdDebug(2100) << k_funcinfo << "PINENTRY_LAUNCHED" << endl; + // p->writeStdin(TQString::number(konsChecked)); + required=TQString(); + } - if (required.find("sign_all.okay")!=-1) { - p->writeStdin(TQString("Y")); - required=TQString(); - } + if (required.find("passphrase.enter")!=-1) { + TQCString signpass; + // kdDebug(2100) << k_funcinfo << "passphrase.enter" << endl; + TQApplication::restoreOverrideCursor(); + int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>") + .arg(errMessage).arg(userIDs)); + TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor)); + if (code!=TQDialog::Accepted) { + signSuccess=4; ///// aborted by user mode + required=TQString(); + p->writeStdin(TQString("quit")); + p->closeWhenDone(); + return; + } + p->writeStdin(signpass,true); + required=TQString(); + // step=2; + } + if ((step==2) && (required.find("keyedit.prompt")!=-1) ) { + // kdDebug(2100) << k_funcinfo << "key sign" << endl; + p->writeStdin(TQString("save")); + p->closeWhenDone(); + signSuccess=4; + required=TQString(); + } + if (required.find("BAD_PASSPHRASE")!=-1) { + // kdDebug(2100) << k_funcinfo << "BAD_PASSPHRASE" << endl; + errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>"); + required=TQString(); + signSuccess=2; ///// bad passphrase + } +// if (required.find("GET_")!=-1) { /////// gpg asks for something unusal, turn to konsole mode +// // kdDebug(2100) << k_funcinfo << "GET_ " << required << endl; +// if (signSuccess!=2) { +// signSuccess=1; ///// switching to console mode +// } +// } + } - if (required.find("passphrase.enter")!=-1) { - TQCString signpass; - int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>") - .arg(errMessage).arg(userIDs)); - if (code!=TQDialog::Accepted) { - signSuccess=4; ///// aborted by user mode - required=TQString(); - p->writeStdin(TQString("quit")); - p->closeWhenDone(); - return; - } - p->writeStdin(signpass,true); - required=TQString(); - // step=2; - } - if ((step==2) && (required.find("keyedit.prompt")!=-1)) { - p->writeStdin(TQString("save")); - required=TQString(); - } - if (required.find("BAD_PASSPHRASE")!=-1) { - errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>"); - required=TQString(); - signSuccess=2; ///// bad passphrase - } - if (required.find("GET_")!=-1) /////// gpg asks for something unusal, turn to konsole mode - { - if (signSuccess!=2) - signSuccess=1; ///// switching to console mode - p->writeStdin(TQString("quit")); - p->closeWhenDone(); + else { // (KgpgInterface::getGpgVersion() < 210) + // kdDebug(2100) << k_funcinfo << " line " << required << endl; + if (required.find("USERID_HINT",0,false)!=-1) { + updateIDs(required); + } - } - } + if (signSuccess==4) { + // kdDebug(2100) << k_funcinfo << " success quit" << endl; + if (required.find("GET_")!=-1) { + p->writeStdin(TQString("quit")); + } + p->closeWhenDone(); + return; + } + + if ((required.find("GOOD_PASSPHRASE")!=-1)) { + // kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE" << endl; + signSuccess=3; + step=2; + } + + if (required.find("sign_uid.expire")!=-1) { + // kdDebug(2100) << k_funcinfo << " sign_uid.expire" << endl; + p->writeStdin(TQString("Never")); + required=TQString(); + } + if (required.find("sign_uid.class")!=-1) { + // kdDebug(2100) << k_funcinfo << " sign_uid.class" << endl; + p->writeStdin(TQString::number(konsChecked)); + required=TQString(); + } + if (required.find("sign_all.okay")!=-1 || required.find("sign_uid.okay")!=-1 ) { + // kdDebug(2100) << k_funcinfo << " sign_uid.okay" << endl; + p->writeStdin(TQString("Y")); + required=TQString(); + } + if (required.find("PINENTRY_LAUNCHED")!=-1) { + // kdDebug(2100) << k_funcinfo << "PINENTRY_LAUNCHED" << endl; + // p->writeStdin(TQString::number(konsChecked)); + required=TQString(); + } + + if (required.find("passphrase.enter")!=-1) { + TQApplication::restoreOverrideCursor(); + TQCString signpass; + // kdDebug(2100) << k_funcinfo << "passphrase.enter" << endl; + int code=KPasswordDialog::getPassword(signpass,i18n("<qt>%1 Enter passphrase for <b>%2</b>:</qt>") + .arg(errMessage).arg(userIDs)); + TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor)); + if (code!=TQDialog::Accepted) { + signSuccess=4; ///// aborted by user mode + required=TQString(); + p->writeStdin(TQString("quit")); + p->closeWhenDone(); + return; + } + p->writeStdin(signpass,true); + required=TQString(); + // step=2; + } + if ((step==2) && (required.find("keyedit.prompt")!=-1) ) { + // kdDebug(2100) << k_funcinfo << "key save" << endl; + p->writeStdin(TQString("save")); + required=TQString(); + } + if (required.find("BAD_PASSPHRASE")!=-1) { + // kdDebug(2100) << k_funcinfo << "BAD_PASSPHRASE" << endl; + errMessage=i18n("<b>Bad passphrase</b>. Try again.</br>"); + required=TQString(); + signSuccess=2; ///// bad passphrase + } + if (required.find("GET_")!=-1) { /////// gpg asks for something unusal, turn to konsole mode + // kdDebug(2100) << k_funcinfo << "GET_ " << required << endl; + if (signSuccess!=2) { + signSuccess=1; ///// switching to console mode + } + p->writeStdin(TQString("quit")); + p->closeWhenDone(); + } + } + } } void KgpgInterface::signover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; + TQApplication::restoreOverrideCursor(); if (signSuccess>1) emit signatureFinished(signSuccess); //// signature successful or bad passphrase else { @@ -957,6 +1098,7 @@ void KgpgInterface::signover(TDEProcess *) void KgpgInterface::openSignConsole() { +// kdDebug(2100) << k_funcinfo << endl; TDEProcess conprocess; TDEConfig *config = TDEGlobal::config(); config->setGroup("General"); @@ -977,6 +1119,7 @@ void KgpgInterface::openSignConsole() void KgpgInterface::KgpgDelSignature(TQString keyID,TQString signKeyID) { +// kdDebug(2100) << k_funcinfo << endl; if (checkuid(keyID)>0) { KMessageBox::sorry(0,i18n("This key has more than one user ID.\nEdit the key manually to delete signature.")); return; @@ -1009,12 +1152,14 @@ void KgpgInterface::KgpgDelSignature(TQString keyID,TQString signKeyID) *conprocess<<"--edit-key"<<keyID<<"uid 1"<<"delsig"; TQObject::connect(conprocess,TQT_SIGNAL(readReady(KProcIO *)),this,TQT_SLOT(delsigprocess(KProcIO *))); TQObject::connect(conprocess, TQT_SIGNAL(processExited(TDEProcess *)),this, TQT_SLOT(delsignover(TDEProcess *))); + TQApplication::setOverrideCursor(TQCursor(TQt::BusyCursor)); conprocess->start(TDEProcess::NotifyOnExit,true); } void KgpgInterface::delsigprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) @@ -1044,6 +1189,8 @@ void KgpgInterface::delsigprocess(KProcIO *p) void KgpgInterface::delsignover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; + TQApplication::restoreOverrideCursor(); emit delsigfinished(deleteSuccess); } @@ -1051,10 +1198,14 @@ void KgpgInterface::delsignover(TDEProcess *) int KgpgInterface::checkuid(TQString KeyID) { +// kdDebug(2100) << k_funcinfo << "KeyID: " << KeyID<< endl; FILE *fp; TQString encResult; char buffer[200]; int uidcnt=0; + if (KgpgInterface::getGpgVersion() > 210 ) { + uidcnt=-1; // there is always one uid in the new version + } TQString gpgcmd="gpg --no-tty --no-secmem-warning --with-colon --list-sigs "+KeyID; ////////// encode with untrusted keys or armor if checked by user @@ -1064,6 +1215,7 @@ int KgpgInterface::checkuid(TQString KeyID) if (encResult.startsWith("uid")) uidcnt++; } +// kdDebug(2100) << k_funcinfo << "uid count: " << uidcnt<< endl; pclose(fp); return uidcnt; } @@ -1074,12 +1226,17 @@ int KgpgInterface::checkuid(TQString KeyID) void KgpgInterface::KgpgKeyExpire(TQString keyID,TQDate date,bool unlimited) { +// kdDebug(2100) << k_funcinfo << endl; + +// kdDebug(2100) << "KgpgKeyExpire date: " << date; + expSuccess=0; step=0; if (unlimited) expirationDelay=0; else expirationDelay=TQDate::currentDate().daysTo(date); +// kdDebug(2100) << "KgpgKeyExpire date: " << TQDate::currentDate().daysTo(date) <<endl; output=TQString(); KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale()); *conprocess<<"gpg"<<"--no-secmem-warning"<<"--no-tty"<<"--command-fd=0"<<"--status-fd=2"<<"--utf8-strings"; @@ -1092,6 +1249,7 @@ void KgpgInterface::KgpgKeyExpire(TQString keyID,TQDate date,bool unlimited) void KgpgInterface::expprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { @@ -1152,6 +1310,7 @@ void KgpgInterface::expprocess(KProcIO *p) void KgpgInterface::expover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if ((expSuccess==3) || (expSuccess==2)) emit expirationFinished(expSuccess); //// signature successful or bad passphrase else { @@ -1171,6 +1330,7 @@ void KgpgInterface::expover(TDEProcess *) void KgpgInterface::KgpgTrustExpire(TQString keyID,int keyTrust) { +// kdDebug(2100) << k_funcinfo << endl; trustValue=keyTrust+1; /* Don't know=1; Do NOT trust=2; Marginally=3; Fully=4; Ultimately=5; */ @@ -1186,6 +1346,7 @@ void KgpgInterface::KgpgTrustExpire(TQString keyID,int keyTrust) void KgpgInterface::trustprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; @@ -1219,6 +1380,7 @@ void KgpgInterface::trustprocess(KProcIO *p) void KgpgInterface::trustover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; emit trustfinished(); } @@ -1228,6 +1390,7 @@ void KgpgInterface::trustover(TDEProcess *) void KgpgInterface::KgpgChangePass(TQString keyID) { +// kdDebug(2100) << k_funcinfo << endl; step=1; output=TQString(); message=TQString(); @@ -1242,6 +1405,7 @@ void KgpgInterface::KgpgChangePass(TQString keyID) void KgpgInterface::passprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { @@ -1320,6 +1484,7 @@ void KgpgInterface::passprocess(KProcIO *p) void KgpgInterface::passover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; //emit trustfinished(); } @@ -1329,6 +1494,7 @@ void KgpgInterface::passover(TDEProcess *) TQString KgpgInterface::getKey(TQStringList IDs, bool attributes) { +// kdDebug(2100) << k_funcinfo << endl; keyString=TQString(); KProcIO *proc=new KProcIO(TQTextCodec::codecForLocale()); *proc<< "gpg"<<"--no-tty"<<"--no-secmem-warning"<<"--utf8-strings"; @@ -1346,6 +1512,7 @@ TQString KgpgInterface::getKey(TQStringList IDs, bool attributes) void KgpgInterface::slotReadKey(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString outp; while (p->readln(outp)!=-1) if (!outp.startsWith("gpg:")) keyString+=outp+"\n"; @@ -1358,6 +1525,7 @@ void KgpgInterface::importKeyURL(KURL url) { ///////////// import a key +// kdDebug(2100) << k_funcinfo << endl; if( TDEIO::NetAccess::download( url, tempKeyFile,0) ) { message=TQString(); KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale()); @@ -1386,6 +1554,7 @@ void KgpgInterface::importKey(TQString keystr) void KgpgInterface::importover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; TQStringList importedKeysIds; TQStringList messageList; TQString resultMessage; @@ -1450,6 +1619,7 @@ kdDebug(2100)<<"Importing is over"<<endl; void KgpgInterface::importURLover(TDEProcess *p) { +// kdDebug(2100) << k_funcinfo << endl; TDEIO::NetAccess::removeTempFile(tempKeyFile); importover(p); //KMessageBox::information(0,message); @@ -1458,6 +1628,7 @@ void KgpgInterface::importURLover(TDEProcess *p) void KgpgInterface::importprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString outp; while (p->readln(outp)!=-1) { if (outp.find("http-proxy")==-1) @@ -1471,6 +1642,7 @@ void KgpgInterface::importprocess(KProcIO *p) void KgpgInterface::KgpgAddUid(TQString keyID,TQString name,TQString email,TQString comment) { +// kdDebug(2100) << k_funcinfo << endl; uidName=name; uidComment=comment; uidEmail=email; @@ -1487,12 +1659,14 @@ addSuccess=true; void KgpgInterface::adduidover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (addSuccess) emit addUidFinished(); else emit addUidError(output); } void KgpgInterface::adduidprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; @@ -1556,6 +1730,7 @@ void KgpgInterface::adduidprocess(KProcIO *p) void KgpgInterface::KgpgGetPhotoList(TQString keyID) { +// kdDebug(2100) << k_funcinfo << endl; photoList.clear(); output=TQString(); photoCount=1; @@ -1571,6 +1746,7 @@ userIDs=keyID; void KgpgInterface::photoreadprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; @@ -1581,6 +1757,7 @@ void KgpgInterface::photoreadprocess(KProcIO *p) void KgpgInterface::photoreadover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; for (int i=1;i<photoCount+1;i++) if (isPhotoId(i)) photoList+=TQString::number(i); @@ -1589,6 +1766,7 @@ emit signalPhotoList(photoList); bool KgpgInterface::isPhotoId(int uid) { +// kdDebug(2100) << k_funcinfo << endl; KTempFile *kgpginfotmp=new KTempFile(); kgpginfotmp->setAutoDelete(true); TQString pgpgOutput="cp %i "+kgpginfotmp->name(); @@ -1608,6 +1786,7 @@ KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale()); void KgpgInterface::KgpgDeletePhoto(TQString keyID,TQString uid) { +// kdDebug(2100) << k_funcinfo << endl; delSuccess=true; output=TQString(); KProcIO *conprocess=new KProcIO(TQTextCodec::codecForLocale()); @@ -1620,12 +1799,14 @@ void KgpgInterface::KgpgDeletePhoto(TQString keyID,TQString uid) void KgpgInterface::delphotoover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (delSuccess) emit delPhotoFinished(); else emit delPhotoError(output); } void KgpgInterface::delphotoprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; @@ -1670,6 +1851,7 @@ void KgpgInterface::delphotoprocess(KProcIO *p) void KgpgInterface::KgpgAddPhoto(TQString keyID,TQString imagePath) { +// kdDebug(2100) << k_funcinfo << endl; photoUrl=imagePath; output=TQString(); addSuccess=true; @@ -1683,12 +1865,14 @@ addSuccess=true; void KgpgInterface::addphotoover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (addSuccess) emit addPhotoFinished(); else emit addPhotoError(output); } void KgpgInterface::addphotoprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; @@ -1747,6 +1931,7 @@ void KgpgInterface::addphotoprocess(KProcIO *p) void KgpgInterface::KgpgRevokeKey(TQString keyID,TQString revokeUrl,int reason,TQString description) { +// kdDebug(2100) << k_funcinfo << endl; revokeReason=reason; revokeSuccess=false; revokeDescription=description; @@ -1764,6 +1949,7 @@ void KgpgInterface::KgpgRevokeKey(TQString keyID,TQString revokeUrl,int reason,T void KgpgInterface::revokeover(TDEProcess *) { +// kdDebug(2100) << k_funcinfo << endl; if (!revokeSuccess) KMessageBox::detailedSorry(0,i18n("Creation of the revocation certificate failed..."),output); else { @@ -1778,27 +1964,33 @@ void KgpgInterface::revokeover(TDEProcess *) void KgpgInterface::revokeprocess(KProcIO *p) { +// kdDebug(2100) << k_funcinfo << endl; TQString required=TQString(); while (p->readln(required,true)!=-1) { output+=required+"\n"; + // kdDebug(2100) << k_funcinfo << " line " << required << endl; if (required.find("USERID_HINT",0,false)!=-1) updateIDs(required); if ((required.find("GOOD_PASSPHRASE")!=-1)) + // kdDebug(2100) << k_funcinfo << " GOOD_PASSPHRASE " << endl; revokeSuccess=true; if ((required.find("gen_revoke.okay")!=-1) || (required.find("ask_revocation_reason.okay")!=-1) || (required.find("openfile.overwrite.okay")!=-1)) { + // kdDebug(2100) << k_funcinfo << " gen_revoke.okay " << endl; p->writeStdin(TQString("YES")); required=TQString(); } if (required.find("ask_revocation_reason.code")!=-1) { + // kdDebug(2100) << k_funcinfo << " ask_revocation_reason.code " << endl; p->writeStdin(TQString::number(revokeReason)); required=TQString(); } if (required.find("passphrase.enter")!=-1) { + // kdDebug(2100) << k_funcinfo << " passphrase.enter " << endl; TQCString signpass; int code=KPasswordDialog::getPassword(signpass,i18n("<qt>Enter passphrase for <b>%1</b>:</qt>").arg(userIDs)); if (code!=TQDialog::Accepted) { @@ -1812,6 +2004,7 @@ void KgpgInterface::revokeprocess(KProcIO *p) } if (required.find("ask_revocation_reason.text")!=-1) { + // kdDebug(2100) << k_funcinfo << " ask_revocation_reason.text " << endl; // kdDebug(2100)<<"description"<<endl; p->writeStdin(revokeDescription); revokeDescription=TQString(); @@ -1833,6 +2026,7 @@ void KgpgInterface::revokeprocess(KProcIO *p) TQString KgpgInterface::getGpgSetting(TQString name,TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; name=name.stripWhiteSpace()+" "; TQFile qfile(TQFile::encodeName(configFile)); if (qfile.open(IO_ReadOnly) && (qfile.exists())) { @@ -1855,6 +2049,7 @@ TQString KgpgInterface::getGpgSetting(TQString name,TQString configFile) TQString KgpgInterface::getGpgMultiSetting(TQString name,TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; // get GnuPG setting for item that can have multiple entries (eg. encrypt-to) TQString parsedResult=TQString(); @@ -1884,6 +2079,7 @@ TQString parsedResult=TQString(); void KgpgInterface::delGpgGroup(TQString name, TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; TQString textToWrite; TQFile qfile(TQFile::encodeName(configFile)); if (qfile.open(IO_ReadOnly) && (qfile.exists())) { @@ -1912,6 +2108,7 @@ void KgpgInterface::delGpgGroup(TQString name, TQString configFile) void KgpgInterface::setGpgGroupSetting(TQString name,TQStringList values, TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; TQString textToWrite; bool found=false; TQFile qfile(TQFile::encodeName(configFile)); @@ -1951,6 +2148,7 @@ void KgpgInterface::setGpgGroupSetting(TQString name,TQStringList values, TQStri TQStringList KgpgInterface::getGpgGroupSetting(TQString name,TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; TQFile qfile(TQFile::encodeName(configFile)); if (qfile.open(IO_ReadOnly) && (qfile.exists())) { @@ -1978,6 +2176,7 @@ TQStringList KgpgInterface::getGpgGroupSetting(TQString name,TQString configFile TQStringList KgpgInterface::getGpgGroupNames(TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; TQStringList groups; TQFile qfile(TQFile::encodeName(configFile)); if (qfile.open(IO_ReadOnly) && (qfile.exists())) { @@ -2000,6 +2199,7 @@ TQStringList KgpgInterface::getGpgGroupNames(TQString configFile) bool KgpgInterface::getGpgBoolSetting(TQString name,TQString configFile) { +// kdDebug(2100) << k_funcinfo << endl; name=name; TQFile qfile(TQFile::encodeName(configFile)); if (qfile.open(IO_ReadOnly) && (qfile.exists())) { @@ -2019,6 +2219,7 @@ bool KgpgInterface::getGpgBoolSetting(TQString name,TQString configFile) void KgpgInterface::setGpgSetting(TQString name,TQString value,TQString url) { +// kdDebug(2100) << k_funcinfo << endl; name=name+" "; TQString textToWrite; bool found=false; @@ -2045,7 +2246,7 @@ void KgpgInterface::setGpgSetting(TQString name,TQString value,TQString url) if (qfile.open(IO_WriteOnly)) { TQTextStream t( &qfile); - t << textToWrite; + t << textToWrite; // FIXME: this shouldn't write at the end of the gpg.conf file qfile.close(); } } @@ -2054,6 +2255,7 @@ void KgpgInterface::setGpgSetting(TQString name,TQString value,TQString url) void KgpgInterface::setGpgMultiSetting(TQString name,TQStringList values,TQString url) { +// kdDebug(2100) << k_funcinfo << endl; name=name+" "; TQString textToWrite; bool found=false; @@ -2086,6 +2288,7 @@ void KgpgInterface::setGpgMultiSetting(TQString name,TQStringList values,TQStrin void KgpgInterface::setGpgBoolSetting(TQString name,bool enable,TQString url) { +// kdDebug(2100) << k_funcinfo << endl; TQString textToWrite; bool found=false; TQFile qfile(TQFile::encodeName(url)); @@ -2119,6 +2322,7 @@ void KgpgInterface::setGpgBoolSetting(TQString name,bool enable,TQString url) TQString KgpgInterface::checkForUtf8bis(TQString txt) { +// kdDebug(2100) << k_funcinfo << endl; if (strchr (txt.ascii(), 0xc3) || (txt.find("\\x")!=-1)) txt=checkForUtf8(txt); else { @@ -2131,6 +2335,7 @@ TQString KgpgInterface::checkForUtf8bis(TQString txt) TQString KgpgInterface::checkForUtf8(TQString txt) { +// kdDebug(2100) << k_funcinfo << endl; // code borrowed from gpa const char *s; |