From acc3bba849e191562eb0b2e1b3ef518159362cbe Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 11 Aug 2010 14:56:55 +0300 Subject: modified: main.cpp modified: messages.cpp modified: new_gpg.rc modified: resource.h --- messages.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 38205cb..c4a890d 100644 --- a/messages.cpp +++ b/messages.cpp @@ -29,15 +29,25 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINRECV, w, l); bool unicode = (bool)(pre->flags&PREF_UNICODE); - { //check for public key - string str = msg; - string::size_type s1, s2; - if(((s2 = str.find("-----END PGP PUBLIC KEY BLOCK-----")) != string::npos) && ((s1 = str.find("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != string::npos)) + { //check for gpg related data + wchar_t *tmp = mir_utf8decodeW(msg); + wstring str = tmp; + mir_free(tmp); + wstring::size_type s1, s2; + + if(((s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----"))) != wstring::npos) && ((s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----"))) != wstring::npos)) { //this is public key } - else if(((s2 = str.find("-/ENCRYPTED-")) != string::npos) && ((s1 = str.find("-ENCRYPTED-")) != string::npos)) - { //this is encrypted data block + else if(((s2 = str.find(_T("-/ENCRYPTED-"))) != wstring::npos) && ((s1 = str.find(_T("-ENCRYPTED-"))) != wstring::npos)) + { //this is generic encrypted data block + } + else if(((s1 = str.find(_T("This message is encrypted."))) != wstring::npos)) + { //this is jabber encrypted data } + + char *utf = mir_utf8encodeW(str.c_str()); //for later usage + mir_free(utf); + } return CallService(MS_PROTO_CHAINRECV, w, l); @@ -48,10 +58,23 @@ int SendMsgSvc(WPARAM w, LPARAM l) CCSDATA *ccs = (CCSDATA*)l; if (!ccs) return CallService(MS_PROTO_CHAINSEND, w, l); + if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0)) + return CallService(MS_PROTO_CHAINSEND, w, l); + char *msg = (char*)(ccs->lParam); if (!msg) return CallService(MS_PROTO_CHAINSEND, w, l); bool unicode = (bool)(ccs->wParam&PREF_UNICODE); + { //encrypt data here + wchar_t *tmp = mir_utf8decodeW(msg); + wstring str = tmp; + mir_free(tmp); + wstring::size_type s1, s2; + + char *utf = mir_utf8encodeW(str.c_str()); //for later usage + mir_free(utf); + } + return CallService(MS_PROTO_CHAINSEND, w, l); } \ No newline at end of file -- cgit v1.2.3