Added ConnectProgressDialog - to help people workout why RS is not connecting.

- Pops up when you do a "Connect Attempt" from the FriendList.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6590 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-08-22 07:30:54 +00:00
parent f519ae1a0d
commit b566d6d69c
7 changed files with 1297 additions and 0 deletions

View File

@ -51,6 +51,11 @@
#include "util/misc.h"
#include "vmessagebox.h"
#define PROGRESS_DIALOG 1
#ifdef PROGRESS_DIALOG
#include "gui/connect/ConnectProgressDialog.h"
#endif
#include "FriendList.h"
#include "ui_FriendList.h"
@ -1491,6 +1496,9 @@ void FriendList::connectfriend()
//this is a SSL key
rsPeers->connectAttempt(getRsId(c));
c->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2)));
#ifdef PROGRESS_DIALOG
ConnectProgressDialog::showProgress(getRsId(c));
#endif
}
}
}

View File

@ -0,0 +1,866 @@
/*
* Connect Progress Dialog
*
* Copyright 2012-2013 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "gui/connect/ConnectProgressDialog.h"
#include <QTimer>
#include <map>
#include <retroshare/rspeers.h>
#include <retroshare/rsconfig.h>
#include <retroshare/rsdht.h>
#include "StatusDefs.h"
/* maintain one static dialog per SSL ID */
static std::map<std::string, ConnectProgressDialog *> instances;
int calcProgress(time_t now, time_t start, int period50, int period75, int period100);
ConnectProgressDialog *ConnectProgressDialog::instance(const std::string& peer_id)
{
std::map<std::string, ConnectProgressDialog *>::iterator it;
it = instances.find(peer_id);
if (it != instances.end())
{
return it->second;
}
ConnectProgressDialog *d = new ConnectProgressDialog(peer_id);
instances[peer_id] = d;
return d;
}
ConnectProgressDialog::ConnectProgressDialog(const std::string& id, QWidget *parent, Qt::WFlags flags)
:QDialog(parent, flags), mId(id), ui(new Ui::ConnectProgressDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
ui->headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png"));
ui->headerFrame->setHeaderText(tr("Connection Assistant"));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(close()));
}
ConnectProgressDialog::~ConnectProgressDialog()
{
std::map<std::string, ConnectProgressDialog *>::iterator it;
it = instances.find(mId);
if (it != instances.end())
{
instances.erase(it);
}
}
void ConnectProgressDialog::showProgress(const std::string& peer_id)
{
ConnectProgressDialog *d = instance(peer_id);
d->initDialog();
d->show();
d->raise();
d->activateWindow();
/* window will destroy itself! */
}
const uint32_t CONNECT_STATE_INIT = 0;
const uint32_t CONNECT_STATE_PROGRESS = 1;
const uint32_t CONNECT_STATE_CONNECTED = 2;
const uint32_t CONNECT_STATE_DENIED = 3;
const uint32_t CONNECT_STATE_FAILED = 4;
const uint32_t CONNECT_DHT_INIT = 0;
const uint32_t CONNECT_DHT_OKAY = 2;
const uint32_t CONNECT_DHT_FAIL = 3;
const uint32_t CONNECT_DHT_DISABLED = 4;
const uint32_t CONNECT_LOOKUP_INIT = 0;
const uint32_t CONNECT_LOOKUP_SEARCH = 1;
const uint32_t CONNECT_LOOKUP_OFFLINE = 2;
const uint32_t CONNECT_LOOKUP_UNREACHABLE = 3;
const uint32_t CONNECT_LOOKUP_ONLINE = 4;
const uint32_t CONNECT_LOOKUP_NODHTCONFIG = 5;
const uint32_t CONNECT_LOOKUP_FAIL = 6;
const uint32_t CONNECT_UDP_INIT = 0;
const uint32_t CONNECT_UDP_PROGRESS = 1;
const uint32_t CONNECT_UDP_FAIL = 2;
const uint32_t CONNECT_CONTACT_NONE = 0;
const uint32_t CONNECT_CONTACT_CONNECTED = 1;
/* at a minimum allow 30 secs for TCP connections */
const int MINIMUM_CONNECT_PERIOD = 30;
/* overall timeout */
const int CONNECT_TIMEOUT_PERIOD = 1800;
/* assume it will take 5 minute to complete DHT load (should take 30 secs, and 2-3 minutes from cold start) */
const int CONNECT_DHT_TYPICAL = 30;
const int CONNECT_DHT_SLOW = 120;
const int CONNECT_DHT_PERIOD = 300;
/* need to shorten this time (DHT work) */
const int CONNECT_LOOKUP_TYPICAL = 200;
const int CONNECT_LOOKUP_SLOW = 300;
const int CONNECT_LOOKUP_PERIOD = 600;
/* Udp can take ages ... */
const int CONNECT_UDP_TYPICAL = 150;
const int CONNECT_UDP_SLOW = 300;
const int CONNECT_UDP_PERIOD = 600;
/* connection must stay up for 5 seconds to be considered okay */
const int REQUIRED_CONTACT_PERIOD = 5;
void ConnectProgressDialog::initDialog()
{
mTimer = new QTimer(this);
connect(mTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
mTimer->start(250);
mState = CONNECT_STATE_PROGRESS;
mInitTS = time(NULL);
mDhtStatus = CONNECT_DHT_INIT;
mLookupTS = 0;
mLookupStatus = CONNECT_LOOKUP_INIT;
mContactTS = 0;
mContactState = CONNECT_CONTACT_NONE;
mUdpTS = 0;
mUdpStatus = CONNECT_UDP_INIT;
ui->progressFrame->setEnabled(true);
/* initialise GUI data */
ui->NetResult->setText("N/A");
ui->ContactResult->setText("N/A");
ui->DhtResult->setText("DHT Startup");
ui->DhtProgressBar->setValue(0);
ui->LookupResult->setText("N/A");
ui->LookupProgressBar->setValue(0);
ui->UdpResult->setText("N/A");
ui->UdpProgressBar->setValue(0);
sayInProgress();
if (rsPeers->isFriend(mId))
{
/* okay */
std::string name = rsPeers->getPeerName(mId);
QString connectName = QString::fromUtf8(name.c_str());
connectName += " (";
connectName += QString::fromStdString(mId).left(10);
connectName += "...)";
ui->connectId->setText(connectName);
}
else
{
ui->connectId->setText(tr("Invalid Peer ID"));
/* list Error */
mState = CONNECT_STATE_FAILED;
sayInvalidPeer();
return;
}
if (rsPeers->isOnline(mId))
{
mState = CONNECT_STATE_CONNECTED;
sayConnected();
return;
}
}
void ConnectProgressDialog::updateStatus()
{
if (time(NULL) > mInitTS + CONNECT_TIMEOUT_PERIOD)
{
sayConnectTimeout();
mState = CONNECT_STATE_FAILED;
}
switch(mState)
{
case CONNECT_STATE_PROGRESS:
updateNetworkStatus();
updateContactStatus();
updateDhtStatus();
updateLookupStatus();
updateUdpStatus();
return;
break;
default:
case CONNECT_STATE_FAILED:
case CONNECT_STATE_DENIED:
case CONNECT_STATE_CONNECTED:
break;
}
/* shutdown actions */
ui->progressFrame->setEnabled(false);
mTimer->stop();
}
void ConnectProgressDialog::updateNetworkStatus()
{
uint32_t netState = rsConfig->getNetState();
QLabel *label = ui->NetResult;
switch(netState)
{
case RSNET_NETSTATE_BAD_UNKNOWN:
label->setText(tr("Unknown State"));
break;
case RSNET_NETSTATE_BAD_OFFLINE:
label->setText(tr("Offline"));
break;
case RSNET_NETSTATE_BAD_NATSYM:
label->setText(tr("Behind Symmetric NAT"));
break;
case RSNET_NETSTATE_BAD_NODHT_NAT:
label->setText(tr("Behind NAT & No DHT"));
break;
case RSNET_NETSTATE_WARNING_RESTART:
label->setText(tr("NET Restart"));
break;
case RSNET_NETSTATE_WARNING_NATTED:
label->setText(tr("Behind NAT"));
break;
case RSNET_NETSTATE_WARNING_NODHT:
label->setText(tr("No DHT"));
break;
case RSNET_NETSTATE_GOOD:
label->setText(tr("NET STATE GOOD!"));
break;
case RSNET_NETSTATE_ADV_FORWARD:
label->setText(tr("UNVERIFABLE FORWARD!"));
break;
case RSNET_NETSTATE_ADV_DARK_FORWARD:
label->setText(tr("UNVERIFABLE FORWARD & NO DHT"));
break;
}
}
void ConnectProgressDialog::updateContactStatus()
{
/* lookup peer details - and try those addresses */
RsPeerDetails details;
if (!rsPeers->getPeerDetails(mId, details))
return;
QString status = StatusDefs::connectStateString(details);
ui->ContactResult->setText(status);
time_t now = time(NULL);
/* now if it says connected - Alter overall state, after REQUIRED CONTACT PERIOD */
if (rsPeers->isOnline(mId))
{
switch(mContactState)
{
default:
case CONNECT_CONTACT_NONE:
{
mContactTS = now;
mContactState = CONNECT_CONTACT_CONNECTED;
}
break;
case CONNECT_CONTACT_CONNECTED:
if (now > mContactTS + REQUIRED_CONTACT_PERIOD)
{
/* still connected, flag as SUCCESS */
mState = CONNECT_STATE_CONNECTED;
sayConnected();
}
break;
}
}
else if (details.wasDeniedConnection)
{
if (details.deniedTS > mInitTS)
{
/* connection dropped, flag as DENIED */
mState = CONNECT_STATE_DENIED;
sayDenied();
}
}
}
void ConnectProgressDialog::updateDhtStatus()
{
/* if DHT is disabled -> mark bad */
/* if DHT is red -> mark bad, probable cause missing bdboot.txt */
/* if DHT is starting, run progress bar */
time_t now = time(NULL);
switch(mDhtStatus)
{
case CONNECT_DHT_OKAY:
case CONNECT_DHT_FAIL:
return;
break;
case CONNECT_DHT_DISABLED:
/* Ensure minimum time for direct TCP connections */
if (now > mInitTS + MINIMUM_CONNECT_PERIOD)
{
mState = CONNECT_STATE_FAILED;
sayDHTOffline();
}
return;
break;
default: /* still in progress */
case CONNECT_DHT_INIT:
if (now > mInitTS + CONNECT_DHT_PERIOD)
{
ui->DhtProgressBar->setValue(100);
ui->DhtResult->setText(tr("DHT Failed"));
mDhtStatus = CONNECT_DHT_FAIL;
mState = CONNECT_STATE_FAILED;
sayDHTFailed();
return;
}
break;
}
RsConfigNetStatus status;
rsConfig->getConfigNetStatus(status);
if (!status.DHTActive)
{
mDhtStatus = CONNECT_DHT_DISABLED;
/* ERROR message */
ui->DhtProgressBar->setValue(100);
ui->DhtResult->setText(tr("DHT Disabled"));
return;
}
if (status.netDhtOk && (status.netDhtNetSize > 100))
{
if (status.netDhtRsNetSize > 10)
{
ui->DhtProgressBar->setValue(100);
ui->DhtResult->setText(tr("DHT Okay"));
mDhtStatus = CONNECT_DHT_OKAY;
return;
}
ui->DhtResult->setText(tr("Finding RS Peers"));
}
ui->DhtProgressBar->setValue(calcProgress(now, mInitTS, CONNECT_DHT_TYPICAL, CONNECT_DHT_SLOW, CONNECT_DHT_PERIOD));
return;
}
void ConnectProgressDialog::updateLookupStatus()
{
switch(mLookupStatus)
{
case CONNECT_LOOKUP_OFFLINE:
case CONNECT_LOOKUP_NODHTCONFIG:
/* Ensure minimum time for direct TCP connections */
if (time(NULL) > mInitTS + MINIMUM_CONNECT_PERIOD)
{
mState = CONNECT_STATE_FAILED;
if (mLookupStatus == CONNECT_LOOKUP_NODHTCONFIG)
{
sayPeerNoDhtConfig();
}
else
{
sayPeerOffline();
}
}
case CONNECT_LOOKUP_FAIL:
case CONNECT_LOOKUP_ONLINE:
case CONNECT_LOOKUP_UNREACHABLE:
return;
break;
default:
break;
}
time_t now = time(NULL);
switch(mDhtStatus)
{
case CONNECT_DHT_DISABLED:
case CONNECT_DHT_FAIL:
mLookupStatus = CONNECT_LOOKUP_FAIL;
ui->LookupProgressBar->setValue(0);
ui->LookupResult->setText(tr("Lookup requires DHT"));
case CONNECT_DHT_INIT:
return;
break;
case CONNECT_DHT_OKAY:
if (mLookupStatus == CONNECT_LOOKUP_INIT)
{
mLookupStatus = CONNECT_LOOKUP_SEARCH;
ui->LookupResult->setText(tr("Searching DHT"));
mLookupTS = now;
}
}
if (now > mLookupTS + CONNECT_LOOKUP_PERIOD)
{
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Lookup Timeout"));
mLookupStatus = CONNECT_LOOKUP_FAIL;
mState = CONNECT_STATE_FAILED;
sayLookupTimeout();
return;
}
ui->LookupProgressBar->setValue(calcProgress(now, mLookupTS, CONNECT_LOOKUP_TYPICAL, CONNECT_LOOKUP_SLOW, CONNECT_LOOKUP_PERIOD));
/* now actually look at the DHT Details */
RsDhtNetPeer status;
rsDht->getNetPeerStatus(mId, status);
switch(status.mDhtState)
{
default:
case RSDHT_PEERDHT_NOT_ACTIVE:
ui->LookupProgressBar->setValue(0);
ui->LookupResult->setText(tr("Peer DHT NOT ACTIVE"));
mLookupStatus = CONNECT_LOOKUP_NODHTCONFIG;
break;
case RSDHT_PEERDHT_SEARCHING:
ui->LookupResult->setText("Searching");
break;
case RSDHT_PEERDHT_FAILURE:
ui->LookupProgressBar->setValue(0);
ui->LookupResult->setText(tr("Lookup Failure"));
mLookupStatus = CONNECT_LOOKUP_FAIL;
break;
case RSDHT_PEERDHT_OFFLINE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Offline"));
mLookupStatus = CONNECT_LOOKUP_OFFLINE;
break;
case RSDHT_PEERDHT_UNREACHABLE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Firewalled"));
mLookupStatus = CONNECT_LOOKUP_UNREACHABLE;
break;
case RSDHT_PEERDHT_ONLINE:
ui->LookupProgressBar->setValue(100);
ui->LookupResult->setText(tr("Peer Online"));
mLookupStatus = CONNECT_LOOKUP_ONLINE;
break;
}
}
void ConnectProgressDialog::updateUdpStatus()
{
switch(mLookupStatus)
{
default:
case CONNECT_LOOKUP_OFFLINE:
case CONNECT_LOOKUP_NODHTCONFIG:
case CONNECT_LOOKUP_FAIL:
return;
break;
case CONNECT_LOOKUP_ONLINE:
case CONNECT_LOOKUP_UNREACHABLE:
break;
}
switch(mUdpStatus)
{
case CONNECT_UDP_FAIL:
return;
break;
case CONNECT_UDP_INIT:
mUdpTS = time(NULL);
mUdpStatus = CONNECT_UDP_PROGRESS;
ui->UdpResult->setText(tr("UDP Setup"));
break;
default:
case CONNECT_UDP_PROGRESS:
break;
}
time_t now = time(NULL);
if (now > mUdpTS + CONNECT_UDP_PERIOD)
{
ui->UdpProgressBar->setValue(100);
ui->UdpResult->setText(tr("Udp Connect Timeout"));
mUdpStatus = CONNECT_UDP_FAIL;
mState = CONNECT_STATE_FAILED;
sayUdpTimeout();
return;
}
ui->UdpProgressBar->setValue(calcProgress(now, mUdpTS, CONNECT_UDP_TYPICAL, CONNECT_UDP_SLOW, CONNECT_UDP_PERIOD));
/* now lookup details from Dht */
RsDhtNetPeer status;
rsDht->getNetPeerStatus(mId, status);
QString fullString = QString::fromStdString(status.mConnectState);
QString connectString = fullString.section(':',0,0);
ui->UdpResult->setText(connectString);
if (connectString == "Failed Wait")
{
/* Ensure minimum time for direct TCP connections */
if (now > mInitTS + MINIMUM_CONNECT_PERIOD)
{
if (status.mCbPeerMsg == "ERROR : END:AUTH_DENIED")
{
/* disaster - connection not allowed */
mState = CONNECT_STATE_DENIED;
sayUdpDenied();
}
else
{
/* disaster - udp failed */
mState = CONNECT_STATE_FAILED;
sayUdpFailed();
}
}
}
}
int calcProgress(time_t now, time_t start, int period50, int period75, int period100)
{
int dt = now - start;
if (dt < 0)
return 0;
if (dt > period100)
return 100;
if (dt < period50)
{
return 50 * (dt / (float) period50);
}
if (dt < period75)
{
return 50 + 25 * ((dt - period50) / (float) (period75 - period50));
}
return 75 + 25 * ((dt - period75) / (float) (period100 - period75));
}
/*********** Status ***********/
const uint32_t MESSAGE_STATUS_INPROGRESS = 1;
const uint32_t MESSAGE_STATUS_SUCCESS = 2;
const uint32_t MESSAGE_STATUS_CONFIG_ERROR = 3;
const uint32_t MESSAGE_STATUS_PEER_ERROR = 4;
const uint32_t MESSAGE_STATUS_UNKNOWN_ERROR = 5;
void ConnectProgressDialog::sayInProgress()
{
QString title = tr("Connection In Progress");
QString message = tr("Initial connections can take a while, please be patient");
message += "\n\n";
message += tr("If an error is detected it will be displayed here");
message += "\n\n";
message += tr("You can close this dialog at any time");
message += "\n";
message += tr("Retroshare will continue connecting in the background");
setStatusMessage(MESSAGE_STATUS_INPROGRESS, title, message);
}
void ConnectProgressDialog::sayConnectTimeout()
{
QString title = tr("Connection Timeout");
QString message = tr("Connection Attempt has taken too long");
message += "\n";
message += tr("But no error has been detected");
message += "\n\n";
message += tr("Try again shortly, Retroshare will continue connecting in the background");
message += "\n\n";
message += tr("If you continue to get this message, please contact developers");
setStatusMessage(MESSAGE_STATUS_UNKNOWN_ERROR, title, message);
}
void ConnectProgressDialog::sayLookupTimeout()
{
QString title = tr("DHT Lookup Timeout");
QString message = tr("DHT Lookup has taken too long");
message += "\n\n";
message += tr("Try again shortly, Retroshare will continue connecting in the background");
message += "\n\n";
message += tr("If you continue to get this message, please contact developers");
setStatusMessage(MESSAGE_STATUS_UNKNOWN_ERROR, title, message);
}
void ConnectProgressDialog::sayUdpTimeout()
{
QString title = tr("UDP Connection Timeout");
QString message = tr("UDP Connection has taken too long");
message += "\n\n";
message += tr("Try again shortly, Retroshare will continue connecting in the background");
message += "\n\n";
message += tr("If you continue to get this message, please contact developers");
setStatusMessage(MESSAGE_STATUS_UNKNOWN_ERROR, title, message);
}
void ConnectProgressDialog::sayUdpFailed()
{
QString title = tr("UDP Connection Failed");
QString message = tr("We are continually working to improve connectivity.");
message += "\n";
message += tr("In this case the UDP connection attempt has failed.");
message += "\n\n";
message += tr("Improve connectivity by opening a Port in your Firewall.");
message += "\n\n";
message += tr("Retroshare will continue connecting in the background");
message += "\n";
message += tr("If you continue to get this message, please contact developers");
setStatusMessage(MESSAGE_STATUS_UNKNOWN_ERROR, title, message);
}
void ConnectProgressDialog::sayConnected()
{
QString title = tr("Connected");
QString message = tr("Congratulations, you are connected");
setStatusMessage(MESSAGE_STATUS_SUCCESS, title, message);
}
void ConnectProgressDialog::sayDHTFailed()
{
QString title = tr("DHT startup Failed");
QString message = tr("Your DHT has not started properly");
message += "\n\n";
message += tr("Common causes of this problem are:");
message += "\n";
message += tr(" - You are not connected to the Internet");
message += "\n";
message += tr(" - You have a missing or out-of-date DHT bootstrap file (bdboot.txt)");
setStatusMessage(MESSAGE_STATUS_CONFIG_ERROR, title, message);
}
void ConnectProgressDialog::sayDHTOffline()
{
QString title = tr("DHT is Disabled");
QString message = tr("The DHT is OFF, so Retroshare cannot find your Friends.");
message += "\n\n";
message += tr("Retroshare has tried All Known Addresses, with no success");
message += "\n";
message += tr("The DHT is needed if your friends have Dynamic IP Addresses.");
message += "\n";
message += tr("Only Advanced Retroshare users should switch of the DHT.");
message += "\n\n";
message += tr("Go to Settings->Server and change config to \"Public: DHT and Discovery\"");
setStatusMessage(MESSAGE_STATUS_CONFIG_ERROR, title, message);
}
void ConnectProgressDialog::sayDenied()
{
QString title = tr("Peer Denied Connection");
QString message = tr("We successfully reached your Friend.");
message += "\n";
message += tr("but they have not added you as a Friend.");
message += "\n\n";
message += tr("Please contact them to add your Certificate");
message += "\n\n";
message += tr("Your Retroshare Node is configured Okay");
setStatusMessage(MESSAGE_STATUS_PEER_ERROR, title, message);
}
void ConnectProgressDialog::sayUdpDenied()
{
QString title = tr("Peer Denied Connection");
QString message = tr("We successfully reached your Friend via UDP.");
message += "\n";
message += tr("but they have not added you as a Friend.");
message += "\n\n";
message += tr("Please contact them to add your Full Certificate");
message += "\n";
message += tr("They need a Certificate + Location for UDP connections to succeed");
message += "\n\n";
message += tr("Your Retroshare Node is configured Okay");
setStatusMessage(MESSAGE_STATUS_PEER_ERROR, title, message);
}
void ConnectProgressDialog::sayPeerOffline()
{
QString title = tr("Peer Offline");
QString message = tr("We Cannot find your Friend.");
message += "\n\n";
message += tr("They are either offline or their DHT is Off");
message += "\n\n";
message += tr("Your Retroshare Node is configured Okay");
setStatusMessage(MESSAGE_STATUS_PEER_ERROR, title, message);
}
void ConnectProgressDialog::sayPeerNoDhtConfig()
{
QString title = tr("Peer DHT is Disabled");
QString message = tr("Your Friend has configured Retroshare with DHT Disabled.");
message += "\n\n";
message += tr("You have previously connected to this Friend");
message += "\n";
message += tr("Retroshare has determined that they have DHT switched off");
message += "\n";
message += tr("Without the DHT it is hard for Retroshare to locate your friend");
message += "\n\n";
message += tr("Try importing a fresh Certificate to get up-to-date connection information");
message += "\n\n";
message += tr("If you continue to get this message, please contact developers");
setStatusMessage(MESSAGE_STATUS_PEER_ERROR, title, message);
}
void ConnectProgressDialog::sayInvalidPeer()
{
QString title = tr("Incomplete Friend Details");
QString message = tr("You have imported an incomplete Certificate");
message += "\n\n";
message += tr("Retroshare cannot connect without ths information");
message += "\n\n";
message += tr("Please retry importing the full Certificate");
setStatusMessage(MESSAGE_STATUS_CONFIG_ERROR, title, message);
}
void ConnectProgressDialog::setStatusMessage(uint32_t status, const QString &title, const QString &message)
{
switch(status)
{
case MESSAGE_STATUS_INPROGRESS:
{
QPixmap pm(":/images/graph-blue.png");
ui->statusIcon->setPixmap(pm.scaledToWidth(40));
}
break;
case MESSAGE_STATUS_SUCCESS:
{
QPixmap pm(":/images/graph-downloaded.png");
ui->statusIcon->setPixmap(pm.scaledToWidth(40));
}
break;
case MESSAGE_STATUS_CONFIG_ERROR:
{
QPixmap pm(":/images/graph-downloading.png");
ui->statusIcon->setPixmap(pm.scaledToWidth(40));
}
break;
case MESSAGE_STATUS_PEER_ERROR:
{
QPixmap pm(":/images/graph-checking.png");
ui->statusIcon->setPixmap(pm.scaledToWidth(40));
}
break;
case MESSAGE_STATUS_UNKNOWN_ERROR:
{
QPixmap pm(":/images/graph-checking.png");
ui->statusIcon->setPixmap(pm.scaledToWidth(40));
}
break;
}
ui->statusTitle->setText(title);
ui->textBrowser->setText(message);
}

View File

@ -0,0 +1,102 @@
/*
* Connect Progress Dialog
*
* Copyright 2012-2013 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef _CONNECT_PROGRESS_DIALOG_H
#define _CONNECT_PROGRESS_DIALOG_H
#include <QDialog>
#include "ui_ConnectProgressDialog.h"
class ConnectProgressDialog : public QDialog
{
Q_OBJECT
public:
static void showProgress(const std::string& id);
private:
ConnectProgressDialog(const std::string& id, QWidget *parent = 0, Qt::WFlags flags = 0);
~ConnectProgressDialog();
static ConnectProgressDialog *instance(const std::string& peer_id);
private slots:
void updateStatus();
private:
void initDialog();
void updateNetworkStatus();
void updateContactStatus();
void updateDhtStatus();
void updateLookupStatus();
void updateUdpStatus();
void setStatusMessage(uint32_t status, const QString &title, const QString &message);
// good stuff.
void sayInProgress();
void sayConnected();
// Peer errors.
void sayDenied();
void sayUdpDenied();
void sayPeerOffline();
void sayPeerNoDhtConfig();
// Config errors.
void sayDHTFailed();
void sayDHTOffline();
void sayInvalidPeer();
// Unknown errors.
void sayConnectTimeout();
void sayLookupTimeout();
void sayUdpTimeout();
void sayUdpFailed();
QTimer *mTimer;
uint32_t mState;
std::string mId;
time_t mInitTS;
time_t mContactTS;
uint32_t mContactState;
uint32_t mDhtStatus;
time_t mLookupTS;
uint32_t mLookupStatus;
time_t mUdpTS;
uint32_t mUdpStatus;
/** Qt Designer generated object */
Ui::ConnectProgressDialog *ui;
};
#endif

