Theory of resonance fluorescence