Commit Graph

160 Commits

Author SHA1 Message Date
Thomas Haller
5183399744 clients: cleanup parse_ip_address 2017-05-23 13:37:10 +02:00
Thomas Haller
9a3e35cc0e clients: don't use nmc_string_to_int_base() and nmc_string_to_uint_base() util
They are redundant.
2017-05-23 13:37:10 +02:00
Thomas Haller
1371116ea2 clients: implement wireless.mac-address-randomization property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
cc79b1a554 clients: implement wired.wake-on-lan property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
d48998b4e8 clients: implement tun.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
3341e89e7c clients: implement macvlan.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
5a98837b23 clients/trivial: whitespace 2017-05-23 13:37:10 +02:00
Thomas Haller
d76c190dc7 clients: fix appending integer to result in nmc_property_set_bytes() 2017-05-23 13:27:24 +02:00
Beniamino Galvani
30393ee236 clients: fix setter for 802-1x.password-raw
The property is a GBytes, not a GByteArray.

https://bugzilla.gnome.org/show_bug.cgi?id=782836
2017-05-23 13:27:24 +02:00
Thomas Haller
234bc0adcf cli: fix use-after-free in _get_fcn_gobject_enum()
Fixes: ddfff04a45
2017-05-15 15:16:22 +02:00
Lubomir Rintel
2899bb3429 cli: add support for the WPS property 2017-05-15 12:59:55 +02:00
Beniamino Galvani
00df57a066 clients: print expected route syntax on parsing failure
Now that routes can include optional attributes, print the expected
syntax in case of parsing failure.

 $ nmcli connection modify dummy ipv4.routes a
 Error: failed to modify ipv4.routes: invalid route: Invalid IPv4
 address 'a'. The valid syntax is: 'ip[/prefix] [next-hop] [metric]
 [attribute=val]... [,ip[/prefix] ...]'.
2017-05-08 10:09:30 +02:00
Beniamino Galvani
6181f41d8d cli: support for wifi-sec.pmf property 2017-04-28 09:46:06 +02:00
Thomas Haller
da5a6534bc cli: fix _values_fcn_gobject_enum() for flag types
For flags, the integer is cast to "unsigned", hence, the min/max
range must be different.

Fixes: f53218ed7c
2017-04-27 17:59:51 +02:00
Thomas Haller
83a6f36207 cli: don't mark field names for translation
Before refactoring nmcli recently, field names were marked for translation.
Note that for the property names, marking them had no effect as only
plain strings can be marked with N_().

Note how --fields are also an input argument. The input should be
independent of the locale and not translated. Likewise, when printing
the header names, they should not be translated to match the --fields
option.

    $ LANG=de_DE.utf8 nmcli --fields GENERAL.DEVICE device show enp0s25
    GENERAL.GERÄT:                          enp0s25

