bool FavHubOptionsPage::write() { TCHAR buf[1024]; GetDlgItemText(IDC_AWAY_MSG, buf, 1024); entry->get(HubSettings::AwayMsg) = Text::fromT(buf); entry->get(HubSettings::ShowJoins) = to3bool(IsDlgButtonChecked(IDC_SHOW_JOIN)); entry->get(HubSettings::FavShowJoins) = to3bool(IsDlgButtonChecked(IDC_SHOW_JOIN_FAV)); entry->get(HubSettings::LogMainChat) = to3bool(IsDlgButtonChecked(IDC_LOGMAINCHAT)); entry->get(HubSettings::ChatNotify) = to3bool(IsDlgButtonChecked(IDC_CHAT_NOTIFY)); auto val = HUB_SETTING_DEFAULT_INT; if (!IsDlgButtonChecked(IDC_SEARCH_INTERVAL_DEFAULT)) { GetDlgItemText(IDC_FAV_SEARCH_INTERVAL_BOX, buf, 512); val = Util::toInt(Text::fromT(buf)); } entry->get(HubSettings::SearchInterval) = val; // connection modes auto getConnMode = [](const CComboBox& combo) -> int { if (combo.GetCurSel() == 1) return SettingsManager::INCOMING_DISABLED; else if (combo.GetCurSel() == 2) return SettingsManager::INCOMING_ACTIVE; else if (combo.GetCurSel() == 3) return SettingsManager::INCOMING_PASSIVE; return HUB_SETTING_DEFAULT_INT; }; entry->get(HubSettings::Connection) = getConnMode(modeCombo4); entry->get(HubSettings::Connection6) = getConnMode(modeCombo6); //external ip addresses GetDlgItemText(IDC_SERVER4, buf, 512); entry->get(HubSettings::UserIp) = Text::fromT(buf); GetDlgItemText(IDC_SERVER6, buf, 512); entry->get(HubSettings::UserIp6) = Text::fromT(buf); //FavoriteManager::getInstance()->save(); return true; }
LRESULT FavHubProperties::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if(wID == IDOK) { TCHAR buf[1024]; GetDlgItemText(IDC_HUBADDR, buf, 256); if(buf[0] == '\0') { WinUtil::showMessageBox(TSTRING(INCOMPLETE_FAV_HUB), MB_ICONWARNING); return 0; } //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 0; } //validate the encoding GetDlgItemText(IDC_ENCODING, buf, 512); if(_tcschr(buf, _T('.')) == NULL && _tcscmp(buf, Text::toT(Text::utf8).c_str()) != 0 && _tcscmp(buf, _T("System default")) != 0) { WinUtil::showMessageBox(TSTRING(INVALID_ENCODING), MB_ICONWARNING); return 0; } //set the values entry->setEncoding(Text::fromT(buf)); entry->setServerStr(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)); entry->setStealth(IsDlgButtonChecked(IDC_STEALTH) == 1); entry->setFavNoPM(IsDlgButtonChecked(IDC_FAV_NO_PM) == 1); //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); GetDlgItemText(IDC_AWAY_MSG, buf, 1024); entry->get(HubSettings::AwayMsg) = Text::fromT(buf); entry->get(HubSettings::ShowJoins) = to3bool(IsDlgButtonChecked(IDC_SHOW_JOIN)); entry->get(HubSettings::FavShowJoins) = to3bool(IsDlgButtonChecked(IDC_SHOW_JOIN)); entry->get(HubSettings::LogMainChat) = to3bool(IsDlgButtonChecked(IDC_LOGMAINCHAT)); entry->get(HubSettings::ChatNotify) = to3bool(IsDlgButtonChecked(IDC_CHAT_NOTIFY)); entry->get(HubSettings::AcceptFailovers) = to3bool(IsDlgButtonChecked(IDC_FAILOVER)); auto val = HubSettings::getMinInt(); if (!IsDlgButtonChecked(IDC_SEARCH_INTERVAL_DEFAULT)) { GetDlgItemText(IDC_FAV_SEARCH_INTERVAL_BOX, buf, 512); val = Util::toInt(Text::fromT(buf)); } entry->get(HubSettings::SearchInterval) = val; 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(); // connection modes auto getConnMode = [](const CComboBox& combo) -> int { if (combo.GetCurSel() == 1) return SettingsManager::INCOMING_DISABLED; else if (combo.GetCurSel() == 2) return SettingsManager::INCOMING_ACTIVE; else if (combo.GetCurSel() == 3) return SettingsManager::INCOMING_PASSIVE; return HubSettings::getMinInt(); }; entry->get(HubSettings::Connection) = getConnMode(modeCombo4); entry->get(HubSettings::Connection6) = getConnMode(modeCombo6); //external ip addresses GetDlgItemText(IDC_SERVER4, buf, 512); entry->get(HubSettings::UserIp) = Text::fromT(buf); GetDlgItemText(IDC_SERVER6, buf, 512); entry->get(HubSettings::UserIp6) = Text::fromT(buf); auto p = ShareManager::getInstance()->getProfiles(); if(hideShare) { entry->setShareProfile(*(p.end()-1)); } else { if(entry->isAdcHub()) { entry->setShareProfile(p[ctrlProfile.GetCurSel()]); } else { entry->setShareProfile(p[0]); } } FavoriteManager::getInstance()->save(); } loaded = false; EndDialog(wID); return 0; }