On 12/03/2012 05:25 PM, Jakub Filak wrote:
----- Original Message ----- From: "Denys Vlasenko" <[email protected]> To: [email protected] Cc: "Jakub Filak" <[email protected]> Sent: Monday, December 3, 2012 4:46:31 PM Subject: Re: [ABRT PATCH 2/3] introduce Desktop Session Autoreporting 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;If you don't use NM, you won't get dbus proxy and you will go this way. I have to add more comments. Sorry, I though it is obvious and clear enough.+ } + + /* 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. +The above function will always think that network is up. I think it's wrong to demand that NetworkManager must be used for network management.
- if the change is seamless for users without NM, then I wouldn't care about it
abrt-applet examines network state only when the autoreporting event failed for some unknown reason while processing a problem. If applet finds out that network is down, applet pushes this problem to the deferred queue. Therefore the deferred queue won't be used in your case. You can consider the above function as a bonus for the NetworkManager users ;) Should I add a compile time condition for disabling NM code? Do you know a better approach how to get network state in GUI desktop application?
- the dependency is only thru dbus, so it's "weak", there is no point of adding compile time conditions
- if these are the only concerns, then I think it's ok to push it --Jirka
+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. will do
