void WebServerPage::updateState(ServerState aNewState) noexcept { tstring statusText; if (aNewState == STATE_STARTED) { ctrlStart.SetWindowText(CTSTRING(STOP)); if (!lastError.empty()) { statusText += lastError + _T("\n"); } statusText += TSTRING(WEB_SERVER_RUNNING); } else if(aNewState == STATE_STOPPING) { statusText += TSTRING(STOPPING); //ctrlStatus.SetWindowText(_T("Stopping...")); } else if (aNewState == STATE_STOPPED) { ctrlStart.SetWindowText(CTSTRING(START)); if (lastError.empty()) { statusText += TSTRING(WEB_SERVER_STOPPED); } else { statusText += TSTRING_F(WEB_SERVER_START_FAILED, lastError.c_str()); } } ctrlStatus.SetWindowText(statusText.c_str()); ctrlStart.EnableWindow(aNewState == STATE_STOPPING ? FALSE : TRUE); currentState = aNewState; }
bool FavHubGeneralPage::write() { TCHAR buf[1024]; GetDlgItemText(IDC_HUBADDR, buf, 256); if (buf[0] == '\0') { WinUtil::showMessageBox(TSTRING(INCOMPLETE_FAV_HUB), MB_ICONWARNING); return false; } //check the primary address for dupes string addresses = Text::fromT(buf); size_t pos = addresses.find(";"); if (!FavoriteManager::getInstance()->isUnique(pos != string::npos ? addresses.substr(0, pos) : addresses, entry->getToken())) { WinUtil::showMessageBox(TSTRING(FAVORITE_HUB_ALREADY_EXISTS), MB_ICONWARNING); return false; } //validate the encoding GetDlgItemText(IDC_ENCODING, buf, 512); if (_tcschr(buf, _T('.')) == NULL && _tcscmp(buf, Text::toT(Text::utf8).c_str()) != 0 && ctrlEncoding.GetCurSel() != 0) { WinUtil::showMessageBox(TSTRING_F(INVALID_ENCODING, buf), MB_ICONWARNING); return false; } //set the values entry->get(HubSettings::NmdcEncoding) = ctrlEncoding.GetCurSel() != 0 ? Text::fromT(buf) : Util::emptyString; entry->setServer(addresses); GetDlgItemText(IDC_HUBNAME, buf, 256); entry->setName(Text::fromT(buf)); GetDlgItemText(IDC_HUBDESCR, buf, 256); entry->setDescription(Text::fromT(buf)); GetDlgItemText(IDC_HUBPASS, buf, 256); entry->setPassword(Text::fromT(buf)); //Hub settings GetDlgItemText(IDC_NICK, buf, 256); entry->get(HubSettings::Nick) = Text::fromT(buf); GetDlgItemText(IDC_USERDESC, buf, 256); entry->get(HubSettings::Description) = Text::fromT(buf); GetDlgItemText(IDC_EMAIL, buf, 256); entry->get(HubSettings::Email) = Text::fromT(buf); CComboBox combo; combo.Attach(GetDlgItem(IDC_FAV_DLG_GROUP)); if (combo.GetCurSel() == 0) { entry->setGroup(Util::emptyString); } else { tstring text(combo.GetWindowTextLength() + 1, _T('\0')); combo.GetWindowText(&text[0], text.size()); text.resize(text.size() - 1); entry->setGroup(Text::fromT(text)); } combo.Detach(); auto p = ShareManager::getInstance()->getProfiles(); ProfileToken token = HUB_SETTING_DEFAULT_INT; if (hideShare) { token = SP_HIDDEN; } else if (entry->isAdcHub() && ctrlProfile.GetCurSel() != 0) { token = p[ctrlProfile.GetCurSel() - 1]->getToken(); } entry->get(HubSettings::ShareProfile) = token; //FavoriteManager::getInstance()->save(); return true; }