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);
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
if (g_str_equal (key, "method")) {
if (c->method)
g_warning ("Duplicate 'method' key found in Bearer IP configuration");
else
g_warn_if_fail (c->method == 0);
c->method = (MMBearerIpMethod) g_variant_get_uint32 (value);
} else if (g_str_equal (key, "address")) {
if (c->address)
g_warning ("Duplicate 'address' key found in Bearer IP configuration");
else
g_warn_if_fail (c->address == NULL);
c->address = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "prefix")) {
if (c->prefix)
g_warning ("Duplicate 'prefix' key found in Bearer IP configuration");
else
g_warn_if_fail (c->prefix == 0);
c->prefix = g_variant_get_uint32 (value);
} else if (g_str_equal (key, "dns1")) {
if (c->dns[0])
g_warning ("Duplicate 'dns1' key found in Bearer IP configuration");
else
g_warn_if_fail (c->dns[0] == NULL);
c->dns[0] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "dns2")) {
if (c->dns[1])
g_warning ("Duplicate 'dns2' key found in Bearer IP configuration");
else
g_warn_if_fail (c->dns[1] == NULL);
c->dns[1] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "dns3")) {
if (c->dns[2])
g_warning ("Duplicate 'dns3' key found in Bearer IP configuration");
else
g_warn_if_fail (c->dns[2] == NULL);
c->dns[2] = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, "gateway")) {
if (c->gateway)
g_warning ("Duplicate 'gateway' key found in Bearer IP configuration");
else
g_warn_if_fail (c->gateway == NULL);
c->gateway = g_variant_dup_string (value, NULL);
} 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 */

View File

@@ -30,13 +30,9 @@ G_BEGIN_DECLS
/**
* 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;