summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-08-13 00:08:41 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-08-13 00:08:41 +0300
commit1c90e6b0df2d7c9c723dfa0c64f07a002ba1507f (patch)
treeb142a4eb57f764c37fb180ba9484c0e65d154ddc /messages.cpp
parente2b98c75887cd08a278c2056ab8742b5108cf0ad (diff)
modified: messages.cpp
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp50
1 files changed, 38 insertions, 12 deletions
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<<str.c_str();
+ f.close();
+ cmd += _T(" --import \"");
+ cmd += tmp2;
+ cmd += _T("\"");
+ }
+ pxExecute(&cmd, "", &output, &exitcode);
+ cp866_to_cp1251(&output);
+ MessageBoxA(0, output.c_str(), "", MB_OK);
+ DeleteFile(tmp2);
+ }
}
else if((str.find(_T("-----END PGP MESSAGE-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP MESSAGE-----")) != wstring::npos))
{ //this is generic encrypted data block
@@ -75,7 +111,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
mir_free(tmp2);
path += _T("\\decrypted_data");
fstream f(path.c_str(), std::ios::in);
- while(!f.eof())
+ while(!f.eof() && f.is_open())
{
char tmp[256];
f.getline(tmp, 256);
@@ -97,17 +133,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
}
}
}
- else if(((s1 = str.find(_T("<body>This message is encrypted.</body>"))) != 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);