tdeio/kssl
ksslpemcallback.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024
00025 #include <kpassdlg.h>
00026 #include <tdelocale.h>
00027 #include "ksslpemcallback.h"
00028
00029 int KSSLPemCallback(char *buf, int size, int rwflag, void *userdata) {
00030 #ifdef KSSL_HAVE_SSL
00031 TQString pass2;
00032 Q_UNUSED(userdata);
00033 Q_UNUSED(rwflag);
00034
00035 if (!buf) return -1;
00036 int rc = KPasswordDialog::getPassword(pass2, i18n("Certificate password"));
00037 if (rc != KPasswordDialog::Accepted) return -1;
00038
00039 TQCString pass = pass2.utf8();
00040 const uint passlen = pass.length();
00041 if (passlen > (unsigned int)size-1)
00042 pass.truncate((unsigned int)size-1);
00043
00044 tqstrncpy(buf, pass, size-1);
00045 buf[size-1] = 0;
00046 pass.fill(' ');
00047 pass2.fill(' ');
00048 return (int)passlen;
00049 #else
00050 Q_UNUSED(buf);
00051 Q_UNUSED(size);
00052 Q_UNUSED(rwflag);
00053 Q_UNUSED(userdata);
00054 return -1;
00055 #endif
00056 }
00057
00058