Considering a single photon in a cavity, how is a qubit realized in this setup? How is the qubit $|0\rangle$ or $|1\rangle$ manipulated? I.e. how are the transitions $|0\rangle \to |1\rangle$ and $|1\rangle \to |0\rangle$ achieved in a controlled manner?
Using a two-state atom dropped or conveyed through the cavity with a precisely controlled speed such that the Rabi oscillation (atom in $|g\rangle$, cavity mode in $|1\rangle$ $\leftrightarrow$ atom in $|e\rangle$, cavity mode in $|0\rangle$) makes just one $\pi$-rotation.
These transactions are well described by the Jaynes-Cummings model.