diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 357261d79..ef3aac5e9 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1387,7 +1387,7 @@ bool p3NetMgrIMPL::netAssistConnectShutdown() return true; } -bool p3NetMgrIMPL::netAssistFriend(std::string id, bool on) +bool p3NetMgrIMPL::netAssistFriend(const std::string &id, bool on) { std::map::iterator it; @@ -1407,7 +1407,7 @@ bool p3NetMgrIMPL::netAssistFriend(std::string id, bool on) } -bool p3NetMgrIMPL::netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags) +bool p3NetMgrIMPL::netAssistKnownPeer(const std::string &id, const struct sockaddr_in &addr, uint32_t flags) { std::map::iterator it; @@ -1458,7 +1458,7 @@ bool p3NetMgrIMPL::netAssistAttach(bool on) -bool p3NetMgrIMPL::netAssistStatusUpdate(std::string id, int state) +bool p3NetMgrIMPL::netAssistStatusUpdate(const std::string &id, int state) { std::map::iterator it; diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 0eee04f29..823bd64b7 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -118,10 +118,10 @@ virtual bool setNetworkMode(uint32_t netMode) = 0; virtual bool setVisState(uint32_t visState) = 0; // Switch DHT On/Off. -virtual bool netAssistFriend(std::string id, bool on) = 0; -virtual bool netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags) = 0; +virtual bool netAssistFriend(const std::string &id, bool on) = 0; +virtual bool netAssistKnownPeer(const std::string &id, const struct sockaddr_in &addr, uint32_t flags) = 0; virtual bool netAssistBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age) = 0; -virtual bool netAssistStatusUpdate(std::string id, int mode) = 0; +virtual bool netAssistStatusUpdate(const std::string &id, int mode) = 0; /* Get Network State */ virtual uint32_t getNetStateMode() = 0; @@ -174,10 +174,10 @@ virtual bool setNetworkMode(uint32_t netMode); virtual bool setVisState(uint32_t visState); // Switch DHT On/Off. -virtual bool netAssistFriend(std::string id, bool on); -virtual bool netAssistKnownPeer(std::string id, const struct sockaddr_in &addr, uint32_t flags); +virtual bool netAssistFriend(const std::string &id, bool on); +virtual bool netAssistKnownPeer(const std::string &id, const struct sockaddr_in &addr, uint32_t flags); virtual bool netAssistBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age); -virtual bool netAssistStatusUpdate(std::string id, int mode); +virtual bool netAssistStatusUpdate(const std::string &id, int mode); /* Get Network State */ virtual uint32_t getNetStateMode(); diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index d67de1687..c62198aba 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -112,7 +112,6 @@ p3PeerMgrIMPL::p3PeerMgrIMPL() mLinkMgr = NULL; mNetMgr = NULL; - mHistoryMgr = NULL; /* setup basics of own state */ mOwnState.id = AuthSSL::getAuthSSL()->OwnId(); @@ -135,11 +134,10 @@ p3PeerMgrIMPL::p3PeerMgrIMPL() return; } -void p3PeerMgrIMPL::setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr, p3HistoryMgr *historyMgr) +void p3PeerMgrIMPL::setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr) { mLinkMgr = linkMgr; mNetMgr = netMgr; - mHistoryMgr = historyMgr; } void p3PeerMgrIMPL::setOwnNetworkMode(uint32_t netMode) @@ -564,7 +562,6 @@ bool p3PeerMgrIMPL::removeFriend(const std::string &id) { if (mFriendList.end() != (it = mFriendList.find(*rit))) { - mHistoryMgr->clear(it->second.id); mFriendList.erase(it); } } diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 162ff26e3..aef654f62 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -113,7 +113,6 @@ class p3NetMgr; class p3LinkMgrIMPL; class p3NetMgrIMPL; -class p3HistoryMgr; class p3PeerMgr { @@ -284,7 +283,7 @@ virtual bool haveOnceConnected(); p3PeerMgrIMPL(); -void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr, p3HistoryMgr *historyMgr); +void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr); void tick(); @@ -319,7 +318,6 @@ void printPeerLists(std::ostream &out); p3LinkMgrIMPL *mLinkMgr; p3NetMgrIMPL *mNetMgr; - p3HistoryMgr *mHistoryMgr; private: RsMutex mPeerMtx; /* protects below */ diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 4b6d801d4..7a15ab023 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1913,7 +1913,7 @@ int RsServer::StartupRetroShare() rsNotify = new p3Notify(); rsPeers = new p3Peers(mLinkMgr, mPeerMgr, mNetMgr); - mPeerMgr->setManagers(mLinkMgr, mNetMgr, mHistoryMgr); + mPeerMgr->setManagers(mLinkMgr, mNetMgr); mNetMgr->setManagers(mPeerMgr, mLinkMgr); //load all the SSL certs as friends diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 8f99a8e92..1cb4bc248 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -1134,9 +1134,7 @@ bool p3ChatService::clearPrivateChatQueue(bool incoming, const std::string &id) delete c; changed = true; - std::list::iterator it1 = it; - it++; - list->erase(it1); + it = list->erase(it); continue; } @@ -1439,6 +1437,9 @@ std::cerr << "p3chatservice: sending requested status string for peer " << peer_ bool p3ChatService::loadList(std::list& load) { + std::list ssl_peers; + mLinkMgr->getFriendList(ssl_peers); + for(std::list::const_iterator it(load.begin());it!=load.end();++it) { RsChatAvatarItem *ai = NULL ; @@ -1474,19 +1475,22 @@ bool p3ChatService::loadList(std::list& load) RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/ if (citem->chatFlags & RS_CHAT_FLAG_PRIVATE) { - RsChatMsgItem *ci = new RsChatMsgItem(); - citem->get(ci); + if (std::find(ssl_peers.begin(), ssl_peers.end(), citem->configPeerId) != ssl_peers.end()) { + RsChatMsgItem *ci = new RsChatMsgItem(); + citem->get(ci); - if (citem->configFlags & RS_CHATMSG_CONFIGFLAG_INCOMING) { - privateIncomingList.push_back(ci); + if (citem->configFlags & RS_CHATMSG_CONFIGFLAG_INCOMING) { + privateIncomingList.push_back(ci); + } else { + privateOutgoingList.push_back(ci); + } } else { - privateOutgoingList.push_back(ci); + // no friends } } else { // ignore all other items } - delete *it; continue; @@ -1507,6 +1511,7 @@ bool p3ChatService::loadList(std::list& load) // delete unknown items delete *it; } + return true; } @@ -1621,6 +1626,11 @@ void p3ChatService::statusChange(const std::list &plist) IndicateConfigChanged(); } } + } else if (it->actions & RS_PEER_MOVED) { + /* now handle remove */ + clearPrivateChatQueue(true, it->id); + clearPrivateChatQueue(false, it->id); + mHistoryMgr->clear(it->id); } } }