diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-19 06:03:40 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-19 06:03:40 +0000 |
commit | 7bf0edaf97198eae500070b1694e35b01ed8c6ba (patch) | |
tree | 369bc0f8637bc42185c0306812f0e49071518250 | |
parent | 607936ac04647798823b4fdd9e423aab350122c6 (diff) |
added password encoding/decoding
git-svn-id: http://svn.miranda-ng.org/main/trunk@5410 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 36 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 24 |
2 files changed, 34 insertions, 26 deletions
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 6b6f4cfa15..c753a655f6 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -39,6 +39,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDOK:
{
TCHAR str[MAX_PATH];
+ char passw[MAX_PATH];
if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
break;
@@ -72,8 +73,9 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA db_set_b(hContact, MODULE, "UseAuth", 1);
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- db_set_ts(hContact, MODULE, "Password", str);
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
+ CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
+ db_set_s(hContact, MODULE, "Password", passw);
}
DeleteAllItems(hwndList);
UpdateList(hwndList);
@@ -184,11 +186,10 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
db_free(&dbLogin);
}
- DBVARIANT dbPass = {0};
- if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) {
- SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
- db_free(&dbPass);
- }
+ ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
+ if (pwd)
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
}
break;
}
@@ -207,6 +208,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP {
ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR str[MAX_PATH];
+ char passw[MAX_PATH];
if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
break;
@@ -235,8 +237,9 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP db_set_b(SelItem->hContact, MODULE, "UseAuth", 1);
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(SelItem->hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- db_set_ts(SelItem->hContact, MODULE, "Password", str);
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
+ CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
+ db_set_s(SelItem->hContact, MODULE, "Password", passw);
}
DeleteAllItems(SelItem->hwndList);
UpdateList(SelItem->hwndList);
@@ -343,10 +346,11 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetDlgItemText(hwndDlg, IDC_LOGIN, dbv.ptszVal);
db_free(&dbv);
}
- if (!db_get_ts(hContact, MODULE, "Password", &dbv)) {
- SetDlgItemText(hwndDlg, IDC_PASSWORD, dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
+
+ if (pwd)
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
}
}
return TRUE;
@@ -357,6 +361,7 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP {
HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR str[MAX_PATH];
+ char passw[MAX_PATH];
if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
break;
@@ -385,8 +390,9 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP db_set_b(hContact, MODULE, "UseAuth", 1);
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- db_set_ts(hContact, MODULE, "Password", str);
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
+ CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
+ db_set_s(hContact, MODULE, "Password", passw);
}
}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 858713f163..21c8e5c037 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -94,10 +94,10 @@ void CreateAuthString(char *auth, HANDLE hContact, HWND hwndDlg) tlogin = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
}
- if (!db_get_ts(hContact, MODULE, "Password", &dbv)) {
- tpass = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
+ if (pwd)
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
+ tpass = mir_a2t(pwd);
}
else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
@@ -158,12 +158,13 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDOK:
{
ItemInfo &SelItem = *(ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- TCHAR str[MAX_PATH], str2[MAX_PATH];
- if (!GetDlgItemText(hwndDlg, IDC_FEEDUSERNAME, str, SIZEOF(str))) {
+ TCHAR username[MAX_PATH];
+ char passw[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDUSERNAME, username, SIZEOF(username))) {
MessageBox(hwndDlg, TranslateT("Enter your username"), TranslateT("Error"), MB_OK);
break;
}
- if (!GetDlgItemText(hwndDlg, IDC_FEEDPASSWORD, str2, SIZEOF(str2))) {
+ if (!GetDlgItemTextA(hwndDlg, IDC_FEEDPASSWORD, passw, SIZEOF(passw))) {
MessageBox(hwndDlg, TranslateT("Enter your password"), TranslateT("Error"), MB_OK);
break;
}
@@ -172,14 +173,15 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA 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);
+ SetDlgItemText(SelItem.hwndList, IDC_LOGIN, username);
+ SetDlgItemTextA(SelItem.hwndList, IDC_PASSWORD, passw);
}
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);
+ db_set_ts(SelItem.hContact, MODULE, "Login", username);
+ CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
+ db_set_s(SelItem.hContact, MODULE, "Password", passw);
}
EndDialog(hwndDlg, IDOK);
return TRUE;
|