Commit Graph

370 Commits

Author SHA1 Message Date
Jiří Klimeš
3cf1131e89 cli: fix 'nmcli connection' so that it returns correct exit code
It was broken by commit 57e802f3aa, which made
nmcli always return success.

For example:
$ nmcli con add type blabla
2014-08-22 23:33:04 +02:00
Thomas Haller
00af27f0ba cli: succeed in master bring-up when device state reaches IP_CONFIG (bgo #733641)
When connecting a master connection, no slave devices will be activated
automatically. The user is supposed to activate them individually.

Hence nmcli should not wait for the connection to be fully activated
because that is not going to happen (unless the user connects a slave
connection from another terminal).

Instead, for master connections behave differently and signal success
once the master device reaches IP_CONFIG state.

This revises behavior introduced by commit
47710f8211.

https://bugzilla.gnome.org/show_bug.cgi?id=733641

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2014-08-19 13:42:31 +02:00
Jiří Klimeš
26eafd3420 trivial: fix a typo in show_access_point_info() function name 2014-08-18 13:58:43 +02:00
Jiří Klimeš
45358f51fc cli: fix crash in nmcli device wifi with multiple wifi devices (bgo #734466)
And separate details for particular devices with an empty line.

https://bugzilla.gnome.org/show_bug.cgi?id=734466

Reported-by: Martin Pitt <martinpitt@gnome.org>
2014-08-18 13:58:43 +02:00
Dan Winship
e1ba13a426 libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.

Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)

Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
2014-08-16 10:17:53 -04:00
Dan Winship
32c26a859b libnm-core: move some fake NMConnection methods over to NMSetting
nm_connection_lookup_setting_type() and
nm_connection_lookup_setting_type_by_quark() have nothing to do with
NMConnection. So move them to NMSetting (and rename them to
nm_setting_lookup_type() and nm_setting_lookup_type_by_quark()).
2014-08-16 10:17:53 -04:00
Dan Winship
57e802f3aa libnm: port NMRemoteSettings to NMObject
NMRemoteSettings duplicates a bunch of NMObject's functionality that
it doesn't need to. In libnm-glib, it wouldn't have been possible to
port NMRemoteSettings to NMObject without breaking ABI, but now in
libnm we can do that.

As a side effect of this, NMRemoteSettings gains a "connections"
property, and "connection-added" and "connection-removed" signals
(with the former replacing the old "new-connection" signal). This also
removes the "connections-loaded" signal, since the connections will
now always be loaded (via the initialization of the "connections"
property) during init()/init_async().

Also, this removes NMRemoteConnection's "removed" signal, since it's
redundant with the new NMRemoteSettings::connection-removed (and
having the signal on NMRemoteSettings instead is more consistent with
other objects).
2014-08-07 15:43:43 -04:00
Dan Winship
8ce06b814c libnm: synchronize NMClient and NMRemoteSettings "is NM running" properties
Rename NMClient:manager-running and NMRemoteSettings:service-running
to both be :nm-running.
2014-08-07 15:43:43 -04:00
Dan Winship
357efd26e4 libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h
Include <linux/if_ether.h> and <linux/if_infiniband.h> from
nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
various headers that had been included to get the ARPHRD_* constants)
from other files where they're not needed now.
2014-08-07 14:04:14 -04:00
Dan Winship
35f36ba4c3 libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones
Drop the arptype-based nm_utils_hwaddr funcs, and rename the
length-based ones to no longer have _len in their names. This also
switches nm_utils_hwaddr_atoba() to using a length rather than an
arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
in some places, where we were only using aton() to do validity
checking).
2014-08-07 12:08:16 -04:00
Dan Winship
d0b05b34d5 libnm: add NetworkManager.h, disallow including individual headers
Add NetworkManager.h, which includes all of the other NM header, and
require all external users of libnm to use that rather than the
individual headers.

(An exception is made for nm-dbus-interface.h,
nm-vpn-dbus-interface.h, and nm-version.h, which can be included
separately.)
2014-08-01 14:34:40 -04:00
Dan Winship
258e74eb0c libnm: make the the use of GInitable mandatory
Remove _nm_object_ensure_inited(), etc; objects that implement
GInitable are now mandatory-to-init().

Remove constructor() implementations that sometimes return NULL; do
all the relevant checking in init() instead.

Make nm_client_new() and nm_remote_settings_new() take a GCancellable
and a GError**.
2014-08-01 14:34:40 -04:00
Dan Winship
3ac0f52878 libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").

NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-08-01 14:34:06 -04:00
Dan Winship
054c12ea30 libnm: remove all deprecated functions and types
Remove deprecated functions and enum types.

For now, deprecated properties are still around, because removing them
would cause warnings when talking to older implementations.
2014-08-01 14:34:05 -04:00
Dan Winship
a7c4d53d03 all: port everything to libnm
Since the API has not changed at this point, this is mostly just a
matter of updating Makefiles, and changing references to the library
name in comments.

NetworkManager cannot link to libnm due to the duplicated type/symbol
names. So it links to libnm-core.la directly, which means that
NetworkManager gets a separate copy of that code from libnm.so.
Everything else links to libnm.
2014-08-01 14:34:05 -04:00
Thomas Haller
ef24273104 cli: fix warning in parse_output_fields() about strict-overflow
gcc warns:

    make[4]: Entering directory `./NetworkManager/cli/src'
      CC       utils.o
    utils.c: In function ‘parse_output_fields’:
    utils.c:707:7: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
        if (found) {
           ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00
Thomas Haller
f0d40201ae cli: fix warning about uninitialized value
gcc warns:

    make[4]: Entering directory `./NetworkManager/cli/src'
      CC       connections.o
    connections.c: In function ‘complete_connection_by_type’:
    connections.c:4235:18: error: ‘mtu_int’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu_int, NULL);
                      ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00
Thomas Haller
996b31ec20 cli: remove unused static struct nmc_mobile_settings
clang warns:

    make[4]: Entering directory `./NetworkManager/cli/src'
      CC       connections.o
    connections.c:2206:23: error: unused variable 'nmc_mobile_settings' [-Werror,-Wunused-const-variable]
    static const NameItem nmc_mobile_settings [] = {
                          ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:00 +02:00
Thomas Haller
b461bf54f2 all: add compatibility macros to ignore deprecation warnings for clang
For clang, the defines G_GNUC_BEGIN_IGNORE_DEPRECATIONS and
G_GNUC_END_IGNORE_DEPRECATIONS are not working. Redefine them
for clang in our glib compatibility wrapper.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:16:59 +02:00
Dan Winship
3d25d70461 clients: reorganize source tree, put all the installed clients together
Create a new clients/ subdirectory at the top level, and move cli/ and
tui/ into it, as well as nm-online.c (which was previously in test/,
which made no sense).

cli/ was split into two subdirectories, src/ and completion/. While
this does simplify things (given that the completion file and the
binary both need to be named "nmcli"), it bloats the source tree, and
we can work around it by just renaming the completion file at install
time. Then we can combine the two directories into one and just have
it all under clients/cli/.
2014-07-30 15:56:19 -04:00