diff options
-rwxr-xr-x | messages.cpp | 6 | ||||
-rwxr-xr-x | utilities.cpp | 24 |
2 files changed, 19 insertions, 11 deletions
diff --git a/messages.cpp b/messages.cpp index 44172df..ab6197c 100755 --- a/messages.cpp +++ b/messages.cpp @@ -610,9 +610,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); mir_free(msg); - HANDLE h = (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); - sent_msgs.push_back(h); - return (int)h; + return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); } if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself cmd += _T("--comment \"\" --no-version "); @@ -752,7 +750,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT)); if(!(flags & PREF_UTF)) flags |= PREF_UTF; - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()); + sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str())); mir_free(msg); return 0; } diff --git a/utilities.cpp b/utilities.cpp index 9356728..9d2a9be 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -439,16 +439,25 @@ int onProtoAck(WPARAM w, LPARAM l) break; } } - else if(ack->type == ACKTYPE_MESSAGE && ack->result == ACKRESULT_FAILED) + else if(ack->type == ACKTYPE_MESSAGE) { extern std::list<HANDLE> sent_msgs; if(!sent_msgs.empty()) { - std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess); - if(it != sent_msgs.end()) + if(ack->result == ACKRESULT_FAILED) { - HistoryLog(ack->hContact, db_event("Failed to send encrypted message", 0,0, 0)); - sent_msgs.erase(it); + std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess); + if(it != sent_msgs.end()) + { + HistoryLog(ack->hContact, db_event("Failed to send encrypted message", 0,0, 0)); + + } + } + else if(ack->result == ACKRESULT_SUCCESS) + { + std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess); + if(it != sent_msgs.end()) + sent_msgs.erase(it); } } } @@ -1166,13 +1175,14 @@ void send_encrypted_msgs_thread(HANDLE hContact) { boost::this_thread::sleep(boost::posix_time::seconds(1)); list<string>::iterator end = hcontact_data[hContact].msgs_to_send.end(); + extern std::list<HANDLE> sent_msgs; for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p) { - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str()); - + sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str())); HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT)); boost::this_thread::sleep(boost::posix_time::seconds(1)); } + hcontact_data[hContact].msgs_to_send.clear(); return; } else |