Proton transfer and ion solvation from ab initio simulations