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. 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 MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &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 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) ; 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 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 createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
private: 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; std::cerr << "Encrypted data size: " << encrypted_size << std::endl;
Radix64::encode((const char *)encrypted_data,encrypted_size,invite.encrypted_radix64_string) ; Radix64::encode((const char *)encrypted_data,encrypted_size,invite.encrypted_radix64_string) ;
invite.destination_pgp_id = pgp_id ;
{ {
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/ 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 createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
private: private:
struct DistantChatInvite struct DistantChatInvite
{ {
unsigned char aes_key[16] ; unsigned char aes_key[16] ;
std::string encrypted_radix64_string ; std::string encrypted_radix64_string ;
std::string destination_pgp_id ;
time_t time_of_validity ; time_t time_of_validity ;
time_t time_of_creation ; time_t time_of_creation ;
time_t last_hit_time ; time_t last_hit_time ;

View File

@ -72,6 +72,24 @@ void CreateMsgLinkDialog::update()
_info_TB->setHtml(s) ; _info_TB->setHtml(s) ;
_gpg_selection->setHidden(true) ; _gpg_selection->setHidden(true) ;
} }
std::vector<DistantChatInviteInfo> invites ;
rsMsgs->getDistantChatInviteList(invites) ;
_existing_links_LW->clear() ;
for(uint32_t i=0;i<invites.size();++i)
{
RetroShareLink link ;
if(!link.createPrivateChatInvite(invites[i].time_of_validity,QString::fromStdString(invites[i].destination_pgp_id),QString::fromStdString(invites[i].encrypted_radix64_string)))
std::cerr << "Cannot create link." << std::endl;
QListWidgetItem *item = new QListWidgetItem(link.toString()) ;
_existing_links_LW->insertItem(0,item) ;
}
} }
time_t CreateMsgLinkDialog::computeValidityDuration() const time_t CreateMsgLinkDialog::computeValidityDuration() const
@ -124,7 +142,6 @@ void CreateMsgLinkDialog::createLink()
QMessageBox::critical(NULL,tr("Private chat invite creation failed"),tr("The creation of the chat invite failed")) ; QMessageBox::critical(NULL,tr("Private chat invite creation failed"),tr("The creation of the chat invite failed")) ;
else else
QMessageBox::information(NULL,tr("Private chat invite created"),tr("Your new chat invite has been copied to clipboard. You can now paste it as a Retroshare link.")) ; QMessageBox::information(NULL,tr("Private chat invite created"),tr("Your new chat invite has been copied to clipboard. You can now paste it as a Retroshare link.")) ;
} }
else else
{ {

View File

@ -17,7 +17,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QListView" name="_existing_links_LV"/> <widget class="QListWidget" name="_existing_links_LW"/>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">