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:
csoler 2013-04-23 22:43:19 +00:00
parent 6ddfe35353
commit cb9f174efa
14 changed files with 56 additions and 26 deletions

View file

@ -100,10 +100,10 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
}
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
}
if (chatflags & RS_CHAT_OPEN) {
if (lobby_id) {
@ -120,7 +120,9 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
} else if(distant_peer_status > 0) {
cd = new PopupDistantChatDialog();
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 {
RsPeerDetails sslDetails;
if (rsPeers->getPeerDetails(peerId, sslDetails)) {

View file

@ -78,7 +78,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
getChatWidget()->addChatButton(inviteFriendsButton) ;
getChatWidget()->addChatBarWidget(inviteFriendsButton) ;
unsubscribeButton = new QPushButton ;
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()));
getChatWidget()->addChatButton(unsubscribeButton) ;
getChatWidget()->addChatBarWidget(unsubscribeButton) ;
}
void ChatLobbyDialog::leaveLobby()

View file

@ -140,9 +140,9 @@ void ChatWidget::setDefaultExtraFileFlags(TransferRequestFlags 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)

View file

@ -73,7 +73,7 @@ public:
bool setStyle();
const RSStyle *getStyle() { return &style; }
void addChatButton(QPushButton *button) ;
void addChatBarWidget(QWidget *w) ;
bool isActive();
void setDefaultExtraFileFlags(TransferRequestFlags f) ;

View file

@ -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)

View file

@ -57,7 +57,7 @@ protected:
void processSettings(bool load);
// used by plugins
void addButton(QPushButton *button) ;
void addChatBarWidget(QWidget *w) ;
protected:
virtual void addIncomingChatMsg(const ChatInfo& info);

View file

@ -22,6 +22,11 @@
#include <QTimer>
#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()
{
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())) ;
_tunnel_check_timer->start() ;
_status_label = new QLabel ;
addChatBarWidget(_status_label) ;
checkTunnel() ;
}
void PopupDistantChatDialog::init(const std::string& hash,const QString & title)
@ -53,17 +62,27 @@ void PopupDistantChatDialog::checkTunnel()
// 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)
{
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 ;
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 ;
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 ;
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 ;
}
}

View file

@ -47,6 +47,7 @@ protected:
QTimer *_tunnel_check_timer ;
std::string _hash ;
std::string _virtual_peer_id ;
QLabel *_status_label ;
};