From 448c6ca661ec9c826cd18bd160e050cf21da112c Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 12 Oct 2011 23:03:15 +0300 Subject: notification on failed delivery --- utilities.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'utilities.cpp') 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 sent_msgs; if(!sent_msgs.empty()) { - std::list::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::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::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::iterator end = hcontact_data[hContact].msgs_to_send.end(); + extern std::list sent_msgs; for(list::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 -- cgit v1.2.3