fixed a few GUI bugs, fixed signature checking, removed message splitting, added identities to create/join methods

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-LobbiesWithGXSIds@7981 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-03-04 22:42:57 +00:00
parent e337c0e09f
commit aad84cd54d
10 changed files with 95 additions and 175 deletions

View File

@ -354,124 +354,27 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec
// This function should be used for all types of chat messages. But this requires a non backward compatible change in // This function should be used for all types of chat messages. But this requires a non backward compatible change in
// chat protocol. To be done for version 0.6 // chat protocol. To be done for version 0.6
// //
void DistributedChatService::checkSizeAndSendLobbyMessage(RsChatLobbyMsgItem *msg) void DistributedChatService::checkSizeAndSendLobbyMessage(RsChatItem *msg)
{ {
// We check the message item, and possibly split it into multiple messages, if the message is too big. // Multiple-parts messaging has been disabled in lobbies, because of the following issues:
// 1 - it breaks signatures because the subid of each sub-item is changed (can be fixed)
// 2 - it breaks (can be fixed as well)
// 3 - it is unreliable since items are not guarrantied to all arrive in the end (cannot be fixed)
// 4 - large objects can be used to corrupt end peers (cannot be fixed)
//
static const uint32_t MAX_ITEM_SIZE = 32000 ;
static const uint32_t MAX_STRING_SIZE = 15000 ; if(msg->serial_size() > MAX_ITEM_SIZE)
int n=0 ;
while(msg->message.size() > MAX_STRING_SIZE)
{ {
// chop off the first 15000 wchars std::cerr << "(EE) Chat item exceeds maximum serial size. It will be dropped." << std::endl;
delete msg ;
RsChatLobbyMsgItem *item = new RsChatLobbyMsgItem(*msg) ;
item->message = item->message.substr(0,MAX_STRING_SIZE) ;
msg->message = msg->message.substr(MAX_STRING_SIZE,msg->message.size()-MAX_STRING_SIZE) ;
// Clear out any one time flags that should not be copied into multiple objects. This is
// a precaution, in case the receivign peer does not yet handle split messages transparently.
//
item->chatFlags &= (RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_PUBLIC | RS_CHAT_FLAG_LOBBY) ;
// Indicate that the message is to be continued.
//
item->chatFlags |= RS_CHAT_FLAG_PARTIAL_MESSAGE ;
item->subpacket_id = n++ ;
sendChatItem(item) ;
} }
msg->subpacket_id = n ;
sendChatItem(msg) ; sendChatItem(msg) ;
} }
bool DistributedChatService::locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *ci) bool DistributedChatService::locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *ci)
{ {
if(ci == NULL) // null item, should be treated normally. return true ;
return true ;
// Check is the item is ending an incomplete item.
//
std::map<ChatLobbyMsgId,std::vector<RsChatLobbyMsgItem*> >::iterator it = _pendingPartialLobbyMessages.find(ci->msg_id) ;
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Checking chat message for completeness:" << std::endl;
#endif
bool ci_is_incomplete = ci->chatFlags & RS_CHAT_FLAG_PARTIAL_MESSAGE ;
if(it != _pendingPartialLobbyMessages.end())
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Pending message found. Appending it." << std::endl;
#endif
// Yes, there is. Add the item to the list of stored sub-items
if(ci->subpacket_id >= it->second.size() )
it->second.resize(ci->subpacket_id+1,NULL) ;
it->second[ci->subpacket_id] = ci ;
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Checking for completeness." << std::endl;
#endif
// Now check wether we have a complete item or not.
//
bool complete = true ;
for(uint32_t i=0;i<it->second.size() && complete;++i)
complete = complete && (it->second[i] != NULL) ;
complete = complete && !(it->second.back()->chatFlags & RS_CHAT_FLAG_PARTIAL_MESSAGE) ;
if(complete)
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Message is complete ! Re-forming it and returning true." << std::endl;
#endif
std::string msg ;
uint32_t flags = 0 ;
for(uint32_t i=0;i<it->second.size();++i)
{
msg += it->second[i]->message ;
flags |= it->second[i]->chatFlags ;
if(i != ci->subpacket_id) // don't delete ci itself !!
delete it->second[i] ;
}
_pendingPartialLobbyMessages.erase(it) ;
ci->chatFlags = flags ;
ci->message = msg ;
ci->chatFlags &= ~RS_CHAT_FLAG_PARTIAL_MESSAGE ; // remove partial flag form message.
return true ;
}
else
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Not complete: returning" << std::endl ;
#endif
return false ;
}
}
else if(ci_is_incomplete || ci->subpacket_id > 0) // the message id might not yet be recorded
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Message is partial, but not recorded. Adding it. " << std::endl;
#endif
_pendingPartialLobbyMessages[ci->msg_id].resize(ci->subpacket_id+1,NULL) ;
_pendingPartialLobbyMessages[ci->msg_id][ci->subpacket_id] = ci ;
return false ;
}
else
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Message is not partial. Returning it as is." << std::endl;
#endif
return true ;
}
} }
bool DistributedChatService::handleRecvItem(RsChatItem *item) bool DistributedChatService::handleRecvItem(RsChatItem *item)
@ -880,10 +783,7 @@ bool DistributedChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,c
item2->PeerId(*it) ; // replaces the virtual peer id with the actual destination. item2->PeerId(*it) ; // replaces the virtual peer id with the actual destination.
if(is_message) checkSizeAndSendLobbyMessage(item2) ;
checkSizeAndSendLobbyMessage(static_cast<RsChatLobbyMsgItem*>(item2)) ;
else
sendChatItem(item2);
} }
++lobby.connexion_challenge_count ; ++lobby.connexion_challenge_count ;
@ -992,8 +892,7 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
int i ; int i ;
for(i=0;i<6;++i) for(i=0;i<6;++i)
if(!mIdService->getPrivateKey(lobby.gxs_id,signature_private_key) if(!mIdService->getPrivateKey(lobby.gxs_id,signature_private_key) || signature_private_key.keyData.bin_data == NULL)
|| signature_private_key.keyData.bin_data == NULL)
{ {
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl; std::cerr << " Cannot get key. Waiting for caching. try " << i << "/6" << std::endl;
@ -1010,18 +909,20 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
return false ; return false ;
} }
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Signing item." << std::endl; std::cerr << "Signing item." << std::endl;
std::cerr << " data hash: " << RsDirUtil::sha1sum(memory,item.signed_serial_size()) << std::endl; std::cerr << " data hash: " << RsDirUtil::sha1sum(memory,item.signed_serial_size()) << std::endl;
std::cerr << " signed data: " << RsUtil::BinToHex((char*)memory,item.signed_serial_size()) << std::endl; std::cerr << " signed data: " << RsUtil::BinToHex((char*)memory,item.signed_serial_size()) << std::endl;
#endif
if(!GxsSecurity::getSignature((const char *)memory,item.signed_serial_size(),signature_private_key,item.signature)) if(!GxsSecurity::getSignature((const char *)memory,item.signed_serial_size(),signature_private_key,item.signature))
{ {
std::cerr << "(EE) Cannot sign message item. " << std::endl; std::cerr << "(EE) Cannot sign message item. " << std::endl;
return false ; return false ;
} }
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " signature done." << std::endl; std::cerr << " signature done." << std::endl;
#ifdef DEBUG_CHAT_LOBBIES
// check signature // check signature
RsTlvSecurityKey public_key ; RsTlvSecurityKey public_key ;
GxsSecurity::extractPublicKey(signature_private_key,public_key) ; GxsSecurity::extractPublicKey(signature_private_key,public_key) ;
@ -1059,6 +960,7 @@ bool DistributedChatService::sendLobbyChat(const ChatLobbyId& lobby_id, const st
item.sendTime = time(NULL); item.sendTime = time(NULL);
item.recvTime = item.sendTime; item.recvTime = item.sendTime;
item.message = msg; item.message = msg;
item.parent_msg_id = 0;
// gives a random msg id, setup the nickname, and signs the item. // gives a random msg id, setup the nickname, and signs the item.
@ -1066,7 +968,7 @@ bool DistributedChatService::sendLobbyChat(const ChatLobbyId& lobby_id, const st
return false; return false;
} }
RsPeerId ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
bounceLobbyObject(&item, ownId) ; bounceLobbyObject(&item, ownId) ;
@ -1337,9 +1239,9 @@ void DistributedChatService::getPendingChatLobbyInvites(std::list<ChatLobbyInvit
} }
bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id) bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const RsGxsId& identity)
{ {
{ {
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
@ -1360,6 +1262,16 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
return true ; return true ;
} }
RsIdentityDetails details ;
// This is our own identity. We force the loading from the cache.
for(int i=0;i<6;++i)
if(mIdService->getIdDetails(identity,details))
break ;
else
usleep(500*1000) ;
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << " Creating new Lobby entry." << std::endl; std::cerr << " Creating new Lobby entry." << std::endl;
#endif #endif
@ -1368,7 +1280,7 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
ChatLobbyEntry entry ; ChatLobbyEntry entry ;
entry.participating_friends.insert(it->second.peer_id) ; entry.participating_friends.insert(it->second.peer_id) ;
entry.lobby_flags = it->second.lobby_flags ; entry.lobby_flags = it->second.lobby_flags ;
entry.gxs_id = _default_identity ; entry.gxs_id = identity ;
entry.lobby_id = lobby_id ; entry.lobby_id = lobby_id ;
entry.lobby_name = it->second.lobby_name ; entry.lobby_name = it->second.lobby_name ;
entry.lobby_topic = it->second.lobby_topic ; entry.lobby_topic = it->second.lobby_topic ;
@ -1391,7 +1303,8 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
RsChatLobbyMsgItem *item = new RsChatLobbyMsgItem; RsChatLobbyMsgItem *item = new RsChatLobbyMsgItem;
item->lobby_id = entry.lobby_id ; item->lobby_id = entry.lobby_id ;
item->msg_id = 0 ; item->msg_id = 0 ;
item->nick = "Lobby management" ; item->parent_msg_id = 0 ;
item->nick = "Lobby management" ;
item->message = std::string("Welcome to chat lobby") ; item->message = std::string("Welcome to chat lobby") ;
item->PeerId(entry.virtual_peer_id) ; item->PeerId(entry.virtual_peer_id) ;
item->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ; item->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ;
@ -1443,7 +1356,15 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co
{ {
RsIdentityDetails details ; RsIdentityDetails details ;
if(gxs_id.isNull() || !mIdService->getIdDetails(gxs_id,details) || !details.mIsOwnId) // This is our own identity. We force the loading from the cache.
for(int i=0;i<6;++i)
if(mIdService->getIdDetails(gxs_id,details))
break ;
else
usleep(500*1000) ;
if(gxs_id.isNull() || !details.mIsOwnId)
{ {
std::cerr << "(EE) Cannot lobby using gxs id " << gxs_id << std::endl; std::cerr << "(EE) Cannot lobby using gxs id " << gxs_id << std::endl;
return false ; return false ;
@ -1516,7 +1437,7 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co
return true ; return true ;
} }
ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags lobby_flags) ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags lobby_flags)
{ {
#ifdef DEBUG_CHAT_LOBBIES #ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Creating a new Chat lobby !!" << std::endl; std::cerr << "Creating a new Chat lobby !!" << std::endl;
@ -1537,7 +1458,7 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam
ChatLobbyEntry entry ; ChatLobbyEntry entry ;
entry.lobby_flags = lobby_flags ; entry.lobby_flags = lobby_flags ;
entry.participating_friends.clear() ; entry.participating_friends.clear() ;
entry.gxs_id = _default_identity ; // to be changed. For debug only!! entry.gxs_id = lobby_identity ; // to be changed. For debug only!!
entry.lobby_id = lobby_id ; entry.lobby_id = lobby_id ;
entry.lobby_name = lobby_name ; entry.lobby_name = lobby_name ;
entry.lobby_topic = lobby_topic ; entry.lobby_topic = lobby_topic ;

View File

@ -62,7 +62,7 @@ class DistributedChatService
bool isLobbyId(const RsPeerId& virtual_peer_id, ChatLobbyId& lobby_id) ; bool isLobbyId(const RsPeerId& virtual_peer_id, ChatLobbyId& lobby_id) ;
void getChatLobbyList(std::list<ChatLobbyId>& clids) ; void getChatLobbyList(std::list<ChatLobbyId>& clids) ;
bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& clinfo) ; bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& clinfo) ;
bool acceptLobbyInvite(const ChatLobbyId& id) ; bool acceptLobbyInvite(const ChatLobbyId& id,const RsGxsId& identity) ;
void denyLobbyInvite(const ChatLobbyId& id) ; void denyLobbyInvite(const ChatLobbyId& id) ;
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ; void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
void invitePeerToLobby(const ChatLobbyId&, const RsPeerId& peer_id,bool connexion_challenge = false) ; void invitePeerToLobby(const ChatLobbyId&, const RsPeerId& peer_id,bool connexion_challenge = false) ;
@ -75,7 +75,7 @@ class DistributedChatService
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) ;
ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic, const std::list<RsPeerId>& invited_friends,ChatLobbyFlags flags) ; ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic, const std::list<RsPeerId>& invited_friends,ChatLobbyFlags flags) ;
void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ; void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
bool joinVisibleChatLobby(const ChatLobbyId& id, const RsGxsId &gxs_id) ; bool joinVisibleChatLobby(const ChatLobbyId& id, const RsGxsId &gxs_id) ;
@ -91,7 +91,7 @@ class DistributedChatService
bool processLoadListItem(const RsItem *item) ; bool processLoadListItem(const RsItem *item) ;
bool locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *) ; bool locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *) ;
void checkSizeAndSendLobbyMessage(RsChatLobbyMsgItem *) ; void checkSizeAndSendLobbyMessage(RsChatItem *) ;
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) ;

View File

@ -363,7 +363,6 @@ uint32_t RsChatLobbyListItem::serial_size()
uint32_t RsChatLobbyMsgItem::serial_size() uint32_t RsChatLobbyMsgItem::serial_size()
{ {
uint32_t s = RsChatMsgItem::serial_size() ; // parent uint32_t s = RsChatMsgItem::serial_size() ; // parent
s += 1; // subpacket id
s += 8; // parent_msg_id s += 8; // parent_msg_id
s += RsChatLobbyBouncingObject::serialized_size(true) ; s += RsChatLobbyBouncingObject::serialized_size(true) ;
@ -372,7 +371,6 @@ uint32_t RsChatLobbyMsgItem::serial_size()
uint32_t RsChatLobbyMsgItem::signed_serial_size() uint32_t RsChatLobbyMsgItem::signed_serial_size()
{ {
uint32_t s = RsChatMsgItem::serial_size() ; // parent uint32_t s = RsChatMsgItem::serial_size() ; // parent
s += 1; // subpacket id
s += 8; // parent_msg_id s += 8; // parent_msg_id
s += RsChatLobbyBouncingObject::serialized_size(false) ; s += RsChatLobbyBouncingObject::serialized_size(false) ;
@ -572,7 +570,6 @@ bool RsChatLobbyMsgItem::serialise(void *data, uint32_t& pktsize)
ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize); // correct header! ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize); // correct header!
pktsize = tlvsize; pktsize = tlvsize;
ok &= setRawUInt8(data, tlvsize, &offset, subpacket_id);
ok &= setRawUInt64(data, tlvsize, &offset, parent_msg_id); ok &= setRawUInt64(data, tlvsize, &offset, parent_msg_id);
// The signature is at the end of the serialised data, so that the signed data is *before* the signature. // The signature is at the end of the serialised data, so that the signed data is *before* the signature.
@ -605,7 +602,7 @@ bool RsChatLobbyMsgItem::serialise_signed_part(void *data, uint32_t& pktsize)
ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize); // correct header! ok &= setRsItemHeader(data, tlvsize, PacketId(), tlvsize); // correct header!
pktsize = tlvsize; pktsize = tlvsize;
ok &= setRawUInt8(data, tlvsize, &offset, subpacket_id); //ok &= setRawUInt8(data, tlvsize, &offset, subpacket_id); // don't serialise sub-part id.
ok &= setRawUInt64(data, tlvsize, &offset, parent_msg_id); ok &= setRawUInt64(data, tlvsize, &offset, parent_msg_id);
// The signature is at the end of the serialised data, so that the signed data is *before* the signature. // The signature is at the end of the serialised data, so that the signed data is *before* the signature.
@ -1056,7 +1053,6 @@ RsChatLobbyMsgItem::RsChatLobbyMsgItem(void *data,uint32_t /*size*/)
uint32_t offset = RsChatMsgItem::serial_size() ; uint32_t offset = RsChatMsgItem::serial_size() ;
ok &= getRawUInt8(data, rssize, &offset, &subpacket_id);
ok &= getRawUInt64(data, rssize, &offset, &parent_msg_id); ok &= getRawUInt64(data, rssize, &offset, &parent_msg_id);
ok &= RsChatLobbyBouncingObject::deserialise_from_memory(data,rssize,offset) ; ok &= RsChatLobbyBouncingObject::deserialise_from_memory(data,rssize,offset) ;

View File

@ -169,7 +169,6 @@ public:
virtual uint32_t signed_serial_size() ; virtual uint32_t signed_serial_size() ;
virtual bool serialise_signed_part(void *data,uint32_t& size) ;// Isn't it better that items can serialize themselves ? virtual bool serialise_signed_part(void *data,uint32_t& size) ;// Isn't it better that items can serialize themselves ?
uint8_t subpacket_id ; // this is for proper handling of split packets.
ChatLobbyMsgId parent_msg_id ; // Used for threaded chat. ChatLobbyMsgId parent_msg_id ; // Used for threaded chat.
}; };

