Skip to content

Commit

Permalink
Use notion of selected Protocol
Browse files Browse the repository at this point in the history
- use Protocol value instead of flags isSsl, isHttp, isHttps in the ecFlowUI implementation

Re ECFLOW-1957
  • Loading branch information
marcosbento committed Oct 21, 2024
1 parent bd3425c commit f9cd127
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 329 deletions.
4 changes: 1 addition & 3 deletions Viewer/ecflowUI/src/OverviewProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ void OverviewProvider::serverInfo(VInfoServer* info, std::stringstream& f) {
f << inc << "Host : " << server->host() << "\n";
f << inc << "Port : " << server->port() << "\n";

if (server->isSsl()) {
f << inc << "SSL : enabled\n";
}
f << inc << "Protocol : " << ecf::to_ui_designation(server->protocol()) << " : enabled\n";

if (!server->user().empty()) {
f << inc << "Custom user : " << server->user() << "\n";
Expand Down
70 changes: 19 additions & 51 deletions Viewer/ecflowUI/src/ServerAddDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>294</width>
<height>315</height>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -20,7 +20,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -85,57 +85,41 @@
<widget class="QLineEdit" name="userEdit"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="protocolLabel">
<property name="text">
<string>Use &amp;SSL:</string>
</property>
<property name="buddy">
<cstring>sslCb</cstring>
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="sslCb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<widget class="QRadioButton" name="protocolPlain">
<property name="text">
<string>Use &amp;HTTP:</string>
</property>
<property name="buddy">
<cstring>httpCb</cstring>
<string>TCP/IP</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="httpCb">
<widget class="QRadioButton" name="protocolSsl">
<property name="text">
<string/>
<string>TCP/IP with SSL</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<item row="8" column="1">
<widget class="QRadioButton" name="protocolHttp">
<property name="text">
<string>Use &amp;HTTPS:</string>
</property>
<property name="buddy">
<cstring>httpsCb</cstring>
<string>HTTP</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="httpsCb">
<item row="9" column="1">
<widget class="QRadioButton" name="protocolHttps">
<property name="text">
<string/>
<string>HTTPS</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="MessageLabel" name="sslMessageLabel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
Expand All @@ -145,22 +129,6 @@
</property>
</widget>
</item>
<item row="9" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
Expand All @@ -176,10 +144,10 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -192,10 +160,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand Down
42 changes: 13 additions & 29 deletions Viewer/ecflowUI/src/ServerEditDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -89,57 +89,41 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="sslLabel">
<widget class="QLabel" name="protocolLabel">
<property name="text">
<string>Use &amp;SSL:</string>
</property>
<property name="buddy">
<cstring>sslCh</cstring>
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="sslCh">
<widget class="QRadioButton" name="protocolPlain">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="httpLabel">
<property name="text">
<string>Use &amp;HTTP:</string>
</property>
<property name="buddy">
<cstring>httpCh</cstring>
<string>TCP/IP</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="httpCh">
<widget class="QRadioButton" name="protocolSsl">
<property name="text">
<string/>
<string>TCP/IP with SSL</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="httpsLabel">
<item row="7" column="1">
<widget class="QRadioButton" name="protocolHttp">
<property name="text">
<string>Use &amp;HTTPS:</string>
</property>
<property name="buddy">
<cstring>httpsCh</cstring>
<string>HTTP</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="httpsCh">
<item row="8" column="1">
<widget class="QRadioButton" name="protocolHttps">
<property name="text">
<string/>
<string>HTTPS</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="MessageLabel" name="sslMessageLabel" native="true"/>
</item>
</layout>
Expand Down
57 changes: 13 additions & 44 deletions Viewer/ecflowUI/src/ServerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ ServerHandler::ServerHandler(const std::string& name,
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl,
bool http,
bool https)
ecf::Protocol protocol)
: name_(name),
host_(host),
port_(port),
user_(user),
ssl_(ssl),
http_(http),
https_(https),
protocol_(protocol),
client_(nullptr),
updating_(false),
communicating_(false),
Expand Down Expand Up @@ -188,12 +184,11 @@ void ServerHandler::createClient(bool init) {

bool ssl_enabled = false;
std::string ssl_error;
// bool http_enabled = false;
std::string http_error;

if (client_) {
#ifdef ECF_OPENSSL
if (ssl_) {
if (isSsl()) {
try {
client_->enable_ssl();
ssl_enabled = true;
Expand All @@ -209,20 +204,18 @@ void ServerHandler::createClient(bool init) {
client_->disable_ssl();
}
#endif
if (http_) {
if (isHttp()) {
try {
client_->enable_http();
// http_enabled = true;
}
catch (std::exception& e) {
http_error = std::string(e.what());
}
}

if (https_) {
if (isHttps()) {
try {
client_->enable_https();
// http_enabled = true;
}
catch (std::exception& e) {
http_error = std::string(e.what());
Expand Down Expand Up @@ -274,7 +267,7 @@ void ServerHandler::createClient(bool init) {
}

#ifdef ECF_OPENSSL
if (ssl_ && !ssl_enabled) {
if (isSsl() && !ssl_enabled) {
sslCertificateError(ssl_error);
return;
}
Expand Down Expand Up @@ -329,31 +322,9 @@ void ServerHandler::recreateClient() {
createClient(false);
}

void ServerHandler::setSsl(bool ssl) {
if (ssl != ssl_) {
ssl_ = ssl;

if (connectState_->state() != ConnectState::VersionIncompatible &&
connectState_->state() != ConnectState::FailedClient) {
recreateClient();
}
}
}

void ServerHandler::setHttp(bool http) {
if (http != http_) {
http_ = http;

if (connectState_->state() != ConnectState::VersionIncompatible &&
connectState_->state() != ConnectState::FailedClient) {
recreateClient();
}
}
}

void ServerHandler::setHttps(bool https) {
if (https != https_) {
https_ = https;
void ServerHandler::setProtocol(ecf::Protocol protocol) {
if (protocol != protocol_) {
protocol_ = protocol;

if (connectState_->state() != ConnectState::VersionIncompatible &&
connectState_->state() != ConnectState::FailedClient) {
Expand Down Expand Up @@ -575,10 +546,8 @@ ServerHandler* ServerHandler::addServer(const std::string& name,
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl,
bool http,
bool https) {
auto* sh = new ServerHandler(name, host, port, user, ssl, http, https);
ecf::Protocol protocol) {
auto* sh = new ServerHandler(name, host, port, user, protocol);
return sh;
}

Expand Down Expand Up @@ -1443,7 +1412,7 @@ void ServerHandler::sslIncompatibleServer(const std::string& msg) {
connectState_->state(ConnectState::SslIncompatible);
std::string errStr = "Cannot communicate to server.";
#if ECF_OPENSSL
if (ssl_) {
if (isSsl()) {
errStr += " Server is marked as SSL in the UI. Please check if the server is really SSL-enabled! Also check "
"settings in Manage servers dialogue!";
}
Expand All @@ -1461,7 +1430,7 @@ void ServerHandler::sslIncompatibleServer(const std::string& msg) {

void ServerHandler::sslCertificateError(const std::string& msg) {
#if ECF_OPENSSL
assert(ssl_);
assert(isSsl());
compatibility_ = Incompatible;
stopRefreshTimer();
comQueue_->disable();
Expand Down
Loading

0 comments on commit f9cd127

Please sign in to comment.