From 2db81bed3b59b2c48bac5cbd97b511e79a9f23ca Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 10 Oct 2013 12:55:59 +0300 Subject: merged some of critical fixes from miranda ng main repo --- messages.cpp | 108 +++++++++-------------------------------------------------- 1 file changed, 15 insertions(+), 93 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 7a4667f..4b82cc2 100755 --- a/messages.cpp +++ b/messages.cpp @@ -42,7 +42,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, { if(bDebugLog) debuglog< tmp; @@ -745,13 +746,13 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(result == pxSuccessExitCodeInvalid) { //mir_free(msg); - HistoryLog(hContact, db_event(Translate("failed o encrypt message, GPG returned error, turn on debug log for more details"), 0,0, DBEF_SENT)); + HistoryLog(hContact, db_event(Translate("failed to encrypt message, GPG returned error, turn on debug log for more details"), 0,0, DBEF_SENT)); boost::filesystem::remove(path); return; } if(out.find("usage: ") != string::npos) { - MessageBox(0, TranslateT("Something wrong, gpg does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); + MessageBox(0, TranslateT("Something is wrong, GPG does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); //mir_free(msg); CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); boost::filesystem::remove(path); @@ -821,6 +822,8 @@ int SendMsgSvc(WPARAM w, LPARAM l) CCSDATA *ccs = (CCSDATA*)l; if (!ccs) return CallService(MS_PROTO_CHAINSEND, w, l); + if(!ccs->lParam) + return CallService(MS_PROTO_CHAINSEND, w, l); char *msg = nullptr; if((ccs->wParam & PREF_UTF) == PREF_UTF) msg = mir_strdup((char*)(ccs->lParam)); @@ -839,89 +842,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) debuglog<hContact, GCDNF_TCHAR))); return CallService(MS_PROTO_CHAINSEND, w, l); } - /*if(!isContactHaveKey(ccs->hContact)) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && gpg_valid) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - void send_encrypted_msgs_thread(HANDLE hContact); - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); - DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); - if(uin) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); - char svc[64]; - strcpy(svc, proto); - strcat(svc, PS_ICQ_CHECKCAPABILITY); - - if(ServiceExists(svc)) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - ICQ_CUSTOMCAP cap = {0}; - strcpy(cap.caps, "GPG AutoExchange"); - if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)ccs->wParam, (LPARAM)"-----PGP KEY REQUEST-----"); - hcontact_data[ccs->hContact].msgs_to_send.push_back(msg); - boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, ccs->hContact)); - mir_free(msg); - return returnNoError(ccs->hContact); - } - } - } - else - { - TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); - if(jid[0]) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - extern list Accounts; - list::iterator end = Accounts.end(); - for(list::iterator p = Accounts.begin(); p != end; p++) - { - TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); - if(caps) - { - wstring str; - for(int i=0;;i++) - { - str.push_back(caps[i]); - if(caps[i] == '\0') - if(caps[i+1] == '\0') - break; - } - mir_free(caps); - if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) - { - if(bDebugLog) - debuglog<hContact, GCDNF_TCHAR))); - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)ccs->wParam, (LPARAM)"-----PGP KEY REQUEST-----"); - hcontact_data[ccs->hContact].msgs_to_send.push_back(msg); - boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, ccs->hContact)); - mir_free(msg); - return returnNoError(ccs->hContact); - } - } - } - } - } - } - else - { - mir_free(msg); - return CallService(MS_PROTO_CHAINSEND, w, l); - } - } */ - else if(bDebugLog) + if(bDebugLog) debuglog<hContact, GCDNF_TCHAR))); if(bDebugLog && metaIsProtoMetaContacts(ccs->hContact)) debuglog<hContact, GCDNF_TCHAR))); @@ -1057,11 +978,11 @@ int HookSendMsg(WPARAM w, LPARAM l) if(bAppendTags) { string str_event = (char*)dbei->pBlob; - mir_free(dbei->pBlob); + //mir_free(dbei->pBlob); str_event.insert(0, toUTF8(outopentag)); str_event.append(toUTF8(outclosetag)); dbei->pBlob = (PBYTE)mir_strdup(str_event.c_str()); - dbei->cbBlob = str_event.length() + 1; + dbei->cbBlob = (DWORD)str_event.length() + 1; } return 0; @@ -1130,6 +1051,7 @@ static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam TranslateDialogDefault(hwndDlg); string questionstr = "Please enter password for key with ID: "; questionstr += inkeyid; + mir_free(inkeyid); SetDlgItemTextA(hwndDlg, IDC_KEYID, questionstr.c_str()); EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), 0); return TRUE; @@ -1160,8 +1082,8 @@ static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam DBWriteContactSettingTString(NULL, szGPGModuleName, "szKeyPassword", tmp); } if(password) - delete [] password; - password = new TCHAR [_tcslen(tmp)+1]; + mir_free(password); + password = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(tmp)+1)); _tcscpy(password, tmp); } mir_free(tmp); -- cgit v1.2.3