From 3a271abf11dcba80c3e7186de0ab67cb7ef7fbba Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 18 Jan 2012 20:47:32 +0000 Subject: [PATCH] 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 --- libretroshare/src/pqi/p3historymgr.cc | 9 ++++++++- libretroshare/src/services/p3chatservice.cc | 14 +++++++++++--- libretroshare/src/services/p3chatservice.h | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index 817fd391f..936cc8902 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -65,11 +65,18 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons return; } + const RsChatLobbyMsgItem *cli = dynamic_cast(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; diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 6c388875a..a0d516187 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -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) ; diff --git a/libretroshare/src/services/p3chatservice.h b/libretroshare/src/services/p3chatservice.h index e61a0a335..779fbfafa 100644 --- a/libretroshare/src/services/p3chatservice.h +++ b/libretroshare/src/services/p3chatservice.h @@ -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) ;