mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 16:35:21 -04:00
fixed compilation, added missing methods for new distant chat
This commit is contained in:
parent
6ca49a2d98
commit
a29f15ae32
13 changed files with 124 additions and 46 deletions
|
@ -1014,8 +1014,9 @@ void IdDialog::chatIdentity()
|
|||
|
||||
RsGxsId from_gxs_id(action->data().toString().toStdString());
|
||||
uint32_t error_code ;
|
||||
DistantChatPeerId did ;
|
||||
|
||||
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), from_gxs_id, error_code))
|
||||
if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(keyId), from_gxs_id, did, error_code))
|
||||
QMessageBox::information(NULL, tr("Distant chat cannot work"), QString("%1 %2: %3").arg(tr("Distant chat refused with this person.")).arg(tr("Error code")).arg(error_code)) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ void ChatDialog::init(ChatId id, const QString &title)
|
|||
|
||||
/* see if it already exists */
|
||||
ChatDialog *cd = getExistingChat(id);
|
||||
DistantChatPeerInfo pinfo ;
|
||||
|
||||
if (cd == NULL) {
|
||||
|
||||
|
@ -104,11 +105,15 @@ void ChatDialog::init(ChatId id, const QString &title)
|
|||
ChatLobbyDialog* cld = new ChatLobbyDialog(id.toLobbyId());
|
||||
cld->init();
|
||||
cd = cld;
|
||||
} else if(id.isGxsTunnelId()) {
|
||||
PopupDistantChatDialog* pdcd = new PopupDistantChatDialog(id.toGxsTunnelId());
|
||||
pdcd->init() ;
|
||||
}
|
||||
else if(id.isPeerId() && rsMsgs->getDistantChatStatus(id.toPeerId(),pinfo))
|
||||
{
|
||||
PopupDistantChatDialog* pdcd = new PopupDistantChatDialog(id.toPeerId());
|
||||
pdcd->init(pinfo.peer_id, QString("This is a distant chat")) ;
|
||||
cd = pdcd;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RsPeerDetails sslDetails;
|
||||
if (rsPeers->getPeerDetails(id.toPeerId(), sslDetails)) {
|
||||
PopupChatDialog* pcd = new PopupChatDialog();
|
||||
|
|
|
@ -553,7 +553,7 @@ void ChatLobbyDialog::distantChatParticipant()
|
|||
rsMsgs->getIdentityForChatLobby(lobbyId, own_id);
|
||||
|
||||
uint32_t error_code ;
|
||||
RsGxsTunnelService::RsGxsTunnelId tunnel_id;
|
||||
DistantChatPeerId tunnel_id;
|
||||
|
||||
if(! rsMsgs->initiateDistantChatConnexion(gxs_id,own_id,tunnel_id,error_code))
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ PopupDistantChatDialog::~PopupDistantChatDialog()
|
|||
delete _update_timer ;
|
||||
}
|
||||
|
||||
PopupDistantChatDialog::PopupDistantChatDialog(const RsGxsTunnelService::RsGxsTunnelId& tunnel_id,QWidget *parent, Qt::WindowFlags flags)
|
||||
PopupDistantChatDialog::PopupDistantChatDialog(const DistantChatPeerId& tunnel_id,QWidget *parent, Qt::WindowFlags flags)
|
||||
: PopupChatDialog(parent,flags)
|
||||
{
|
||||
_tunnel_id = tunnel_id ;
|
||||
|
@ -60,19 +60,20 @@ PopupDistantChatDialog::PopupDistantChatDialog(const RsGxsTunnelService::RsGxsTu
|
|||
updateDisplay() ;
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::init()
|
||||
void PopupDistantChatDialog::init(const DistantChatPeerId &peer_id, const QString &title)
|
||||
{
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo;
|
||||
_tunnel_id = peer_id;
|
||||
DistantChatPeerInfo tinfo;
|
||||
|
||||
if(!rsGxsTunnels->getDistantChatStatus(tunnel_id,tinfo))
|
||||
if(!rsMsgs->getDistantChatStatus(_tunnel_id,tinfo))
|
||||
return ;
|
||||
|
||||
PopupChatDialog::init(ChatId(tinfo.destination_gxs_id), title) ;
|
||||
PopupChatDialog::init(ChatId(tinfo.to_id), title) ;
|
||||
|
||||
// Do not use setOwnId, because we don't want the user to change the GXS avatar from the chat window
|
||||
// it will not be transmitted.
|
||||
|
||||
ui.ownAvatarWidget->setId(ChatId(tinfo.source_gxs_id));
|
||||
ui.ownAvatarWidget->setId(ChatId(tinfo.own_id));
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::updateDisplay()
|
||||
|
@ -87,15 +88,15 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
// make sure about the tunnel status
|
||||
//
|
||||
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo;
|
||||
DistantChatPeerInfo tinfo;
|
||||
rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
ui.avatarWidget->setId(ChatId(tinfo.destination_gxs_id));
|
||||
ui.avatarWidget->setId(ChatId(tinfo.to_id));
|
||||
|
||||
QString msg;
|
||||
switch(tinfo.tunnel_status)
|
||||
switch(tinfo.status)
|
||||
{
|
||||
case RsGxsTunnelService::RS_DISTANT_CHAT_STATUS_UNKNOWN: //std::cerr << "Unknown hash. Error!" << std::endl;
|
||||
case RS_DISTANT_CHAT_STATUS_UNKNOWN: //std::cerr << "Unknown hash. Error!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRY_LED)) ;
|
||||
msg = tr("Hash Error. No tunnel.");
|
||||
_status_label->setToolTip(msg) ;
|
||||
|
@ -103,7 +104,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
getChatWidget()->blockSending(tr("Can't send message, because there is no tunnel."));
|
||||
setPeerStatus(RS_STATUS_OFFLINE) ;
|
||||
break ;
|
||||
case RsGxsTunnelService::RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl;
|
||||
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
_status_label->setToolTip(QObject::tr("Distant peer has closed the chat")) ;
|
||||
|
||||
|
@ -112,7 +113,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
setPeerStatus(RS_STATUS_OFFLINE) ;
|
||||
|
||||
break ;
|
||||
case RsGxsTunnelService::RS_DISTANT_CHAT_STATUS_TUNNEL_DN: //std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: //std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
msg = QObject::tr("Tunnel is pending...");
|
||||
_status_label->setToolTip(msg) ;
|
||||
|
@ -120,7 +121,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
getChatWidget()->blockSending(msg);
|
||||
setPeerStatus(RS_STATUS_OFFLINE) ;
|
||||
break ;
|
||||
case RsGxsTunnelService::RS_DISTANT_CHAT_STATUS_CAN_TALK: //std::cerr << "Tunnel is ok and data is transmitted." << std::endl;
|
||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: //std::cerr << "Tunnel is ok and data is transmitted." << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||
msg = QObject::tr("Secured tunnel is working. You can talk!");
|
||||
_status_label->setToolTip(msg) ;
|
||||
|
@ -134,10 +135,11 @@ void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
|
|||
{
|
||||
//std::cerr << "Closing window => closing distant chat for hash " << _pid << std::endl;
|
||||
|
||||
uint32_t status= RS_DISTANT_CHAT_STATUS_UNKNOWN;
|
||||
rsMsgs->getDistantChatStatus(_pid,status) ;
|
||||
DistantChatPeerInfo tinfo ;
|
||||
|
||||
rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
if(status != RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED)
|
||||
if(tinfo.status != RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED)
|
||||
{
|
||||
QString msg = tr("Closing this window will end the conversation, notify the peer and remove the encrypted tunnel.") ;
|
||||
|
||||
|
@ -157,26 +159,26 @@ void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
|
|||
|
||||
QString PopupDistantChatDialog::getPeerName(const ChatId &id) const
|
||||
{
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo;
|
||||
DistantChatPeerInfo tinfo;
|
||||
|
||||
rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
RsIdentityDetails details ;
|
||||
if(rsIdentity->getIdDetails(destination_gxs_id,details))
|
||||
if(rsIdentity->getIdDetails(tinfo.to_id,details))
|
||||
return QString::fromUtf8( details.mNickname.c_str() ) ;
|
||||
else
|
||||
return QString::fromStdString(destination_gxs_id.toStdString()) ;
|
||||
return QString::fromStdString(tinfo.to_id.toStdString()) ;
|
||||
}
|
||||
|
||||
QString PopupDistantChatDialog::getOwnName() const
|
||||
{
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo;
|
||||
DistantChatPeerInfo tinfo;
|
||||
|
||||
rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
RsIdentityDetails details ;
|
||||
if(rsIdentity->getIdDetails(source_gxs_id,details))
|
||||
if(rsIdentity->getIdDetails(tinfo.own_id,details))
|
||||
return QString::fromUtf8( details.mNickname.c_str() ) ;
|
||||
else
|
||||
return QString::fromStdString(source_gxs_id.toStdString()) ;
|
||||
return QString::fromStdString(tinfo.own_id.toStdString()) ;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ class PopupDistantChatDialog: public PopupChatDialog
|
|||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
PopupDistantChatDialog(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
PopupDistantChatDialog(const DistantChatPeerId &tunnel_id, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
/** Default destructor */
|
||||
virtual ~PopupDistantChatDialog();
|
||||
|
||||
virtual void init(const RsGxsId &gxs_id, const QString &title);
|
||||
virtual void init(const DistantChatPeerId& peer_id, const QString &title);
|
||||
virtual void closeEvent(QCloseEvent *e) ;
|
||||
|
||||
virtual QString getPeerName(const ChatId &id) const ;
|
||||
|
@ -49,7 +49,7 @@ class PopupDistantChatDialog: public PopupChatDialog
|
|||
|
||||
private:
|
||||
QTimer *_update_timer ;
|
||||
RsGxsTunnelService::RsGxsTunnelId _tunnel_id ;
|
||||
DistantChatPeerId _tunnel_id ;
|
||||
QLabel *_status_label ;
|
||||
|
||||
friend class ChatDialog;
|
||||
|
|
|
@ -200,8 +200,9 @@ void AvatarWidget::refreshStatus()
|
|||
}
|
||||
else if(mId.isGxsId())
|
||||
{
|
||||
if(!rsMsgs->getDistantChatStatus(mId.toGxsId(),status))
|
||||
//if(!rsMsgs->getDistantChatStatus(mId.toGxsId(),status))
|
||||
status = RS_STATUS_OFFLINE ;
|
||||
#warning we need to do something clever here
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue