// // Uniquely selects an interface given a manager and a string representing // the desired interface. // void CPageNetwork::CheckInterface( HTREEITEM hmgr, char *net_address ) { HTREEITEM hifc; if ( !hmgr ) { ErrorMessage("invalid tree item in CPageNetwork::CheckInterface()"); return; } // walk through its list of interfaces for ( hifc = m_TTargets.GetChildItem( hmgr ); hifc; hifc = m_TTargets.GetNextSiblingItem( hifc ) ) { // check to see if the current interface should have a check mark if ( net_address && !strcmp( m_TTargets.GetItemText(hifc), net_address ) ) { // found it! set its check mark SetSelectionCheck( hifc, TargetChecked ); } else { // not the one. clear its check mark SetSelectionCheck( hifc, TargetUnChecked ); } } }
// // Used to select one or more targets. May or may not clear any previous // selection depending on the replace parameter. // void CPageNetwork::SelectRange( HTREEITEM hstart, HTREEITEM hend, BOOL replace, TargetSelType state ) { HTREEITEM hmgr, hifc; BOOL in_range; if ( !hstart || !hend ) { ErrorMessage( "Unexpectedly found start or end point of selection" " range equal NULL in CPageNetwork::SelectRange()." ); return; } // Clear all the check boxes if forced to or if a multiple selection occurs. if ( replace ) SetAllCheck( TargetUnChecked ); // The last selection is the start point. selected = hstart; highlighted = hend; // Note that if both endpoints are the same, other selections will be // unchecked depending on the value of the 'replace' variable. if ( hstart == hend ) { SetSelectionCheck( hstart, state ); return; } // Since we don't know the relationship between the clicked item // and the last selection (up or down), we do not know what // direction to select targets in. Do a linear seach of the target tree // until we find either the start or end point. From there, mark // all the targets the specified selection type until we reach the end or // start (whichever we didn't get before). in_range = FALSE; for ( hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem( hmgr ) ) { for ( hifc = m_TTargets.GetChildItem( hmgr ); hifc; hifc = m_TTargets.GetNextSiblingItem( hifc ) ) { // Do we have either the previously selected item or the // clicked item? if ( hifc == hstart || hifc == hend ) in_range = !in_range; // If we are between the start and end point, set the state. if ( in_range || hifc == hstart || hifc == hend ) SetSelectionCheck( hifc, state ); } } }
// // Sets all the interface's check box to the specified state. // void CPageDisk::SetAllCheck(TargetSelType selection) { HTREEITEM hdisk; // Get the first manager item of the target tree for (hdisk = m_TTargets.GetRootItem(); hdisk; hdisk = m_TTargets.GetNextSiblingItem(hdisk)) { SetSelectionCheck(hdisk, selection); } }
// // Sets all the interface's check box to the specified state. // void CPageDisk::SetAllCheck(TargetSelType selection) { HTREEITEM hdisk; // Get the first manager item of the target tree hdisk = m_TTargets.GetRootItem(); // recurse into tree; assumes only 2 levels!!! while(hdisk) { SetSelectionCheck(hdisk, selection); hdisk = GetNextTreeObject(hdisk); } }
// // Sets all the interface's check box to the specified state. // void CPageNetwork::SetAllCheck(TargetSelType selection) { HTREEITEM hmgr; HTREEITEM hifc; // Get the first manager item of the target tree for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) { // walk through its list of interfaces for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) { SetSelectionCheck(hifc, selection); } } }
void CPageDisk::ShowTargetSelection() { Manager *manager; Worker *worker; HTREEITEM hiface; int w, i, expected_worker, iface_count, wkr_count; TargetSelType state; Target_Spec target_info; // Get the selected manager. manager = theApp.pView->m_pWorkerView->GetSelectedManager(); // Get the first disk item from the target tree. hiface = m_TTargets.GetRootItem(); switch ( theApp.pView->m_pWorkerView->GetSelectedType() ) { case WORKER: // A worker is selected, show its assigned targets. worker = theApp.pView->m_pWorkerView->GetSelectedWorker(); // Loop through the manager's disks, and mark which ones are selected // for the worker. iface_count = manager->InterfaceCount( GenericDiskType ); for ( i = 0; i < iface_count; i++ ) { if ( worker->IsTargetAssigned( manager->GetInterface(i, GenericDiskType))) SetSelectionCheck( hiface, TargetChecked ); else SetSelectionCheck( hiface, TargetUnChecked ); hiface = m_TTargets.GetNextSiblingItem( hiface ); } break; case MANAGER: // Show the targets assigned to a manager's workers if possible. expected_worker = 0; // Loop through the manager's disks, and see if they are assigned // to the expected worker. If not, gray all of them and return. iface_count = manager->InterfaceCount( GenericDiskType ); wkr_count = manager->WorkerCount( GenericDiskType ); for ( i = 0; i < iface_count; i++ ) { memcpy( &target_info, manager->GetInterface( i, GenericDiskType ), sizeof( Target_Spec ) ); state = TargetUnChecked; for ( w = 0; w < wkr_count; w++ ) { // If the disk is selected by any other than expected // worker, all the disk check boxes are grayed. if ( manager->GetWorker(w, GenericDiskType)->IsTargetAssigned( &target_info ) ) { if ( w != expected_worker || state != TargetUnChecked ) { SetAllCheck( TargetGrayed ); return; } state = TargetChecked; if ( ++expected_worker == wkr_count ) { expected_worker = 0; } } } SetSelectionCheck( hiface, state ); hiface = m_TTargets.GetNextSiblingItem( hiface ); } break; default: SetAllCheck( TargetGrayed ); break; } }
void CPageNetwork::ShowTargetSelection() { Manager *manager, *partner_manager; Worker *worker, *partner_worker; char *remote_address; HTREEITEM hmgr; HTREEITEM hifc; int i, expected_worker; TargetSelType state; switch (theApp.pView->m_pWorkerView->GetSelectedType()) { case WORKER: worker = theApp.pView->m_pWorkerView->GetSelectedWorker(); // Get the interface to check. if (IsType(worker->Type(), GenericServerType)) { if (!worker->net_partner) { partner_manager = NULL; } else { partner_manager = worker->net_partner->manager; if (IsType(worker->GetTarget(0)->spec.type, TCPClientType)) remote_address = worker->GetTarget(0)->spec.tcp_info.remote_address; else if (IsType(worker->GetTarget(0)->spec.type, VIClientType)) remote_address = worker->GetTarget(0)->spec.vi_info.remote_nic_name; else { ErrorMessage("Invalid client target type in CPageNetwork::" "ShowTargetSelection()."); return; } } } else if (IsType(worker->Type(), GenericClientType)) { partner_manager = worker->net_partner->manager; remote_address = worker->net_partner->spec.name; } else { return; } // Walk the target tree to find the correct partner manager. for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) { if (m_TTargets.GetItemData(hmgr) == (DWORD_PTR) partner_manager) { // Check the appropriate interface on the partner manager. CheckInterface(hmgr, remote_address); } else { // Clear all check marks for this manager's interfaces. CheckInterface(hmgr, NULL); } } break; case MANAGER: // Get the selected manager. manager = theApp.pView->m_pWorkerView->GetSelectedManager(); expected_worker = 0; // Loop through all the target tree items. for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) { // Get the possible partner manager from the tree. partner_manager = (Manager *) m_TTargets.GetItemData(hmgr); // Loop through that manager item's interfaces. for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) { // Initialize the state. It may or may not be changed, // depending on whether we find it selected by a worker. state = TargetUnChecked; // Check the interface for selection by any of the manager's // workers for (i = 0; i < manager->WorkerCount(GenericServerType); i++) { // Get the net partner of the expected worker. partner_worker = manager->GetWorker(i, GenericServerType)->net_partner; // If the partner worker exists and it's manager is the // same as the manager in the target tree that we are // currently looking at and.. if (partner_worker && partner_worker->manager == partner_manager) { // if the net addresses match but.. if (m_TTargets.GetItemText(hifc) == partner_worker->GetLocalNetworkInterface()) { // the worker is not the expected worker.. if (i != expected_worker || state != TargetUnChecked) { // gray the selection SetAllCheck(TargetGrayed); return; } state = TargetChecked; expected_worker++; } } } SetSelectionCheck(hifc, state); } } break; default: SetAllCheck(TargetGrayed); break; } }