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