static void
get_property (GObject *object, guint prop_id,
              GValue *value, GParamSpec *pspec)
{
	NMSettingGsm *setting = NM_SETTING_GSM (object);

	switch (prop_id) {
	case PROP_NUMBER:
		g_value_set_string (value, nm_setting_gsm_get_number (setting));
		break;
	case PROP_USERNAME:
		g_value_set_string (value, nm_setting_gsm_get_username (setting));
		break;
	case PROP_PASSWORD:
		g_value_set_string (value, nm_setting_gsm_get_password (setting));
		break;
	case PROP_PASSWORD_FLAGS:
		g_value_set_flags (value, nm_setting_gsm_get_password_flags (setting));
		break;
	case PROP_APN:
		g_value_set_string (value, nm_setting_gsm_get_apn (setting));
		break;
	case PROP_NETWORK_ID:
		g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
		break;
	case PROP_PIN:
		g_value_set_string (value, nm_setting_gsm_get_pin (setting));
		break;
	case PROP_PIN_FLAGS:
		g_value_set_flags (value, nm_setting_gsm_get_pin_flags (setting));
		break;
	case PROP_HOME_ONLY:
		g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
		break;
	case PROP_DEVICE_ID:
		g_value_set_string (value, nm_setting_gsm_get_device_id (setting));
		break;
	case PROP_SIM_ID:
		g_value_set_string (value, nm_setting_gsm_get_sim_id (setting));
		break;
	case PROP_SIM_OPERATOR_ID:
		g_value_set_string (value, nm_setting_gsm_get_sim_operator_id (setting));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Beispiel #2
0
gboolean
nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
{
	NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
	NMSettingConnection *s_con;

	s_con = nm_connection_get_setting_connection (connection);
	g_assert (s_con);

	if (g_str_equal (nm_setting_connection_get_connection_type (s_con),
	                 NM_SETTING_GSM_SETTING_NAME)) {
		NMSettingGsm *s_gsm;
		const char *str;

		s_gsm = nm_connection_get_setting_gsm (connection);
		if (!s_gsm)
			return FALSE;

		str = nm_setting_gsm_get_device_id (s_gsm);
		if (str) {
			if (!priv->device_id) {
				nm_log_dbg (LOGD_MB, "(%s): %s/%s has device-id, device does not",
				            priv->uid,
				            nm_connection_get_uuid (connection),
				            nm_connection_get_id (connection));
				return FALSE;
			}
			if (strcmp (str, priv->device_id)) {
				nm_log_dbg (LOGD_MB, "(%s): %s/%s device-id mismatch",
				            priv->uid,
				            nm_connection_get_uuid (connection),
				            nm_connection_get_id (connection));
				return FALSE;
			}
		}

		/* SIM properties may not be available before the SIM is unlocked, so
		 * to ensure that autoconnect works, the connection's SIM properties
		 * are only compared if present on the device.
		 */

		str = nm_setting_gsm_get_sim_id (s_gsm);
		if (str && priv->sim_id) {
			if (strcmp (str, priv->sim_id)) {
				nm_log_dbg (LOGD_MB, "(%s): %s/%s sim-id mismatch",
				            priv->uid,
				            nm_connection_get_uuid (connection),
				            nm_connection_get_id (connection));
				return FALSE;
			}
		}

		str = nm_setting_gsm_get_sim_operator_id (s_gsm);
		if (str && priv->sim_operator_id) {
			if (strcmp (str, priv->sim_operator_id)) {
				nm_log_dbg (LOGD_MB, "(%s): %s/%s sim-operator-id mismatch",
				            priv->uid,
				            nm_connection_get_uuid (connection),
				            nm_connection_get_id (connection));
				return FALSE;
			}
		}
	}

	if (NM_MODEM_GET_CLASS (self)->check_connection_compatible)
		return NM_MODEM_GET_CLASS (self)->check_connection_compatible (self, connection);
	return FALSE;
}