fixed initing of profile passphrase for friend server manager

This commit is contained in:
csoler 2022-01-16 21:17:10 +01:00
parent 763eeffe25
commit eefbd8a710
6 changed files with 107 additions and 58 deletions

@ -1 +1 @@
Subproject commit 89b4d9c3352c02630cd555918515b1412b3264ff
Subproject commit f0300848539b3decd7034e5c221eed33c1c784bc

View File

@ -21,9 +21,9 @@
#ifndef _SEARCHDIALOG_H
#define _SEARCHDIALOG_H
#include <retroshare/rstypes.h>
#include "retroshare/rstypes.h"
#include "ui_SearchDialog.h"
#include <retroshare-gui/mainpage.h>
#include "retroshare-gui/mainpage.h"
class AdvancedSearchDialog;
class RSTreeWidgetItemCompareRole;

View File

@ -20,12 +20,14 @@
#include <QTimer>
#include <QMovie>
#include <QMessageBox>
#include <QTcpSocket>
#include "retroshare/rsfriendserver.h"
#include "retroshare/rstor.h"
#include "util/qtthreadsutils.h"
#include "util/misc.h"
#include "gui/common/FilesDefs.h"
#include "FriendServerControl.h"
@ -37,7 +39,7 @@
/** Constructor */
FriendServerControl::FriendServerControl(QWidget *parent)
: QWidget(parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
@ -48,6 +50,22 @@ FriendServerControl::FriendServerControl(QWidget *parent)
return;
}
int H = QFontMetricsF(torServerAddress_LE->font()).height();
QString help_str = tr("\
<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Friend Server</h1> \
<p>This configuration panel allows you to specify the onion address of a \
friend server. Retroshare will talk to that server anonymously through Tor \
and use it to acquire a fixed number of friends.</p> \
<p>The friend server will continue supplying new friends until that number is reached \
in particular if you add your own friends manually, the friend server may become useless \
and you will save bandwidth disabling it. When disabling it, you will keep existing friends.</p> \
<p>The friend server only knows your peer ID and profile public key. It doesn't know your IP address.</p> \
"
).arg(QString::number(2*H), QString::number(2*H)) ;
registerHelpButton(helpButton,help_str,"Friend Server") ;
mConnectionCheckTimer = new QTimer;
// init values
@ -69,18 +87,6 @@ FriendServerControl::FriendServerControl(QWidget *parent)
serverStatusCheckResult_LB->setMovie(mCheckingServerMovie);
updateFriendServerStatusIcon(false);
updateTorProxyInfo();
}
void FriendServerControl::updateTorProxyInfo()
{
std::string friend_proxy_address;
uint16_t friend_proxy_port;
RsTor::getProxyServerInfo(friend_proxy_address,friend_proxy_port);
torProxyPort_SB->setValue(friend_proxy_port);
torProxyAddress_LE->setText(QString::fromStdString(friend_proxy_address));
}
FriendServerControl::~FriendServerControl()
@ -92,7 +98,16 @@ FriendServerControl::~FriendServerControl()
void FriendServerControl::onOnOffClick(bool b)
{
if(b)
{
if(passphrase_LE->text().isNull())
{
QMessageBox::critical(nullptr,tr("Missing profile passphrase."),tr("Your profile passphrase is missing. Please enter is in the field below before enabling the friend server."));
whileBlocking(friendServerOnOff_CB)->setCheckState(Qt::Unchecked);
return;
}
rsFriendServer->setProfilePassphrase(passphrase_LE->text().toStdString());
rsFriendServer->startServer();
}
else
rsFriendServer->stopServer();
}

View File

@ -22,9 +22,10 @@
#include <QGraphicsScene>
#include "retroshare-gui/mainpage.h"
#include "ui_FriendServerControl.h"
class FriendServerControl : public QWidget, public Ui::FriendServerControl
class FriendServerControl : public MainPage, public Ui::FriendServerControl
{
Q_OBJECT
@ -37,7 +38,6 @@ protected slots:
void onOnionAddressEdit(const QString&);
void onOnionPortEdit(int);
void onNbFriendsToRequestsChanged(int n);
void updateTorProxyInfo();
void checkServerAddress();
private:

View File

@ -12,11 +12,48 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="friendServerOnOff_CB">
<property name="text">
<string>On/Off</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="friendServerOnOff_CB">
<property name="text">
<string>On/Off</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<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="QToolButton" name="helpButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
@ -72,13 +109,22 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter here the onion address of the Friend Server that was given to you. The address will be automatically checked after you enter it and a green bullet will appear if the server is online.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>.onion</string>
</property>
<property name="placeholderText">
<string>Onion address of the friend server</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="torServerPort_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Communication port of the server. You usually get a server address as somestring.onion:port. The port is the number right after &amp;quot;:&amp;quot;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>1025</number>
</property>
@ -107,49 +153,35 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Tor proxy address:</string>
<string>Retroshare passphrase:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="torProxyAddress_LE">
<property name="text">
<string>127.0.0.1</string>
<widget class="QLineEdit" name="passphrase_LE">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Your Retroshare login passphrase is needed to ensure the security of data exchange with the friend server.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>Your retroshare passphrase</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="torProxyPort_SB">
<property name="minimum">
<number>1025</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>9050</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -178,6 +210,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -123,7 +123,7 @@ void StartDialog::loadPerson()
rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ;
rsNotify->setDisableAskPassword(true);
bool res = Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ;
bool res = Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ;
rsNotify->setDisableAskPassword(false);
rsNotify->clearPgpPassphrase();