Ejemplo n.º 1
0
WTL::CString CNBUnitDevice::GetName()
{
	WTL::CString strText;

	if(1 != m_pDevice->UnitDevicesCount())
	{
		strText.Format(_T("%s:%d"), m_pDevice->m_BaseInfo.szDeviceName, m_BaseInfo.UnitNo);
	}
	else
	{
		strText.Format(_T("%s"), m_pDevice->m_BaseInfo.szDeviceName);
	}

	return strText;
}
Ejemplo n.º 2
0
void CSelectDiskPage::UpdateControls()
{
	GetDlgItem(IDC_BTN_ADD).EnableWindow(m_wndListSingle.GetSelectedDiskObjectList().size() > 0);
	GetDlgItem(IDC_BTN_REMOVE).EnableWindow(m_wndListBind.GetSelectedDiskObjectList().size() > 0);
	GetDlgItem(IDC_BTN_REMOVE_ALL).EnableWindow( m_wndListBind.GetItemCount() > 0 );

	CEdit ctlEditCount;
	ctlEditCount.Attach(GetDlgItem(IDC_BIND_WIZ_COUNT));
	WTL::CString strDiskCount;
	strDiskCount.Format(_T("%d"), m_pWizData->m_nDiskCount);
	ctlEditCount.SetWindowText(strDiskCount);

	CEdit ctlEditSize;
	ctlEditSize.Attach(GetDlgItem(IDC_BIND_WIZ_SIZE));

	if ( m_wndListBind.GetDiskObjectList().size() == m_pWizData->m_nDiskCount )
	{
		WTL::CString strSize;
		pGetDiskSizeString(
			strSize, 
			m_pWizData->m_nBindType, 
			m_pWizData->m_nDiskCount, 
			m_wndListBind.GetSelectedDiskObjectList());

		ctlEditSize.SetWindowText(strSize);


		SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
	}
	else
	{
		ctlEditSize.SetWindowText(_T(""));
		SetWizardButtons( PSWIZB_BACK);
	}
}
Ejemplo n.º 3
0
BOOL
CRegisterDeviceDialog::IsValidDeviceStringIdKey()
{
	// Transfer data from the controls to member variables
	DoDataExchange(TRUE);

	if (!(m_strDeviceIDs[0].GetLength() == 5 &&
		m_strDeviceIDs[1].GetLength() == 5 &&
		m_strDeviceIDs[2].GetLength() == 5 &&
		m_strDeviceIDs[3].GetLength() == 5 &&
		(m_strDeviceKey.GetLength() == 0 || m_strDeviceKey.GetLength() == 5)))
	{
		return FALSE;
	}

	WTL::CString strDeviceID;
	strDeviceID.Format(TEXT("%s%s%s%s"), 
		m_strDeviceIDs[0], m_strDeviceIDs[1], 
		m_strDeviceIDs[2], m_strDeviceIDs[3]);

	strDeviceID.MakeUpper();

	if (m_strDeviceKey.GetLength() > 0) {
		m_strDeviceKey.MakeUpper();
		return ::NdasValidateStringIdKeyW(strDeviceID, m_strDeviceKey);
	} else {
		return ::NdasValidateStringIdKeyW(strDeviceID, NULL);
	}
}
Ejemplo n.º 4
0
WTL::CString CNBNdasDevice::GetName()
{
	WTL::CString strText;

	strText.Format(_T("%s"), m_BaseInfo.szDeviceName);

	return strText;
}
Ejemplo n.º 5
0
LRESULT 
CRegisterDeviceDialog::
OnInitDialog(HWND hWnd, LPARAM lParam)
{
	DWORD nDeviceCount = static_cast<DWORD>(lParam);

	//
	// Attach controls
	//
	m_wndStringIDs[0] = CEdit(GetDlgItem(IDC_DEV_ID_1));
	m_wndStringIDs[1] = CEdit(GetDlgItem(IDC_DEV_ID_2));
	m_wndStringIDs[2] = CEdit(GetDlgItem(IDC_DEV_ID_3));
	m_wndStringIDs[3] = CEdit(GetDlgItem(IDC_DEV_ID_4));

	m_wndStringKey = GetDlgItem(IDC_DEV_KEY);
	m_wndName = GetDlgItem(IDC_DEV_NAME);
	m_wndRegister = GetDlgItem(IDC_REGISTER);

	//
	// chaining paste support
	//
	DWORD i(0);
	for (; i < 3; ++i) {
		m_wndPasteChains[i].Attach(m_hWnd, m_wndStringIDs[i], m_wndStringIDs[i+1]);
	}
	m_wndPasteChains[i].Attach(m_hWnd, m_wndStringIDs[i], NULL);

	//
	// limit the maximum text
	//
	m_wndStringIDs[0].SetLimitText(5);
	m_wndStringIDs[1].SetLimitText(5);
	m_wndStringIDs[2].SetLimitText(5);
	m_wndStringIDs[3].SetLimitText(5);
	m_wndStringKey.SetLimitText(5);
	m_wndName.SetLimitText(32);

	//
	// default device name
	//
	WTL::CString strNewDeviceName;

	strNewDeviceName.Format(IDS_NEW_DEVICE_NAME_TEMPLATE, nDeviceCount + 1);
	m_wndName.SetWindowText(strNewDeviceName);
	m_wndName.SetSelAll();
	m_wndName.SetFocus();

	//
	// Centering
	//
	CenterWindow();

	SetMsgHandled(FALSE);
	return 0;
}
Ejemplo n.º 6
0
void CNBBindListViewCtrl::OnPaint(HDC /*wParam*/)
{
	CRect rtCol, rtHeader, rtSubItem;
	CHeaderCtrl header = GetHeader();
	header.GetWindowRect( rtHeader );
	ScreenToClient( rtHeader );
	header.GetItemRect( 0, rtCol) ;
	rtCol.OffsetRect( rtHeader.TopLeft() );

	while ( !m_vtRowHeader.empty() )
	{
		CCustomStaticCtrl *pWnd = m_vtRowHeader.front();
		m_vtRowHeader.pop_front();
		pWnd->DestroyWindow();
		delete pWnd;
	}

	// For vertical scroll.
	if ( GetItemCount() > 0 )
	{
		GetSubItemRect(0, 0, LVIR_BOUNDS, rtSubItem);
	}
	else
	{
		rtSubItem.top = rtCol.bottom;
	}

	for ( UINT i=0; i < m_nMaxCount; i++ )
	{
		CCustomStaticCtrl *pWnd;
		CStatic staticCtrl;
		pWnd = new CCustomStaticCtrl;
		CRect rtItem;
		static int nHeight = 14;
		rtItem.left = rtCol.left;
		rtItem.right = rtCol.right-2;
		rtItem.top = rtSubItem.top + i * nHeight;
		rtItem.bottom = rtItem.top + nHeight-1;
		
		if ( rtItem.top < rtCol.bottom )
			continue;
		WTL::CString strTitle;
		strTitle.Format(_T("%d"), i);
		staticCtrl.Create( m_hWnd, rtItem, strTitle,
			WS_CHILD | SS_CENTER | WS_DISABLED);
		staticCtrl.ShowWindow( SW_SHOW );
		pWnd->SubclassWindow( staticCtrl.m_hWnd );
		m_vtRowHeader.push_back( pWnd );
	}
	DefWindowProc();
}
Ejemplo n.º 7
0
PropertyList CRAID4DiskUIHandler::GetPropertyList(CDiskObjectPtr obj) const
{
	PropertyList propList;
	PropertyListItem propItem;
	WTL::CString strBuffer;

	//propItem[0] = _T("Binding type");
	propItem.strName.LoadString( IDS_UIHANDLER_PROPERTY_NUM_BOUND_DISK );
	strBuffer.Format( _T("%d"), obj->GetDiskCountInBind() );
	propItem.strValue = strBuffer;
	propItem.strToolTip.LoadString( IDS_UIHANDLER_PROPERTY_NUM_BOUND_DISK_TOOLTIP );
	propList.push_back( propItem );
	return propList;	
}
Ejemplo n.º 8
0
void CRecoverDlg::RefreshProgBar(UINT32 nTotalSize, UINT32 nCurrentStep)
{
	// Step in progress bar
	UINT nNewStep = nCurrentStep;

	m_progBar.OnSetPos(0, nCurrentStep, NULL);

	nCurrentStep = (!nCurrentStep) ? 1 : nCurrentStep;

	// Display time left
	time_t timeNow = ::time( NULL );
	time_t timeElapsed = timeNow - m_timeBegin;
	time_t timeLeft;
	if ( timeElapsed != 0 
		&& m_timePrev != timeNow	// To prevent too frequent update
		)
	{
		m_timePrev = timeNow;
		// Calculate transfer rate
		double fMBPerSecond = ((double)(nCurrentStep * m_nBytesPerBit)) / (1024 * 1024) / timeElapsed;


		WTL::CString strMBPerSecond;
		strMBPerSecond.Format( _T("%.01f"),fMBPerSecond);
		::SetWindowText( GetDlgItem(IDC_TEXT_RATE), strMBPerSecond );

		WTL::CString strTimeLeft;
		timeLeft = (nTotalSize - nCurrentStep) * (timeElapsed) / (nCurrentStep);

		int nHour, nMin, nSec;
		nSec = timeLeft % 60;
		nMin = (timeLeft / 60) % 60;
		nHour = timeLeft / 60 / 60;
		strTimeLeft.Format( _T("%02d:%02d:%02d"), nHour, nMin, nSec );
		::SetWindowText( GetDlgItem(IDC_TEXT_LEFTTIME), strTimeLeft );
	}
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
DWORD WINAPI CMainDlg::DetectVersion(LPVOID lpParameter)
{
    CMainDlg *pThis = static_cast<CMainDlg *> (lpParameter);
    WTL::CString result;
    const wchar_t *p_versionstr;
    const wchar_t *p_versiondat;
    const wchar_t *p_term;
    DWORD res;
    int pos;

    pThis->m_edit.AppendText(L"Detecting scan executable\r\n");

    pThis->m_process = new Process(L"scan.exe /?");
    res = pThis->m_process->Exec(result);
    delete pThis->m_process;
    pThis->m_process = NULL;

    if (res) return -1;

    pos = result.Find(L"Scan engine v");

    if (pos == -1) /* V2 */
    {
        p_versionstr = L"McAfee VirusScan Command Line for Win32 Version: ";
        p_versiondat = L"Dat set version: ";
        p_term = L"\r";
        pThis->m_process = new Process(L"scan.exe /version");
        res = pThis->m_process->Exec(result);
        delete pThis->m_process;
        pThis->m_process = NULL;
        if (res) return -1;
        pos = result.Find(p_versionstr);
        if (pos == -1)
        {
            pThis->m_edit.AppendText(L"Unknown Version\r\n");
            return -1;
        }
        pThis->m_toolversion = 2;
    }
    else /* V1 */
    {
        p_versionstr = L"Scan engine v";
        p_versiondat = L"Virus data file v";
        p_term = L" ";
        pThis->m_toolversion = 1;
    }

    pos += wcslen(p_versionstr);
    WTL::CString verstr = result.Mid(pos);
    pos = verstr.Find(p_term);
    pThis->m_version = verstr.Left(pos);

    pos = result.Find(p_versiondat);
    if (pos == -1)
    {
        pThis->m_edit.AppendText(L"Cannot parse dat version\r\n");
        return -1;
    }

    pos += wcslen(p_versiondat);
    result = result.Mid(pos);
    pThis->m_datversion = _wtoi(result.GetBuffer(0));

    WTL::CString message;
    message.Format(L"Tool version %s - Dat Version %d\r\n", pThis->m_version,  pThis->m_datversion);
    pThis->m_edit.AppendText(message); 

    return 0;
}
Ejemplo n.º 11
0
void CMirrorDlg::DispathNotification()
{
	NBSYNC_REPORT report;
	report.nSize = sizeof(NBSYNC_REPORT);
	CMultithreadedObserver::GerReport( static_cast<NDAS_SYNC_REPORT*>(&report) );

	if ( m_nCurrentPhase != report.nPhase )
	{
		m_nCurrentPhase = report.nPhase;
		switch( report.nPhase )
		{
		case NBSYNC_PHASE_CONNECT:
			m_strPhase = _T("Connecting to disks..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_REBIND:
			m_strPhase = _T("Updating disk information...");
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_BIND:
			m_strPhase = _T("Writing disk information required for mirroring...");
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_RETRIVE_BITMAP:
			m_strPhase = _T("Retrieving synchronization information..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_SYNCHRONIZE:
			m_strPhase = _T("Synchronizing..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_FINISHED:
			m_strPhase = _T("Synchronization has finished."); // TODO : String resource
			DoDataExchange(FALSE);
			m_bFinished = TRUE;
			break;
		case NBSYNC_PHASE_FAILED:
		default:
			if ( report.nErrorCode == NBSYNC_ERRORCODE_STOPPED )
			{
				m_strPhase = _T("Synchronization has been stopped.");
				DoDataExchange(FALSE);
			}
			else
			{
				m_strPhase = _T("Synchronization has failed.");
				DoDataExchange(FALSE);
			}
			break;
		}

		if ( report.bRebound && !m_bRebound )
		{
			boost::dynamic_pointer_cast<CDiskObjectComposite>
				(m_pDest->GetParent())->DeleteChild(m_pDest);
			if ( m_pMirDisks->front()->IsUsable() )
			{
				m_pMirDisks->DeleteChild( m_pMirDisks->back() );
			}
			else
			{
				m_pMirDisks->DeleteChild( m_pMirDisks->front() );
			}
			m_pMirDisks->AddChild(m_pMirDisks, m_pDest);
			m_bRebound = TRUE;
		}
	}

	// Display process
	if ( (m_nCurrentPhase == NBSYNC_PHASE_SYNCHRONIZE 
		  || m_nCurrentPhase == NBSYNC_PHASE_FINISHED
		  || m_nCurrentPhase == NBSYNC_PHASE_FAILED )
		&& report.nTotalSize != 0 )
	{
		// Step in progress bar
		UINT nNewStep = 
			static_cast<UINT>(
			   (report.nProcessedSize*m_progBar.GetRangeLimit(FALSE)) 
			 / report.nTotalSize
			);
		while ( m_progBar.GetPos() < nNewStep )
		{
			m_progBar.StepIt();
		}

		// Display progressbar message
		/*
		WTL::CString strProgBarMsg;

		strProgBarMsg.Format(
			"%d / %d KBs", 
			static_cast<int>(report.nProcessedSize/2),
			static_cast<int>(report.nTotalSize/2));
		m_progBar.SetWindowText( strProgBarMsg );
		*/

		// Display time left
		CTime timeNow = CTime::GetCurrentTime();
		CTimeSpan timeElapsed = timeNow - m_timeBegin;
		CTimeSpan timeLeft;
		if ( timeElapsed.GetTotalSeconds() != 0 
			&& m_timePrev != timeNow	// To prevent too frequent update
			)
		{
			m_timePrev = timeNow;
			// Calculate transfer rate
			double fMBPerSecond = 
				(report.nProcessedDirtySize) / 2.0 / 1024
				/ timeElapsed.GetTotalSeconds();
			

			WTL::CString strMBPerSecond;
			strMBPerSecond.Format( _T("%.01f"),fMBPerSecond);
			::SetWindowText( GetDlgItem(IDC_TEXT_RATE), strMBPerSecond );

			WTL::CString strTimeLeft;
			timeLeft = 
				static_cast<UINT>(
					(report.nTotalDirtySize-report.nProcessedDirtySize) 
					/ ( fMBPerSecond * 2 * 1024 )
				);
			int nHour, nMin, nSec;
			nSec = timeLeft.GetSeconds();
			nMin = timeLeft.GetMinutes();
			nHour = static_cast<int>(timeLeft.GetTotalHours());
			strTimeLeft.Format( _T("%02d:%02d:%02d"), nHour, nMin, nSec );
			//strTimeLeft = timeLeft.Format(TIME_FORMAT);
			::SetWindowText( GetDlgItem(IDC_TEXT_LEFTTIME), strTimeLeft );
		}
	}
	return;
}