How to connect the third contact in the DC barrel?
If no plug is inserted, the third pin will contact the middle pin. You can put a bias on it from e.g. a battery, and detect presence of an external supply that way.