Commit c62701f6 authored by Dan Williams's avatar Dan Williams

modem: get and save modem master device

For later use identifying the actual physical modem device instead
of just one of the modem's ports.
parent 0e510370
......@@ -62,10 +62,12 @@ nm_cdma_error_get_type (void)
NMDevice *
nm_modem_cdma_new (const char *path,
const char *data_device,
const char *driver)
const char *device,
const char *data_device,
const char *driver)
{
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (data_device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
......@@ -75,6 +77,7 @@ nm_modem_cdma_new (const char *path,
NM_DEVICE_INTERFACE_DRIVER, driver,
NM_DEVICE_INTERFACE_MANAGED, TRUE,
NM_MODEM_PATH, path,
NM_MODEM_DEVICE, device,
NULL);
}
......
......@@ -28,8 +28,9 @@ typedef struct {
GType nm_modem_cdma_get_type (void);
NMDevice *nm_modem_cdma_new (const char *path,
const char *data_device,
const char *driver);
const char *device,
const char *data_device,
const char *driver);
G_END_DECLS
......
......@@ -80,11 +80,13 @@ nm_gsm_error_get_type (void)
NMDevice *
nm_modem_gsm_new (const char *path,
const char *data_device,
const char *driver,
guint32 ip_method)
const char *device,
const char *data_device,
const char *driver,
guint32 ip_method)
{
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (data_device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
......@@ -95,6 +97,7 @@ nm_modem_gsm_new (const char *path,
NM_DEVICE_INTERFACE_MANAGED, TRUE,
NM_MODEM_PATH, path,
NM_MODEM_IP_METHOD, ip_method,
NM_MODEM_DEVICE, device,
NULL);
}
......
......@@ -28,9 +28,10 @@ typedef struct {
GType nm_modem_gsm_get_type (void);
NMDevice *nm_modem_gsm_new (const char *path,
const char *data_device,
const char *driver,
guint32 ip_method);
const char *device,
const char *data_device,
const char *driver,
guint32 ip_method);
G_END_DECLS
......
......@@ -50,6 +50,7 @@ nm_modem_manager_get (void)
static gboolean
get_modem_properties (DBusGConnection *connection,
const char *path,
char **device,
char **data_device,
char **driver,
guint32 *type,
......@@ -65,11 +66,11 @@ get_modem_properties (DBusGConnection *connection,
"org.freedesktop.DBus.Properties");
if (dbus_g_proxy_call_with_timeout (proxy, "Get", 15000, &err,
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
G_TYPE_STRING, "Type",
G_TYPE_INVALID,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
G_TYPE_STRING, "Type",
G_TYPE_INVALID,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
*type = g_value_get_uint (&value);
g_value_unset (&value);
} else {
......@@ -77,6 +78,19 @@ get_modem_properties (DBusGConnection *connection,
goto out;
}
if (dbus_g_proxy_call_with_timeout (proxy, "Get", 15000, &err,
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
G_TYPE_STRING, "MasterDevice",
G_TYPE_INVALID,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
*device = g_value_dup_string (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get device: %s", err->message);
goto out;
}
if (dbus_g_proxy_call_with_timeout (proxy, "Get", 15000, &err,
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
G_TYPE_STRING, "IpMethod",
......@@ -130,8 +144,7 @@ create_modem (NMModemManager *manager, const char *path)
{
NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (manager);
NMDevice *device;
char *data_device = NULL;
char *driver = NULL;
char *data_device = NULL, *driver = NULL, *master_device = NULL;
uint modem_type = MM_MODEM_TYPE_UNKNOWN;
uint ip_method = MM_MODEM_IP_METHOD_PPP;
......@@ -140,8 +153,9 @@ create_modem (NMModemManager *manager, const char *path)
return;
}
if (!get_modem_properties (nm_dbus_manager_get_connection (priv->dbus_mgr), path,
&data_device, &driver, &modem_type, &ip_method))
if (!get_modem_properties (nm_dbus_manager_get_connection (priv->dbus_mgr),
path, &master_device, &data_device, &driver,
&modem_type, &ip_method))
return;
if (modem_type == MM_MODEM_TYPE_UNKNOWN) {
......@@ -149,6 +163,11 @@ create_modem (NMModemManager *manager, const char *path)
return;
}
if (!master_device || !strlen (master_device)) {
nm_warning ("Modem with path %s has unknown device, ignoring", path);
return;
}
if (!driver || !strlen (driver)) {
nm_warning ("Modem with path %s has unknown driver, ignoring", path);
return;
......@@ -160,9 +179,9 @@ create_modem (NMModemManager *manager, const char *path)
}
if (modem_type == MM_MODEM_TYPE_GSM)
device = nm_modem_gsm_new (path, data_device, driver, ip_method);
device = nm_modem_gsm_new (path, master_device, data_device, driver, ip_method);
else if (modem_type == MM_MODEM_TYPE_CDMA)
device = nm_modem_cdma_new (path, data_device, driver);
device = nm_modem_cdma_new (path, master_device, data_device, driver);
else
g_error ("Invalid modem type");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment