diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-18 13:58:00 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-18 13:58:00 +0000 |
commit | b91be49d75102064a455581665e230778ba9f325 (patch) | |
tree | 7b71caa18e78b7f60ce09de3c330758c5e127768 /plugins/NewsAggregator/Src | |
parent | 3fda20c00f0d7e8a266970475719717cfbcf00c9 (diff) |
preparing for using authenticztion dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@5402 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewsAggregator/Src')
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 258ec6a031..6ca80cfd04 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -118,6 +118,68 @@ void CreateAuthString(char *auth, HANDLE hContact, HWND hwndDlg) mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode((PBYTE)str, len)));
}
+INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ ItemInfo &SelItem = *(ItemInfo*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)&SelItem);
+
+ if (SelItem.hwndList)
+ {
+ TCHAR str[MAX_PATH];
+ if (GetDlgItemText(SelItem.hwndList, IDC_FEEDTITLE, str, SIZEOF(str)))
+ SetDlgItemText(hwndDlg, IDC_FEEDNAME, str);
+ else
+ {
+ GetDlgItemText(SelItem.hwndList, IDC_FEEDURL, str, SIZEOF(str));
+ SetDlgItemText(hwndDlg, IDC_FEEDNAME, str);
+ }
+ }
+ else if (SelItem.hContact)
+ {
+ }
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ ItemInfo &SelItem = *(ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TCHAR str[MAX_PATH], str2[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDUSERNAME, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter your username"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDPASSWORD, str2, SIZEOF(str2))) {
+ 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);
+ EndDialog(hwndDlg, IDOK);
+ return TRUE;
+ }
+
+ case IDCANCEL:
+ {
+ EndDialog(hwndDlg, IDCANCEL);
+ return TRUE;
+ }
+ }
+ break;
+
+ }
+
+ return FALSE;
+}
+
VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg)
{
NETLIBHTTPREQUEST nlhr = {0};
@@ -164,10 +226,16 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
(*szData)[nlhrReply->dataLength] = 0;
}
+ //тут тоже добавить 401
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
} else {
if (nlhr.resultCode == 401) {
- //запросить ввести логин и пароль и снова попытаться скачать
+ ItemInfo SelItem = {0};
+ SelItem.hwndList = hwndDlg;
+ SelItem.hContact = hContact;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK)
+ {
+ }
}
}
@@ -662,11 +730,9 @@ TCHAR * CheckFeed(TCHAR *tszURL, HWND hwndDlg) }
xi.destroyNode(hXml);
}
- else {
- TCHAR mes[MAX_PATH];
- mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis not a valid feed's address."), tszURL);
- MessageBox(hwndDlg, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONERROR);
- }
+ TCHAR mes[MAX_PATH];
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis not a valid feed's address."), tszURL);
+ MessageBox(hwndDlg, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONERROR);
return NULL;
}
|