summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-10-12 23:03:15 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-10-12 23:03:15 +0300
commit448c6ca661ec9c826cd18bd160e050cf21da112c (patch)
treebca331b9c59d2b8ee49cb0ce488203ac4ea34d5d
parent34317b53102eb8d1cad310fec31922a85bf9add9 (diff)
notification on failed delivery
-rwxr-xr-xmessages.cpp6
-rwxr-xr-xutilities.cpp24
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