CDeviceInfoList CServiceDeviceInfoFactory::Create() { if ( !NdasEnumDevices( EnumCallBack, reinterpret_cast<LPARAM>(this) ) ) { // TODO : ERROR : Fail to get device list NDAS_THROW_EXCEPTION(CServiceException, ::GetLastError()); } return m_listDevice; }
BOOL CMainFrame::RefreshStatus() { AutoCursor l_auto_cursor(IDC_WAIT); m_viewTreeList.GetTreeControl().DeleteAllItems(); ClearDevices(); // Initially, no commands are enabled // UIEnableForDevice(pDevice, IDM_TOOL_BIND); UIEnableForDevice(NULL, IDM_TOOL_UNBIND); UIEnableForDevice(NULL, IDM_TOOL_ADDMIRROR); UIEnableForDevice(NULL, IDM_TOOL_MIGRATE); UIEnableForDevice(NULL, IDM_TOOL_REPLACE_DEVICE); UIEnableForDevice(NULL, IDM_TOOL_REPLACE_UNIT_DEVICE); UIEnableForDevice(NULL, IDM_TOOL_SINGLE); UIEnableForDevice(NULL, IDM_TOOL_SPAREADD); UIEnableForDevice(NULL, IDM_TOOL_SPAREREMOVE); UpdateWindow(); // retrieve all the device & unit device information if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices))) { return FALSE; } m_wndRefreshProgress.ShowWindow(SW_SHOW); m_wndRefreshProgress.SetRange32(0, m_listDevices.size()); m_wndRefreshProgress.SetStep(1); m_wndRefreshProgress.SetPos(0); // initialize all the unit devices for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { if(!(*itDevice)->UnitDevicesInitialize()) { // add single empty device ATLTRACE(_T("Device not connected : %s\n"), (*itDevice)->GetName()); // m_wndRefreshProgress.ShowWindow(SW_HIDE); // return FALSE; } m_wndRefreshProgress.StepIt(); } // create logical devices CNBUnitDevice *pUnitDevice; CNBLogicalDevice *pLogicalDevice; m_wndRefreshProgress.SetPos(0); for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++) { // find logical device which has this unit device as member pLogicalDevice = NULL; pUnitDevice = (*(*itDevice))[i]; ATLASSERT(pUnitDevice); if(!pUnitDevice) return FALSE; for(NBLogicalDevicePtrList::iterator itLogicalDevice = m_listLogicalDevices.begin(); itLogicalDevice != m_listLogicalDevices.end(); itLogicalDevice++) { if((*itLogicalDevice)->IsMember(pUnitDevice)) { // add to this logical device pLogicalDevice = *itLogicalDevice; ATLTRACE(_T("use CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName()); break; } } if(NULL == pLogicalDevice) { // create new logical device pLogicalDevice = new CNBLogicalDevice(); m_listLogicalDevices.push_back(pLogicalDevice); ATLTRACE(_T("new CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName()); } if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice)) { m_wndRefreshProgress.ShowWindow(SW_HIDE); return FALSE; } } m_wndRefreshProgress.StepIt(); } m_viewTreeList.SetDevices(&m_listLogicalDevices); m_wndRefreshProgress.ShowWindow(SW_HIDE); return TRUE; }
BOOL CMainFrame::RefreshStatus() { // lock ActivateUI(FALSE); m_viewTreeList.GetTreeControl().DeleteAllItems(); ClearDevices(); // retrieve all the device & unit device information if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices))) return FALSE; m_wndRefreshProgress.ShowWindow(SW_SHOW); m_wndRefreshProgress.SetRange32(0, m_listDevices.size()); m_wndRefreshProgress.SetStep(1); m_wndRefreshProgress.SetPos(0); // initialize all the unit devices for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { if(!(*itDevice)->UnitDevicesInitialize()) { m_wndRefreshProgress.ShowWindow(SW_HIDE); return FALSE; } m_wndRefreshProgress.StepIt(); } // create logical devices CNBUnitDevice *pUnitDevice; CNBLogicalDevice *pLogicalDevice; UINT32 nLogicalDeviceIndex = 0; m_wndRefreshProgress.SetPos(0); for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++) { // find logical device which has this unit device as member pLogicalDevice = NULL; pUnitDevice = (*(*itDevice))[i]; for(NBLogicalDevicePtrMap::iterator itLogicalDevice = m_mapLogicalDevices.begin(); itLogicalDevice != m_mapLogicalDevices.end(); itLogicalDevice++) { if(itLogicalDevice->second->IsMember(pUnitDevice)) { // add to this logical device pLogicalDevice = itLogicalDevice->second; break; } } if(NULL == pLogicalDevice) { // create new logical device pLogicalDevice = new CNBLogicalDevice(nLogicalDeviceIndex); m_mapLogicalDevices[nLogicalDeviceIndex++] = pLogicalDevice; } if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice)) { m_wndRefreshProgress.ShowWindow(SW_HIDE); return FALSE; } } m_wndRefreshProgress.StepIt(); } m_viewTreeList.SetDevices(&m_mapLogicalDevices); m_wndRefreshProgress.ShowWindow(SW_HIDE); ActivateUI(TRUE); return TRUE; }
BOOL CMainFrame::RefreshStatus() { // lock ActivateUI(FALSE); m_viewTreeList.GetTreeControl().DeleteAllItems(); ClearDevices(); // retrieve all the device & unit device information if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices))) return FALSE; m_wndRefreshProgress.ShowWindow(SW_SHOW); m_wndRefreshProgress.SetRange32(0, m_listDevices.size()); m_wndRefreshProgress.SetStep(1); m_wndRefreshProgress.SetPos(0); // initialize all the unit devices for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { if(!(*itDevice)->UnitDevicesInitialize()) { // add single empty device ATLTRACE(_T("Device not connected : %s\n"), (*itDevice)->GetName()); // m_wndRefreshProgress.ShowWindow(SW_HIDE); // return FALSE; } m_wndRefreshProgress.StepIt(); } // create logical devices CNBUnitDevice *pUnitDevice; CNBLogicalDevice *pLogicalDevice; m_wndRefreshProgress.SetPos(0); for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin(); itDevice != m_listDevices.end(); itDevice++) { /* if(0 == (*itDevice)->UnitDevicesCount()) { // suppose to be disconnected pLogicalDevice = new CNBLogicalDevice(); pLogicalDevice->SetEmpty(); m_listLogicalDevices.push_back(pLogicalDevice); ATLTRACE(_T("new CNBLogicalDevice(%p) : empty\n"), pLogicalDevice); } */ for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++) { // find logical device which has this unit device as member pLogicalDevice = NULL; pUnitDevice = (*(*itDevice))[i]; ATLASSERT(pUnitDevice); if(!pUnitDevice) return FALSE; for(NBLogicalDevicePtrList::iterator itLogicalDevice = m_listLogicalDevices.begin(); itLogicalDevice != m_listLogicalDevices.end(); itLogicalDevice++) { if((*itLogicalDevice)->IsMember(pUnitDevice)) { // add to this logical device pLogicalDevice = *itLogicalDevice; ATLTRACE(_T("use CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName()); break; } } if(NULL == pLogicalDevice) { // create new logical device pLogicalDevice = new CNBLogicalDevice(); m_listLogicalDevices.push_back(pLogicalDevice); ATLTRACE(_T("new CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName()); } if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice)) { m_wndRefreshProgress.ShowWindow(SW_HIDE); return FALSE; } } m_wndRefreshProgress.StepIt(); } m_viewTreeList.SetDevices(&m_listLogicalDevices); m_wndRefreshProgress.ShowWindow(SW_HIDE); ActivateUI(TRUE); return TRUE; }