mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 17:13:58 -05:00
added empty rsFriendServer struct and basic UI functionality
This commit is contained in:
parent
3f6503dfc3
commit
21ea281df4
8 changed files with 166 additions and 17 deletions
|
|
@ -18,24 +18,97 @@
|
|||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <QTimer>
|
||||
#include <QMovie>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include "retroshare/rsfriendserver.h"
|
||||
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/common/FilesDefs.h"
|
||||
|
||||
#include "FriendServerControl.h"
|
||||
//#include <retroshare/rsfriendserver.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
RsFriendServer *rsFriendServer = new RsFriendServer;
|
||||
|
||||
#define ICON_STATUS_UNKNOWN ":/images/ledoff1.png"
|
||||
#define ICON_STATUS_OK ":/images/ledon1.png"
|
||||
|
||||
/** Constructor */
|
||||
FriendServerControl::FriendServerControl(QWidget *parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
// /* Hide Settings frame */
|
||||
// connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
||||
// connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
||||
// connect( ui.freezeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setFreezeState(bool)));
|
||||
// connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString)));
|
||||
mConnectionCheckTimer = new QTimer;
|
||||
|
||||
QObject::connect(mConnectionCheckTimer,SIGNAL(timeout()),this,SLOT(checkServerAddress()));
|
||||
QObject::connect(torServerAddress_LE,SIGNAL(textChanged(const QString&)),this,SLOT(onOnionAddressEdit(const QString&)));
|
||||
|
||||
mCheckingServerMovie = new QMovie(":/images/loader/circleball-16.gif");
|
||||
|
||||
updateFriendServerStatusIcon(false);
|
||||
}
|
||||
|
||||
FriendServerControl::~FriendServerControl()
|
||||
{
|
||||
delete mCheckingServerMovie;
|
||||
delete mConnectionCheckTimer;
|
||||
}
|
||||
|
||||
void FriendServerControl::onOnOffClick(bool b)
|
||||
{
|
||||
if(b)
|
||||
rsFriendServer->start();
|
||||
else
|
||||
rsFriendServer->stop();
|
||||
}
|
||||
|
||||
void FriendServerControl::onOnionAddressEdit(const QString&)
|
||||
{
|
||||
// Setup timer to auto-check the friend server address
|
||||
|
||||
mConnectionCheckTimer->stop();
|
||||
mConnectionCheckTimer->setSingleShot(true);
|
||||
mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time.
|
||||
|
||||
mConnectionCheckTimer->start();
|
||||
|
||||
serverStatusCheckResult_LB->setMovie(mCheckingServerMovie);
|
||||
mCheckingServerMovie->start();
|
||||
}
|
||||
|
||||
void FriendServerControl::checkServerAddress()
|
||||
{
|
||||
rsFriendServer->checkServerAddress_async(torServerAddress_LE->text().toStdString(),torServerPort_SB->value(),
|
||||
[this](bool test_result)
|
||||
{
|
||||
RsQThreadUtils::postToObject( [=]() { updateFriendServerStatusIcon(test_result); },this);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void FriendServerControl::onNbFriendsToRequestsChanged(int n)
|
||||
{
|
||||
rsFriendServer->setFriendsToRequest(n);
|
||||
}
|
||||
|
||||
void FriendServerControl::updateFriendServerStatusIcon(bool ok)
|
||||
{
|
||||
if(ok)
|
||||
{
|
||||
torServerStatus_LB->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ;
|
||||
torServerStatus_LB->setToolTip(tr("Friend server is currently reachable.")) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
torServerStatus_LB->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ;
|
||||
torServerStatus_LB->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ;
|
||||
}
|
||||
mCheckingServerMovie->stop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue