void ChangeAddr_OnEndTask_Init (HWND hDlg, LPSVR_CHANGEADDR_PARAMS lpp, LPTASKPACKET ptp) { if (!ptp->rc) { TCHAR szName[ cchNAME ]; lpp->lpiServer->GetServerName (szName); ErrorDialog (ptp->status, IDS_ERROR_REFRESH_SERVER_STATUS, TEXT("%s"), szName); } else { memcpy (&lpp->ssOld, &TASKDATA(ptp)->ss, sizeof(SERVERSTATUS)); memcpy (&lpp->ssNew, &TASKDATA(ptp)->ss, sizeof(SERVERSTATUS)); ChangeAddr_Enable (hDlg, TRUE); } Server_FillAddrList (hDlg, &lpp->ssNew, FALSE); }
void Server_General_OnEndTask_InitDialog (HWND hDlg, LPIDENT lpiServer, LPTASKPACKET ptp) { TCHAR szText[ cchRESOURCE ]; if (!ptp->rc) { GetString (szText, IDS_UNKNOWN); SetDlgItemText (hDlg, IDC_SVR_NUMAGGREGATES, szText); SetDlgItemText (hDlg, IDC_SVR_CAPACITY, szText); SetDlgItemText (hDlg, IDC_SVR_ALLOCATION, szText); LB_StartChange (GetDlgItem (hDlg, IDC_SVR_ADDRESSES), TRUE); LB_AddItem (GetDlgItem (hDlg, IDC_SVR_ADDRESSES), szText, (LPARAM)-1); LB_EndChange (GetDlgItem (hDlg, IDC_SVR_ADDRESSES), (LPARAM)-1); lpiServer->GetServerName (szText); ErrorDialog (ptp->status, IDS_ERROR_REFRESH_SERVER_STATUS, TEXT("%s"), szText); } else { EnableWindow (GetDlgItem (hDlg, IDC_SVR_AUTH_YES), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SVR_AUTH_NO), TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SVR_CHANGEADDR), TRUE); wsprintf (szText, TEXT("%lu"), TASKDATA(ptp)->nAggr); SetDlgItemText (hDlg, IDC_SVR_NUMAGGREGATES, szText); LPTSTR pszText = FormatString (IDS_SVR_CAPACITY, TEXT("%.1B"), (double)TASKDATA(ptp)->ckCapacity * 1024.0); SetDlgItemText (hDlg, IDC_SVR_CAPACITY, pszText); FreeString (pszText); DWORD dwPercentUsed = 100; if (TASKDATA(ptp)->ckCapacity) dwPercentUsed = (DWORD)( (double)100 * TASKDATA(ptp)->ckAllocation / TASKDATA(ptp)->ckCapacity ); pszText = FormatString (IDS_SVR_ALLOCATION, TEXT("%.1B%lu"), (double)TASKDATA(ptp)->ckAllocation * 1024.0, dwPercentUsed); SetDlgItemText (hDlg, IDC_SVR_ALLOCATION, pszText); FreeString (pszText); Server_FillAddrList (hDlg, &TASKDATA(ptp)->ss); } }
void ChangeAddr_OnRemove (HWND hDlg, LPSVR_CHANGEADDR_PARAMS lpp) { HWND hList = GetDlgItem (hDlg, IDC_SVR_ADDRESSES); int iSel; if ((iSel = LB_GetSelected (hList)) != -1) { TCHAR szItem[ cchRESOURCE ] = TEXT(""); SendMessage (hList, LB_GETTEXT, iSel, (LPARAM)szItem); SOCKADDR_IN AddrSel; Server_ParseAddress (&AddrSel, szItem); int AddrSelInt; AfsClass_AddressToInt (&AddrSelInt, &AddrSel); if (AddrSelInt != 0) { for (size_t iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrSelInt) || (NewAddrInt == AddrSelInt)) { AfsClass_IntToAddress (&lpp->ssNew.aAddresses[iAddr], 0); } } } Server_FillAddrList (hDlg, &lpp->ssNew, FALSE); ChangeAddr_OnSelect (hDlg); } }
void ChangeAddr_OnChange (HWND hDlg, LPSVR_CHANGEADDR_PARAMS lpp) { HWND hList = GetDlgItem (hDlg, IDC_SVR_ADDRESSES); int iSel; if ((iSel = LB_GetSelected (hList)) != -1) { TCHAR szItem[ cchRESOURCE ] = TEXT(""); SendMessage (hList, LB_GETTEXT, iSel, (LPARAM)szItem); SOCKADDR_IN AddrSel; Server_ParseAddress (&AddrSel, szItem); int AddrSelInt; AfsClass_AddressToInt (&AddrSelInt, &AddrSel); if (AddrSelInt != 0) { SOCKADDR_IN AddrNew = AddrSel; if (ModalDialogParam (IDD_SVR_NEWADDR, hDlg, (DLGPROC)NewAddr_DlgProc, (LPARAM)&AddrNew) != IDOK) return; int AddrNewInt; AfsClass_AddressToInt (&AddrNewInt, &AddrNew); if (AddrNewInt && (AddrNewInt != AddrSelInt)) { // First see if the new IP address is already in the server's // list of IP addresses--if so, just delete the old address. // size_t iAddr; for (iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrNewInt) || (NewAddrInt == AddrNewInt)) { AddrNewInt = 0; break; } } // Now update the SERVERSTATUS structure. // for (iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr) { int OldAddrInt; AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]); int NewAddrInt; AfsClass_AddressToInt (&NewAddrInt, &lpp->ssNew.aAddresses[iAddr]); if ((OldAddrInt == AddrSelInt) || (NewAddrInt == AddrSelInt)) { AfsClass_IntToAddress (&lpp->ssNew.aAddresses[iAddr], AddrNewInt); break; } } } } Server_FillAddrList (hDlg, &lpp->ssNew, FALSE); ChangeAddr_OnSelect (hDlg); } }