summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-09-24 11:48:03 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-09-24 11:48:03 +0300
commit6d88cf817136473cfb98332cb4616e3563e33971 (patch)
treecd1f732b3cb10cc91e52e3411a3595d2a80a4279 /messages.cpp
parenta2d855c24796591e73ce8f2160746716aec6516e (diff)
replacer
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/messages.cpp b/messages.cpp
new file mode 100644
index 0000000..16cac57
--- /dev/null
+++ b/messages.cpp
@@ -0,0 +1,97 @@
+// Copyright © 2010 sss
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "commonheaders.h"
+
+
+wstring new_key;
+HANDLE new_key_hcnt = NULL;
+HANDLE new_key_hcnt_mutex = NULL;
+bool _terminate = false;
+
+BOOL isProtoMetaContacts(HANDLE hContact);
+
+int RecvMsgSvc(WPARAM w, LPARAM l)
+{
+ CCSDATA *ccs = (CCSDATA*)l;
+ if (!ccs)
+ return CallService(MS_PROTO_CHAINRECV, w, l);
+ PROTORECVEVENT *pre = (PROTORECVEVENT*)(ccs->lParam);
+ if (!pre)
+ return CallService(MS_PROTO_CHAINRECV, w, l);
+ char *msg = pre->szMessage;
+ if (!msg)
+ return CallService(MS_PROTO_CHAINRECV, w, l);
+ HANDLE hContact = ccs->hContact;
+ if(isProtoMetaContacts(hContact))
+ hContact = metaGetMostOnline(hContact);
+
+
+ return CallService(MS_PROTO_CHAINRECV, w, l);
+}
+
+int SendMsgSvc(WPARAM w, LPARAM l)
+{
+ CCSDATA *ccs = (CCSDATA*)l;
+ if (!ccs)
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+
+ char *msg = (char*)(ccs->lParam);
+ if (!msg)
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+ HANDLE hContact = ccs->hContact;
+ if(isProtoMetaContacts(hContact))
+ hContact = metaGetMostOnline(hContact);
+
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+}
+
+int HookSendMsg(WPARAM w, LPARAM l)
+{
+ HANDLE hContact = (HANDLE)w;
+ if(isProtoMetaContacts(hContact))
+ hContact = metaGetMostOnline(hContact);
+ if(!DBGetContactSettingByte(hContact, szReplacerModuleName, "GPGEncryption", 0))
+ return 0;
+
+ if(bAppendTags)
+ {
+ if(!l)
+ return 0;
+ BYTE Msgs = DBGetContactSettingByte(hContact, szReplacerModuleName, "MsgsForTagging", 0);
+ if(!Msgs)
+ return 0;
+ DBEVENTINFO * dbei = (DBEVENTINFO*)l;
+ if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT))
+ {
+ char *msg = (char*)dbei->pBlob;
+ TCHAR *tmp = mir_utf8decodeW(msg);
+ wstring str = tmp;
+ mir_free(tmp);
+ str.insert(0, outopentag);
+ str.append(outclosetag);
+ char *msg2 = mir_utf8encodeW(str.c_str());
+ mir_free(dbei->pBlob);
+ dbei->pBlob = (PBYTE)msg2;
+ dbei->cbBlob = strlen(msg2)+1;
+ DBWriteContactSettingByte(hContact, szReplacerModuleName, "MsgsForTagging", Msgs - 1);
+ }
+ }
+ return 0;
+}
+
+
+