Drop the translation marks.
2017-04-23 23:45:02 +02:00
Thomas Haller
7aab314cef cli: fix marking settings docs for translation
Text for translation cannot contain defines (or variables). We must
generate the description docs with plain N_() values.
2017-04-23 23:45:02 +02:00
Thomas Haller
b20092b51e cli: fix marking setting pretty name for translation 2017-04-23 23:45:02 +02:00
Thomas Haller
9fcbe4ff71 cli: don't use #define for translation texts
Text for translation cannot contain defines (or variables).
2017-04-23 23:45:02 +02:00
Thomas Haller
6dfb3e9ffb cli/trivial: remove whitespace between N_ macro and parenthesis
For _() and N_() we don't have a space before the parenthesis.
Be consistent about that.
2017-04-19 18:27:19 +02:00
Beniamino Galvani
afca8a4c0f clients: fix setting of enum properties
Ensure we call G_IS_ENUM_CLASS() or G_IS_FLAGS_CLASS() only on classed
types.

 $ nmcli connection modify foobar wifi.powersave 1
 Thread 1 "nmcli" received signal SIGSEGV, Segmentation fault.
 0x0000000000440a4d in _set_fcn_gobject_enum at
 clients/common/nm-meta-setting-desc.c:985
 985                 || G_IS_ENUM_CLASS (gtype_prop)) {

Fixes: f53218ed7c
2017-04-18 13:40:02 +02:00
Lubomir Rintel
738c2fcefc clients/meta-setting-desc: fix an unintentional fallthrough
Fixes: ddfff04a45
2017-04-15 12:30:02 +02:00
Thomas Haller
275ab5fb8f cli: make properties list a list of pointers
That allows for the property list to contain derived
property types. Also, the list can be directly passed
off as a "const NMMetaAbstractInfo *const*" list.
2017-04-13 10:10:12 +02:00
Thomas Haller
f2b5a42c7c cli: let NMMetaNestedPropertyInfo derive NMMetaPropertyInfo 2017-04-13 10:10:12 +02:00
Thomas Haller
6d12d2f3a0 cli: move setting creation to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
b629b98687 cli: move completion for connection type to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
2a760897f2 cli: move completion for master connections to meta data
This change (improves) behavior.

Before, we would only complete
  if (g_strcmp0 (con_type, nmc_tab_completion.con_type) != 0)
which doesn't really make sense as it depends on the slave-type,
not nmc_tab_completion.con_type.
2017-04-12 14:12:20 +02:00
Thomas Haller
1e4bc51a4a cli: move completion for devices names to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
d32817999c cli: move information about valid connection settings to common 2017-04-12 14:12:20 +02:00
Thomas Haller
3ed0fc1b45 cli: move setting alias to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
6c2727af14 cli: add meta data for NMSettingGeneric 2017-04-12 14:12:20 +02:00
Thomas Haller
0fa5fc3f51 cli: move completing VPN service types to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
0b7e9c3bef cli: move prompting for boolean values to meta data
This changes behavior, in that yes|no prompt and answer is no longer
localized.

For command line arguments, I think it is always wrong for nmcli to
behave differently based on the localization. That is, input properties
on command line should not be translated.

One could make an argument, that in interactive mode that is different
and the user can be prompted in the his language.

But I think for consistency, it is wrong to ask for localized nmcli input.
2017-04-12 14:12:19 +02:00
Thomas Haller
cfd9f66ae9 cli: add property completion to meta-data
(not used yet).
2017-04-12 14:12:19 +02:00
Thomas Haller
4f19c46a1e cli: move part of setting meta data from "connection.c"'s OptionInfo 2017-04-12 14:12:19 +02:00
Thomas Haller
2ba39a3b33 cli: don't translate <hidden> text in terse mode 2017-04-12 14:10:56 +02:00
Thomas Haller
ddfff04a45 cli: extend NMMetaSettingInfoEditor's get_fcn() to support different output forms 2017-04-12 14:10:56 +02:00
Thomas Haller
b7efa62745 cli: cleanup meta data virtual function arguments
- have the "self" argument first, before the environment arguments.
  It's more idiomatic.
- from within cli, always pass nmc_meta_environment and nmc_meta_arg
  where needed.
- drop the union in NMMetaAbstractInfo. I was suppost to make casts
  nicer, but it doesn't really.
2017-04-12 14:00:00 +02:00
Thomas Haller
41b31051f2 cli: use nmc_print() to output device's IP4 info
The IP4 info adds a new type: to expose strv arguments
for addresses, etc.
2017-04-12 14:00:00 +02:00
Thomas Haller
3045daf127 cli: use nmc_print() to output setting data 2017-04-12 11:24:04 +02:00
Thomas Haller
0b92c26bda cli: fix invalid assertion
Fixes: 19c70ace95
2017-04-06 15:41:27 +02:00
Thomas Haller
e3a07633dc cli: fix signature of NMMetaAbstractType:get_fcn()
Depending on the get_type argument, we don't only want
to return strings, but arbitrary pointers.

The out_to_free argument still makes sense, but depending on
the get-type you must know how to free the pointer.
2017-04-05 16:53:06 +02:00
Thomas Haller
bb40abb3de cli: move nmc_bond_validate_mode() to "clients/common/nm-client-utils.h"
"clients/common/nm-client-utils.h" already contains other nmc_* validation functions.
It's the better place for nmc_bond_validate_mode()
2017-04-05 16:53:06 +02:00
Thomas Haller
d32590041f cli: change checking for get-type PRETTY making PARSABLE the default
Currently we only have two get-types: PRETTY and PARSABLE.
In the future we may want to add more of those, so the
default behavior when encountering an unrecognized get-type
should be PARSABLE.

Don't ever check whether get-type is PARSABLE. Check instead,
whether it is PRETTY (the non-default) or do the default (PARSABLE).
2017-04-05 16:53:06 +02:00
Thomas Haller
19c70ace95 cli: add get_fcn() to NMMetaAbstractInfo 2017-04-05 16:53:06 +02:00
Thomas Haller
137273669d cli: add nmc_output_selection_create() to parse field selection
nmc_output_selection_create() returns a less opaque result then
a GArray and a GPtrArray for the groups.
2017-04-05 16:53:06 +02:00
Thomas Haller
bfb9fd0d2f cli: split tracking of meta data out of NmcOutputField
When generating output data, nmcli iterates over a list of
property-descriptors (nmc_fields_ip4_config), creates an intermediate
array (output_data) and finally prints it.

However, previously both the meta data (nmc_fields_ip4_config) and
the intermediate format use the same type NmcOutputField. This means,
certain fields are relevant to describe a property, and other fields
are output/formatting fields.

Split this up. Now, the meta data is tracked in form of an NMMetaAbstractInfo
lists. This separates the information about properties from intermediate steps
during creation of the output.

Note that currently functions like print_ip4_config() still have all the
knowledge about how to generate the output. That is wrong, instead, the
meta data (NMMetaAbstractInfo) should describe how to create the output
and then all those functions could be replaced. This means, later we want
to add more knowledge to the NMMetaAbstractInfo, so it is important to
keep them separate from NmcOutputField.
2017-04-05 16:53:06 +02:00
Thomas Haller
6a489199b9 cli: make setting meta data more generic
Embed a @meta_type structure in NMMetaSettingInfoEditor and
NMMetaPropertyInfo. This allows to make the NMMeta*Info instances
themself to become generic and they can be passed around as generic
NMMetaAbstractInfo types.
For one, the embedded NMMetaType pointer can be used to determine
of which type a NMMetaAbstractInfo instance is. On the other hand,
the NMMetaType struct can be extended to be a VTable to provide
generic access to the type.
In the end, both NMMetaSettingInfoEditor and NMMetaPropertyInfo are
conceptionally very similar: the describe a certain type and provide
accessors.

In nmcli we have yet another NMMetaAbstractInfo type: NmcOutputField
will be modified to become another implementation of meta data (it
already is, it just cannot be used interchangable with the other
types).

Also, embed the NMMetaSettingInfoEditor in the NMMetaPropertyInfo
instance. This allows from a given NMMetaPropertyInfo to retrieve it's
parent NMMetaSettingInfoEditor.
2017-04-05 16:53:06 +02:00
Thomas Haller
cecee19b2b cli: move pre-check for setting connection:secondaries out of nm-meta-setting-desc.c
This check requires additional information about the environment, that
is about the present connections in NMClient.

"nm-meta-setting-desc.c" should be independent from the libnm D-Bus
cache, hence move this code to "settings.c".
2017-04-05 16:53:06 +02:00
Thomas Haller
2379af7e36 cli: notify warning via NMMetaEnvironment instead of printing directly from "nm-meta-setting-desc.h"
The lower layers are concerned with handling settings. They should not
be aware of how to notify about warnings. Instead, signal them via
the warn_fcn() hook.
2017-04-05 16:53:06 +02:00
Thomas Haller
17f9191656 cli: don't register tranform-functions for GValues when setting GObject property
For G_TYPE_BOOLEAN, let it get handled by the getter hook instead
of modifying system-wide behavior of glib.

Also, there are no properties of G_TYPE_CHAR. Just drop that.
2017-04-05 16:53:05 +02:00