static void teamd_dbus_appeared (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { NMDeviceTeam *self = NM_DEVICE_TEAM (user_data); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (self); gboolean success; g_return_if_fail (priv->teamd_dbus_watch); _LOGI (LOGD_TEAM, "teamd appeared on D-Bus"); nm_device_queue_recheck_assume (device); /* If another teamd grabbed the bus name while our teamd was starting, * just ignore the death of our teamd and run with the existing one. */ if (priv->teamd_process_watch) { gs_unref_variant GVariant *ret = NULL; guint32 pid; ret = g_dbus_connection_call_sync (connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionUnixProcessID", g_variant_new ("(s)", name_owner), NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, 2000, NULL, NULL); g_variant_get (ret, "(u)", &pid); if (pid != priv->teamd_pid) teamd_cleanup (device, FALSE); } /* Grab a teamd control handle even if we aren't going to use it * immediately. But if we are, and grabbing it failed, fail the * device activation. */ success = ensure_teamd_connection (device); if (nm_device_get_state (device) == NM_DEVICE_STATE_PREPARE) { if (success) nm_device_activate_schedule_stage2_device_config (device); else if (!nm_device_uses_assumed_connection (device)) nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); } }
static void modem_prepare_result (NMModem *modem, gboolean success, NMDeviceStateReason reason, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceState state; state = nm_device_get_state (device); g_return_if_fail (state == NM_DEVICE_STATE_PREPARE); if (success) nm_device_activate_schedule_stage2_device_config (device); else nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); }
static void companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_data) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); gboolean scanning; if (!priv->stage1_waiting) return; g_object_get (companion, "scanning", &scanning, NULL); if (!scanning) { priv->stage1_waiting = FALSE; nm_device_activate_schedule_stage2_device_config (NM_DEVICE (self)); } }
static void teamd_dbus_appeared (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { NMDevice *dev = NM_DEVICE (user_data); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); g_return_if_fail (priv->teamd_dbus_watch); nm_log_info (LOGD_TEAM, "(%s): teamd appeared on D-Bus", nm_device_get_iface (dev)); teamd_timeout_remove (dev); #if WITH_TEAMDCTL if (!ensure_teamd_connection (dev)) { nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED); return; } #endif nm_device_activate_schedule_stage2_device_config (dev); }
static void stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); GError *error = NULL; dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID); if (!error) nm_device_activate_schedule_stage2_device_config (device); else { const char *required_secret = NULL; gboolean retry_secret = FALSE; if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN)) required_secret = NM_SETTING_GSM_PIN; else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG)) { clear_pin (device); required_secret = NM_SETTING_GSM_PIN; retry_secret = TRUE; } else nm_warning ("GSM modem connection failed: %s", error->message); if (required_secret) { nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_act_request_get_secrets (nm_device_get_act_request (device), NM_SETTING_GSM_SETTING_NAME, retry_secret, SECRETS_CALLER_GSM, required_secret, NULL); } else nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, translate_mm_error (error)); g_error_free (error); } }
static void wmx_state_change_cb (struct wmxsdk *wmxsdk, WIMAX_API_DEVICE_STATUS new_status, WIMAX_API_DEVICE_STATUS old_status, WIMAX_API_STATUS_REASON reason, WIMAX_API_CONNECTION_PROGRESS_INFO progress, void *user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); NMDeviceState state; const char *iface; gboolean old_available = FALSE; const char *nsp_name = NULL; iface = nm_device_get_iface (NM_DEVICE (self)); nm_log_info (LOGD_WIMAX, "(%s): wimax state change %s -> %s (%s (%d))", iface, iwmx_sdk_dev_status_to_str (old_status), iwmx_sdk_dev_status_to_str (new_status), iwmx_sdk_con_progress_to_str (progress), progress); if (new_status == old_status) return; state = nm_device_get_state (NM_DEVICE (self)); old_available = nm_device_is_available (NM_DEVICE (self)); priv->status = new_status; if (priv->current_nsp) nsp_name = nm_wimax_nsp_get_name (priv->current_nsp); switch (new_status) { case WIMAX_API_DEVICE_STATUS_UnInitialized: case WIMAX_API_DEVICE_STATUS_RF_OFF_HW_SW: case WIMAX_API_DEVICE_STATUS_RF_OFF_HW: case WIMAX_API_DEVICE_STATUS_RF_OFF_SW: if (priv->wimaxd_enabled) { priv->wimaxd_enabled = FALSE; if (update_availability (self, old_available)) return; } break; case WIMAX_API_DEVICE_STATUS_Connecting: case WIMAX_API_DEVICE_STATUS_Data_Connected: /* If for some reason we're initially connected, force a disconnect here */ if (state < NM_DEVICE_STATE_DISCONNECTED) force_disconnect (self, wmxsdk); /* Fall through */ case WIMAX_API_DEVICE_STATUS_Ready: case WIMAX_API_DEVICE_STATUS_Scanning: if (priv->wimaxd_enabled == FALSE) { priv->wimaxd_enabled = TRUE; if (update_availability (self, old_available)) return; } break; default: nm_log_warn (LOGD_WIMAX, "(%s): unhandled WiMAX device state %d", iface, new_status); break; } /* Handle activation success and failure */ if (nm_device_is_activating (NM_DEVICE (self))) { if (new_status == WIMAX_API_DEVICE_STATUS_Data_Connected) { /* Success */ clear_activation_timeout (self); nm_log_info (LOGD_WIMAX, "(%s): connected to '%s'", iface, nsp_name); nm_device_activate_schedule_stage3_ip_config_start (NM_DEVICE (self)); return; } if (priv->connect_failed) { /* Connection attempt failed */ nm_log_info (LOGD_WIMAX, "(%s): connection to '%s' failed: (%d) %s", iface, nsp_name, reason, iwmx_sdk_reason_to_str (reason)); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); return; } /* If stage2 was postponed because the device was scanning or something, * then check if we need to move to stage2 now that the device might be * ready. */ if (state == NM_DEVICE_STATE_PREPARE && priv->prepare_done) { if ( new_status == WIMAX_API_DEVICE_STATUS_Ready || new_status == WIMAX_API_DEVICE_STATUS_Connecting) { nm_device_activate_schedule_stage2_device_config (NM_DEVICE (self)); return; } } } /* Handle disconnection */ if (state == NM_DEVICE_STATE_ACTIVATED) { if ( old_status == WIMAX_API_DEVICE_STATUS_Data_Connected && new_status < WIMAX_API_DEVICE_STATUS_Connecting) { nm_log_info (LOGD_WIMAX, "(%s): disconnected from '%s': (%d) %s", iface, nsp_name, reason, iwmx_sdk_reason_to_str (reason)); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); } } }