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__); }
static void apn_button_mobile_wizard_done (NMAMobileWizard *wizard, gboolean canceled, NMAMobileWizardAccessMethod *method, gpointer user_data) { CEPageMobile *self = CE_PAGE_MOBILE (user_data); CEPageMobilePrivate *priv = CE_PAGE_MOBILE_GET_PRIVATE (self); if (canceled || !method) { nma_mobile_wizard_destroy (wizard); return; } if (!canceled && method) { switch (method->devtype) { case NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: gtk_entry_set_text (GTK_ENTRY (priv->username), method->username ? method->username : ""); gtk_entry_set_text (GTK_ENTRY (priv->password), method->password ? method->password : ""); gtk_entry_set_text (GTK_ENTRY (priv->apn), method->gsm_apn ? method->gsm_apn : ""); break; case NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO: gtk_entry_set_text (GTK_ENTRY (priv->username), method->username ? method->username : ""); gtk_entry_set_text (GTK_ENTRY (priv->password), method->password ? method->password : ""); break; default: g_assert_not_reached (); break; } } nma_mobile_wizard_destroy (wizard); }
static void dun_cleanup (NmaBtDevice *self) { NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self); GSList *iter; /* ModemManager */ for (iter = priv->modem_proxies; iter; iter = g_slist_next (iter)) g_object_unref (DBUS_G_PROXY (iter->data)); g_slist_free (priv->modem_proxies); priv->modem_proxies = NULL; g_clear_object (&priv->mm_proxy); #if WITH_MODEM_MANAGER_1 g_clear_object (&priv->dbus_connection); g_clear_object (&priv->modem_manager_1); #endif if (priv->dun_proxy && priv->rfcomm_iface) { dbus_g_proxy_call_no_reply (priv->dun_proxy, "Disconnect", G_TYPE_STRING, priv->rfcomm_iface, G_TYPE_INVALID); } g_clear_object (&priv->dun_proxy); g_free (priv->rfcomm_iface); priv->rfcomm_iface = NULL; if (priv->dun_timeout_id) { g_source_remove (priv->dun_timeout_id); priv->dun_timeout_id = 0; } if (priv->wizard) { nma_mobile_wizard_destroy (priv->wizard); priv->wizard = NULL; } }
static void new_connection_mobile_wizard_done (NMAMobileWizard *wizard, gboolean canceled, NMAMobileWizardAccessMethod *method, gpointer user_data) { WizardInfo *info = user_data; NMConnection *connection = NULL; if (!canceled && method) { NMSetting *type_setting; const char *ctype = NULL; char *detail = NULL; switch (method->devtype) { case NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: ctype = NM_SETTING_GSM_SETTING_NAME; type_setting = nm_setting_gsm_new (); /* De-facto standard for GSM */ g_object_set (type_setting, NM_SETTING_GSM_NUMBER, "*99#", NM_SETTING_GSM_USERNAME, method->username, NM_SETTING_GSM_PASSWORD, method->password, NM_SETTING_GSM_APN, method->gsm_apn, NULL); break; case NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO: ctype = NM_SETTING_CDMA_SETTING_NAME; type_setting = nm_setting_cdma_new (); /* De-facto standard for CDMA */ g_object_set (type_setting, NM_SETTING_CDMA_NUMBER, "#777", NM_SETTING_GSM_USERNAME, method->username, NM_SETTING_GSM_PASSWORD, method->password, NULL); break; default: g_assert_not_reached (); break; } if (method->plan_name) detail = g_strdup_printf ("%s %s %%d", method->provider_name, method->plan_name); else detail = g_strdup_printf ("%s connection %%d", method->provider_name); connection = ce_page_new_connection (detail, ctype, FALSE, info->settings, info->user_data); g_free (detail); nm_connection_add_setting (connection, type_setting); add_default_serial_setting (connection); nm_connection_add_setting (connection, nm_setting_ppp_new ()); } (*info->result_func) (connection, canceled, NULL, info->user_data); if (wizard) nma_mobile_wizard_destroy (wizard); g_object_unref (info->settings); g_free (info); }
static void mobile_wizard_done (NMAMobileWizard *wizard, gboolean cancelled, NMAMobileWizardAccessMethod *method, gpointer user_data) { AutoWizardInfo *info = user_data; NMConnection *connection = NULL; if (!cancelled && method) { NMSetting *setting; char *uuid, *id; const char *setting_name; if (method->devtype != info->requested_capability) { g_warning ("Unexpected device type"); cancelled = TRUE; goto done; } connection = nm_connection_new (); if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { setting_name = NM_SETTING_CDMA_SETTING_NAME; setting = nm_setting_cdma_new (); g_object_set (setting, NM_SETTING_CDMA_NUMBER, "#777", NM_SETTING_CDMA_USERNAME, method->username, NM_SETTING_CDMA_PASSWORD, method->password, NM_SETTING_CDMA_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL); nm_connection_add_setting (connection, setting); } else if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { setting_name = NM_SETTING_GSM_SETTING_NAME; setting = nm_setting_gsm_new (); g_object_set (setting, NM_SETTING_GSM_NUMBER, "*99#", NM_SETTING_GSM_USERNAME, method->username, NM_SETTING_GSM_PASSWORD, method->password, NM_SETTING_GSM_APN, method->gsm_apn, NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL); nm_connection_add_setting (connection, setting); } else g_assert_not_reached (); /* Serial setting */ setting = nm_setting_serial_new (); g_object_set (setting, NM_SETTING_SERIAL_BAUD, 115200, NM_SETTING_SERIAL_BITS, 8, NM_SETTING_SERIAL_PARITY, 'n', NM_SETTING_SERIAL_STOPBITS, 1, NULL); nm_connection_add_setting (connection, setting); nm_connection_add_setting (connection, nm_setting_ppp_new ()); setting = nm_setting_connection_new (); id = utils_create_mobile_connection_id (method->provider_name, method->plan_name); uuid = nm_utils_uuid_generate (); g_object_set (setting, NM_SETTING_CONNECTION_ID, id, NM_SETTING_CONNECTION_TYPE, setting_name, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_UUID, uuid, NULL); g_free (uuid); g_free (id); nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL); nm_connection_add_setting (connection, setting); } done: (*(info->callback)) (connection, TRUE, cancelled, info->callback_data); if (wizard) nma_mobile_wizard_destroy (wizard); g_free (info); }
static void gsm_mobile_wizard_done (NMAMobileWizard *wizard, gboolean canceled, NMAMobileWizardAccessMethod *method, gpointer user_data) { NMConnection *connection = NULL; if (!canceled && method) { NMSetting *setting; char *uuid, *id; if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { g_warning ("Unexpected device type (not GSM)."); canceled = TRUE; goto done; } connection = nm_connection_new (); setting = nm_setting_gsm_new (); g_object_set (setting, NM_SETTING_GSM_NUMBER, "*99#", NM_SETTING_GSM_USERNAME, method->username, NM_SETTING_GSM_PASSWORD, method->password, NM_SETTING_GSM_APN, method->gsm_apn, NULL); nm_connection_add_setting (connection, setting); /* Serial setting */ setting = nm_setting_serial_new (); g_object_set (setting, NM_SETTING_SERIAL_BAUD, 115200, NM_SETTING_SERIAL_BITS, 8, NM_SETTING_SERIAL_PARITY, 'n', NM_SETTING_SERIAL_STOPBITS, 1, NULL); nm_connection_add_setting (connection, setting); nm_connection_add_setting (connection, nm_setting_ppp_new ()); setting = nm_setting_connection_new (); if (method->plan_name) id = g_strdup_printf ("%s %s", method->provider_name, method->plan_name); else id = g_strdup_printf ("%s connection", method->provider_name); uuid = nm_utils_uuid_generate (); g_object_set (setting, NM_SETTING_CONNECTION_ID, id, NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_UUID, uuid, NULL); g_free (uuid); g_free (id); nm_connection_add_setting (connection, setting); } done: connect_3g (connection, canceled, user_data); nma_mobile_wizard_destroy (wizard); }