diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-27 20:45:29 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-27 20:45:29 +0300 |
commit | 7a2b804bf9726fc0287b7b524ead935b759a1205 (patch) | |
tree | e5a0e4e19097538f7b624067781d90761cf227b3 /messages.cpp | |
parent | f3d248034ff8629704e7a76a09b2d565df92c195 (diff) |
modified: main.h
modified: messages.cpp
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/messages.cpp b/messages.cpp index 8df3a2b..37d8458 100644 --- a/messages.cpp +++ b/messages.cpp @@ -364,7 +364,7 @@ struct handle_plus_string string *str; HANDLE hContact; }; -list<handle_plus_string*> msgs_to_ignore; +//list<handle_plus_string*> msgs_to_ignore; int SendMsgSvc(WPARAM w, LPARAM l) { CCSDATA *ccs = (CCSDATA*)l; @@ -379,11 +379,12 @@ int SendMsgSvc(WPARAM w, LPARAM l) HANDLE hContact = ccs->hContact; if(metaIsProtoMetaContacts(hContact)) { - string str_event = (char*)ccs->lParam; - handle_plus_string *hps = new handle_plus_string; - hps->str = new string(str_event); - hps->hContact = ccs->hContact; - msgs_to_ignore.push_back(hps); +// string str_event = (char*)ccs->lParam; +// handle_plus_string *hps = new handle_plus_string; +// hps->str = new string(str_event); + hcontact_data[ccs->hContact].msgs_to_ignore.push_back((char*)ccs->lParam); +// hps->hContact = ccs->hContact; +// msgs_to_ignore.push_back(hps); return CallService(MS_PROTO_CHAINSEND, w, l); } // hContact = metaGetCurrent(hContact); @@ -512,10 +513,11 @@ int SendMsgSvc(WPARAM w, LPARAM l) { //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; - msgs_to_ignore.push_back(hps); +// 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); if(bAppendTags) { str_event.insert(0, toUTF8(outopentag)); @@ -523,13 +525,15 @@ int SendMsgSvc(WPARAM w, LPARAM l) } HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | DBEF_UTF); HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | DBEF_UTF); - DBWriteContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", 0) + 1); + hcontact_data[metaGetContact(hContact)].msgs_to_tag.push_back(str_event); +// DBWriteContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", 0) + 1); 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); +// DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", 0) + 1); + hcontact_data[metaGetContact(hContact)].msgs_to_tag.push_back(toUTF8(str)); } } return CallService(MS_PROTO_CHAINSEND, w, l); @@ -544,14 +548,13 @@ int HookSendMsg(WPARAM w, LPARAM l) { if(strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----")) //grrrr! return 1; - if(!msgs_to_ignore.empty()) + if(!hcontact_data[(HANDLE)w].msgs_to_ignore.empty()) { - for(list<handle_plus_string*>::iterator p = msgs_to_ignore.begin(); p != msgs_to_ignore.end(); p++) + for(list<string>::iterator p = hcontact_data[(HANDLE)w].msgs_to_ignore.begin(); p != hcontact_data[(HANDLE)w].msgs_to_ignore.end(); p++) { - if(((*p)->hContact == (HANDLE)w || (*p)->hContact == metaGetContact((HANDLE)w) || (*p)->hContact == metaGetCurrent((HANDLE)w)) && !strcmp((*p)->str->c_str(), (char*)dbei->pBlob)) + if(*p == (char*)dbei->pBlob) { - delete (*p)->str; - msgs_to_ignore.remove(*p); + hcontact_data[(HANDLE)w].msgs_to_ignore.erase(p); return 1; } } @@ -567,10 +570,27 @@ int HookSendMsg(WPARAM w, LPARAM l) if(bAppendTags) { - BYTE Msgs = DBGetContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", 0); + 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(*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; + } + } + } +/* BYTE Msgs = DBGetContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", 0); if(!Msgs) return 0; - if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT)) { char *msg = (char*)dbei->pBlob; wstring str = toUTF16(msg); @@ -581,7 +601,7 @@ int HookSendMsg(WPARAM w, LPARAM l) dbei->pBlob = (PBYTE)msg2; dbei->cbBlob = strlen(msg2)+1; DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", Msgs - 1); - } + }*/ } return 0; } |