patch "Fix_ChatLobbyAutoSubscribe_6951.diff" from Phenom. Fixes request for existing lobbies when no lobby ihas been found yet. Code beautification

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6971 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-12-27 20:21:44 +00:00
parent 5c52890ad5
commit ee4985c935
2 changed files with 22 additions and 16 deletions

View File

@ -63,7 +63,7 @@ static const time_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactiv
static const time_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs.
static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work
static const time_t DISTANT_CHAT_CLEANING_PERIOD = 60 ; // don't ask for lobby list more than once every 30 secs.
static const time_t DISTANT_CHAT_CLEANING_PERIOD = 60 ; // clean distant chat caches every 60 secs (remove old invites)
static const time_t DISTANT_CHAT_KEEP_ALIVE_PERIOD = 10 ; // sens keep alive distant chat packets every 10 secs.
static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ; // size of AES encryption key for distant chat.
static const uint32_t DISTANT_CHAT_HASH_SIZE = 20 ; // This is sha1 size in bytes.
@ -125,8 +125,12 @@ int p3ChatService::tick()
std::vector<VisibleChatLobbyRecord> visible_lobbies_tmp ;
getListOfNearbyChatLobbies(visible_lobbies_tmp) ;
if (visible_lobbies_tmp.size()==0){
last_req_chat_lobby_list = now-LOBBY_LIST_AUTO_UPDATE_TIME+MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ;
} else {
last_req_chat_lobby_list = now ;
}
}
// Flush items that could not be sent, probably because of a Mutex protected zone.
//
@ -435,11 +439,11 @@ void p3ChatService::locked_printDebugInfo() const
std::cerr << " \"" << std::hex << it->first << "\" flags = " << it->second << std::dec << std::endl;
}
bool p3ChatService::isLobbyId(const std::string& id,ChatLobbyId& lobby_id)
bool p3ChatService::isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id)
{
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(id)) ;
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(virtual_peer_id)) ;
if(it != _lobby_ids.end())
{
@ -2017,10 +2021,10 @@ bool p3ChatService::loadList(std::list<RsItem*>& load)
_default_nick_name = kit->value ;
}
RsChatLobbyConfigItem *cas = NULL ;
RsChatLobbyConfigItem *clci = NULL ;
if(NULL != (cas = dynamic_cast<RsChatLobbyConfigItem*>(*it)))
_known_lobbies_flags[cas->lobby_Id] = ChatLobbyFlags(cas->flags) ;
if(NULL != (clci = dynamic_cast<RsChatLobbyConfigItem*>(*it)))
_known_lobbies_flags[clci->lobby_Id] = ChatLobbyFlags(clci->flags) ;
// delete unknown items
delete *it;
@ -2088,6 +2092,8 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
list.push_back(ei) ;
}
/* Save Default Nick Name */
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
RsTlvKeyValue kv;
kv.key = "DEFAULT_NICK_NAME" ;
@ -2099,11 +2105,11 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
/* Save Lobby Auto Subscribe */
for(std::map<ChatLobbyId,ChatLobbyFlags>::const_iterator it=_known_lobbies_flags.begin();it!=_known_lobbies_flags.end();++it)
{
RsChatLobbyConfigItem *cas = new RsChatLobbyConfigItem ;
cas->lobby_Id=it->first;
cas->flags=it->second.toUInt32();
RsChatLobbyConfigItem *clci = new RsChatLobbyConfigItem ;
clci->lobby_Id=it->first;
clci->flags=it->second.toUInt32();
list.push_back(cas) ;
list.push_back(clci) ;
}
@ -2515,16 +2521,16 @@ uint64_t p3ChatService::makeConnexionChallengeCode(const std::string& peer_id,Ch
return result ;
}
void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& cl_infos)
{
// fill up a dummy list for now.
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
linfos.clear() ;
cl_infos.clear() ;
for(std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end();++it)
linfos.push_back(it->second) ;
cl_infos.push_back(it->second) ;
}
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id,bool connexion_challenge)
{

View File

@ -163,9 +163,9 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
*/
bool clearPrivateChatQueue(bool incoming, const std::string &id);
bool getVirtualPeerId(const ChatLobbyId&, std::string& virtual_peer_id) ;
bool isLobbyId(const std::string&, ChatLobbyId&) ;
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
bool getVirtualPeerId(const ChatLobbyId& lobby_id, std::string& virtual_peer_id) ;
bool isLobbyId(const std::string& virtual_peer_id, ChatLobbyId& lobby_id) ;
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >& cl_infos) ;
bool acceptLobbyInvite(const ChatLobbyId& id) ;
void denyLobbyInvite(const ChatLobbyId& id) ;
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;