mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-05 13:16:12 -05:00
added tunnel state light to distant chat popup dialog. Added proper peer name. Changed method for adding widgets in the chat bar
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6337 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6ddfe35353
commit
cb9f174efa
@ -312,7 +312,7 @@ 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;
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
|
||||||
virtual uint32_t getDistantChatStatus(const std::string& hash) = 0;
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -342,8 +342,8 @@ bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,std::
|
|||||||
{
|
{
|
||||||
return mChatSrv->initiateDistantChatConnexion(encrypted_str,hash,error_code) ;
|
return mChatSrv->initiateDistantChatConnexion(encrypted_str,hash,error_code) ;
|
||||||
}
|
}
|
||||||
uint32_t p3Msgs::getDistantChatStatus(const std::string& hash)
|
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getDistantChatStatus(hash) ;
|
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class p3Msgs: public RsMsgs
|
|||||||
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);
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||||
virtual uint32_t getDistantChatStatus(const std::string& hash) ;
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -420,12 +420,13 @@ bool p3ChatService::isOnline(const std::string& id)
|
|||||||
{
|
{
|
||||||
// check if the id is a tunnel id or a peer id.
|
// check if the id is a tunnel id or a peer id.
|
||||||
|
|
||||||
uint32_t res = getDistantChatStatus(id) ;
|
uint32_t status ;
|
||||||
|
std::string pgp_id ;
|
||||||
|
|
||||||
if(!res)
|
if(!getDistantChatStatus(id,status,pgp_id))
|
||||||
return mLinkMgr->isOnline(id) ;
|
return mLinkMgr->isOnline(id) ;
|
||||||
|
|
||||||
return res == RS_DISTANT_CHAT_STATUS_TUNNEL_OK ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
||||||
@ -2897,6 +2898,7 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
|||||||
info.last_contact = now ;
|
info.last_contact = now ;
|
||||||
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_OK ;
|
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_OK ;
|
||||||
info.virtual_peer_id = virtual_peer_id ;
|
info.virtual_peer_id = virtual_peer_id ;
|
||||||
|
info.pgp_id = it->second.destination_pgp_id ;
|
||||||
memcpy(info.aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(info.aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
|
|
||||||
_distant_chat_peers[hash] = info ;
|
_distant_chat_peers[hash] = info ;
|
||||||
@ -3226,6 +3228,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
|||||||
|
|
||||||
info.last_contact = time(NULL) ;
|
info.last_contact = time(NULL) ;
|
||||||
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
||||||
|
info.pgp_id = pgp_id.toStdString() ;
|
||||||
memcpy(info.aes_key,data+DISTANT_CHAT_HASH_SIZE,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(info.aes_key,data+DISTANT_CHAT_HASH_SIZE,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
|
|
||||||
_distant_chat_peers[hash] = info ;
|
_distant_chat_peers[hash] = info ;
|
||||||
@ -3286,16 +3289,19 @@ bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>&
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t p3ChatService::getDistantChatStatus(const std::string& hash)
|
bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.find(hash) ;
|
std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end())
|
if(it == _distant_chat_peers.end())
|
||||||
return RS_DISTANT_CHAT_STATUS_UNKNOWN ;
|
return false ;
|
||||||
else
|
|
||||||
return it->second.status ;
|
status = it->second.status ;
|
||||||
|
pgp_id = it->second.pgp_id ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,7 +313,8 @@ 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) ;
|
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||||
virtual uint32_t getDistantChatStatus(const std::string& hash) ;
|
|
||||||
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DistantChatInvite
|
struct DistantChatInvite
|
||||||
@ -330,6 +331,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||||||
unsigned char aes_key[16] ; // key to encrypt packets
|
unsigned char aes_key[16] ; // key to encrypt packets
|
||||||
uint32_t status ; // info: do we have a tunnel ?
|
uint32_t status ; // info: do we have a tunnel ?
|
||||||
std::string virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
std::string virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||||
|
std::string pgp_id ; // pgp id of the peer we're talking to.
|
||||||
};
|
};
|
||||||
|
|
||||||
// This map contains the ongoing invites. This is the list where to look to
|
// This map contains the ongoing invites. This is the list where to look to
|
||||||
|
@ -49,8 +49,8 @@ AudioPopupChatDialog::AudioPopupChatDialog(QWidget *parent)
|
|||||||
connect(audioListenToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioListen()));
|
connect(audioListenToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioListen()));
|
||||||
connect(audioMuteCaptureToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioMuteCapture()));
|
connect(audioMuteCaptureToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioMuteCapture()));
|
||||||
|
|
||||||
addButton(audioListenToggleButton) ;
|
addChatBarWidget(audioListenToggleButton) ;
|
||||||
addButton(audioMuteCaptureToggleButton) ;
|
addChatBarWidget(audioMuteCaptureToggleButton) ;
|
||||||
|
|
||||||
//ui.chatWidget->resetStatusBar();
|
//ui.chatWidget->resetStatusBar();
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t distant_peer_status ;
|
uint32_t distant_peer_status ;
|
||||||
|
std::string distant_chat_pgp_id ;
|
||||||
|
|
||||||
if(distant_peer_status = rsMsgs->getDistantChatStatus(peerId)) {
|
if(rsMsgs->getDistantChatStatus(peerId,distant_peer_status,distant_chat_pgp_id))
|
||||||
chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // use own flags
|
chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // use own flags
|
||||||
}
|
|
||||||
|
|
||||||
if (chatflags & RS_CHAT_OPEN) {
|
if (chatflags & RS_CHAT_OPEN) {
|
||||||
if (lobby_id) {
|
if (lobby_id) {
|
||||||
@ -120,7 +120,9 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
|
|||||||
} else if(distant_peer_status > 0) {
|
} else if(distant_peer_status > 0) {
|
||||||
cd = new PopupDistantChatDialog();
|
cd = new PopupDistantChatDialog();
|
||||||
chatDialogs[peerId] = cd;
|
chatDialogs[peerId] = cd;
|
||||||
cd->init(peerId, tr("Distant peer (PGP id=%1)")) ;
|
std::string peer_name = rsPeers->getGPGName(distant_chat_pgp_id) ;
|
||||||
|
cd->init(peerId, tr("Talking to ")+QString::fromStdString(peer_name)+" (PGP id="+QString::fromStdString(distant_chat_pgp_id)+")") ;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
RsPeerDetails sslDetails;
|
RsPeerDetails sslDetails;
|
||||||
if (rsPeers->getPeerDetails(peerId, sslDetails)) {
|
if (rsPeers->getPeerDetails(peerId, sslDetails)) {
|
||||||
|
@ -78,7 +78,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
|
|||||||
|
|
||||||
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
||||||
|
|
||||||
getChatWidget()->addChatButton(inviteFriendsButton) ;
|
getChatWidget()->addChatBarWidget(inviteFriendsButton) ;
|
||||||
|
|
||||||
unsubscribeButton = new QPushButton ;
|
unsubscribeButton = new QPushButton ;
|
||||||
unsubscribeButton->setMinimumSize(QSize(28,28)) ;
|
unsubscribeButton->setMinimumSize(QSize(28,28)) ;
|
||||||
@ -95,7 +95,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
|
|||||||
|
|
||||||
connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));
|
connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));
|
||||||
|
|
||||||
getChatWidget()->addChatButton(unsubscribeButton) ;
|
getChatWidget()->addChatBarWidget(unsubscribeButton) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::leaveLobby()
|
void ChatLobbyDialog::leaveLobby()
|
||||||
|
@ -140,9 +140,9 @@ void ChatWidget::setDefaultExtraFileFlags(TransferRequestFlags fl)
|
|||||||
ui->hashBox->setDefaultTransferRequestFlags(fl) ;
|
ui->hashBox->setDefaultTransferRequestFlags(fl) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::addChatButton(QPushButton *button)
|
void ChatWidget::addChatBarWidget(QWidget *w)
|
||||||
{
|
{
|
||||||
ui->toolBarFrame->layout()->addWidget(button) ;
|
ui->toolBarFrame->layout()->addWidget(w) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::init(const std::string &peerId, const QString &title)
|
void ChatWidget::init(const std::string &peerId, const QString &title)
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
bool setStyle();
|
bool setStyle();
|
||||||
const RSStyle *getStyle() { return &style; }
|
const RSStyle *getStyle() { return &style; }
|
||||||
|
|
||||||
void addChatButton(QPushButton *button) ;
|
void addChatBarWidget(QWidget *w) ;
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
void setDefaultExtraFileFlags(TransferRequestFlags f) ;
|
void setDefaultExtraFileFlags(TransferRequestFlags f) ;
|
||||||
|
@ -141,9 +141,9 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::addButton(QPushButton *button)
|
void PopupChatDialog::addChatBarWidget(QWidget *w)
|
||||||
{
|
{
|
||||||
getChatWidget()->addChatButton(button) ;
|
getChatWidget()->addChatBarWidget(w) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::onChatChanged(int list, int type)
|
void PopupChatDialog::onChatChanged(int list, int type)
|
||||||
|
@ -57,7 +57,7 @@ protected:
|
|||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
|
|
||||||
// used by plugins
|
// used by plugins
|
||||||
void addButton(QPushButton *button) ;
|
void addChatBarWidget(QWidget *w) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void addIncomingChatMsg(const ChatInfo& info);
|
virtual void addIncomingChatMsg(const ChatInfo& info);
|
||||||
|
@ -22,6 +22,11 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "PopupDistantChatDialog.h"
|
#include "PopupDistantChatDialog.h"
|
||||||
|
|
||||||
|
#define IMAGE_RED_LED ":/images/redled.png"
|
||||||
|
#define IMAGE_YEL_LED ":/images/yellowled.png"
|
||||||
|
#define IMAGE_GRN_LED ":/images/greenled.png"
|
||||||
|
#define IMAGE_GRY_LED ":/images/grayled.png"
|
||||||
|
|
||||||
PopupDistantChatDialog::~PopupDistantChatDialog()
|
PopupDistantChatDialog::~PopupDistantChatDialog()
|
||||||
{
|
{
|
||||||
delete _tunnel_check_timer ;
|
delete _tunnel_check_timer ;
|
||||||
@ -36,6 +41,10 @@ PopupDistantChatDialog::PopupDistantChatDialog(QWidget *parent, Qt::WFlags flags
|
|||||||
QObject::connect(_tunnel_check_timer,SIGNAL(timeout()),this,SLOT(checkTunnel())) ;
|
QObject::connect(_tunnel_check_timer,SIGNAL(timeout()),this,SLOT(checkTunnel())) ;
|
||||||
|
|
||||||
_tunnel_check_timer->start() ;
|
_tunnel_check_timer->start() ;
|
||||||
|
_status_label = new QLabel ;
|
||||||
|
|
||||||
|
addChatBarWidget(_status_label) ;
|
||||||
|
checkTunnel() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupDistantChatDialog::init(const std::string& hash,const QString & title)
|
void PopupDistantChatDialog::init(const std::string& hash,const QString & title)
|
||||||
@ -53,17 +62,27 @@ void PopupDistantChatDialog::checkTunnel()
|
|||||||
// make sure about the tunnel status
|
// make sure about the tunnel status
|
||||||
//
|
//
|
||||||
|
|
||||||
uint32_t status = rsMsgs->getDistantChatStatus(_hash) ;
|
uint32_t status= RS_DISTANT_CHAT_STATUS_UNKNOWN;
|
||||||
|
std::string pgp_id ;
|
||||||
|
rsMsgs->getDistantChatStatus(_hash,status,pgp_id) ;
|
||||||
|
|
||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
case 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)) ;
|
||||||
|
_status_label->setText(tr("Hash error")) ;
|
||||||
break ;
|
break ;
|
||||||
case 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)) ;
|
||||||
|
_status_label->setText(tr("Tunnel is broken")) ;
|
||||||
break ;
|
break ;
|
||||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: std::cerr << "Tunnel is ok. " << std::endl;
|
case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: std::cerr << "Tunnel is ok. " << std::endl;
|
||||||
|
_status_label->setPixmap(QPixmap(IMAGE_YEL_LED)) ;
|
||||||
|
_status_label->setText(tr("Tunnel established")) ;
|
||||||
break ;
|
break ;
|
||||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and works. You can talk!" << std::endl;
|
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and works. You can talk!" << std::endl;
|
||||||
|
_status_label->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||||
|
_status_label->setText(tr("Tunnel is working")) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ protected:
|
|||||||
QTimer *_tunnel_check_timer ;
|
QTimer *_tunnel_check_timer ;
|
||||||
std::string _hash ;
|
std::string _hash ;
|
||||||
std::string _virtual_peer_id ;
|
std::string _virtual_peer_id ;
|
||||||
|
QLabel *_status_label ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user