Monday, March 29, 2010

ISensNetwork based network monitor for Evolution

These weeks I was using my spare cycles to prepare evolution to be buildable and running before the GNOME 2.30 freeze. One of the things that Evolution for windows was missing was an alternative for the NetworkManager network connection detection module. I crafted one using Windows ISensNetwork COM interface. The result is to be found here for those that might be interested in seeing how to implement COM callbacks in plain C.

There are some examples out there showing how to implement ISensNetwork. One of them using heavy ATL framework is to be found here. Another, one, using C++ is to be found here. Both examples have a little problem that actually prevents them from being properly used from unprivileged account, although they work well when Administrator runs them. The problem is that the registering of the event subscription will return E_ACCESSDENIED. Judging from the number of post on different fora when one querries Uncle Google, the solution is not very known. If you have the same problem, please check the plain C example that I crafted using the above-mentioned C++ code as a base. I discovered that specifying that the subscription is a per user one, by using IEventSubscription::put_PerUser(..) method allows your program to register for system events even if it is run as unprivileged user. The source code can be built with different flavours of MinGW and also with Visual Studio and the program installs an icon in the system tray that will notify you when connection status of your computer changes.

By the way, there is not a lot of sample code out there that would use COM from a plain C. Apart excellent code produced by my colleague and object of mute admiration, Tor Lillqvist, there is an wonderful serie of articles by Jeff Glatt. It is worth reading for anybody that wants to do COM the real men's way, in plain C. Here are the links to part 1, part 2, part 3, part 4, part 5, part 6, part 7 and part 8. It is worth to register and get the example code as well as a neat clean html version of the articles. It is enough to download the files linked from the part 8 since they are always cumulated with all files from all previous parts.

Tuesday, March 02, 2010

DBus for windows in windows:mingw repositories

Last night two important new packages landed into windows:mingw:win32 and windows:mingw:win64 projects and repositories in openSUSE build service: mingw32-dbus-1 and mingw32-dbus-1-glib glib bindings for 32-bit Windows and mingw64-dbus-1 and mingw64-dbus-1-glib for 64-bit Windows. Although, they are known to work in certain setting, they might be buggy in others. So, if you build for Windows some package that needs Dbus, please use these rpms to solve that dependency. And if you find bugs, just report them against the corresponding repository. We will take care of investigating and pushing the reports up the stream.

As a nice result of this new packages would be that the development version of evolution-data-server and evolution should be buildable now on Windows too. Not tried yet though, but I know someone who did ;-)

Note that the dbus-1 package is based on the latest development tarball (1.3.0) and is brought to the level of recent git master by a patch inside the rpm package. The dbus-1-glib is basically the 0.84 tarball with a little patch allowing cross-compiling and disabling one test that hard-codes the use of Unix sockets.

So, please, use those packages, stress-test them and report all useful information.