refs #816, set timestamp in text message

This commit is contained in:
Klaus Basan
2016-11-22 20:05:08 +01:00
parent 927343399c
commit 224b534684
3 changed files with 29 additions and 1 deletions

View File

@@ -759,7 +759,9 @@ namespace BlackCore
void CNetworkVatlib::onTextMessageReceived(VatSessionID, const char *from, const char *to, const char *msg, void *cbvar)
{
BlackMisc::Network::CTextMessageList messages(cbvar_cast(cbvar)->fromFSD(msg), CCallsign(cbvar_cast(cbvar)->fromFSD(from)), CCallsign(cbvar_cast(cbvar)->fromFSD(to)));
CTextMessage tm(cbvar_cast(cbvar)->fromFSD(msg), CCallsign(cbvar_cast(cbvar)->fromFSD(from)), CCallsign(cbvar_cast(cbvar)->fromFSD(to)));
tm.setCurrentUtcTime();
CTextMessageList messages(tm);
emit cbvar_cast(cbvar)->textMessagesReceived(messages);
}
@@ -777,6 +779,7 @@ namespace BlackCore
}
if (frequencies.isEmpty()) { return; }
BlackMisc::Network::CTextMessageList messages(cbvar_cast(cbvar)->fromFSD(msg), frequencies, CCallsign(cbvar_cast(cbvar)->fromFSD(from)));
messages.setCurrentUtcTime();
emit cbvar_cast(cbvar)->textMessagesReceived(messages);
}

View File

@@ -104,6 +104,25 @@ namespace BlackMisc
return this->container().contains(&OBJ::hasValidTimestamp, false);
}
template <class OBJ, class CONTAINER>
void ITimestampObjectList<OBJ, CONTAINER>::setCurrentUtcTime()
{
for (ITimestampBased &tsObj : this->container())
{
tsObj.setCurrentUtcTime();
}
}
template <class OBJ, class CONTAINER>
void ITimestampObjectList<OBJ, CONTAINER>::setInvalidTimestampsToCurrentUtcTime()
{
for (ITimestampBased &tsObj : this->container())
{
if (tsObj.hasValidTimestamp()) { continue; }
tsObj.setCurrentUtcTime();
}
}
template <class OBJ, class CONTAINER>
QDateTime ITimestampObjectList<OBJ, CONTAINER>::latestTimestamp() const
{

View File

@@ -50,6 +50,12 @@ namespace BlackMisc
//! Has invalid timestamp
bool hasInvalidTimestamps() const;
//! Set all timestamps to now
void setCurrentUtcTime();
//! Set invalid timestamps to now
void setInvalidTimestampsToCurrentUtcTime();
//! Latest timestamp
QDateTime latestTimestamp() const;