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)Skin_LoadIcon(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; MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; if (hContact == NULL) { szProto = ppro->m_szModuleName; } else { szProto = GetContactProto(hContact); } if (!szProto) break; if (hContact) { DBVARIANT dbv; char z[128]; if (ppro->getString(hContact, YAHOO_LOGINID, &dbv) == 0) { mir_strcpy(z, dbv.pszVal); db_free(&dbv); } else { mir_strcpy(z, "???"); } SetDlgItemTextA(hwndDlg, IDC_SEARCH_ID, z); if (ppro->getString(hContact, "Transport", &dbv) == 0) { mir_strcpy(z, dbv.pszVal); db_free(&dbv); } else { mir_strcpy(z, "Yahoo"); } SetDlgItemTextA(hwndDlg, IDC_SEARCH_PROTOCOL, z); if (ppro->getString(hContact, "MirVer", &dbv) == 0) { mir_strcpy(z, dbv.pszVal); db_free(&dbv); } else { mir_strcpy(z, "???"); } SetDlgItemTextA(hwndDlg, IDC_NFO_CLIENT, z); } else { } } break; } } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: break; } return FALSE; }
INT_PTR CALLBACK first_run_dialog(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); db_free(&dbv); } if (!ppro->getString(YAHOO_PASSWORD, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); db_free(&dbv); } SetButtonCheck(hwndDlg, IDC_YAHOO_JAPAN, ppro->getByte("YahooJapan", 0)); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDC_NEWYAHOOACCOUNTLINK) { CallService(MS_UTILS_OPENURL, 1, ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN) == 1) ? (LPARAM) "http://edit.yahoo.co.jp/config/eval_register" : (LPARAM) "http://edit.yahoo.com/config/eval_register" ); return TRUE; } if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) { switch (LOWORD(wParam)) { case IDC_HANDLE: case IDC_PASSWORD: case IDC_YAHOO_JAPAN: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { char str[128]; BOOL reconnectRequired = FALSE; 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) db_free(&dbv); ppro->setString(YAHOO_LOGINID, str); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str)); dbv.pszVal = NULL; if (ppro->getString(YAHOO_PASSWORD, &dbv) || lstrcmpA(str, dbv.pszVal)) reconnectRequired = TRUE; if (dbv.pszVal != NULL) db_free(&dbv); if (reconnectRequired) ppro->delSetting(YAHOO_PWTOKEN); ppro->setString(YAHOO_PASSWORD, str); ppro->setByte("YahooJapan", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN)); 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; }
//======================================================= //Custom status message windows handling //======================================================= static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { CYahooProto* ppro = (CYahooProto*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO)); if (!ppro->getString(YAHOO_CUSTSTATDB, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, dbv.pszVal); EnableWindow(GetDlgItem(hwndDlg, IDOK), mir_strlen(dbv.pszVal) > 0); db_free(&dbv); } else { SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, ""); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); } CheckDlgButton(hwndDlg, IDC_CUSTSTATBUSY, ppro->getByte("BusyCustStat", 0) ? BST_CHECKED : BST_UNCHECKED); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: { char str[255 + 1]; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); /* Get String from dialog */ GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, _countof(str)); /* Save it for later use */ ppro->setString(YAHOO_CUSTSTATDB, str); ppro->setByte("BusyCustStat", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY)); /* set for Idle/AA */ if (ppro->m_startMsg) mir_free(ppro->m_startMsg); ppro->m_startMsg = mir_strdup(str); /* notify Server about status change */ ppro->set_status(YAHOO_CUSTOM_STATUS, str, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY)); /* change local/miranda status */ ppro->BroadcastStatus((BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY) ? ID_STATUS_AWAY : ID_STATUS_ONLINE); } case IDCANCEL: DestroyWindow(hwndDlg); break; } if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) { if (LOWORD(wParam) == IDC_CUSTSTAT) { char str[255 + 1]; BOOL toSet; toSet = GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, _countof(str)) != 0; EnableWindow(GetDlgItem(hwndDlg, IDOK), toSet); } } break; /* case WM_COMMAND */ case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); break; } return FALSE; }