Skip to content

th/libnm-dbus-rework-1] various patches for libnm and NMRefString

Thomas Haller requested to merge th/libnm-dbus-rework-1 into master

This is the first of a series of upcoming patches that will aim to rework (improve :) ) libnm.

At this point,

  • it just adds two utilities that are so far unused (but will be used).

  • also, it drops unused code from NMSecretAgentOld that still assumed there could be private D-Bus sockets.


In particular, NMRefString is something I wanted for a long time.

In the past, I did nm-ref-string, but that was NACK-ed. Also, it followed a different approach back then:

  • it exposed strings as const char *, instead of having a NMRefString struct (like GRefString does)
  • it does not supported interning, but only reference counting.

There is also GRefString, which serves a similar purpose, but makes some design decisions differently.

While there are pros and cons for each options (including whether to have such a helper at all), I think this is the overall best solution. And I intend to use that.

The usecase will be when tracking D-Bus objects. Those objects have D-Bus interfaces (strings like org.freedesktop.NetworkManager.Device.Wired), properties (strings like "HwAddress"), and object paths (like "/org/freedesktop/NetworkManager/Settings/22"). These strings are "arbitrary", in the sense that we cannot g_intern_string() them, because the application would leak them without freeing them ever. We should deduplicate them and also be able to compare them with pointer equality. That's what NMRefString gives.

Merge request reports