Hi!!
Well, it's surely doable, no problem.
the fact is - I tought there was a simpler solution.
I will have to implement e mechanism to keep track of the bearers no longer
present, so I was thiking to:
- mark all the bearer objects I keep as non-visited
- compare the bearer returned with the ones I have, marking any match as
"visited"
- in the end, all the non-visisted bearers are no longer present and will be
removed
Yeah, I'm going to use paths for comparison.
Enrico
On Mon, 4 Oct 2021, Aleksander Morgado wrote:
Date: Mon, 4 Oct 2021 15:11:58
From: Aleksander Morgado <aleksan...@aleksander.es>
To: Enrico Mioso <mrkiko...@gmail.com>
Cc: "ModemManager (development)" <modemmanager-devel@lists.freedesktop.org>
Subject: Re: GSignals for bearers addition/removal
Hey,
On Mon, Oct 4, 2021 at 3:01 PM Enrico Mioso <mrkiko...@gmail.com> wrote:
Ok. My idea was to connect to the ::connected signals of each bearer to monitor
their state.
To do so, I'm going to keep a list of bearers I am managing, and in my case i
would like them to be ideally all of the bearers of a modem.
To keep GSignals connected, I need to keep an object reference infact.
But this way I will need to scan the entire list everytime.
Am I missing something big?
What you can do is; run the list operation once and get the initial
bearer object list. Then, whenever the "bearers" property is updated
you'll get notified, and you can compare the list of bearer object
references you're keeping, with the new list (e.g. comparing the
object DBus paths for example). If new bearers are reported in the new
list, you take a reference to the object and add them to the list
you're keeping. If a bearer that you had is no longer in the new list,
you remove it from your list.
It's a bit tricky, because the mm_modem_list_bearers_sync() operation
is creating new bearer objects each time it's called, so the objects
in the new list and the objects you're keeping in your own list are
really different objects, even if they point to the same remote DBus
object.
--
Aleksander
https://aleksander.es