If the iPhone is 4.1 - you are SOL
If the Firmware is 4.0.2
A) Are you getting from Apple? (don't think you can get one with 4.0.2 anymore) if yes, them you are SOL
B) if no, them are you getting from ebay/craiglist/friend/newsapaer, etc .... Them if the previews owner saved the SHSHs on Cydia, you will be able to restore to 4.0.1 jailbreak and unlock. However if the previews owner update to 4.1 or 4.1 beta at any point, the phone may have an updated basedband which is not unlockable at the moment (if ever), in that case you will be able to jailbreake but not unlock.
if Firmware is 4.0.1
* If that is the case.....you may be getting it from a 3er party so same point B) above applies
As you can see, this is not a simple question that can be answer without more details and information, it is very dependent on each device.