コード例 #1
0
ファイル: netlibsecurity.cpp プロジェクト: raoergsls/miranda
static INT_PTR NtlmCreateResponseService( WPARAM wParam, LPARAM lParam )
{
	NETLIBNTLMREQUEST* req = ( NETLIBNTLMREQUEST* )lParam;
	unsigned complete;

	char* response = NtlmCreateResponseFromChallenge(( HANDLE )wParam, req->szChallenge, 
		StrConvT(req->userName), StrConvT(req->password), false, complete );

	return (INT_PTR)response;
}
コード例 #2
0
static INT_PTR TimestampToStringA(WPARAM wParam, LPARAM lParam)
{
	DBTIMETOSTRING *tts = (DBTIMETOSTRING*)lParam;
	if (tts == NULL) return 0;

	TCHAR *szDest = (TCHAR*)alloca(tts->cbDest);
	timeapiPrintTimeStamp(NULL, (time_t)wParam, StrConvT(tts->szFormat), szDest, tts->cbDest, 0); 
	WideCharToMultiByte(CP_ACP, 0, szDest, -1, tts->szDest, tts->cbDest, NULL, NULL);
	return 0;
}
コード例 #3
0
static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg,UINT message, WPARAM wParam, LPARAM lParam)
{
	switch( message ) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			PROTOCOLDESCRIPTOR** proto;
			int protoCount, i, cnt = 0;
			Proto_EnumProtocols(( WPARAM )&protoCount, ( LPARAM )&proto );
			for ( i=0; i < protoCount; i++ ) {
				PROTOCOLDESCRIPTOR* pd = proto[i];
				if ( pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof( *pd )) {
					SendDlgItemMessageA( hwndDlg, IDC_PROTOTYPECOMBO, CB_ADDSTRING, 0, (LPARAM)proto[i]->szName );
					++cnt;
				}
			}
			SendDlgItemMessage( hwndDlg, IDC_PROTOTYPECOMBO, CB_SETCURSEL, 0, 0 );
			EnableWindow( GetDlgItem( hwndDlg, IDOK ), cnt != 0 );

			SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
			AccFormDlgParam* param = ( AccFormDlgParam* )lParam;

			if ( param->action == PRAC_ADDED ) // new account
				SetWindowText( hwndDlg, TranslateT( "Create new account" ));
			else {
				TCHAR str[200];
				if ( param->action == PRAC_CHANGED ) { // update
					EnableWindow( GetDlgItem( hwndDlg, IDC_PROTOTYPECOMBO ), FALSE );
					mir_sntprintf( str, SIZEOF(str), _T("%s: %s"), TranslateT( "Editing account" ), param->pa->tszAccountName );
				}
				else mir_sntprintf( str, SIZEOF(str), _T("%s: %s"), TranslateT( "Upgrading account" ), param->pa->tszAccountName );

				SetWindowText( hwndDlg, str );
				SetDlgItemText( hwndDlg, IDC_ACCNAME, param->pa->tszAccountName );
				SetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, param->pa->szModuleName );
				SendDlgItemMessageA( hwndDlg, IDC_PROTOTYPECOMBO, CB_SELECTSTRING, -1, (LPARAM)param->pa->szProtoName );

				EnableWindow( GetDlgItem( hwndDlg, IDC_ACCINTERNALNAME ), FALSE );
			}
			SendDlgItemMessage( hwndDlg, IDC_ACCINTERNALNAME, EM_LIMITTEXT, 40, 0 );
		}
		return TRUE;

	case WM_COMMAND:
		switch( LOWORD(wParam)) {
		case IDOK:
			{
				AccFormDlgParam* param = ( AccFormDlgParam* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
				PROTOACCOUNT* pa = param->pa;

				if ( param->action == PRAC_ADDED ) {
					char buf[200];
					GetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF( buf ));
					rtrim( buf );
					if ( buf[0] ) {
						for (int i = 0; i < accounts.getCount(); ++i)
							if (_stricmp(buf, accounts[i]->szModuleName) == 0)
								return FALSE;
				}	}

				switch( param->action ) {
				case PRAC_UPGRADED:
					{
						int idx;
						BOOL oldProto = pa->bOldProto;
						TCHAR szPlugin[MAX_PATH];
						mir_sntprintf(szPlugin, SIZEOF(szPlugin), _T("%s.dll"), StrConvT(pa->szProtoName));
						idx = accounts.getIndex(pa);
						UnloadAccount(pa, false, false);
						accounts.remove(idx);
						if (oldProto && UnloadPlugin(szPlugin, SIZEOF(szPlugin))) 
						{
							TCHAR szNewName[MAX_PATH];
							mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s~"), szPlugin);
							MoveFile(szPlugin, szNewName);
						}
					}
					// fall through

				case PRAC_ADDED:
					pa = (PROTOACCOUNT*)mir_calloc( sizeof( PROTOACCOUNT ));
					pa->cbSize = sizeof( PROTOACCOUNT );
					pa->bIsEnabled = TRUE;
                    pa->bIsVisible = TRUE;
                    
					pa->iOrder = accounts.getCount();
					pa->type = PROTOTYPE_PROTOCOL;
					break;
				}
				{
					TCHAR buf[256];
					GetDlgItemText( hwndDlg, IDC_ACCNAME, buf, SIZEOF( buf ));
					mir_free(pa->tszAccountName);
					pa->tszAccountName = mir_tstrdup( buf );
				}
				if ( param->action == PRAC_ADDED || param->action == PRAC_UPGRADED ) 
                {
					char buf[200];
					GetDlgItemTextA( hwndDlg, IDC_PROTOTYPECOMBO, buf, SIZEOF( buf ));
					pa->szProtoName = mir_strdup( buf );
					GetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF( buf ));
					rtrim( buf );
					if ( buf[0] == 0 ) {
						int count = 1;
						for( ;; ) {
							DBVARIANT dbv;
							mir_snprintf( buf, SIZEOF(buf), "%s_%d", pa->szProtoName, count++ );
							if ( DBGetContactSettingString( NULL, buf, "AM_BaseProto", &dbv ))
								break;
							DBFreeVariant( &dbv );
					}	}
					pa->szModuleName = mir_strdup( buf );

					if ( !pa->tszAccountName[0] ) {
						mir_free(pa->tszAccountName);
						pa->tszAccountName = mir_a2t(buf);
					}

					DBWriteContactSettingString( NULL, pa->szModuleName, "AM_BaseProto", pa->szProtoName );
					accounts.insert( pa );

					if ( ActivateAccount( pa )) {
						pa->ppro->OnEvent( EV_PROTO_ONLOAD, 0, 0 );
						if (!DBGetContactSettingByte(NULL, "CList", "MoveProtoMenus", FALSE))
							pa->ppro->OnEvent( EV_PROTO_ONMENU, 0, 0 );
					}
					else pa->type = PROTOTYPE_DISPROTO;
				}

				WriteDbAccounts();
				NotifyEventHooks( hAccListChanged, param->action, ( LPARAM )pa );

				SendMessage( GetParent(hwndDlg), WM_MY_REFRESH, 0, 0 );
			}

			EndDialog( hwndDlg, TRUE );
			break;

		case IDCANCEL:
			EndDialog( hwndDlg, FALSE );
			break;
		}
	}

	return FALSE;
}
コード例 #4
0
ファイル: netlibsecurity.cpp プロジェクト: raoergsls/miranda
HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal)
{
	return NetlibInitSecurityProvider(StrConvT(szProvider), StrConvT(szPrincipal));
}