Search in sources :

Example 11 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class LibresonicThemeResolver method doResolveThemeName.

private String doResolveThemeName(HttpServletRequest request) {
    String themeId = null;
    // Look for user-specific theme.
    String username = securityService.getCurrentUsername(request);
    if (username != null) {
        UserSettings userSettings = settingsService.getUserSettings(username);
        if (userSettings != null) {
            themeId = userSettings.getThemeId();
        }
    }
    if (themeId != null && themeExists(themeId)) {
        return themeId;
    }
    // Return system theme.
    themeId = settingsService.getThemeId();
    return themeExists(themeId) ? themeId : "default";
}
Also used : UserSettings(org.libresonic.player.domain.UserSettings)

Example 12 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class UserSettingsController method updateUser.

public void updateUser(UserSettingsCommand command) {
    User user = securityService.getUserByName(command.getUsername());
    user.setEmail(StringUtils.trimToNull(command.getEmail()));
    user.setLdapAuthenticated(command.isLdapAuthenticated());
    user.setAdminRole(command.isAdminRole());
    user.setDownloadRole(command.isDownloadRole());
    user.setUploadRole(command.isUploadRole());
    user.setCoverArtRole(command.isCoverArtRole());
    user.setCommentRole(command.isCommentRole());
    user.setPodcastRole(command.isPodcastRole());
    user.setStreamRole(command.isStreamRole());
    user.setJukeboxRole(command.isJukeboxRole());
    user.setSettingsRole(command.isSettingsRole());
    user.setShareRole(command.isShareRole());
    if (command.isPasswordChange()) {
        user.setPassword(command.getPassword());
    }
    securityService.updateUser(user);
    UserSettings userSettings = settingsService.getUserSettings(command.getUsername());
    userSettings.setTranscodeScheme(TranscodeScheme.valueOf(command.getTranscodeSchemeName()));
    userSettings.setChanged(new Date());
    settingsService.updateUserSettings(userSettings);
    List<Integer> allowedMusicFolderIds = Util.toIntegerList(command.getAllowedMusicFolderIds());
    settingsService.setMusicFoldersForUser(command.getUsername(), allowedMusicFolderIds);
}
Also used : User(org.libresonic.player.domain.User) UserSettings(org.libresonic.player.domain.UserSettings) Date(java.util.Date)

Example 13 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class AudioScrobblerService method createRegistrationData.

private RegistrationData createRegistrationData(MediaFile mediaFile, String username, boolean submission, Date time) {
    if (mediaFile == null || mediaFile.isVideo()) {
        return null;
    }
    UserSettings userSettings = settingsService.getUserSettings(username);
    if (!userSettings.isLastFmEnabled() || userSettings.getLastFmUsername() == null || userSettings.getLastFmPassword() == null) {
        return null;
    }
    RegistrationData reg = new RegistrationData();
    reg.username = userSettings.getLastFmUsername();
    reg.password = userSettings.getLastFmPassword();
    reg.artist = mediaFile.getArtist();
    reg.album = mediaFile.getAlbumName();
    reg.title = mediaFile.getTitle();
    reg.duration = mediaFile.getDurationSeconds() == null ? 0 : mediaFile.getDurationSeconds();
    reg.time = time == null ? new Date() : time;
    reg.submission = submission;
    return reg;
}
Also used : UserSettings(org.libresonic.player.domain.UserSettings)

Example 14 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class LibresonicLocaleResolver method doResolveLocale.

private Locale doResolveLocale(HttpServletRequest request) {
    Locale locale = null;
    // Look for user-specific locale.
    String username = securityService.getCurrentUsername(request);
    if (username != null) {
        UserSettings userSettings = settingsService.getUserSettings(username);
        if (userSettings != null) {
            locale = userSettings.getLocale();
        }
    }
    if (locale != null && localeExists(locale)) {
        return locale;
    }
    // Return system locale.
    locale = settingsService.getLocale();
    return localeExists(locale) ? locale : Locale.ENGLISH;
}
Also used : Locale(java.util.Locale) UserSettings(org.libresonic.player.domain.UserSettings)

Aggregations

UserSettings (org.libresonic.player.domain.UserSettings)14 User (org.libresonic.player.domain.User)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 HashMap (java.util.HashMap)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 Date (java.util.Date)3 Player (org.libresonic.player.domain.Player)2 Locale (java.util.Locale)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 UserSettingsCommand (org.libresonic.player.command.UserSettingsCommand)1 Avatar (org.libresonic.player.domain.Avatar)1 Playlist (org.libresonic.player.domain.Playlist)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1