mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added empty rsFriendServer struct and basic UI functionality
This commit is contained in:
parent
3f6503dfc3
commit
21ea281df4
@ -145,6 +145,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
|
||||
retroshare/rsrtt.h \
|
||||
retroshare/rsconfig.h \
|
||||
retroshare/rsversion.h \
|
||||
retroshare/rsfriendserver.h \
|
||||
retroshare/rsservicecontrol.h \
|
||||
retroshare/rsgxsdistsync.h
|
||||
|
||||
|
20
libretroshare/src/retroshare/rsfriendserver.h
Normal file
20
libretroshare/src/retroshare/rsfriendserver.h
Normal file
@ -0,0 +1,20 @@
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include "util/rstime.h"
|
||||
|
||||
class RsFriendServer
|
||||
{
|
||||
public:
|
||||
void start() {}
|
||||
void stop() {}
|
||||
|
||||
void checkServerAddress_async(const std::string&,uint16_t, const std::function<void (bool result_status)>& callback)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
callback(true);
|
||||
}
|
||||
void setServerAddress(const std::string&,uint16_t) {}
|
||||
void setFriendsToRequest(uint32_t) {}
|
||||
};
|
||||
|
||||
extern RsFriendServer *rsFriendServer;
|
@ -17,9 +17,8 @@ public:
|
||||
{
|
||||
setPriorityLevel(QOS_PRIORITY_DEFAULT) ;
|
||||
}
|
||||
virtual void clear() override;
|
||||
|
||||
virtual ~RsFriendServerItem() {}
|
||||
virtual void clear() override {}
|
||||
};
|
||||
|
||||
class RsFriendServerClientPublishItem: public RsFriendServerItem
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -26,9 +26,21 @@
|
||||
|
||||
class FriendServerControl : public QWidget, public Ui::FriendServerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FriendServerControl(QWidget *parent = 0);
|
||||
virtual ~FriendServerControl();
|
||||
public:
|
||||
FriendServerControl(QWidget *parent = 0);
|
||||
virtual ~FriendServerControl();
|
||||
|
||||
protected slots:
|
||||
void onOnOffClick(bool b);
|
||||
void onOnionAddressEdit(const QString&);
|
||||
void onNbFriendsToRequestsChanged(int n);
|
||||
void checkServerAddress();
|
||||
|
||||
private:
|
||||
void updateFriendServerStatusIcon(bool ok);
|
||||
|
||||
QTimer *mConnectionCheckTimer;
|
||||
QMovie *mCheckingServerMovie;
|
||||
};
|
||||
|
@ -74,6 +74,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="serverStatusCheckResult_LB">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="torServerStatus_LB">
|
||||
<property name="text">
|
||||
@ -83,6 +90,43 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Server port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="torServerPort_SB">
|
||||
<property name="minimum">
|
||||
<number>1025</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1729</number>
|
||||
</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">
|
||||
<property name="orientation">
|
||||
|
@ -89,9 +89,9 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent)
|
||||
ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||
|
||||
ui.tabWidget->setTabPosition(QTabWidget::North);
|
||||
ui.tabWidget->addTab(friendServerControl = new FriendServerControl(),QIcon(IMAGE_PEERS), tr("Friend Server"));
|
||||
ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Network graph"));
|
||||
ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Keyring"));
|
||||
ui.tabWidget->addTab(friendServerControl = new FriendServerControl(),QIcon(IMAGE_PEERS), tr("Friend Server"));
|
||||
|
||||
ui.tabWidget->hideCloseButton(0);
|
||||
ui.tabWidget->hideCloseButton(1);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>712</width>
|
||||
<height>502</height>
|
||||
<width>738</width>
|
||||
<height>540</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="ServerPageVLayout">
|
||||
|
Loading…
Reference in New Issue
Block a user