Hot bubbles from active galactic nuclei as a heat source in cooling-flow clusters