mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 07:41:20 -04:00
fixed some bugs in auto-activating saved chat rooms
This commit is contained in:
parent
c72b49c296
commit
5139c023ab
7 changed files with 50 additions and 29 deletions
|
@ -933,7 +933,7 @@ void DistributedChatService::sendLobbyStatusPeerChangedNickname(const ChatLobbyI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DistributedChatService::sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id)
|
void DistributedChatService::sendLobbyStatusPeerLeaving(const ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
sendLobbyStatusItem(lobby_id,RS_CHAT_LOBBY_EVENT_PEER_LEFT,std::string()) ;
|
sendLobbyStatusItem(lobby_id,RS_CHAT_LOBBY_EVENT_PEER_LEFT,std::string()) ;
|
||||||
}
|
}
|
||||||
|
@ -990,7 +990,7 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
|
||||||
while( lobby.msg_cache.find(item.msg_id) != lobby.msg_cache.end() ) ;
|
while( lobby.msg_cache.find(item.msg_id) != lobby.msg_cache.end() ) ;
|
||||||
|
|
||||||
RsIdentityDetails details ;
|
RsIdentityDetails details ;
|
||||||
if(!rsIdentity->getIdDetails(lobby.gxs_id,details))
|
if(!rsIdentity || !rsIdentity->getIdDetails(lobby.gxs_id,details))
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) Cannot send chat lobby object. Signign identity " << lobby.gxs_id << " is unknown." << std::endl;
|
std::cerr << "(EE) Cannot send chat lobby object. Signign identity " << lobby.gxs_id << " is unknown." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -1580,6 +1580,9 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co
|
||||||
}
|
}
|
||||||
_chat_lobbys[lobby_id] = entry ;
|
_chat_lobbys[lobby_id] = entry ;
|
||||||
}
|
}
|
||||||
|
setLobbyAutoSubscribe(lobby_id,true);
|
||||||
|
|
||||||
|
triggerConfigSave(); // so that we save the subscribed lobbies
|
||||||
|
|
||||||
for(std::list<RsPeerId>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
||||||
invitePeerToLobby(lobby_id,*it) ;
|
invitePeerToLobby(lobby_id,*it) ;
|
||||||
|
@ -1668,10 +1671,11 @@ void DistributedChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribe
|
||||||
void DistributedChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
void DistributedChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
{
|
{
|
||||||
// send AKN item
|
// send AKN item
|
||||||
sendLobbyStatusPeerLiving(id) ;
|
sendLobbyStatusPeerLeaving(id) ;
|
||||||
|
setLobbyAutoSubscribe(id, false);
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
|
RS_STACK_MUTEX(mDistributedChatMtx);
|
||||||
|
|
||||||
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(id) ;
|
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(id) ;
|
||||||
|
|
||||||
|
@ -1706,6 +1710,7 @@ void DistributedChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
_chat_lobbys.erase(it) ;
|
_chat_lobbys.erase(it) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
triggerConfigSave(); // so that we save the subscribed lobbies
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_DEL) ;
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_DEL) ;
|
||||||
|
|
||||||
// done!
|
// done!
|
||||||
|
@ -1828,19 +1833,27 @@ bool DistributedChatService::setIdentityForChatLobby(const ChatLobbyId& lobby_id
|
||||||
|
|
||||||
void DistributedChatService::setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe)
|
void DistributedChatService::setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe)
|
||||||
{
|
{
|
||||||
{
|
|
||||||
RS_STACK_MUTEX(mDistributedChatMtx);
|
|
||||||
|
|
||||||
if(autoSubscribe){
|
if(autoSubscribe)
|
||||||
_known_lobbies_flags[lobby_id] |= RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
{
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mDistributedChatMtx);
|
||||||
|
_known_lobbies_flags[lobby_id] |= RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
||||||
|
}
|
||||||
RsGxsId gxsId;
|
RsGxsId gxsId;
|
||||||
|
|
||||||
if (getIdentityForChatLobby(lobby_id, gxsId))
|
if (getIdentityForChatLobby(lobby_id, gxsId))
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mDistributedChatMtx);
|
||||||
_lobby_default_identity[lobby_id] = gxsId;
|
_lobby_default_identity[lobby_id] = gxsId;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mDistributedChatMtx);
|
||||||
_known_lobbies_flags[lobby_id] &= ~RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE ;
|
_known_lobbies_flags[lobby_id] &= ~RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE ;
|
||||||
_lobby_default_identity.erase(lobby_id);
|
_lobby_default_identity.erase(lobby_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
triggerConfigSave();
|
triggerConfigSave();
|
||||||
|
@ -2116,12 +2129,15 @@ bool DistributedChatService::processLoadListItem(const RsItem *item)
|
||||||
entry.last_connexion_challenge_time = now ;
|
entry.last_connexion_challenge_time = now ;
|
||||||
entry.last_keep_alive_packet_time = now ;
|
entry.last_keep_alive_packet_time = now ;
|
||||||
|
|
||||||
RS_STACK_MUTEX(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
|
{
|
||||||
_chat_lobbys[entry.lobby_id] = entry ;
|
RS_STACK_MUTEX(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
_chat_lobbys[entry.lobby_id] = entry ;
|
||||||
|
}
|
||||||
|
|
||||||
// make the UI aware of the existing chat room
|
// make the UI aware of the existing chat room
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ class DistributedChatService
|
||||||
void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
||||||
bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
||||||
void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ;
|
void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ;
|
||||||
|
void sendLobbyStatusPeerLeaving(const ChatLobbyId& lobby_id) ;
|
||||||
|
|
||||||
ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic, const std::set<RsPeerId>& invited_friends,ChatLobbyFlags flags) ;
|
ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic, const std::set<RsPeerId>& invited_friends,ChatLobbyFlags flags) ;
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ class DistributedChatService
|
||||||
bool sendLobbyChat(const ChatLobbyId &lobby_id, const std::string&) ;
|
bool sendLobbyChat(const ChatLobbyId &lobby_id, const std::string&) ;
|
||||||
bool handleRecvChatLobbyMsgItem(RsChatMsgItem *item) ;
|
bool handleRecvChatLobbyMsgItem(RsChatMsgItem *item) ;
|
||||||
|
|
||||||
bool checkSignature(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id) ;
|
bool checkSignature(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// make some statistics about time shifts, to prevent various issues.
|
/// make some statistics about time shifts, to prevent various issues.
|
||||||
|
@ -119,7 +120,6 @@ class DistributedChatService
|
||||||
bool bounceLobbyObject(RsChatLobbyBouncingObject *obj, const RsPeerId& peer_id) ;
|
bool bounceLobbyObject(RsChatLobbyBouncingObject *obj, const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
void sendLobbyStatusItem(const ChatLobbyId&, int type, const std::string& status_string) ;
|
void sendLobbyStatusItem(const ChatLobbyId&, int type, const std::string& status_string) ;
|
||||||
void sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id) ;
|
|
||||||
void sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id, const std::string& newnick) ;
|
void sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id, const std::string& newnick) ;
|
||||||
|
|
||||||
void sendLobbyStatusNewPeer(const ChatLobbyId& lobby_id) ;
|
void sendLobbyStatusNewPeer(const ChatLobbyId& lobby_id) ;
|
||||||
|
|
|
@ -833,6 +833,13 @@ virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||||
*/
|
*/
|
||||||
virtual void unsubscribeChatLobby(const ChatLobbyId &lobby_id) = 0;
|
virtual void unsubscribeChatLobby(const ChatLobbyId &lobby_id) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sendLobbyStatusPeerLeaving notify friend nodes that we're leaving a subscribed lobby
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] lobby_id lobby to leave
|
||||||
|
*/
|
||||||
|
virtual void sendLobbyStatusPeerLeaving(const ChatLobbyId& lobby_id) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief setIdentityForChatLobby set the chat identit
|
* @brief setIdentityForChatLobby set the chat identit
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
|
|
@ -453,6 +453,10 @@ void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const RsPeerId& peer
|
||||||
{
|
{
|
||||||
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
|
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
|
||||||
}
|
}
|
||||||
|
void p3Msgs::sendLobbyStatusPeerLeaving(const ChatLobbyId& lobby_id)
|
||||||
|
{
|
||||||
|
mChatSrv->sendLobbyStatusPeerLeaving(lobby_id) ;
|
||||||
|
}
|
||||||
void p3Msgs::unsubscribeChatLobby(const ChatLobbyId& lobby_id)
|
void p3Msgs::unsubscribeChatLobby(const ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
mChatSrv->unsubscribeChatLobby(lobby_id) ;
|
mChatSrv->unsubscribeChatLobby(lobby_id) ;
|
||||||
|
|
|
@ -147,6 +147,7 @@ class p3Msgs: public RsMsgs
|
||||||
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
|
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||||
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||||
virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
||||||
|
virtual void sendLobbyStatusPeerLeaving(const ChatLobbyId& lobby_id);
|
||||||
virtual bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId&) ;
|
virtual bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId&) ;
|
||||||
virtual bool getIdentityForChatLobby(const ChatLobbyId&,RsGxsId& nick) ;
|
virtual bool getIdentityForChatLobby(const ChatLobbyId&,RsGxsId& nick) ;
|
||||||
virtual bool setDefaultIdentityForChatLobby(const RsGxsId&) ;
|
virtual bool setDefaultIdentityForChatLobby(const RsGxsId&) ;
|
||||||
|
|
|
@ -608,21 +608,15 @@ void ChatLobbyWidget::updateDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the new model (after lobby save to disk) the auto-subscribe flag is used to automatically join lobbies that where
|
// In the new model (after lobby save to disk) the auto-subscribe flag is used to automatically join lobbies that where
|
||||||
// previously being used when the software quits.
|
// previously being used when the t software quits.
|
||||||
|
|
||||||
bool autoSubscribe = rsMsgs->getLobbyAutoSubscribe(lobby.lobby_id);
|
bool autoSubscribe = rsMsgs->getLobbyAutoSubscribe(lobby.lobby_id);
|
||||||
|
|
||||||
if (autoSubscribe && !subscribed)
|
if (autoSubscribe && subscribed && _lobby_infos.find(lobby.lobby_id) == _lobby_infos.end())
|
||||||
{
|
{
|
||||||
if(_lobby_infos.find(lobby.lobby_id) == _lobby_infos.end())
|
ChatDialog *cd = ChatDialog::getChat(ChatId(lobby.lobby_id), RS_CHAT_OPEN);
|
||||||
{
|
|
||||||
if (item == ui.lobbyTreeWidget->currentItem())
|
addChatPage(dynamic_cast<ChatLobbyDialog*>(cd));
|
||||||
{
|
|
||||||
ChatDialog::chatFriend(ChatId(lobby.lobby_id)) ;
|
|
||||||
}else{
|
|
||||||
ChatDialog::chatFriend(ChatId(lobby.lobby_id),false) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.total_number_of_peers, subscribed, autoSubscribe,lobby_flags);
|
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.total_number_of_peers, subscribed, autoSubscribe,lobby_flags);
|
||||||
|
@ -689,7 +683,7 @@ void ChatLobbyWidget::updateDisplay()
|
||||||
if(it == _lobby_infos.end() && rsMsgs->joinVisibleChatLobby(lobby.lobby_id,lobby.gxs_id))
|
if(it == _lobby_infos.end() && rsMsgs->joinVisibleChatLobby(lobby.lobby_id,lobby.gxs_id))
|
||||||
{
|
{
|
||||||
std::cerr << "Adding back ChatLobbyDialog for subscribed lobby " << std::hex << lobby.lobby_id << std::dec << std::endl;
|
std::cerr << "Adding back ChatLobbyDialog for subscribed lobby " << std::hex << lobby.lobby_id << std::dec << std::endl;
|
||||||
ChatDialog::chatFriend(ChatId(lobby.lobby_id),false) ;
|
ChatDialog::chatFriend(ChatId(lobby.lobby_id),true) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
publicSubLobbyItem->setHidden(publicSubLobbyItem->childCount()==0);
|
publicSubLobbyItem->setHidden(publicSubLobbyItem->childCount()==0);
|
||||||
|
|
|
@ -424,9 +424,8 @@ ChatLobbyDialog::~ChatLobbyDialog()
|
||||||
// announce leaving of lobby
|
// announce leaving of lobby
|
||||||
|
|
||||||
// check that the lobby still exists.
|
// check that the lobby still exists.
|
||||||
if (mChatId.isLobbyId()) {
|
if (mChatId.isLobbyId())
|
||||||
rsMsgs->unsubscribeChatLobby(mChatId.toLobbyId());
|
rsMsgs->sendLobbyStatusPeerLeaving(mChatId.toLobbyId());
|
||||||
}
|
|
||||||
|
|
||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue