Commit Graph

46 Commits

Author SHA1 Message Date
Thomas Haller
9bba4871f3 build: move "libnm/" to "src/" and split it
Like with "libnm-core/", split "libnm/" into different directories for
the public headers, for the implementation and for the helper "aux"
library.
2021-02-24 12:48:37 +01:00
Thomas Haller
9dc84b32b0 build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +01:00
Thomas Haller
606612ea59 all: add "libnm/nm-default-client.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
977ea352a0 all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Thomas Haller
88071abb43 all: unify comment style for SPDX-License-Identifier tag
Our coding style recommends C style comments (/* */) instead of C++
(//). Also, systemd (which we partly fork) uses C style comments for
the SPDX-License-Identifier.

Unify the style.

  $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
2020-09-29 16:50:53 +02:00
Thomas Haller
8841d529e1 format: manually replace remaining tabs with spaces and reformat 2020-09-29 09:12:27 +02:00
Thomas Haller
740b092fda format: replace tabs for indentation in code comments
sed -i \
     -e 's/^'$'\t'' \*/     */g' \
     -e 's/^'$'\t\t'' \*/         */g' \
     -e 's/^'$'\t\t\t'' \*/             */g' \
     -e 's/^'$'\t\t\t\t'' \*/                 */g' \
     -e 's/^'$'\t\t\t\t\t'' \*/                     */g' \
     -e 's/^'$'\t\t\t\t\t\t'' \*/                         */g' \
     -e 's/^'$'\t\t\t\t\t\t\t'' \*/                             */g' \
     $(git ls-files -- '*.[hc]')
2020-09-28 16:07:52 +02:00
Antonio Cardace
328fb90f3e all: reformat all with new clang-format style
Run:

    ./contrib/scripts/nm-code-format.sh -i
    ./contrib/scripts/nm-code-format.sh -i

Yes, it needs to run twice because the first run doesn't yet produce the
final result.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 16:07:51 +02:00
Thomas Haller
ba42189bb9 all: add trailing semicolon to NM_UTILS_LOOKUP_DEFINE()/NM_GOBJECT_PROPERTIES_DEFINE*() 2020-07-19 12:12:58 +02:00
Sayed Shah
7337ab8959 all: fix typo in man pages
There should be a comma after 'Otherwise' and 'Currently'.

https://bugzilla.redhat.com/show_bug.cgi?id=1852452

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/560
2020-07-03 10:48:04 +02:00
Thomas Haller
ec332e3a25 cli: show differnt text for state of externally connected devices 2020-06-10 19:45:47 +02:00
Thomas Haller
38a79ca5cd cli: split parsing from nmc_utils_read_passwd_file()
Makes it easier testable.
2020-05-13 10:28:04 +02:00
Thomas Haller
360f0fae11 cli: move nmc_utils_read_passwd_file() to "common/nm-client-utils.c" 2020-05-13 10:28:04 +02:00
Thomas Haller
f69746c9f9 clients: avoid compiler warning about redefining NDEBUG for qrcodegen
[1/5] Compiling C object 'clients/common/913ef36@@nmc-base@sta/nm-client-utils.c.o'.
  ../clients/common/nm-client-utils.c:528: warning: "NDEBUG" redefined
    528 | #define NDEBUG
        |
  <command-line>: note: this is the location of the previous definition
2020-01-15 22:25:21 +01:00
Lubomir Rintel
c820c98f2a clients: draw border around qr code on linux console
Scanners won't recognize it on black background otherwise.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/327
2019-11-05 16:32:20 +01:00
Lubomir Rintel
7061341a41 cli: add "nmcli d wifi show"
A quick overview of the currently connected Wi-Fi network, including
credentials. Comes handy if someone wants to connect more devices to
their Hotspot or the same network as they are connected to.
2019-10-18 17:38:57 +02:00
Lubomir Rintel
2ca172ebea utils: correct caching of can_show_graphics
It's being forgotten unless it's also static. Spotted by Thomas in the
code that was copied from here.
2019-10-18 17:38:57 +02:00
Thomas Haller
3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Thomas Haller
abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Lubomir Rintel
24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Thomas Haller
bb4e5a7a62 cli: don't treat empty string as valid number in nmc_string_to_uint_base()
How hard can it be to use strtol()? Apparently very. You need to check
errno, the endpointer, and also not pass in an empty string.

Previously, nmc_string_to_uint_base() would silently accept "" as valid
number. That's a bug.

Btw, let's not use strtol() (or nmc_string_to_uint*()). We have
_nm_utils_ascii_str_to_int64(), which gets all of this right.
2019-03-25 09:12:32 +01:00
Benjamin Berg
00e64d1332 core/devices: Add P2P Wifi device and peer tracking
This only adds the new device type and simple peer list handling.
2019-01-27 23:45:12 +01:00
Thomas Haller
de3f6cfb98 doc,all: fix spelling of Open vSwitch (instead of OpenVSwitch)
Also affects documentation and translated strings.

Reported-by: Flavio Leitner <fbl@redhat.com>
2018-11-28 14:26:42 +01:00
Thomas Haller
64f1e78e28 cli: drop NMCTriStateValue for NMTernary 2018-08-10 10:38:19 +02:00
Beniamino Galvani
53c2951f61 device: configure SR-IOV 2018-07-11 16:16:22 +02:00
Thomas Haller
6f8f7ad597 cli: rework enum-to-string function to not return translated text
There are cases, where we need the untranslated text.

There is no change of behavior of this patch, because all
callers now explicitly call gettext().
2018-07-09 15:43:55 +02:00
Beniamino Galvani
1f7780cba9 cli: fix property matching
@ret was not initialized when there was only one partial match.

Also, refactor the code to return all matching values.

Fixes: 3fd9bf9d7d

https://github.com/NetworkManager/NetworkManager/pull/123
2018-05-28 11:33:40 +02:00
Lubomir Rintel
3fd9bf9d7d clients: fix an error message in case of property ambiguity
Before:

  $ nmcli c modify Dukkha ipv4.ignore no
  Error: invalid property 'ignore': 'ignore' is ambiguous (ignore-auto-routes x (null)).

After:

  $ nmcli c modify Dukkha ipv4.ignore no
  Error: invalid property 'ignore': 'ignore' is ambiguous (ignore-auto-routes x ignore-auto-dns).
2018-05-24 18:39:11 +02:00
Thomas Haller
2f50c8d915 clients/common: add nmc_objects_sort_by_path() helper 2018-05-14 17:53:03 +02:00
Thomas Haller
684bf31150 all: unify spelling of translators hint in source code
Use the same form everywhere: "TRANSLATORS" instead of "Translators".
The manual also seems to prefer the upper-case form [1].

  $ sed 's/\<Translators\>: /TRANSLATORS: /g' $(git grep -l Translators) -i

[1] https://www.gnu.org/software/gettext/manual/gettext.html
2018-04-13 10:00:09 +02:00
Francesco Giudici
38844e6c5e client: fix nmc_string_is_valid ambiguous detection
when input matched the heading of two allowed values the match was
reported as ambiguous without checking if there was a perfect match
following: fixed.

Example of a failing input:
const char **allowed = [ "ipv4, ipv6, ip" ];
const char *input = "ip";

"ip" was detected as ambiguous.
2018-02-12 10:42:58 +01:00
Beniamino Galvani
aa820e9386 all: add more meaningful error code for unsupported IP method
Add a new device state reason code for unsupported IP method. It is
returned, for example, when users select manual IP configuration for
WWAN connections:

 # nmcli connection mod Gsm ipv4.method manual ipv4.address 1.2.3.4/32
 # nmcli connection up Gsm
 Error: Connection activation failed: The selected IP method is not
 supported

compared to the old:

 Error: Connection activation failed: IP configuration could not be
 reserved (no available address, timeout, etc.)

Note that we could instead fail the connection validation if the
method is not supported by the connection type, but adding such
limitation now could make existing connections invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1459529
2017-12-21 10:02:07 +01:00
Lubomir Rintel
9d95e1f175 clients/cli: use a nicer password prompt
Makes sense in order for the user to know that they're actually typing
the password (edited just to illustrate the point, the actual output was
shamefully messy and perhaps needs fixing too):

  $ nmcli c up Wrathmosphere
  Passwords or encryption keys are required to access the wireless network 'Wrathmosphere'.
  Password (802-1x.password): *********
2017-12-18 14:47:37 +01:00
Lubomir Rintel
9e4de97967 libnm-core: move detection of UTF-8 capable terminals to clients/
Having it in libnm doesn't make any sense and prevents using it for more
internal functionality.

Too bad nm_utils_wifi_strength_bars() is already a public API.
No problem -- replace it with a compatible yet dumber equivalent.
2017-12-18 14:47:37 +01:00
Thomas Haller
5d3736ac65 cli: drop nmc_strsplit_set()
In most cases, it copies the entire strv needlessly.
We can do better.

Also, the max_tokens argument is handled wrongly (albeit
not used anywhere anymore).
2017-12-12 15:19:43 +01:00
Beniamino Galvani
12a49cbdc7 device: add a new state-reason for DAD failures 2017-11-09 22:26:17 +01:00
Lubomir Rintel
d0cb2050f3 all: add OVSDB connection failure device state reason 2017-10-30 17:40:09 +01:00
Lubomir Rintel
4391ba82dd cli/trivial: drop default branch from some cases
This way not handling a known enum value will be caught by a compiler
warning.
2017-10-30 17:38:37 +01:00
Beniamino Galvani
1824cc9e3f clients: move get_effective_activation_state() to nm-clients-utils.c 2017-10-16 17:26:49 +02:00
Beniamino Galvani
aa964ae969 build: move nm-client-utils.c to libnmc-base.a
In a later commit we'll add a new generic client function used by
nmcli and nmtui. nm-client-utils.c seems the right place for it, so
move the file to the base library that is used by both clients.

While at it, also put in that file some functions that will be needed
by nmtui.
2017-10-16 17:25:35 +02:00
Thomas Haller
8c87a4b8a8 clients: replace nmc_string_to_int() by _nm_utils_ascii_str_to_int64() 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
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
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
d1c6d64e6a shared: move _nm_utils_strv_cleanup() to shared utils 2017-04-05 16:53:06 +02:00
Thomas Haller
23298bfc88 cli: move utils function from common.h to nm-meta-setting-desc.c
These functions are only used by nm-meta-setting-desc.c. Make them internal.
Unfortunately, they are part of "common.h" which cannot be used without
the rest of nmcli. Still todo.
2017-03-30 13:09:58 +02:00