Update Ktlint to 0.20.0 version.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-03-24 19:47:55 +01:00
parent 46922d98ae
commit eb09e9b417
77 changed files with 722 additions and 583 deletions

View File

@ -19,9 +19,9 @@ internal const val STORAGE_DIR_NAME = "persistent_storage"
* Look at [org.moire.ultrasonic.cache.serializers] package for available [DomainEntitySerializer]s.
*/
class PermanentFileStorage(
private val directories: Directories,
private val serverId: String,
private val debug: Boolean = false
private val directories: Directories,
private val serverId: String,
private val debug: Boolean = false
) {
private val serializationContext = object : SerializationContext {
override fun isDebug(): Boolean = debug
@ -34,9 +34,9 @@ class PermanentFileStorage(
* Stores given [objectToStore] using [name] as a key and [objectSerializer] as serializer.
*/
fun <T> store(
name: String,
objectToStore: T,
objectSerializer: DomainEntitySerializer<T>
name: String,
objectToStore: T,
objectSerializer: DomainEntitySerializer<T>
) {
val storeFile = getFile(name)
if (!storeFile.exists()) storeFile.createNewFile()
@ -47,8 +47,8 @@ class PermanentFileStorage(
* Loads object with [name] key using [objectDeserializer] deserializer.
*/
fun <T> load(
name: String,
objectDeserializer: DomainEntitySerializer<T>
name: String,
objectDeserializer: DomainEntitySerializer<T>
): T? {
val storeFile = getFile(name)
if (!storeFile.exists()) return null

View File

@ -15,9 +15,9 @@ private const val SERIALIZER_VERSION = 1
private val artistSerializer get() = object : ObjectSerializer<Artist>(SERIALIZER_VERSION) {
override fun serializeObject(
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: Artist
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: Artist
) {
output.writeString(item.id)
.writeString(item.name)
@ -31,9 +31,9 @@ private val artistSerializer get() = object : ObjectSerializer<Artist>(SERIALIZE
}
override fun deserializeObject(
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
): Artist? {
if (versionNumber != SERIALIZER_VERSION) return null

View File

@ -14,9 +14,9 @@ private const val SERIALIZATION_VERSION = 1
private val indexesSerializer get() = object : ObjectSerializer<Indexes>(SERIALIZATION_VERSION) {
override fun serializeObject(
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: Indexes
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: Indexes
) {
val artistListSerializer = getArtistListSerializer()
output.writeLong(item.lastModified)
@ -26,9 +26,9 @@ private val indexesSerializer get() = object : ObjectSerializer<Indexes>(SERIALI
}
override fun deserializeObject(
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
): Indexes? {
if (versionNumber != SERIALIZATION_VERSION) return null

View File

@ -15,17 +15,17 @@ private const val SERIALIZATION_VERSION = 1
private val musicFolderSerializer = object : ObjectSerializer<MusicFolder>(SERIALIZATION_VERSION) {
override fun serializeObject(
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: MusicFolder
context: SerializationContext,
output: SerializerOutput<out SerializerOutput<*>>,
item: MusicFolder
) {
output.writeString(item.id).writeString(item.name)
}
override fun deserializeObject(
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
context: SerializationContext,
input: SerializerInput,
versionNumber: Int
): MusicFolder? {
if (versionNumber != SERIALIZATION_VERSION) return null

View File

@ -8,7 +8,7 @@ ext.versions = [
gradle : '4.5.1',
androidTools : "3.0.1",
ktlint : "0.15.1",
ktlint : "0.20.0",
ktlintGradle : "3.2.0",
detekt : "1.0.0.RC6-4",
jacoco : "0.7.9",

View File

@ -3,12 +3,12 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class Artist(
var id: String? = null,
var name: String? = null,
var index: String? = null,
var coverArt: String? = null,
var albumCount: Long? = null,
var closeness: Int = 0
var id: String? = null,
var name: String? = null,
var index: String? = null,
var coverArt: String? = null,
var albumCount: Long? = null,
var closeness: Int = 0
) : Serializable {
companion object {
private const val serialVersionUID = -5790532593784846982L

View File

@ -6,12 +6,12 @@ import java.io.Serializable
import java.util.Date
data class Bookmark(
val position: Int = 0,
val username: String,
val comment: String,
val created: Date? = null,
val changed: Date? = null,
val entry: Entry
val position: Int = 0,
val username: String,
val comment: String,
val created: Date? = null,
val changed: Date? = null,
val entry: Entry
) : Serializable {
companion object {
private const val serialVersionUID = 8988990025189807803L

View File

@ -3,9 +3,9 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class ChatMessage(
val username: String,
val time: Long,
val message: String
val username: String,
val time: Long,
val message: String
) : Serializable {
companion object {
private const val serialVersionUID = 496544310289324167L

View File

@ -3,8 +3,8 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class Genre(
val name: String,
val index: String
val name: String,
val index: String
) : Serializable {
companion object {
private const val serialVersionUID = -3943025175219134028L

View File

@ -3,10 +3,10 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class Indexes(
val lastModified: Long,
val ignoredArticles: String,
val shortcuts: MutableList<Artist> = mutableListOf(),
val artists: MutableList<Artist> = mutableListOf()
val lastModified: Long,
val ignoredArticles: String,
val shortcuts: MutableList<Artist> = mutableListOf(),
val artists: MutableList<Artist> = mutableListOf()
) : Serializable {
companion object {
private const val serialVersionUID = 8156117238598414701L

View File

@ -1,8 +1,8 @@
package org.moire.ultrasonic.domain
data class JukeboxStatus(
var positionSeconds: Int? = null,
var currentPlayingIndex: Int? = null,
var gain: Float? = null,
var isPlaying: Boolean = false
var positionSeconds: Int? = null,
var currentPlayingIndex: Int? = null,
var gain: Float? = null,
var isPlaying: Boolean = false
)

View File

@ -4,7 +4,7 @@ package org.moire.ultrasonic.domain
* Song lyrics.
*/
data class Lyrics(
val artist: String? = null,
val title: String? = null,
val text: String? = null
val artist: String? = null,
val title: String? = null,
val text: String? = null
)

View File

@ -25,8 +25,9 @@ class MusicDirectory {
@JvmOverloads
fun getChildren(
includeDirs: Boolean = true,
includeFiles: Boolean = true): List<Entry> {
includeDirs: Boolean = true,
includeFiles: Boolean = true
): List<Entry> {
if (includeDirs && includeFiles) {
return children
}
@ -35,34 +36,34 @@ class MusicDirectory {
}
data class Entry(
var id: String? = null,
var parent: String? = null,
var isDirectory: Boolean = false,
var title: String? = null,
var album: String? = null,
var albumId: String? = null,
var artist: String? = null,
var artistId: String? = null,
var track: Int? = 0,
var year: Int? = 0,
var genre: String? = null,
var contentType: String? = null,
var suffix: String? = null,
var transcodedContentType: String? = null,
var transcodedSuffix: String? = null,
var coverArt: String? = null,
var size: Long? = null,
var songCount: Long? = null,
var duration: Int? = null,
var bitRate: Int? = null,
var path: String? = null,
var isVideo: Boolean = false,
var starred: Boolean = false,
var discNumber: Int? = null,
var type: String? = null,
var created: Date? = null,
var closeness: Int = 0,
var bookmarkPosition: Int = 0
var id: String? = null,
var parent: String? = null,
var isDirectory: Boolean = false,
var title: String? = null,
var album: String? = null,
var albumId: String? = null,
var artist: String? = null,
var artistId: String? = null,
var track: Int? = 0,
var year: Int? = 0,
var genre: String? = null,
var contentType: String? = null,
var suffix: String? = null,
var transcodedContentType: String? = null,
var transcodedSuffix: String? = null,
var coverArt: String? = null,
var size: Long? = null,
var songCount: Long? = null,
var duration: Int? = null,
var bitRate: Int? = null,
var path: String? = null,
var isVideo: Boolean = false,
var starred: Boolean = false,
var discNumber: Int? = null,
var type: String? = null,
var created: Date? = null,
var closeness: Int = 0,
var bookmarkPosition: Int = 0
) : Serializable {
fun setDuration(duration: Long) {
this.duration = duration.toInt()

View File

@ -4,6 +4,6 @@ package org.moire.ultrasonic.domain
* Represents a top level directory in which music or other media is stored.
*/
data class MusicFolder(
val id: String,
val name: String
val id: String,
val name: String
)

View File

@ -3,13 +3,13 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class Playlist @JvmOverloads constructor(
val id: String,
var name: String,
val owner: String = "",
val comment: String = "",
val songCount: String = "",
val created: String = "",
val public: Boolean? = null
val id: String,
var name: String,
val owner: String = "",
val comment: String = "",
val songCount: String = "",
val created: String = "",
val public: Boolean? = null
) : Serializable {
companion object {
private const val serialVersionUID = -4160515427075433798L

View File

@ -3,11 +3,11 @@ package org.moire.ultrasonic.domain
import java.io.Serializable
data class PodcastsChannel(
val id: String,
val title: String?,
val url: String?,
val description: String?,
val status: String?
val id: String,
val title: String?,
val url: String?,
val description: String?,
val status: String?
) : Serializable {
companion object {
private const val serialVersionUID = -4160515427075433798L

View File

@ -4,8 +4,8 @@ package org.moire.ultrasonic.domain
* The criteria for a music search.
*/
data class SearchCriteria(
val query: String,
val artistCount: Int,
val albumCount: Int,
val songCount: Int
val query: String,
val artistCount: Int,
val albumCount: Int,
val songCount: Int
)

View File

@ -6,7 +6,7 @@ import org.moire.ultrasonic.domain.MusicDirectory.Entry
* The result of a search. Contains matching artists, albums and songs.
*/
data class SearchResult(
val artists: List<Artist>,
val albums: List<Entry>,
val songs: List<Entry>
val artists: List<Artist>,
val albums: List<Entry>,
val songs: List<Entry>
)

View File

@ -4,15 +4,15 @@ import org.moire.ultrasonic.domain.MusicDirectory.Entry
import java.io.Serializable
data class Share(
var id: String? = null,
var url: String? = null,
var description: String? = null,
var username: String? = null,
var created: String? = null,
var lastVisited: String? = null,
var expires: String? = null,
var visitCount: Long? = null,
private val entries: MutableList<Entry> = mutableListOf()
var id: String? = null,
var url: String? = null,
var description: String? = null,
var username: String? = null,
var created: String? = null,
var lastVisited: String? = null,
var expires: String? = null,
var visitCount: Long? = null,
private val entries: MutableList<Entry> = mutableListOf()
) : Serializable {
val name: String?
get() = url?.let { urlPattern.matcher(url).replaceFirst("$1") }

View File

@ -6,7 +6,7 @@ import net.swiftzer.semver.SemVer
* Represents the version number of the Subsonic Android app.
*/
data class Version(
val version: SemVer
val version: SemVer
) : Comparable<Version> {
override fun compareTo(other: Version): Int {

View File

@ -57,8 +57,10 @@ fun parseDate(dateAsString: String): Calendar {
return result
}
fun <T : SubsonicResponse> checkErrorCallParsed(mockWebServerRule: MockWebServerRule,
apiRequest: () -> Response<T>): T {
fun <T : SubsonicResponse> checkErrorCallParsed(
mockWebServerRule: MockWebServerRule,
apiRequest: () -> Response<T>
): T {
mockWebServerRule.enqueueResponse("request_data_not_found_error_response.json")
val response = apiRequest()
@ -77,9 +79,11 @@ fun SubsonicResponse.assertBaseResponseOk() {
error `should be` null
}
fun MockWebServerRule.assertRequestParam(responseResourceName: String = "ping_ok.json",
expectedParam: String,
apiRequest: () -> Response<out Any>) {
fun MockWebServerRule.assertRequestParam(
responseResourceName: String = "ping_ok.json",
expectedParam: String,
apiRequest: () -> Response<out Any>
) {
this.enqueueResponse(responseResourceName)
apiRequest()

View File

@ -37,9 +37,11 @@ class SubsonicApiSSLTest {
mockWebServer.shutdown()
}
private fun createSSLContext(certificatePemStream: InputStream,
certificatePkcs12Stream: InputStream,
password: String): SSLContext {
private fun createSSLContext(
certificatePemStream: InputStream,
certificatePkcs12Stream: InputStream,
password: String
): SSLContext {
var cert: X509Certificate? = null
val trustStore = KeyStore.getInstance(KeyStore.getDefaultType())
trustStore.load(null)

View File

@ -7,5 +7,5 @@ import java.io.IOException
* by current server api version.
*/
class ApiNotSupportedException(
serverApiVersion: SubsonicAPIVersions)
: IOException("Server api $serverApiVersion does not support this call")
serverApiVersion: SubsonicAPIVersions
) : IOException("Server api $serverApiVersion does not support this call")

View File

@ -43,8 +43,9 @@ import retrofit2.Call
* for this call.
*/
internal class ApiVersionCheckWrapper(
val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions) : SubsonicAPIDefinition by api {
val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions
) : SubsonicAPIDefinition by api {
override fun getArtists(musicFolderId: String?): Call<GetArtistsResponse> {
checkVersion(V1_8_0)
return api.getArtists(musicFolderId)
@ -70,26 +71,30 @@ internal class ApiVersionCheckWrapper(
return api.getAlbum(id)
}
override fun search2(query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?): Call<SearchTwoResponse> {
override fun search2(
query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?
): Call<SearchTwoResponse> {
checkVersion(V1_4_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search2(query, artistCount, artistOffset, albumCount, albumOffset, songCount,
musicFolderId)
}
override fun search3(query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?): Call<SearchThreeResponse> {
override fun search3(
query: String,
artistCount: Int?,
artistOffset: Int?,
albumCount: Int?,
albumOffset: Int?,
songCount: Int?,
musicFolderId: String?
): Call<SearchThreeResponse> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.search3(query, artistCount, artistOffset, albumCount, albumOffset,
@ -101,9 +106,11 @@ internal class ApiVersionCheckWrapper(
return api.getPlaylists(username)
}
override fun createPlaylist(id: String?,
name: String?,
songIds: List<String>?): Call<SubsonicResponse> {
override fun createPlaylist(
id: String?,
name: String?,
songIds: List<String>?
): Call<SubsonicResponse> {
checkVersion(V1_2_0)
return api.createPlaylist(id, name, songIds)
}
@ -113,12 +120,14 @@ internal class ApiVersionCheckWrapper(
return api.deletePlaylist(id)
}
override fun updatePlaylist(id: String,
name: String?,
comment: String?,
public: Boolean?,
songIdsToAdd: List<String>?,
songIndexesToRemove: List<Int>?): Call<SubsonicResponse> {
override fun updatePlaylist(
id: String,
name: String?,
comment: String?,
public: Boolean?,
songIdsToAdd: List<String>?,
songIndexesToRemove: List<Int>?
): Call<SubsonicResponse> {
checkVersion(V1_8_0)
return api.updatePlaylist(id, name, comment, public, songIdsToAdd, songIndexesToRemove)
}
@ -141,35 +150,41 @@ internal class ApiVersionCheckWrapper(
return api.scrobble(id, time, submission)
}
override fun getAlbumList(type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?): Call<GetAlbumListResponse> {
override fun getAlbumList(
type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?
): Call<GetAlbumListResponse> {
checkVersion(V1_2_0)
checkParamVersion(musicFolderId, V1_11_0)
return api.getAlbumList(type, size, offset, fromYear, toYear, genre, musicFolderId)
}
override fun getAlbumList2(type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?): Call<GetAlbumList2Response> {
override fun getAlbumList2(
type: AlbumListType,
size: Int?,
offset: Int?,
fromYear: Int?,
toYear: Int?,
genre: String?,
musicFolderId: String?
): Call<GetAlbumList2Response> {
checkVersion(V1_8_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getAlbumList2(type, size, offset, fromYear, toYear, genre, musicFolderId)
}
override fun getRandomSongs(size: Int?,
genre: String?,
fromYear: Int?,
toYear: Int?,
musicFolderId: String?): Call<GetRandomSongsResponse> {
override fun getRandomSongs(
size: Int?,
genre: String?,
fromYear: Int?,
toYear: Int?,
musicFolderId: String?
): Call<GetRandomSongsResponse> {
checkVersion(V1_2_0)
return api.getRandomSongs(size, genre, fromYear, toYear, musicFolderId)
}
@ -186,14 +201,16 @@ internal class ApiVersionCheckWrapper(
return api.getStarred2(musicFolderId)
}
override fun stream(id: String,
maxBitRate: Int?,
format: String?,
timeOffset: Int?,
videoSize: String?,
estimateContentLength: Boolean?,
converted: Boolean?,
offset: Long?): Call<ResponseBody> {
override fun stream(
id: String,
maxBitRate: Int?,
format: String?,
timeOffset: Int?,
videoSize: String?,
estimateContentLength: Boolean?,
converted: Boolean?,
offset: Long?
): Call<ResponseBody> {
checkParamVersion(maxBitRate, V1_2_0)
checkParamVersion(format, V1_6_0)
checkParamVersion(videoSize, V1_6_0)
@ -203,11 +220,13 @@ internal class ApiVersionCheckWrapper(
estimateContentLength, converted)
}
override fun jukeboxControl(action: JukeboxAction,
index: Int?,
offset: Int?,
ids: List<String>?,
gain: Float?): Call<JukeboxResponse> {
override fun jukeboxControl(
action: JukeboxAction,
index: Int?,
offset: Int?,
ids: List<String>?,
gain: Float?
): Call<JukeboxResponse> {
checkVersion(V1_2_0)
checkParamVersion(offset, V1_7_0)
return api.jukeboxControl(action, index, offset, ids, gain)
@ -218,9 +237,11 @@ internal class ApiVersionCheckWrapper(
return api.getShares()
}
override fun createShare(idsToShare: List<String>,
description: String?,
expires: Long?): Call<SharesResponse> {
override fun createShare(
idsToShare: List<String>,
description: String?,
expires: Long?
): Call<SharesResponse> {
checkVersion(V1_6_0)
return api.createShare(idsToShare, description, expires)
}
@ -230,9 +251,11 @@ internal class ApiVersionCheckWrapper(
return api.deleteShare(id)
}
override fun updateShare(id: String,
description: String?,
expires: Long?): Call<SubsonicResponse> {
override fun updateShare(
id: String,
description: String?,
expires: Long?
): Call<SubsonicResponse> {
checkVersion(V1_6_0)
return api.updateShare(id, description, expires)
}
@ -242,10 +265,12 @@ internal class ApiVersionCheckWrapper(
return api.getGenres()
}
override fun getSongsByGenre(genre: String,
count: Int,
offset: Int,
musicFolderId: String?): Call<GetSongsByGenreResponse> {
override fun getSongsByGenre(
genre: String,
count: Int,
offset: Int,
musicFolderId: String?
): Call<GetSongsByGenreResponse> {
checkVersion(V1_9_0)
checkParamVersion(musicFolderId, V1_12_0)
return api.getSongsByGenre(genre, count, offset, musicFolderId)
@ -271,9 +296,11 @@ internal class ApiVersionCheckWrapper(
return api.getBookmarks()
}
override fun createBookmark(id: String,
position: Long,
comment: String?): Call<SubsonicResponse> {
override fun createBookmark(
id: String,
position: Long,
comment: String?
): Call<SubsonicResponse> {
checkVersion(V1_9_0)
return api.createBookmark(id, position, comment)
}

View File

@ -35,14 +35,16 @@ private const val READ_TIMEOUT = 60_000L
*
* @author Yahor Berdnikau
*/
class SubsonicAPIClient(baseUrl: String,
username: String,
password: String,
minimalProtocolVersion: SubsonicAPIVersions,
clientID: String,
allowSelfSignedCertificate: Boolean = false,
enableLdapUserSupport: Boolean = false,
debug: Boolean = false) {
class SubsonicAPIClient(
baseUrl: String,
username: String,
password: String,
minimalProtocolVersion: SubsonicAPIVersions,
clientID: String,
allowSelfSignedCertificate: Boolean = false,
enableLdapUserSupport: Boolean = false,
debug: Boolean = false
) {
private val versionInterceptor = VersionInterceptor(minimalProtocolVersion) {
protocolVersion = it
}

View File

@ -54,8 +54,10 @@ interface SubsonicAPIDefinition {
fun getMusicFolders(): Call<MusicFoldersResponse>
@GET("getIndexes.view")
fun getIndexes(@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?): Call<GetIndexesResponse>
fun getIndexes(
@Query("musicFolderId") musicFolderId: String?,
@Query("ifModifiedSince") ifModifiedSince: Long?
): Call<GetIndexesResponse>
@GET("getMusicDirectory.view")
fun getMusicDirectory(@Query("id") id: String): Call<GetMusicDirectoryResponse>
@ -64,14 +66,18 @@ interface SubsonicAPIDefinition {
fun getArtists(@Query("musicFolderId") musicFolderId: String?): Call<GetArtistsResponse>
@GET("star.view")
fun star(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
fun star(
@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null
): Call<SubsonicResponse>
@GET("unstar.view")
fun unstar(@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null): Call<SubsonicResponse>
fun unstar(
@Query("id") id: String? = null,
@Query("albumId") albumId: String? = null,
@Query("artistId") artistId: String? = null
): Call<SubsonicResponse>
@GET("getArtist.view")
fun getArtist(@Query("id") id: String): Call<GetArtistResponse>
@ -80,31 +86,37 @@ interface SubsonicAPIDefinition {
fun getAlbum(@Query("id") id: String): Call<GetAlbumResponse>
@GET("search.view")
fun search(@Query("artist") artist: String? = null,
@Query("album") album: String? = null,
@Query("title") title: String? = null,
@Query("any") any: String? = null,
@Query("count") count: Int? = null,
@Query("offset") offset: Int? = null,
@Query("newerThan") newerThan: Long? = null): Call<SearchResponse>
fun search(
@Query("artist") artist: String? = null,
@Query("album") album: String? = null,
@Query("title") title: String? = null,
@Query("any") any: String? = null,
@Query("count") count: Int? = null,
@Query("offset") offset: Int? = null,
@Query("newerThan") newerThan: Long? = null
): Call<SearchResponse>
@GET("search2.view")
fun search2(@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchTwoResponse>
fun search2(
@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null
): Call<SearchTwoResponse>
@GET("search3.view")
fun search3(@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<SearchThreeResponse>
fun search3(
@Query("query") query: String,
@Query("artistCount") artistCount: Int? = null,
@Query("artistOffset") artistOffset: Int? = null,
@Query("albumCount") albumCount: Int? = null,
@Query("albumOffset") albumOffset: Int? = null,
@Query("songCount") songCount: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null
): Call<SearchThreeResponse>
@GET("getPlaylist.view")
fun getPlaylist(@Query("id") id: String): Call<GetPlaylistResponse>
@ -113,119 +125,143 @@ interface SubsonicAPIDefinition {
fun getPlaylists(@Query("username") username: String? = null): Call<GetPlaylistsResponse>
@GET("createPlaylist.view")
fun createPlaylist(@Query("playlistId") id: String? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<String>? = null): Call<SubsonicResponse>
fun createPlaylist(
@Query("playlistId") id: String? = null,
@Query("name") name: String? = null,
@Query("songId") songIds: List<String>? = null
): Call<SubsonicResponse>
@GET("deletePlaylist.view")
fun deletePlaylist(@Query("id") id: String): Call<SubsonicResponse>
@GET("updatePlaylist.view")
fun updatePlaylist(
@Query("playlistId") id: String,
@Query("name") name: String? = null,
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null):
@Query("playlistId") id: String,
@Query("name") name: String? = null,
@Query("comment") comment: String? = null,
@Query("public") public: Boolean? = null,
@Query("songIdToAdd") songIdsToAdd: List<String>? = null,
@Query("songIndexToRemove") songIndexesToRemove: List<Int>? = null
):
Call<SubsonicResponse>
@GET("getPodcasts.view")
fun getPodcasts(@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: String? = null): Call<GetPodcastsResponse>
fun getPodcasts(
@Query("includeEpisodes") includeEpisodes: Boolean? = null,
@Query("id") id: String? = null
): Call<GetPodcastsResponse>
@GET("getLyrics.view")
fun getLyrics(@Query("artist") artist: String? = null,
@Query("title") title: String? = null): Call<GetLyricsResponse>
fun getLyrics(
@Query("artist") artist: String? = null,
@Query("title") title: String? = null
): Call<GetLyricsResponse>
@GET("scrobble.view")
fun scrobble(@Query("id") id: String,
@Query("time") time: Long? = null,
@Query("submission") submission: Boolean? = null): Call<SubsonicResponse>
fun scrobble(
@Query("id") id: String,
@Query("time") time: Long? = null,
@Query("submission") submission: Boolean? = null
): Call<SubsonicResponse>
@GET("getAlbumList.view")
fun getAlbumList(
@Query("type") type: AlbumListType,
@Query("size") size: Int? = null,
@Query("offset") offset: Int? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumListResponse>
@Query("type") type: AlbumListType,
@Query("size") size: Int? = null,
@Query("offset") offset: Int? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetAlbumListResponse>
@GET("getAlbumList2.view")
fun getAlbumList2(
@Query("type") type: AlbumListType,
@Query("size") size: Int? = null,
@Query("offset") offset: Int? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetAlbumList2Response>
@Query("type") type: AlbumListType,
@Query("size") size: Int? = null,
@Query("offset") offset: Int? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("genre") genre: String? = null,
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetAlbumList2Response>
@GET("getRandomSongs.view")
fun getRandomSongs(
@Query("size") size: Int? = null,
@Query("genre") genre: String? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetRandomSongsResponse>
@Query("size") size: Int? = null,
@Query("genre") genre: String? = null,
@Query("fromYear") fromYear: Int? = null,
@Query("toYear") toYear: Int? = null,
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetRandomSongsResponse>
@GET("getStarred.view")
fun getStarred(@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredResponse>
@GET("getStarred2.view")
fun getStarred2(
@Query("musicFolderId") musicFolderId: String? = null): Call<GetStarredTwoResponse>
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetStarredTwoResponse>
@Streaming
@GET("getCoverArt.view")
fun getCoverArt(@Query("id") id: String,
@Query("size") size: Long? = null): Call<ResponseBody>
fun getCoverArt(
@Query("id") id: String,
@Query("size") size: Long? = null
): Call<ResponseBody>
@Streaming
@GET("stream.view")
fun stream(@Query("id") id: String,
@Query("maxBitRate") maxBitRate: Int? = null,
@Query("format") format: String? = null,
@Query("timeOffset") timeOffset: Int? = null,
@Query("size") videoSize: String? = null,
@Query("estimateContentLength") estimateContentLength: Boolean? = null,
@Query("converted") converted: Boolean? = null,
@Header("Range") offset: Long? = null): Call<ResponseBody>
fun stream(
@Query("id") id: String,
@Query("maxBitRate") maxBitRate: Int? = null,
@Query("format") format: String? = null,
@Query("timeOffset") timeOffset: Int? = null,
@Query("size") videoSize: String? = null,
@Query("estimateContentLength") estimateContentLength: Boolean? = null,
@Query("converted") converted: Boolean? = null,
@Header("Range") offset: Long? = null
): Call<ResponseBody>
@GET("jukeboxControl.view")
fun jukeboxControl(@Query("action") action: JukeboxAction,
@Query("index") index: Int? = null,
@Query("offset") offset: Int? = null,
@Query("id") ids: List<String>? = null,
@Query("gain") gain: Float? = null): Call<JukeboxResponse>
fun jukeboxControl(
@Query("action") action: JukeboxAction,
@Query("index") index: Int? = null,
@Query("offset") offset: Int? = null,
@Query("id") ids: List<String>? = null,
@Query("gain") gain: Float? = null
): Call<JukeboxResponse>
@GET("getShares.view")
fun getShares(): Call<SharesResponse>
@GET("createShare.view")
fun createShare(@Query("id") idsToShare: List<String>,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SharesResponse>
fun createShare(
@Query("id") idsToShare: List<String>,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null
): Call<SharesResponse>
@GET("deleteShare.view")
fun deleteShare(@Query("id") id: String): Call<SubsonicResponse>
@GET("updateShare.view")
fun updateShare(@Query("id") id: String,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null): Call<SubsonicResponse>
fun updateShare(
@Query("id") id: String,
@Query("description") description: String? = null,
@Query("expires") expires: Long? = null
): Call<SubsonicResponse>
@GET("getGenres.view")
fun getGenres(): Call<GenresResponse>
@GET("getSongsByGenre.view")
fun getSongsByGenre(
@Query("genre") genre: String,
@Query("count") count: Int = 10,
@Query("offset") offset: Int = 0,
@Query("musicFolderId") musicFolderId: String? = null): Call<GetSongsByGenreResponse>
@Query("genre") genre: String,
@Query("count") count: Int = 10,
@Query("offset") offset: Int = 0,
@Query("musicFolderId") musicFolderId: String? = null
): Call<GetSongsByGenreResponse>
@GET("getUser.view")
fun getUser(@Query("username") username: String): Call<GetUserResponse>
@ -241,9 +277,10 @@ interface SubsonicAPIDefinition {
@GET("createBookmark.view")
fun createBookmark(
@Query("id") id: String,
@Query("position") position: Long,
@Query("comment") comment: String? = null): Call<SubsonicResponse>
@Query("id") id: String,
@Query("position") position: Long,
@Query("comment") comment: String? = null
): Call<SubsonicResponse>
@GET("deleteBookmark.view")
fun deleteBookmark(@Query("id") id: String): Call<SubsonicResponse>

View File

@ -56,8 +56,10 @@ enum class SubsonicAPIVersions(val subsonicVersions: String, val restApiVersion:
}
class SubsonicAPIVersionsDeserializer : JsonDeserializer<SubsonicAPIVersions>() {
override fun deserialize(p: JsonParser,
ctxt: DeserializationContext?): SubsonicAPIVersions {
override fun deserialize(
p: JsonParser,
ctxt: DeserializationContext?
): SubsonicAPIVersions {
if (p.currentName != "version") {
throw JsonParseException(p, "Not valid token for API version!")
}

View File

@ -12,10 +12,10 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
* ldap users.
*/
internal class ProxyPasswordInterceptor(
initialAPIVersions: SubsonicAPIVersions,
private val hexInterceptor: PasswordHexInterceptor,
private val mD5Interceptor: PasswordMD5Interceptor,
private val forceHexPassword: Boolean = false
initialAPIVersions: SubsonicAPIVersions,
private val hexInterceptor: PasswordHexInterceptor,
private val mD5Interceptor: PasswordMD5Interceptor,
private val forceHexPassword: Boolean = false
) : Interceptor {
var apiVersion: SubsonicAPIVersions = initialAPIVersions

View File

@ -20,8 +20,9 @@ private const val DEFAULT_PEEK_BYTE_COUNT = 1000L
* @author Yahor Berdnikau
*/
internal class VersionInterceptor(
internal var protocolVersion: SubsonicAPIVersions,
private val notifier: (SubsonicAPIVersions) -> Unit = {}) : Interceptor {
internal var protocolVersion: SubsonicAPIVersions,
private val notifier: (SubsonicAPIVersions) -> Unit = {}
) : Interceptor {
private val jsonFactory = JsonFactory()
override fun intercept(chain: Chain): okhttp3.Response {

View File

@ -4,14 +4,15 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Album(
val id: String = "",
val name: String = "",
val coverArt: String = "",
val artist: String = "",
val artistId: String = "",
val songCount: Int = 0,
val duration: Int = 0,
val created: Calendar? = null,
val year: Int = 0,
val genre: String = "",
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList())
val id: String = "",
val name: String = "",
val coverArt: String = "",
val artist: String = "",
val artistId: String = "",
val songCount: Int = 0,
val duration: Int = 0,
val created: Calendar? = null,
val year: Int = 0,
val genre: String = "",
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,10 +3,12 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Artist(val id: String = "",
val name: String = "",
val coverArt: String = "",
val albumCount: Int = 0,
val starred: Calendar? = null,
@JsonProperty("album")
val albumsList: List<Album> = emptyList())
data class Artist(
val id: String = "",
val name: String = "",
val coverArt: String = "",
val albumCount: Int = 0,
val starred: Calendar? = null,
@JsonProperty("album")
val albumsList: List<Album> = emptyList()
)

View File

@ -3,9 +3,10 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class Bookmark(
val position: Long = 0,
val username: String = "",
val comment: String = "",
val created: Calendar? = null,
val changed: Calendar? = null,
val entry: MusicDirectoryChild = MusicDirectoryChild())
val position: Long = 0,
val username: String = "",
val comment: String = "",
val created: Calendar? = null,
val changed: Calendar? = null,
val entry: MusicDirectoryChild = MusicDirectoryChild()
)

View File

@ -1,6 +1,7 @@
package org.moire.ultrasonic.api.subsonic.models
data class ChatMessage(
val username: String = "",
val time: Long = 0,
val message: String = "")
val username: String = "",
val time: Long = 0,
val message: String = ""
)

View File

@ -2,6 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Genre(val songCount: Int = 0,
val albumCount: Int = 0,
@JsonProperty("value") val name: String)
data class Genre(
val songCount: Int = 0,
val albumCount: Int = 0,
@JsonProperty("value") val name: String
)

View File

@ -2,6 +2,8 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Index(val name: String = "",
@JsonProperty("artist")
val artists: List<Artist> = emptyList())
data class Index(
val name: String = "",
@JsonProperty("artist")
val artists: List<Artist> = emptyList()
)

View File

@ -2,9 +2,11 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Indexes(val lastModified: Long = 0,
val ignoredArticles: String = "",
@JsonProperty("index")
val indexList: List<Index> = emptyList(),
@JsonProperty("shortcut")
val shortcutList: List<Artist> = emptyList())
data class Indexes(
val lastModified: Long = 0,
val ignoredArticles: String = "",
@JsonProperty("index")
val indexList: List<Index> = emptyList(),
@JsonProperty("shortcut")
val shortcutList: List<Artist> = emptyList()
)

View File

@ -3,8 +3,9 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class JukeboxStatus(
val currentIndex: Int = -1,
val playing: Boolean = false,
val gain: Float = 0.0f,
val position: Int = 0,
@JsonProperty("entry") val playlistEntries: List<MusicDirectoryChild> = emptyList())
val currentIndex: Int = -1,
val playing: Boolean = false,
val gain: Float = 0.0f,
val position: Int = 0,
@JsonProperty("entry") val playlistEntries: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,7 +3,8 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class License(
val valid: Boolean = false,
val email: String = "",
val trialExpires: Calendar = Calendar.getInstance(),
val licenseExpires: Calendar = Calendar.getInstance())
val valid: Boolean = false,
val email: String = "",
val trialExpires: Calendar = Calendar.getInstance(),
val licenseExpires: Calendar = Calendar.getInstance()
)

View File

@ -3,6 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class Lyrics(
val artist: String = "",
val title: String = "",
@JsonProperty("value") val text: String = "")
val artist: String = "",
val title: String = "",
@JsonProperty("value") val text: String = ""
)

View File

@ -3,12 +3,14 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class MusicDirectory(val id: String = "",
val parent: String = "",
val name: String = "",
val userRating: Int = 0,
val averageRating: Float = 0.0f,
val starred: Calendar? = null,
val playCount: Int = 0,
@JsonProperty("child")
val childList: List<MusicDirectoryChild> = emptyList())
data class MusicDirectory(
val id: String = "",
val parent: String = "",
val name: String = "",
val userRating: Int = 0,
val averageRating: Float = 0.0f,
val starred: Calendar? = null,
val playCount: Int = 0,
@JsonProperty("child")
val childList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -2,36 +2,38 @@ package org.moire.ultrasonic.api.subsonic.models
import java.util.Calendar
data class MusicDirectoryChild(val id: String = "",
val parent: String = "",
val isDir: Boolean = false,
val title: String = "",
val album: String = "",
val artist: String = "",
val track: Int = -1,
val year: Int? = null,
val genre: String = "",
val coverArt: String = "",
val size: Long = -1,
val contentType: String = "",
val suffix: String = "",
val transcodedContentType: String = "",
val transcodedSuffix: String = "",
val duration: Int = -1,
val bitRate: Int = -1,
val path: String = "",
val isVideo: Boolean = false,
val playCount: Int = 0,
val discNumber: Int = -1,
val created: Calendar? = null,
val albumId: String = "",
val artistId: String = "",
val type: String = "",
val starred: Calendar? = null,
val streamId: String = "",
val channelId: String = "",
val description: String = "",
val status: String = "",
val publishDate: Calendar? = null,
val userRating: Int? = null,
val averageRating: Float? = null)
data class MusicDirectoryChild(
val id: String = "",
val parent: String = "",
val isDir: Boolean = false,
val title: String = "",
val album: String = "",
val artist: String = "",
val track: Int = -1,
val year: Int? = null,
val genre: String = "",
val coverArt: String = "",
val size: Long = -1,
val contentType: String = "",
val suffix: String = "",
val transcodedContentType: String = "",
val transcodedSuffix: String = "",
val duration: Int = -1,
val bitRate: Int = -1,
val path: String = "",
val isVideo: Boolean = false,
val playCount: Int = 0,
val discNumber: Int = -1,
val created: Calendar? = null,
val albumId: String = "",
val artistId: String = "",
val type: String = "",
val starred: Calendar? = null,
val streamId: String = "",
val channelId: String = "",
val description: String = "",
val status: String = "",
val publishDate: Calendar? = null,
val userRating: Int? = null,
val averageRating: Float? = null
)

View File

@ -4,15 +4,15 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Playlist(
val id: String = "",
val name: String = "",
val owner: String = "",
val comment: String = "",
val public: Boolean = false,
val songCount: Int = 0,
val duration: Long = 0,
val created: Calendar? = null,
val changed: Calendar? = null,
val coverArt: String = "",
@JsonProperty("entry") val entriesList: List<MusicDirectoryChild> = emptyList()
val id: String = "",
val name: String = "",
val owner: String = "",
val comment: String = "",
val public: Boolean = false,
val songCount: Int = 0,
val duration: Long = 0,
val created: Calendar? = null,
val changed: Calendar? = null,
val coverArt: String = "",
@JsonProperty("entry") val entriesList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,12 +3,13 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class PodcastChannel(
val id: String = "",
val url: String = "",
val title: String = "",
val description: String = "",
val coverArt: String = "",
val originalImageUrl: String = "",
val status: String = "",
val errorMessage: String = "",
@JsonProperty("episode") val episodeList: List<MusicDirectoryChild> = emptyList())
val id: String = "",
val url: String = "",
val title: String = "",
val description: String = "",
val coverArt: String = "",
val originalImageUrl: String = "",
val status: String = "",
val errorMessage: String = "",
@JsonProperty("episode") val episodeList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,6 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class SearchResult(
val offset: Int = 0,
val totalHits: Int = 0,
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList())
val offset: Int = 0,
val totalHits: Int = 0,
@JsonProperty("match") val matchList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class SearchThreeResult(
@JsonProperty("artist") val artistList: List<Artist> = emptyList(),
@JsonProperty("album") val albumList: List<Album> = emptyList(),
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
@JsonProperty("artist") val artistList: List<Artist> = emptyList(),
@JsonProperty("album") val albumList: List<Album> = emptyList(),
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,7 +3,7 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class SearchTwoResult(
@JsonProperty("artist") val artistList: List<Artist> = emptyList(),
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList(),
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
@JsonProperty("artist") val artistList: List<Artist> = emptyList(),
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList(),
@JsonProperty("song") val songList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -4,12 +4,13 @@ import com.fasterxml.jackson.annotation.JsonProperty
import java.util.Calendar
data class Share(
val id: String = "",
val url: String = "",
val username: String = "",
val created: Calendar? = null,
val expires: Calendar? = null,
val visitCount: Int = 0,
val description: String = "",
val lastVisited: Calendar? = null,
@JsonProperty("entry") val items: List<MusicDirectoryChild> = emptyList())
val id: String = "",
val url: String = "",
val username: String = "",
val created: Calendar? = null,
val expires: Calendar? = null,
val visitCount: Int = 0,
val description: String = "",
val lastVisited: Calendar? = null,
@JsonProperty("entry") val items: List<MusicDirectoryChild> = emptyList()
)

View File

@ -3,19 +3,20 @@ package org.moire.ultrasonic.api.subsonic.models
import com.fasterxml.jackson.annotation.JsonProperty
data class User(
val username: String = "",
val email: String = "",
val scrobblingEnabled: Boolean = false,
val adminRole: Boolean = false,
val settingsRole: Boolean = false,
val downloadRole: Boolean = false,
val uploadRole: Boolean = false,
val playlistRole: Boolean = false,
val coverArtRole: Boolean = false,
val commentRole: Boolean = false,
val podcastRole: Boolean = false,
val streamRole: Boolean = false,
val jukeboxRole: Boolean = false,
val shareRole: Boolean = false,
val videoConverstionRole: Boolean = false,
@JsonProperty("folder") val folderList: List<Int> = emptyList())
val username: String = "",
val email: String = "",
val scrobblingEnabled: Boolean = false,
val adminRole: Boolean = false,
val settingsRole: Boolean = false,
val downloadRole: Boolean = false,
val uploadRole: Boolean = false,
val playlistRole: Boolean = false,
val coverArtRole: Boolean = false,
val commentRole: Boolean = false,
val podcastRole: Boolean = false,
val streamRole: Boolean = false,
val jukeboxRole: Boolean = false,
val shareRole: Boolean = false,
val videoConverstionRole: Boolean = false,
@JsonProperty("folder") val folderList: List<Int> = emptyList()
)

View File

@ -6,13 +6,15 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Bookmark
class BookmarksResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("bookmarks") private val bookmarksWrapper = BookmarkWrapper()
val bookmarkList: List<Bookmark> get() = bookmarksWrapper.bookmarkList
}
internal class BookmarkWrapper(
@JsonProperty("bookmark") val bookmarkList: List<Bookmark> = emptyList())
@JsonProperty("bookmark") val bookmarkList: List<Bookmark> = emptyList()
)

View File

@ -6,13 +6,15 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.ChatMessage
class ChatMessagesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("chatMessages") private val wrapper = ChatMessagesWrapper()
val chatMessages: List<ChatMessage> get() = wrapper.messagesList
}
internal class ChatMessagesWrapper(
@JsonProperty("chatMessage") val messagesList: List<ChatMessage> = emptyList())
@JsonProperty("chatMessage") val messagesList: List<ChatMessage> = emptyList()
)

View File

@ -5,9 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Genre
class GenresResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
class GenresResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("genres") private val genresWrapper = GenresWrapper()
val genresList: List<Genre> get() = genresWrapper.genresList
}

View File

@ -6,10 +6,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Album
@Suppress("NamingConventionViolation")
class GetAlbumList2Response(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
class GetAlbumList2Response(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("albumList2") private val albumWrapper2 = AlbumWrapper2()
val albumList: List<Album>
@ -18,4 +19,5 @@ class GetAlbumList2Response(status: Status,
@Suppress("NamingConventionViolation")
private class AlbumWrapper2(
@JsonProperty("album") val albumList: List<Album> = emptyList())
@JsonProperty("album") val albumList: List<Album> = emptyList()
)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetAlbumListResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
class GetAlbumListResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("albumList") private val albumWrapper = AlbumWrapper()
val albumList: List<MusicDirectoryChild>
@ -16,4 +17,5 @@ class GetAlbumListResponse(status: Status,
}
private class AlbumWrapper(
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("album") val albumList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -4,7 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Album
class GetAlbumResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val album: Album = Album()) : SubsonicResponse(status, version, error)
class GetAlbumResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val album: Album = Album()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Artist
class GetArtistResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val artist: Artist = Artist())
: SubsonicResponse(status, version, error)
class GetArtistResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val artist: Artist = Artist()
) : SubsonicResponse(status, version, error)

View File

@ -5,8 +5,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Indexes
class GetArtistsResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("artists") val indexes: Indexes = Indexes()) :
SubsonicResponse(status, version, error)
class GetArtistsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("artists") val indexes: Indexes = Indexes()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Indexes
class GetIndexesResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val indexes: Indexes = Indexes()) :
SubsonicResponse(status, version, error)
class GetIndexesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val indexes: Indexes = Indexes()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Lyrics
class GetLyricsResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val lyrics: Lyrics = Lyrics())
: SubsonicResponse(status, version, error)
class GetLyricsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val lyrics: Lyrics = Lyrics()
) : SubsonicResponse(status, version, error)

View File

@ -5,9 +5,10 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectory
class GetMusicDirectoryResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("directory")
val musicDirectory: MusicDirectory = MusicDirectory()) :
SubsonicResponse(status, version, error)
class GetMusicDirectoryResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("directory")
val musicDirectory: MusicDirectory = MusicDirectory()
) : SubsonicResponse(status, version, error)

View File

@ -5,7 +5,8 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Playlist
class GetPlaylistResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val playlist: Playlist = Playlist()) : SubsonicResponse(status, version, error)
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val playlist: Playlist = Playlist()
) : SubsonicResponse(status, version, error)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Playlist
class GetPlaylistsResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
class GetPlaylistsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("playlists")
private val playlistsWrapper: PlaylistsWrapper = PlaylistsWrapper()
@ -17,4 +18,5 @@ class GetPlaylistsResponse(status: Status,
}
private class PlaylistsWrapper(
@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList())
@JsonProperty("playlist") val playlistList: List<Playlist> = emptyList()
)

View File

@ -6,9 +6,10 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
class GetPodcastsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("podcasts") private val channelsWrapper = PodcastChannelWrapper()
val podcastChannels: List<PodcastChannel>
@ -16,4 +17,5 @@ class GetPodcastsResponse(
}
private class PodcastChannelWrapper(
@JsonProperty("channel") val channelsList: List<PodcastChannel> = emptyList())
@JsonProperty("channel") val channelsList: List<PodcastChannel> = emptyList()
)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetRandomSongsResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
class GetRandomSongsResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("randomSongs") private val songsWrapper = RandomSongsWrapper()
val songsList
@ -16,4 +17,5 @@ class GetRandomSongsResponse(status: Status,
}
private class RandomSongsWrapper(
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -6,13 +6,15 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class GetSongsByGenreResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("songsByGenre") private val songsByGenreList = SongsByGenreWrapper()
val songsList get() = songsByGenreList.songsList
}
internal class SongsByGenreWrapper(
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("song") val songsList: List<MusicDirectoryChild> = emptyList()
)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class GetStarredResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
class GetStarredResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class GetStarredTwoResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred2: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
class GetStarredTwoResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val starred2: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -5,7 +5,8 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.User
class GetUserResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val user: User = User()) : SubsonicResponse(status, version, error)
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val user: User = User()
) : SubsonicResponse(status, version, error)

View File

@ -5,11 +5,12 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus
class JukeboxResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
var jukebox: JukeboxStatus = JukeboxStatus())
: SubsonicResponse(status, version, error) {
class JukeboxResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
var jukebox: JukeboxStatus = JukeboxStatus()
) : SubsonicResponse(status, version, error) {
@JsonSetter("jukeboxStatus") fun setJukeboxStatus(jukebox: JukeboxStatus) {
this.jukebox = jukebox
}

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.License
class LicenseResponse(val license: License = License(),
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) :
SubsonicResponse(status, version, error)
class LicenseResponse(
val license: License = License(),
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error)

View File

@ -5,14 +5,16 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicFolder
class MusicFoldersResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) :
SubsonicResponse(status, version, error) {
class MusicFoldersResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("musicFolders") private val wrapper = MusicFoldersWrapper()
val musicFolders get() = wrapper.musicFolders
}
internal class MusicFoldersWrapper(
@JsonProperty("musicFolder") val musicFolders: List<MusicFolder> = emptyList())
@JsonProperty("musicFolder") val musicFolders: List<MusicFolder> = emptyList()
)

View File

@ -4,8 +4,9 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchResult
class SearchResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val searchResult: SearchResult = SearchResult())
: SubsonicResponse(status, version, error)
class SearchResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
val searchResult: SearchResult = SearchResult()
) : SubsonicResponse(status, version, error)

View File

@ -6,8 +6,8 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchThreeResult
class SearchThreeResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult3") val searchResult: SearchThreeResult = SearchThreeResult())
: SubsonicResponse(status, version, error)
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult3") val searchResult: SearchThreeResult = SearchThreeResult()
) : SubsonicResponse(status, version, error)

View File

@ -6,8 +6,8 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
class SearchTwoResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult())
: SubsonicResponse(status, version, error)
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?,
@JsonProperty("searchResult2") val searchResult: SearchTwoResult = SearchTwoResult()
) : SubsonicResponse(status, version, error)

View File

@ -5,10 +5,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.Share
class SharesResponse(status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?)
: SubsonicResponse(status, version, error) {
class SharesResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("shares") private val wrappedShares = SharesWrapper()
val shares get() = wrappedShares.share

View File

@ -9,9 +9,11 @@ import java.io.InputStream
*
* [responseHttpCode] will be there always.
*/
class StreamResponse(val stream: InputStream? = null,
val apiError: SubsonicError? = null,
val responseHttpCode: Int) {
class StreamResponse(
val stream: InputStream? = null,
val apiError: SubsonicError? = null,
val responseHttpCode: Int
) {
/**
* Check if this response has error.
*/

View File

@ -13,9 +13,11 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
* Base Subsonic API response.
*/
@JsonRootName(value = "subsonic-response")
open class SubsonicResponse(val status: Status,
val version: SubsonicAPIVersions,
val error: SubsonicError?) {
open class SubsonicResponse(
val status: Status,
val version: SubsonicAPIVersions,
val error: SubsonicError?
) {
@JsonDeserialize(using = Status.Companion.StatusJsonDeserializer::class)
enum class Status(val jsonValue: String) {
OK("ok"), ERROR("failed");

View File

@ -6,13 +6,15 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
class VideosResponse(
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?) : SubsonicResponse(status, version, error) {
status: Status,
version: SubsonicAPIVersions,
error: SubsonicError?
) : SubsonicResponse(status, version, error) {
@JsonProperty("videos") private val videosWrapper = VideosWrapper()
val videosList: List<MusicDirectoryChild> get() = videosWrapper.videosList
}
internal class VideosWrapper(
@JsonProperty("video") val videosList: List<MusicDirectoryChild> = emptyList())
@JsonProperty("video") val videosList: List<MusicDirectoryChild> = emptyList()
)