Re: Settings empty username for NMSettingGsm not working [SOLVED]



Solved the problem with:
s_gsm = (NMSettingGsm *) nm_setting_gsm_new();
g_object_set (s_gsm,
                  NM_SETTING_GSM_NUMBER,       nc_get_str_or_null(number),
                  NM_SETTING_GSM_USERNAME,     nc_get_str_or_null(username),
                  NM_SETTING_GSM_PASSWORD,     nc_get_str_or_null(password),
                  NM_SETTING_GSM_APN,          nc_get_str_or_null(apn),
                  NM_SETTING_GSM_PIN,          nc_get_str_or_null(pin),
                  NULL);
...

and

static gchar* nc_get_str_or_null(gchar* txt)
{
    if (txt && strlen(txt) > 0)
        return txt;

    return NULL;
}


Cheers,

tom


2011/1/20 toabctl <toabctl googlemail com>
Hi,

i try to set an empty username with:

...
s_gsm = (NMSettingGsm *) nm_setting_gsm_new();
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_USERNAME, "", NULL);
nm_connection_add_setting (connection, NM_SETTING (s_gsm));
GHashTable *hash;
hash = nm_connection_to_hash(connection);
GError* error = NULL;
bus_g_proxy_call (proxy, "AddConnection", &error,
                  DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
                  G_TYPE_INVALID);
if(error != NULL)
{
g_warning("Error ModemGSM: %s", error->message);
g_error_free(error);
}
...

But the Error message is:  Error ModemGSM: username


in libnm-util/nm-setting-gsm.c :
if (priv->username && !strlen (priv->username)) {
g_set_error (error,
            NM_SETTING_GSM_ERROR,
            NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
            NM_SETTING_GSM_USERNAME);
return FALSE;
}


Why must strlen(username) > 0 ? There s no reason for that. Empty usernames should be possible.


Cheers,
Tom




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]