It's really simple. Just issue

sudo ufw allow Samba
This configures it for all samba ports via the app facility in ufw... man ufw for more details. This was with Ubuntu 10.4.