mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 08:20:08 +01:00
merge: branch 'lr/modem-properties'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/139
This commit is contained in:
commit
055e95ea26
10 changed files with 378 additions and 14 deletions
|
|
@ -6,17 +6,6 @@
|
|||
|
||||
-->
|
||||
<interface name="org.freedesktop.NetworkManager.Device.Modem">
|
||||
|
||||
<!--
|
||||
PropertiesChanged:
|
||||
@properties: A dictionary mapping property names to variant boxed values
|
||||
|
||||
DEPRECATED. Use the standard "PropertiesChanged" signal from "org.freedesktop.DBus.Properties" instead which exists since version NetworkManager 1.2.0.
|
||||
-->
|
||||
<signal name="PropertiesChanged">
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
<!--
|
||||
ModemCapabilities:
|
||||
|
||||
|
|
@ -38,5 +27,46 @@
|
|||
Returns: <link linkend="NMDeviceModemCapabilities">NMDeviceModemCapabilities</link>
|
||||
-->
|
||||
<property name="CurrentCapabilities" type="u" access="read"/>
|
||||
|
||||
<!--
|
||||
DeviceId:
|
||||
|
||||
An identifier used by the modem backend (ModemManager) that aims to
|
||||
uniquely identify the a device. Can be used to match a connection to a
|
||||
particular device.
|
||||
|
||||
Since: 1.20
|
||||
-->
|
||||
<property name="DeviceId" type="s" access="read" />
|
||||
|
||||
<!--
|
||||
OperatorCode:
|
||||
|
||||
The MCC and MNC (concatenated) of the network the modem is connected to.
|
||||
Blank if disconnected or not a 3GPP modem.
|
||||
|
||||
Since: 1.20
|
||||
-->
|
||||
<property name="OperatorCode" type="s" access="read" />
|
||||
|
||||
<!--
|
||||
Apn:
|
||||
|
||||
The access point name the modem is connected to. Blank if disconnected.
|
||||
|
||||
Since: 1.20
|
||||
-->
|
||||
<property name="Apn" type="s" access="read" />
|
||||
|
||||
<!--
|
||||
PropertiesChanged:
|
||||
@properties: A dictionary mapping property names to variant boxed values
|
||||
|
||||
DEPRECATED. Use the standard "PropertiesChanged" signal from "org.freedesktop.DBus.Properties" instead which exists since version NetworkManager 1.2.0.
|
||||
-->
|
||||
<signal name="PropertiesChanged">
|
||||
<arg name="properties" type="a{sv}"/>
|
||||
</signal>
|
||||
|
||||
</interface>
|
||||
</node>
|
||||
|
|
|
|||
|
|
@ -1604,3 +1604,10 @@ global:
|
|||
nm_tc_qdisc_get_attribute_names;
|
||||
nm_tc_qdisc_set_attribute;
|
||||
} libnm_1_16_0;
|
||||
|
||||
libnm_1_20_0 {
|
||||
global:
|
||||
nm_device_modem_get_apn;
|
||||
nm_device_modem_get_device_id;
|
||||
nm_device_modem_get_operator_code;
|
||||
} libnm_1_18_0;
|
||||
|
|
|
|||
|
|
@ -36,12 +36,18 @@ G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE)
|
|||
typedef struct {
|
||||
NMDeviceModemCapabilities caps;
|
||||
NMDeviceModemCapabilities current_caps;
|
||||
char *device_id;
|
||||
char *operator_code;
|
||||
char *apn;
|
||||
} NMDeviceModemPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MODEM_CAPS,
|
||||
PROP_CURRENT_CAPS,
|
||||
PROP_DEVICE_ID,
|
||||
PROP_OPERATOR_CODE,
|
||||
PROP_APN,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
|
@ -82,6 +88,62 @@ nm_device_modem_get_current_capabilities (NMDeviceModem *self)
|
|||
return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_modem_get_device_id:
|
||||
* @self: a #NMDeviceModem
|
||||
*
|
||||
* An identifier used by the modem backend (ModemManager) that aims to
|
||||
* uniquely identify the a device. Can be used to match a connection to a
|
||||
* particular device.
|
||||
*
|
||||
* Returns: a device-id string
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
const char *
|
||||
nm_device_modem_get_device_id (NMDeviceModem *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL);
|
||||
|
||||
return NM_DEVICE_MODEM_GET_PRIVATE (self)->device_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_modem_get_operator_code:
|
||||
* @self: a #NMDeviceModem
|
||||
*
|
||||
* The MCC and MNC (concatenated) of the network the modem is connected to.
|
||||
*
|
||||
* Returns: the operator code or %NULL if disconnected or not a 3GPP modem.
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
const char *
|
||||
nm_device_modem_get_operator_code (NMDeviceModem *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL);
|
||||
|
||||
return NM_DEVICE_MODEM_GET_PRIVATE (self)->operator_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_modem_get_apn:
|
||||
* @self: a #NMDeviceModem
|
||||
*
|
||||
* The access point name the modem is connected to.
|
||||
*
|
||||
* Returns: the APN name or %NULL if disconnected
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
const char *
|
||||
nm_device_modem_get_apn (NMDeviceModem *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NULL);
|
||||
|
||||
return NM_DEVICE_MODEM_GET_PRIVATE (self)->apn;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_type_description (NMDevice *device)
|
||||
{
|
||||
|
|
@ -164,6 +226,9 @@ init_dbus (NMObject *object)
|
|||
const NMPropertiesInfo property_info[] = {
|
||||
{ NM_DEVICE_MODEM_MODEM_CAPABILITIES, &priv->caps },
|
||||
{ NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &priv->current_caps },
|
||||
{ NM_DEVICE_MODEM_DEVICE_ID, &priv->device_id },
|
||||
{ NM_DEVICE_MODEM_OPERATOR_CODE, &priv->operator_code },
|
||||
{ NM_DEVICE_MODEM_APN, &priv->apn },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
|
@ -174,6 +239,18 @@ init_dbus (NMObject *object)
|
|||
property_info);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->device_id);
|
||||
g_free (priv->operator_code);
|
||||
g_free (priv->apn);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_modem_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
|
@ -189,6 +266,15 @@ get_property (GObject *object,
|
|||
case PROP_CURRENT_CAPS:
|
||||
g_value_set_flags (value, nm_device_modem_get_current_capabilities (self));
|
||||
break;
|
||||
case PROP_DEVICE_ID:
|
||||
g_value_set_string (value, nm_device_modem_get_device_id (self));
|
||||
break;
|
||||
case PROP_OPERATOR_CODE:
|
||||
g_value_set_string (value, nm_device_modem_get_operator_code (self));
|
||||
break;
|
||||
case PROP_APN:
|
||||
g_value_set_string (value, nm_device_modem_get_apn (self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -205,6 +291,7 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
|||
g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
||||
nm_object_class->init_dbus = init_dbus;
|
||||
|
|
@ -242,4 +329,40 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class)
|
|||
NM_DEVICE_MODEM_CAPABILITY_NONE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMDeviceModem:device-id:
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CURRENT_CAPS,
|
||||
g_param_spec_string (NM_DEVICE_MODEM_DEVICE_ID, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMDeviceModem:operator-code:
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CURRENT_CAPS,
|
||||
g_param_spec_string (NM_DEVICE_MODEM_OPERATOR_CODE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMDeviceModem:apn:
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CURRENT_CAPS,
|
||||
g_param_spec_string (NM_DEVICE_MODEM_APN, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities"
|
||||
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
|
||||
#define NM_DEVICE_MODEM_DEVICE_ID "device-id"
|
||||
#define NM_DEVICE_MODEM_OPERATOR_CODE "operator-code"
|
||||
#define NM_DEVICE_MODEM_APN "apn"
|
||||
|
||||
/**
|
||||
* NMDeviceModem:
|
||||
|
|
@ -59,6 +62,15 @@ GType nm_device_modem_get_type (void);
|
|||
NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *self);
|
||||
NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *self);
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
const char *nm_device_modem_get_device_id (NMDeviceModem *self);
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
const char *nm_device_modem_get_operator_code (NMDeviceModem *self);
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
const char *nm_device_modem_get_apn (NMDeviceModem *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_DEVICE_MODEM_H__ */
|
||||
|
|
|
|||
|
|
@ -7,13 +7,16 @@ global:
|
|||
nm_modem_deactivate;
|
||||
nm_modem_deactivate_async;
|
||||
nm_modem_device_state_changed;
|
||||
nm_modem_get_apn;
|
||||
nm_modem_get_capabilities;
|
||||
nm_modem_get_configured_mtu;
|
||||
nm_modem_get_control_port;
|
||||
nm_modem_get_device_id;
|
||||
nm_modem_get_driver;
|
||||
nm_modem_get_iid;
|
||||
nm_modem_get_path;
|
||||
nm_modem_get_ip_ifindex;
|
||||
nm_modem_get_operator_code;
|
||||
nm_modem_get_secrets;
|
||||
nm_modem_get_state;
|
||||
nm_modem_get_type;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2009 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2019 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -36,10 +36,13 @@ _LOG_DECLARE_SELF(NMDeviceModem);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceModem,
|
||||
PROP_MODEM,
|
||||
PROP_CAPABILITIES,
|
||||
PROP_CURRENT_CAPABILITIES,
|
||||
PROP_DEVICE_ID,
|
||||
PROP_OPERATOR_CODE,
|
||||
PROP_APN,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -47,6 +50,9 @@ typedef struct {
|
|||
NMDeviceModemCapabilities caps;
|
||||
NMDeviceModemCapabilities current_caps;
|
||||
gboolean rf_enabled;
|
||||
char *device_id;
|
||||
char *operator_code;
|
||||
char *apn;
|
||||
} NMDeviceModemPrivate;
|
||||
|
||||
struct _NMDeviceModem {
|
||||
|
|
@ -307,6 +313,34 @@ ip_ifindex_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
|
|||
nm_device_sysctl_ip_conf_set (device, AF_INET6, "disable_ipv6", "1");
|
||||
}
|
||||
|
||||
static void
|
||||
operator_code_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMDeviceModem *self = NM_DEVICE_MODEM (user_data);
|
||||
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
|
||||
const char *operator_code = nm_modem_get_operator_code (modem);
|
||||
|
||||
if (g_strcmp0 (priv->operator_code, operator_code) != 0) {
|
||||
g_free (priv->operator_code);
|
||||
priv->operator_code = g_strdup (operator_code);
|
||||
_notify (self, PROP_OPERATOR_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
apn_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMDeviceModem *self = NM_DEVICE_MODEM (user_data);
|
||||
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
|
||||
const char *apn = nm_modem_get_apn (modem);
|
||||
|
||||
if (g_strcmp0 (priv->apn, apn) != 0) {
|
||||
g_free (priv->apn);
|
||||
priv->apn = g_strdup (apn);
|
||||
_notify (self, PROP_APN);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ids_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
|
|
@ -692,6 +726,8 @@ set_modem (NMDeviceModem *self, NMModem *modem)
|
|||
g_signal_connect (modem, "notify::" NM_MODEM_DEVICE_ID, G_CALLBACK (ids_changed_cb), self);
|
||||
g_signal_connect (modem, "notify::" NM_MODEM_SIM_ID, G_CALLBACK (ids_changed_cb), self);
|
||||
g_signal_connect (modem, "notify::" NM_MODEM_SIM_OPERATOR_ID, G_CALLBACK (ids_changed_cb), self);
|
||||
g_signal_connect (modem, "notify::" NM_MODEM_OPERATOR_CODE, G_CALLBACK (operator_code_changed_cb), self);
|
||||
g_signal_connect (modem, "notify::" NM_MODEM_APN, G_CALLBACK (apn_changed_cb), self);
|
||||
}
|
||||
|
||||
static guint32
|
||||
|
|
@ -722,6 +758,15 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_CURRENT_CAPABILITIES:
|
||||
g_value_set_uint (value, priv->current_caps);
|
||||
break;
|
||||
case PROP_DEVICE_ID:
|
||||
g_value_set_string (value, priv->device_id);
|
||||
break;
|
||||
case PROP_OPERATOR_CODE:
|
||||
g_value_set_string (value, priv->operator_code);
|
||||
break;
|
||||
case PROP_APN:
|
||||
g_value_set_string (value, priv->apn);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -745,6 +790,10 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_CURRENT_CAPABILITIES:
|
||||
priv->current_caps = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_DEVICE_ID:
|
||||
/* construct-only */
|
||||
priv->device_id = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -779,6 +828,7 @@ nm_device_modem_new (NMModem *modem)
|
|||
NM_DEVICE_MODEM_MODEM, modem,
|
||||
NM_DEVICE_MODEM_CAPABILITIES, caps,
|
||||
NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps,
|
||||
NM_DEVICE_MODEM_DEVICE_ID, nm_modem_get_device_id (modem),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -792,6 +842,10 @@ dispose (GObject *object)
|
|||
g_clear_object (&priv->modem);
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->device_id, g_free);
|
||||
g_clear_pointer (&priv->operator_code, g_free);
|
||||
g_clear_pointer (&priv->apn, g_free);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
|
@ -804,6 +858,9 @@ static const NMDBusInterfaceInfoExtended interface_info_device_modem = {
|
|||
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("ModemCapabilities", "u", NM_DEVICE_MODEM_CAPABILITIES),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("CurrentCapabilities", "u", NM_DEVICE_MODEM_CURRENT_CAPABILITIES),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("DeviceId", "s", NM_DEVICE_MODEM_DEVICE_ID),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("OperatorCode", "s", NM_DEVICE_MODEM_OPERATOR_CODE),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Apn", "s", NM_DEVICE_MODEM_APN),
|
||||
),
|
||||
),
|
||||
.legacy_property_changed = TRUE,
|
||||
|
|
@ -861,5 +918,23 @@ nm_device_modem_class_init (NMDeviceModemClass *klass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_DEVICE_ID] =
|
||||
g_param_spec_string (NM_DEVICE_MODEM_DEVICE_ID, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_OPERATOR_CODE] =
|
||||
g_param_spec_string (NM_DEVICE_MODEM_OPERATOR_CODE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_APN] =
|
||||
g_param_spec_string (NM_DEVICE_MODEM_APN, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
#define NM_DEVICE_MODEM_MODEM "modem"
|
||||
#define NM_DEVICE_MODEM_CAPABILITIES "modem-capabilities"
|
||||
#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities"
|
||||
#define NM_DEVICE_MODEM_DEVICE_ID "device-id"
|
||||
#define NM_DEVICE_MODEM_OPERATOR_CODE "operator-code"
|
||||
#define NM_DEVICE_MODEM_APN "apn"
|
||||
|
||||
typedef struct _NMDeviceModem NMDeviceModem;
|
||||
typedef struct _NMDeviceModemClass NMDeviceModemClass;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ typedef struct {
|
|||
MMObject *modem_object;
|
||||
/* Per-interface objects */
|
||||
MMModem *modem_iface;
|
||||
MMModem3gpp *modem_3gpp_iface;
|
||||
MMModemSimple *simple_iface;
|
||||
MMSim *sim_iface;
|
||||
|
||||
|
|
@ -548,6 +549,8 @@ connect_context_step (NMModemBroadband *self)
|
|||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
_nm_modem_set_apn (NM_MODEM (self), mm_simple_connect_properties_get_apn (ctx->connect_properties));
|
||||
|
||||
_LOGD ("launching connection with ip type '%s' (try %d)",
|
||||
nm_modem_ip_type_to_string (current),
|
||||
ctx->ip_type_tries + 1);
|
||||
|
|
@ -1158,6 +1161,7 @@ disconnect (NMModem *modem,
|
|||
DisconnectContext *ctx;
|
||||
|
||||
connect_context_clear (self);
|
||||
_nm_modem_set_apn (NM_MODEM (self), NULL);
|
||||
|
||||
ctx = g_slice_new0 (DisconnectContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
|
|
@ -1338,6 +1342,15 @@ supported_ip_families_changed (MMModem *modem, GParamSpec *pspec, gpointer user_
|
|||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
operator_code_changed (MMModem3gpp *modem_3gpp, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (user_data);
|
||||
|
||||
g_return_if_fail (modem_3gpp == self->_priv.modem_3gpp_iface);
|
||||
_nm_modem_set_operator_code (NM_MODEM (self), mm_modem_3gpp_get_operator_code (modem_3gpp));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -1371,6 +1384,7 @@ set_property (GObject *object,
|
|||
/* construct-only */
|
||||
self->_priv.modem_object = g_value_dup_object (value);
|
||||
self->_priv.modem_iface = mm_object_get_modem (self->_priv.modem_object);
|
||||
self->_priv.modem_3gpp_iface = mm_object_get_modem_3gpp (self->_priv.modem_object);
|
||||
g_assert (self->_priv.modem_iface != NULL);
|
||||
g_signal_connect (self->_priv.modem_iface,
|
||||
"state-changed",
|
||||
|
|
@ -1386,6 +1400,13 @@ set_property (GObject *object,
|
|||
G_CALLBACK (supported_ip_families_changed),
|
||||
self);
|
||||
|
||||
if (self->_priv.modem_3gpp_iface) {
|
||||
g_signal_connect (self->_priv.modem_3gpp_iface,
|
||||
"notify::operator-code",
|
||||
G_CALLBACK (operator_code_changed),
|
||||
self);
|
||||
}
|
||||
|
||||
/* Note: don't grab the Simple iface here; the Modem interface is the
|
||||
* only one assumed to be always valid and available */
|
||||
break;
|
||||
|
|
@ -1407,7 +1428,9 @@ nm_modem_broadband_new (GObject *object, GError **error)
|
|||
{
|
||||
MMObject *modem_object;
|
||||
MMModem *modem_iface;
|
||||
MMModem3gpp *modem_3gpp_iface;
|
||||
const char *const*drivers;
|
||||
const char *operator_code = NULL;
|
||||
gs_free char *driver = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_OBJECT (object), NULL);
|
||||
|
|
@ -1423,6 +1446,10 @@ nm_modem_broadband_new (GObject *object, GError **error)
|
|||
if (drivers)
|
||||
driver = g_strjoinv (", ", (char **) drivers);
|
||||
|
||||
modem_3gpp_iface = mm_object_peek_modem_3gpp (modem_object);
|
||||
if (modem_3gpp_iface)
|
||||
operator_code = mm_modem_3gpp_get_operator_code (modem_3gpp_iface);
|
||||
|
||||
return g_object_new (NM_TYPE_MODEM_BROADBAND,
|
||||
NM_MODEM_PATH, mm_object_get_path (modem_object),
|
||||
NM_MODEM_UID, mm_modem_get_primary_port (modem_iface),
|
||||
|
|
@ -1432,6 +1459,7 @@ nm_modem_broadband_new (GObject *object, GError **error)
|
|||
NM_MODEM_DEVICE_ID, mm_modem_get_device_identifier (modem_iface),
|
||||
NM_MODEM_BROADBAND_MODEM, modem_object,
|
||||
NM_MODEM_DRIVER, driver,
|
||||
NM_MODEM_OPERATOR_CODE, operator_code,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1448,7 +1476,17 @@ dispose (GObject *object)
|
|||
g_clear_object (&self->_priv.ipv4_config);
|
||||
g_clear_object (&self->_priv.ipv6_config);
|
||||
g_clear_object (&self->_priv.bearer);
|
||||
g_clear_object (&self->_priv.modem_iface);
|
||||
|
||||
if (self->_priv.modem_iface) {
|
||||
g_signal_handlers_disconnect_by_data (self->_priv.modem_iface, self);
|
||||
g_clear_object (&self->_priv.modem_iface);
|
||||
}
|
||||
|
||||
if (self->_priv.modem_3gpp_iface) {
|
||||
g_signal_handlers_disconnect_by_data (self->_priv.modem_3gpp_iface, self);
|
||||
g_clear_object (&self->_priv.modem_3gpp_iface);
|
||||
}
|
||||
|
||||
g_clear_object (&self->_priv.simple_iface);
|
||||
g_clear_object (&self->_priv.sim_iface);
|
||||
g_clear_object (&self->_priv.modem_object);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMModem,
|
|||
PROP_SIM_ID,
|
||||
PROP_IP_TYPES,
|
||||
PROP_SIM_OPERATOR_ID,
|
||||
PROP_OPERATOR_CODE,
|
||||
PROP_APN,
|
||||
);
|
||||
|
||||
enum {
|
||||
|
|
@ -90,6 +92,8 @@ typedef struct _NMModemPrivate {
|
|||
char *sim_id;
|
||||
NMModemIPType ip_types;
|
||||
char *sim_operator_id;
|
||||
char *operator_code;
|
||||
char *apn;
|
||||
|
||||
NMPPPManager *ppp_manager;
|
||||
|
||||
|
|
@ -436,6 +440,18 @@ nm_modem_get_sim_operator_id (NMModem *self)
|
|||
return NM_MODEM_GET_PRIVATE (self)->sim_operator_id;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_modem_get_operator_code (NMModem *self)
|
||||
{
|
||||
return NM_MODEM_GET_PRIVATE (self)->operator_code;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_modem_get_apn (NMModem *self)
|
||||
{
|
||||
return NM_MODEM_GET_PRIVATE (self)->apn;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* IP method PPP */
|
||||
|
||||
|
|
@ -1577,6 +1593,30 @@ nm_modem_get_capabilities (NMModem *self,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
_nm_modem_set_operator_code (NMModem *self, const char *operator_code)
|
||||
{
|
||||
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
|
||||
|
||||
if (g_strcmp0 (priv->operator_code, operator_code) != 0) {
|
||||
g_free (priv->operator_code);
|
||||
priv->operator_code = g_strdup (operator_code);
|
||||
_notify (self, PROP_OPERATOR_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_nm_modem_set_apn (NMModem *self, const char *apn)
|
||||
{
|
||||
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
|
||||
|
||||
if (g_strcmp0 (priv->apn, apn) != 0) {
|
||||
g_free (priv->apn);
|
||||
priv->apn = g_strdup (apn);
|
||||
_notify (self, PROP_APN);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -1615,6 +1655,12 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_SIM_OPERATOR_ID:
|
||||
g_value_set_string (value, priv->sim_operator_id);
|
||||
break;
|
||||
case PROP_OPERATOR_CODE:
|
||||
g_value_set_string (value, priv->operator_code);
|
||||
break;
|
||||
case PROP_APN:
|
||||
g_value_set_string (value, priv->apn);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1667,6 +1713,12 @@ set_property (GObject *object, guint prop_id,
|
|||
if (s && s[0])
|
||||
priv->sim_operator_id = g_strdup (s);
|
||||
break;
|
||||
case PROP_OPERATOR_CODE:
|
||||
_nm_modem_set_operator_code (NM_MODEM (object), g_value_get_string (value));
|
||||
break;
|
||||
case PROP_APN:
|
||||
_nm_modem_set_apn (NM_MODEM (object), g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1728,6 +1780,8 @@ finalize (GObject *object)
|
|||
g_free (priv->device_id);
|
||||
g_free (priv->sim_id);
|
||||
g_free (priv->sim_operator_id);
|
||||
g_free (priv->operator_code);
|
||||
g_free (priv->apn);
|
||||
|
||||
G_OBJECT_CLASS (nm_modem_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -1811,6 +1865,18 @@ nm_modem_class_init (NMModemClass *klass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_OPERATOR_CODE] =
|
||||
g_param_spec_string (NM_MODEM_OPERATOR_CODE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_APN] =
|
||||
g_param_spec_string (NM_MODEM_APN, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
signals[PPP_STATS] =
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#define NM_MODEM_SIM_ID "sim-id"
|
||||
#define NM_MODEM_IP_TYPES "ip-types" /* Supported IP types */
|
||||
#define NM_MODEM_SIM_OPERATOR_ID "sim-operator-id"
|
||||
#define NM_MODEM_OPERATOR_CODE "operator-code"
|
||||
#define NM_MODEM_APN "apn"
|
||||
|
||||
/* Signals */
|
||||
#define NM_MODEM_PPP_STATS "ppp-stats"
|
||||
|
|
@ -175,6 +177,8 @@ const char *nm_modem_get_device_id (NMModem *modem);
|
|||
const char *nm_modem_get_sim_id (NMModem *modem);
|
||||
const char *nm_modem_get_sim_operator_id (NMModem *modem);
|
||||
gboolean nm_modem_get_iid (NMModem *modem, NMUtilsIPv6IfaceId *out_iid);
|
||||
const char *nm_modem_get_operator_code (NMModem *modem);
|
||||
const char *nm_modem_get_apn (NMModem *modem);
|
||||
|
||||
gboolean nm_modem_set_data_port (NMModem *self,
|
||||
NMPlatform *platform,
|
||||
|
|
@ -286,4 +290,7 @@ const char *nm_modem_ip_type_to_string (NMModemIPType ip_type);
|
|||
|
||||
guint32 nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source);
|
||||
|
||||
void _nm_modem_set_operator_code (NMModem *self, const char *operator_code);
|
||||
void _nm_modem_set_apn (NMModem *self, const char *apn);
|
||||
|
||||
#endif /* __NETWORKMANAGER_MODEM_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue