Commit Graph

119 Commits

Author SHA1 Message Date
Thomas Haller
84aa6bad89 cli: add property-info for NMSettingWired 2017-03-30 13:09:57 +02:00
Thomas Haller
486dc1e596 cli: add property-info for NMSettingWimax 2017-03-30 13:09:57 +02:00
Thomas Haller
9c6f70f9e0 cli: add property-info for NMSettingAdsl 2017-03-30 13:09:56 +02:00
Thomas Haller
f34ef5d1fe cli: add property-info for NMSettingPpp 2017-03-30 13:09:56 +02:00
Thomas Haller
6bf1d6fc16 cli: add property-info for NMSetting8021x 2017-03-30 13:09:56 +02:00
Thomas Haller
d530bffb6c cli: add property-info for NMSettingWirelessSecurity 2017-03-30 13:09:56 +02:00
Thomas Haller
09d127b473 cli: add property-info for NMSettingPppoe 2017-03-30 13:09:56 +02:00
Thomas Haller
a89e9a0a6f cli: add property-info for NMSettingDcb 2017-03-30 13:09:56 +02:00
Thomas Haller
89b5685695 cli: add property-info for NMSettingProxy 2017-03-30 13:09:56 +02:00
Thomas Haller
40f47dbb06 cli: add property-info for NMSettingIP4Config and NMSettingIP6Config 2017-03-30 13:09:56 +02:00
Thomas Haller
4e91492b76 cli: rework property handling via NmcPropertyInfo for NMSettingConnection
Add an improved way of tracking meta data about settings.

E.g. it is wrong to generate for each property a nmc_property_*_get_*()
function. Instead, there should be a meta data about the property
itself, and a mechanism to retrieve the property.

For now, only do this for NMSettingConnection and keep all the existing
infrastructure in place. Later on all settings shall be moved.

Especially to accomodate NmcOutputField mangles the concept of
setting-meta data, formatting options, and collecting output results.
It's a total hack, that will be need fixing later.
2017-03-30 13:09:55 +02:00
Francesco Giudici
ef0d0d08eb nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...

Fixes: 16902a2be6
2017-03-29 13:02:39 +02:00
Lubomir Rintel
f909ef421b cli: check for global options before each agument
Turn --ask and --show-secrets into global options. This is for user
comfort, see: rh #1351263.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
5a71bc8022 cli: add NmCli argument to next_arg()
Will be useful in next commit.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
16902a2be6 cli: use next_arg() on argument boundary
Shift argc and argc manually between argument ant its value and use
next_arg() between arguments everywhere. Whill be useful to parse global
arguments.
2017-03-28 15:32:05 +02:00
Thomas Haller
618dd28950 cli: fix completion of setting names for --fields (2) 2017-03-28 13:42:40 +02:00
Francesco Giudici
f4d0417c8d nmcli: add -g[et-values] option as a '-m tab -t -f <arg>' shortcut
Quick and easy way to get clean and parsable field values.
2017-03-28 10:55:00 +02:00
Thomas Haller
6e1616ba69 cli: fix completion of setting names for --fields 2017-03-26 19:48:29 +02:00
Lubomir Rintel
84c484ed5b cli: make match() return boolean
Coccinelle semantic patch:

  @@
  @@
  -int
  +gboolean
          matches (...);

  @@
  expression pattern, cmd, len;
  @@
  -int
  +gboolean
          matches (...)
          {
                  ...
  -               return memcmp (pattern, cmd, len);
  +               return memcmp (pattern, cmd, len) == 0;
          }

  @@
  expression prefix, str;
  @@
  (
  -matches (prefix, str) != 0
  +!matches (prefix, str)
  |
  -matches (prefix, str) == 0
  +matches (prefix, str)
  )

  @@
  expression prefix, str;
  @@
  -(matches (prefix, str))
  +matches (prefix, str)

  @@
  expression prefix, str;
  @@
  -(!matches (prefix, str))
  +!matches (prefix, str)

spatch --smpl-spacing --sp-file match.cocci --dir clients/cli/ \
  --include-headers --macro-file shared/nm-utils/gsystem-local-alloc.h
2017-02-15 13:04:07 +01:00
Thomas Haller
dc40288849 all: use NM_CACHED_QUARK_FCN() to define cached quarks 2017-02-10 14:33:52 +01:00
Beniamino Galvani
a3b61303f8 cli: implement 'networking' subcommand using nmc_do_cmd()
It simplifies the code and doesn't require that NM is running to
display the help.
2016-12-09 17:57:49 +01:00
Beniamino Galvani
593cfc73c1 cli: the 'networking' command needs a client and NM running
Fixes: 01a20015e0
2016-12-05 10:52:59 +01:00
Lubomir Rintel
01a20015e0 cli: use nmc_do_cmd to get the client and check if the daemon is running
The makes use of asynchronous client initialization, making things a bit
faster and reduces code duplication too.
2016-11-11 16:18:03 +01:00
Lubomir Rintel
3ee03afecc cli: make it possible to call sub-commands with client obtained asynchronously 2016-11-11 16:18:03 +01:00
Lubomir Rintel
6499bb893f cli: get rid of client-global connections list
Caching it in the NmCli object is unnecessary, ugly and would be cumbersome in
future when we'll be creating the client object only when needed.
2016-11-11 16:18:03 +01:00
Lubomir Rintel
0cde514252 cli/trivial: fix some whitespace errors 2016-11-11 16:18:03 +01:00
Lubomir Rintel
7279ea1317 client: don't do g_criticals
Also, be a bit more careful about the layers of errors. Just don't do this:

   (process:236): nmcli-CRITICAL **: Error: Could not create NMClient object:
     Permissions request failed: Authorization check failed:
     The name org.freedesktop.PolicyKit1 was not provided by any .service files.
2016-11-09 15:06:20 +01:00
Beniamino Galvani
995229181c cli: remove editor thread
Currently the editor runs in a dedicated thread so that the blocking
call to readline() doesn't stop the processing of D-Bus events in the
main loop. The editor thread can access objects concurrently with the
main thread and this can cause races and crashes.

Remove the editor thread and use the non-blocking readline API.

https://bugzilla.gnome.org/show_bug.cgi?id=732097
https://bugzilla.redhat.com/show_bug.cgi?id=1368353
2016-09-23 09:46:28 +02:00
Thomas Haller
0bdcab100c all: cleanup includes in header files
- don't include "nm-default.h" in header files. Every source file must
  include as first header "nm-default.h", thus our headers get the
  default include already implicitly.

- we don't support compiling NetworkManager itself with a C++ compiler. Remove
  G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support
  users of libnm to use C++, thus they stay in public headers.

(cherry picked from commit f19aff8909)
2016-08-17 19:51:17 +02:00
Lubomir Rintel
8cc6ce7e44 cli: add -f argument completion 2016-08-01 15:51:29 +02:00
Lubomir Rintel
2e5f8d7de6 cli: complete global flags 2016-08-01 15:51:29 +02:00
Lubomir Rintel
e996dfbb26 cli: make global flags parsing saner
Keep argv pointed at the current argument not the previous one.
2016-08-01 15:51:29 +02:00
Lubomir Rintel
d73c0e57d5 cli: add ability to indicate command completion expects a file name 2016-08-01 13:52:36 +02:00
Lubomir Rintel
9827725210 cli: get rid of the global command completion whitelist
We're going to implement most of the missing pieces; the rest is going
to handle inability to complete itself.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
60f992c5d3 cli: handle global usage with nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
f14845cc20 cli: output a short summary of devices when called without arguments
This aims to be somewhat similar to what "ifconfig" does.

https://bugzilla.gnome.org/show_bug.cgi?id=766426
2016-07-19 14:29:05 +02:00
Lubomir Rintel
c054b871f7 cli/device: add device name completion
Useful with connect, disconnect, delete, monitor, show and reapply.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
1a88eac02a cli: split out do_cmd() 2016-06-29 20:28:42 +02:00
Lubomir Rintel
ef8d696252 cli: move the final completion check after the main loop exit
For "nmcli d modify" we'll need to do the completion from async
handlers. This seems to be the most reasonable place to ignore the
errors.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
3aff650e22 nmcli: improve connection autocompletion (2/2)
Complete the property as we parse the list of properties. This makes it
possible to actually complete an unfinished property.  E.g:

  $ nmcli --complete c modify enp0s25 +ipv6.addr
  +ipv6.addresses +ipv6.addr-gen-mode
2016-06-21 16:28:48 +02:00
Francesco Giudici
cd4395a261 nmcli: enable connection autocompletion for 802.1x properties
nmcli bash autocompletion leveraged on "nmcli connection edit", "print"
to retrieve the specific properties of a connection. Anyway, the
interactive editor is smart and just prints the used components, so in a
connection where 802.1x is not enabled we had no autocompletion.
Solved adding an "hidden" command "nmcli --complete connection modify"
as suggested in bgo #724860 in order to retrieve ALL the available
properties for use in autocompletion.
Here patch from L.Rintel has been merged to make che --complete option
global to nmcli (first version was local to "connection modify").

https://bugzilla.gnome.org/show_bug.cgi?id=724860
https://bugzilla.redhat.com/show_bug.cgi?id=1301226
2016-06-21 16:28:48 +02:00
Francesco Giudici
3c67a1ec5e cli: remove version check against NM
When performing NM package upgrade the new version of nmcli will be immediately
available while NM daemon will not, as it would not restart in order to avoid
to disrupt connectivity. This could create issues with tools leveraging
on nmcli output (till reboot). As apart from this case it is very unlikely
that a user can have this nmcli / NM daemon version mismatch situation,
the check could cause more harm than benefit in real user case
scenarios.

https://bugzilla.redhat.com/show_bug.cgi?id=1291785
2016-04-28 09:35:20 +02:00
Thomas Haller
8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Jiří Klimeš
1351b852f5 cli: fix nmcli help for 'monitor' command 2016-02-03 10:04:47 +01:00
Jiří Klimeš
629de4e689 cli: add global --show-secrets option
- it controls echoing passwords input on terminal
- it replaces --show-secrets in 'nmcli connection show', which is deprecated now
- it replaces --show-password in 'nmcli device wifi hotspot', which is deprecated now
2015-12-07 14:14:58 +01:00
Lubomir Rintel
d03f347b9d cli: add nmcli monitor
https://bugzilla.redhat.com/show_bug.cgi?id=1034158
2015-12-05 12:16:23 +01:00
Lubomir Rintel
88ae8d2b13 cli: turn should_wait into a semaphore
Count the exit blockers. We'll want to terminate the device monitor in case all
monitored devices vanish.
2015-12-05 12:05:17 +01:00
Dan Winship
22e1a97e12 all: drop includes to <glib/gi18n.h> for "nm-default.h"
The localization headers are now included via "nm-default.h".

Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.
2015-08-05 15:35:51 +02:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00