On 11/28/2012 06:39 PM, Jakub Filak wrote:
> +static bool is_networking_enabled(void)
> +{
> + GError *error = NULL;
> +
> + /* Create a D-Bus proxy to get the object properties from the NM Manager
> + * object. NM_DBUS_* defines are from NetworkManager.h.
> + */
> + const int flags = G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
> + | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS;
> +
> + GDBusProxy *props_proxy = g_dbus_proxy_new_sync(g_system_bus,
> + flags,
> + NULL /* GDBusInterfaceInfo */,
> + NM_DBUS_SERVICE,
> + NM_DBUS_PATH,
> + DBUS_INTERFACE_PROPERTIES,
> + NULL /* GCancellable */,
> + &error);
> +
> + if (!props_proxy)
> + {
> + error_msg ("Failed to get NetworkManager proxy: %s", error->message);
> + g_error_free (error);
> + return true;
> + }
> +
> + /* Get the ActiveConnections property from the NM Manager object */
> + GVariant *const value = g_dbus_proxy_call_sync (props_proxy,
> + "Get",
> + g_variant_new("(ss)", NM_DBUS_INTERFACE,
> "State"),
> + G_DBUS_PROXY_FLAGS_NONE,
> + -1 /* timeout: use proxy default */,
> + NULL /* GCancellable */,
> + &error);
> +
> + bool ret = false;
> + if (!error)
> + /* sinks the value */
> + ret = nm_state_is_connected(value);
> + else
> + {
> + error_msg ("Failed to Get State property: %s", error->message);
> + g_error_free (error);
> + }
> +
> + g_object_unref(props_proxy);
> +
> + return ret;
> +}
On my machine I don't use NetworkManager.
The above function will always think that network is down.
I think it's wrong to demand that NetworkManager must be used
for network management.
> +static void show_problem_list_notification(GList *problems, int flags);
> +
> +static gboolean process_deferred_queue_timeout_fn(GList *queue)
> +{
> + g_deferred_timeout = 0;
> + show_problem_list_notification(queue, /* process these crashes as new
> crashes */ 0);
> +
> + return FALSE;
> +}
Returning FALSE removes the g_deferred_timeout source?
Please add a comment which says so.
--
vda