On Thursday 02 of February 2012 11:23:15 Dan Williams wrote: > On Mon, 2012-01-30 at 16:56 -0800, Greg Suarez wrote: > > Hi all, > > > > My code communicates with NM via dbus c-api and I would like know how > > to detect when NM restarts so I can tear down the old connection and > > create a new one. > > What I'm seeing right now is when NM restarts I cease to get any > > notifications from NM. I'm working with NM 0.9 > > If you listen to the "NameOwnerChanged" signals from the core dbus > daemon you'll get notifications of service restarts. NM even does this > in places to see when stuff like wpa_supplicant quits. This signal has > 3 parameters: the dbus service name that had an owner change, the old > owner name, and the new owner name. So when NM starts you'd get > something like this: > > "org.freedesktop.NetworkManager","",":1.36" > > and when NM quits, you'd get something like this: > > "org.freedesktop.NetworkManager",":1.36","" > > which you can use to figure out when to tear down the old connection and > to make a new one. > > Dan >
I've put together a few examples to demonstrate how to listen for "NameOwnerChanged" signal. http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib/monitor- nm-running-GDBus.c http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib/monitor- nm-running-dbus-glib.c http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/qt/monitor- nm-running.cpp Useful links: * http://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-name- owner-changed * http://developer.gnome.org/gio/stable/gio-Watching-Bus-Names.html * http://doc.qt.nokia.com/4.7-snapshot/qdbusservicewatcher.html Jirka PS: Uff, cgit.freedesktop.org is down. _______________________________________________ networkmanager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
