From 607936ac04647798823b4fdd9e423aab350122c6 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 19 Jul 2013 05:23:52 +0000 Subject: auth data request working now git-svn-id: http://svn.miranda-ng.org/main/trunk@5409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewsAggregator/Src/Utils.cpp | 41 ++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 6ca80cfd04..858713f163 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -140,6 +140,15 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA } else if (SelItem.hContact) { + DBVARIANT dbv; + if (!db_get_ts(SelItem.hContact, MODULE, "Nick", &dbv)) { + SetDlgItemText(hwndDlg, IDC_FEEDNAME, dbv.ptszVal); + db_free(&dbv); + } + else if (!db_get_ts(SelItem.hContact, MODULE, "URL", &dbv)) { + SetDlgItemText(hwndDlg, IDC_FEEDNAME, dbv.ptszVal); + db_free(&dbv); + } } } return TRUE; @@ -158,11 +167,20 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA MessageBox(hwndDlg, TranslateT("Enter your password"), TranslateT("Error"), MB_OK); break; } - CheckDlgButton(SelItem.hwndList, IDC_USEAUTH, BST_CHECKED); - EnableWindow(GetDlgItem(SelItem.hwndList, IDC_LOGIN), TRUE); - EnableWindow(GetDlgItem(SelItem.hwndList, IDC_PASSWORD), TRUE); - SetDlgItemText(SelItem.hwndList, IDC_LOGIN, str); - SetDlgItemText(SelItem.hwndList, IDC_PASSWORD, str); + if (SelItem.hwndList) + { + CheckDlgButton(SelItem.hwndList, IDC_USEAUTH, BST_CHECKED); + EnableWindow(GetDlgItem(SelItem.hwndList, IDC_LOGIN), TRUE); + EnableWindow(GetDlgItem(SelItem.hwndList, IDC_PASSWORD), TRUE); + SetDlgItemText(SelItem.hwndList, IDC_LOGIN, str); + SetDlgItemText(SelItem.hwndList, IDC_PASSWORD, str2); + } + else if (SelItem.hContact) + { + db_set_b(SelItem.hContact, MODULE, "UseAuth", 1); + db_set_ts(SelItem.hContact, MODULE, "Login", str); + db_set_ts(SelItem.hContact, MODULE, "Password", str2); + } EndDialog(hwndDlg, IDOK); return TRUE; } @@ -174,7 +192,6 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA } } break; - } return FALSE; @@ -226,7 +243,16 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength); (*szData)[nlhrReply->dataLength] = 0; } - //тут тоже добавить 401 + else if (nlhrReply->resultCode == 401) + { + ItemInfo SelItem = {0}; + SelItem.hwndList = hwndDlg; + SelItem.hContact = hContact; + if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK) + { + GetNewsData(tszUrl, szData, hContact, hwndDlg); + } + } CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } else { if (nlhr.resultCode == 401) { @@ -235,6 +261,7 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) SelItem.hContact = hContact; if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK) { + GetNewsData(tszUrl, szData, hContact, hwndDlg); } } } -- cgit v1.2.3