diff options
author | George Hazan <george.hazan@gmail.com> | 2013-11-19 18:01:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-11-19 18:01:14 +0000 |
commit | d6e05cc3bca53565d9ca65377ab8b0b6190774b3 (patch) | |
tree | 76040facd4d0b82162069a19cae8f7f024bf1f65 /protocols/Tlen/src | |
parent | 2ef414538760079fa2955fca1a2c03d610459fa8 (diff) |
preparing to the transparent cyphering: end of MS_DB_CRYPT_ENCODESTRING/MS_DB_CRYPT_DECODESTRING
git-svn-id: http://svn.miranda-ng.org/main/trunk@6938 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen/src')
-rw-r--r-- | protocols/Tlen/src/tlen.cpp | 10 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_opt.cpp | 121 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_p2p_old.cpp | 5 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_thread.cpp | 12 |
4 files changed, 70 insertions, 78 deletions
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index dbb36e1108..0bf2926e3e 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -187,13 +187,9 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM wParam, LPARAM lParam) login = mir_strdup(dbv.pszVal);
db_free(&dbv);
}
- if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE) {
- if (!db_get(NULL, m_szModuleName, "Password", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
- password = mir_strdup(dbv.pszVal);
- db_free(&dbv);
- }
- }
+
+ if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE)
+ password = db_get_sa(NULL, m_szModuleName, "Password");
else if (threadData != NULL && strlen(threadData->password) > 0)
password = mir_strdup(threadData->password);
diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp index d8c47e0859..5d8a66af30 100644 --- a/protocols/Tlen/src/tlen_opt.cpp +++ b/protocols/Tlen/src/tlen_opt.cpp @@ -127,7 +127,6 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR db_free(&dbv);
}
if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
@@ -167,7 +166,6 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
reconnectRequired = TRUE;
if (dbv.pszVal != NULL) db_free(&dbv);
@@ -205,7 +203,6 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara db_free(&dbv);
}
if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
@@ -303,7 +300,6 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
reconnectRequired = TRUE;
if (dbv.pszVal != NULL) db_free(&dbv);
@@ -399,9 +395,8 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, if (!db_get_ts(NULL, proto->m_szModuleName, "LoginServer", &dbv)) {
SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, dbv.ptszVal);
db_free(&dbv);
- } else {
- SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, _T("tlen.pl"));
}
+ else SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, _T("tlen.pl"));
EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_HOSTPORT), TRUE);
@@ -409,8 +404,9 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, if (!db_get_ts(NULL, proto->m_szModuleName, "ManualHost", &dbv)) {
SetDlgItemText(hwndDlg, IDC_HOST, dbv.ptszVal);
db_free(&dbv);
- } else
- SetDlgItemText(hwndDlg, IDC_HOST, _T("s1.tlen.pl"));
+ }
+ else SetDlgItemText(hwndDlg, IDC_HOST, _T("s1.tlen.pl"));
+
SetDlgItemInt(hwndDlg, IDC_HOSTPORT, db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT), FALSE);
CheckDlgButton(hwndDlg, IDC_KEEPALIVE, db_get_b(NULL, proto->m_szModuleName, "KeepAlive", TRUE));
@@ -431,11 +427,11 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PORT_LABEL), bChecked);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PORT), bChecked);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USE_AUTH), bChecked);
- if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE) == TRUE) {
+ if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE) == TRUE)
CheckDlgButton(hwndDlg, IDC_FILE_PROXY_USE_AUTH, TRUE);
- } else {
+ else
bChecked = FALSE;
- }
+
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USER_LABEL), bChecked);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USER), bChecked);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PASSWORD_LABEL), bChecked);
@@ -454,8 +450,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, SetDlgItemText(hwndDlg, IDC_FILE_PROXY_USER, dbv.ptszVal);
db_free(&dbv);
}
- if (!db_get(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
+ if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
@@ -503,63 +498,63 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, }
}
break;
+
case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->code) {
- case PSN_APPLY:
- {
- WORD port;
- BOOL useEncryption;
- BOOL reconnectRequired = FALSE;
- DBVARIANT dbv;
- GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, sizeof(text));
- if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv) || strcmp(text, dbv.pszVal))
- reconnectRequired = TRUE;
- if (dbv.pszVal != NULL) db_free(&dbv);
- db_set_s(NULL, proto->m_szModuleName, "LoginServer", strlwr(text));
+ switch (((LPNMHDR) lParam)->code) {
+ case PSN_APPLY:
+ WORD port;
+ BOOL useEncryption;
+ BOOL reconnectRequired = FALSE;
+ DBVARIANT dbv;
+ GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, sizeof(text));
+ if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv) || strcmp(text, dbv.pszVal))
+ reconnectRequired = TRUE;
+ if (dbv.pszVal != NULL) db_free(&dbv);
+ db_set_s(NULL, proto->m_szModuleName, "LoginServer", strlwr(text));
- GetDlgItemTextA(hwndDlg, IDC_HOST, text, sizeof(text));
- if (db_get(NULL, proto->m_szModuleName, "ManualHost", &dbv) || strcmp(text, dbv.pszVal))
- reconnectRequired = TRUE;
- if (dbv.pszVal != NULL) db_free(&dbv);
- db_set_s(NULL, proto->m_szModuleName, "ManualHost", text);
+ GetDlgItemTextA(hwndDlg, IDC_HOST, text, sizeof(text));
+ if (db_get(NULL, proto->m_szModuleName, "ManualHost", &dbv) || strcmp(text, dbv.pszVal))
+ reconnectRequired = TRUE;
+ if (dbv.pszVal != NULL) db_free(&dbv);
+ db_set_s(NULL, proto->m_szModuleName, "ManualHost", text);
- port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, NULL, FALSE);
- if (db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT) != port)
- reconnectRequired = TRUE;
- db_set_w(NULL, proto->m_szModuleName, "ManualPort", port);
+ port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, NULL, FALSE);
+ if (db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT) != port)
+ reconnectRequired = TRUE;
+ db_set_w(NULL, proto->m_szModuleName, "ManualPort", port);
- proto->tlenOptions.sendKeepAlive = IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE);
- db_set_b(NULL, proto->m_szModuleName, "KeepAlive", (BYTE) proto->tlenOptions.sendKeepAlive);
+ proto->tlenOptions.sendKeepAlive = IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE);
+ db_set_b(NULL, proto->m_szModuleName, "KeepAlive", (BYTE) proto->tlenOptions.sendKeepAlive);
- useEncryption = IsDlgButtonChecked(hwndDlg, IDC_USE_SSL);
- if (db_get_b(NULL, proto->m_szModuleName, "UseEncryption", TRUE) != useEncryption)
- reconnectRequired = TRUE;
- db_set_b(NULL, proto->m_szModuleName, "UseEncryption", (BYTE) useEncryption);
-
- db_set_b(NULL, proto->m_szModuleName, "VisibilitySupport", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_VISIBILITY_SUPPORT));
- // File transfer options
- db_set_b(NULL, proto->m_szModuleName, "UseFileProxy", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_USE_PROXY));
- db_set_w(NULL, proto->m_szModuleName, "FileProxyType", (WORD) SendDlgItemMessage(hwndDlg, IDC_FILE_PROXY_TYPE, CB_GETCURSEL, 0, 0));
- GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, sizeof(text));
- db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text);
- db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE));
- db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH));
- GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, sizeof(text));
- db_set_s(NULL, proto->m_szModuleName, "FileProxyUsername", text);
- GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, sizeof(text));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
- db_set_s(NULL, proto->m_szModuleName, "FileProxyPassword", text);
- if (reconnectRequired && proto->isConnected)
- MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
- ApplyChanges(proto, 4);
- return TRUE;
- }
- }
+ useEncryption = IsDlgButtonChecked(hwndDlg, IDC_USE_SSL);
+ if (db_get_b(NULL, proto->m_szModuleName, "UseEncryption", TRUE) != useEncryption)
+ reconnectRequired = TRUE;
+ db_set_b(NULL, proto->m_szModuleName, "UseEncryption", (BYTE) useEncryption);
+
+ db_set_b(NULL, proto->m_szModuleName, "VisibilitySupport", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_VISIBILITY_SUPPORT));
+
+ // File transfer options
+ db_set_b(NULL, proto->m_szModuleName, "UseFileProxy", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_USE_PROXY));
+ db_set_w(NULL, proto->m_szModuleName, "FileProxyType", (WORD) SendDlgItemMessage(hwndDlg, IDC_FILE_PROXY_TYPE, CB_GETCURSEL, 0, 0));
+
+ GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, sizeof(text));
+ db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text);
+
+ db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE));
+ db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH));
+
+ GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, sizeof(text));
+ db_set_s(NULL, proto->m_szModuleName, "FileProxyUsername", text);
+
+ GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, sizeof(text));
+ db_set_s(NULL, proto->m_szModuleName, "FileProxyPassword", text);
+
+ if (reconnectRequired && proto->isConnected)
+ MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
+ ApplyChanges(proto, 4);
+ return TRUE;
}
break;
- case WM_DESTROY:
- break;
}
return FALSE;
diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index 88e561803b..c8ca8df1dd 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -470,12 +470,11 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft) strcpy(sb.szPassword, "");
if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE)) {
sb.useAuth = TRUE;
- if (!db_get(NULL, proto->m_szModuleName, "FileProxyUsername", &dbv)) {
+ if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyUsername", &dbv)) {
strcpy(sb.szUser, dbv.pszVal);
db_free(&dbv);
}
- if (!db_get(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
+ if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
strcpy(sb.szPassword, dbv.pszVal);
db_free(&dbv);
}
diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index 42a34bfa5f..ca7bce7e61 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -167,21 +167,23 @@ void __cdecl TlenServerThread(ThreadData *info) QueueUserAPC(TlenPasswordCreateDialogApcProc, hMainThread, (DWORD) jidStr);
WaitForSingleObject(hEventPasswdDlg, INFINITE);
CloseHandle(hEventPasswdDlg);
- //if ((p=(char *)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, TlenPasswordDlgProc, (LPARAM) jidStr)) != onlinePassword) {
+
if (onlinePassword[0] != (char) -1) {
strncpy(info->password, onlinePassword, sizeof(info->password));
info->password[sizeof(info->password)-1] = '\0';
- } else {
+ }
+ else {
info->proto->debugLogA("Thread ended, password request dialog was canceled");
loginErr = LOGINERR_BADUSERID;
}
- } else {
+ }
+ else {
if (!db_get(NULL, info->proto->m_szModuleName, "Password", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
strncpy(info->password, dbv.pszVal, sizeof(info->password));
info->password[sizeof(info->password)-1] = '\0';
db_free(&dbv);
- } else {
+ }
+ else {
info->proto->debugLogA("Thread ended, password is not configured");
loginErr = LOGINERR_BADUSERID;
}
|