Commit graph

81 commits

Author SHA1 Message Date
Dan Winship e2f5343b08 tui: fix an NmtMacEntry bug introduced when changing hwaddrs to strings
https://bugzilla.redhat.com/show_bug.cgi?id=1148921
2014-10-02 13:18:26 -04:00
Thomas Haller b662fbf450 cli: support new bond option 'lacp_rate'
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-02 16:36:11 +02:00
Jiří Klimeš 7e67fd2b24 libnm: return errors in nm_client_networking_set_enabled()
and do not print an error in the library. The caller can decide what to do
on an error.
2014-10-01 11:53:07 +02:00
Jiří Klimeš 8919a8572a cli: strip errors from D-Bus before presenting to a user 2014-10-01 11:53:07 +02:00
Jiří Klimeš f585085907 cli: rename network-manager.[ch] to general.[ch] 2014-10-01 11:53:07 +02:00
Dan Winship e684f36365 libnm-core: add nm_utils_wifi_strength_bars(), use it in nmcli and nmtui
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)
2014-09-27 11:49:15 -04:00
Dan Winship 1b74e77f9f cli: use g_print/g_printerr rather than printf/fprintf
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.
2014-09-27 11:45:53 -04:00
Jiří Klimeš 9eabe9c5f6 cli: move "CONNECTIONS" group lower in the output 2014-09-25 19:09:06 +02:00
Jiří Klimeš 6c27af6385 cli: show capabilities for Bluetooth devices 2014-09-25 19:09:05 +02:00
Jiří Klimeš 0b6bd87848 cli: also show team and bridge specific details for devices
Now it is only SLAVES field, common for bond, team and bridge devices.
2014-09-25 19:09:05 +02:00
Dan Winship 2237ea3ddb libnm: make sync/async APIs more GLib-like
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.
2014-09-25 09:29:20 -04:00
Dan Winship 6ca10677d6 libnm: merge saved and unsaved connection methods
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.
2014-09-25 09:29:20 -04:00
Jiří Klimeš 37f12088e4 tui: additional fix for 'primary' option
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.
2014-09-23 08:27:49 +02:00
Jiří Klimeš 3784678177 cli: create a connection if none exist in 'nmcli dev connect' (rh #1113941)
https://bugzilla.redhat.com/show_bug.cgi?id=1113941
2014-09-22 13:10:43 +02:00
Jiří Klimeš dc1c17fd30 cli: get NMClient early and remove duplicated code 2014-09-22 12:53:46 +02:00
Jiří Klimeš f27a259ee6 cli: when NM is not running, give this error in 'nmcli connection'
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.
2014-09-22 12:53:46 +02:00
Lubomir Rintel 82947737b1 cli: return a failure status when the daemon is not running (bgo #698060)
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>
2014-09-22 12:53:46 +02:00
Jiří Klimeš 2f369559cb tui: fix displaying bond ARP IP targets
GLib-GObject-WARNING **: g_object_set_valist: object class `NmtAddressList' has no property named `string'
2014-09-22 12:30:44 +02:00
Jiří Klimeš b0b51ec5ef tui: don't call g_strv_length() on NULL
GLib-CRITICAL **: g_strv_length: assertion `str_array != NULL' failed
2014-09-22 12:25:20 +02:00
Lubomir Rintel a36a3a9a52 tui/bond: remove primary option if mode is not active-backup (rh #1142864)
Just drop it as we disable the widget in UI.

https://bugzilla.redhat.com/show_bug.cgi?id=1142864
2014-09-22 10:54:15 +02:00
Jiří Klimeš 8ee53b79f6 cli: fix crash by getting addresses and routes
Broken by commit 6793a32a8c that changed
return values from GSlist to GPtrArray.
2014-09-19 22:59:39 +02:00
Dan Winship c6f4c354fe tui: fix an earlier bugfix
Fix to f69842aa; the arguments weren't swapped, one of them was just
completely superfluous.
2014-09-19 10:05:46 -04:00
Dan Winship 2e197706b7 tui: fix a double free
The dictionary passed to the NMSecretAgent get_secrets callback will
get sunk if it's floating, so we shouldn't be unreffing it.
2014-09-19 09:43:01 -04:00
Dan Winship 783e37a288 tui: bind the leap-username property to its entry 2014-09-19 09:10:24 -04:00
Jiří Klimeš 4359e556e4 tui,examples: accept null SSID gracefully
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736802
2014-09-19 09:07:16 -04:00
Dan Winship 6793a32a8c libnm: port to GDBus
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).
2014-09-18 11:51:09 -04:00
Dan Winship acf86f68b3 libnm-core: change connection hash tables to variants in API
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.
2014-09-18 11:51:09 -04:00
Dan Winship ca5f23a8b6 tui: fix an out-of-date comment
nmtui-connect.c claimed that it didn't implement deactivation yet, but
that was implemented long ago.
2014-09-17 08:27:15 -04:00
Dan Winship ad8b13091b libnm-core: fix up connection deserialize/copy/replace semantics
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.
2014-09-17 08:21:21 -04:00
Dan Winship b9f9fd39ab Revert "tui: fix a crash"
This reverts commit c0ecd2f628.
2014-09-17 08:21:21 -04:00
Jiří Klimeš b81175f4ca tui: fix error: ‘return’ with no value, in function returning non-void 2014-09-16 18:26:17 +02:00
Dan Winship 054bf2bb74 tui: add support for editing DSL connections (rh #1105753) 2014-09-16 07:58:38 -04:00
Dan Winship 030dace710 tui: reorganize page-creation code a bit
Allow each page type to specify whether it should be shown by default,
letting us simplify NmtPageMain.
2014-09-16 07:58:37 -04:00
Dan Winship b05b342ceb tui: add support for borderless NmtNewtSections 2014-09-16 07:58:37 -04:00
Dan Winship c0ecd2f628 tui: fix a crash
NMSettingIP4Config:dns is NULL if no DNS servers are set
2014-09-15 09:31:21 -04:00
Dan Winship d3b53b707a libnm: start glib-ifying NMSecretAgent APIs
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.
2014-09-09 12:16:38 -04:00
Jiří Klimeš c6a932a2ce cli: fix ssid parameter processing in 'nmcli con add'
(broken by commit c43f88907b)
2014-09-09 16:54:32 +02:00
Dan Winship 730d096fe1 cli: fix MAC address validation (bgo #736275)
nm_utils_hwaddr_valid() accepts length while check_mac() mistakenly passes
type.

(broken by 3a54d05098)

https://bugzilla.gnome.org/show_bug.cgi?id=736275
2014-09-09 11:13:00 +02:00
Dan Williams 82b0ea8707 tui: fix updating of NmtPasswordFields passwords (bgo #733002)
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
2014-09-04 09:49:14 -05:00
Dan Williams 240a9a92ae tui: fix requesting and displaying secrets
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.
2014-09-04 09:49:10 -05:00
Dan Winship 356fb7d77e libnm: drop libnm IP-address-array types, use G_TYPE_STRV
Make NMIP4Config:nameservers, NMIP4Config:wins-servers, and
NMIP6Config:nameservers be G_TYPE_STRV, with stringified IP addresses,
and update the APIs accordingly.
2014-09-04 09:21:05 -04:00
Dan Winship 3e5b3833aa libnm: change empty-GPtrArray-return semantics
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.
2014-09-04 09:21:05 -04:00
Dan Winship 20dc44bda9 libnm: drop NM_TYPE_SSID, use G_TYPE_BYTES
Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding
APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship 4eb04dbcf8 libnm: drop NM_TYPE_STRING_ARRAY, use G_TYPE_STRV
Make NMIP4Config and NMIP6Config's array-of-string properties be
G_TYPE_STRV, and update the corresponding APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship f71218d70a libnm: simplify NMDevice:state-reason
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.
2014-09-04 09:21:04 -04:00
Dan Winship c43f88907b libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES
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.
2014-09-04 09:20:11 -04:00
Dan Winship 3fbabde4c3 libnm-core: replace GByteArray with pointer + length in some APIs
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).
2014-09-04 09:20:11 -04:00
Dan Winship 9837565789 libnm-core: improve NMSettingIP4Config / NMSettingIP6Config property types
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).
2014-09-04 09:20:11 -04:00
Dan Winship 9ed6bd2be5 libnm-core: change map-of-string properties to G_TYPE_HASH_TABLE
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.)
2014-09-04 09:20:11 -04:00
Dan Winship 6a4127cfa0 libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV
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.)
2014-09-04 09:20:10 -04:00