Old plugins (ie, that aren't IPv6 capable) don't send the 'config'
signal, and thus have no way of signalling which IP methods they
have support for. Which means they won't set priv->has_ip4 and
thus the connect timer will kill the connection after a minute.
So track whether we got a 'config' signal, and if we didn't, but
we did get an 'ip4-config' signal (which means this is an old
plugin) then we just assume that the plugin supports IPv4. This
allows the connect timer to be canceled and the plugin to advance
to the STARTED state.
Currently the .gir files for NetworkManager-1.0 and NMClient-1.0 declare
their dependencies twice, once with the GIR name and another one with
the pkg-config name. This causes problems with Vala bindings generation.
Add new API to allow passing both IPv4 and IPv6 configuration
information from VPN plugins to the backend.
Now instead of a single Ip4Config, a plugin has Config, Ip4Config, and
Ip6Config. "Config" contains information which is neither IPv4 nor
IPv6 specific, and also indicates which of Ip4Config and Ip6Config are
present. Ip4Config now only contains the IPv4-specific bits of
configuration.
There is backward compatibility in both directions: if the daemon is
new and the VPN plugin is old, then NM will notice that the plugin
emitted the Ip4Config signal without having emitted the Config signal
first, and so will assume that it is IPv4-only, and that the generic
bits of configuration have been included with the Ip4Config. If the
daemon is old and the plugin is new, then NMVPNPlugin will copy the
values from the generic config into the IPv4 config as well. (In fact,
NMVPNPlugin *always* does this, because it's harmless, and it's easier
than actually checking the daemon version.)
Currently the VPN is still configured all-at-once, after both IPv4 and
IPv6 information has been received, but the APIs allow for the
possibility of configuring them one at a time in the future.
The signal is private for libnm-glib and should not be used externally.
It is emitted when there's an error while creating an object.
In addition, this commit makes use of the signal in NMClient to ensure
that the callbacks are always called for nm_client_activate_connection()
and nm_client_add_and_activate_connection().
Otherwise if a client holds references to the objects (or in the
JavaScript case, uses deferred garbage collection) they'll still
be in the cache when NM restarts, and the old object may have the
same path as some new object, which isn't good.
When NMClient changes state to "not running", don't just unref all the
devices and connections: emit notify::active-connections and
device-removed signals too, so the app will drop its copies of them.
https://bugzilla.gnome.org/show_bug.cgi?id=674473
In some situations, objects might get used after being disposed, so
clear out their various priv fields so we don't try to access unreffed
objects, freed strings, etc.
https://bugzilla.gnome.org/show_bug.cgi?id=674473
No idea *why* they're NULL, unless perhaps that dbus-glib can't demarshal
the variants for some reason, but until we know why at least log the
problem so we know what properties the issue might affect.
If a client keeps the connection around after NMRemoteSettings is done
with it (and has emitted 'removed' for that connection) then the
RemoteSettings object was still registered to receive signals for
that connection. To prevent clients from being able to screw up
the RemoteSettings, disconnect any signals it may be listening for
when the connection is removed. (it should be doing that anyway)
This reverts commit dd0460697c.
The commit dd0460697c make nm_remote_settings_new()
create the NMRemoteSettings object synchronously. It fixed getting properties,
but undid the previous ability to initialize the object asynchronously.
It can be reverted now, because a4f450aa0b commit
ensure initialization in get_property() calls.
We need to do _nm_object_ensure_inited() /
_nm_remote_settings_ensure_inited() from the get_property()
implementations; in most cases, get_property() just calls another
accessor method (which will call _nm_object_ensure_inited()), but in a
few places, it reads priv->whatever directly, so we need to make sure
that it's valid.
Most of the stuff was done by 762df85234.
But to allow this piece of code:
from gi.repository import NMClient
nmclient = NMClient.Client()
print nmclient.get_active_connections()
we also need to set "dbus-path" property in NMClient constuctor(),
else parent NMObject is not properly constructed.
Bindings (like GObject Introspection) almost always create objects
using g_object_new() by default and don't use our helper functions
like nm_client_new(). Thus we need to make sure that if the
object is created in that way, any property accesses or functions
that return properties ensure that the object is fully initialized,
which is what the _new() functions were supposed to do. In one
case in NMClient that was missing (getting active connections)
and wasn't happening at all in NMRemoteSettings, which are our two
entry points into libnm-glib.
This allows this python+GI sequence to return the expected active
connection list:
from gi.repository import NMClient
nmclient = NMClient.Client(dbus_path='/org/freedesktop/NetworkManager')
active = nmclient.get_active_connections()
print(active)
where previously it returned an empty list because the NMClient
wasn't fully initialized by the time nm_client_get_active_connections()
was called.
Add nm_device_connection_compatible() that returns an error when it fails.
nm_device_connection_valid() does the same work except it doesn't set GError.
First: object creation requests get triggered each time a property
that refers to the object is read. That can happen from a couple
of places around the same time (like initialization) and to be
expected. But when those requests are processed (after we've
determined the type of object to create) a previous request may
have already created the object. If that's the case don't create
a duplicate.
Second: properties can also be updated from a few places which
don't know about each other (from both regular code and the
"pseudo property" signal handlers) so when adding objects to
array properties, make sure the object hasn't already been
added to that array.
Active Device objects held a reference to their ActiveConnection
which also held a reference back to the Device. Ensure that's
broken so everyone can get disposed correctly.
When NM was registering all of its enum types by hand, it was using
NamesLikeThis rather than the default names-like-this for the "nick"
values. When we switched to using glib-mkenums, this resulted in
dbus-glib using different strings for the D-Bus error names, causing
compatibility problems.
Fix this by using glib-mkenums annotations to manually fix all the
enum values back to what they were before. (This can't be done in a
more automated way, because the old names aren't 100% consistent. Eg,
"UNKNOWN" frequently becomes "UnknownError" rather than just
"Unknown".)
NM emits coalesced PropertiesChanged signals, which might be
delayed slightly and thus sent after the StateChanged signal
for devices. Clients of libnm-glib listening for the
'state-changed' signal and then querying the state manually
using nm_device_get_state() would still see the old state until
it was updated via the delayed PropertiesChanged signal
processing. Since when the StateChanged signal comes in the
device is already in the new state, just update the state and
leave the GObject property notify signal to the
PropertiesChanged signal handling code so that clients have
an accurate device state.
Fix handle_object_array_property() to deal with receiving an empty
list correctly (rather than warning and leaving the property with its
previous value still set).
Also, add two more untracked properties that shouldn't be warned about
(NMDevice:device-type and NMActiveConnection:vpn, both of which are
only used at construct time).
Rather than generating enum classes by hand (and complaining in each
file that "this should really be standard"), use glib-mkenums.
Unfortunately, we need a very new version of glib-mkenums in order to
deal with NM's naming conventions and to fix a few other bugs, so just
import that into the source tree temporarily.
Also, to simplify the use of glib-mkenums, import Makefile.glib from
https://bugzilla.gnome.org/654395.
To avoid having to run glib-mkenums for every subdirectory of src/,
add a new "generated" directory, and put the generated enums files
there.
Finally, use Makefile.glib for marshallers too, and generate separate
ones for libnm-glib and NetworkManager.
The notifications for child objects (like NMClient's device-added
signal or NMDeviceWifi's access-point-added signal) could get emitted
before the child objects were actually constructed, because
object_created() decrements the properties-retrieved tracking
variable, which wasn't always incremented before calling that
function.
Need to initialize libnm-util to get GValue transforms registered
so the property values print out as strings. Then actually print
some debugging information about properties.
Some property updates (mainly those dealing with properties that
hold objects themsevles) weren't being done in a synchronous manner
when synchronicity was requested. Make sure that happens.