Re: signal for (De)ActivateConnection?



Hi,

[...]

Hi,

sounds a bit like you want to perform some action when a particular
connection profile activates/deactivates.

jepp.

First, you need to know which a connection profile you care about, that
is, you need its /org/freedesktop/NetworkManager/Settings/* path.
You need to call GetSettings() on each of the profiles, to match what
you are looking for (for example, matching the connection.id).

Ok. I'd prefer a general approach, not one for a single machine only.
So I need some information about the type of connection this is.
In my actual script I check for the type of device (NM_DEVICE_TYPE_*)
combined with a few active checks into the network this device is
connected to, to decide what actions to take.

When a connection is activated, it has an active-connection that
references it. Usually there is at most one such active-connection,
but while re-activating a connection there can be multiple once (one
that is about to deactivate, and once that is about to activate).

Ok, I guess there are flags to check just like for devices? For that
purpose I check NM_DEVICE_STATE_* in the actual script.

Anyway, you need to monitor these active connections for whether they
reference the profile you care about. The Manager's PropertyChanged
event for ActiveConnections notifies you when active-connection come to
be and cease to exist.

Ok, this seems to be the important piece.
What exactly is the PropertyChanged Event *for ActiveConnection*?

The ActiveConnection basically ties the profile to the networking
device.

Ok.

and as said, an active VPN connection is a bit odd, they are active-
connections too (with an additional
org.freedesktop.NetworkManager.VPN.Connection interface).


I would inspect the state with the "d-feet" GUI.

Never came across this tool, but I'll check it - thx.


You could also use libnm via GObject introspection (e.g. from Perl or
Python). That might be more convenient to use, then a plain D-Bus
library (the latter works of course too). We don't have any perl
examples, only Python:
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/pyth
on

Yeah, I saw them and adopted my actual script from them, but I couldn't
find a useful example for quering active connections - presumably cause
I looked for the wrong patterns.

best,
Thomas

Thx again.

Bye.
Michael.
-- 
Michael Hirmke


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]