Re: signal for (De)ActivateConnection?



Hi Thomas,

obviously you wrote an answer to my latest mail, but it never got into
my inbox. I only saw it on nabbles.com 8-/
Nevertheless thx for it.

 On Sun, 2018-12-23 at 23:41 +0100, Michael Hirmke wrote:

Hi,

after a long time I found some time to start the rewrite of my
script.
There are a few questions remaining, though.

If I understood correctly, for a generic script I have to iterate
over
all existing connections (ListConnections).
What I don't understand actually is how to get a relation between the
connection settings object and an existing active connection object.
Do I have to iterate over all active connections and find a matching
uuid? Or do we have a simpler way to get to this
relation/information?
Yes, that's one way.

Of, if you know already which Device you are interested in, you can get
from the device to the active connection to the (settings) connection.

I am not interested in devices at all, but only in connections, their type
and their state.
Meanwhile the script does quite the thing, but I am not sure, if it is
doing it the "right" way or if my logics is ok. I know, I make too great
demands on you, but could yo have a look on the pseudo code below and
tell me, whether or where I should alter/improve the program flow?
And perhaps you can ask the question regarding the signal handler
included in the pseudo code.

-----------------------------------------------------------------------
pseudo code for dbus_nm_c:

MAIN:

- connect to the DBus system bus
- retrieve NetworkManager service
- retrieve NetworkManager interface
- retrieve NetworkManager settings interface

- initially find and handle active connections
  -> call function 'HandleAllActiveConnections' with a list of paths for
     active connections (NMIF->ActiveConnections)

- connect to signal 'PropertiesChanged' on NetworkManager interface
  -> handler is function 'onNMPropertiesChanged'

- get reactor
- start reactor and wait for signals

function HandleAllActiveConnections:

- loop over paramter with paths of active connections
- if connection is
  /^\/org\/freedesktop\/NetworkManager\/(ActiveConnection|VPN\/Connection)/
  - run function 'HandleActiveConnection' this connection

function HandleActiveConnection:

  - get connection object from connection path
  - if no signal handler is assigned to that connection object
    (IFCA->{ "signal_handlers" }{ "StateChanged" }) *) see below
    !! Question: Is there a method to get that information instead of
    !! directly diving into the object structure??

    - get connection type
    - get connection state

    - run function 'onConnectionStateChanged' (for initial work to do)
      with parameters for connection type and state

    - assign a handler for signal 'StateChanged' on the connection
      -> handler is again function 'onConnectionStateChanged'
         with parameters for connection type and state

function onConnectionStateChanged:

- do the real work

function onNMPropertiesChanged:

- if changed property is 'ActiveConnections'
  -> call function 'HandleAllActiveConnections' with a list of paths for
     active connections ($props->{ 'ActiveConnections' })

----
*) If a handler for signal StateChanged" already exists for this
   connection, the connection is already known and a handler has been
   added in a previous iteration; from then on everything has to be
   handled by this handler called by the appropriate signal for the
   connection; even if another "PropertiesChanged" signal for
   NetworkManager with "ActiveConnections" containing the same
   connection must be ignored.
-----------------------------------------------------------------------



best,
Thomas


Thx a lot.

Merry Christmas (if this is your thing :))

Bye.
Michael.
-- 
Michael Hirmke


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