added method to get list of existing private chat links

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6306 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-04-14 15:05:24 +00:00
parent e7871b598b
commit 5a889eb1cd
7 changed files with 56 additions and 3 deletions

View file

@ -195,6 +195,14 @@ class ChatLobbyInfo
time_t last_activity ; // last recorded activity. Useful for removing dead lobbies.
};
struct DistantChatInviteInfo
{
std::string hash ; // hash to contact the invite and refer to it.
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
std::string destination_pgp_id ; // pgp is of the destination of the chat link
time_t time_of_validity ; // time when te invite becomes unusable
};
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
@ -292,6 +300,8 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
/****************************************/
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
};

View file

@ -334,5 +334,8 @@ bool p3Msgs::createDistantChatInvite(const std::string& pgp_id,time_t time_of_va
{
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
}
bool p3Msgs::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites)
{
return mChatSrv->getDistantChatInviteList(invites) ;
}

View file

@ -184,6 +184,7 @@ class p3Msgs: public RsMsgs
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_type) ;
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
private:

View file

@ -3003,6 +3003,7 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
std::cerr << "Encrypted data size: " << encrypted_size << std::endl;
Radix64::encode((const char *)encrypted_data,encrypted_size,invite.encrypted_radix64_string) ;
invite.destination_pgp_id = pgp_id ;
{
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
@ -3039,6 +3040,24 @@ void p3ChatService::cleanDistantChatInvites()
}
}
bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites)
{
invites.clear() ;
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
for(std::map<std::string,DistantChatInvite>::const_iterator it(_distant_chat_invites.begin());it!=_distant_chat_invites.end();++it)
{
DistantChatInviteInfo info ;
info.hash = it->first ;
info.encrypted_radix64_string = it->second.encrypted_radix64_string ;
info.time_of_validity = it->second.time_of_validity ;
info.destination_pgp_id = it->second.destination_pgp_id ;
invites.push_back(info);
}
return true ;
}

View file

@ -311,11 +311,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
//
bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
private:
struct DistantChatInvite
{
unsigned char aes_key[16] ;
std::string encrypted_radix64_string ;
std::string destination_pgp_id ;
time_t time_of_validity ;
time_t time_of_creation ;
time_t last_hit_time ;