|
|
|
@ -25,6 +25,12 @@ import java.util.List; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
|
|
|
|
|
|
import org.libresonic.player.command.PlayerSettingsCommand; |
|
|
|
@ -42,14 +48,19 @@ import org.libresonic.player.service.TranscodingService; |
|
|
|
|
* |
|
|
|
|
* @author Sindre Mehus |
|
|
|
|
*/ |
|
|
|
|
public class PlayerSettingsController extends SimpleFormController { |
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/playerSettings") |
|
|
|
|
public class PlayerSettingsController { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private PlayerService playerService; |
|
|
|
|
@Autowired |
|
|
|
|
private SecurityService securityService; |
|
|
|
|
@Autowired |
|
|
|
|
private TranscodingService transcodingService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected Object formBackingObject(HttpServletRequest request) throws Exception { |
|
|
|
|
@RequestMapping(method = RequestMethod.GET) |
|
|
|
|
protected Object formBackingObject(HttpServletRequest request, Model model) throws Exception { |
|
|
|
|
|
|
|
|
|
handleRequestParameters(request); |
|
|
|
|
List<Player> players = getPlayers(request); |
|
|
|
@ -91,12 +102,12 @@ public class PlayerSettingsController extends SimpleFormController { |
|
|
|
|
command.setPlayers(players.toArray(new Player[players.size()])); |
|
|
|
|
command.setAdmin(user.isAdminRole()); |
|
|
|
|
|
|
|
|
|
return command; |
|
|
|
|
model.addAttribute("command",command); |
|
|
|
|
return "playerSettings"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void doSubmitAction(Object comm) throws Exception { |
|
|
|
|
PlayerSettingsCommand command = (PlayerSettingsCommand) comm; |
|
|
|
|
@RequestMapping(method = RequestMethod.POST) |
|
|
|
|
protected String doSubmitAction(@ModelAttribute PlayerSettingsCommand command, Model model) throws Exception { |
|
|
|
|
Player player = playerService.getPlayerById(command.getPlayerId()); |
|
|
|
|
|
|
|
|
|
player.setAutoControlEnabled(command.isAutoControlEnabled()); |
|
|
|
@ -110,6 +121,8 @@ public class PlayerSettingsController extends SimpleFormController { |
|
|
|
|
transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds()); |
|
|
|
|
|
|
|
|
|
command.setReloadNeeded(true); |
|
|
|
|
model.addAttribute("command",command); |
|
|
|
|
return "redirect:playerSettings.view"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Player> getPlayers(HttpServletRequest request) { |
|
|
|
@ -135,15 +148,4 @@ public class PlayerSettingsController extends SimpleFormController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setSecurityService(SecurityService securityService) { |
|
|
|
|
this.securityService = securityService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setPlayerService(PlayerService playerService) { |
|
|
|
|
this.playerService = playerService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setTranscodingService(TranscodingService transcodingService) { |
|
|
|
|
this.transcodingService = transcodingService; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|