void
CNdasDevicePropGeneralPage::_UpdateLogDeviceData(
	ndas::UnitDevicePtr pUnitDevice)
{
	NDAS_LOGICALDEVICE_ID logDeviceId = pUnitDevice->GetLogicalDeviceId();

	ndas::LogicalDevicePtr pLogDevice;
	if (!ndas::FindLogicalDevice(pLogDevice, logDeviceId))
	{
		m_wndLogDeviceTree.DeleteAllItems();
		m_wndLogDeviceTree.ShowWindow(SW_HIDE);
		m_wndLogDeviceNA.ShowWindow(SW_SHOW);
		return;
	}
	else
	{
		m_wndLogDeviceTree.ShowWindow(SW_SHOW);
		m_wndLogDeviceNA.ShowWindow(SW_HIDE);
	}

	//
	// TODO: To handle errors
	//
	(void) pLogDevice->UpdateInfo();
	(void) pLogDevice->UpdateStatus();

	NDAS_LOGICALDEVICE_TYPE logDevType = pLogDevice->GetType();
	NDAS_LOGICALDEVICE_STATUS logDevStatus = pLogDevice->GetStatus();

	CString strStatus = pLogicalDeviceStatusString(
		logDevStatus, 
		pLogDevice->GetNdasLogicalUnitError(), 
		pLogDevice->GetMountedAccess());

	CString strType = pLogicalDeviceTypeString(logDevType);

	const NDASUSER_LOGICALDEVICE_INFORMATION* pLogDeviceInfo = pLogDevice->GetLogicalDeviceInfo();

	CString strCapacity = pBlockCapacityString(
		pLogDeviceInfo->SubType.LogicalDiskInformation.Blocks);

	CString strRootNode;
	strRootNode.Format(_T("%s (%s) - %s"), strType, strCapacity, strStatus);

	m_wndLogDeviceTree.DeleteAllItems();

	CTreeItem rootItem = m_wndLogDeviceTree.InsertItem(
		strRootNode, 
		TVI_ROOT, 
		TVI_LAST);

	CString strNodeText;
	CString strLocationCaption;
//	strLocationCaption.LoadString(IDS_LOGDEV_LOCATION);
//	strNodeText.Format(_T("%s %s"), strLocationCaption, strLocation);
//	strNodeText.Format(_T("%s"), strLocation);
//	CTreeItem tiLocation = tiRoot.AddTail(strNodeText, 0);
//	tiLocation.Expand();

	CTreeItem memberItem = rootItem; // .AddTail(_T("Members"), 0);

	//
	// Encryption information
	//
	{
		if (NULL != pLogDeviceInfo && 
			IS_NDAS_LOGICALDEVICE_TYPE_DISK(pLogDevice->GetType()) &&
			0 != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Revision &&
			NDAS_CONTENT_ENCRYPT_TYPE_NONE != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Type)
		{
			CString strNode = pNdasLogicalDiskEncryptString(pLogDeviceInfo);
			memberItem.AddTail(strNode, 0);
			// m_wndLogDeviceTree.InsertItem(strNode, TVI_ROOT, TVI_LAST);
		}
	}

	for (DWORD i = 0; i < pLogDevice->GetUnitDeviceInfoCount(); ++i) 
	{

		CString strNode;
		ndas::LogicalDevice::UNITDEVICE_INFO ui = 
			pLogDevice->GetUnitDeviceInfo(i);

		ndas::DevicePtr pMemberDevice;
		if (!ndas::FindDeviceByNdasId(pMemberDevice, ui.DeviceId))
		{
			CString strMissingDeviceId = 
				pDelimitedDeviceIdString2(CString(ui.DeviceId), m_chConcealed);

			if (0 == ui.UnitNo)
			{
				// "[%1!d!] %2!s! (Not registered)"
				strNode.FormatMessage(
					IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, 
					ui.Index + 1,
					strMissingDeviceId);
			}
			else
			{
				// "[%1!d!] %2!s!:%3!d! (Not registered)"
				strNode.FormatMessage(
					IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, 
					ui.Index + 1,
					strMissingDeviceId,
					ui.UnitNo + 1);
			}
			memberItem.AddTail(strNode, 0);
			continue;
		}

		ndas::UnitDevicePtr pMemberUnitDevice;

		if (!pMemberDevice->FindUnitDevice(pMemberUnitDevice, ui.UnitNo))
		{
			if (0 == ui.UnitNo)
			{
				// "[%1!d!] Unavailable (%2!s!)"
				strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_0_FMT, 
					ui.Index + 1,
					pMemberDevice->GetName());
			}
			else
			{
				// "[%1!d!] Unavailable (%2!s!:%3!d!)"
				strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_FMT, 
					ui.Index + 1,
					pMemberDevice->GetName(), 
					ui.UnitNo + 1);
			}
			memberItem.AddTail(strNode, 0);
			continue;
		}

		if (0 == ui.UnitNo)
		{
			// 	"[%1!d!] %2!s!"
			strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_0_FMT, 
				ui.Index + 1, 
				pMemberDevice->GetName());
		}
		else
		{
			// 	"[%1!d!] %2!s!:%3!d! "
			strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_FMT, 
				ui.Index + 1, 
				pMemberDevice->GetName(), 
				ui.UnitNo + 1);
		}

		memberItem.AddTail(strNode, 0);
	}

	memberItem.Expand();
	rootItem.Expand();

}
예제 #2
0
void
CGeneralPage::GenerateLogDevTree(
	ndas::UnitDevice* pUnitDevice)
{
	CString strRootNode;

	NDAS_LOGICALDEVICE_ID logDevId = pUnitDevice->GetLogicalDeviceId();

	ndas::LogicalDevice* pLogDev = _pLogDevColl->FindLogicalDevice(logDevId);

	if (NULL == pLogDev) {

		strRootNode.LoadString(IDS_LOGDEV_INFO_UNAVAILABLE);
		CTreeItem tiRoot = m_tvLogDev.InsertItem(
			strRootNode, 
			TVI_ROOT, 
			TVI_LAST);

		return;
	}

	//
	// TODO: To handle errors
	//
	(VOID) pLogDev->UpdateInfo();
	(VOID) pLogDev->UpdateStatus();

	NDAS_LOGICALDEVICE_TYPE logDevType = pLogDev->GetType();
	NDAS_LOGICALDEVICE_STATUS logDevStatus = pLogDev->GetStatus();

	CString strType, strLocation, strStatus;

	pLogicalDeviceStatusString(
		strStatus, 
		logDevStatus, 
		pLogDev->GetMountedAccess());

	pLogicalDeviceTypeString(strType, logDevType);

	//	Slot %1!d!, Target ID %2!d!, LUN %3!d!
	//strLocation.FormatMessage(
	//	IDS_LOGDEV_LOCATION_FMT,
	//	pLogDev->GetLogicalDeviceId());

	strRootNode.Format(_T("%s - %s"), strType, strStatus);

	m_tvLogDev.DeleteAllItems();

	CTreeItem tiRoot = m_tvLogDev.InsertItem(
		strRootNode, 
		TVI_ROOT, 
		TVI_LAST);

	CString strNodeText;
	CString strLocationCaption;
//	strLocationCaption.LoadString(IDS_LOGDEV_LOCATION);
//	strNodeText.Format(_T("%s %s"), strLocationCaption, strLocation);
	strNodeText.Format(_T("%s"), strLocation);
//	CTreeItem tiLocation = tiRoot.AddTail(strNodeText, 0);
//	tiLocation.Expand();

	CTreeItem tiMember = tiRoot; // .AddTail(_T("Members"), 0);

	for (DWORD i = 0; i < pLogDev->GetUnitDeviceInfoCount(); ++i) {

		CString strNode;
		ndas::LogicalDevice::UNITDEVICE_INFO ui = 
			pLogDev->GetUnitDeviceInfo(i);

		ndas::Device* pMemberDevice = 
			_pDeviceColl->FindDevice(ui.DeviceId);

		if (NULL == pMemberDevice) {
			// "[%1!d!] Missing Entry"
			strNode.FormatMessage(
				IDS_LOGICALDEVICE_ENTRY_MISSING_FMT, 
				ui.Index + 1);
			tiMember.AddTail(strNode, 0);
			continue;
		}

		ndas::UnitDevice* pMemberUnitDevice = 
			pMemberDevice->FindUnitDevice(ui.UnitNo);

		if (NULL == pMemberUnitDevice) {
			// "[%1!d!] Unavailable (%2!s!:%3!d!)"
			strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_FMT, 
				ui.Index + 1,
				pMemberDevice->GetName(), 
				ui.UnitNo);
			tiMember.AddTail(strNode, 0);
			pMemberDevice->Release();
			continue;
		}

		// 	"[%1!d!] %2!s!:%3!d! "
		strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_FMT, 
			ui.Index + 1, 
			pMemberDevice->GetName(), 
			ui.UnitNo);

		tiMember.AddTail(strNode, 0);
		pMemberUnitDevice->Release();
		pMemberDevice->Release();
	}

	tiMember.Expand();
	tiRoot.Expand();

	pLogDev->Release();
}