static void
apn_button_clicked (GtkButton *button, gpointer user_data)
{
	CEPageMobile *self = CE_PAGE_MOBILE (user_data);
	CEPageMobilePrivate *priv = CE_PAGE_MOBILE_GET_PRIVATE (self);
	NMAMobileWizard *wizard;
	GtkWidget *toplevel;

	toplevel = gtk_widget_get_toplevel (CE_PAGE (self)->page);
	g_return_if_fail (gtk_widget_is_toplevel (toplevel));

	if (!priv->window_added) {
		gtk_window_group_add_window (priv->window_group, GTK_WINDOW (toplevel));
		priv->window_added = TRUE;
	}

	wizard = nma_mobile_wizard_new (GTK_WINDOW (toplevel),
									priv->window_group,
									NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS,
									FALSE,
									apn_button_mobile_wizard_done,
									self);
	if (wizard)
		nma_mobile_wizard_present (wizard);
}
static void
start_wizard (NmaBtDevice *self,
              const gchar *path,
              NMDeviceType devtype)
{
	NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);

	if (devtype == NM_DEVICE_TYPE_UNKNOWN) {
		dun_error (self, __func__, NULL, _("unknown modem type."));
		return;
	}

	if (priv->wizard) {
		g_message ("%s: (%s) oops! not starting Wizard as one is already in progress", __func__, path);
		return;
	}

	g_message ("%s: (%s) starting the mobile wizard", __func__, path);

	g_source_remove (priv->dun_timeout_id);
	priv->dun_timeout_id = 0;

	/* Start the mobile wizard */
	priv->wizard = nma_mobile_wizard_new (priv->parent_window,
	                                      priv->window_group,
	                                      devtype,
	                                      FALSE,
	                                      wizard_done_cb,
	                                      self);
	nma_mobile_wizard_present (priv->wizard);
}
gboolean
mobile_helper_wizard (NMDeviceModemCapabilities capabilities,
                      AppletNewAutoConnectionCallback callback,
                      gpointer callback_data)
{
	NMAMobileWizard *wizard;
	AutoWizardInfo *info;
	NMAMobileWizardAccessMethod *method;
	NMDeviceModemCapabilities wizard_capability;

	/* Convert the input capabilities mask into a single value */
	if (capabilities & NM_DEVICE_MODEM_CAPABILITY_LTE)
		/* All LTE modems treated as GSM/UMTS for the wizard */
		wizard_capability = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
	else if (capabilities & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
		wizard_capability = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
	else if (capabilities & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
		wizard_capability = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
	else {
		g_warning ("Unknown modem capabilities (0x%X): can't launch wizard", capabilities);
		return FALSE;
	}

	info = g_malloc0 (sizeof (AutoWizardInfo));
	info->callback = callback;
	info->callback_data = callback_data;
	info->requested_capability = wizard_capability;

	wizard = nma_mobile_wizard_new (NULL,
	                                NULL,
	                                wizard_capability,
	                                FALSE,
									mobile_wizard_done,
	                                info);
	if (wizard) {
		nma_mobile_wizard_present (wizard);
		return TRUE;
	}

	/* Fall back to something */
	method = g_malloc0 (sizeof (NMAMobileWizardAccessMethod));
	method->devtype = wizard_capability;

	if (wizard_capability == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
		method->provider_name = _("GSM");
	else if (wizard_capability == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
		method->provider_name = _("CDMA");
	else
		g_assert_not_reached ();

	mobile_wizard_done (NULL, FALSE, method, info);
	g_free (method);

	return TRUE;
}
static void
toplevel_shown (GtkWindow       *toplevel,
                GParamSpec      *pspec,
                NMAMobileWizard *wizard)
{
    gboolean visible = FALSE;

    g_object_get (G_OBJECT (toplevel), "visible", &visible, NULL);
    if (visible)
        nma_mobile_wizard_present (wizard);
}
void
mobile_connection_new (GtkWindow *parent,
                       const char *detail,
                       NMRemoteSettings *settings,
                       PageNewConnectionResultFunc result_func,
                       gpointer user_data)
{
	NMAMobileWizard *wizard;
	WizardInfo *info;
	GtkWidget *dialog, *vbox, *gsm_radio, *cdma_radio, *label, *content, *alignment;
	GtkWidget *hbox, *image;
	gint response;
	NMAMobileWizardAccessMethod method;

	info = g_malloc0 (sizeof (WizardInfo));
	info->result_func = result_func;
	info->settings = g_object_ref (settings);
	info->user_data = user_data;

	wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
									new_connection_mobile_wizard_done, info);
	if (wizard) {
		nma_mobile_wizard_present (wizard);
		return;
	}

	/* Fall back to just asking for GSM vs. CDMA */
	dialog = gtk_dialog_new_with_buttons (_("Select Mobile Broadband Provider Type"),
	                                      parent,
	                                      GTK_DIALOG_MODAL,
	                                      GTK_STOCK_CANCEL,
	                                      GTK_RESPONSE_CANCEL,
	                                      GTK_STOCK_OK,
	                                      GTK_RESPONSE_OK,
	                                      NULL);
	g_signal_connect (dialog, "delete-event", G_CALLBACK (cancel_dialog), NULL);
	gtk_window_set_icon_name (GTK_WINDOW (dialog), "nm-device-wwan");

	content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
	alignment = gtk_alignment_new (0, 0, 0.5, 0.5);
	gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
	gtk_box_pack_start (GTK_BOX (content), alignment, TRUE, FALSE, 6);

#if GTK_CHECK_VERSION (3,1,6)
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
#else
	hbox = gtk_hbox_new (FALSE, 6);
#endif
	gtk_container_add (GTK_CONTAINER (alignment), hbox);

	image = gtk_image_new_from_icon_name ("nm-device-wwan", GTK_ICON_SIZE_DIALOG);
	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
	gtk_misc_set_padding (GTK_MISC (image), 0, 6);
	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 6);

#if GTK_CHECK_VERSION (3,1,6)
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
#else
	vbox = gtk_vbox_new (FALSE, 6);
#endif
	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);

	label = gtk_label_new (_("Select the technology your mobile broadband provider uses.  If you are unsure, ask your provider."));
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 12);

	gsm_radio = gtk_radio_button_new_with_mnemonic (NULL, _("My provider uses _GSM-based technology (i.e. GPRS, EDGE, UMTS, HSDPA)"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gsm_radio), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), gsm_radio, FALSE, FALSE, 6);

	/* Translators: CDMA has 'D' accelerator key; 'C' collides with 'Cancel' button.
	                You may need to change it according to your language. */
	cdma_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (gsm_radio),
                                           _("My provider uses C_DMA-based technology (i.e. 1xRTT, EVDO)"));
	gtk_box_pack_start (GTK_BOX (vbox), cdma_radio, FALSE, FALSE, 6);

	gtk_widget_show_all (dialog);

	memset (&method, 0, sizeof (method));
	response = gtk_dialog_run (GTK_DIALOG (dialog));
	if (response == GTK_RESPONSE_OK) {
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cdma_radio))) {
			method.devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
			method.provider_name = _("CDMA");
		} else {
			method.devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
			method.provider_name = _("GSM");
		}
	}
	gtk_widget_destroy (dialog);

	new_connection_mobile_wizard_done (NULL,
	                                   (response != GTK_RESPONSE_OK),
	                                   (response == GTK_RESPONSE_OK) ? &method : NULL,
	                                   info);
}
static gboolean
show_wizard_idle_cb (NMAMobileWizard *wizard)
{
    nma_mobile_wizard_present (wizard);
    return FALSE;
}
void
bluetooth_connection_new (GtkWindow *parent,
                          const char *detail,
                          NMClient *client,
                          PageNewConnectionResultFunc result_func,
                          gpointer user_data)
{
	gint response;
	NMAMobileWizard *wizard = NULL;
	WizardInfo *info;
	GtkWidget *dialog, *content, *alignment, *vbox, *label, *dun_radio, *panu_radio;

	info = g_malloc0 (sizeof (WizardInfo));
	info->result_func = result_func;
	info->client = g_object_ref (client);
	info->user_data = user_data;
	info->type = NM_SETTING_BLUETOOTH_TYPE_PANU;

	dialog = gtk_dialog_new_with_buttons (_("Bluetooth Type"),
	                                      parent,
	                                      GTK_DIALOG_MODAL,
	                                      GTK_STOCK_CANCEL,
	                                      GTK_RESPONSE_CANCEL,
	                                      GTK_STOCK_OK,
	                                      GTK_RESPONSE_OK,
	                                      NULL);

	content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

	alignment = gtk_alignment_new (0, 0, 0.5, 0.5);
	gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
	gtk_box_pack_start (GTK_BOX (content), alignment, TRUE, FALSE, 6);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_container_add (GTK_CONTAINER (alignment), vbox);

	label = gtk_label_new (_("Select the type of the Bluetooth connection profile."));
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 12);

	panu_radio = gtk_radio_button_new_with_mnemonic (NULL, _("_Personal Area Network"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panu_radio), TRUE);
	gtk_box_pack_start (GTK_BOX (vbox), panu_radio, FALSE, FALSE, 6);

	dun_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (panu_radio),
	                                                            _("_Dial-Up Network"));
	gtk_box_pack_start (GTK_BOX (vbox), dun_radio, FALSE, FALSE, 6);

	gtk_widget_show_all (dialog);
	response = gtk_dialog_run (GTK_DIALOG (dialog));
	if (response == GTK_RESPONSE_OK) {
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dun_radio))) {
			info->type = NM_SETTING_BLUETOOTH_TYPE_DUN;
			wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
			                                new_connection_mobile_wizard_done, info);
		} else {
			info->type = NM_SETTING_BLUETOOTH_TYPE_PANU;
		}
	}
	gtk_widget_destroy (dialog);

	if (wizard)
		nma_mobile_wizard_present (wizard);
	else
		new_connection_mobile_wizard_done (NULL, (response != GTK_RESPONSE_OK), NULL, info);
}