Пример #1
1
void ViewerCmdLine::parseOptionsFile()
{
  StringStorage pathToIniFile = m_options[OPTIONS_FILE];
  if (pathToIniFile.findChar(_T('\\')) == -1) {
    StringStorage newPathToIniFile;
    newPathToIniFile.format(_T(".\\%s"), pathToIniFile.getString());
    pathToIniFile = newPathToIniFile;
  }
  IniFileSettingsManager sm(pathToIniFile.getString());
  sm.setApplicationName(_T("connection"));

  StringStorage host;
  if (!sm.getString(_T("host"), &host)) {
    throw CommandLineFormatException(_T("Could not read options file."));
  }
  StringStorage port;
  if (sm.getString(_T("port"), &port)) {
    StringStorage hostString;
    hostString.format(_T("%s:%s"), host.getString(), port.getString());
    m_conData->setHost(&hostString);
  } else {
    m_conData->setHost(&host);
  }

  StringStorage password;
  sm.getString(_T("password"), &password);
  if (!password.isEmpty()) {
    m_conData->setCryptedPassword(&password);
  } else {
    parsePassword();
  }
  
  sm.setApplicationName(_T("options"));
  m_conConf->loadFromStorage(&sm);
}
Пример #2
0
StringStorage ViewerWindow::formatWindowName() const
{
	StringStorage desktopName = m_viewerCore->getRemoteDesktopName();
	if (desktopName.isEmpty() && !m_conData->getHost().isEmpty()) {
		desktopName = m_conData->getHost();
	}
	StringStorage windowName;
	if (!desktopName.isEmpty()) {
		windowName.format(_T("%s - %s"), desktopName.getString(), ProductNames::VIEWER_PRODUCT_NAME);
	}
	else {
		windowName.format(_T("%s"), ProductNames::VIEWER_PRODUCT_NAME);
	}
	return windowName;
}
Пример #3
0
void LoginDialog::enableConnect()
{
  StringStorage str;
  int iSelected = m_server.getSelectedItemIndex();
  if (iSelected == -1) {
    m_server.getText(&str);
    m_ok.setEnabled(!str.isEmpty());
  } else {
    m_ok.setEnabled(true);
  }
}
Пример #4
0
BOOL LoginDialog::onOptions()
{
  OptionsDialog dialog;
  dialog.setConnectionConfig(&m_connectionConfig);
  dialog.setParent(getControl());
  if (dialog.showModal() == 1) {
    StringStorage server;
    m_server.getText(&server);
    if (server.isEmpty()) {
      ConnectionConfigSM ccsm(RegistryPaths::VIEWER_PATH,
                              server.getString());
      m_connectionConfig.saveToStorage(&ccsm);
    }
    return FALSE;
  }
  return TRUE;
}
bool EditIpAccessRuleDialog::validateInput()
{
  StringStorage firstIp;
  StringStorage lastIp;

  m_firstIp.getText(&firstIp);
  m_lastIp.getText(&lastIp);

  if (!IpAccessRule::isIpAddressStringValid(firstIp.getString())) {
    m_firstIp.setFocus();
    m_firstIp.showBalloonTip(&m_warningBalloonTip);
    return false;
  } // if

  if (lastIp.isEmpty()) {
    return true;
  }

  if (!IpAccessRule::isIpAddressStringValid(lastIp.getString())) {
    m_lastIp.setFocus();
    m_lastIp.showBalloonTip(&m_warningBalloonTip);
    return false;
  } // if

  AnsiStringStorage firstIpAnsi(&firstIp);
  AnsiStringStorage lastIpAnsi(&lastIp);

  unsigned long firstIpAddr = inet_addr(firstIpAnsi.getString());
  unsigned long lastIpAddr = inet_addr(lastIpAnsi.getString());

  if (IpAccessRule::compareIp(firstIpAddr, lastIpAddr) == 1) {
    m_lastIp.setFocus();
    m_lastIp.showBalloonTip(&m_lastIpLessThanFirstBT);
    return false;
  }

  return true;
}
Пример #6
0
void LoginDialog::updateHistory()
{
  ConnectionHistory *conHistory;

  StringStorage currentServer;
  m_server.getText(&currentServer);
  m_server.removeAllItems();
  conHistory = ViewerConfig::getInstance()->getConnectionHistory();
  conHistory->load();
  for (size_t i = 0; i < conHistory->getHostCount(); i++) {
    m_server.insertItem(static_cast<int>(i), conHistory->getHost(i));
  }
  m_server.setText(currentServer.getString());
  if (m_server.getItemsCount()) {
    if (currentServer.isEmpty()) {
      m_server.setSelectedItem(0);
    }
    StringStorage server;
    m_server.getText(&server);
    ConnectionConfigSM ccsm(RegistryPaths::VIEWER_PATH,
                            server.getString());
    m_connectionConfig.loadFromStorage(&ccsm);
  }
}
Пример #7
0
void ImagedButton::drawItem(LPDRAWITEMSTRUCT dis)
{
  HDC dc = dis->hDC;

  BOOL isPressed = (dis->itemState & ODS_SELECTED);
  BOOL isFocused = (dis->itemState & ODS_FOCUS);
  BOOL isDisabled = (dis->itemState & ODS_DISABLED);
  BOOL drawFocusRect = !(dis->itemState & ODS_NOFOCUSRECT);

  RECT itemRect = dis->rcItem;
  SetBkMode(dc, TRANSPARENT);

  if (m_isUsingTheme) {
    DWORD state = (isPressed) ? PBS_PRESSED : PBS_NORMAL;
    if (state == PBS_NORMAL) {
      if (isFocused) {
        state = PBS_DEFAULTED;
      } 
      if (m_mouseOver) {
        state = PBS_HOT;
      } 
      if (isDisabled) {
        state = PBS_DISABLED;
      }
    } 
    ThemeLib::DrawThemeBackground(m_theme, dc, BP_PUSHBUTTON, state, &itemRect, NULL);
  } else {
    if (isFocused) {
      HBRUSH br = CreateSolidBrush(RGB(0,0,0));
      FrameRect(dc, &itemRect, br);
      InflateRect(&itemRect, -1, -1);
      DeleteObject(br);
    } 

    HBRUSH background = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    FillRect(dc, &itemRect, background);
    DeleteObject(background);

    if (isPressed) {
      HBRUSH shadow = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
      FrameRect(dc, &itemRect, shadow);
      DeleteObject(shadow);
    } else {
      UINT uState = DFCS_BUTTONPUSH |
                    ((m_mouseOver) ? DFCS_HOT : 0) |
                    ((isPressed) ? DFCS_PUSHED : 0);

      DrawFrameControl(dc, &itemRect, DFC_BUTTON, uState);
    } 
  } 

  StringStorage title;
  getText(&title);

  RECT captionRect = dis->rcItem;

  TEXTMETRIC metric;
  GetTextMetrics(dc, &metric);

  RECT imageRect;

  calcRect(&itemRect, isPressed == TRUE, 0, metric.tmHeight,
           m_iconWidth, m_iconHeight, &captionRect, &imageRect);

  if (m_icon != NULL) {
    drawIcon(&dc, &imageRect, isPressed == TRUE, isDisabled == TRUE);
  }

  if (!title.isEmpty()) {
    if (isPressed && !m_isUsingTheme) {
      OffsetRect(&captionRect, 1, 1);
    }

    if (m_isUsingTheme) {
      WCHAR *unicodeString = new WCHAR[title.getLength() + 1];
      size_t len = title.getLength();
      title.toUnicodeString(unicodeString, &len);

      DWORD state = PBS_NORMAL;

      if (isDisabled) {
        state = PBS_DISABLED;
      }

      ThemeLib::DrawThemeText(m_theme, dc, BP_PUSHBUTTON, state,
                              unicodeString, len,
                              DT_CENTER | DT_VCENTER | DT_SINGLELINE,
                              0, &captionRect);
      delete[] unicodeString;
    } else {
      SetBkMode(dc, TRANSPARENT);

      if (isDisabled) {
        OffsetRect(&captionRect, 1, 1);
        SetTextColor(dc, ::GetSysColor(COLOR_3DHILIGHT));
        DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER);
        OffsetRect(&captionRect, -1, -1);
        SetTextColor(dc, ::GetSysColor(COLOR_3DSHADOW));
        DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER);
      } else {
        SetTextColor(dc, ::GetSysColor(COLOR_BTNTEXT));
        SetBkColor(dc, ::GetSysColor(COLOR_BTNFACE));
        DrawText(dc, title.getString(), -1, &captionRect, DT_WORDBREAK | DT_CENTER);
      } 
    } 
  } 

  if (isFocused && drawFocusRect) {
    RECT focusRect = itemRect;
    InflateRect(&focusRect, -3, -3);
    DrawFocusRect(dc, &focusRect);
  } 
} 
void AdministrationConfigDialog::updateUI()
{
  m_logLevel.setSignedInt(m_config->getLogLevel());

  m_useControlAuth.check(m_config->isControlAuthEnabled());

  ConfigDialog *configDialog = (ConfigDialog *)m_parentDialog;

  StringStorage logPath;

  m_config->getLogFilePath(&logPath);

  if (logPath.isEmpty()) {
    logPath.setString(StringTable::getString(IDS_LOGPATH_UNAVALIABLE));
    m_openLogPathButton.setEnabled(false);
    m_logPathTB.setEnabled(false);
  }

  m_logPathTB.setText(logPath.getString());

  StringStorage folder;
  getFolderName(logPath.getString(), &folder);
  HANDLE hDoc = CreateFile(folder.getString(), GENERIC_READ,
                           FILE_SHARE_READ, 0, OPEN_EXISTING,
                           FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);
  if (hDoc == INVALID_HANDLE_VALUE) {
    m_openLogPathButton.setEnabled(false);
  } else {
    CloseHandle(hDoc);
    m_openLogPathButton.setEnabled(true);
  }

  for (int i = 0; i < 5; i++) {
    m_shared[0].check(false);
  }

  if (m_config->isAlwaysShared() && !m_config->isNeverShared() && !m_config->isDisconnectingExistingClients()) {
    m_shared[0].check(true);
  }
  if (!m_config->isAlwaysShared() && m_config->isNeverShared() && !m_config->isDisconnectingExistingClients()) {
    m_shared[1].check(true);
  }
  if (!m_config->isAlwaysShared() && m_config->isNeverShared() && m_config->isDisconnectingExistingClients()) {
    m_shared[2].check(true);
  }
  if (!m_config->isAlwaysShared() && !m_config->isNeverShared() && !m_config->isDisconnectingExistingClients()) {
    m_shared[3].check(true);
  }
  if (!m_config->isAlwaysShared() && !m_config->isNeverShared() && m_config->isDisconnectingExistingClients()) {
    m_shared[4].check(true);
  }

  for (int i = 0; i < 3; i++) {
    m_disconnectAction[i].check(false);
  }
  switch (m_config->getDisconnectAction()) {
  case ServerConfig::DA_DO_NOTHING:
    m_disconnectAction[0].check(true);
    break;
  case ServerConfig::DA_LOCK_WORKSTATION:
    m_disconnectAction[1].check(true);
    break;
  case ServerConfig::DA_LOGOUT_WORKSTATION:
    m_disconnectAction[2].check(true);
    break;
  }

  m_logForAllUsers.check(m_config->isSaveLogToAllUsersPathFlagEnabled());

  if (m_config->hasControlPassword()) {
    unsigned char cryptedPassword[8];

    m_config->getControlPassword(cryptedPassword);

    m_cpControl->setCryptedPassword((char *)cryptedPassword);
  }

  m_cpControl->setEnabled(m_config->isControlAuthEnabled());
}