[gnome-software] Monitor network status



commit cbc131350288efa98a7674c174c802538bf9796a
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 18 12:58:26 2013 -0400

    Monitor network status
    
    For now, we don't do anything. In the future, we want to hold
    installs until we go online.

 src/gs-application.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index ef731c8..c642f9e 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -48,6 +48,7 @@ struct _GsApplication {
        GsShell         *shell;
        GsUpdateMonitor *update_monitor;
        GsShellSearchProvider *search_provider;
+       GNetworkMonitor *network_monitor;
 };
 
 struct _GsApplicationClass {
@@ -69,6 +70,27 @@ gs_application_monitor_updates (GsApplication *app)
 }
 
 static void
+network_changed_cb (GNetworkMonitor *monitor,
+                   gboolean available,
+                   GsApplication *app)
+{
+       g_debug ("*** Network status change: %s", available ? "online" : "offline");
+}
+
+static void
+gs_application_monitor_network (GsApplication *app)
+{
+       app->network_monitor = g_network_monitor_get_default ();
+
+       g_signal_connect (app->network_monitor, "network-changed",
+                         G_CALLBACK (network_changed_cb), app);
+
+       network_changed_cb (app->network_monitor,
+                           g_network_monitor_get_network_available (app->network_monitor),
+                           app);
+}
+
+static void
 gs_application_initialize_plugins (GsApplication *app)
 {
        static gboolean initialized = FALSE;
@@ -337,6 +359,7 @@ gs_application_startup (GApplication *application)
 
        gs_application_monitor_updates (GS_APPLICATION (application));
        gs_application_provide_search (GS_APPLICATION (application));
+       gs_application_monitor_network (GS_APPLICATION (application));
 }
 
 static void
@@ -359,6 +382,7 @@ gs_application_finalize (GObject *object)
        g_clear_object (&app->update_monitor);
        g_clear_object (&app->profile);
        g_clear_object (&app->search_provider);
+       g_clear_object (&app->network_monitor);
 
        G_OBJECT_CLASS (gs_application_parent_class)->finalize (object);
 }


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