For my Qt GUI, I display a progress bar on first start to keep track of how far the initial block chain download is.
This needs a conservative estimate of the total blocks in the chain. Currently, one such estimate is hardcoded into IsInitialBlockDownload as a magic number.
This patch moves the magic number to a constant, and adds a function GetTotalBlocksEstimate() to retrieve the value (always 0 for testnet).
According to the forum topic https://forum.bitcoin.org/index.php?topic=17485.0 it would be possible to compute a real estimate based on version messages; this same interface could later be extended to return this.