Exemplo n.º 1
0
static void
wizard_done_cb (MobileWizard *self,
                gboolean canceled,
                MobileWizardAccessMethod *method,
                gpointer user_data)
{
	PluginInfo *info = user_data;
	BMConnection *connection = NULL;
	BMAGConfSettings *gconf_settings;
	BMAGConfConnection *exported;
	GByteArray *mac;
	BMSetting *s_bt;

	g_message ("%s: mobile wizard done", __func__);

	if (canceled || !method) {
		dun_error (info, __func__, NULL, _("Mobile wizard was canceled"));
		return;
	}

	if (method->devtype == BM_DEVICE_TYPE_CDMA)
		connection = dun_new_cdma (method);
	else if (method->devtype == BM_DEVICE_TYPE_GSM)
		connection = dun_new_gsm (method);
	else {
		dun_error (info, __func__, NULL, _("Unknown phone device type (not GSM or CDMA)"));
		return;
	}

	mobile_wizard_destroy (info->wizard);
	info->wizard = NULL;

	g_assert (connection);

	/* The Bluetooth settings */
	mac = get_array_from_bdaddr (info->bdaddr);
	g_assert (mac);
	s_bt = bm_setting_bluetooth_new ();
	g_object_set (G_OBJECT (s_bt),
	              BM_SETTING_BLUETOOTH_BDADDR, mac,
	              BM_SETTING_BLUETOOTH_TYPE, BM_SETTING_BLUETOOTH_TYPE_DUN,
	              NULL);
	g_byte_array_free (mac, TRUE);
	bm_connection_add_setting (connection, s_bt);

	g_message ("%s: adding new setting to GConf", __func__);

	gconf_settings = nma_gconf_settings_new (NULL);
	exported = nma_gconf_settings_add_connection (gconf_settings, connection);
	if (exported)
		info->dun_connection = BM_SETTINGS_CONNECTION_INTERFACE (exported);

	g_message ("%s: success!", __func__);
	dun_cleanup (info, _("Your phone is now ready to use!"), FALSE);
}
static void
wizard_done_cb (NMAMobileWizard *wizard,
                gboolean canceled,
                NMAMobileWizardAccessMethod *method,
                gpointer user_data)
{
	NmaBtDevice *self = NMA_BT_DEVICE (user_data);
	NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
	NMConnection *connection = NULL;
	NMSetting *s_bt;

	g_return_if_fail (wizard == priv->wizard);

	g_message ("%s: mobile wizard done", __func__);

	if (canceled || !method) {
		dun_error (self, __func__, NULL, _("Mobile wizard was canceled"));
		return;
	}

	if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
		connection = dun_new_cdma (method);
	else if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
		connection = dun_new_gsm (method);
	else {
		dun_error (self, __func__, NULL, _("Unknown phone device type (not GSM or CDMA)"));
		return;
	}

	nma_mobile_wizard_destroy (priv->wizard);
	priv->wizard = NULL;

	g_assert (connection);

	/* The Bluetooth settings */
	s_bt = nm_setting_bluetooth_new ();
	g_object_set (G_OBJECT (s_bt),
	              NM_SETTING_BLUETOOTH_BDADDR, priv->bdaddr_array,
	              NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_DUN,
	              NULL);
	nm_connection_add_setting (connection, s_bt);

	g_message ("%s: adding new setting", __func__);

	/* Add the connection to the settings service */
	nm_remote_settings_add_connection (priv->settings,
	                                   connection,
	                                   dun_add_cb,
	                                   self);

	g_message ("%s: waiting for add connection result...", __func__);
}