123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
- #include <vncviewer/UserPasswdDialog.h>
- #include <vncviewer/resource.h>
-
- using namespace rfb;
- using namespace rfb::win32;
-
-
- UserPasswdDialog::UserPasswdDialog() : Dialog(GetModuleHandle(0)), showUsername(false) {
- }
-
-
- void UserPasswdDialog::setCSecurity(const CSecurity* cs) {
- description.replaceBuf(tstrDup(cs->description()));
- }
-
- bool UserPasswdDialog::showDialog() {
- return Dialog::showDialog(MAKEINTRESOURCE(IDD_VNC_AUTH_DLG));
- }
-
- void UserPasswdDialog::initDialog() {
- if (username.buf) {
- setItemString(IDC_USERNAME, username.buf);
- tstrFree(username.takeBuf());
- }
- if (password.buf) {
- setItemString(IDC_PASSWORD, password.buf);
- tstrFree(password.takeBuf());
- }
- if (!showUsername) {
- setItemString(IDC_USERNAME, _T(""));
- enableItem(IDC_USERNAME, false);
- }
- if (description.buf) {
- TCharArray title(128);
- GetWindowText(handle, title.buf, 128);
- _tcsncat(title.buf, _T(" ["), 128);
- _tcsncat(title.buf, description.buf, 128);
- _tcsncat(title.buf, _T("]"), 128);
- SetWindowText(handle, title.buf);
- }
- }
-
- bool UserPasswdDialog::onOk() {
- username.buf = getItemString(IDC_USERNAME);
- password.buf = getItemString(IDC_PASSWORD);
- return true;
- }
-
-
- bool UserPasswdDialog::getUserPasswd(char** user, char** passwd) {
- bool result = false;
- showUsername = user != 0;
- if (user && *user)
- username.buf = tstrDup(*user);
- if (passwd && *passwd)
- password.buf = tstrDup(*passwd);
- if (showDialog()) {
- if (user)
- *user = strDup(username.buf);
- *passwd = strDup(password.buf);
- result = true;
- }
- tstrFree(username.takeBuf());
- tstrFree(password.takeBuf());
- return result;
- }
|