Exemple #1
0
LRESULT CNBBindListViewCtrl::OnGetDispInfo(LPNMHDR lParam)
{
	NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lParam);
	CDiskObjectPtr obj;
	const CObjectUIHandler *phandler;

	obj = m_mapObject[static_cast<UINT>(pDispInfo->item.lParam)];
	ATLASSERT( obj.get() != NULL );

	phandler = CObjectUIHandler::GetUIHandler( obj );
	
	switch ( pDispInfo->item.iSubItem )
	{
	case 0: // Index
		::_stprintf(
			pDispInfo->item.pszText,
			_T("%d"), 
			pDispInfo->item.iItem
			);
		break;
	case 1:	// Name
		::_tcsncpy( 
			pDispInfo->item.pszText,  
			obj->GetTitle(),
			pDispInfo->item.cchTextMax-1
			);
		break;
	case 2:	// ID
/*
		::_tcsncpy(
			pDispInfo->item.pszText,  
			phandler->GetStringID( obj ),
			pDispInfo->item.cchTextMax-1
			);
		break;
	case 3: // Size
*/
		{
			WTL::CString strSize;
			strSize.FormatMessage(
				IDS_LISTVIEW_SIZE_IN_GB,
				phandler->GetSizeInMB( obj ) / 1024,
				(phandler->GetSizeInMB( obj ) % 1024) / 10
				);
			::_tcsncpy(
				pDispInfo->item.pszText,  
				strSize,
				pDispInfo->item.cchTextMax-1
				);
		}		
	default:
		break;
	}
	pDispInfo->item.pszText[pDispInfo->item.cchTextMax-1] = '\0';
	return 0;
}
Exemple #2
0
BOOL CUnsupportedDiskUIHandler::OnClearDIB(CDiskObjectPtr obj) const
{
	ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);

	WTL::CString strWarning;
	strWarning.FormatMessage( 
			IDS_UIHANDLER_CLEARDIB_CONFIRM,
			obj->GetTitle()
			);
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);
	if ( MessageBox(::GetFocus(), strWarning, strTitle, MB_YESNO | MB_ICONWARNING) != IDYES )
	{
		return TRUE;
	}
	CUnitDiskObjectPtr unitDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	if ( !unitDisk->CanAccessExclusive() )
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY );
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return TRUE;
	}
	try {
		unitDisk->Open( TRUE );
        unitDisk->Initialize( unitDisk );
		unitDisk->CommitDiskInfo();
		unitDisk->Close();
	}
	catch( CNDASException & )
	{
		unitDisk->Close();
		WTL::CString strMsg;
		strMsg.LoadString ( IDS_UIHANDLER_CLEARDIB_FAIL );
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONERROR
			);
		return TRUE;
	}
	WTL::CString strMsg;
	strMsg.LoadString( IDS_UIHANDLER_CLEARDIB_SUCCESS );
	return TRUE;
}
Exemple #3
0
WTL::CString CNBDevice::GetCapacityString(UINT64 ui64capacity)
{
	WTL::CString strText;
	UINT64 ui64capacityMB = ui64capacity / (1024 * 1024);
	UINT32 uicapacityGB = (UINT32)(ui64capacityMB / 1000);
	UINT32 uicapacityMB = (UINT32)(ui64capacityMB % 1000);

	if(0 == ui64capacityMB)
	{
		strText = _T("");
	}
	else
	{
		strText.FormatMessage(IDS_DISKPROPERTYPAGE_SIZE_IN_GB, uicapacityGB, uicapacityMB);
	}

	return strText;
}
Exemple #4
0
void CNBListViewCtrl::AddDiskObject(CDiskObjectPtr o)
{
	LVITEM lvItem = { 0 };
	const CObjectUIHandler *pHandler = CObjectUIHandler::GetUIHandler(o);
	WTL::CString strName = pHandler->GetTitle(o);
	WTL::CString strCapacity;

	strCapacity.FormatMessage( 
		IDS_DISKPROPERTYPAGE_SIZE_IN_GB,
		pHandler->GetSizeInMB( o ) / 1024,
		(pHandler->GetSizeInMB( o ) % 1024) / 10 
		);

	lvItem.mask		= LVIF_TEXT | LVIF_PARAM;
	lvItem.iItem	= GetItemCount();
	lvItem.pszText	= strName.LockBuffer(); //LPSTR_TEXTCALLBACK;
	lvItem.lParam	= static_cast<LPARAM>(o->GetUniqueID());
	CListViewCtrl::InsertItem( &lvItem );
	CListViewCtrl::SetItemText(lvItem.iItem, 1, strCapacity.LockBuffer() );
	m_mapObject[o->GetUniqueID()] = o;
}
Exemple #5
0
WTL::CString CObjectUIHandler::GetType(CDiskObjectPtr obj) const
{
	WTL::CString strTitle;

	if(obj->IsUnitDisk())
	{
		if(dynamic_cast<CEmptyDiskObject*>(obj.get()) != NULL)
		{
			strTitle.LoadString(IDS_UNIDEV_TYPE_DISK_EMPTY);
		}
		else
		{
			strTitle.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK);
		}
	}
	else
	{
		CDiskObjectCompositePtr pDiskObjectComposite = 
			boost::dynamic_pointer_cast<CDiskObjectComposite>(obj);


		switch(pDiskObjectComposite->GetNDASMediaType())
		{
		case NMT_SINGLE: strTitle.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
		case NMT_AGGREGATE: strTitle.LoadString(IDS_LOGDEV_TYPE_AGGREGATED_DISK); break;
		case NMT_MIRROR: strTitle.LoadString(IDS_LOGDEV_TYPE_MIRRORED_DISK); break;
		case NMT_RAID0: strTitle.LoadString(IDS_LOGDEV_TYPE_DISK_RAID0); break;
		case NMT_RAID1: strTitle.LoadString(IDS_LOGDEV_TYPE_DISK_RAID1); break;
		case NMT_RAID4: strTitle.LoadString(IDS_LOGDEV_TYPE_DISK_RAID4); break;
		case NMT_CDROM: strTitle.LoadString(IDS_LOGDEV_TYPE_DVD_DRIVE); break;
		case NMT_OPMEM: strTitle.LoadString(IDS_LOGDEV_TYPE_MO_DRIVE); break;
		case NMT_FLASH: strTitle.LoadString(IDS_LOGDEV_TYPE_CF_DRIVE); break;
		default:
			strTitle.FormatMessage(IDS_LOGDEV_TYPE_UNKNOWN_FMT, 
				pDiskObjectComposite->GetNDASMediaType());
		}
	}

	return strTitle;
}
Exemple #6
0
WTL::CString CNBLogicalDevice::GetTypeString()
{
	WTL::CString strText;

	switch(GetType())
	{
	case NMT_INVALID: strText = _T(""); break;
	case NMT_SINGLE: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_AGGREGATE: strText.LoadString(IDS_LOGDEV_TYPE_AGGREGATED_DISK); break;
	case NMT_MIRROR: strText.LoadString(IDS_LOGDEV_TYPE_MIRRORED_DISK); break;
	case NMT_RAID0: strText.LoadString(IDS_LOGDEV_TYPE_DISK_RAID0); break;
	case NMT_RAID1: strText.LoadString(IDS_LOGDEV_TYPE_DISK_RAID1); break;
	case NMT_RAID4: strText.LoadString(IDS_LOGDEV_TYPE_DISK_RAID4); break;
	case NMT_CDROM: strText.LoadString(IDS_LOGDEV_TYPE_DVD_DRIVE); break;
	case NMT_OPMEM: strText.LoadString(IDS_LOGDEV_TYPE_MO_DRIVE); break;
	case NMT_FLASH: strText.LoadString(IDS_LOGDEV_TYPE_CF_DRIVE); break;
	default:
		strText.FormatMessage(IDS_LOGDEV_TYPE_UNKNOWN_FMT, GetType());
	}

	return strText;
}
Exemple #7
0
WTL::CString CNBLogicalDevice::GetName()
{
	ATLASSERT(m_mapUnitDevices.size());

	WTL::CString strText;

	if(0 == m_mapUnitDevices.size())
	{
		strText.FormatMessage(IDS_LOGDEV_TYPE_UNKNOWN_FMT, NMT_INVALID);
	}
	else if(IsGroup())
	{
		strText = GetTypeString();
	}
	else
	{
		ATLASSERT(1 == m_mapUnitDevices.size() && m_mapUnitDevices.count(0));

		strText = m_mapUnitDevices[0]->GetName();
	}

	return strText;
}
Exemple #8
0
// 0 to automatically advance to the next page
// -1 to prevent the page from changing
INT 
CSelectDiskPage::OnWizardNext()
{
	ATLASSERT( m_wndListBind.GetItemCount() == (int)m_pWizData->m_nDiskCount);
	ATLASSERT( 
		NMT_AGGREGATE == m_pWizData->m_nBindType || 
		NMT_RAID0 == m_pWizData->m_nBindType || 
		NMT_RAID1 == m_pWizData->m_nBindType || 
		NMT_RAID4 == m_pWizData->m_nBindType);

	NBUnitDevicePtrList listBind;
	unsigned int i;
	UINT32 BindResult;
	WTL::CString strMsg;

	// warning message
	{
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		strMsg.LoadString(IDS_WARNING_BIND);
		int id = MessageBox(
			strMsg,
			strTitle,
			MB_YESNO|MB_ICONEXCLAMATION
			);
		if(IDYES != id)
			return -1;
	}

	m_pWizData->listUnitDevicesBind = m_wndListBind.GetDiskObjectList();

	NDASCOMM_CONNECTION_INFO *pConnectionInfo;
	pConnectionInfo = new NDASCOMM_CONNECTION_INFO[m_pWizData->m_nDiskCount];
	ZeroMemory(pConnectionInfo, sizeof(NDASCOMM_CONNECTION_INFO) * m_pWizData->m_nDiskCount);

	listBind = m_wndListBind.GetDiskObjectList();
	WTL::CString strTitle;
	CNBUnitDevice *UnitDiskObject;
	NBUnitDevicePtrList::const_iterator itr;
	
	for (i = 0, itr = listBind.begin(); itr != listBind.end(); ++itr, i++ )
	{
		UnitDiskObject = *itr;
		
		if(!UnitDiskObject->InitConnectionInfo(&pConnectionInfo[i], TRUE))
//		if(!((*itr)->GetAccessMask() & GENERIC_WRITE))
		{
			// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
			strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
				(*itr)->GetName()
				);
			strTitle.LoadString(IDS_APPLICATION);
			MessageBox(
				strMsg,
				strTitle,
				MB_OK|MB_ICONERROR
				);

			delete [] pConnectionInfo;
			return -1;
		}
	}

	m_pWizData->m_BindResult = NdasOpBind(
		m_pWizData->m_nDiskCount, pConnectionInfo, m_pWizData->m_nBindType);
	if(m_pWizData->m_BindResult != m_pWizData->m_nDiskCount) // error
		m_pWizData->dwBindLastError = ::GetLastError();		

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for (i = 0; i < m_pWizData->m_nDiskCount; i++ )
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}

	delete [] pConnectionInfo;

	return 0;
}
Exemple #9
0
void CMainFrame::OnSingle(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	WTL::CString strMsg;

	CTreeItem itemSelected = m_view.GetSelectedItem();
	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectPtr obj, parent;
	obj = m_mapObject[m_view.GetItemData(itemSelected)];

	if(!obj->IsUnitDisk())
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	// AING_TO_DO
	{
		strMsg.LoadString(IDS_WARNING_SINGLE);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		int ret = MessageBox( 
			strMsg,
			strTitle,
			MB_YESNO | MB_ICONWARNING
			);

		if(IDYES != ret)
		{
			LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
			return;
		}
	}

	//
	// Check whether any disk is being accessed by other program/computer
	//
	if ( !obj->CanAccessExclusive() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		strMsg.LoadString(IDS_FAIL_TO_ACCESS_EXCLUSIVELY);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox( 
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	if(!(obj->GetAccessMask() & GENERIC_WRITE))
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			obj->GetTitle()
			);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	NDAS_CONNECTION_INFO ConnectionInfo;

	CUnitDiskObjectPtr unitDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	
	ZeroMemory(&ConnectionInfo, sizeof(NDAS_CONNECTION_INFO));

	ConnectionInfo.type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
	ConnectionInfo.UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ConnectionInfo.bWriteAccess = TRUE;
	ConnectionInfo.ui64OEMCode = NULL;
	ConnectionInfo.protocol = IPPROTO_LPXTCP;
	CopyMemory(ConnectionInfo.MacAddress, 
		unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		LPXADDR_NODE_LENGTH);

	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE);

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, unitDisk->GetTitle());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		NDAS_UNITDEVICE_ID unitDeviceId;
		CopyMemory(unitDeviceId.DeviceId.Node, ConnectionInfo.MacAddress, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = ConnectionInfo.UnitNo;
		HixChangeNotify.Notify(unitDeviceId);
	}

	OnRefreshStatus(NULL, NULL, NULL);


}
Exemple #10
0
void CMainFrame::OnUnBind(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	BOOL bUnbindMirror = 
		(NMT_RAID1 == pLogicalDevice->GetType() ||
		NMT_MIRROR == pLogicalDevice->GetType());

	// warning message
	WTL::CString strMsg;

	NBUnitDevicePtrList listUnitDevices = pLogicalDevice->GetOperatableDevices();
	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_UNBIND_DLG_CAPTION, 
		(bUnbindMirror) ? IDS_WARNING_UNBIND_MIR : IDS_WARNING_UNBIND, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO *ci = new NDASCOMM_CONNECTION_INFO[listUnitDevices.size()];

	UINT32 i = 0;

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->InitConnectionInfo(&ci[i], TRUE);
	}


	UINT32 BindResult = NdasOpBind(listUnitDevices.size(), ci, NMT_SINGLE);

	DWORD dwLastError = ::GetLastError();

	if(i == BindResult)
	{
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		strMsg.LoadString(
			(bUnbindMirror) ? IDS_WARNING_UNBIND_AFTER_MIR : 
		IDS_WARNING_UNBIND_AFTER);

		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{

		::SetLastError(dwLastError);

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			if(BindResult < listUnitDevices.size())
			{
				i = 0;
				for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
					itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
				{
					if(i == BindResult)
						strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, (*itUnitDevice)->GetName());
				}
				
			}
			else
				strMsg.LoadString(IDS_BIND_FAIL);
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
	}

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->HixChangeNotify(pGetNdasHostGuid());
	}

	delete [] ci;

	OnRefreshStatus(NULL, NULL, NULL);

	return;
}
Exemple #11
0
void CMainFrame::OnSingle(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	WTL::CString strMsg;

	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBUnitDevice *pUnitDevice;
	if(dynamic_cast<CNBLogicalDevice *>(pDevice))
	{
		CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
		if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
			return;

		pUnitDevice = (*pLogicalDevice)[0];
	}
	else
	{
		pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
		if(!pUnitDevice || !pUnitDevice->IsOperatable())
			return;
	}

	if(!pUnitDevice)
		return;

	NDASCOMM_CONNECTION_INFO ConnectionInfo;
	if(!pUnitDevice->InitConnectionInfo(&ConnectionInfo, TRUE))
	{
		
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			pUnitDevice->GetName()
			);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE);

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, pUnitDevice->GetName());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	OnRefreshStatus(NULL, NULL, NULL);
}
//////////////////////////////////////////////////////////////////////////
// Page 1
//////////////////////////////////////////////////////////////////////////
LRESULT CDiskPropertyPage1::OnInitDialog(HWND /*hWndFocus*/, LPARAM /*lParam*/)
{
	WTL::CString strCaption;
	strCaption.LoadString(IDS_DISKPROPERTYPAGE_CAPTION);
	GetParent().SetWindowText(strCaption);

	CDiskObjectPtr disk = GetParentSheet()->GetDiskObject();
	const CObjectUIHandler *phandler = CObjectUIHandler::GetUIHandler( disk );
	WTL::CString strText;

	if(disk->IsUnitDisk())
	{
		GetDlgItem(IDC_EDIT_NAME).SetWindowText( disk->GetTitle() );
		GetDlgItem(IDC_EDIT_ID).SetWindowText( 
			phandler->GetStringID(disk) );
	}
	else
	{
		GetDlgItem(IDC_EDIT_NAME).SetWindowText(phandler->GetTitle(disk));
		GetDlgItem(IDC_DEVICE_ID).ShowWindow(SW_HIDE);
		GetDlgItem(IDC_EDIT_ID).ShowWindow(SW_HIDE);
	}

	if ( (disk->GetAccessMask() & GENERIC_WRITE) != 0 )
	{
		strText.LoadString( IDS_DISKPROPERTYPAGE_WRITEKEY_PRESENT );
		GetDlgItem(IDC_EDIT_WRITEKEY).SetWindowText( strText );
	}
	else
	{
		strText.LoadString( IDS_DISKPROPERTYPAGE_WRITEKEY_NOT_PRESENT );
		GetDlgItem(IDC_EDIT_WRITEKEY).SetWindowText( strText );
	}
	WTL::CString strCapacity;
	strCapacity.FormatMessage( 
			IDS_DISKPROPERTYPAGE_SIZE_IN_GB,
			phandler->GetSizeInMB( disk ) / 1024,
			(phandler->GetSizeInMB( disk ) % 1024) / 10 
			);
	GetDlgItem(IDC_EDIT_CAPACITY).SetWindowText( strCapacity );

	//
	// If the object is composite disk with 2 mirrored disk of DIB V1,
	// display 'Migrate' button and message.
	//
	if(!disk->IsUnitDisk() && // bound disk
		disk->GetParent()->IsRoot() && // top disk
		2 == disk->GetDiskCount()) // 2 disks only
	{
		CDiskObjectCompositePtr pDiskObjectComposite = 
            boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);
		if(NMT_MIRROR == pDiskObjectComposite->GetNDASMediaType())
		{
			GetDlgItem(IDC_TEXT_MIGRATE).ShowWindow( SW_SHOW );
			GetDlgItem(IDC_BTN_MIGRATE).ShowWindow( SW_SHOW );
			GetDlgItem(IDC_ST_MIGRATE).ShowWindow( SW_SHOW );
		}
	}

	return 0;
}
Exemple #13
0
INT_PTR 
ShowErrorMessageBox(
	LPCTSTR szMessage, LPCTSTR szTitle, HWND hWnd, DWORD dwError)
{
	BOOL fSuccess = FALSE;
	WTL::CString strDescription;

	if (dwError & APPLICATION_ERROR_MASK) {

		HMODULE hModule = ::LoadLibraryEx(
			_T("ndasmsg.dll"), 
			NULL, 
			LOAD_LIBRARY_AS_DATAFILE);

		LPTSTR lpszErrorMessage = NULL;

		if (NULL != hModule) {

			INT iChars = ::FormatMessage(
				FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
				hModule,
				dwError,
				0,
				(LPTSTR) &lpszErrorMessage,
				0,
				NULL);
		}

		//
		// Facility: NDAS 0x%1!04X!\r\n
		// Error Code: %2!u! (0x%2!04X!)\r\n
		// %3!s!			
		//

		fSuccess = strDescription.FormatMessage(
			IDS_ERROR_NDAS_DESCRIPTION_FMT,
			(dwError & 0x0FFF000),
			(dwError & 0xFFFF),
			(lpszErrorMessage) ? lpszErrorMessage : _T(""));
		ATLASSERT(fSuccess);

		if (NULL != lpszErrorMessage) {
			::LocalFree(lpszErrorMessage);
		}

		if (NULL != hModule) {
			::FreeLibrary(hModule);
		}


	} else {

		LPTSTR lpszErrorMessage = NULL;
		INT iChars = ::FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
			NULL, 
			dwError, 
			0, 
			(LPTSTR) &lpszErrorMessage, 
			0, 
			NULL);

		//
		// Error Code: %1!u! (0x%1!04X!)
		// %2!s!
		//
		fSuccess = strDescription.FormatMessage(
			IDS_ERROR_SYSTEM_DESCRIPTION_FMT,
			dwError,
			(lpszErrorMessage) ? lpszErrorMessage : _T(""));
		ATLASSERT(fSuccess);

		if (NULL != lpszErrorMessage) {
			::LocalFree(lpszErrorMessage);
		}
	}

	CAppErrorDlg dlg(szMessage,strDescription,szTitle);
	INT_PTR iDlgResult = dlg.DoModal(hWnd);
	return iDlgResult;
}
Exemple #14
0
void CUnBindDlg::OnOK(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	UINT32 nDiskCount = 0;
	unsigned int i;
	NDASCOMM_CONNECTION_INFO *pConnectionInfo;
	CFindIfVisitor<TRUE> unitDiskFinder;
	CDiskObjectList listUnbind;	// List of disks to unbind
	CDiskObjectList::iterator itr;
	CUnitDiskObjectPtr unitDisk;
	WTL::CString strMsg;
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);
	BOOL bUnbindMirror;

	BOOL bReadyToUnbind;
	UINT32 BindResult;

	bUnbindMirror = (dynamic_cast<const CMirDiskObject*>(m_pDiskUnbind.get()) != NULL);

	// warning message
	strMsg.LoadString((bUnbindMirror) ? IDS_WARNING_UNBIND_MIR : IDS_WARNING_UNBIND);
	int id = MessageBox(
		strMsg,
		strTitle,
		MB_YESNO|MB_ICONEXCLAMATION
		);
	if(IDYES != id)
		return;

	listUnbind = unitDiskFinder.FindIf( m_pDiskUnbind, IsUnitDisk);
	nDiskCount = listUnbind.size();
	pConnectionInfo = new NDASCOMM_CONNECTION_INFO[nDiskCount];
	ZeroMemory(pConnectionInfo, sizeof(NDASCOMM_CONNECTION_INFO) * nDiskCount);

	bReadyToUnbind = TRUE;
	for ( itr = listUnbind.begin(), i = 0; itr != listUnbind.end(); ++itr )
	{
		if(!(*itr)->IsUnitDisk())
			continue;

		unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

		ZeroMemory(&pConnectionInfo[i], sizeof(NDASCOMM_CONNECTION_INFO));
		pConnectionInfo[i].address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
		pConnectionInfo[i].login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
		pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		pConnectionInfo[i].bWriteAccess = TRUE;
		pConnectionInfo[i].ui64OEMCode = NULL;
		pConnectionInfo[i].bSupervisor = FALSE;
		pConnectionInfo[i].protocol = NDASCOMM_TRANSPORT_LPX;

		CopyMemory(pConnectionInfo[i].AddressLPX, 
			unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);
		
		if(!(unitDisk->GetAccessMask() & GENERIC_WRITE))
		{
			// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
			strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
				unitDisk->GetTitle()
				);
			MessageBox(
				strMsg,
				strTitle,
				MB_OK|MB_ICONERROR
				);

			bReadyToUnbind = FALSE;
		}

		i++;
	}

	if(!bReadyToUnbind)
	{
		delete [] pConnectionInfo;
		EndDialog(IDCANCEL);
	}

	BindResult = NdasOpBind(i, pConnectionInfo,NMT_SINGLE);

	DWORD dwLastError = ::GetLastError();

	m_unboundDisks = listUnbind;

	if(i == BindResult)
	{
		strMsg.LoadString(
			(bUnbindMirror) ? IDS_WARNING_UNBIND_AFTER_MIR : 
			IDS_WARNING_UNBIND_AFTER);

		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{
		for ( itr = listUnbind.begin(); itr != listUnbind.end(); ++itr )
		{
			unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

			if(!BindResult)
				break;
			BindResult--;
		}

		::SetLastError(dwLastError);

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, unitDisk->GetTitle());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
 	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for(i = 0; i < BindResult; i++)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}

	delete [] pConnectionInfo;

	EndDialog(IDOK);
}