Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nit: Cleanup "BackendFailures" in controller.cpp #10013

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,6 @@ bool Controller::processNextStep() {
emit readyToUpdate();
return true;
}

if (nextStep == BackendFailure) {
emit readyToBackendFailure();
return true;
}

return false;
}

Expand Down Expand Up @@ -946,24 +940,6 @@ bool Controller::switchServers(const ServerData& serverData) {
return true;
}

void Controller::backendFailure() {
logger.error() << "backend failure";

if (m_state == StateInitializing || m_state == StateOff) {
emit readyToBackendFailure();
return;
}

m_nextStep = BackendFailure;

if (m_state == StateOn || m_state == StateOnPartial ||
m_state == StateSwitching || m_state == StateSilentSwitching ||
m_state == StateConnecting || m_state == StateConfirming) {
deactivate();
return;
}
}

QString Controller::currentServerString() const {
return QString("%1-%2-%3-%4")
.arg(m_serverData.exitCountryCode(), m_serverData.exitCityName(),
Expand Down
3 changes: 0 additions & 3 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Controller : public QObject, public LogSerializer {
void captivePortalPresent();
void captivePortalGone();
bool switchServers(const ServerData& serverData);
void backendFailure();
void updateRequired();
void deleteOSTunnelConfig();
void startHandshakeTimer();
Expand Down Expand Up @@ -148,7 +147,6 @@ class Controller : public QObject, public LogSerializer {
void recordDataTransferTelemetry();
void readyToQuit();
void readyToUpdate();
void readyToBackendFailure();
void readyToServerUnavailable(bool pingReceived);
void activationBlockedForCaptivePortal();
void isDeviceConnectedChanged();
Expand Down Expand Up @@ -191,7 +189,6 @@ class Controller : public QObject, public LogSerializer {
Quit,
Update,
Disconnect,
BackendFailure,
};

NextStep m_nextStep = None;
Expand Down
25 changes: 6 additions & 19 deletions src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,6 @@ MozillaVPN::MozillaVPN() : App(nullptr), m_private(new MozillaVPNPrivate()) {

connect(&m_private->m_controller, &Controller::readyToUpdate, this,
[this]() { setState(StateUpdateRequired); });

connect(&m_private->m_controller, &Controller::readyToBackendFailure, this,
[this]() {
TaskScheduler::deleteTasks();
setState(StateBackendFailure);
});

connect(&m_private->m_controller, &Controller::readyToServerUnavailable, this,
[](bool pingReceived) {
NotificationHandler::instance()->serverUnavailableNotification(
Expand Down Expand Up @@ -1148,11 +1141,12 @@ void MozillaVPN::heartbeatCompleted(bool success) {
// for the user to do and it may not affect the connectivity at all so it is
// not necessary to take additional actions.
if (!success && state() == StateAuthenticating) {
m_private->m_controller.backendFailure();
TaskScheduler::deleteTasks();
setState(StateHeartbeatFailure);
return;
}

if (state() != StateBackendFailure) {
if (state() != StateHeartbeatFailure) {
return;
}

Expand Down Expand Up @@ -1447,9 +1441,10 @@ void MozillaVPN::registerNavigatorScreens() {
});

Navigator::registerScreen(
MozillaVPN::ScreenBackendFailure, Navigator::LoadPolicy::LoadTemporarily,
MozillaVPN::ScreenHeartbeatFailure,
Navigator::LoadPolicy::LoadTemporarily,
"qrc:/qt/qml/Mozilla/VPN/screens/ScreenBackendFailure.qml",
QVector<int>{MozillaVPN::StateBackendFailure},
QVector<int>{MozillaVPN::StateHeartbeatFailure},
[](int*) -> int8_t { return 0; }, []() -> bool { return false; });

Navigator::registerScreen(
Expand Down Expand Up @@ -1880,14 +1875,6 @@ void MozillaVPN::registerInspectorCommands() {
AddonManager::instance()->fetch();
return QJsonObject();
});

InspectorHandler::registerCommand(
"force_backend_failure", "Force a backend failure", 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually a force_heartbeat_command aswell, so both did the same things 🫠

[](InspectorHandler*, const QList<QByteArray>&) {
MozillaVPN::instance()->controller()->backendFailure();
return QJsonObject();
});

InspectorHandler::registerCommand(
"force_captive_portal_check", "Force a captive portal check", 0,
[](InspectorHandler*, const QList<QByteArray>&) {
Expand Down
4 changes: 2 additions & 2 deletions src/mozillavpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class MozillaVPN final : public App {
public:
enum CustomState {
StateDeviceLimit = StateCustom + 1,
StateBackendFailure,
StateHeartbeatFailure,
StateUpdateRequired,
};
Q_ENUM(CustomState);

enum CustomScreen {
ScreenAuthenticating = Navigator::ScreenCustom + 1,
ScreenAuthenticationInApp,
ScreenBackendFailure,
ScreenHeartbeatFailure,
ScreenBillingNotAvailable,
ScreenCaptivePortal,
ScreenCrashReporting,
Expand Down
6 changes: 6 additions & 0 deletions src/ui/screens/ScreenBackendFailure.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import Mozilla.Shared 1.0
import Mozilla.VPN 1.0
import components 0.1

/**
* This screen is an error that should be triggered
* whenever we have a hearbeatfailure.
* Note: we did not rename the file as that would nuke
* translations at this point in time.
**/
MZStackView {
id: stackview

Expand Down
2 changes: 0 additions & 2 deletions tests/qml/moccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ void Controller::getStatus(

void Controller::quit() {}

void Controller::backendFailure() {}

void Controller::captivePortalPresent() {}

void Controller::captivePortalGone() {}
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/moccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void Controller::getStatus(

void Controller::quit() {}

void Controller::backendFailure() {}

void Controller::captivePortalPresent() {}

void Controller::captivePortalGone() {}
Expand Down
Loading