AT&T wins legal battle to buy Time Warner