Esempio n. 1
0
dlgWndPinpadInfo::dlgWndPinpadInfo( unsigned long ulHandle, DlgPinUsage PinPusage, 
		DlgPinOperation operation, const std::wstring & csReader, 
		const std::wstring & PinName, const std::wstring & Message, HWND Parent)
:Win32Dialog(L"WndPinpadInfo")

{
	m_szHeader=NULL;
	m_szMessage=NULL;

	m_ModalHold = false;
	m_szMessage = _wcsdup( Message.c_str() );

	m_ulHandle = ulHandle;

	std::wstring tmpTitle = L"";

	tmpTitle += GETSTRING_DLG(PinpadInfo);

	if (PinPusage == DLG_PIN_AUTH)
		m_szHeader = _wcsdup( L"Pin da Autenticação" );
	else
		m_szHeader = _wcsdup( PinName.c_str() );

	if(!csReader.empty())
	{
		tmpTitle += L" - ";
		tmpTitle += csReader;
	}
	

	if( CreateWnd( tmpTitle.c_str() , 420, 280, 0, Parent ) )
	{
		if( PinPusage == DLG_PIN_SIGN )
			ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_BITMAP2) );
		else
			ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_BITMAP1) );
		CreateBitapMask( ImagePIN, ImagePIN_Mask );

		TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0,
				DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial" );


		SendMessage( Parent, WM_SETFONT, (WPARAM)TextFont, 0 );

	}

}
Esempio n. 2
0
std::wstring CLang::GetMessageFromID(DlgMessageID messageID)
{
    std::wstring csMessage=L"";
    unsigned char separator;
#ifdef WIN32
    separator = '\\';
#else
    separator = '/';
#endif

    switch( messageID )
    {
    case DLG_MESSAGE_TESTCARD:
        csMessage+=GETSTRING_DLG(TheRootCertificateIsNotCorrect);
        csMessage+=L"\n";
        csMessage+=GETSTRING_DLG(ThisMayBeATestCard);
        csMessage+=L"\n\n";
        csMessage+=GETSTRING_DLG(DoYouWantToAcceptIt);
        break;
    case DLG_MESSAGE_ENTER_CORRECT_CARD:
        csMessage+=GETSTRING_DLG(PleaseEnterTheCorrectEidCard);
        break;
    case DLG_MESSAGE_USER_WARNING:
    {
        wchar_t fullpath[PATH_LENGHT];
        wcscpy_s(fullpath,PATH_LENGHT,L"");

        const wchar_t *exename=NULL;
        wchar_t *partPath = fullpath;//current (sub)folder name
        wchar_t *nextPartPath = fullpath;//next (sub)folder name
        wchar_t *startOfLine = fullpath;//start of (part of) path that is not yet copied
        GetProcessName(fullpath,PATH_LENGHT);

        if(wcslen(fullpath)==0)
        {
            wcscpy_s(fullpath,PATH_LENGHT,GETSTRING_DLG(UnknownApplication));
            exename=fullpath;
        }
        else
        {
            exename=wcsrchr(fullpath,separator);
            if(exename==NULL)
                exename=L"???";
            else
                exename++;
        }

        csMessage+=GETSTRING_DLG(TheFollowingApplication1IsTrying);
        csMessage.replace(csMessage.find(L"%1"),2,exename);
        csMessage+=L"\n\n\n\n\n";
        csMessage+=GETSTRING_DLG(PathOfTheApplication);
        csMessage+=L"\n\n";

        nextPartPath=wcschr(partPath,separator);
        while(nextPartPath != NULL)
        {
            nextPartPath++;//skip separator
            if((nextPartPath-startOfLine)>48)
            {
                csMessage+=L"\n";
                startOfLine = nextPartPath;
            }
            csMessage.append(partPath,(nextPartPath-partPath));
            //csMessage+=L" ";
            partPath = nextPartPath;
            nextPartPath=wcschr(partPath,separator);
        }
        if((wcslen(partPath)+(partPath-startOfLine))>48)
        {
            csMessage+=L"\n";
        }
        csMessage+=partPath;

        //csMessage+=fullpath;
    }
    break;
    case DLG_MESSAGE_SDK35_WARNING:
        csMessage+=GETSTRING_DLG(OldSDK35Notification);
        break;
    case DLG_MESSAGE_NONE:
    default:
        break;
    }
    return csMessage;
}
Esempio n. 3
0
dlgWndAskPIN::dlgWndAskPIN( DlgPinInfo pinInfo, DlgPinUsage PinPusage, std::wstring & Header, std::wstring & PINName, bool UseKeypad, HWND Parent )
:Win32Dialog(L"WndAskPIN")
{
	m_UseKeypad = UseKeypad;

	PinResult[0] = ' ';
	PinResult[1] = (char)0;

	std::wstring tmpTitle = L"";

	if( PinPusage == DLG_PIN_SIGN )
		tmpTitle += GETSTRING_DLG(SigningWith);
	else
		tmpTitle += GETSTRING_DLG(Asking);

	tmpTitle += L" ";
	tmpTitle += PINName;

	m_ulPinMinLen = pinInfo.ulMinLen;
	m_ulPinMaxLen = pinInfo.ulMaxLen;

	szHeader = Header.c_str();
	szPIN = PINName.c_str();

	int Height = 280;
	if( m_UseKeypad )
		Height = 480;

	if( CreateWnd( tmpTitle.c_str() , 480, Height, 0, Parent ) )
	{
		RECT clientRect;
		GetClientRect( m_hWnd, &clientRect );

		TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0,
				DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"MS Shell Dlg" );

		//OK Button
		HWND hOkButton = CreateWindow(
			L"BUTTON", GETSTRING_DLG(Ok), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 
			clientRect.right - 160, clientRect.bottom - 36, 72, 24, 
			m_hWnd, (HMENU)IDB_OK, m_hInstance, NULL );
		EnableWindow( hOkButton, false );

		//Cancel Button
		HWND hCancelButton = CreateWindow(
			L"BUTTON", GETSTRING_DLG(Cancel), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 
			clientRect.right - 80, clientRect.bottom - 36, 72, 24, 
			m_hWnd, (HMENU)IDB_CANCEL, m_hInstance, NULL );

		m_KeypadHeight=0;

		//Virtual Keypad
		if( m_UseKeypad )
		{
			int top = 60;
			int hMargin = 12;
			int vMargin = 12;
			int btnwidth = 48;
			int btnheight = 48;
			int totwidth = btnwidth*3 + 2*hMargin;
			int totheight = btnheight*4 +3*vMargin;
			int left = (clientRect.right - clientRect.left - totwidth)/2;
			m_KeypadHeight = top + totheight + 8;

			for( int i = 0; i < 4; i++ )
			{
				for( int  j = 0; j < 3; j++ )
				{
					if( i == 3 && j == 0 )
						continue;
					HWND hOkButton = CreateWindow(
						L"BUTTON", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW, //BS_FLAT, 
						left + ( btnwidth + hMargin )* j, top + ( btnheight + vMargin ) * i, btnwidth, btnheight, 
						m_hWnd, (HMENU)(long long)(IDB_KeypadStart + 3*i + j ), m_hInstance, NULL );
				}
			}

			ImageKP_BTN[0] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_0) );
			ImageKP_BTN[1] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_1) );
			ImageKP_BTN[2] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_2) );
			ImageKP_BTN[3] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_3) );
			ImageKP_BTN[4] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_4) );
			ImageKP_BTN[5] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_5) );
			ImageKP_BTN[6] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_6) );
			ImageKP_BTN[7] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_7) );
			ImageKP_BTN[8] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_8) );
			ImageKP_BTN[9] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_9) );
			ImageKP_BTN[10] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_CE) );
			ImageKP_BTN[11] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_BTN) );

			CreateBitapMask( ImageKP_BTN[11], ImageKP_BTN_Mask );
			//MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - LoadBitmap");
		}

		DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_PASSWORD;
		if( pinInfo.ulFlags & PIN_FLAG_DIGITS )
			dwStyle |= ES_NUMBER;

		LONG pinTop=0;
		LONG pinLeft=clientRect.right/2 - 100 + 40;

		if( m_UseKeypad )
			pinTop = clientRect.top + 20;
		else
			pinTop = clientRect.bottom - 80;

		HWND hTextEdit = CreateWindowEx( WS_EX_CLIENTEDGE,
			L"EDIT", L"", dwStyle, 
			pinLeft, pinTop, 160, 26, 
			m_hWnd, (HMENU)IDC_EDIT, m_hInstance, NULL );
		SendMessage( hTextEdit, EM_LIMITTEXT, m_ulPinMaxLen, 0 );

		HWND hStaticText = CreateWindow( 
			L"STATIC", szPIN, WS_CHILD | WS_VISIBLE | SS_RIGHT, 
			pinLeft-100, pinTop +4 , 96, 22, 
			m_hWnd, (HMENU)IDC_STATIC, m_hInstance, NULL );

		SendMessage( hStaticText, WM_SETFONT, (WPARAM)TextFont, 0 );

		SendMessage( hOkButton, WM_SETFONT, (WPARAM)TextFont, 0 );
		SendMessage( hCancelButton, WM_SETFONT, (WPARAM)TextFont, 0 );

		if( PinPusage == DLG_PIN_SIGN )
			ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PINSIGN) );
		else
			ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PIN) );
		CreateBitapMask( ImagePIN, ImagePIN_Mask );

		SetFocus(GetDlgItem( m_hWnd, IDC_EDIT ));
	}
}
Esempio n. 4
0
dlgWndBadPIN::dlgWndBadPIN( std::wstring & PINName, unsigned long RemainingTries, HWND Parent )
:Win32Dialog(L"WndBadPIN")
{
	std::wstring tmpTitle = L"";

	if(wcscmp(L"nl",langbad.c_str())==0)
		tmpTitle += (L"Atenção");
	else
		tmpTitle += GETSTRING_DLG(Notification);
	tmpTitle += L": ";
	tmpTitle += GETSTRING_DLG(Bad); 
	tmpTitle += L" ";

	if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0)
		tmpTitle += (L"Pin da Autenticação");
	else
		tmpTitle += PINName;

	wchar_t tmpBuf[128];
	std::wstring tmpStr = L"";
	_itow_s( RemainingTries, tmpBuf, 128, 10 ); 
	szHeader = new wchar_t[128];
	szBody = L"";

	tmpStr = GETSTRING_DLG(Bad);
	tmpStr += L" \""; 
	if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0)
		tmpStr += (L"Pin da Autenticação");
	else
		tmpStr += PINName;
	tmpStr += L"\": ";
	tmpStr += tmpBuf;
	tmpStr += L" "; 
	tmpStr += GETSTRING_DLG(RemainingAttempts); 
	wcscpy_s( szHeader, 128, tmpStr.c_str() );
	if( RemainingTries == 0 )
	{
		if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0)
			tmpTitle += (L"Pin da Autenticação");
		else
			tmpTitle += PINName;
		tmpStr += L" ";
		tmpStr = GETSTRING_DLG(PinBlocked);
		szBody = tmpStr.c_str();
	}
	else
	{
		szBody = GETSTRING_DLG(TryAgainOrCancel);
	}

	if( CreateWnd( tmpTitle.c_str() , 280, 230, 0,  Parent ) )
	{
		RECT clientRect;
		GetClientRect( m_hWnd, &clientRect );

		TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0,
				DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
				DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"MS Shell Dlg" );

		if( RemainingTries == 0 )
		{
			HWND hOkButton = CreateWindow(
				L"BUTTON", GETSTRING_DLG(Ok), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 
				clientRect.right - 160, clientRect.bottom - 36, 72, 24, 
				m_hWnd, (HMENU)IDB_OK, m_hInstance, NULL );
			SendMessage( hOkButton, WM_SETFONT, (WPARAM)TextFont, 0 );
		}
		else
		{
			HWND hRetryButton = CreateWindow(
				L"BUTTON", GETSTRING_DLG(Retry), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 
				clientRect.right - 160, clientRect.bottom - 36, 72, 24, 
				m_hWnd, (HMENU)IDB_RETRY, m_hInstance, NULL );
			SendMessage( hRetryButton, WM_SETFONT, (WPARAM)TextFont, 0 );

			HWND hCancelButton = CreateWindow(
				L"BUTTON", GETSTRING_DLG(Cancel), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_TEXT, 
				clientRect.right - 80, clientRect.bottom - 36, 72, 24, 
				m_hWnd, (HMENU)IDB_CANCEL, m_hInstance, NULL );
			SendMessage( hCancelButton, WM_SETFONT, (WPARAM)TextFont, 0 );
		}

		HWND hStaticText = CreateWindow( 
			L"STATIC", szBody, WS_CHILD | WS_VISIBLE | SS_CENTER, 
			0, clientRect.bottom - 76, clientRect.right, 22, 
			m_hWnd, (HMENU)IDC_STATIC, m_hInstance, NULL );
		SendMessage( hStaticText, WM_SETFONT, (WPARAM)TextFont, 0 );

		ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PIN) );
		CreateBitapMask( ImagePIN, ImagePIN_Mask );
	}
}
Esempio n. 5
0
dlgWndAskPIN::dlgWndAskPIN( DlgPinInfo pinInfo, DlgPinUsage PinPusage, QString & Header, QString & PINName, bool UseKeypad, QWidget *parent ) : dlgWndBase(parent)
{
	ui.setupUi(this);

	if( pinInfo.ulFlags & PIN_FLAG_DIGITS )
	{
		char buffer[20];
		sprintf(buffer,"[0-9]{%lld,%lld}",pinInfo.ulMinLen,pinInfo.ulMaxLen);
		QRegExp rx(buffer);
		m_PinValidator=new QRegExpValidator(rx, 0);
	}
	else
	{
		m_PinValidator=NULL;
	}

	QString Title;
	//if( DApplic == DLG_APP_BELPIC )
	//{
		this->setWindowIcon( QIcon( ":/Resources/ICO_CARD_EID_PLAIN_16x16.png" ) );
	//	Title+=QString::fromWCharArray(GETSTRING_DLG(Belpic));
	//	Title+= ": ";
	//}
	//else
	//{
	//}
	if( PinPusage == DLG_PIN_SIGN )
	{
		Title+=QString::fromWCharArray(GETSTRING_DLG(SigningWith));
		Title+= ": ";
	}
	else
	{
		Title+=QString::fromWCharArray(GETSTRING_DLG(Asking));
		Title+= " ";
	}
	Title+= PINName;
	this->setWindowTitle(Title);

	ui.lblHeader->setText( QString::fromWCharArray(GETSTRING_DLG(EnterYourPin)) );
	ui.lblPINName->setText( QString::fromWCharArray(GETSTRING_DLG(Pin)) );
	ui.lblPINName_2->setText( QString::fromWCharArray(GETSTRING_DLG(Pin)) );

	ui.btnOk->setText( QString::fromWCharArray(GETSTRING_DLG(Ok)) );
	ui.btnCancel->setText( QString::fromWCharArray(GETSTRING_DLG(Cancel)) );

	if( PinPusage == DLG_PIN_SIGN )
		ui.lblIcon->setPixmap( QPixmap( ":/Resources/ICO_CARD_DIGSIG_128x128.png" ) );
	else
		ui.lblIcon->setPixmap( QPixmap( ":/Resources/ICO_CARD_PIN_128x128.png" ) );

	m_ulPinMinLen = pinInfo.ulMinLen;
	m_ulPinMaxLen = pinInfo.ulMaxLen;

	m_UseKeypad = UseKeypad;

	if( m_UseKeypad )
	{
		QList<QToolButton *> allTBT = ui.fraPIN_Keypad->findChildren<QToolButton *>();
		for (int i = 0; i < allTBT.size(); ++i) 
		{
			allTBT.at(i)->setMinimumSize( KP_BTN_SIZE, KP_BTN_SIZE );
			allTBT.at(i)->setIconSize( QSize( KP_BTN_SIZE, KP_BTN_SIZE ) );
			allTBT.at(i)->setAutoRaise( true );
		}

		ui.tbtNUM_1->setIcon( QIcon( ":/Resources/KeyPadButton1.png" ) );
		ui.tbtNUM_2->setIcon( QIcon( ":/Resources/KeyPadButton2.png" ) );
		ui.tbtNUM_3->setIcon( QIcon( ":/Resources/KeyPadButton3.png" ) );
		ui.tbtNUM_4->setIcon( QIcon( ":/Resources/KeyPadButton4.png" ) );
		ui.tbtNUM_5->setIcon( QIcon( ":/Resources/KeyPadButton5.png" ) );
		ui.tbtNUM_6->setIcon( QIcon( ":/Resources/KeyPadButton6.png" ) );
		ui.tbtNUM_7->setIcon( QIcon( ":/Resources/KeyPadButton7.png" ) );
		ui.tbtNUM_8->setIcon( QIcon( ":/Resources/KeyPadButton8.png" ) );
		ui.tbtNUM_9->setIcon( QIcon( ":/Resources/KeyPadButton9.png" ) );
		ui.tbtNUM_0->setIcon( QIcon( ":/Resources/KeyPadButton0.png" ) );
		ui.tbtClear->setIcon( QIcon( ":/Resources/KeyPadButtonCE.png" ) );

		ui.fraPIN_Normal->setVisible( false );
		ui.lblHeader->setVisible( false );

		if( !PINName.isEmpty() )
			ui.lblPINName_2->setText( PINName );

		if( pinInfo.ulFlags & PIN_FLAG_DIGITS )
			ui.txtPIN_2->setValidator(m_PinValidator);
		else
			ui.txtPIN_2->setMaxLength( pinInfo.ulMaxLen );
	}
	else
	{
		 ui.fraPIN_Keypad->setVisible( false );

		if( !PINName.isEmpty() )
			ui.lblPINName->setText( PINName );
		if( !Header.isEmpty() )
			ui.lblHeader->setText( Header );
	
		if( pinInfo.ulFlags & PIN_FLAG_DIGITS )
			ui.txtPIN->setValidator(m_PinValidator);
		else
			ui.txtPIN->setMaxLength( pinInfo.ulMaxLen );
	}
}