libmm-glib: generic warning if IP config dictionary has unexpected contents

This commit is contained in:
Aleksander Morgado
2011-12-21 11:13:45 +01:00
parent dcfe2e5390
commit a422f5619f
2 changed files with 17 additions and 35 deletions

View File

@@ -235,42 +235,28 @@ create_ip_config_struct (GVariant *variant)
g_variant_iter_init (&iter, variant); g_variant_iter_init (&iter, variant);
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) { while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
if (g_str_equal (key, "method")) { if (g_str_equal (key, "method")) {
if (c->method) g_warn_if_fail (c->method == 0);
g_warning ("Duplicate 'method' key found in Bearer IP configuration"); c->method = (MMBearerIpMethod) g_variant_get_uint32 (value);
else
c->method = (MMBearerIpMethod) g_variant_get_uint32 (value);
} else if (g_str_equal (key, "address")) { } else if (g_str_equal (key, "address")) {
if (c->address) g_warn_if_fail (c->address == NULL);
g_warning ("Duplicate 'address' key found in Bearer IP configuration"); c->address = g_variant_dup_string (value, NULL);
else
c->address = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "prefix")) { } else if (g_str_equal (key, "prefix")) {
if (c->prefix) g_warn_if_fail (c->prefix == 0);
g_warning ("Duplicate 'prefix' key found in Bearer IP configuration"); c->prefix = g_variant_get_uint32 (value);
else
c->prefix = g_variant_get_uint32 (value);
} else if (g_str_equal (key, "dns1")) { } else if (g_str_equal (key, "dns1")) {
if (c->dns[0]) g_warn_if_fail (c->dns[0] == NULL);
g_warning ("Duplicate 'dns1' key found in Bearer IP configuration"); c->dns[0] = g_variant_dup_string (value, NULL);
else
c->dns[0] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "dns2")) { } else if (g_str_equal (key, "dns2")) {
if (c->dns[1]) g_warn_if_fail (c->dns[1] == NULL);
g_warning ("Duplicate 'dns2' key found in Bearer IP configuration"); c->dns[1] = g_variant_dup_string (value, NULL);
else
c->dns[1] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "dns3")) { } else if (g_str_equal (key, "dns3")) {
if (c->dns[2]) g_warn_if_fail (c->dns[2] == NULL);
g_warning ("Duplicate 'dns3' key found in Bearer IP configuration"); c->dns[2] = g_variant_dup_string (value, NULL);
else
c->dns[2] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "gateway")) { } else if (g_str_equal (key, "gateway")) {
if (c->gateway) g_warn_if_fail (c->gateway == NULL);
g_warning ("Duplicate 'gateway' key found in Bearer IP configuration"); c->gateway = g_variant_dup_string (value, NULL);
else
c->gateway = g_variant_dup_string (value, NULL);
} else } else
g_warning ("Invalid property '%s' found in Bearer IP configuration", key); g_warning ("Unexpected property '%s' found in Bearer IP configuration", key);
} }
/* If no method is set, don't build the config struct */ /* If no method is set, don't build the config struct */

View File

@@ -30,13 +30,9 @@ G_BEGIN_DECLS
/** /**
* MMBearerIpConfig: * MMBearerIpConfig:
* @method: a #MMBearerIpMethod.
* @address: IP address, only if @method is #MM_BEARER_IP_METHOD_STATIC.
* @prefix: Numeric CIDR network prefix, only if @method is #MM_BEARER_IP_METHOD_STATIC.
* @dns: Array of DNS server IP addresses, only if @method is #MM_BEARER_IP_METHOD_STATIC.
* @gateway: IP address of the default gateway, only if @method is #MM_BEARER_IP_METHOD_STATIC.
* *
* Addressing details for assignment to the data interface * Addressing details for assignment to the data interface.
* This is an opaque struct.
*/ */
typedef struct _MMBearerIpConfig MMBearerIpConfig; typedef struct _MMBearerIpConfig MMBearerIpConfig;