"Fossies" - the Fresh Open Source Software Archive

Member "tvnserver-2.0.4/wsconfig-lib/ChangePasswordDialog.cpp" (3 Aug 2011, 3452 Bytes) of archive /windows/misc/tvnserver-2.0.4-src.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ChangePasswordDialog.cpp" see the Fossies "Dox" file reference documentation.

    1 // Copyright (C) 2008, 2009, 2010 GlavSoft LLC.
    2 // All rights reserved.
    3 //
    4 //-------------------------------------------------------------------------
    5 // This file is part of the TightVNC software.  Please visit our Web site:
    6 //
    7 //                       http://www.tightvnc.com/
    8 //
    9 // This program is free software; you can redistribute it and/or modify
   10 // it under the terms of the GNU General Public License as published by
   11 // the Free Software Foundation; either version 2 of the License, or
   12 // (at your option) any later version.
   13 //
   14 // This program is distributed in the hope that it will be useful,
   15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17 // GNU General Public License for more details.
   18 //
   19 // You should have received a copy of the GNU General Public License along
   20 // with this program; if not, write to the Free Software Foundation, Inc.,
   21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   22 //-------------------------------------------------------------------------
   23 //
   24 
   25 #include "ChangePasswordDialog.h"
   26 #include "tvnserver/resource.h"
   27 
   28 #include "server-config-lib/ServerConfig.h"
   29 
   30 #include "util/VncPassCrypt.h"
   31 
   32 ChangePasswordDialog::ChangePasswordDialog(Control *parent, bool isNewPassword)
   33 : BaseDialog(IDD_CHANGE_PASSWORD), m_allowEmptyPassword(false), m_newPassword(isNewPassword)
   34 {
   35   setParent(parent);
   36 
   37   m_passwordEmptyTooltip.setText(StringTable::getString(IDS_PASSWORD_IS_EMPTY));
   38   m_passwordEmptyTooltip.setTitle(StringTable::getString(IDS_MBC_TVNCONTROL));
   39 
   40   m_passwordsNotMatchTooltip.setText(StringTable::getString(IDS_PASSWORDS_NOT_MATCH));
   41   m_passwordsNotMatchTooltip.setTitle(StringTable::getString(IDS_MBC_TVNCONTROL));
   42 }
   43 
   44 ChangePasswordDialog::~ChangePasswordDialog()
   45 {
   46 }
   47 
   48 const TCHAR *ChangePasswordDialog::getPasswordInPlainText() const
   49 {
   50   return m_passwordText.getString();
   51 }
   52 
   53 BOOL ChangePasswordDialog::onInitDialog()
   54 {
   55   initControls();
   56   if (m_newPassword) {
   57     m_ctrlThis.setText(StringTable::getString(IDS_NEW_PASSWORD));
   58   } else {
   59     m_ctrlThis.setText(StringTable::getString(IDS_CHANGE_PASSWORD));
   60   }
   61   return TRUE;
   62 }
   63 
   64 BOOL ChangePasswordDialog::onCommand(UINT cID, UINT nID)
   65 {
   66   if (nID == BN_CLICKED) {
   67     switch (cID) {
   68     case IDOK:
   69       onOkButtonClick();
   70       break;
   71     case IDCANCEL:
   72       onCancelButtonClick();
   73       break;
   74     }
   75   }
   76   return TRUE;
   77 }
   78 
   79 void ChangePasswordDialog::onOkButtonClick()
   80 {
   81   StringStorage password1;
   82   StringStorage password2;
   83   m_password1.getText(&password1);
   84   m_password2.getText(&password2);
   85 
   86   if (password1.isEmpty() && !m_allowEmptyPassword) {
   87     m_password1.showBalloonTip(&m_passwordEmptyTooltip);
   88     m_password1.setFocus();
   89     return ;
   90   }
   91   if (!password1.isEqualTo(&password2)) {
   92     m_password2.showBalloonTip(&m_passwordsNotMatchTooltip);
   93     m_password2.setFocus();
   94     return ;
   95   }
   96 
   97   m_passwordText.setString(password1.getString());
   98 
   99   kill(IDOK);
  100 }
  101 
  102 void ChangePasswordDialog::onCancelButtonClick()
  103 {
  104   kill(IDCANCEL);
  105 }
  106 
  107 void ChangePasswordDialog::initControls()
  108 {
  109   HWND hwnd = m_ctrlThis.getWindow();
  110   m_password1.setWindow(GetDlgItem(hwnd, IDC_PASSWORD));
  111   m_password2.setWindow(GetDlgItem(hwnd, IDC_PASSWORD2));
  112 
  113   m_password1.setTextLengthLimit(VNC_PASSWORD_SIZE);
  114   m_password2.setTextLengthLimit(VNC_PASSWORD_SIZE);
  115 }