added auto-resend of unsent messages. Fixed display of From field in outbox

This commit is contained in:
csoler 2016-01-08 20:48:47 -05:00
parent 0c591f08ae
commit 75edb46c99
2 changed files with 108 additions and 77 deletions

View file

@ -332,15 +332,20 @@ int p3MsgService::checkOutgoingMessages()
* if online, send
*/
static const uint32_t OLD_MESSAGE_FLUSHING_DELAY = 86400*7 ; // re-send old messages every week. This mainly ensures that
// messages that where never sent get sent at some point.
time_t now = time(NULL);
bool changed = false ;
std::list<RsMsgItem*> output_queue ;
{
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
const RsPeerId& ownId = mServiceCtrl->getOwnId();
std::list<uint32_t>::iterator it;
std::list<uint32_t> toErase;
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<uint32_t, RsMsgItem *>::iterator mit;
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); ++mit)
@ -350,10 +355,27 @@ int p3MsgService::checkOutgoingMessages()
/* find the certificate */
RsPeerId pid = mit->second->PeerId();
bool should_send = false ;
if( pid == ownId
|| ( (mit->second->msgFlags & RS_MSG_FLAGS_DISTANT) && (!(mit->second->msgFlags & RS_MSG_FLAGS_ROUTED)))
|| mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) ) /* FEEDBACK Msg to Ourselves */
if( pid == ownId)
should_send = true ;
if( mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) ) /* FEEDBACK Msg to Ourselves */
should_send = true ;
if (mit->second->msgFlags & RS_MSG_FLAGS_DISTANT)
{
if(!(mit->second->msgFlags & RS_MSG_FLAGS_ROUTED))
should_send = true ;
if(mit->second->sendTime + OLD_MESSAGE_FLUSHING_DELAY < now)
{
should_send = true ;
mit->second->sendTime = now;
}
}
if(should_send)
{
/* send msg */
pqioutput(PQL_DEBUG_BASIC, msgservicezone,

View file

@ -1098,25 +1098,34 @@ void MessagesDialog::insertMessages()
// From ....
{
bool setText = true;
if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX) {
if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX)
{
if ((it->msgflags & RS_MSG_SYSTEM) && it->srcId == ownId) {
text = "RetroShare";
} else {
}
else
{
if (it->msgflags & RS_MSG_DISTANT)
{
// distant message
setText = false;
if (gotInfo || rsMail->getMessage(it->msgId, msgInfo)) {
gotInfo = true;
if(msgbox != RS_MSG_INBOX && !msgInfo.rsgxsid_msgto.empty())
item->setId(RsGxsId(*msgInfo.rsgxsid_msgto.begin()), COLUMN_FROM, false);
else
item->setId(RsGxsId(msgInfo.rsgxsid_srcId), COLUMN_FROM, false);
} else {
}
else
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
}
} else {
else
text = QString::fromUtf8(rsPeers->getPeerName(it->srcId).c_str());
}
}
} else {
else
{
if (gotInfo || rsMail->getMessage(it->msgId, msgInfo)) {
gotInfo = true;