cgeo/c-geo-opensource — pull request #1446 by samueltardieu (2012-04-25 12:19:17+00:00)
Title: Observable cggeo

This change transforms the former `cgGeo` into an observer/subject pattern. I would appreciate if people would test it as the change are quite exhaustive and although it seems to work fine in tests and for me in real life, more tests can be useful to ensure the behaviour hasn't changed. Formal reviews are fine of course, but even tests alone will be great. I plan to merge this in two days, or sooner if I get early feedback.

After this change, no global `cgeoapplication.cgeo` object is available. The geolocation is accessed by registering an observer through `cgeoapplication.addObserver` (and removing it through `cgeoapplication.deleteObserver`), and if the last known state is required it can be obtained through `cgeoapplication.currentGeo()` although I plan to have less of those in the future.

Note that the returned or updated object is no longer a `cgGeo` instance but an immutable object implementing the `IGeoData` interface.

When this change is in, I plan to refactor the direction handling the same way, then probably unify both of them.

The diff statistics can be split in two parts:

- 278 lines added by the observer/subject pattern implementation (interfaces and two concrete classes, + documentation and tests)
- 144 lines removed from the core c:geo code by using this pattern and removing some redundancies (more of them will be cleaned up in the future but are unrelated to this change)