From 07bff43c1ee8ffb1e19dc2ed6419f602c0053f56 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 12 Aug 2010 21:19:08 +0300 Subject: modified: gpg_wrapper.cpp modified: gpg_wrapper.h modified: main.cpp modified: messages.cpp modified: options.cpp --- messages.cpp | 57 +++++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index f6cff09..cb38468 100644 --- a/messages.cpp +++ b/messages.cpp @@ -52,6 +52,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) char *tmp = mir_t2a(str.c_str()); TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); wstring path = tmp2; + mir_free(tmp2); path.append(_T("\\encrypted_data.asc")); wfstream f(path.c_str(), std::ios::out); f< ")); - wstring path2 = tmp2; - mir_free(tmp2); - path2.append(_T("\\decrypted_data")); - _tcscat(cmd, _T("\"")); - _tcscat(cmd, path2.c_str()); - _tcscat(cmd, _T("\"")); - pxExecute(cmd, "", &out, &code); - wfstream f(path2.c_str(), std::ios::in); - str.clear(); - while(!f.eof() && f.is_open()) - { - TCHAR tmp[128]; - f.getline(tmp, 128); - str.append(tmp); - str.append(_T("\n")); - } - f.close(); + wstring cmd; + cmd += _T(" -d -a \""); + cmd += path; + pxExecute(&cmd, "", &out, &code); DeleteFile(path.c_str()); - DeleteFile(path2.c_str()); - if(str.length() > 0) + cp866_to_cp1251(&out); { - mir_free((void**)ccs->lParam); - char *utf = mir_utf8encodeW(str.c_str()); - ccs->lParam = (LPARAM)utf; + string::size_type p = out.find(">\"\n") +3; + TCHAR *tmp = mir_a2t (out.substr(p).c_str()); + if(_tcslen(tmp) > 0) + { + mir_free((void**)ccs->lParam); + char *utf = mir_utf8encodeW(tmp); + ccs->lParam = (LPARAM)utf; + return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + } } } } @@ -126,7 +115,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) { //not xmpp, just replace whole message string out; DWORD code; - TCHAR cmd[128]; + wstring cmd; wstring path; char *tmp = UniGetContactSettingUtf(ccs->hContact, szModuleName, "KeyFingerprint", ""); if(strlen(tmp) < 2) @@ -134,19 +123,19 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(tmp); return CallService(MS_PROTO_CHAINSEND, w, l); } - _tcscpy(cmd, _T("--batch --yes -e -a -r ")); + cmd += _T("--batch --yes -e -a -r "); TCHAR *tmp2 = mir_a2t(tmp); mir_free(tmp); - _tcscat(cmd, tmp2); + cmd += tmp2; mir_free(tmp2); - _tcscat(cmd, _T(" \"")); + cmd += _T(" \""); tmp2 = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); path.append(tmp2); - _tcscat(cmd, tmp2); + cmd += tmp2; mir_free(tmp2); - _tcscat(cmd, _T("\\exported_data")); + cmd += _T("\\exported_data"); path.append(_T("\\exported_data")); - _tcscat(cmd, _T("\"")); + cmd += _T("\""); { char *tmp = mir_t2a(str.c_str()); wfstream f(path.c_str(), std::ios::out); @@ -154,7 +143,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(tmp); f.close(); } - pxExecute(cmd, "", &out, &code); + pxExecute(&cmd, "", &out, &code); DeleteFile(path.c_str()); path.append(_T(".asc")); wfstream f(path.c_str(), std::ios::in); -- cgit v1.2.3