View File

@ -454,7 +454,7 @@ virtual void getChatLobbyList(std::list<ChatLobbyId>& cl_list) = 0;
virtual bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& info) = 0 ; virtual bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& info) = 0 ;
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) = 0 ; virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) = 0 ;
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const RsPeerId& peer_id) = 0; virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const RsPeerId& peer_id) = 0;
virtual bool acceptLobbyInvite(const ChatLobbyId& id) = 0 ; virtual bool acceptLobbyInvite(const ChatLobbyId& id,const RsGxsId& identity) = 0 ;
virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ; virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ;
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0; virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0;
virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0; virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0;
@ -464,7 +464,7 @@ virtual bool setDefaultIdentityForChatLobby(const RsGxsId& nick) = 0;
virtual bool getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ; virtual bool getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ;
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ; virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ;
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ; virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ;
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ; virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ;
/****************************************/ /****************************************/
/* Distant chat */ /* Distant chat */

View File

@ -493,9 +493,9 @@ void p3Msgs::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& pub
mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ; mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ;
} }
ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags privacy_type) ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags privacy_type)
{ {
return mChatSrv->createChatLobby(lobby_name,lobby_topic,invited_friends,privacy_type) ; return mChatSrv->createChatLobby(lobby_name,lobby_identity,lobby_topic,invited_friends,privacy_type) ;
} }
void p3Msgs::setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) void p3Msgs::setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe)
@ -509,9 +509,9 @@ bool p3Msgs::getLobbyAutoSubscribe(const ChatLobbyId& lobby_id)
} }
bool p3Msgs::acceptLobbyInvite(const ChatLobbyId& id) bool p3Msgs::acceptLobbyInvite(const ChatLobbyId& id,const RsGxsId& gxs_id)
{ {
return mChatSrv->acceptLobbyInvite(id) ; return mChatSrv->acceptLobbyInvite(id,gxs_id) ;
} }
void p3Msgs::denyLobbyInvite(const ChatLobbyId& id) void p3Msgs::denyLobbyInvite(const ChatLobbyId& id)
{ {

View File

@ -143,7 +143,7 @@ class p3Msgs: public RsMsgs
virtual void getChatLobbyList(std::list<ChatLobbyId>& cl_list) ; virtual void getChatLobbyList(std::list<ChatLobbyId>& cl_list) ;
virtual bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& info) ; virtual bool getChatLobbyInfo(const ChatLobbyId& id,ChatLobbyInfo& info) ;
virtual void invitePeerToLobby(const ChatLobbyId&, const RsPeerId&) ; virtual void invitePeerToLobby(const ChatLobbyId&, const RsPeerId&) ;
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ; virtual bool acceptLobbyInvite(const ChatLobbyId& id, const RsGxsId &gxs_id) ;
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) ;
@ -153,7 +153,7 @@ class p3Msgs: public RsMsgs
virtual bool getDefaultIdentityForChatLobby(RsGxsId& nick) ; virtual bool getDefaultIdentityForChatLobby(RsGxsId& nick) ;
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe); virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id); virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags privacy_type) ; virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,ChatLobbyFlags privacy_type) ;
virtual bool initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id,uint32_t& error_code) ; virtual bool initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id,uint32_t& error_code) ;
virtual bool getDistantChatStatus(const RsGxsId& gxs_id,uint32_t& status, RsGxsId *from_gxs_id=NULL) ; virtual bool getDistantChatStatus(const RsGxsId& gxs_id,uint32_t& status, RsGxsId *from_gxs_id=NULL) ;

