From 1c90e6b0df2d7c9c723dfa0c64f07a002ba1507f Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 13 Aug 2010 00:08:41 +0300 Subject: modified: messages.cpp --- messages.cpp | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index ed3da04..8bc2914 100644 --- a/messages.cpp +++ b/messages.cpp @@ -39,6 +39,42 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { //this is public key if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) ;// + s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); + DBWriteContactSettingTString(ccs->hContact, szModuleName, "GPGPubKey", str.substr(s1,s2-s1).c_str()); + tmp = new TCHAR [str.length()+1]; +// _tcscpy(tmp, str.substr(ws1,ws2-ws1).c_str()); + { //gpg execute block + wstring cmd; + TCHAR tmp2[MAX_PATH] = {0}; + TCHAR *ptmp; + string output; + DWORD exitcode; + { + ptmp = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T("")); + _tcscpy(tmp2, ptmp); + mir_free(ptmp); + _tcscat(tmp2, _T("\\")); + _tcscat(tmp2, _T("temporary_exported.asc")); + wfstream f(tmp2, std::ios::out); + ptmp = UniGetContactSettingUtf(ccs->hContact, szModuleName, "GPGPubKey", _T("")); + wstring str = ptmp; + mir_free(ptmp); + wstring::size_type s = 0; + while((s = str.find(_T("\r"), s)) != wstring::npos) + { + str.erase(s, 1); + } + f<This message is encrypted."))) != wstring::npos)) - { //this is xmpp encrypted data - if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) - ;// - } - - char *utf = mir_utf8encodeW(str.c_str()); //for later usage - mir_free(utf); - } - return CallService(MS_PROTO_CHAINRECV, w, l); } @@ -165,7 +191,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) path.append(_T(".asc")); wfstream f(path.c_str(), std::ios::in); str.clear(); - while(!f.eof()) + while(!f.eof() && f.is_open()) { TCHAR tmp[128]; f.getline(tmp, 128); -- cgit v1.2.3