From c83fb4b4bfd6b29e0264d5215ce43f6afe10ce51 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 22 Aug 2012 06:32:09 +0300 Subject: autoexchange fixes db event filter fixes backported fixes from miranda_ng port --- main.cpp | 88 ++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 38 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 3857f38..e28114c 100755 --- a/main.cpp +++ b/main.cpp @@ -1218,16 +1218,17 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { wstring path; { //data sanity checks - TCHAR *tmp = new TCHAR [5]; + TCHAR *tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); if(_tcslen(tmp) < 3) { - mir_free(tmp); + mir_free(tmp); tmp = NULL; MessageBox(0, TranslateT("You must set encryption algorythm first"), TranslateT("Error"), MB_OK); break; } - mir_free(tmp); - tmp = new TCHAR [5]; + if(tmp) + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*6); GetDlgItemText(hwndDlg, IDC_KEY_LENGTH, tmp, 5); int length = _ttoi(tmp); mir_free(tmp); @@ -1236,39 +1237,39 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, MessageBox(0, TranslateT("Key length must be of length from 1024 to 4096 bits"), TranslateT("Error"), MB_OK); break; } - tmp = new TCHAR [12]; - GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 12); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*12); + GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 11); if(_tcslen(tmp) != 10 && tmp[0] != '0') { MessageBox(0, TranslateT("Invalid date"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; - tmp = new TCHAR [128]; - GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 128); + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); + GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 127); if(_tcslen(tmp) < 5) { MessageBox(0, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } else if (_tcschr(tmp, _T('(')) || _tcschr(tmp, _T(')'))) { MessageBox(0, TranslateT("Name cannot contain '(' or ')'"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; - tmp = new TCHAR [128]; + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128); if((_tcslen(tmp)) < 5 || (!_tcschr(tmp, _T('@'))) || (!_tcschr(tmp, _T('.')))) { MessageBox(0, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; + mir_free(tmp); } { //generating key file TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); @@ -1284,11 +1285,11 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, break; } f<<"Key-Type: "; - tmp = new TCHAR [5]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); tmp2 = mir_t2a(tmp); - delete [] tmp; - char *subkeytype = new char [6]; + mir_free(tmp); + char *subkeytype = (char*)mir_alloc(6); if(strstr(tmp2, "RSA")) strcpy(subkeytype, "RSA"); else if(strstr(tmp2, "DSA")) //this is useless check for now, but it will be required if someone add another key types support @@ -1297,10 +1298,10 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, mir_free(tmp2); f<<"\n"; f<<"Key-Length: "; - tmp = new TCHAR [5]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_LENGTH, tmp, 5); int length = _ttoi(tmp); - delete [] tmp; + mir_free(tmp); f<szProtoName); + strcat(svc, PS_ICQ_ADDCAPABILITY); + if(ServiceExists(svc)) + CallService(svc, 0, (LPARAM)&cap); + } } } @@ -2249,7 +2261,7 @@ void ImportKey() s2 = output.find("<", s); else if(s2 > output.find("<", s)) s2 = output.find("<", s); - tmp = new char [output.substr(s,s2-s-1).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-1).length()+1)); strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp); @@ -2261,14 +2273,14 @@ void ImportKey() s2++; if(output[s] == ')') { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1)); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s+=3; s2 = output.find(">", s); - tmp = new char [output.substr(s,s2-s).length()+1]; + tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1)); strcpy(tmp, output.substr(s,s2-s).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp); @@ -2276,7 +2288,7 @@ void ImportKey() } else { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1)); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); -- cgit v1.2.3