Move install state detection to it's own function
Move install state detection to it's own function

Install state is getting used a few times, it's easier having the
detection mechanism in one function that can be used everywhere else.
Also adds an Install State Enum for easier usage.

no1dead/Plug1n,Wolvan/Homebr3w