Commit 9bc83ca1 authored by Thomas Haller's avatar Thomas Haller

libnm: implement nm_client_check_connectivity() by using GDBusConnection directly

Note that nm_client_check_connectivity() has this odd behavior of
updating the connectivity state right away. We keep doing that.
parent 2f21e96e
......@@ -758,13 +758,38 @@ nm_client_check_connectivity (NMClient *client,
GCancellable *cancellable,
GError **error)
{
gs_unref_variant GVariant *ret = NULL;
guint32 connectivity;
g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN);
if (!_nm_client_check_nm_running (client, error))
ret = _nm_object_dbus_call_sync (client,
cancellable,
NM_DBUS_PATH,
NM_DBUS_INTERFACE,
"CheckConnectivity",
g_variant_new ("()"),
G_VARIANT_TYPE ("(u)"),
G_DBUS_CALL_FLAGS_NONE,
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
TRUE,
error);
if (!ret)
return NM_CONNECTIVITY_UNKNOWN;
return nm_manager_check_connectivity (NM_CLIENT_GET_PRIVATE (client)->manager,
cancellable, error);
g_variant_get (ret,
"(u)",
&connectivity);
/* upon receiving the synchronous response, we hack the NMClient state
* and update the property outside the ordered D-Bus messages (like
* "PropertiesChanged" signals).
*
* This is really ugly, we shouldn't do this. */
_nm_manager_set_connectivity_hack (NM_CLIENT_GET_PRIVATE (client)->manager,
connectivity);
return connectivity;
}
static void
......
......@@ -629,30 +629,15 @@ nm_manager_get_connectivity (NMManager *manager)
return NM_MANAGER_GET_PRIVATE (manager)->connectivity;
}
NMConnectivityState
nm_manager_check_connectivity (NMManager *manager,
GCancellable *cancellable,
GError **error)
void
_nm_manager_set_connectivity_hack (NMManager *manager,
guint32 connectivity)
{
NMManagerPrivate *priv;
guint32 connectivity;
g_return_val_if_fail (NM_IS_MANAGER (manager), NM_CONNECTIVITY_UNKNOWN);
priv = NM_MANAGER_GET_PRIVATE (manager);
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
if (nmdbus_manager_call_check_connectivity_sync (priv->proxy,
&connectivity,
cancellable, error)) {
if (connectivity != priv->connectivity) {
priv->connectivity = connectivity;
g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY);
}
return connectivity;
}
else {
if (error && *error)
g_dbus_error_strip_remote_error (*error);
return NM_CONNECTIVITY_UNKNOWN;
if ((NMConnectivityState) connectivity != priv->connectivity) {
priv->connectivity = (NMConnectivityState) connectivity;
g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY);
}
}
......
......@@ -118,10 +118,9 @@ NMClientPermissionResult nm_manager_get_permission_result (NMManager *manager,
NMConnectivityState nm_manager_get_connectivity (NMManager *manager);
_NM_DEPRECATED_SYNC_METHOD_INTERNAL
NMConnectivityState nm_manager_check_connectivity (NMManager *manager,
GCancellable *cancellable,
GError **error);
void _nm_manager_set_connectivity_hack (NMManager *manager,
guint32 connectivity);
void nm_manager_check_connectivity_async (NMManager *manager,
GCancellable *cancellable,
GAsyncReadyCallback callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment