void SpeedPage::validateMCNLimits(WORD wNotifyCode) { if (IsDlgButtonChecked(IDC_MCN_AUTODETECT)) { return; } TCHAR buf[64]; if (wNotifyCode == CBN_SELENDOK) { ctrlUpload.GetLBText(ctrlUpload.GetCurSel(), buf); } else { GetDlgItemText(IDC_CONNECTION, buf, sizeof(buf) +1); } double uploadvalue = Util::toDouble(Text::fromT(buf)); TCHAR buf2[64]; if (wNotifyCode == CBN_SELENDOK) { ctrlDownload.GetLBText(ctrlDownload.GetCurSel(), buf2); } else { GetDlgItemText(IDC_DL_SPEED, buf2, sizeof(buf2) +1); } double downloadvalue = Util::toDouble(Text::fromT(buf2)); int downloadAutoSlots=AirUtil::getSlotsPerUser(true, downloadvalue); int uploadAutoSlots=AirUtil::getSlotsPerUser(false, uploadvalue); int mcnExtrasDL=maxMCNExtras(downloadvalue); int mcnExtrasUL=maxMCNExtras(uploadvalue); tstring aSlotsDL; aSlotsDL.resize(40); aSlotsDL.resize(GetDlgItemText(IDC_MCNDLSLOTS, &aSlotsDL[0], 40)); tstring aSlotsUL; aSlotsUL.resize(40); aSlotsUL.resize(GetDlgItemText(IDC_MCNULSLOTS, &aSlotsUL[0], 40)); //LogManager::getInstance()->message("DLslots: " + Util::toString(downloadAutoSlots) + " ULslots: " + Util::toString(uploadAutoSlots) + " MaxDLExtra: " + Util::toString(mcnExtrasDL) + " MaxULExtra: " + Util::toString(mcnExtrasUL) + " DL: " + Util::toString(downloadvalue) + " UL " + Util::toString(uploadvalue)); //LogManager::getInstance()->message("aSlotsDL: " + Text::fromT(aSlotsDL) + " aSlotsUL: " + Text::fromT(aSlotsUL)); if ((Util::toInt(Text::fromT(aSlotsDL)) > downloadAutoSlots + mcnExtrasDL)) { //LogManager::getInstance()->message("Change1"); if ((downloadAutoSlots + mcnExtrasDL) > 0) { SetDlgItemText(IDC_MCNDLSLOTS, Util::toStringW(downloadAutoSlots + mcnExtrasDL).c_str()); } } if ((Util::toInt(Text::fromT(aSlotsUL)) > uploadAutoSlots + mcnExtrasUL)) { //LogManager::getInstance()->message("Change2"); if ((uploadAutoSlots + mcnExtrasUL) > 0) { SetDlgItemText(IDC_MCNULSLOTS, Util::toStringW(uploadAutoSlots + mcnExtrasUL).c_str()); } } if ((Util::toInt(Text::fromT(aSlotsDL)) > Util::toInt(Text::fromT(aSlotsUL))) && (Util::toInt(Text::fromT(aSlotsUL)) < uploadAutoSlots)) { //LogManager::getInstance()->message("Change3"); if (Util::toInt(Text::fromT(aSlotsUL)) > 0) { SetDlgItemText(IDC_MCNDLSLOTS, aSlotsUL.c_str()); } } return; }
void SpeedPage::validateMCNLimits(WORD wNotifyCode) { if (loading) return; if (IsDlgButtonChecked(IDC_MCN_AUTODETECT)) { return; } // We don't allow setting per user download slots higher from the default value if upload slots have been lowered from the default TCHAR buf[64]; if (wNotifyCode == CBN_SELENDOK) { ctrlUpload.GetLBText(ctrlUpload.GetCurSel(), buf); } else { GetDlgItemText(IDC_CONNECTION, buf, sizeof(buf) +1); } double uploadvalue = Util::toDouble(Text::fromT(buf)); TCHAR buf2[64]; if (wNotifyCode == CBN_SELENDOK) { ctrlDownload.GetLBText(ctrlDownload.GetCurSel(), buf2); } else { GetDlgItemText(IDC_DL_SPEED, buf2, sizeof(buf2) +1); } double downloadvalue = Util::toDouble(Text::fromT(buf2)); int downloadAutoSlots = AirUtil::getSlotsPerUser(true, downloadvalue); int uploadAutoSlots = AirUtil::getSlotsPerUser(false, uploadvalue); int mcnExtrasDL = maxMCNExtras(downloadvalue); int mcnExtrasUL = maxMCNExtras(uploadvalue); ctrlMcnDL.GetWindowText(buf, 40); int fieldDlSlots = Util::toInt(Text::fromT(buf)); ctrlMcnUL.GetWindowText(buf, 40); int fieldUlSlots = Util::toInt(Text::fromT(buf)); /*if (fieldDlSlots == 0 && ctrlMcnDL.GetWindowTextLength() > 0) { ctrlMcnDL.SetWindowText(_T("")); } if (fieldUlSlots == 0 && ctrlMcnUL.GetWindowTextLength() > 0) { ctrlMcnUL.SetWindowText(_T("")); }*/ if (fieldDlSlots == 0 || (fieldDlSlots > downloadAutoSlots + mcnExtrasDL)) { if ((downloadAutoSlots + mcnExtrasDL) > 0) { fieldDlSlots = downloadAutoSlots + mcnExtrasDL; ctrlMcnDL.SetWindowText(Util::toStringW(fieldDlSlots).c_str()); } } if (fieldUlSlots == 0 || (fieldUlSlots > uploadAutoSlots + mcnExtrasUL)) { if ((uploadAutoSlots + mcnExtrasUL) > 0) { fieldUlSlots = uploadAutoSlots + mcnExtrasUL; ctrlMcnUL.SetWindowText(Util::toStringW(fieldUlSlots).c_str()); } } // download slots can't be more than upload slots if ((fieldDlSlots > fieldUlSlots) && fieldUlSlots < uploadAutoSlots) { ctrlMcnDL.SetWindowText(Util::toStringW(fieldUlSlots).c_str()); } return; }