Unfortunately, there is a bug in lgi library causing the incorrect values
being returned and the example crashes. I am going to send a patch to lgi
to fix the issues.
If a connection has an associated "rule-NAME" or "rule6-NAME" file,
don't try to read in the routes, since NetworkManager won't be able to
parse them correctly. Instead, log a warning that they will need to be
applied via a dispatcher script, and provide a script that would do
that in examples/dispatcher/.
Update the raw D-Bus python examples to use newer APIs where
appropriate (and split the add-connection example into 1.0-only and
0.9-compatible versions). Update the gi-based python examples for the
various API changes since they were last updated.
Also add a comment to the ruby add-connection example pointing out
that it's still using the old settings APIs.
config.h should be included from every .c file, and it should be
included before any other include. Fix that.
(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.
Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
libnm mostly used GPtrArrays in its APIs, except that arrays of
connections were usually GSLists. Fix this and make them GPtrArrays
too (and rename nm_client_list_connections() to
nm_client_get_connections() to match everything else).
Make synchronous APIs take GCancellables, and make asynchronous APIs
use GAsyncReadyCallbacks and have names ending in "_async", with
"_finish" functions to retrieve the results.
Also, make nm_client_activate_connection_finish(),
nm_client_add_and_activate_finish(), and
nm_remote_settings_add_connection_finish() be (transfer full) rather
than (transfer none), because the refcounting semantics become
slightly confusing in some edge cases otherwise.
Merge nm_remote_settings_add_connection() and
nm_remote_settings_add_connection_unsaved(), and likewise
nm_remote_connection_commit_changes() and
nm_remote_connection_commit_changes_unsaved(), by adding a boolean
flag to each saying whether to save to disk.
Port libnm-core/libnm to GDBus.
The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
Port the dbus-glib-based examples to GDBus.
Also, don't use libnm in them at all; there's not much point in
examples that use the D-Bus API directly if they're just going to fall
back to libnm for the hard stuff... (And also, this avoids the problem
that GDBus uses GVariant, while the libnm-core APIs currently still
use GHashTables.)
Also fix up some comment grammar and copyright style, and add emacs
modelines where missing.
Also rename the existing GDBus-based examples to have names ending in
"-gdbus", not "-GDBus", since there's no reason to gratuitously
capitalize here.
libnm functions that return GPtrArrays of objects had a rule that if
the array was empty, they would return NULL rather than a 0-length
array. As it turns out, this is just a nuisance to clients, since in
most places the code for the non-empty case would end up doing the
right thing for the empty case as well (and where it doesn't, we can
check "array->len == 0" just as easily as "array == NULL"). So just
return the 0-length array instead.
APIs that take arbitrary data should take it in the form of a pointer
and length, not a GByteArray, so that you can use them regardless of
what format you have the data in (GByteArray, GBytes, plain array,
etc).
Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
addition to clarifying that this is specifically the D-Bus
serialization format, these names will also work better in the
GDBus-based future where the serialization format is GVariant, not
GHashTable.
Also, move NMSettingHashFlags to nm-connection.h, and rename it
NMConnectionSerializationFlags.
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().
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).
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.)
"NetworkManager.h"'s name (and non-standard capitalization) suggest
that it's some sort of high-level super-important header, but it's
really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h"
and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
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**.
Most D-Bus interface name macros used "INTERFACE" in their name (eg,
NM_DBUS_INTERFACE), but a few used "IFACE" instead (eg,
NM_DBUS_IFACE_SETTINGS). Make them consistent.
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.
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.
NetworkManager.h, NetworkManagerVPN.h, and nm-version.h are part of
the libnm-util API, so move them to libnm-util.
include/ still contains headers that are strictly NM-internal (eg,
nm-glib-compat.h).
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>
Tighten up with suggestions from Johannes Buchner and mention
his contribution.
Also fixes operation with current nmcli since it changed from
"802-3-ethernet" -> "ethernet" and thus the script was broken.
https://bugzilla.gnome.org/show_bug.cgi?id=513488
The function toStdString() is only available when QT was
compiled with STL support. The configure script does
not check STL support and might build the QT examples
even if toStdString() is not available.
Fix this, by not using the function.
This fixes the previous commit f73e3669b3
that I pushed accidentally.
https://bugzilla.gnome.org/show_bug.cgi?id=727608
Signed-off-by: Thomas Haller <thaller@redhat.com>
The function toStdString() is only available when QT was
compiled with STL support. The configure script does
not check STL support and might build the QT examples
even if toStdString() is not available.
Fix this, by not using the function.
https://bugzilla.gnome.org/show_bug.cgi?id=727608
Signed-off-by: Thomas Haller <thaller@redhat.com>
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.
Error found by running Coverity scan
https://bugzilla.redhat.com/show_bug.cgi?id=1025894
Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.
The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).
Signed-off-by: Thomas Haller <thaller@redhat.com>
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.
In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
There where cases, where TAB was mixed with SPACES. Replace TAB with SPACES.
Additionally, make the script nm-state.py executable
Signed-off-by: Thomas Haller <thaller@redhat.com>
The various need_secrets() implementation do allocate a fresh GPtrArray, but
add static strings to them without dup'ing. Thus callers must _not_ free the
array elements, only the array itself. Adjust documentation and annotations
accordingly.
Also adjust the corresponding comment in the goi-list-connections.py example.
https://bugzilla.gnome.org/show_bug.cgi?id=698175
We had separate checks for glib-2.0, gobject-2.0, gmodule-2.0, and
gio-unix-2.0. It doesn't make sense to link a binary against all 4
because gio-unix-2.0 depends on glib-2.0 and gobject-2.0. Doing this
actually breaks things in unusual circumstances.
Generally, few bits of NM actually just use glib, and not gio. We
might as well coalesce those requirements together, even if it means
in some cases we "overlink". Additionally, I chose for now to fold
gmodule-2.0 in as well, even though many fewer programs need it. The
cost of overlinking is quite small.
The benefit of this is less repeated junk in Makefile.am, as well as
more centralized control over GLib. A followup patch will allow us to
set -DGLIB_VERSION_MIN_REQUIRED in just one place, rather than having
to replicate it 4 times.
The NM configure is still suboptimal - for example, libpolkit-1
depends on gio-2.0, so really we should determine the compiler flags
all in one pass. But it doesn't matter too much for now.
A new value for NM80211Mode is introduced (NM_802_11_MODE_AP) and the
new mode is passed to wpa_supplicant analogous to adhoc-mode.
The places which need to know the interface mode have been extended to
handle the new mode.
If the configuration does not contain a fixed frequency, a channel is
selected the same way as with adhoc-mode before.
Unfortunately since libnm-glib/libnm-util make heavy use of
GHashTable and GValue, functions that deal with these types
can't be used from Python when using GObject Introspection,
since pygobject can't handle conversion between python types
and GValue/GHashTable very well. You'll likely encounter
assertions like:
ERROR:pygi-argument.c:1755:_pygi_argument_to_object: assertion failed: (g_type_info_get_tag (key_type_info) != GI_TYPE_TAG_VOID)
Aborted
- the first uses dbus-glib and D-Bus "NameOwnerChanged" signal directly
- the second uses GIO's g_bus_watch_name()
- the third uses Qt and QDBusServiceWatcher class
It's always used with a GByteArray anyway, as are most
functions in nm-utils.h. Even better, we can skip the
memcpy since it turns out to be pointless.
Simplifies code internally, and makes it easier for clients as well in
some cases where they want to control what ends up in the resulting
hash and what does not.
Just for consistency, make settings related stuff live under the
org.freedesktop.NetworkManager namespace, rather than its own
org.freedesktop.NetworkManagerSettings namespace. Renames are done for
DBus interface names, DBus object paths, and polkit actions.
Remove the org.freedesktop.NetworkManagerSystemSettings bus name and
have everybody talk to org.freedesktop.NetworkManager. Now that we have
a single settings service that's embedded in the main daemon, we don't
need separate names anymore.
* examples/python/systray/eggtrayicon.c, gnome/applet/eggtrayicon.c,
gnome/applet/passphrase-dialog.c, gnome/applet/vpn-password-dialog.c,
src/NetworkManager.c: Include <glib/gi18n.h> and not <libintl.h>.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1760 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* panel-applet/menu-info.c: change from bold text to light
colored, may cause problems with some themes, i've tested a lot
and they seem fine.
* panel-applet/NMWirelessApplet.c: fix strength tooltip
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@288 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* initscript/Debian/.cvsignore:
* initscript/Slackware/.cvsignore:
Added new cvsignores for Makefile, Makefile.in
* test/.cvsignore:
Added nmtestdevices
* src/NetworkManagerDevice.c:
* src/NetworkManager.c:
Updated the wireless/wired HAL device strings from net.ethernet to
net.80203 or net.80211 depending on wired or wireless respectively
Should probably update the configure.in to ask for the correct HAL
version now.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@168 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/NetworkManager.py:
s/Quality/Strength/
* examples/python/systray/network_tray.py:
Lots of little changes and fixes. been rotting for a while so I
figured I'd finally sync them all with CVS
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@166 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/systray/network_tray.py
(network_tray.sort_networks):
Added support for having wireless always scanning
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@141 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/NetworkManager.py:
added CONNECTED, CONNECTING, and DISCONNECTED states
added methods to return number of devices of a single type
* examples/python/systray/network_tray.py:
did some tweaks to get the menu looking near what it is supposed
to look like. Also did a Airo card hack to make it show the
correct AP quality
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@134 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/NetworkManager.py:
added convience functions has_wired_device and has_wireless_device
* examples/python/systray/network_tray.py:
cleaned up a bunch of cruft, added support for listing wireless
networks just like the real applet. This is probably all I'm
going to work on this applet from now on.
TODO: add support for actually changing networks and devices
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@111 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/NetworkManager.py (NetworkManager.get_device):
changed "nm.networks" into a dict from a list so I can store all
the cool information about networks in there
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@109 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
* examples/python/NetworkManager.py:
Bug fixes to the code so we get all the device information
that we need in get_device()
* examples/python/NMTester.py:
Fixed _print_device_list to print_device_list
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@107 4912f4e0-d625-0410-9fb7-b9a5a253dbdc