From 9cacf2e1ff52a8c5a3e90c4271c56e357ba57367 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 16 Feb 2017 17:38:46 +0000 Subject: Remove doConnectionTestAsync() The connection test uses the network-available property and a URI check, but the network-available property is set to TRUE even when the connection is local or behind a captive portal, which means that the test has different behaviours than just a simple connectivity check as performed by NetworkManager. https://phabricator.endlessm.com/T15612 --- overrides/Endless.js | 2 -- overrides/endless_private/connection_test.js | 46 ---------------------------- 2 files changed, 48 deletions(-) delete mode 100644 overrides/endless_private/connection_test.js diff --git a/overrides/Endless.js b/overrides/Endless.js index a835838..67d1efb 100644 --- a/overrides/Endless.js +++ b/overrides/Endless.js @@ -24,7 +24,6 @@ function getCurrentFileDir() { imports.searchPath.unshift(getCurrentFileDir()); const AssetButton = imports.endless_private.asset_button; -const ConnectionTest = imports.endless_private.connection_test; const SearchBox = imports.endless_private.search_box; const TopbarHomeButton = imports.endless_private.topbar_home_button; const TopbarNavButton = imports.endless_private.topbar_nav_button; @@ -34,7 +33,6 @@ function _init() { Endless = this; Endless.getCurrentFileDir = getCurrentFileDir; Endless.AssetButton = AssetButton.AssetButton; - Endless.doConnectionTestAsync = ConnectionTest.doConnectionTestAsync; Endless.SearchBox = SearchBox.SearchBox; Endless.TopbarHomeButton = TopbarHomeButton.TopbarHomeButton; Endless.TopbarNavButton = TopbarNavButton.TopbarNavButton; diff --git a/overrides/endless_private/connection_test.js b/overrides/endless_private/connection_test.js deleted file mode 100644 index ce2e0f9..0000000 --- a/overrides/endless_private/connection_test.js +++ /dev/null @@ -1,46 +0,0 @@ -const Gio = imports.gi.Gio; - -// Performs a connection test by first looking for an available connection, and -// performing a ping test with address parameters specified by hostname, scheme, -// and port. The test is performed asynchronously. -// successCallback, failureCallback, and errorCallback are optional parameters -// and are called in their relevent outcome cases. If the ping test completed, -// the userData will be passed to the callbacks. Additionally, the errorCallback -// will recieve the error as the first argument. -// If an errorCallback is not provided, errors will be re-thrown (with the -// exception of a Gio.ResolverError, which is a connection failure). -function doConnectionTestAsync(hostname, scheme, port, connectionSuccessCallback, - connectionFailureCallback, - errorCallback) { - let network_monitor = Gio.NetworkMonitor.get_default(); - let network_address = new Gio.NetworkAddress({ - 'hostname': hostname, - 'scheme': scheme, - 'port': port - }); - - if (network_monitor.get_network_available()) { - network_monitor.can_reach_async(network_address, null, - function(userData, asyncResult) { - try { - let ping_success = network_monitor. - can_reach_finish(asyncResult, null); - if (ping_success && connectionSuccessCallback) { - connectionSuccessCallback(userData); - } else if (!ping_success && connectionFailureCallback) { - connectionFailureCallback(userData); - } - } catch (err) { - if (err instanceof Gio.ResolverError) { - connectionFailureCallback(userData); - } else if (errorCallback) { - errorCallback(err, userData); - } else { - throw err; - } - } - }); - } else if (connectionFailureCallback) { - connectionFailureCallback(); - } -} -- cgit v1.2.3