Adapted to new KPasswordEdit::password() signature.

This relates to bug 2961.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/12/head
Slávek Banko 6 years ago
parent 2f0c49e852
commit 2e5de46030
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -301,5 +301,5 @@ char * Kleo::QGpgMEJob::getPassphrase( const char * useridHint, const char * /*d
} }
canceled = false; canceled = false;
// gpgme++ free()s it, and we need to copy as long as dlg isn't deleted :o // gpgme++ free()s it, and we need to copy as long as dlg isn't deleted :o
return strdup( dlg.passphrase() ); return strdup( dlg.passphrase().utf8() );
} }

@ -100,13 +100,12 @@ Kleo::PassphraseDialog::~PassphraseDialog() {
delete d; d = 0; delete d; d = 0;
} }
const char * Kleo::PassphraseDialog::passphrase() const { const TQString Kleo::PassphraseDialog::passphrase() const {
return d->lineedit->password(); return d->lineedit->password();
} }
void Kleo::PassphraseDialog::slotOk() { void Kleo::PassphraseDialog::slotOk() {
const char * pass = passphrase(); emit finished( passphrase() );
emit finished( pass ? pass : "" );
KDialogBase::slotOk(); KDialogBase::slotOk();
} }

@ -63,13 +63,13 @@ namespace Kleo {
bool modal=true ); bool modal=true );
~PassphraseDialog(); ~PassphraseDialog();
const char * passphrase() const; const TQString passphrase() const;
signals: signals:
/** emitted when the user clicks Ok. \a pass is never NULL. /** emitted when the user clicks Ok. \a pass is never NULL.
\c pass only valid inside slots connected to this signal. \c pass only valid inside slots connected to this signal.
*/ */
void finished( const char * pass ); void finished( const TQString pass );
/** emitted when the user clicks Cancel. */ /** emitted when the user clicks Cancel. */
void canceled(); void canceled();

@ -55,7 +55,7 @@ Module::Module()
mPublicKeysCached(false), mPublicKeysCached(false),
mSecretKeys(), mSecretKeys(),
mSecretKeysCached(false), mSecretKeysCached(false),
passphrase(0), passphrase_buffer_len(0), havePassPhrase(false) passphrase(0), havePassPhrase(false)
{ {
if (!kpgpObject) { if (!kpgpObject) {
kdDebug(5100) << "creating new pgp object" << endl; kdDebug(5100) << "creating new pgp object" << endl;
@ -209,7 +209,7 @@ Module::prepare( bool needPassPhrase, Block* block )
TQApplication::restoreOverrideCursor(); TQApplication::restoreOverrideCursor();
if (passdlgResult == TQDialog::Accepted) { if (passdlgResult == TQDialog::Accepted) {
if (!setPassPhrase(passdlg.passphrase())) { if (!setPassPhrase(passdlg.passphrase())) {
if (strlen(passdlg.passphrase()) >= 1024) if (passdlg.passphrase().length() >= 1024)
errMsg = i18n("Passphrase is too long, it must contain fewer than 1024 characters."); errMsg = i18n("Passphrase is too long, it must contain fewer than 1024 characters.");
else else
errMsg = i18n("Out of memory."); errMsg = i18n("Out of memory.");
@ -227,18 +227,11 @@ Module::prepare( bool needPassPhrase, Block* block )
void void
Module::wipePassPhrase(bool freeMem) Module::wipePassPhrase(bool freeMem)
{ {
if ( passphrase ) { if (!passphrase.isEmpty()) {
if ( passphrase_buffer_len ) passphrase.fill(' ');
memset( passphrase, 0x00, passphrase_buffer_len );
else {
kdDebug(5100) << "wipePassPhrase: passphrase && !passphrase_buffer_len ???" << endl;
passphrase = 0;
}
} }
if ( freeMem && passphrase ) { if (freeMem && !passphrase.isNull()) {
free( passphrase ); passphrase = TQString();
passphrase = 0;
passphrase_buffer_len = 0;
} }
havePassPhrase = false; havePassPhrase = false;
} }
@ -837,34 +830,21 @@ Module::getAsciiPublicKey(const KeyID& keyID)
} }
bool Module::setPassPhrase(const char * aPass) bool Module::setPassPhrase(const TQString& aPass)
{ {
// null out old buffer before we touch the new string. So in case // null out old buffer before we touch the new string. So in case
// aPass isn't properly null-terminated, we don't leak secret data. // aPass isn't properly null-terminated, we don't leak secret data.
wipePassPhrase(); wipePassPhrase();
if (aPass) if (!aPass.isNull())
{ {
size_t newlen = strlen( aPass ); if (aPass.length() >= 1024) {
if ( newlen >= 1024 ) {
// rediculously long passphrase. // rediculously long passphrase.
// Maybe someone wants to trick us in malloc()'ing // Maybe someone wants to trick us in malloc()'ing
// huge buffers... // huge buffers...
return false; return false;
} }
if ( passphrase_buffer_len < newlen + 1 ) { passphrase = aPass;
// too little space in current buffer:
// allocate a larger one.
if ( passphrase )
free( passphrase );
passphrase_buffer_len = (newlen + 1 + 15) & ~0xF; // make it a multiple of 16.
passphrase = (char*)malloc( passphrase_buffer_len );
if (!passphrase) {
passphrase_buffer_len = 0;
return false;
}
}
memcpy( passphrase, aPass, newlen + 1 );
havePassPhrase = true; havePassPhrase = true;
} }
return true; return true;

@ -332,7 +332,7 @@ private:
KeyIDList getEncryptionKeys( const TQString& person ); KeyIDList getEncryptionKeys( const TQString& person );
/** Set pass phrase */ /** Set pass phrase */
bool setPassPhrase(const char* pass); bool setPassPhrase(const TQString& pass);
/** test if the PGP executable is found and if there is a passphrase /** test if the PGP executable is found and if there is a passphrase
set or given. Returns: set or given. Returns:
@ -431,8 +431,7 @@ private:
bool mSecretKeysCached : 1; // did we already read the secret keys? bool mSecretKeysCached : 1; // did we already read the secret keys?
bool storePass : 1; bool storePass : 1;
char * passphrase; TQString passphrase;
size_t passphrase_buffer_len;
TQString errMsg; TQString errMsg;

@ -59,7 +59,7 @@ Base::clear()
int int
Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP ) Base::run( const char *cmd, const TQString& passphrase, bool onlyReadFromPGP )
{ {
/* the pipe ppass is used for to pass the password to /* the pipe ppass is used for to pass the password to
* pgp. passing the password together with the normal input through * pgp. passing the password together with the normal input through
@ -74,7 +74,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
struct pollfd pollin, pollout, pollerr; struct pollfd pollin, pollout, pollerr;
int pollstatus; int pollstatus;
if(passphrase) if (!passphrase.isNull())
{ {
if (pipe(ppass) < 0) { if (pipe(ppass) < 0) {
// An error occurred // An error occurred
@ -83,7 +83,8 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
} }
pass = fdopen(ppass[1], "w"); pass = fdopen(ppass[1], "w");
fwrite(passphrase, sizeof(char), strlen(passphrase), pass); TQCString pass2 = passphrase.local8Bit();
fwrite(pass2, sizeof(char), pass2.length(), pass);
fwrite("\n", sizeof(char), 1, pass); fwrite("\n", sizeof(char), 1, pass);
fclose(pass); fclose(pass);
close(ppass[1]); close(ppass[1]);
@ -368,7 +369,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
close(perr[0]); close(perr[0]);
unsetenv("PGPPASSFD"); unsetenv("PGPPASSFD");
if(passphrase) if (!passphrase.isNull())
close(ppass[0]); close(ppass[0]);
// Did the child exit normally? // Did the child exit normally?
@ -397,7 +398,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
int int
Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG ) Base::runGpg( const char *cmd, const TQString& passphrase, bool onlyReadFromGnuPG )
{ {
/* the pipe ppass is used for to pass the password to /* the pipe ppass is used for to pass the password to
* pgp. passing the password together with the normal input through * pgp. passing the password together with the normal input through
@ -417,7 +418,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
const int STD_IN = 2; const int STD_IN = 2;
int pollstatus; int pollstatus;
if(passphrase) if (!passphrase.isNull())
{ {
if (pipe(ppass) < 0) { if (pipe(ppass) < 0) {
// An error occurred // An error occurred
@ -426,7 +427,8 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
} }
pass = fdopen(ppass[1], "w"); pass = fdopen(ppass[1], "w");
fwrite(passphrase, sizeof(char), strlen(passphrase), pass); TQCString pass2 = passphrase.local8Bit();
fwrite(pass2, sizeof(char), pass2.length(), pass);
fwrite("\n", sizeof(char), 1, pass); fwrite("\n", sizeof(char), 1, pass);
fclose(pass); fclose(pass);
close(ppass[1]); close(ppass[1]);
@ -459,7 +461,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
printf("Something went wrong in libkpgp/kpgpbase.cpp\n"); printf("Something went wrong in libkpgp/kpgpbase.cpp\n");
} }
if( passphrase ) { if (!passphrase.isNull()) {
if( mVersion >= "1.0.7" ) { if( mVersion >= "1.0.7" ) {
// GnuPG >= 1.0.7 supports the gpg-agent, so we look for it. // GnuPG >= 1.0.7 supports the gpg-agent, so we look for it.
if( 0 == getenv("GPG_AGENT_INFO") ) { if( 0 == getenv("GPG_AGENT_INFO") ) {
@ -504,7 +506,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
//#warning FIXME: there has to be a better way to do this //#warning FIXME: there has to be a better way to do this
/* this is nasty nasty nasty (but it works) */ /* this is nasty nasty nasty (but it works) */
if( passphrase ) { if (!passphrase.isNull()) {
if( mVersion >= "1.0.7" ) { if( mVersion >= "1.0.7" ) {
// GnuPG >= 1.0.7 supports the gpg-agent, so we look for it. // GnuPG >= 1.0.7 supports the gpg-agent, so we look for it.
if( 0 == getenv("GPG_AGENT_INFO") ) { if( 0 == getenv("GPG_AGENT_INFO") ) {
@ -682,7 +684,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
close(pout[0]); close(pout[0]);
close(perr[0]); close(perr[0]);
if(passphrase) if (!passphrase.isNull())
close(ppass[0]); close(ppass[0]);
// Did the child exit normally? // Did the child exit normally?

@ -41,14 +41,14 @@ public:
virtual int encrypt( Block& , const KeyIDList& ) { return OK; } virtual int encrypt( Block& , const KeyIDList& ) { return OK; }
/** Clearsigns the message with the currently set key. */ /** Clearsigns the message with the currently set key. */
virtual int clearsign( Block& , const char *) { return OK; } virtual int clearsign( Block& , const TQString& ) { return OK; }
/** Encrypts and signs the message with the given keys. */ /** Encrypts and signs the message with the given keys. */
virtual int encsign( Block& , const KeyIDList& , virtual int encsign( Block& , const KeyIDList& ,
const char * = 0) { return OK; } const TQString& = 0) { return OK; }
/** Decrypts the message. */ /** Decrypts the message. */
virtual int decrypt( Block& , const char * = 0) { return OK; } virtual int decrypt( Block& , const TQString& = 0) { return OK; }
/** Verifies the message. */ /** Verifies the message. */
virtual int verify( Block& block ) { return decrypt( block, 0 ); } virtual int verify( Block& block ) { return decrypt( block, 0 ); }
@ -77,7 +77,7 @@ public:
/** Signs the given key with the currently set user key. This is currently /** Signs the given key with the currently set user key. This is currently
not implemented. */ not implemented. */
virtual int signKey(const KeyID& , const char *) { return OK; } virtual int signKey(const KeyID& , const TQString& ) { return OK; }
/** Returns an error message if an error occurred during the last /** Returns an error message if an error occurred during the last
@ -86,9 +86,9 @@ public:
protected: protected:
virtual int run( const char *cmd, const char *passphrase = 0, virtual int run( const char *cmd, const TQString& passphrase = 0,
bool onlyReadFromPGP = false ); bool onlyReadFromPGP = false );
virtual int runGpg( const char *cmd, const char *passphrase = 0, virtual int runGpg( const char *cmd, const TQString& passphrase = 0,
bool onlyReadFromGnuPG = false ); bool onlyReadFromGnuPG = false );
virtual void clear(); virtual void clear();
@ -115,10 +115,10 @@ public:
virtual ~Base2(); virtual ~Base2();
virtual int encrypt( Block& block, const KeyIDList& recipients ); virtual int encrypt( Block& block, const KeyIDList& recipients );
virtual int clearsign( Block& block, const char *passphrase ); virtual int clearsign( Block& block, const TQString& passphrase );
virtual int encsign( Block& block, const KeyIDList& recipients, virtual int encsign( Block& block, const KeyIDList& recipients,
const char *passphrase = 0 ); const TQString& passphrase = 0 );
virtual int decrypt( Block& block, const char *passphrase = 0 ); virtual int decrypt( Block& block, const TQString& passphrase = 0 );
virtual int verify( Block& block ) { return decrypt( block, 0 ); } virtual int verify( Block& block ) { return decrypt( block, 0 ); }
virtual Key* readPublicKey( const KeyID& keyID, virtual Key* readPublicKey( const KeyID& keyID,
@ -127,7 +127,7 @@ public:
virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() );
virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() );
virtual TQCString getAsciiPublicKey( const KeyID& keyID ); virtual TQCString getAsciiPublicKey( const KeyID& keyID );
virtual int signKey( const KeyID& keyID, const char *passphrase ); virtual int signKey( const KeyID& keyID, const TQString& passphrase );
protected: protected:
KeyList doGetPublicKeys( const TQCString & cmd, KeyList doGetPublicKeys( const TQCString & cmd,
@ -147,10 +147,10 @@ public:
virtual ~BaseG(); virtual ~BaseG();
virtual int encrypt( Block& block, const KeyIDList& recipients ); virtual int encrypt( Block& block, const KeyIDList& recipients );
virtual int clearsign( Block& block, const char *passphrase ); virtual int clearsign( Block& block, const TQString& passphrase );
virtual int encsign( Block& block, const KeyIDList& recipients, virtual int encsign( Block& block, const KeyIDList& recipients,
const char *passphrase = 0 ); const TQString& passphrase = 0 );
virtual int decrypt( Block& block, const char *passphrase = 0 ); virtual int decrypt( Block& block, const TQString& passphrase = 0 );
virtual int verify( Block& block ) { return decrypt( block, 0 ); } virtual int verify( Block& block ) { return decrypt( block, 0 ); }
virtual Key* readPublicKey( const KeyID& keyID, virtual Key* readPublicKey( const KeyID& keyID,
@ -159,7 +159,7 @@ public:
virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() );
virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() );
virtual TQCString getAsciiPublicKey( const KeyID& keyID ); virtual TQCString getAsciiPublicKey( const KeyID& keyID );
virtual int signKey( const KeyID& keyID, const char *passphrase ); virtual int signKey( const KeyID& keyID, const TQString& passphrase );
private: private:
Key* parseKeyData( const TQCString& output, int& offset, Key* key = 0 ); Key* parseKeyData( const TQCString& output, int& offset, Key* key = 0 );
@ -175,10 +175,10 @@ public:
virtual ~Base5(); virtual ~Base5();
virtual int encrypt( Block& block, const KeyIDList& recipients ); virtual int encrypt( Block& block, const KeyIDList& recipients );
virtual int clearsign( Block& block, const char *passphrase ); virtual int clearsign( Block& block, const TQString& passphrase );
virtual int encsign( Block& block, const KeyIDList& recipients, virtual int encsign( Block& block, const KeyIDList& recipients,
const char *passphrase = 0 ); const TQString& passphrase = 0 );
virtual int decrypt( Block& block, const char *passphrase = 0 ); virtual int decrypt( Block& block, const TQString& passphrase = 0 );
virtual int verify( Block& block ) { return decrypt( block, 0 ); } virtual int verify( Block& block ) { return decrypt( block, 0 ); }
virtual Key* readPublicKey( const KeyID& keyID, virtual Key* readPublicKey( const KeyID& keyID,
@ -187,7 +187,7 @@ public:
virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList publicKeys( const TQStringList & patterns = TQStringList() );
virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() ); virtual KeyList secretKeys( const TQStringList & patterns = TQStringList() );
virtual TQCString getAsciiPublicKey( const KeyID& keyID ); virtual TQCString getAsciiPublicKey( const KeyID& keyID );
virtual int signKey( const KeyID& keyID, const char *passphrase ); virtual int signKey( const KeyID& keyID, const TQString& passphrase );
private: private:
Key* parseKeyData( const TQCString& output, int& offset, Key* key = 0 ); Key* parseKeyData( const TQCString& output, int& offset, Key* key = 0 );
@ -204,7 +204,7 @@ public:
Base6(); Base6();
virtual ~Base6(); virtual ~Base6();
virtual int decrypt( Block& block, const char *passphrase = 0 ); virtual int decrypt( Block& block, const TQString& passphrase = 0 );
virtual int verify( Block& block ) { return decrypt( block, 0 ); } virtual int verify( Block& block ) { return decrypt( block, 0 ); }
virtual Key* readPublicKey( const KeyID& keyID, virtual Key* readPublicKey( const KeyID& keyID,

@ -55,7 +55,7 @@ Base2::encrypt( Block& block, const KeyIDList& recipients )
int int
Base2::clearsign( Block& block, const char *passphrase ) Base2::clearsign( Block& block, const TQString& passphrase )
{ {
return encsign( block, KeyIDList(), passphrase ); return encsign( block, KeyIDList(), passphrase );
} }
@ -63,16 +63,16 @@ Base2::clearsign( Block& block, const char *passphrase )
int int
Base2::encsign( Block& block, const KeyIDList& recipients, Base2::encsign( Block& block, const KeyIDList& recipients,
const char *passphrase ) const TQString& passphrase )
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;
if(!recipients.isEmpty() && passphrase != 0) if (!recipients.isEmpty() && !passphrase.isNull())
cmd = PGP2 " +batchmode +language=en +verbose=1 -seat"; cmd = PGP2 " +batchmode +language=en +verbose=1 -seat";
else if(!recipients.isEmpty()) else if(!recipients.isEmpty())
cmd = PGP2 " +batchmode +language=en +verbose=1 -eat"; cmd = PGP2 " +batchmode +language=en +verbose=1 -eat";
else if(passphrase != 0) else if (!passphrase.isNull())
cmd = PGP2 " +batchmode +language=en +verbose=1 -sat"; cmd = PGP2 " +batchmode +language=en +verbose=1 -sat";
else else
{ {
@ -80,7 +80,7 @@ Base2::encsign( Block& block, const KeyIDList& recipients,
return OK; return OK;
} }
if(passphrase != 0) if (!passphrase.isNull())
cmd += addUserId(); cmd += addUserId();
if(!recipients.isEmpty()) { if(!recipients.isEmpty()) {
@ -185,7 +185,7 @@ Base2::encsign( Block& block, const KeyIDList& recipients,
} }
} }
#endif #endif
if(passphrase != 0) if (!passphrase.isNull())
{ {
if(error.find("Pass phrase is good") != -1) if(error.find("Pass phrase is good") != -1)
{ {
@ -224,7 +224,7 @@ Base2::encsign( Block& block, const KeyIDList& recipients,
int int
Base2::decrypt( Block& block, const char *passphrase ) Base2::decrypt( Block& block, const TQString& passphrase )
{ {
int index, index2; int index, index2;
int exitStatus = 0; int exitStatus = 0;
@ -294,7 +294,7 @@ Base2::decrypt( Block& block, const char *passphrase )
block.setRequiredUserId( error.mid(index, index2 - index) ); block.setRequiredUserId( error.mid(index, index2 - index) );
//kdDebug(5100) << "Base: key needed is \"" << block.requiredUserId() << "\"!\n"; //kdDebug(5100) << "Base: key needed is \"" << block.requiredUserId() << "\"!\n";
if((passphrase != 0) && (error.find("Bad pass phrase") != -1)) if ((!passphrase.isNull()) && (error.find("Bad pass phrase") != -1))
{ {
errMsg = i18n("Bad passphrase; could not decrypt."); errMsg = i18n("Bad passphrase; could not decrypt.");
kdDebug(5100) << "Base: passphrase is bad" << endl; kdDebug(5100) << "Base: passphrase is bad" << endl;
@ -573,7 +573,7 @@ Base2::secretKeys( const TQStringList & patterns )
int int
Base2::signKey(const KeyID& keyID, const char *passphrase) Base2::signKey(const KeyID& keyID, const TQString& passphrase)
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;

@ -55,7 +55,7 @@ Base5::encrypt( Block& block, const KeyIDList& recipients )
int int
Base5::clearsign( Block& block, const char *passphrase ) Base5::clearsign( Block& block, const TQString& passphrase )
{ {
return encsign( block, KeyIDList(), passphrase ); return encsign( block, KeyIDList(), passphrase );
} }
@ -63,7 +63,7 @@ Base5::clearsign( Block& block, const char *passphrase )
int int
Base5::encsign( Block& block, const KeyIDList& recipients, Base5::encsign( Block& block, const KeyIDList& recipients,
const char *passphrase ) const TQString& passphrase )
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;
@ -73,11 +73,11 @@ Base5::encsign( Block& block, const KeyIDList& recipients,
// we want a clear signature // we want a clear signature
bool signonly = false; bool signonly = false;
if(!recipients.isEmpty() && passphrase != 0) if (!recipients.isEmpty() && !passphrase.isNull())
cmd = "pgpe +batchmode -afts "; cmd = "pgpe +batchmode -afts ";
else if(!recipients.isEmpty()) else if(!recipients.isEmpty())
cmd = "pgpe +batchmode -aft "; cmd = "pgpe +batchmode -aft ";
else if(passphrase != 0) else if (!passphrase.isNull())
{ {
cmd = "pgps +batchmode -abft "; cmd = "pgps +batchmode -abft ";
signonly = true; signonly = true;
@ -88,7 +88,7 @@ Base5::encsign( Block& block, const KeyIDList& recipients,
return OK; return OK;
} }
if(passphrase != 0) if (!passphrase.isNull())
cmd += addUserId(); cmd += addUserId();
if(!recipients.isEmpty()) if(!recipients.isEmpty())
@ -191,7 +191,7 @@ Base5::encsign( Block& block, const KeyIDList& recipients,
int int
Base5::decrypt( Block& block, const char *passphrase ) Base5::decrypt( Block& block, const TQString& passphrase )
{ {
int exitStatus = 0; int exitStatus = 0;
@ -222,7 +222,7 @@ Base5::decrypt( Block& block, const char *passphrase )
// or do we not have the secret key? // or do we not have the secret key?
if(error.find("Need a pass phrase") != -1) if(error.find("Need a pass phrase") != -1)
{ {
if(passphrase != 0) if (!passphrase.isNull())
{ {
errMsg = i18n("Bad passphrase; could not decrypt."); errMsg = i18n("Bad passphrase; could not decrypt.");
kdDebug(5100) << "Base: passphrase is bad" << endl; kdDebug(5100) << "Base: passphrase is bad" << endl;
@ -433,12 +433,12 @@ TQCString Base5::getAsciiPublicKey(const KeyID& keyID)
int int
Base5::signKey(const KeyID& keyID, const char *passphrase) Base5::signKey(const KeyID& keyID, const TQString& passphrase)
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;
if(passphrase == 0) return false; if (passphrase.isNull()) return false;
cmd = "pgpk -s -f +batchmode=1 0x"; cmd = "pgpk -s -f +batchmode=1 0x";
cmd += keyID; cmd += keyID;

@ -46,7 +46,7 @@ Base6::~Base6()
int int
Base6::decrypt( Block& block, const char *passphrase ) Base6::decrypt( Block& block, const TQString& passphrase )
{ {
int index, index2; int index, index2;
int exitStatus = 0; int exitStatus = 0;

@ -62,7 +62,7 @@ BaseG::encrypt( Block& block, const KeyIDList& recipients )
int int
BaseG::clearsign( Block& block, const char *passphrase ) BaseG::clearsign( Block& block, const TQString& passphrase )
{ {
return encsign( block, KeyIDList(), passphrase ); return encsign( block, KeyIDList(), passphrase );
} }
@ -70,16 +70,16 @@ BaseG::clearsign( Block& block, const char *passphrase )
int int
BaseG::encsign( Block& block, const KeyIDList& recipients, BaseG::encsign( Block& block, const KeyIDList& recipients,
const char *passphrase ) const TQString& passphrase )
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;
if(!recipients.isEmpty() && passphrase != 0) if (!recipients.isEmpty() && !passphrase.isNull())
cmd = "--batch --armor --sign --encrypt --textmode"; cmd = "--batch --armor --sign --encrypt --textmode";
else if(!recipients.isEmpty()) else if(!recipients.isEmpty())
cmd = "--batch --armor --encrypt --textmode"; cmd = "--batch --armor --encrypt --textmode";
else if(passphrase != 0) else if (!passphrase.isNull())
cmd = "--batch --escape-from --clearsign"; cmd = "--batch --escape-from --clearsign";
else else
{ {
@ -87,7 +87,7 @@ BaseG::encsign( Block& block, const KeyIDList& recipients,
return OK; return OK;
} }
if(passphrase != 0) if (!passphrase.isNull())
cmd += addUserId(); cmd += addUserId();
if(!recipients.isEmpty()) if(!recipients.isEmpty())
@ -164,7 +164,7 @@ BaseG::encsign( Block& block, const KeyIDList& recipients,
} }
} }
#endif #endif
if( passphrase != 0 ) if (!passphrase.isNull())
{ {
// Example 1 (bad passphrase, clearsign only): // Example 1 (bad passphrase, clearsign only):
// gpg: skipped `0x12345678': bad passphrase // gpg: skipped `0x12345678': bad passphrase
@ -205,7 +205,7 @@ BaseG::encsign( Block& block, const KeyIDList& recipients,
int int
BaseG::decrypt( Block& block, const char *passphrase ) BaseG::decrypt( Block& block, const TQString& passphrase )
{ {
int index, index2; int index, index2;
int exitStatus = 0; int exitStatus = 0;
@ -252,7 +252,7 @@ BaseG::decrypt( Block& block, const char *passphrase )
{ {
if( ( index = error.find( "bad passphrase" ) ) != -1 ) if( ( index = error.find( "bad passphrase" ) ) != -1 )
{ {
if( passphrase != 0 ) if (!passphrase.isNull())
{ {
errMsg = i18n( "Bad passphrase; could not decrypt." ); errMsg = i18n( "Bad passphrase; could not decrypt." );
kdDebug(5100) << "Base: passphrase is bad" << endl; kdDebug(5100) << "Base: passphrase is bad" << endl;
@ -483,7 +483,7 @@ BaseG::secretKeys( const TQStringList & patterns )
int int
BaseG::signKey(const KeyID& keyID, const char *passphrase) BaseG::signKey(const KeyID& keyID, const TQString& passphrase)
{ {
TQCString cmd; TQCString cmd;
int exitStatus = 0; int exitStatus = 0;

@ -95,7 +95,7 @@ PassphraseDialog::~PassphraseDialog()
{ {
} }
const char * PassphraseDialog::passphrase() const TQString PassphraseDialog::passphrase()
{ {
return lineedit->password(); return lineedit->password();
} }

@ -62,7 +62,7 @@ class KDE_EXPORT PassphraseDialog : public KDialogBase
bool modal=true, const TQString &keyID=TQString()); bool modal=true, const TQString &keyID=TQString());
virtual ~PassphraseDialog(); virtual ~PassphraseDialog();
const char * passphrase(); const TQString passphrase();
private: private:
KPasswordEdit *lineedit; KPasswordEdit *lineedit;

@ -376,14 +376,14 @@ void ResourceCalDav::loadFinished() {
if (loader->error()) { if (loader->error()) {
if (loader->errorNumber() == -401) { if (loader->errorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
TQCString newpass; TQString newpass;
if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
log("load error: " + loader->errorString() ); log("load error: " + loader->errorString() );
loadError(TQString("[%1] ").arg(abs(loader->errorNumber())) + loader->errorString()); loadError(TQString("[%1] ").arg(abs(loader->errorNumber())) + loader->errorString());
} }
else { else {
// Set new password and try again // Set new password and try again
mPrefs->setPassword(TQString(newpass)); mPrefs->setPassword(newpass);
startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl()); startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl());
} }
} }
@ -424,14 +424,14 @@ void ResourceCalDav::loadFinished() {
if (loader->tasksError()) { if (loader->tasksError()) {
if (loader->tasksErrorNumber() == -401) { if (loader->tasksErrorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
// TQCString newpass; // TQString newpass;
// if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { // if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
// log("load error: " + loader->tasksErrorString() ); // log("load error: " + loader->tasksErrorString() );
// loadError(TQString("[%1] ").arg(abs(loader->tasksErrorNumber())) + loader->tasksErrorString()); // loadError(TQString("[%1] ").arg(abs(loader->tasksErrorNumber())) + loader->tasksErrorString());
// } // }
// else { // else {
// // Set new password and try again // // Set new password and try again
// mPrefs->setPassword(TQString(newpass)); // mPrefs->setPassword(newpass);
// startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl()); // startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl());
// } // }
} }
@ -472,14 +472,14 @@ void ResourceCalDav::loadFinished() {
if (loader->journalsError()) { if (loader->journalsError()) {
if (loader->journalsErrorNumber() == -401) { if (loader->journalsErrorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
// TQCString newpass; // TQString newpass;
// if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { // if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
// log("load error: " + loader->journalsErrorString() ); // log("load error: " + loader->journalsErrorString() );
// loadError(TQString("[%1] ").arg(abs(loader->journalsErrorNumber())) + loader->journalsErrorString()); // loadError(TQString("[%1] ").arg(abs(loader->journalsErrorNumber())) + loader->journalsErrorString());
// } // }
// else { // else {
// // Set new password and try again // // Set new password and try again
// mPrefs->setPassword(TQString(newpass)); // mPrefs->setPassword(newpass);
// startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl()); // startLoading(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl());
// } // }
} }
@ -969,14 +969,14 @@ void ResourceCalDav::writingFinished() {
if (mWriter->error() && (abs(mWriter->errorNumber()) != 207)) { if (mWriter->error() && (abs(mWriter->errorNumber()) != 207)) {
if (mWriter->errorNumber() == -401) { if (mWriter->errorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
TQCString newpass; TQString newpass;
if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
log("write error: " + mWriter->errorString()); log("write error: " + mWriter->errorString());
saveError(TQString("[%1] ").arg(abs(mWriter->errorNumber())) + mWriter->errorString()); saveError(TQString("[%1] ").arg(abs(mWriter->errorNumber())) + mWriter->errorString());
} }
else { else {
// Set new password and try again // Set new password and try again
mPrefs->setPassword(TQString(newpass)); mPrefs->setPassword(newpass);
startWriting(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl()); startWriting(mPrefs->getFullUrl(), mPrefs->getFullTasksUrl(), mPrefs->getFullJournalsUrl());
} }
} }

@ -372,14 +372,14 @@ void ResourceCardDav::loadFinished() {
if (loader->error()) { if (loader->error()) {
if (loader->errorNumber() == -401) { if (loader->errorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
TQCString newpass; TQString newpass;
if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
log("load error: " + loader->errorString() ); log("load error: " + loader->errorString() );
if (addressBook() != NULL) addressBook()->error(TQString("[%1] ").arg(abs(loader->errorNumber())) + loader->errorString()); if (addressBook() != NULL) addressBook()->error(TQString("[%1] ").arg(abs(loader->errorNumber())) + loader->errorString());
} }
else { else {
// Set new password and try again // Set new password and try again
mPrefs->setPassword(TQString(newpass)); mPrefs->setPassword(newpass);
startLoading(mPrefs->getFullUrl()); startLoading(mPrefs->getFullUrl());
} }
} }
@ -641,14 +641,14 @@ void ResourceCardDav::writingFinished() {
if (mWriter->error() && (abs(mWriter->errorNumber()) != 207)) { if (mWriter->error() && (abs(mWriter->errorNumber()) != 207)) {
if (mWriter->errorNumber() == -401) { if (mWriter->errorNumber() == -401) {
if (NULL != mPrefs) { if (NULL != mPrefs) {
TQCString newpass; TQString newpass;
if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) { if (KPasswordDialog::getPassword (newpass, TQString("<b>") + i18n("Remote authorization required") + TQString("</b><p>") + i18n("Please input the password for") + TQString(" ") + mPrefs->getusername(), NULL) != 1) {
log("write error: " + mWriter->errorString()); log("write error: " + mWriter->errorString());
if (addressBook() != NULL) addressBook()->error(TQString("[%1] ").arg(abs(mWriter->errorNumber())) + mWriter->errorString()); if (addressBook() != NULL) addressBook()->error(TQString("[%1] ").arg(abs(mWriter->errorNumber())) + mWriter->errorString());
} }
else { else {
// Set new password and try again // Set new password and try again
mPrefs->setPassword(TQString(newpass)); mPrefs->setPassword(newpass);
startWriting(mPrefs->getFullUrl()); startWriting(mPrefs->getFullUrl());
} }
} }

Loading…
Cancel
Save