Added history for chat lobbies and disabled it until the lobbies are saved.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4813 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-01-18 20:47:32 +00:00
parent 51cfb0c5fe
commit 3a271abf11
3 changed files with 20 additions and 5 deletions

View File

@ -65,11 +65,18 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
return;
}
const RsChatLobbyMsgItem *cli = dynamic_cast<const RsChatLobbyMsgItem*>(chatItem);
if (cli) {
// disable history for chat lobbies until they are saved
return;
}
RsHistoryMsgItem* item = new RsHistoryMsgItem;
item->chatPeerId = chatPeerId;
item->incoming = incoming;
item->peerId = peerId;
item->peerName = rsPeers->getPeerName(item->peerId);
item->peerName = cli ? cli->nick : rsPeers->getPeerName(item->peerId);
item->sendTime = chatItem->sendTime;
item->recvTime = chatItem->recvTime;

View File

@ -378,7 +378,7 @@ bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstrin
ChatLobbyId lobby_id ;
if(isLobbyId(id,lobby_id))
return sendLobbyChat(msg,lobby_id) ;
return sendLobbyChat(id,msg,lobby_id) ;
// make chat item....
#ifdef CHAT_DEBUG
@ -1736,7 +1736,7 @@ void p3ChatService::locked_initLobbyBouncableObject(const ChatLobbyId& lobby_id,
item.nick = lobby.nick_name ;
}
bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lobby_id)
bool p3ChatService::sendLobbyChat(const std::string &id, const std::wstring& msg, const ChatLobbyId& lobby_id)
{
#ifdef CHAT_DEBUG
std::cerr << "Sending chat lobby message to lobby " << std::hex << lobby_id << std::dec << std::endl;
@ -1759,7 +1759,11 @@ bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lo
item.message = msg;
}
bounceLobbyObject(&item,rsPeers->getOwnId()) ;
std::string ownId = rsPeers->getOwnId();
mHistoryMgr->addMessage(false, id, ownId, &item);
bounceLobbyObject(&item, ownId) ;
return true ;
}
@ -2222,6 +2226,10 @@ void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
sendItem(item) ;
}
// remove history
mHistoryMgr->clear(it->second.virtual_peer_id);
// remove lobby information
_chat_lobbys.erase(it) ;

View File

@ -229,7 +229,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
/// receive and handle chat lobby item
bool recvLobbyChat(RsChatLobbyMsgItem*,const std::string& src_peer_id) ;
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
bool sendLobbyChat(const std::string &id, const std::wstring&, const ChatLobbyId&) ;
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;