View File

@ -0,0 +1,316 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConnectProgressDialog</class>
<widget class="QDialog" name="ConnectProgressDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>553</width>
<height>530</height>
</rect>
</property>
<property name="windowTitle">
<string>Connection Progress</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="HeaderFrame" name="headerFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="progressFrame">
<property name="enabled">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Connecting to:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="connectId">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Network </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="NetResult">
<property name="text">
<string>Net Result</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Connect Status</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="ContactResult">
<property name="text">
<string>Contact Result</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>DHT Startup</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QProgressBar" name="DhtProgressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="DhtResult">
<property name="text">
<string>DHT Result</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Peer Lookup</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QProgressBar" name="LookupProgressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="LookupResult">
<property name="text">
<string>Peer Result</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>UDP Setup</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QProgressBar" name="UdpProgressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="UdpResult">
<property name="text">
<string>UDP Result</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="statusIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>1</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>5</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This Widget shows the progress of your connection to your new peer.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;It is helpful for problem-solving.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If you are an expert RS user, or trust that RS will do the right thing&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;you can close it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -431,6 +431,7 @@ void DhtWindow::updateNetPeers()
cpmstr = "Relay VIA " + QString::fromStdString(status.mPeerConnectProxyId);
break;
default:
case RSDHT_TOU_MODE_NONE:
cpmstr = "None";
break;
}

View File

@ -127,6 +127,7 @@
<file>images/graph-downloading.png</file>
<file>images/graph-notdownload.png</file>
<file>images/graph-checking.png</file>
<file>images/graph-blue.png</file>
<file>images/add-share24.png</file>
<file>images/add_24x24.png</file>
<file>images/advsearch_24x24.png</file>

View File

@ -466,6 +466,7 @@ HEADERS += rshare.h \
gui/feeds/SecurityItem.h \
gui/feeds/NewsFeedUserNotify.h \
gui/connect/ConnectFriendWizard.h \
gui/connect/ConnectProgressDialog.h \
gui/groups/CreateGroup.h \
gui/dht/DhtWindow.h \
gui/bwctrl/BwCtrlWindow.h \
@ -519,6 +520,7 @@ FORMS += gui/StartDialog.ui \
gui/ChatLobbyWidget.ui \
gui/connect/ConfCertDialog.ui \
gui/connect/ConnectFriendWizard.ui \
gui/connect/ConnectProgressDialog.ui \
gui/msgs/MessageComposer.ui \
gui/msgs/MessageWindow.ui\
gui/msgs/MessageWidget.ui\
@ -771,6 +773,7 @@ SOURCES += main.cpp \
gui/feeds/SecurityItem.cpp \
gui/feeds/NewsFeedUserNotify.cpp \
gui/connect/ConnectFriendWizard.cpp \
gui/connect/ConnectProgressDialog.cpp \
gui/groups/CreateGroup.cpp \
gui/dht/DhtWindow.cpp \
gui/bwctrl/BwCtrlWindow.cpp \