View File

@ -837,22 +837,28 @@ void ChatLobbyWidget::readChatLobbyInvites()
std::list<ChatLobbyInvite> invites; std::list<ChatLobbyInvite> invites;
rsMsgs->getPendingChatLobbyInvites(invites); rsMsgs->getPendingChatLobbyInvites(invites);
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it) { for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
if (QMessageBox::Ok == QMessageBox::question(this, tr("Invitation to chat lobby"), tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(RsHtml::plainText(it->lobby_name)), QMessageBox::Ok, QMessageBox::Ignore)) { {
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl; #warning We need here a QDialog that also asks for the identity to use.
#ifdef REMOVED_CODE
QDialog dialog ;
rsMsgs->acceptLobbyInvite((*it).lobby_id); if (QMessageBox::Ok == QMessageBox::question(this, tr("Invitation to chat lobby"), tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(RsHtml::plainText(it->lobby_name)), QMessageBox::Ok, QMessageBox::Ignore)) {
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
rsMsgs->acceptLobbyInvite((*it).lobby_id);
RsPeerId vpid; RsPeerId vpid;
if(rsMsgs->getVirtualPeerId((*it).lobby_id,vpid )) { if(rsMsgs->getVirtualPeerId((*it).lobby_id,vpid )) {
ChatDialog::chatFriend(ChatId((*it).lobby_id),true); ChatDialog::chatFriend(ChatId((*it).lobby_id),true);
} else { } else {
std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl; std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl;
} }
} else { } else {
rsMsgs->denyLobbyInvite((*it).lobby_id); rsMsgs->denyLobbyInvite((*it).lobby_id);
} }
} #endif
}
} }
void ChatLobbyWidget::filterColumnChanged(int) void ChatLobbyWidget::filterColumnChanged(int)

View File

@ -626,7 +626,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
qsParticipant=gxs_id; qsParticipant=gxs_id;
ui.chatWidget->updateStatusString(RsHtml::plainText(name) + " %1", RsHtml::plainText(name)); ui.chatWidget->updateStatusString(RsHtml::plainText(name) + " %1", RsHtml::plainText(str));
if (!isParticipantMuted(gxs_id)) if (!isParticipantMuted(gxs_id))
emit typingEventReceived(id()) ; emit typingEventReceived(id()) ;

View File

@ -112,25 +112,14 @@ void CreateLobbyDialog::createLobby()
std::list<RsPeerId> shareList; std::list<RsPeerId> shareList;
ui->keyShareList->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(shareList, false); ui->keyShareList->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(shareList, false);
// if (shareList.empty()) { // if (shareList.empty()) {
// QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend"), QMessageBox::Ok, QMessageBox::Ok); // QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend"), QMessageBox::Ok, QMessageBox::Ok);
// return; // return;
// } // }
// create chat lobby !! // create chat lobby !!
std::string lobby_name = ui->lobbyName_LE->text().toUtf8().constData() ; std::string lobby_name = ui->lobbyName_LE->text().toUtf8().constData() ;
std::string lobby_topic = ui->lobbyTopic_LE->text().toUtf8().constData() ; std::string lobby_topic = ui->lobbyTopic_LE->text().toUtf8().constData() ;
// add to group
ChatLobbyFlags lobby_flags ;
if(ui->security_CB->currentIndex() == 0)
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PUBLIC ;
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, lobby_topic, shareList, lobby_flags);
std::cerr << "gui: Created chat lobby " << std::hex << id << std::endl ;
// set nick name ! // set nick name !
RsGxsId gxs_id ; RsGxsId gxs_id ;
@ -140,10 +129,19 @@ void CreateLobbyDialog::createLobby()
case GxsIdChooser::None: case GxsIdChooser::None:
return ; return ;
} }
rsMsgs->setIdentityForChatLobby(id,gxs_id) ; // add to group
// open chat window !! ChatLobbyFlags lobby_flags ;
if(ui->security_CB->currentIndex() == 0)
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PUBLIC ;
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name,gxs_id, lobby_topic, shareList, lobby_flags);
std::cerr << "gui: Created chat lobby " << std::hex << id << std::endl ;
// open chat window !!
ChatDialog::chatFriend(ChatId(id)) ; ChatDialog::chatFriend(ChatId(id)) ;
close(); close();
} }