Phonon-induced dephasing of quantum dot excitons and microcavity-embedded quantum