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 --- messages.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'messages.cpp') 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