This afternoon JP asked if Banshee should not fetch CD metadata through MusicBrainz if there wasn’t an available network connection; Nat and I also discussed related ideas a few months ago, and I felt like taking a few hours to diverge from the normal code base this evening, so it was perfect timing to implement a nice, simple piece of “functional candy.”
I ended up writing some quick NetworkManager C# “bindings” using dbus-sharp and the NetworkManager DBus API. They’re mostly complete: no dialup support and no wireless network creation support. The manager, device, and network objects are supported, with only a select few method implementations missing on each. Signals work, though I’m pretty pissed at
NetworkManager.Manager.InvokeEvent(string) for juicy details in
For those interested in viewing the code or even using it in your C# programs, it is checked in.
In Banshee there is a new class,
Banshee.Base.NetworkDetect, which has an event to notify other classes that a connection is either up or down, and has a basic
Connected property. If NetworkManager can’t be found, it’s always assumed that a connection is available. There should probably be some kind of non-NetworkManager fall back, but it’s not really that important. If you have NetworkManager, great, if not, oh well.
This now means that, for example, if you started Banshee and you were offline, and then inserted an audio CD, Banshee would not attempt to fetch the metadata from MusicBrainz. However, you then connect and are online, and NetworkManager fires a signal, Banshee propagates it to the audio CD object, and it fetches metadata automagically. How cute.