Add nm_utils_wifi_strength_bars(), which figures out whether the
terminal can display graphical wifi strength bars, and converts a
numerical value to the appropriate Unicode or ASCII characters.
This also now takes into consideration the fact that the console font
doesn't contain all of the necessary characters, so we can't display
the graphical bars there. (rh #1131491)
Use g_print() and g_printerr(), which wrap printf() and
fprintf(stderr,...), but handle conversion from UTF-8 if the locale is
using a different character set.
Make synchronous APIs take GCancellables, and make asynchronous APIs
use GAsyncReadyCallbacks and have names ending in "_async", with
"_finish" functions to retrieve the results.
Also, make nm_client_activate_connection_finish(),
nm_client_add_and_activate_finish(), and
nm_remote_settings_add_connection_finish() be (transfer full) rather
than (transfer none), because the refcounting semantics become
slightly confusing in some edge cases otherwise.
Merge nm_remote_settings_add_connection() and
nm_remote_settings_add_connection_unsaved(), and likewise
nm_remote_connection_commit_changes() and
nm_remote_connection_commit_changes_unsaved(), by adding a boolean
flag to each saying whether to save to disk.
The entry can't be empty. Otherwise removing the value and saving connection
would result in the primary option containing only the first character of the
original value.
Check whether NM is running before comparing nmcli and NM versions. Returning
NMC_RESULT_ERROR_NM_NOT_RUNNING is in accordance with other nmcli commands.
Applies to status commands such as "nmcli radio" or "nmcli g status".
This is consistent with other commands.
The "RUNNING" field is now always "running", the tool will just return
an error instead of setting it to "not running". It never signalled
whether the daemon was actually running anyway, only whether the client
managed to connect to it.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Port libnm-core/libnm to GDBus.
The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.
This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
libnm-util's connection deserializing/copying/replacing functions have
odd semantics where sometimes they both modify a connection AND return
an error. libnm-core tried to improve things by guaranteeing that the
connection would not be modified if the new settings were invalid, but
this ended up breaking a bunch of places that needed to be able to
work with invalid connections. So re-fix the functions by reverting
back to the old semantics, but having return values that clearly
distinguish whether the connection was modified or not.
For comparison:
- nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():
- libnm-util: returns a valid connection or NULL.
- OLD libnm-core: returned a valid connection or NULL.
- NEW libnm-core: returns a valid connection or NULL.
- nm_connection_duplicate() / nm_simple_connection_new_clone():
- libnm-util: always succeeds, whether or not the connection is
valid.
- OLD libnm-core: returned a valid connection or NULL
- NEW libnm-core: always succeeds, whether or not the connection
is valid.
- nm_connection_replace_settings_from_connection():
- libnm-util: always replaces the settings, but returns FALSE if
the connection is now invalid.
- OLD libnm-core: either replaced the settings and returned TRUE
(if the settings were valid), or else left the connection
unchanged and returned FALSE (if not).
- NEW libnm-core: always replaces the settings, and has no
return value. (The modified connection is valid if and only if
the replaced-from connection was valid; just like with the
libnm-util version.)
- nm_connection_replace_settings():
- libnm-util: returns TRUE if the new settings are valid, or
FALSE if either (a) the new settings could not be deserialized
and the connection is unchanged, or (b) the new settings were
deserialized, and the connection was updated, but is now not
valid.
- OLD libnm-core: either replaced the settings and returned TRUE
(if the settings were valid), or else left the connection
unchanged and returned FALSE (if not).
- NEW libnm-core: returns TRUE if the connection was updated
(whether or not it is valid), or FALSE if the new settings
could not be deserialized and the connection is unchanged.
Make register() and unregister() have cancellable sync and async
variants. And make NMSecretAgent implement GInitable/GAsyncInitable,
and do the initial auto-registration as part of initialization rather
than doing it asynchronously and emitting a signal.
The actual entry is a sub-widget, and was getting updated when the
user changed the password, but those changes were not being
propagated to the NmtPasswordFields object's 'password' property.
https://bugzilla.gnome.org/show_bug.cgi?id=733002
nmt_sync_op_complete_pointer() completes the operation after the
caller of this function returns. This means that any values passed
to this function must either be allocated from its caller, or
referenced by the caller.
nm_remote_connection_get_secrets() owns the 'secrets' hash passed
to the callback, and it is destroyed when the callback returns.
So nmtui's got_secrets() must copy the hash to ensure the data
sticks around for nmt_sync_op_wait_pointer() later.
Make NMIP4Config:nameservers, NMIP4Config:wins-servers, and
NMIP6Config:nameservers be G_TYPE_STRV, with stringified IP addresses,
and update the APIs accordingly.
libnm functions that return GPtrArrays of objects had a rule that if
the array was empty, they would return NULL rather than a 0-length
array. As it turns out, this is just a nuisance to clients, since in
most places the code for the non-empty case would end up doing the
right thing for the empty case as well (and where it doesn't, we can
check "array->len == 0" just as easily as "array == NULL"). So just
return the 0-length array instead.
The NMDevice:state-reason property was awkward to work with since it
was a tuple of two values (state and reason), and likewise, although
we had nm_device_get_state() to return just the state, there was no
corresponding function to get just the reason.
Fix this; make the state-reason property contain just the
NMDeviceStateReason, and make nm_device_get_state_reason() return just
that.
Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and
update corresponding APIs. Notably, this means they are now refcounted
rather than being copied.
Update the rest of NM for the changes. The daemon still converts SSIDs
to GByteArrays internally, because changing it to use GBytes has lots
of trickle-down effects. It can possibly be changed later.
APIs that take arbitrary data should take it in the form of a pointer
and length, not a GByteArray, so that you can use them regardless of
what format you have the data in (GByteArray, GBytes, plain array,
etc).
Make the :addresses and :routes properties be GPtrArrays of
NMIP4Address, etc, rather than just reflecting the D-Bus data.
Make the :dns properties be arrays of strings rather than arrays of
binary IP addresses (and update the corresponding APIs as well).
Change all DBUS_TYPE_G_MAP_OF_STRING properties to G_TYPE_HASH_TABLE,
with annotations indicating they are string->string. Not much outside
libnm-core needs to changed for this, since DBUS_TYPE_G_MAP_OF_STRING
was already represented as a hash table.
(One change needed within libnm-core is that we now need to copy the
hash tables in get_property(), or else the caller will receive a
reffed copy of the object's own hash table, which we don't want.)
Change all DBUS_TYPE_G_LIST_OF_STRING and DBUS_TYPE_G_ARRAY_OF_STRING
properties to G_TYPE_STRV, and update everything accordingly.
(This doesn't actually require using
_nm_setting_class_transform_property(); dbus-glib is happy to transform
between 'as' and G_TYPE_STRV.)