WTL::CString CNBUnitDevice::GetStatusString() { WTL::CString strText; DWORD status = GetStatus(); if(NDASBIND_UNIT_DEVICE_STATUS_DISCONNECTED & status) { strText.LoadString(IDS_STATUS_NOT_CONNECTED); } else if(NDASBIND_UNIT_DEVICE_STATUS_MOUNTED & status) { strText.LoadString(IDS_STATUS_IN_USE); } else if(NDASBIND_UNIT_DEVICE_STATUS_NO_WRITE_KEY & status) { strText.LoadString(IDS_STATUS_READ_ONLY); } else { strText.LoadString(IDS_STATUS_FINE); } return strText; }
BOOL CALLBACK CheckCapacityForMirror(CNBUnitDevice *pUnitDevice, HWND hWnd, LPVOID lpContext) { if(!lpContext) return TRUE; if(!pUnitDevice) return FALSE; CNBLogicalDevice *pLogicalDevice = (CNBLogicalDevice *)lpContext; for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++) { if ((*pLogicalDevice)[i] && (*pLogicalDevice)[i]->GetCapacityInByte() > pUnitDevice->GetCapacityInByte()) { WTL::CString strMsg; strMsg.LoadString( IDS_SELECTMIRDLG_SMALLER_DISK ); WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); MessageBox( hWnd, strMsg, strTitle, MB_OK | MB_ICONWARNING ); return FALSE; } } return TRUE; }
void CRecoverDlg::Start() { WTL::CString strBtnFace; // // Launch working thread // m_btnOK.EnableWindow(FALSE); strBtnFace.LoadString( IDS_RECOVER_BTN_CANCEL ); m_btnCancel.SetWindowText( strBtnFace ); m_btnCancel.EnableWindow(FALSE); m_bRunning = TRUE; HANDLE hThread; hThread = CreateThread( NULL, 0, ThreadRecover, this, NULL, // run immediately NULL); if(!hThread) { WTL::CString strMsg = _T(""); ShowErrorMessageBox(strMsg); strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE ); m_btnCancel.SetWindowText( strBtnFace ); m_bRunning = FALSE; m_bFinished = TRUE; } }
BOOL CRAID4DiskUIHandler::OnRecover(CDiskObjectPtr obj) const { ATLASSERT( dynamic_cast<CRAID4DiskObject*>(obj.get()) != NULL ); CRAID4DiskObjectPtr raid4Disk = boost::dynamic_pointer_cast<CRAID4DiskObject>(obj); if(!raid4Disk->IsDirty()) { WTL::CString strMsg; strMsg.LoadString(IDS_WARNING_NOT_NEED_RECOVER ); WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); MessageBox( ::GetFocus(), strMsg, strTitle, MB_OK | MB_ICONERROR ); return TRUE; } std::list<CDiskObjectPtr>::iterator it; CUnitDiskObjectPtr pUnitDisk; it = raid4Disk->begin(); INT32 iDirty; for(iDirty = raid4Disk->GetDirtyDisk(); iDirty > 0; iDirty--) it++; pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it); CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID4, IDS_RECOVERDLG_TASK_RECOVER); dlgRecover.SetMemberDevice(pUnitDisk); dlgRecover.DoModal(); CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid()); BOOL bResults = HixChangeNotify.Initialize(); if(bResults) { NDAS_UNITDEVICE_ID unitDeviceId; for(it = raid4Disk->begin(); it != raid4Disk->end(); ++it) { pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it); CopyMemory(unitDeviceId.DeviceId.Node, pUnitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, sizeof(unitDeviceId.DeviceId.Node)); unitDeviceId.UnitNo = pUnitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber; HixChangeNotify.Notify(unitDeviceId); } } return TRUE; }
BOOL CRecoverDlg::CallBackRecover( DWORD dwStatus, UINT32 Total, UINT32 Current) { WTL::CString strBtnFace; switch(dwStatus) { case NDAS_RECOVER_STATUS_INITIALIZE: // activate stop button m_nBytesPerBit = Current; m_timeBegin = ::time( NULL ); m_progBar.OnSetRange32(0, 0, Total); m_progBar.OnSetPos(0, 0, NULL); m_btnCancel.EnableWindow(TRUE); SetPhaseText(IDS_RECOVERDLG_PHASE_SYNC); break; case NDAS_RECOVER_STATUS_RUNNING: RefreshProgBar(Total, Current); // refresh time remaining, progress break; case NDAS_RECOVER_STATUS_FINALIZE: // m_bFinished = TRUE; break; case NDAS_RECOVER_STATUS_FAILED: m_bRunning = FALSE; m_bFinished = FALSE; m_btnOK.EnableWindow(TRUE); strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE ); m_btnCancel.SetWindowText(strBtnFace); m_btnCancel.EnableWindow(TRUE); SetPhaseText(IDS_RECOVERDLG_PHASE_READY); break; case NDAS_RECOVER_STATUS_COMPLETE: m_bRunning = FALSE; m_bFinished = TRUE; m_btnOK.EnableWindow(FALSE); strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE ); m_btnCancel.SetWindowText(strBtnFace); SetPhaseText(IDS_RECOVERDLG_PHASE_DONE); break; } if(m_bStopRequest) { m_bStopRequest = FALSE; return FALSE; } return TRUE; }
WTL::CString CNBUnitDevice::GetTypeString() { // AING_TO_DO : Set proper text WTL::CString strText; switch(GetType()) { case NMT_INVALID: case NMT_SINGLE: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_MIRROR: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_SAFE_RAID1: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_AGGREGATE: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_RAID0: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_RAID1: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_RAID4: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_AOD: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_VDVD: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_CDROM: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_OPMEM: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; case NMT_FLASH: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break; default: break; } return strText; }
void CMainFrame::OnUnBind(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/) { ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus); CTreeItem itemSelected = m_view.GetSelectedItem(); if ( itemSelected.IsNull() ) { LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus); return; } CDiskObjectPtr obj, parent; obj = m_mapObject[m_view.GetItemData(itemSelected)]; // Find topmost group composite of bind parent = obj->GetParent(); while ( !parent->IsRoot() ) { obj = parent; parent = obj->GetParent(); } // // Check whether any disk is being accessed by other program/computer // if ( !obj->CanAccessExclusive() ) { LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus); WTL::CString strMsg; strMsg.LoadString(IDS_FAIL_TO_ACCESS_EXCLUSIVELY); WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); MessageBox( strMsg, strTitle, MB_OK | MB_ICONWARNING ); return; } // Unbind disks CUnBindDlg dlgUnbind; dlgUnbind.SetDiskToUnbind(obj); if ( dlgUnbind.DoModal() == IDOK ) { // AING : Cause dlgBind use ndasop.lib to bind disks, // you can't ensure each disk information is stable after bind process. OnRefreshStatus(NULL, NULL, NULL); } LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus); }
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; }
static HFONT pGetTitleFont() { BOOL fSuccess = FALSE; static HFONT hTitleFont = NULL; if (NULL != hTitleFont) { return hTitleFont; } WTL::CString strFontName; WTL::CString strFontSize; fSuccess = strFontName.LoadString(IDS_BIG_BOLD_FONT_NAME); ATLASSERT(fSuccess); fSuccess = strFontSize.LoadString(IDS_BIG_BOLD_FONT_SIZE); ATLASSERT(fSuccess); NONCLIENTMETRICS ncm = {0}; ncm.cbSize = sizeof(NONCLIENTMETRICS); fSuccess = ::SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); ATLASSERT(fSuccess); LOGFONT TitleLogFont = ncm.lfMessageFont; TitleLogFont.lfWeight = FW_BOLD; HRESULT hr = ::StringCchCopy(TitleLogFont.lfFaceName, (sizeof(TitleLogFont.lfFaceName)/sizeof(TitleLogFont.lfFaceName[0])), strFontName); ATLASSERT(SUCCEEDED(hr)); INT TitleFontSize = ::StrToInt(strFontSize); if (TitleFontSize == 0) { TitleFontSize = 12; } HDC hdc = ::GetDC(NULL); TitleLogFont.lfHeight = 0 - ::GetDeviceCaps(hdc,LOGPIXELSY) * TitleFontSize / 72; hTitleFont = ::CreateFontIndirect(&TitleLogFont); ::ReleaseDC(NULL, hdc); return hTitleFont; }
////////////////////////////////////////////////////////////////////////// // CNBBindListViewCtrl ////////////////////////////////////////////////////////////////////////// void CNBBindListViewCtrl::InitColumn() { static COLUMN_INFO column_info[] = { //{ _T("Index"), 45 }, { IDS_LISTVIEW_COL_EMPTY, 20 }, { IDS_LISTVIEW_COL_NAME, 120 }, // { IDS_LISTVIEW_COL_ID, 200 }, { IDS_LISTVIEW_COL_SIZE, 100 } }; ATLASSERT( m_nColCount <= sizeof(column_info)/sizeof(column_info[0]) ); UINT i, nColCount; // Clear all the column exist nColCount = CListViewCtrl::GetHeader().GetItemCount(); for ( i=0; i < nColCount; i++ ) CListViewCtrl::DeleteColumn(0); // Add new columns for ( i=0; i < m_nColCount; i++ ) { WTL::CString strHeader; strHeader.LoadString( column_info[i].nColHeaderID ); CListViewCtrl::InsertColumn( i, strHeader, LVCFMT_LEFT, column_info[i].nWidth, -1 ); } int viewWidth = 90; SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); SetColumnWidth(2, 50); SetColumnWidth(1, viewWidth - GetColumnWidth(0) + GetColumnWidth(2)); }
void CMainFrame::ActivateUI(BOOL bActivate) { m_wndToolBar.EnableWindow(bActivate); HMENU hMenu = ATL::CWindow::GetMenu(); if(!hMenu) return; UINT uEnableMenuItem = (bActivate) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(hMenu, IDM_AGGR_REFRESH, uEnableMenuItem); EnableMenuItem(hMenu, IDM_AGGR_BIND, uEnableMenuItem); EnableMenuItem(hMenu, IDM_AGGR_UNBIND, uEnableMenuItem); EnableMenuItem(hMenu, IDM_AGGR_ADDMIRROR, uEnableMenuItem); EnableMenuItem(hMenu, IDM_AGGR_SYNCHRONIZE, uEnableMenuItem); EnableMenuItem(hMenu, IDM_AGGR_SINGLE, uEnableMenuItem); if(bActivate) { ::SetWindowText(m_hWndStatusBar, _T("")); } else { WTL::CString strStatusText; strStatusText.LoadString(IDS_STATUS_REFRESH); ::SetWindowText(m_hWndStatusBar, strStatusText); } }
LRESULT CRecoverDlg::OnInitDialog(HWND /*hWndCtl*/, LPARAM /*lParam*/) { ATLASSERT( m_pDevice.get() != NULL ); CenterWindow(); m_progBar.SubclassWindow( GetDlgItem(IDC_PROGBAR) ); m_btnOK.Attach( GetDlgItem(IDOK) ); m_btnCancel.Attach( GetDlgItem(IDCANCEL) ); WTL :: CString strBtnFace; strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE ); m_btnCancel.SetWindowText( strBtnFace ); DoDataExchange(TRUE); m_strBindType.LoadString(m_id_bind_type); m_strDevice = m_pDevice->GetTitle(); DoDataExchange(FALSE); WTL::CString strCaption; strCaption.LoadString(m_id_caption); SetWindowText(strCaption); SetPhaseText(IDS_RECOVERDLG_PHASE_READY); if(m_bForceStart) Start(); return 0; }
void CNBListViewCtrl::InitColumn() { static COLUMN_INFO column_info[] = { { IDS_LISTVIEW_COL_NAME, 120 }, // { IDS_LISTVIEW_COL_ID, 200 }, { IDS_LISTVIEW_COL_SIZE, 100 } }; ATLASSERT( m_nColCount <= sizeof(column_info)/sizeof(column_info[0]) ); UINT i, nColCount; // Clear all the column exist nColCount = CListViewCtrl::GetHeader().GetItemCount(); for ( i=0; i < nColCount; i++ ) CListViewCtrl::DeleteColumn(0); // Add new columns for ( i=0; i < m_nColCount; i++ ) { WTL::CString strHeader; strHeader.LoadString( column_info[i].nColHeaderID ); CListViewCtrl::InsertColumn( i, strHeader, LVCFMT_LEFT, column_info[i].nWidth, -1 ); } CRect lvrc; CListViewCtrl::GetClientRect(lvrc); CListViewCtrl::SetColumnWidth(1, 70); CListViewCtrl::SetColumnWidth(0, lvrc.Width() - 70); }
////////////////////////////////////////////////////////////////////////// // Page 2 ////////////////////////////////////////////////////////////////////////// LRESULT CDiskPropertyPage2::OnInitDialog(HWND /*hWndFocus*/, LPARAM /*lParam*/) { WTL::CString strCaption; strCaption.LoadString(IDS_DISKPROPERTYPAGE_CAPTION); GetParentSheet()->SetWindowText(strCaption); CDiskObjectPtr disk = GetParentSheet()->GetDiskObject(); m_listProperty.SubclassWindow( GetDlgItem(IDC_LIST_PROPERTY) ); DWORD dwStyle = LVS_EX_FULLROWSELECT; //| LVS_EX_GRIDLINES //| LVS_EX_INFOTIP m_listProperty.SetExtendedListViewStyle( dwStyle, dwStyle ); WTL::CString strCol[2]; strCol[0].LoadString( IDS_DISKPROPERTYPAGE_LIST_COL_NAME ); strCol[1].LoadString( IDS_DISKPROPERTYPAGE_LIST_COL_VALUE ); m_listProperty.InsertColumn( 0, strCol[0], LVCFMT_LEFT, 130, -1 ); m_listProperty.InsertColumn( 1, strCol[1], LVCFMT_LEFT, 200, -1 ); const CObjectUIHandler *phandler = CObjectUIHandler::GetUIHandler( disk ); PropertyList propList = phandler->GetPropertyList( disk ); PropertyList::iterator itr; for ( itr = propList.begin(); itr != propList.end(); ++itr ) { m_listProperty.InsertItem( itr->strName, itr->strValue, itr->strToolTip ); } return 0; }
VOID CBindTypePage::UpdateControls (UINT32 nType) { CComboBox ctlComboBox; ctlComboBox.Attach(GetDlgItem(IDC_COMBO_DISKCOUNT)); ctlComboBox.ResetContent(); WTL::CString strDesc; switch(nType) { case NMT_AGGREGATE : ctlComboBox.InsertString(-1, _T("2")); ctlComboBox.InsertString(-1, _T("3")); ctlComboBox.InsertString(-1, _T("4")); ctlComboBox.InsertString(-1, _T("5")); ctlComboBox.InsertString(-1, _T("6")); ctlComboBox.InsertString(-1, _T("7")); ctlComboBox.InsertString(-1, _T("8")); strDesc.LoadString(IDS_BNZ_DESC_AGGREGATION); break; case NMT_RAID0 : ctlComboBox.InsertString(-1, _T("2")); ctlComboBox.InsertString(-1, _T("4")); ctlComboBox.InsertString(-1, _T("8")); strDesc.LoadString(IDS_BNZ_DESC_RAID0); break; case NMT_RAID1 : ctlComboBox.InsertString(-1, _T("2")); strDesc.LoadString(IDS_BNZ_DESC_RAID1); break; case NMT_RAID4 : ctlComboBox.InsertString(-1, _T("3")); ctlComboBox.InsertString(-1, _T("5")); ctlComboBox.InsertString(-1, _T("9")); strDesc.LoadString(IDS_BNZ_DESC_RAID4); break; default: break; } ctlComboBox.SetCurSel(0); CStatic ctlStatic; ctlStatic.Attach(GetDlgItem(IDC_BIND_TYPE_DESCRIPTION)); ctlStatic.SetWindowText(strDesc); }
WTL::CString CEmptyDiskUIHandler::GetStringID(CDiskObjectPtr obj) const { WTL::CString strDashedID; strDashedID.LoadString(IDS_UNIDEV_TYPE_DISK_EMPTY); return strDashedID; }
CMenuIDToStringMap() { for ( int i=0; i < sizeof(IDToStrMap)/sizeof(IDToStrMap[0]); i++ ) { WTL::CString strMenu; strMenu.LoadString( IDToStrMap[i].nStrID ); insert( std::make_pair(IDToStrMap[i].nID, strMenu) ); } }
WTL::CString CNBUnitDevice::GetFaultToleranceString() { WTL::CString strText; DWORD status = GetFaultTolerance(); if(NDASBIND_UNIT_DEVICE_RMD_INVALID & status) { } else if(NDASBIND_UNIT_DEVICE_RMD_FAULT & status) { strText.LoadString(IDS_FT_FAULT_CHILD); } else if(NDASBIND_UNIT_DEVICE_RMD_SPARE & status) { strText.LoadString(IDS_FT_FAULT_SPARE); } return strText; }
CTreeItem CNBTreeListView::SetDevice(CTreeItem tiParent, CNBDevice *pDevice) { CTreeItem tiDevice; if(!pDevice) { // set empty device WTL::CString strText; strText.LoadString(IDS_UNIDEV_TYPE_DISK_EMPTY); tiDevice = GetTreeControl().InsertItem( strText, 0, // IDI_FAIL 0, // IDI_FAIL tiParent, TVI_LAST); tiDevice.SetData((DWORD_PTR)NULL); return tiDevice; } tiDevice = GetTreeControl().InsertItem( pDevice->GetName(), pDevice->GetIconIndex((UINT *)anIconIDs, sizeof(anIconIDs)/sizeof(anIconIDs[0])), pDevice->GetSelectIconIndex((UINT *)anIconIDs, sizeof(anIconIDs)/sizeof(anIconIDs[0])), tiParent, TVI_LAST); tiDevice.SetData((DWORD_PTR)pDevice); // ID int col = 1; SetSubItemText(tiDevice, col, pDevice->GetIDString()); // Capacity col++; SetSubItemText(tiDevice, col, pDevice->GetCapacityString()); // Status col++; SetSubItemText(tiDevice, col, pDevice->GetStatusString()); // Type col++; SetSubItemText(tiDevice, col, pDevice->GetTypeString()); // Fault Tolerance col++; SetSubItemText(tiDevice, col, pDevice->GetFaultToleranceString()); return tiDevice; }
CListImpl::CListImpl(void): m_highlightstat(0) ,m_styleentry_height(80) { // init font sample string WTL::CString text; text.LoadString(IDS_SUBTITLESTYLES); Strings::Split(text, L"|", m_samplevec); m_listtextrc.clear(); m_listhittestrc.clear(); }
WTL::CString CNBLogicalDevice::GetFaultToleranceString() { WTL::CString strText; DWORD status = GetFaultTolerance(); if(NDASBIND_LOGICAL_DEVICE_RMD_INVALID & status) { strText.LoadString(IDS_FT_NOT_FAULT_TOLERANT); } else if(NDASBIND_LOGICAL_DEVICE_RMD_MISSING & status) { strText.LoadString(IDS_FT_MISSING); } else if(NDASBIND_LOGICAL_DEVICE_RMD_BROKEN & status) { strText.LoadString(IDS_FT_FAULT); } else if(NDASBIND_LOGICAL_DEVICE_RMD_FAULT & status) { strText.LoadString(IDS_FT_DIRTY); UINT64 SectorsFault; NDASCOMM_CONNECTION_INFO ci; AnyUnitDevice()->InitConnectionInfo(&ci, FALSE); if(NdasOpGetFaultSectorSize(&ci, &SectorsFault)) { WTL::CString strText2 = strText; strText.Format(_T("%s(%d%%)"), strText2, 100 - (SectorsFault * SECTOR_SIZE * 100) / AnyUnitDevice()->GetCapacityInByte()); } } else { strText.LoadString(IDS_FT_FAULT_TOLERANT); } return strText; }
WTL::CString CNBLogicalDevice::GetStatusString() { WTL::CString strText; DWORD status = GetStatus(); if(NMT_INVALID == GetType()) { strText = _T(""); } else if(NDASBIND_LOGICAL_DEVICE_STATUS_NO_WRITE_KEY & status) { strText.LoadString(IDS_STATUS_READ_ONLY); } else if(NDASBIND_LOGICAL_DEVICE_STATUS_MOUNTED & status) { strText.LoadString(IDS_STATUS_IN_USE); } else { strText.LoadString(IDS_STATUS_FINE); } return strText; }
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; }
WTL::CString CObjectUIHandler::GetTitle(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 = obj->GetTitle(); } } else { strTitle = GetType(obj); } return strTitle; }
BOOL CNBTreeListView::Initialize() { // Initialize Column HDITEM col = { 0 }; col.mask = HDI_FORMAT | HDI_TEXT | HDI_WIDTH; col.fmt = HDF_LEFT; // SetExtendedListViewStyle ( LVS_EX_FULLROWSELECT); int i = 0; WTL::CString strHeader; for ( i=0; i < countof(column_info); i++ ) { strHeader.LoadString( column_info[i].nColHeaderID ); col.cxy = column_info[i].nWidth; col.pszText = strHeader.LockBuffer(); GetHeaderControl().InsertItem(i, &col); } // Image List CImageList imageList; // imageList.Create(64, 32, ILC_COLOR8|ILC_MASK, sizeof(anIconIDs)/sizeof(anIconIDs[0]), 1); imageList.Create(32, 32, ILC_COLOR8|ILC_MASK, sizeof(anIconIDs)/sizeof(anIconIDs[0]), 1); for ( int i=0; i < sizeof(anIconIDs)/sizeof(anIconIDs[0]); i++ ) { HICON hIcon = ::LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(anIconIDs[i]) ); // Uncomment this if you want 32x32 icon. // HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(anIconIDs[i]), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR); imageList.AddIcon( hIcon ); } GetTreeControl().SetImageList( imageList, LVSIL_NORMAL); return TRUE; }
void CListImpl::OnLButtonDbClick(UINT wParam, WTL::CPoint pt) { int index = GetCurSel(); WTL::CRect mainrc = GetHittestDivideRect(2 * index); WTL::CRect seconrc = GetHittestDivideRect(2 * index + 1); BOOL mainorsecon; int vecindex = MAXINT; WTL::CString text; std::vector<std::wstring> vec; text.LoadString(IDS_CUSTOMIZEFONT_TITLE); Strings::Split(text, L"|", vec); if (PtInRect(&mainrc, pt)) { mainorsecon = TRUE; vecindex = 0; } if (PtInRect(&seconrc, pt)) { mainorsecon = FALSE; vecindex = 1; } if (vecindex != MAXINT) { CustomizeFontDlg fdlg; fdlg.SetTitleText(vec[vecindex]); fdlg.SetSampleText(m_samplevec[0], m_samplevec[1]); fdlg.SetFontParam(m_fontparams.GetFontParam(index), m_fontparams.GetFontParam(index, FALSE), mainorsecon); if (fdlg.DoModal() == IDC_FONTOK_BUTTON) m_fontparams.WriteProfile(); } }
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; }
BOOL CMirDiskUIHandler::OnSynchronize(CDiskObjectPtr obj) const { ATLASSERT( dynamic_cast<CMirDiskObject*>(obj.get()) != NULL ); CMirDiskObjectPtr mirDisk = boost::dynamic_pointer_cast<CMirDiskObject>(obj); CUnitDiskObjectPtr sourceDisk, destDisk; BOOL bFirstDefected, bSecondDefected; BOOL bResults; bResults = mirDisk->GetDirtyDiskStatus(&bFirstDefected, &bSecondDefected); if(!bResults) return FALSE; // check dirty status here // ATLASSERT( mirDisk->GetDirtyDiskCount() > 0 ); if ( !bFirstDefected && !bSecondDefected) { WTL::CString strMsg; strMsg.LoadString(IDS_WARNING_NOT_NEED_RECOVER ); WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); MessageBox( ::GetFocus(), strMsg, strTitle, MB_OK | MB_ICONERROR ); return TRUE; } // // Select the source disk and the dest disk // if ( bFirstDefected && bSecondDefected) { CSelectDiskDlg dlgSelect(IDD_SELSOURCE); CDiskObjectList listDisks; listDisks.push_back( mirDisk->front() ); listDisks.push_back( mirDisk->back() ); dlgSelect.SetSingleDisks( listDisks ); if ( dlgSelect.DoModal() != IDOK ) return TRUE; sourceDisk = dlgSelect.GetSelectedDisk(); if ( sourceDisk == mirDisk->front() ) destDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(mirDisk->back()); else destDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(mirDisk->front()); } else { if (bFirstDefected) { sourceDisk = /*boost::dynamic_pointer_cast<CUnitDiskObject>*/ (mirDisk->SecondDisk()); destDisk = /*boost::dynamic_pointer_cast<CUnitDiskObject>*/ (mirDisk->FirstDisk()); } else if (bSecondDefected ) { sourceDisk = /*boost::dynamic_pointer_cast<CUnitDiskObject>*/ (mirDisk->FirstDisk()); destDisk = /*boost::dynamic_pointer_cast<CUnitDiskObject>*/ (mirDisk->SecondDisk()); } else { return FALSE; } } // // Synchronize // CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_RECOVER); dlgRecover.SetMemberDevice(destDisk); dlgRecover.DoModal(); CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid()); bResults = HixChangeNotify.Initialize(); if(bResults) { NDAS_UNITDEVICE_ID unitDeviceId; CopyMemory(unitDeviceId.DeviceId.Node, sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, sizeof(unitDeviceId.DeviceId.Node)); unitDeviceId.UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber; HixChangeNotify.Notify(unitDeviceId); CopyMemory(unitDeviceId.DeviceId.Node, destDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, sizeof(unitDeviceId.DeviceId.Node)); unitDeviceId.UnitNo = destDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber; HixChangeNotify.Notify(unitDeviceId); } return TRUE; }
BOOL CMirDiskUIHandler::OnMigrate(CDiskObjectPtr obj ) const { CMirDiskObjectPtr mirDisk = boost::dynamic_pointer_cast<CMirDiskObject>(obj); if(NMT_MIRROR != mirDisk->GetNDASMediaType()) return FALSE; UINT32 BindResult; CDiskObjectPtr disk = obj; NDASCOMM_CONNECTION_INFO pConnectionInfo[NUMBER_MIGRATE_DISK]; UINT32 i; WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); // Find aggregation root if (NUMBER_MIGRATE_DISK != disk->GetDiskCount()) { WTL::CString strMsg; strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_DISK_NOT_EXIST ); MessageBox( ::GetFocus(), strMsg, strTitle, MB_OK | MB_ICONWARNING ); return FALSE; } WTL::CString strConfirmMsg; strConfirmMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_CONFIRM ); if ( IDYES != MessageBox( ::GetFocus(), strConfirmMsg, strTitle, MB_YESNO | MB_ICONWARNING ) ) { return FALSE; } if ( !disk->CanAccessExclusive() ) { WTL::CString strMsg; strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY ); MessageBox( ::GetFocus(), strMsg, strTitle, MB_OK | MB_ICONWARNING ); return FALSE; } CDiskObjectCompositePtr pDiskObjectComposite = boost::dynamic_pointer_cast<CDiskObjectComposite>(disk); CDiskObjectComposite::const_iterator itr; for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i) { CUnitDiskObjectPtr 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); } BindResult = NdasOpBind(NUMBER_MIGRATE_DISK, pConnectionInfo, NMT_RAID1); WTL :: CString strMsg; if(NUMBER_MIGRATE_DISK == BindResult) { strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_SUCCESS); WTL::CString strTitle; strTitle.LoadString(IDS_APPLICATION); MessageBox( ::GetFocus(), strMsg, strTitle, MB_OK|MB_ICONINFORMATION ); } else { 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 for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i) { CUnitDiskObjectPtr unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*itr); if(BindResult == i) strMsg.FormatMessage(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL_AT_FMT, unitDisk->GetTitle()); } break; default: strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_FAIL); break; } ShowErrorMessageBox(strMsg); } CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid()); BOOL bResults = HixChangeNotify.Initialize(); if(bResults) { for(i = 0; i < NUMBER_MIGRATE_DISK; i++) { NDAS_UNITDEVICE_ID unitDeviceId; CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, sizeof(unitDeviceId.DeviceId.Node)); unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo; HixChangeNotify.Notify(unitDeviceId); } } return TRUE; }
WTL::CString CObjectUIHandler::GetFaultTolerance(CDiskObjectPtr obj) const { WTL::CString strTitle; strTitle = _T(""); if(obj->IsUnitDisk()) { if((dynamic_cast<CEmptyDiskObject*>(obj.get()) == NULL)) { CDiskObjectPtr parent; CUnitDiskObjectPtr pUnitDiskObject = boost::dynamic_pointer_cast<CUnitDiskObject>(obj); if(!(parent = pUnitDiskObject->GetParent())->IsRoot()) { CDiskObjectCompositePtr pDiskObjectComposite = boost::dynamic_pointer_cast<CDiskObjectComposite>(parent); if (NMT_RAID4 == pDiskObjectComposite->GetNDASMediaType()) { UINT8 child_status = pDiskObjectComposite->RMDUnitStatus(pUnitDiskObject->GetLocation()->GetUnitDiskLocation()); if(NDAS_UNIT_META_BIND_STATUS_FAULT & child_status) { strTitle.LoadString(IDS_FT_FAULT_CHILD); } else if(NDAS_UNIT_META_BIND_STATUS_SPARE & child_status) { strTitle.LoadString(IDS_FT_FAULT_SPARE); } } } else { strTitle.LoadString(IDS_FT_UNIT); } } } else { CDiskObjectCompositePtr pDiskObjectComposite = boost::dynamic_pointer_cast<CDiskObjectComposite>(obj); // check missing member if(pDiskObjectComposite->IsBroken()) { strTitle.LoadString(IDS_FT_MISSING); } else { switch(pDiskObjectComposite->GetNDASMediaType()) { case NMT_AGGREGATE: case NMT_RAID0: case NMT_MIRROR: if(pDiskObjectComposite->IsBroken()) strTitle.LoadString(IDS_FT_MISSING); else strTitle.LoadString(IDS_FT_NOT_FAULT_TOLERANT); break; case NMT_RAID1: { CMirDiskObjectPtr pMirDiskObject = boost::dynamic_pointer_cast<CMirDiskObject>(pDiskObjectComposite); if(pMirDiskObject->IsBroken()) strTitle.LoadString(IDS_FT_NEED_REPAIR); else if(pMirDiskObject->IsDirty()) strTitle.LoadString(IDS_FT_DIRTY); else strTitle.LoadString(IDS_FT_FAULT_TOLERANT); } break; case NMT_RAID4: { CRAID4DiskObjectPtr pRAID4DiskObject = boost::dynamic_pointer_cast<CRAID4DiskObject>(pDiskObjectComposite); if(pRAID4DiskObject->IsBroken()) { strTitle.LoadString(IDS_FT_NEED_REPAIR); } else { switch(pDiskObjectComposite->RMDStatus()) { case 0: strTitle.LoadString(IDS_FT_FAULT_TOLERANT); break; case 1: strTitle.LoadString(IDS_FT_DIRTY); break; case 2: strTitle.LoadString(IDS_FT_FAULT); break; case 3: strTitle.LoadString(IDS_FT_IN_SYNC); break; default: break; } } } break; default: break; } } } return strTitle; }