gboolean nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device) { NMActiveConnectionPrivate *priv; gs_unref_object NMDevice *old_device = NULL; g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE); g_return_val_if_fail (!device || NM_IS_DEVICE (device), FALSE); priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); if (device == priv->device) return TRUE; _LOGD ("set device %s%s%s [%p]", NM_PRINT_FMT_QUOTED (device && nm_device_get_iface (device), "\"", nm_device_get_iface (device), "\"", device ? "(unknown)" : "(null)"), device); old_device = priv->device ? g_object_ref (priv->device) : NULL; _device_cleanup (self); if (device) { /* Device obviously can't be its own master */ g_return_val_if_fail (!priv->master || device != nm_active_connection_get_device (priv->master), FALSE); priv->device = g_object_ref (device); g_signal_connect (device, NM_DEVICE_STATE_CHANGED, G_CALLBACK (device_state_changed), self); g_signal_connect (device, "notify::master", G_CALLBACK (device_master_changed), self); g_signal_connect (device, "notify::" NM_DEVICE_METERED, G_CALLBACK (device_metered_changed), self); if (!priv->assumed) { priv->pending_activation_id = g_strdup_printf ("activation::%p", (void *)self); nm_device_add_pending_action (device, priv->pending_activation_id, TRUE); } } else { /* The ActiveConnection's device can only be cleared after the * connection is activated. */ g_warn_if_fail (priv->state > NM_ACTIVE_CONNECTION_STATE_UNKNOWN); priv->device = NULL; } _notify (self, PROP_INT_DEVICE); g_signal_emit (self, signals[DEVICE_CHANGED], 0, priv->device, old_device); _notify (self, PROP_DEVICES); return TRUE; }
static void add_dnsmasq_nameserver (NMDnsDnsmasq *self, GVariantBuilder *servers, const char *ip, const char *domain) { g_return_if_fail (ip); _LOGD ("adding nameserver '%s'%s%s%s", ip, NM_PRINT_FMT_QUOTED (domain, " for domain \"", domain, "\"", "")); g_variant_builder_open (servers, G_VARIANT_TYPE ("as")); g_variant_builder_add (servers, "s", ip); if (domain) g_variant_builder_add (servers, "s", domain); g_variant_builder_close (servers); }
static NMFirewallManagerCallId _start_request (NMFirewallManager *self, CBInfoOpsType ops_type, const char *iface, const char *zone, NMFirewallManagerAddRemoveCallback callback, gpointer user_data) { NMFirewallManagerPrivate *priv; CBInfo *info; const char *dbus_method; g_return_val_if_fail (NM_IS_FIREWALL_MANAGER (self), NULL); g_return_val_if_fail (iface && *iface, NULL); priv = NM_FIREWALL_MANAGER_GET_PRIVATE (self); info = _cb_info_create (self, ops_type, iface, callback, user_data); _LOGD (info, "firewall zone %s %s:%s%s%s%s", _ops_type_to_string (info->ops_type), iface, NM_PRINT_FMT_QUOTED (zone, "\"", zone, "\"", "default"), _cb_info_is_idle (info) ? " (not running, simulate success)" : ""); if (!_cb_info_is_idle (info)) { switch (ops_type) { case CB_INFO_OPS_ADD: dbus_method = "addInterface"; break; case CB_INFO_OPS_CHANGE: dbus_method = "changeZone"; break; case CB_INFO_OPS_REMOVE: dbus_method = "removeInterface"; break; default: g_assert_not_reached (); } g_dbus_proxy_call (priv->proxy, dbus_method, g_variant_new ("(ss)", zone ? zone : "", iface), G_DBUS_CALL_FLAGS_NONE, 10000, info->dbus.cancellable, _handle_dbus, info); if (!info->callback) { /* if the user did not provide a callback, the call_id is useless. * Especially, the user cannot use the call-id to cancel the request, * because he cannot know whether the request is still pending. * * Hence, returning %NULL doesn't mean that the request could not be started * (the request will always be started). */ return NULL; } } else if (!info->callback) { /* if the user did not provide a callback and firewalld is not running, * there is no point in scheduling an idle-request to fake success. Just * return right away. */ _LOGD (info, "complete: drop request simulating success"); _cb_info_complete_normal (info, NULL); return NULL; } else info->idle.id = g_idle_add (_handle_idle, info); return info; }