static void
get_secrets_cb (GtkDialog *dialog,
                gint response,
                gpointer user_data)
{
	SecretsRequest *req = user_data;
	MobileHelperSecretsInfo *info = (MobileHelperSecretsInfo *) req;
	GError *error = NULL;

	if (response == GTK_RESPONSE_OK) {
		if (info->capability == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
			NMSettingGsm *setting;

			setting = nm_connection_get_setting_gsm (req->connection);
			if (setting) {
				g_object_set (G_OBJECT (setting),
				              info->secret_name, gtk_entry_get_text (info->secret_entry),
				              NULL);
			} else {
				error = g_error_new (NM_SECRET_AGENT_ERROR,
				                     NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
				                     "%s.%d (%s): no GSM setting",
				                     __FILE__, __LINE__, __func__);
			}
		} else if (info->capability == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
				NMSettingCdma *setting;

				setting = nm_connection_get_setting_cdma (req->connection);
				if (setting) {
					g_object_set (G_OBJECT (setting),
					              info->secret_name, gtk_entry_get_text (info->secret_entry),
					              NULL);
				} else {
					error = g_error_new (NM_SECRET_AGENT_ERROR,
					                     NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
					                     "%s.%d (%s): no CDMA setting",
					                     __FILE__, __LINE__, __func__);
				}
		} else
			g_assert_not_reached ();
	} else {
		error = g_error_new (NM_SECRET_AGENT_ERROR,
		                     NM_SECRET_AGENT_ERROR_USER_CANCELED,
		                     "%s.%d (%s): canceled",
		                     __FILE__, __LINE__, __func__);
	}

	if (info->capability == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
		applet_secrets_request_complete_setting (req, NM_SETTING_GSM_SETTING_NAME, error);
	else if (info->capability == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
		applet_secrets_request_complete_setting (req, NM_SETTING_CDMA_SETTING_NAME, error);
	else
		g_assert_not_reached ();

	applet_secrets_request_free (req);
	g_clear_error (&error);
}
static void
get_bt_secrets_cb (GtkDialog *dialog,
                   gint response,
                   gpointer user_data)
{
	SecretsRequest *req = user_data;
	NMBtSecretsInfo *info = (NMBtSecretsInfo *) req;
	NMSetting *setting;
	GError *error = NULL;

	if (response == GTK_RESPONSE_OK) {
		setting = nm_connection_get_setting_by_name (req->connection, req->setting_name);
		if (setting) {
			/* Normally we'd want to get all the settings's secrets and return those
			 * to NM too (since NM wants them), but since the only other secrets for 3G
			 * connections are PINs, and since the phone obviously has to be unlocked
			 * to even make the Bluetooth connection, we can skip doing that here for
			 * Bluetooth devices.
			 */

			/* Update the password */
			g_object_set (G_OBJECT (setting),
					      info->secret_name, gtk_entry_get_text (info->secret_entry),
					      NULL);
		} else {
			g_set_error (&error,
				         NM_SECRET_AGENT_ERROR,
				         NM_SECRET_AGENT_ERROR_FAILED,
				         "%s.%d (%s): unhandled setting '%s'",
				         __FILE__, __LINE__, __func__, req->setting_name);
		}
	} else {
		g_set_error (&error,
		             NM_SECRET_AGENT_ERROR,
		             NM_SECRET_AGENT_ERROR_FAILED,
		             "%s.%d (%s): canceled",
		             __FILE__, __LINE__, __func__);
	}

	applet_secrets_request_complete_setting (req, req->setting_name, error);
	applet_secrets_request_free (req);
	g_clear_error (&error);
}