/* * DlgProcYahooOpts - Account Options Dialog */ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); ppro = (CYahooProto*)lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); if ( !ppro->GetString( YAHOO_LOGINID, &dbv )) { SetDlgItemTextA(hwndDlg,IDC_HANDLE,dbv.pszVal); DBFreeVariant(&dbv); } if ( !ppro->GetString( "Nick", &dbv )) { SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal); DBFreeVariant(&dbv); } if ( !ppro->GetString( YAHOO_PASSWORD, &dbv )) { //bit of a security hole here, since it's easy to extract a password from an edit box YAHOO_CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, ( LPARAM )dbv.pszVal ); SetDlgItemTextA( hwndDlg, IDC_PASSWORD, dbv.pszVal ); DBFreeVariant( &dbv ); } //SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte( "DisableUTF8", 0 )); SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte( "UseYAB", 1 )); SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte( "ShowAvatars", 1 )); SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte( "MailAutoLogin", 1 )); SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte( "DisableYahoomail", 0 )); SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte( "ShowErrors", 1 )); return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_NEWYAHOOACCOUNTLINK: YAHOO_CallService( MS_UTILS_OPENURL, 1, ppro->GetByte( "YahooJapan", 0 ) ? (LPARAM)"http://edit.yahoo.co.jp/config/eval_register" : (LPARAM)"http://edit.yahoo.com/config/eval_register" ); return TRUE; //case IDC_DISABLE_UTF8: case IDC_USE_YAB: case IDC_SHOW_AVATARS: case IDC_MAIL_AUTOLOGIN: case IDC_SHOW_ERRORS: case IDC_DISABLEYAHOOMAIL: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) switch( LOWORD( wParam )) { case IDC_HANDLE: case IDC_PASSWORD: case IDC_NICK: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT) PSN_APPLY ) { BOOL reconnectRequired = FALSE; char str[128]; GetDlgItemTextA( hwndDlg, IDC_HANDLE, str, sizeof( str )); dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINID, str ); GetDlgItemTextA( hwndDlg, IDC_PASSWORD, str, sizeof( str )); YAHOO_CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str ); dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_PASSWORD, str ); GetDlgItemTextA( hwndDlg, IDC_NICK, str, sizeof( str )); if (str[0] == '\0') { /* Check for empty Nick, if so delete the key in the DB */ DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick" ); } else { /* otherwise save the new Nick */ ppro->SetString( "Nick", str ); } //ppro->SetByte("DisableUTF8", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISABLE_UTF8 )); ppro->SetByte("UseYAB", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_USE_YAB )); ppro->SetByte("ShowAvatars", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_AVATARS )); ppro->SetByte("MailAutoLogin", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_MAIL_AUTOLOGIN )); ppro->SetByte("DisableYahoomail", ( BYTE )!IsDlgButtonChecked( hwndDlg, IDC_DISABLEYAHOOMAIL )); ppro->SetByte("ShowErrors", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_ERRORS )); if (reconnectRequired ) { DBDeleteContactSetting(NULL, ppro->m_szModuleName, YAHOO_PWTOKEN); } /*if ( restartRequired ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } break; } return FALSE; }
static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: // lParam is hContact TranslateDialogDefault( hwndDlg ); //SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS)); break; case WM_NOTIFY: if (( ( LPNMHDR )lParam )->idFrom == 0 ) { switch (( ( LPNMHDR )lParam )->code ) { case PSN_PARAMCHANGED: SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (( PSHNOTIFY* )lParam )->lParam ); break; case PSN_INFOCHANGED: { CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (!ppro) break; char* szProto; HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; if (hContact == NULL) { szProto = ppro->m_szModuleName; } else { szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); } if (!szProto) break; if (hContact) { DBVARIANT dbv; char z[128]; if (ppro->GetString( hContact, YAHOO_LOGINID, &dbv ) == 0) { strcpy(z, dbv.pszVal); DBFreeVariant( &dbv ); } else { strcpy(z, "???"); } SetDlgItemTextA(hwndDlg, IDC_SEARCH_ID, z); if (ppro->GetString( hContact, "Transport", &dbv ) == 0) { strcpy(z, dbv.pszVal); DBFreeVariant( &dbv ); } else { strcpy(z, "Yahoo"); } SetDlgItemTextA(hwndDlg, IDC_SEARCH_PROTOCOL, z); if (ppro->GetString( hContact, "MirVer", &dbv ) == 0) { strcpy(z, dbv.pszVal); DBFreeVariant( &dbv ); } else { strcpy(z, "???"); } SetDlgItemTextA(hwndDlg, IDC_NFO_CLIENT, z); } else { } } break; } } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: break; } return FALSE; }
/* * DlgProcYahooOpts - Connection Options Dialog */ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); ppro = ( CYahooProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); if ( !ppro->GetString( YAHOO_LOGINSERVER, &dbv )){ SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, dbv.pszVal ); DBFreeVariant( &dbv ); } else SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, ppro->GetByte( "YahooJapan", 0 ) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER ); SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, ppro->GetWord( NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT ), FALSE ); SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 ) ); return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_RESETSERVER: SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER ); SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, YAHOO_DEFAULT_PORT, FALSE ); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_YAHOO_JAPAN: SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, (IsDlgButtonChecked(hwndDlg,IDC_YAHOO_JAPAN)==BST_CHECKED) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER ); // fall through and enable apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) switch( LOWORD( wParam )) { case IDC_LOGINSERVER: case IDC_YAHOOPORT: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY ) { BOOL reconnectRequired = FALSE/*, restartRequired = FALSE*/; char str[128]; DBVARIANT dbv; int port; GetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, str, sizeof( str )); if ( ppro->GetString( YAHOO_LOGINSERVER, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINSERVER, str ); port = GetDlgItemInt( hwndDlg, IDC_YAHOOPORT, NULL, FALSE ); if ( ppro->GetWord(NULL, YAHOO_LOGINPORT, -1) != port) reconnectRequired = TRUE; ppro->SetWord( NULL, YAHOO_LOGINPORT, port); ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN )); /*if ( restartRequired ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } break; } return FALSE; }