Programmatically determine what is on the i2c line
Scanning all possible addresses is probably the most straightforward, assuming you don't know what the slave address is beforehand.  I2C is not all that slow (100s of kbit/sec) so scanning through 128 addresses will not take much time at all.  

Now, after you've identified which addresses are accessible on the bus, the next step is actually communicating with them.  This is why scanning is not usually done over the entire range - generally the firmware only knows how to talk to a few devices, and the addresses for these devices are hard-coded in the firmware.  This is the case because generally I2C device addresses are not very flexible - they're either completely fixed, or mostly fixed with a couple of bits settable via pin strapping.  This generally means you're stuck with solution 3 by default.