static void add_pan_connection (NmaBtDevice *self) { NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self); NMConnection *connection; NMSetting *setting, *bt_setting, *ip_setting; char *id, *uuid; /* The connection */ connection = nm_connection_new (); /* The connection settings */ setting = nm_setting_connection_new (); id = g_strdup_printf (_("%s Network"), priv->alias ? priv->alias : priv->bdaddr); uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (setting), NM_SETTING_CONNECTION_ID, id, NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, NM_SETTING_BLUETOOTH_SETTING_NAME, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL); g_free (id); g_free (uuid); nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL); nm_connection_add_setting (connection, setting); /* The Bluetooth settings */ bt_setting = nm_setting_bluetooth_new (); g_object_set (G_OBJECT (bt_setting), NM_SETTING_BLUETOOTH_BDADDR, priv->bdaddr_array, NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU, NULL); nm_connection_add_setting (connection, bt_setting); /* IPv4 */ ip_setting = nm_setting_ip4_config_new (); g_object_set (G_OBJECT (ip_setting), NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NM_SETTING_IP4_CONFIG_MAY_FAIL, FALSE, NULL); nm_connection_add_setting (connection, ip_setting); /* IPv6 */ ip_setting = nm_setting_ip6_config_new (); g_object_set (G_OBJECT (ip_setting), NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE, NULL); nm_connection_add_setting (connection, ip_setting); /* Add the connection to the settings service */ nm_remote_settings_add_connection (priv->settings, connection, pan_add_cb, self); }
static void all_user_changed (GtkToggleButton *b, CEPageWifi *page) { gboolean all_users; NMSettingConnection *sc; sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection); all_users = gtk_toggle_button_get_active (b); g_object_set (sc, "permissions", NULL, NULL); if (!all_users) nm_setting_connection_add_permission (sc, "user", g_get_user_name (), NULL); }
static NMConnection * dun_new_gsm (NMAMobileWizardAccessMethod *method) { NMConnection *connection; NMSetting *setting; char *uuid, *id; 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_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, 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 (); 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, NM_SETTING_BLUETOOTH_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); return connection; }
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); }