The password dialog can be canceled.

Fixed an error when cancel the login password dialog at startup. RetroShare did not start after this.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4537 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-08-05 20:45:09 +00:00
parent b1ac8bc9d2
commit 687b2ecd36
5 changed files with 24 additions and 13 deletions

View file

@ -107,7 +107,10 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp
#ifdef GPG_DEBUG2
fprintf(stderr, "pgp_pwd_callback() called.\n");
#endif
std::string text = rsicontrol->getNotify().askForPassword(uid_hint,prev_was_bad);
std::string password;
if (rsicontrol->getNotify().askForPassword(uid_hint, prev_was_bad, password) == false) {
return GPG_ERR_CANCELED;
}
#ifdef GPG_DEBUG2
std::cerr << "pgp_pwd_callback() got GPG passwd from gui." << std::endl;
@ -116,12 +119,12 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp
if((void*)fd != NULL)
{
#ifndef WINDOWS_SYS
write(fd, text.c_str(), text.size());
write(fd, password.c_str(), password.size());
write(fd, "\n", 1); /* needs a new line? */
#else
DWORD written = 0;
HANDLE winFd = (HANDLE) fd;
WriteFile(winFd, text.c_str(), text.size(), &written, NULL);
WriteFile(winFd, password.c_str(), password.size(), &written, NULL);
WriteFile(winFd, "\n", 1, &written, NULL);
#endif
}