BOOL SERVER::RefreshStatus (BOOL fNotify, ULONG *pStatus) { BOOL rc = TRUE; DWORD status = 0; if (m_fStatusOutOfDate) { m_fStatusOutOfDate = FALSE; if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusBegin, GetIdentifier()); LPCELL lpCell; if ((lpCell = OpenCell (&status)) == NULL) rc = FALSE; else { PVOID hCell; if ((hCell = lpCell->GetCellObject (&status)) == NULL) rc = FALSE; else { WORKERPACKET wp; wp.wpClientAFSServerGet.hCell = hCell; wp.wpClientAFSServerGet.pszServer = m_szName; if (!Worker_DoTask (wtaskClientAFSServerGet, &wp, &status)) rc = FALSE; else { m_ss.nAddresses = 0; for (size_t iAddr = 0; iAddr < AFS_MAX_SERVER_ADDRESS; ++iAddr) { if (wp.wpClientAFSServerGet.Entry.serverAddress[ iAddr ] == 0) continue; AfsClass_IntToAddress (&m_ss.aAddresses[ m_ss.nAddresses++ ], wp.wpClientAFSServerGet.Entry.serverAddress[ iAddr ]); } lpCell->m_lServers->Update (this); // That update affected a hashlistkey } } lpCell->Close(); } if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshStatusEnd, GetIdentifier(), ((rc) ? 0 : status)); } if (pStatus && !rc) *pStatus = status; return TRUE; }
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); } }