From 82e4196bfcfe5fa976ef602f54fbaf82d3854f6d Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 12 Aug 2010 19:58:37 +0300 Subject: modified: main.cpp modified: messages.cpp --- main.cpp | 7 +++--- messages.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/main.cpp b/main.cpp index 7d8ef1f..702a9b2 100644 --- a/main.cpp +++ b/main.cpp @@ -90,7 +90,8 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM TCHAR cmd[512]; _tcscpy(cmd, _T("--list-secret-keys")); pxExecute(cmd, "", &out, &code); - } + } + cp866_to_cp1251(&out); while(p != string::npos) { if((p = out.find("sec ", p)) == string::npos) @@ -112,11 +113,11 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM mir_free(tmp); p = out.find("uid ", p); p2 = out.find_first_not_of(" ", p+5); - p = out.find(" ", p2); + p = out.find("<", p2); tmp = mir_a2t(out.substr(p2,p-p2).c_str()); ListView_SetItemText(hwndList, iRow, 2, tmp); mir_free(tmp); - p = out.find("<", p) + 1; + p++; p2 = out.find(">", p); tmp = mir_a2t(out.substr(p,p2-p).c_str()); ListView_SetItemText(hwndList, iRow, 1, tmp); diff --git a/messages.cpp b/messages.cpp index 2b81167..f6cff09 100644 --- a/messages.cpp +++ b/messages.cpp @@ -40,13 +40,59 @@ int RecvMsgSvc(WPARAM w, LPARAM l) if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) ;// } - else if(((s2 = str.find(_T("-/ENCRYPTED-"))) != wstring::npos) && ((s1 = str.find(_T("-ENCRYPTED-"))) != wstring::npos)) + else if((str.find(_T("-----END PGP MESSAGE-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP MESSAGE-----")) != wstring::npos)) { //this is generic encrypted data block if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) ;// + { + wstring::size_type p = 0; + while((p = str.find(_T("\r"), p)) != wstring::npos) + str.erase(p, 1); + } + char *tmp = mir_t2a(str.c_str()); + TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); + wstring path = 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(); + DeleteFile(path.c_str()); + DeleteFile(path2.c_str()); + if(str.length() > 0) + { + mir_free((void**)ccs->lParam); + char *utf = mir_utf8encodeW(str.c_str()); + ccs->lParam = (LPARAM)utf; + } + } } else if(((s1 = str.find(_T("This message is encrypted."))) != wstring::npos)) - { //this is jabber encrypted data + { //this is xmpp encrypted data if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) ;// } @@ -75,10 +121,9 @@ int SendMsgSvc(WPARAM w, LPARAM l) { //encrypt data here wchar_t *tmp = mir_utf8decodeW(msg); wstring str = tmp; - MessageBox(0, str.c_str(), _T(""), MB_OK); mir_free(tmp); wstring::size_type s1, s2; - { //not xmpp + { //not xmpp, just replace whole message string out; DWORD code; TCHAR cmd[128]; @@ -94,7 +139,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(tmp); _tcscat(cmd, tmp2); mir_free(tmp2); - _tcscat(cmd, _T("\"")); + _tcscat(cmd, _T(" \"")); tmp2 = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); path.append(tmp2); _tcscat(cmd, tmp2); @@ -103,28 +148,30 @@ int SendMsgSvc(WPARAM w, LPARAM l) path.append(_T("\\exported_data")); _tcscat(cmd, _T("\"")); { - wfstream f(path.c_str(), std::ios_base::in); - f<lParam); - char *utf = mir_utf8encodeW(str.c_str()); //for later usage - ccs->hContact = utf; - } - - + char *utf = mir_utf8encodeW(str.c_str()); + ccs->lParam = (LPARAM)utf; + } } - return CallService(MS_PROTO_CHAINSEND, w, l); } \ No newline at end of file -- cgit v1.2.3