Skip to content
Closed
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
15 changes: 3 additions & 12 deletions Modules/Panels/WiFi/WiFiNetworksList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,10 @@ NBox {
id: connectedText
anchors.centerIn: parent
text: {
switch (NetworkService.networkConnectivity) {
case "full":
return I18n.tr("wifi.panel.connected");
case "limited":
return I18n.tr("wifi.panel.internet-limited");
case "portal": // Where Captive Portal is detected (User intervention needed)
return I18n.tr("wifi.panel.action-required");
// I assume unknown is for connecting/disconnecting state where connectivity hasn't been determined yet (Shouldn't be visible for long enough to matter)
// and none is for no connectivity at all.
// None and Unknown will return direct output of NetworkService.networkConnectivity
default:
return NetworkService.networkConnectivity;
if (NetworkService.networkConnectivity === "portal") {
return I18n.tr("wifi.panel.action-required"); // Where Captive Portal is detected (User intervention needed)
}
return NetworkService.internetConnectivity ? I18n.tr("wifi.panel.connected") : I18n.tr("wifi.panel.internet-limited");
}
pointSize: Style.fontSizeXXS
color: Color.mOnPrimary
Expand Down
27 changes: 10 additions & 17 deletions Services/Networking/NetworkService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ Singleton {
running: false
command: ["nmcli", "networking", "connectivity", "check"]

property int failedChecks: 0

stdout: StdioCollector {
onStreamFinished: {
const result = text.trim();
Expand All @@ -596,28 +594,25 @@ Singleton {

if (result === "none" && root.networkConnectivity !== result) {
root.networkConnectivity = result;
connectivityCheckProcess.failedChecks = 0;
root.scan();
}

if (result === "full" && root.networkConnectivity !== result) {
root.networkConnectivity = result;
root.internetConnectivity = true;
connectivityCheckProcess.failedChecks = 0;
root.scan();
if (result === "full") {
if (root.networkConnectivity !== result) {
root.networkConnectivity = result;
}
pingCheckProcess.running = true;
}

if ((result === "limited" || result === "portal") && root.networkConnectivity !== result) {
connectivityCheckProcess.failedChecks++;
if (connectivityCheckProcess.failedChecks === 3) {
if (result === "limited" || result === "portal") {
if (root.networkConnectivity !== result) {
root.networkConnectivity = result;
pingCheckProcess.running = true;
}
pingCheckProcess.running = true;
}

if (result === "unknown" && root.networkConnectivity !== result) {
root.networkConnectivity = result;
connectivityCheckProcess.failedChecks = 0;
}
}
}
Expand All @@ -633,16 +628,14 @@ Singleton {

Process {
id: pingCheckProcess
command: ["sh", "-c", "ping -c1 -W2 ping.archlinux.org >/dev/null 2>&1 || " + "ping -c1 -W2 1.1.1.1 >/dev/null 2>&1 || " + "curl -fsI --max-time 5 https://cloudflare.com/cdn-cgi/trace >/dev/null 2>&1"]
command: ["sh", "-c", "ping -c1 -W2 ping.archlinux.org >/dev/null 2>&1 || ping -c1 -W2 1.1.1.1 >/dev/null 2>&1 || curl -fsI --max-time 5 https://cloudflare.com/cdn-cgi/trace >/dev/null 2>&1"]

onExited: function (exitCode, exitStatus) {
if (exitCode === 0) {
connectivityCheckProcess.failedChecks = 0;
root.internetConnectivity = true;
} else {
root.internetConnectivity = false;
Logger.i("Network", "No internet connectivity");
ToastService.showWarning(root.cachedLastConnected, I18n.tr("toast.internet.limited"));
connectivityCheckProcess.failedChecks = 0;
}
root.scan();
}
Expand Down