Commit graph

697 commits

Author SHA1 Message Date
Thomas Haller 86ffea8004 libnm: ensure auto-registration only when not yet registered
Calling nm_secret_agent_register() on an already registered
instance leads to a warning. Ensure to call register during
auto-registration only when needed.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-27 08:52:25 +02:00
Dan Winship 645ab39bb6 libnm, libnm-glib: fix cut-and-paste-os
Several nm-device-*.c files apparently originally used
nm-device-ethernet.c as a template, but missed a reference to "eth" in
class_init.
2014-08-18 11:10:42 -04:00
Dan Winship 7e791ce3fe libnm, libnm-glib: belatedly replace _nm_client_is_object_path()
_nm_client_is_object_path() had been copied from
g_variant_is_object_path() with a note that it should be replaced when
we depended on GLib > 2.24, but it got missed when we actually updated
the dependency. Fix it now. (Also fix a nearby typo.)
2014-08-07 15:43:42 -04:00
Dan Winship 48ad586209 libnm-glib: add tests of NMClient:manager-running and NMRemoteSettings:service-running
Test that the code to track whether NetworkManager is running works
correctly.
2014-08-01 12:12:42 -04:00
Dan Winship fe264a2d01 libnm-glib: fix a crash when using multiple NMClients
NMObjectCache was assuming there would never be more than one object
with the same path, but since NMClient is an NMObject, it was getting
cached too, so if you created two clients and then unreffed one of
them, it's possible the wrong one could get left in the cache, causing
a crash the next time the other one called nm_object_cache_clear().

Fix this by only adding NMObjects to the cache in the codepaths where
we also check to see if the object was already in the cache.

(This also means we can remove the "except" argument to
nm_object_cache_clear(), since the NMClient won't be cached any more.)
2014-08-01 12:12:42 -04:00
Dan Winship 08b91199fb libnm-glib: make test-networkmanager-service.py automatically exit with its parent
test-nm-client.c and test-remote-settings-client.c were using their
own assertion macros so they could kill the test service on assertion
failure. Except that some new code didn't get the memo and used the
g_assert* macros. Not to mention that sometimes the tests would crash
outside of an assertion macro.

We can make test-networkmanager-service.py notice that its parent has
crashed by opening a pipe between them and taking advantage of the
fact that the pipe will be automatically closed if the parent crashes.
So then test-networkmanager-service.py just has to watch for that, and
exit if the pipe closes.

Then that lets us drop the test_assert* macros and just use g_assert*
instead.
2014-08-01 12:12:42 -04:00
Dan Winship bd8a7f74b1 libnm-glib: split out test service launching code from tests 2014-08-01 12:12:42 -04:00
Dan Winship ade4f2e84e libnm-glib: use automake test infrastructure for test programs
Use "TESTS = tests-nm-client test-remote-settings-client" rather than
overriding "check-local".

Add a script "libnm-test-launch.sh" that will handle redirecting the
test via dbus-launch if needed.
2014-08-01 11:55:49 -04:00
Dan Winship 4f7e9bd336 libnm-glib: compile test-networkmanager-service.py path into test binaries
Rather than passing the path to the test service on the command line,
compile it into the test programs.

(Among other things, this makes it easier to run the test directly
from the command line.)
2014-08-01 11:55:49 -04:00
Thomas Haller 0238f8f8e2 libnm-glib: fix warning about redefining typedef RemoteCall
clang warns:

    make[4]: Entering directory `./NetworkManager/libnm-glib'
      CC       libnm_glib_la-nm-remote-connection.lo
    nm-remote-connection.c:77:3: error: redefinition of typedef 'RemoteCall' is a C11 feature [-Werror,-Wtypedef-redefinition]
    } RemoteCall;
      ^
    nm-remote-connection.c:67:27: note: previous definition is here
    typedef struct RemoteCall RemoteCall;
                              ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:16:59 +02:00
Thomas Haller 1de6d83e29 libnm-glib/test: add asserts to test-remote-settings-client
- register a weak references and ensure that the connection
  is removed when expected.

- disconnect the vis_new_connection_cb() handler

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:07:38 +02:00
Thomas Haller d6b3ef0819 libnm-glib/test: fix crash in test-remote-settings-client
test_make_invisible() forgot to disconnect handler invis_removed_cb().
Later, during test_remove_connection(), the connection will be eventually
removed and the callback will corrupt the stack by writing to the '&done'
user data.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:07:38 +02:00
Giovanni Campagna 07046462f7 libnm-glib: disconnect the connectivity check cancellable signal after the call has ended (bgo #733915)
We cannot rely on connectivity data freeing to disconnect the signal,
because the simple async result might be kept alive by external
code (for example the language runtime for JS), but we must not
call dbus_g_proxy_cancel_call() if that cancellable is cancelled or
reused afterwards.

https://bugzilla.gnome.org/show_bug.cgi?id=733915
2014-07-31 20:51:44 -05:00
Dan Winship 5432ef5e52 tools: move libnm-glib's fake NM service implementations here
Move libnm-glib's test-fake-nm.py and test-remote-settings-service.py
to tools/, merge them together into a single program, and fix a few
bugs (notably some missing signal emissions in the Settings service).

Although they are currently only used by libnm-glib's tests, they are
generic enough that they could be used by other code in the future
(and in particular, they will be used by libnm's tests as well).
2014-07-30 15:56:29 -04:00
Thomas Haller 7f35d808f5 libnm-glib: fix gtk-doc for NMClient:active-connections
Since previous commit dafe51e881,
the gtk-doc is no longer ignored. However, the angle brackets
add invalid XML characters to ./docs/libnm-glib/xml/nm-client.xml
This breaks the build.

    make[3]: Entering directory `./NetworkManager/docs/libnm-glib'
      DOC   Scanning header files
      DOC   Introspecting gobjects
      DOC   Building HTML
    ../xml/nm-client.xml:1110: parser error : Opening and ending tag mismatch: NMActiveConnection line 1109 and para
    </para></refsect2>
           ^
    ../xml/nm-client.xml:1110: parser error : Opening and ending tag mismatch: para line 1107 and refsect2
    </para></refsect2>
                      ^
    ../xml/nm-client.xml:1211: parser error : Opening and ending tag mismatch: refsect2 line 1104 and refsect1
    </refsect1>
               ^
    ../xml/nm-client.xml:1262: parser error : Opening and ending tag mismatch: refsect1 line 1095 and refentry
    </refentry>
               ^
    ../xml/nm-client.xml:1263: parser error : Premature end of data in tag refentry line 7

    ^
    ../libnm-glib-docs.xml:67: element include: XInclude error : could not load ../xml/nm-client.xml, and no fallback was found
    make[3]: *** [html-build.stamp] Error 6

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-27 04:31:03 +02:00
Dan Winship dafe51e881 libnm-glib: document some properties
Some libnm-glib object properties were only documented in the
GParamSpec strings, not via gtk-doc comments, so they became
undocumented when the paramspec strings went away. Fix that.

(Also fix incorrect gtk-doc syntax with several NMClient properties.)
2014-07-25 09:49:58 -04:00
Jiří Klimeš 576c82049b libnm-glib: implement nm_device_delete() for D-Bus device' Delete() method 2014-07-22 14:24:42 +02:00
Jiří Klimeš 3dbe8041a7 libnm-glib: add nm_device_is_software() function to NMDevice
It says whether the device is a software one, according to device capabilities.
2014-07-22 14:24:42 +02:00
Thomas Haller faa6c34db1 libnm-glib: evaluate assert check only once in test-remote-settings-client
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-21 12:20:56 +02:00
Dan Winship 396610d14a libnm-glib: fix assertion-failure messages in test-remote-settings-client
test-remote-setting-client uses a macro:

    #define test_assert(condition) \
    do { \
        if (!G_LIKELY (condition)) \
            cleanup (); \
        g_assert (condition); \
    } while (0)

where cleanup() kills the fake remote-settings service and unrefs
settings. However, in many cases, "condition" would involve a test
against a connection that was owned by settings, so if the check
failed, the connection would end up getting freed by cleanup(), and so
then the second invocation of condition would result in the program
aborting on a failed check somewhere else (eg, "invalid unclassed
pointer in cast to 'NMConnection'") rather than displaying the failed
assertion that had gotten us to that point.

Fix this by not unreffing settings from cleanup(); in the normal exit
case we can just have main() unref it, and in the assertion-failed
case, we don't need to free things anyway.
2014-07-20 08:58:56 -04:00
Dan Winship 30c74c6007 build: more srcdir!=builddir fixes
nm-version.h was getting disted, making srcdir!=builddir work for
tarball builds, but not for git builds.

Also, remove "-I${top_builddir}/include" from all Makefile.ams, since
there's nothing generated in include/ any more.
2014-07-15 11:37:19 -04:00
Dan Winship 3aad3124f1 libnm-glib: drop separate test library
Previously, we built a second copy of libnm-glib that was hacked to
use the session bus rather than the system bus, for use by the test
programs. Rather than doing that, just have test-nm-client explicitly
override the choice of bus. (test-remote-settings-client was actually
already doing this, although it leaked the bus after.)
2014-07-15 09:44:55 -04:00
Dan Winship 2570c5a17c libnm-util, libnm-glib: whitespace fixes
Fix indentation, kill trailing whitespace, split some long lines.
2014-07-15 09:44:55 -04:00
Dan Winship cb7e1893e7 libnm-util, libnm-glib: standardize copyright/license headers
- Remove list of authors from files that had them; these serve no
  purpose except to quickly get out of date (and were only used in
  libnm-util and not libnm-glib anyway).

- Just say "Copyright", not "(C) Copyright" or "Copyright (C)"

- Put copyright statement after the license, not before

- Remove "NetworkManager - Network link manager" from the few files
  that contained it, and "libnm_glib -- Access network status &
  information from glib applications" from the many files that
  contained it.

- Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
  to files that were missing it.
2014-07-15 09:44:54 -04:00
Dan Winship 4223fa47e4 libnm-util, libnm-glib: tweak (element-type) annotations in docs
g-i allows you to specify types in annotations using either their
fully-qualified introspected names (eg, "NMClient.Device") or their
plain C names ("NMDevice"). Switch from the former to the latter (so
that they'll still be correct when migrated to libnm later).
2014-07-15 09:44:54 -04:00
Thomas Haller f352bfd2af trivial/libnm-glib: rename internal PROP_* enum values
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-14 19:31:34 +02:00
Thomas Haller 568742ed41 libnm-glib: fix initialization of NMObject type
Ensure that the @type_funcs and @type_async_funcs
hashes are initialized before running the class
init function.

libnm-glib-scan hits the following assertion:
  GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
  #0  0x0000003370c504e9 in g_logv (log_domain=0x3370cb2f4e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffd1578f70) at gmessages.c:989
  #1  0x0000003370c5063f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1025
  #2  0x00007f2169f42545 in _nm_object_register_type_func (base_type=base_type@entry=13597296, type_func=type_func@entry=0x7f2169f47ae9 <_nm_device_type_for_path>, type_async_func=type_async_func@entry=
      0x7f2169f47880 <_nm_device_type_for_path_async>) at nm-object.c:551
  #3  0x00007f2169f48664 in nm_device_get_type () at nm-device.c:62
  #4  0x0000000000402577 in get_object_types () at libnm-glib-scan.c:46
  #5  0x0000000000404b0b in main (argc=<optimized out>, argv=<optimized out>) at libnm-glib-scan.c:135

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-14 16:14:03 +02:00
Thomas Haller 734203e12e libnm-glib/tests: remove waiting time for initializing NMClient
This waiting time significantly increases the runtime of the tests.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-08 19:01:01 +02:00
Dan Winship aa1dce6da2 all: remove remaining GParamSpec name/blurb strings
Remove all remaining GParamSpec name and blurb strings (and fix
indentation while we're there), and add G_PARAM_STATIC_STRINGS to all
paramspecs that were lacking it.
2014-06-19 17:45:03 -04:00
Dan Winship 8487a4490c libnm-util, libnm-glib: be consistent about "Wi-Fi", "Ethernet", "InfiniBand" in docs
We made the UIs consistent last year, but missed the documentation.
Fix the docs to also consistently use "Wi-Fi" rather than "WiFi",
"Wifi", "wifi", or "WiFI"; "Ethernet" rather than "ethernet"; and
"InfiniBand" rather than "Infiniband".
2014-06-19 17:45:01 -04:00
Thomas Haller b633711572 libnm-glib: don't use deprecated nm_access_point_get_hw_address()
nm_access_point_get_hw_address() is already deprecated since
pre-0.9.0-beta3 (f30e15a04d). However,
it also is defined as NM_DEPRECATED_IN_0_9_10, because there
are no deprecated macros for previous version.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 11:19:02 +02:00
Dan Williams 351ab1d76f libnm-glib-vpn: bump soname (1.1.0 -> 1.2.0) for API additions 2014-06-06 18:28:20 -05:00
Dan Williams 08faaf1170 libnm-glib: bump soname (4.7.0 -> 4.8.0) for API additions 2014-06-06 18:28:20 -05:00
Jiří Klimeš 8b41e6e2ea libnm-glib: fix double unref() when object creation fails 2014-06-05 18:11:29 +02:00
Thomas Haller 41ced630fb libnm-glib: fix resetting IP config during additional SetConfig() calls
When receiving updated VPN IP configuration from the helper after the
initial connect event, the library overwrites the already initialized
GValue fields by calling g_value_init() again. This is an error and causes
the following warning:

   (nm-openvpn-service:27645): GLib-GObject-WARNING **: gvalue.c:183: cannot initialize GValue with type gchararray, the value has already been initialized as gchararray

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 20:17:22 +02:00
Jiří Klimeš 98ae6e06d2 all: g_type_init() has been deprecated in GLib 2.35.0
g_type_init() deprecation:
https://bugzilla.gnome.org/show_bug.cgi?id=686161
2014-05-27 16:58:21 +02:00
Dan Williams 2af30e813a docs: clarify some uses of nm_active_connection_get_connection() 2014-05-22 09:07:57 -05:00
Dan Winship bea82ca98b all: set G_LOG_DOMAIN appropriately, for better g_log() messages 2014-04-23 10:19:17 -04:00
Dan Williams 2200687b0f libnm-glib: add documentation for NMRemoteSettings and connection addition 2014-04-10 10:51:29 -05:00
Dan Winship 1d0b50c2c4 build: add some missing -DNM_VERSION_MAX_ALLOWED
Add -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE to a bunch of
Makefile.ams that were missing it and might eventually need it.
2014-04-07 11:30:18 -04:00
Jiří Klimeš 759236681c trivial: make clear the maximum bitrate is in kbit/s 2014-04-01 15:15:09 +02:00
Dan Winship 5cd37d250a libnm-glib: add nm_device_get_setting_type()
Add a function mapping NMDevices to their corresponding base NMSetting
types.
2014-03-06 09:38:36 -05:00
Dan Winship 6300ea57ab libnm-glib: fix a double free in NMDeviceVlan 2014-03-05 11:20:54 -05:00
Jiří Klimeš ee6f684f0a libnm-glib: support 'type', 'id' properties in NMActiveConnection (rh #1061822)
https://bugzilla.redhat.com/show_bug.cgi?id=1061822
2014-03-05 16:17:13 +01:00
Dan Winship 74809e64cc libnm-glib: fix glib-mkenums warnings
glib-mkenums doesn't parse /*< public >*/ and /*< private >*/, and in
fact, it warns about them, so don't write it that way.
2014-02-28 16:13:22 -05:00
Thomas Haller d3a2219cee replace snprintf by g_snprintf
Use the glib wrapper for snprintf.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:35:33 +01:00
Jiří Klimeš c2a1cb1a44 docs: use %TRUE, %FALSE macros instead of plain TRUE, FALSE values for gtkdoc 2014-02-24 17:00:39 +01:00
Thomas Haller f8dcab53d9 libnm-glib: take reference in NMRemoteConnection before calling DBUS
We always have to take a reference to the NMRemoteConnection
before calling to DBUS, because the connection might be deleted
in the meantime.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-21 16:20:29 +01:00
Thomas Haller 9968895e19 libnm-glib: accept omitting callback in nm_remote_connection_*
The functions nm_remote_connection_save(), nm_remote_connection_commit_changes(),
and nm_remote_connection_commit_changes_unsaved() indicate in the documentation,
that they allow omitting the callback argument. Remove invalid checks
for callback.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-21 16:20:29 +01:00
Dan Winship 9c4d86ee80 libnm-util, libnm-glib: add versioned deprecation/availability macros
Add versioned NM_DEPRECATED_IN_* and NM_AVAILABLE_IN_* macros, and tag
new/deprecated functions accordingly. (All currently-deprecated
functions are assumed to have been deprecated in 0.9.10.)

Add NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED macros which
can be set to determine which versions will cause warnings.

With the current settings, external consumers of the
libnm-util/libnm-glib APIs will have MIN_REQUIRED and MAX_ALLOWED both
set to NM_VERSION_0_9_8 by default, meaning they will get warnings
about functions added in 0.9.10. NM internally sets
NM_VERSION_MAX_ALLOWED to NM_VERSION_NEXT_STABLE to ensure that it is
always allowed to use all APIs.
2014-02-13 11:24:37 -05:00