mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 16:15:23 -04:00
Merged branch v0.5-GenericTunneling into trunk (Rev. 6284 to 6410).
- adds turtle router as a generic tunneling service - made ftServer a client of the service. Now turtle file items are handled in ftServer - added new client: p3MsgService to send/recv pgp-encrypted distant messages - added new client: p3ChatService to perform private (AES-encrypted) distant chat through tunnels. - The GUI is disabled for now, since it needs some polishing before being fully usable. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6411 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
dc2521cf71
62 changed files with 5031 additions and 1989 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "ChatDialog.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "PopupChatDialog.h"
|
||||
#include "PopupDistantChatDialog.h"
|
||||
#include "ChatLobbyDialog.h"
|
||||
#include "PopupChatWindow.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
@ -91,11 +92,19 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
|
|||
ChatDialog *cd = getExistingChat(peerId);
|
||||
|
||||
if (cd == NULL) {
|
||||
ChatLobbyId lobby_id;
|
||||
ChatLobbyId lobby_id = 0;
|
||||
bool distant_peer = false ;
|
||||
|
||||
if (rsMsgs->isLobbyId(peerId, lobby_id)) {
|
||||
chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // use own flags
|
||||
}
|
||||
|
||||
uint32_t distant_peer_status ;
|
||||
std::string distant_chat_pgp_id ;
|
||||
|
||||
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) {
|
||||
std::list<ChatLobbyInfo> linfos;
|
||||
|
@ -108,6 +117,12 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
|
|||
cd->init(peerId, QString::fromUtf8((*it).lobby_name.c_str()));
|
||||
}
|
||||
}
|
||||
} else if(distant_peer_status > 0) {
|
||||
cd = new PopupDistantChatDialog();
|
||||
chatDialogs[peerId] = cd;
|
||||
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)) {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "ui_ChatWidget.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/CreateMsgLinkDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
|
@ -139,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)
|
||||
|
@ -548,11 +549,22 @@ void ChatWidget::contextMenu(QPoint point)
|
|||
QAction *action = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||
action->setDisabled(RSLinkClipboard::empty());
|
||||
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
|
||||
#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
|
||||
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this, SLOT(pasteCreateMsgLink()));
|
||||
#endif
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
}
|
||||
|
||||
void ChatWidget::pasteCreateMsgLink()
|
||||
{
|
||||
CreateMsgLinkDialog dialog ;
|
||||
dialog.exec() ;
|
||||
|
||||
ui->chatTextEdit->insertHtml(RSLinkClipboard::toHtml());
|
||||
}
|
||||
|
||||
void ChatWidget::contextMenuTextBrowser(QPoint point)
|
||||
{
|
||||
QMatrix matrix;
|
||||
|
|
|
@ -47,7 +47,6 @@ class ChatWidget : public QWidget
|
|||
public:
|
||||
enum enumChatType { TYPE_NORMAL, TYPE_HISTORY, TYPE_OFFLINE, TYPE_SYSTEM };
|
||||
|
||||
public:
|
||||
explicit ChatWidget(QWidget *parent = 0);
|
||||
~ChatWidget();
|
||||
|
||||
|
@ -74,13 +73,14 @@ public:
|
|||
bool setStyle();
|
||||
const RSStyle *getStyle() { return &style; }
|
||||
|
||||
void addChatButton(QPushButton *button) ;
|
||||
void addChatBarWidget(QWidget *w) ;
|
||||
|
||||
bool isActive();
|
||||
void setDefaultExtraFileFlags(TransferRequestFlags f) ;
|
||||
void pasteText(const QString&);
|
||||
|
||||
private slots:
|
||||
void pasteCreateMsgLink() ;
|
||||
void clearChatHistory();
|
||||
void deleteChatHistory();
|
||||
void messageHistory();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
98
retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp
Normal file
98
retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2013, Cyril Soler
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#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 ;
|
||||
}
|
||||
|
||||
PopupDistantChatDialog::PopupDistantChatDialog(QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(parent,flags)
|
||||
{
|
||||
_tunnel_check_timer = new QTimer;
|
||||
_tunnel_check_timer->setInterval(1000) ;
|
||||
|
||||
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)
|
||||
{
|
||||
_hash = hash ;
|
||||
PopupChatDialog::init(hash,title) ;
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::checkTunnel()
|
||||
{
|
||||
if(!isVisible())
|
||||
return ;
|
||||
|
||||
std::cerr << "Checking tunnel..." ;
|
||||
// make sure about the tunnel status
|
||||
//
|
||||
|
||||
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->setToolTip(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->setToolTip(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->setToolTip(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->setToolTip(tr("Tunnel is working")) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
53
retroshare-gui/src/gui/chat/PopupDistantChatDialog.h
Normal file
53
retroshare-gui/src/gui/chat/PopupDistantChatDialog.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2013, Cyril Soler
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PopupChatDialog.h"
|
||||
|
||||
class QTimer ;
|
||||
|
||||
class PopupDistantChatDialog: public PopupChatDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class ChatDialog;
|
||||
|
||||
public slots:
|
||||
void checkTunnel() ;
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
PopupDistantChatDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
virtual ~PopupDistantChatDialog();
|
||||
|
||||
virtual void init(const std::string& _hash, const QString &title);
|
||||
virtual void updateStatus(int /*status*/) {}
|
||||
|
||||
QTimer *_tunnel_check_timer ;
|
||||
std::string _hash ;
|
||||
std::string _virtual_peer_id ;
|
||||
QLabel *_status_label ;
|
||||
};
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue