[gnome-maps/wip/mlundblad/force-online-option] application: Add force online option



commit f827086bcb0cc8d0365346abe934d2d9e32661c6
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Oct 29 23:16:11 2019 +0100

    application: Add force online option
    
    Add command line option to ignore
    network monitor state.
    This is intended to work-around
    problematic setups not compatible
    with NetworkManager, such as some
    proxies and VPN clients.

 src/application.js | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/application.js b/src/application.js
index 58d15c33..a4bee15b 100644
--- a/src/application.js
+++ b/src/application.js
@@ -97,6 +97,13 @@ var Application = GObject.registerClass({
         this.add_main_option('version', 'v'.charCodeAt(0), GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
                              _("Show the version of the program"), null);
 
+        this.add_main_option('force-online',
+                             0,
+                             GLib.OptionFlags.NONE,
+                             GLib.OptionArg.NONE,
+                             _("Ignore network availability"),
+                             null);
+
         this.connect('handle-local-options', (app, options) => {
             if (options.contains('local')) {
                 let variant = options.lookup_value('local', null);
@@ -108,6 +115,8 @@ var Application = GObject.registerClass({
                  * leaving the running instance unaffected
                  */
                 return 0;
+            } else if (options.contains('force-online')) {
+                this._forceOnline = true;
             }
 
             return -1;
@@ -115,7 +124,9 @@ var Application = GObject.registerClass({
     }
 
     _checkNetwork() {
-        this.connected = networkMonitor.connectivity === Gio.NetworkConnectivity.FULL;
+        this.connected =
+            this._forceOnline ||
+            networkMonitor.connectivity === Gio.NetworkConnectivity.FULL;
     }
 
     _showContact(id) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]