I'm writing a NodeJS module that allows to communicate with NetworkManager from _javascript_. The module uses libnm-glib library.

In order to test the module, I took the approach to mock NetworkManager DBus service on the Session bus. It works fine for the NMRemoteSettings object as nm_remote_settings_new allows to supply my own DBusGConnection object connected to the session bus.

It's more difficult with NMClient object, as nm_cliet_new does not allow to supply the DBusGConnection object. Looking at the source code I have noticed that it creates it's own bus object bound to the System bus.

I worked around that by creating the NMClient using g_object_new directly, and passing bus object via construction parameters. This way my component may be missing some initialization done by _nm_object_ensure_inited (that's called in nm_client_new), but I noticed that _nm_object_ensure_inited is also called by other methods like nm_client_get_state, so I assume that whenever I call one of these, the object gets fully initialized. It seems to work fine, by the way.

So basically I have two questions.

 - Is it OK to create NMClient object this way? (at least with the version of NM)
 - I noticed that in the latest revision, nm_client_new hasn't changed. Is there a reason why DBusGConnection parameter is not there? Is there a chance that it will be added in future releases?


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