summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-28 19:46:57 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-28 19:46:57 +0300
commit81a35fab982d1d0a98a4ddf61e8b57f03fc9e41e (patch)
tree107ddd366581c34a3ee4c4a33e10b7ee5e4dd168 /messages.cpp
parent1d04c812fa182628596c89f7f092ee2bf928af9f (diff)
modified: messages.cpp
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp75
1 files changed, 49 insertions, 26 deletions
diff --git a/messages.cpp b/messages.cpp
index a6a00f0..c7e0c99 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -21,7 +21,7 @@ wstring new_key;
HANDLE new_key_hcnt = NULL;
boost::mutex new_key_hcnt_mutex;
bool _terminate = false;
-
+int returnNoError(HANDLE hContact);
int RecvMsgSvc(WPARAM w, LPARAM l)
{
@@ -35,6 +35,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
if (!msg)
return CallService(MS_PROTO_CHAINRECV, w, l);
HANDLE hContact = ccs->hContact;
+
// if(isProtoMetaContacts(hContact))
// hContact = metaGetMostOnline(hContact);
@@ -288,7 +289,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
char *tmp = new char [str.length()+1];
strcpy(tmp, str.c_str());
pre->szMessage = tmp;
- return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
+ return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); //TODO: add event for metacontact
}
}
}
@@ -320,7 +321,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
str.insert(0, "Received unencrypted message:\n");
debuglog<<"info: Failed to decrypt GPG encrypted message.\n";
pre->szMessage = mir_strdup(str.c_str());
- return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
+ return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); //TODO: add event for metacontact
}
else
{
@@ -335,10 +336,12 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{
char *msg = mir_strdup(toUTF8(str).c_str());
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, DBEF_UTF);
+ HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, DBEF_UTF);
mir_free(msg);
+// return returnNoError(hContact);
return 1;
}
- return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
+ return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); //TODO: add event for metacontact
}
}
}
@@ -349,21 +352,23 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
if(metaIsSubcontact(hContact))
{
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, DBEF_UTF);
+ HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, DBEF_UTF);
mir_free(msg);
+// return returnNoError(hContact);
return 1;
}
wstring str = toUTF16(msg);
mir_free((void**)pre->szMessage);
pre->szMessage = mir_strdup(toUTF8(str).c_str());
- return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
+ return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); //TODO: add event for metacontact
}
return CallService(MS_PROTO_CHAINRECV, w, l);
}
-struct handle_plus_string
+/*struct handle_plus_string
{
string *str;
HANDLE hContact;
-};
+};*/
//list<handle_plus_string*> msgs_to_ignore;
int SendMsgSvc(WPARAM w, LPARAM l)
{
@@ -511,14 +516,12 @@ int SendMsgSvc(WPARAM w, LPARAM l)
}
if(metaIsSubcontact(hContact))
{ //dirty hack to avoid metacontacts problem ..., this also broke filters chain
- int returnNoError(HANDLE hContact);
string str_event = (char*)ccs->lParam;
// handle_plus_string *hps = new handle_plus_string;
// hps->str = new string(str_event);
// hps->hContact = hContact;
- hcontact_data[hContact].msgs_to_ignore.push_back((char*)ccs->lParam);
// msgs_to_ignore.push_back(hps);
- hcontact_data[metaGetContact(hContact)].msgs_to_tag.push_back(str_event);
+ hcontact_data[hContact].msgs_to_ignore.push_back(str_event);
if(bAppendTags)
{
str_event.insert(0, toUTF8(outopentag));
@@ -530,10 +533,10 @@ int SendMsgSvc(WPARAM w, LPARAM l)
CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)toUTF8(str).c_str());
return returnNoError(hContact);
}
- ccs->lParam = (LPARAM)mir_strdup(toUTF8(str).c_str());
if(bAppendTags)
// DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", 0) + 1);
- hcontact_data[metaGetContact(hContact)].msgs_to_tag.push_back(toUTF8(str));
+ hcontact_data[hContact].msgs_to_tag.push_back((char*)ccs->lParam);
+ ccs->lParam = (LPARAM)mir_strdup(toUTF8(str).c_str());
}
}
return CallService(MS_PROTO_CHAINSEND, w, l);
@@ -548,13 +551,21 @@ int HookSendMsg(WPARAM w, LPARAM l)
{
if(strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----")) //grrrr!
return 1;
+ HANDLE hContact = NULL;
if(!hcontact_data[(HANDLE)w].msgs_to_ignore.empty())
+ hContact = (HANDLE)w;
+ else if(!hcontact_data[metaGetContact((HANDLE)w)].msgs_to_ignore.empty())
+ hContact = metaGetContact((HANDLE)w);
+ else if(!hcontact_data[metaGetCurrent((HANDLE)w)].msgs_to_ignore.empty())
+ hContact = metaGetCurrent((HANDLE)w);
+ if(hContact)
{
- for(list<string>::iterator p = hcontact_data[(HANDLE)w].msgs_to_ignore.begin(); p != hcontact_data[(HANDLE)w].msgs_to_ignore.end(); p++)
+ list<string>::iterator end = hcontact_data[hContact].msgs_to_ignore.end();
+ for(list<string>::iterator p = hcontact_data[hContact].msgs_to_ignore.begin(); p != end; p++)
{
if(*p == (char*)dbei->pBlob)
{
- hcontact_data[(HANDLE)w].msgs_to_ignore.erase(p);
+ hcontact_data[hContact].msgs_to_ignore.erase(p);
return 1;
}
}
@@ -572,20 +583,24 @@ int HookSendMsg(WPARAM w, LPARAM l)
{
if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT))
{
- std::list<string>::iterator end = hcontact_data[hContact].msgs_to_tag.end();
- for(std::list<string>::iterator i = hcontact_data[hContact].msgs_to_tag.begin(); i != end; ++i)
+ if(!hcontact_data[hContact].msgs_to_tag.empty())
{
- if(*i == (char*)dbei->pBlob)
+ std::list<string>::iterator end = hcontact_data[hContact].msgs_to_tag.end();
+ for(std::list<string>::iterator i = hcontact_data[hContact].msgs_to_tag.begin(); i != end; ++i)
{
- char *msg = (char*)dbei->pBlob;
- wstring str = toUTF16(msg);
- str.insert(0, outopentag);
- str.append(outclosetag);
- char *msg2 = mir_strdup(toUTF8(str).c_str());
- mir_free(dbei->pBlob);
- dbei->pBlob = (PBYTE)msg2;
- dbei->cbBlob = strlen(msg2)+1;
- hcontact_data[hContact].msgs_to_tag.erase(i);
+ if(*i == (char*)dbei->pBlob)
+ {
+ char *msg = (char*)dbei->pBlob;
+ wstring str = toUTF16(msg);
+ str.insert(0, outopentag);
+ str.append(outclosetag);
+ char *msg2 = mir_strdup(toUTF8(str).c_str());
+ mir_free(dbei->pBlob);
+ dbei->pBlob = (PBYTE)msg2;
+ dbei->cbBlob = strlen(msg2)+1;
+ hcontact_data[hContact].msgs_to_tag.erase(i);
+ break;
+ }
}
}
}
@@ -604,6 +619,14 @@ int HookSendMsg(WPARAM w, LPARAM l)
DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", Msgs - 1);
}*/
}
+ if((dbei->eventType == EVENTTYPE_MESSAGE) && !(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w))
+ {
+ char tmp[29];
+ strncpy(tmp, (char*)dbei->pBlob, 27);
+ tmp[28] = '\0';
+ if(strstr(tmp, "-----BEGIN PGP MESSAGE-----"))
+ return 1;
+ }
return 0;
}