summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-08-14 15:12:56 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-08-14 15:12:56 +0300
commit86cafe5f5e47960cb8962fd555612aeb2d288285 (patch)
tree43d96003c93b7f1d8f186d51f0276f9b7af46d68 /messages.cpp
parentc7afab6ec1a5bde6295c96abac0710cfcb3c84cd (diff)
modified: main.cpp
modified: messages.cpp modified: new_gpg.rc modified: resource.h
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp52
1 files changed, 17 insertions, 35 deletions
diff --git a/messages.cpp b/messages.cpp
index 5214429..960d063 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -16,6 +16,10 @@
#include "commonheaders.h"
+
+wstring new_key;
+HANDLE new_key_hcnt = NULL;
+
int RecvMsgSvc(WPARAM w, LPARAM l)
{
CCSDATA *ccs = (CCSDATA*)l;
@@ -41,6 +45,11 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{ //this is public key
if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0))
;//
+ void ShowNewKeyDialog();
+/* if(key_action == 3)
+ return CallService(MS_PROTO_CHAINRECV, w, l);
+ else if(key_action == 2)
+ DBWriteContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 1); */
s1 = 0;
while((s1 = str.find(_T("\r"), s1)) != wstring::npos)
{
@@ -49,39 +58,10 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----"));
s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----"));
s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----"));
- DBWriteContactSettingTString(ccs->hContact, szModuleName, "GPGPubKey", str.substr(s1,s2-s1).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);
- f<<str.c_str();
- f.close();
- cmd += _T(" --trust-model always ");
- cmd += _T(" --import \"");
- cmd += tmp2;
- cmd += _T("\"");
- }
- if(pxExecute(&cmd, "", &output, &exitcode) == pxNotFound)
- {
- MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
- return CallService(MS_PROTO_CHAINRECV, w, l);
- }
- cp866_to_cp1251(&output);
- MessageBoxA(0, output.c_str(), "", MB_OK);
- DeleteFile(tmp2);
- }
+ new_key.append(str.substr(s1,s2-s1));
+ new_key_hcnt = ccs->hContact;
+ ShowNewKeyDialog();
+ return CallService(MS_PROTO_CHAINRECV, w, l);
}
s1 = str.find(_T("-----BEGIN PGP MESSAGE-----"));
s2 = str.find(_T("-----END PGP MESSAGE-----"));
@@ -221,6 +201,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
mir_free(tmp);
return CallService(MS_PROTO_CHAINSEND, w, l);
}
+ cmd += _T("--comment \"\" --no-version ");
cmd += _T("--trust-model always ");
cmd += _T("--batch --yes -e -a -r ");
TCHAR *tmp2 = mir_a2t(tmp);
@@ -272,12 +253,13 @@ int SendMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
mir_free((void**)ccs->lParam);
- char *utf = mir_utf8encodeW(str.c_str());
+ char *utf = mir_u2a(str.c_str());
ccs->lParam = (LPARAM)utf;
if(bAppendTags)
DBWriteContactSettingByte(ccs->hContact, szModuleName, "MsgsForTagging", DBGetContactSettingByte(ccs->hContact, szModuleName, "MsgsForTagging", 0) + 1);
}
}
+ ccs->wParam&=~PREF_UNICODE;
return CallService(MS_PROTO_CHAINSEND, w, l);
}
@@ -311,4 +293,4 @@ int HookSendMsg(WPARAM w, LPARAM l)
}
}
return 0;
-} \ No newline at end of file
+}