+ }*/
+
+std::list<STG_MSG>::iterator it(messages.begin());
+while (it != messages.end())
+ {
+ printfd(__FILE__, "Message timeout: %d, delta: %f\n", settings->GetMessageTimeout(), difftime(stgTime, it->header.creationTime));
+ if (settings->GetMessageTimeout() > 0 &&
+ difftime(stgTime, it->header.creationTime) > settings->GetMessageTimeout())
+ {
+ // Timeout exceeded
+ if (store->DelMessage(it->header.id, login))
+ {
+ WriteServLog("Error deleting message: '%s'", store->GetStrError().c_str());
+ printfd(__FILE__, "Error deleting message: '%s'\n", store->GetStrError().c_str());
+ }
+ messages.erase(it++);
+ continue;
+ }
+ if (static_cast<time_t>(it->header.lastSendTime + it->header.repeatPeriod * 60) < stgTime)
+ {
+ if (SendMessage(*it))
+ {
+ // We need to check all messages in queue for timeout
+ ++it;
+ continue;
+ }
+ it->header.repeat--;
+ if (it->header.repeat < 0)
+ {
+ if (store->DelMessage(it->header.id, login))
+ {
+ WriteServLog("Error deleting message: '%s'", store->GetStrError().c_str());
+ printfd(__FILE__, "Error deleting message: '%s'\n", store->GetStrError().c_str());
+ }
+ messages.erase(it++);
+ }
+ else
+ {
+ #ifndef DEBUG
+ //TODO: gcc v. 4.x generate ICE on x86_64
+ it->header.lastSendTime = time(NULL);
+ #else
+ it->header.lastSendTime = stgTime;
+ #endif
+ if (store->EditMessage(*it, login))
+ {
+ WriteServLog("Error modifying message: '%s'", store->GetStrError().c_str());
+ printfd(__FILE__, "Error modifying message: '%s'\n", store->GetStrError().c_str());
+ }
+ ++it;
+ }
+ }
+ else
+ {
+ ++it;
+ }