diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2011-10-12 23:03:15 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2011-10-12 23:03:15 +0300 |
commit | 448c6ca661ec9c826cd18bd160e050cf21da112c (patch) | |
tree | bca331b9c59d2b8ee49cb0ce488203ac4ea34d5d /utilities.cpp | |
parent | 34317b53102eb8d1cad310fec31922a85bf9add9 (diff) |
notification on failed delivery
Diffstat (limited to 'utilities.cpp')
-rwxr-xr-x | utilities.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
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 |