mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
added selection of which identity we talk as when multiple GXS identities are available
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7691 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5b3872a041
commit
06065ef623
@ -501,8 +501,6 @@ void DistantChatService::handleRecvDHPublicKey(RsChatDHPublicKeyItem *item)
|
||||
|
||||
// Looks for the DH params. If not there yet, create them.
|
||||
//
|
||||
bool should_send = false ;
|
||||
|
||||
int size = DH_size(it->second.dh) ;
|
||||
unsigned char *key_buff = new unsigned char[size] ;
|
||||
|
||||
@ -777,31 +775,39 @@ void DistantChatService::sendTurtleData(RsChatItem *item)
|
||||
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
||||
}
|
||||
|
||||
bool DistantChatService::initiateDistantChatConnexion(const RsGxsId& gxs_id,uint32_t& error_code)
|
||||
bool DistantChatService::initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id,uint32_t& error_code)
|
||||
{
|
||||
TurtleFileHash hash = hashFromGxsId(gxs_id) ;
|
||||
TurtleFileHash hash = hashFromGxsId(to_gxs_id) ;
|
||||
|
||||
// should be a parameter.
|
||||
|
||||
std::list<RsGxsId> lst ;
|
||||
std::list<RsGxsId> lst ;
|
||||
mIdService->getOwnIds(lst) ;
|
||||
|
||||
if(lst.empty())
|
||||
{
|
||||
std::cerr << " (EE) Cannot start distant chat, since no GXS id is available." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
RsGxsId own_gxs_id = lst.front() ;
|
||||
bool found = false ;
|
||||
for(std::list<RsGxsId>::const_iterator it = lst.begin();it!=lst.end();++it)
|
||||
if(*it == from_gxs_id)
|
||||
{
|
||||
found=true;
|
||||
break ;
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
std::cerr << " (EE) Cannot start distant chat, since GXS id " << from_gxs_id << " is not available." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
RsGxsId own_gxs_id = from_gxs_id ;
|
||||
|
||||
//
|
||||
startClientDistantChatConnection(hash,gxs_id,own_gxs_id) ;
|
||||
startClientDistantChatConnection(hash,to_gxs_id,own_gxs_id) ;
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
|
||||
// spawn a status item so as to open the chat window.
|
||||
RsChatMsgItem *item = new RsChatMsgItem;
|
||||
item->message = "Starting distant chat. Please wait for secure tunnel to be established." ;
|
||||
item->message = "[Starting distant chat. Please wait for secure tunnel to be established.]" ;
|
||||
item->chatFlags = RS_CHAT_FLAG_PRIVATE ;
|
||||
item->PeerId(RsPeerId(gxs_id)) ;
|
||||
item->PeerId(RsPeerId(to_gxs_id)) ;
|
||||
handleRecvChatMsgItem(item) ;
|
||||
|
||||
return true ;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
// Creates the invite if the public key of the distant peer is available.
|
||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||
//
|
||||
bool initiateDistantChatConnexion(const RsGxsId& gxs_id,uint32_t& error_code) ;
|
||||
bool initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId &from_gxs_id, uint32_t &error_code) ;
|
||||
bool closeDistantChatConnexion(const RsGxsId& pid) ;
|
||||
virtual bool getDistantChatStatus(const RsGxsId &gxs_id,uint32_t &status) ;
|
||||
|
||||
|
@ -425,7 +425,7 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
|
||||
/* Distant chat */
|
||||
/****************************************/
|
||||
|
||||
virtual bool initiateDistantChatConnexion(const RsGxsId& pid,uint32_t& error_code) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const RsGxsId& to_pid,const RsGxsId& from_pid,uint32_t& error_code) = 0;
|
||||
virtual bool getDistantChatStatus(const RsGxsId& gxs_id,uint32_t& status) = 0;
|
||||
virtual bool closeDistantChatConnexion(const RsGxsId& pid) = 0;
|
||||
|
||||
|
@ -364,9 +364,9 @@ void p3Msgs::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
|
||||
{
|
||||
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
||||
}
|
||||
bool p3Msgs::initiateDistantChatConnexion(const RsGxsId& gxs_id,uint32_t& error_code)
|
||||
bool p3Msgs::initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id,uint32_t& error_code)
|
||||
{
|
||||
return mChatSrv->initiateDistantChatConnexion(gxs_id,error_code) ;
|
||||
return mChatSrv->initiateDistantChatConnexion(to_gxs_id,from_gxs_id,error_code) ;
|
||||
}
|
||||
bool p3Msgs::getDistantChatStatus(const RsGxsId &gxs_id,uint32_t &status)
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ class p3Msgs: public RsMsgs
|
||||
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,uint32_t privacy_type) ;
|
||||
|
||||
virtual bool initiateDistantChatConnexion(const RsGxsId& 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) ;
|
||||
virtual bool closeDistantChatConnexion(const RsGxsId &pid) ;
|
||||
|
||||
|
@ -876,7 +876,7 @@ void IdDialog::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req
|
||||
|
||||
case IDDIALOG_IDDETAILS:
|
||||
insertIdDetails(req.mToken);
|
||||
break;
|
||||
break;
|
||||
|
||||
case IDDIALOG_REPLIST:
|
||||
insertRepList(req.mToken);
|
||||
@ -901,8 +901,31 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||
QMenu contextMnu( this );
|
||||
|
||||
contextMnu.addAction(ui.editIdentity);
|
||||
contextMnu.addAction(ui.removeIdentity);
|
||||
contextMnu.addAction(ui.chatIdentity);
|
||||
contextMnu.addAction(ui.removeIdentity);
|
||||
|
||||
std::list<RsGxsId> own_identities ;
|
||||
rsIdentity->getOwnIds(own_identities) ;
|
||||
|
||||
if(own_identities.size() == 1)
|
||||
{
|
||||
QAction * action = contextMnu.addAction(QIcon(),"Chat with this peer",this,SLOT(chatIdentity()));
|
||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMenu *mnu = contextMnu.addMenu("Chat with this peer as...") ;
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||
{
|
||||
RsIdentityDetails idd ;
|
||||
rsIdentity->getIdDetails(*it,idd) ;
|
||||
|
||||
QPixmap pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||
|
||||
QAction * action = mnu->addAction(QIcon(pixmap),QString::fromStdString(idd.mNickname) + " (" + QString::fromStdString((*it).toStdString())+ ")",this,SLOT(chatIdentity()));
|
||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
@ -917,12 +940,17 @@ void IdDialog::chatIdentity()
|
||||
return;
|
||||
}
|
||||
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
|
||||
uint32_t error_code ;
|
||||
QAction *action = qobject_cast<QAction *>(QObject::sender());
|
||||
if (!action)
|
||||
return ;
|
||||
|
||||
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), error_code))
|
||||
QMessageBox::information(NULL,"Distant cannot work","Distant chat refused with this peer. Reason: "+QString::number(error_code)) ;
|
||||
RsGxsId from_gxs_id(action->data().toString().toStdString());
|
||||
uint32_t error_code ;
|
||||
|
||||
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), from_gxs_id, error_code))
|
||||
QMessageBox::information(NULL,"Distant chat cannot work","Distant chat refused with this peer. Error code: "+QString::number(error_code)) ;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user