static gboolean extract_details_from_connection (NMConnection *connection, const char *secrets_setting_name, const char **username, const char **password, GError **error) { NMSettingConnection *s_con; NMSetting *setting; const char *setting_name; g_return_val_if_fail (connection != NULL, FALSE); g_return_val_if_fail (username != NULL, FALSE); g_return_val_if_fail (password != NULL, FALSE); if (secrets_setting_name) setting_name = secrets_setting_name; else { /* Get the setting matching the connection type */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); setting_name = nm_setting_connection_get_connection_type (s_con); g_assert (setting_name); /* In case of bluetooth connection, use GSM or CDMA setting */ if (strcmp (setting_name, NM_SETTING_BLUETOOTH_SETTING_NAME) == 0) { if (nm_connection_get_setting_gsm (connection)) setting_name = NM_SETTING_GSM_SETTING_NAME; else setting_name = NM_SETTING_CDMA_SETTING_NAME; } } setting = nm_connection_get_setting_by_name (connection, setting_name); if (!setting) { /* This shouldn't ever happen */ g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "Missing type-specific setting; no secrets could be found."); return FALSE; } if (NM_IS_SETTING_PPPOE (setting)) { *username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting)); *password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting)); } else if (NM_IS_SETTING_ADSL (setting)) { *username = nm_setting_adsl_get_username (NM_SETTING_ADSL (setting)); *password = nm_setting_adsl_get_password (NM_SETTING_ADSL (setting)); } else if (NM_IS_SETTING_GSM (setting)) { *username = nm_setting_gsm_get_username (NM_SETTING_GSM (setting)); *password = nm_setting_gsm_get_password (NM_SETTING_GSM (setting)); } else if (NM_IS_SETTING_CDMA (setting)) { *username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting)); *password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting)); } return TRUE; }
static gboolean extract_details_from_connection (NMConnection *connection, const char **username, const char **password, GError **error) { NMSettingConnection *s_con; NMSetting *setting; const char *connection_type; g_return_val_if_fail (connection != NULL, FALSE); g_return_val_if_fail (username != NULL, FALSE); g_return_val_if_fail (password != NULL, FALSE); s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); g_assert (s_con); connection_type = nm_setting_connection_get_connection_type (s_con); g_assert (connection_type); setting = nm_connection_get_setting_by_name (connection, connection_type); if (!setting) { g_set_error_literal (error, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, "Missing type-specific setting; no secrets could be found."); return FALSE; } /* FIXME: push this down to the settings and keep PPP manager generic */ if (NM_IS_SETTING_PPPOE (setting)) { *username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting)); *password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting)); } else if (NM_IS_SETTING_GSM (setting)) { *username = nm_setting_gsm_get_username (NM_SETTING_GSM (setting)); *password = nm_setting_gsm_get_password (NM_SETTING_GSM (setting)); } else if (NM_IS_SETTING_CDMA (setting)) { *username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting)); *password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting)); } return TRUE; }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMSettingPPPOE *setting = NM_SETTING_PPPOE (object); switch (prop_id) { case PROP_SERVICE: g_value_set_string (value, nm_setting_pppoe_get_service (setting)); break; case PROP_USERNAME: g_value_set_string (value, nm_setting_pppoe_get_username (setting)); break; case PROP_PASSWORD: g_value_set_string (value, nm_setting_pppoe_get_password (setting)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
CEPage * ce_page_dsl_new (NMConnectionEditor *editor, NMConnection *connection, GtkWindow *parent_window, NMClient *client, const char **out_secrets_setting_name, GError **error) { CEPageDsl *self; CEPageDslPrivate *priv; self = CE_PAGE_DSL (ce_page_new (CE_TYPE_PAGE_DSL, editor, connection, parent_window, client, UIDIR "/ce-page-dsl.ui", "DslPage", _("DSL"))); if (!self) { g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load DSL user interface.")); return NULL; } dsl_private_init (self); priv = CE_PAGE_DSL_GET_PRIVATE (self); priv->setting = nm_connection_get_setting_pppoe (connection); if (!priv->setting) { priv->setting = NM_SETTING_PPPOE (nm_setting_pppoe_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->setting)); } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); *out_secrets_setting_name = NM_SETTING_PPPOE_SETTING_NAME; return CE_PAGE (self); }