mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-02 22:26:52 +02:00
refactor(backend): retire unused native bridge entry points
This commit is contained in:
1 parent
b8e3a4c166
commit
fe88048db2
45 files changed
+20
-1832
No files matched your search
@@ -198,7 +198,6 @@ internal interface CoreBackend {
|
||||
fun checkHiResAuthenticity(path: String, optionsJson: String): String
|
||||
fun readAudioMetadata(path: String, hint: String, cacheKey: String): String
|
||||
fun setLibraryCoverCacheDirectory(path: String)
|
||||
fun scanLibraryFolder(folder: String): String
|
||||
fun scanLibraryFolderToNdjsonFile(folder: String, output: String): Long
|
||||
fun scanLibraryFolderIncremental(folder: String, existing: String): String
|
||||
fun scanLibraryFolderIncrementalFromSnapshot(folder: String, snapshot: String): String
|
||||
|
||||
@@ -93,11 +93,9 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
"editFileMetadata",
|
||||
"reEnrichFile",
|
||||
"setLibraryCoverCacheDir",
|
||||
"scanLibraryFolder",
|
||||
"scanLibraryFolderToNDJSONFile",
|
||||
"scanLibraryFolderIncremental",
|
||||
"scanLibraryFolderIncrementalFromSnapshot",
|
||||
"scanSafTree",
|
||||
"scanSafTreeToNDJSONFile",
|
||||
"scanSafTreeIncremental",
|
||||
"scanSafTreeIncrementalFromSnapshot",
|
||||
@@ -1904,14 +1902,6 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
}
|
||||
result.success(null)
|
||||
}
|
||||
"scanLibraryFolder" -> {
|
||||
val folderPath = call.argument<String>("folder_path") ?: ""
|
||||
val response = withContext(Dispatchers.IO) {
|
||||
safScanActive = false
|
||||
bridgeJsonResult(coreBackend.scanLibraryFolder(folderPath))
|
||||
}
|
||||
result.success(response)
|
||||
}
|
||||
"scanLibraryFolderToNDJSONFile" -> {
|
||||
val folderPath = call.argument<String>("folder_path") ?: ""
|
||||
val outputPath = call.argument<String>("output_path") ?: ""
|
||||
@@ -1955,13 +1945,6 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
}
|
||||
result.success(response)
|
||||
}
|
||||
"scanSafTree" -> {
|
||||
val treeUri = call.argument<String>("tree_uri") ?: ""
|
||||
val response = withContext(Dispatchers.IO) {
|
||||
scanSafTree(treeUri)
|
||||
}
|
||||
result.success(response)
|
||||
}
|
||||
"scanSafTreeToNDJSONFile" -> {
|
||||
val treeUri = call.argument<String>("tree_uri") ?: ""
|
||||
val outputPath = call.argument<String>("output_path") ?: ""
|
||||
|
||||
@@ -297,10 +297,6 @@ internal object RustCoreBackend : CoreBackend {
|
||||
libraryCoverDirectory = directory
|
||||
}
|
||||
|
||||
override fun scanLibraryFolder(folder: String): String = withLibraryDirectories(listOf(folder)) {
|
||||
it.scanLibraryFolder(File(folder).canonicalPath, null)
|
||||
}
|
||||
|
||||
override fun scanLibraryFolderToNdjsonFile(folder: String, output: String): Long =
|
||||
withLibraryDirectories(listOf(folder)) { current ->
|
||||
require(File(output).isAbsolute && File(output).extension.equals("ndjson", ignoreCase = true)) {
|
||||
@@ -622,7 +618,7 @@ internal object RustCoreBackend : CoreBackend {
|
||||
null
|
||||
}
|
||||
"setLoggingEnabled", "setAllowPrivateNetwork", "setDownloadFallbackExtensionIds",
|
||||
"setNetworkCompatibilityOptions", "setSongLinkNetworkOptions",
|
||||
"setNetworkCompatibilityOptions",
|
||||
"setLyricsProviders", "setLyricsFetchOptions" -> synchronized(this) {
|
||||
when (method) {
|
||||
"setLoggingEnabled" -> {
|
||||
@@ -637,7 +633,7 @@ internal object RustCoreBackend : CoreBackend {
|
||||
manager?.environment()?.use { it.setAllowPrivateNetwork(allowed) }
|
||||
allowPrivateNetwork = allowed
|
||||
}
|
||||
"setNetworkCompatibilityOptions", "setSongLinkNetworkOptions" -> {
|
||||
"setNetworkCompatibilityOptions" -> {
|
||||
val allowed = args["allow_http"] as? Boolean ?: false
|
||||
val insecureTls = args["insecure_tls"] as? Boolean ?: false
|
||||
manager?.environment()?.use { it.setNetworkCompatibilityOptions(allowed, insecureTls) }
|
||||
@@ -678,19 +674,10 @@ internal object RustCoreBackend : CoreBackend {
|
||||
"getRepoExtensions" -> return repositoryOwner().extensions(
|
||||
args["force_refresh"] as? Boolean ?: false,
|
||||
)
|
||||
"searchRepoExtensions" -> return repositoryOwner().search(
|
||||
string("query"),
|
||||
string("category"),
|
||||
)
|
||||
"getRepoCategories" -> return JSONArray(repositoryOwner().categories()).toString()
|
||||
"downloadRepoExtension" -> return repositoryOwner().download(
|
||||
string("extension_id"),
|
||||
string("dest_dir"),
|
||||
)
|
||||
"clearRepoCache" -> {
|
||||
repositoryOwner().clearCache()
|
||||
return null
|
||||
}
|
||||
}
|
||||
val current = owner()
|
||||
return when (method) {
|
||||
@@ -708,10 +695,6 @@ internal object RustCoreBackend : CoreBackend {
|
||||
current.setEnabled(string("extension_id"), args["enabled"] as? Boolean ?: false)
|
||||
null
|
||||
}
|
||||
"unloadExtension" -> {
|
||||
current.unload(string("extension_id"))
|
||||
null
|
||||
}
|
||||
"removeExtension" -> {
|
||||
current.remove(string("extension_id"))
|
||||
null
|
||||
@@ -730,8 +713,6 @@ internal object RustCoreBackend : CoreBackend {
|
||||
"getProviderPriority", "getMetadataProviderPriority" -> {
|
||||
JSONObject(current.providerPriorities()).optJSONArray(if (method == "getProviderPriority") "download" else "metadata")?.toString() ?: "[]"
|
||||
}
|
||||
"getLyricsProviders" -> current.getLyricsProvidersJson()
|
||||
"getLyricsFetchOptions" -> current.getLyricsFetchOptionsJson()
|
||||
"getAvailableLyricsProviders" -> current.getAvailableLyricsProvidersJson()
|
||||
"searchTracksWithMetadataProviders" -> current.searchMetadataProviders(
|
||||
string("query"),
|
||||
@@ -766,14 +747,6 @@ internal object RustCoreBackend : CoreBackend {
|
||||
string("spotify_id"),
|
||||
null,
|
||||
)
|
||||
"getSpotifyIDFromDeezerTrack" -> current.getSpotifyIdFromDeezerTrack(
|
||||
string("deezer_track_id"),
|
||||
null,
|
||||
)
|
||||
"getTidalURLFromDeezerTrack" -> current.getTidalUrlFromDeezerTrack(
|
||||
string("deezer_track_id"),
|
||||
null,
|
||||
)
|
||||
"getTrackPlatformLinks" -> current.getTrackPlatformLinksJson(
|
||||
string("spotify_id"),
|
||||
string("isrc"),
|
||||
@@ -810,36 +783,15 @@ internal object RustCoreBackend : CoreBackend {
|
||||
}
|
||||
"findURLHandler" -> current.findUrlHandler(string("url")) ?: ""
|
||||
"handleURLWithExtension" -> current.handleUrlJson(string("url"))
|
||||
"enrichTrackWithExtension" -> current.enrichTrackJson(string("extension_id"), string("track", "{}"))
|
||||
"getExtensionPendingAuth" -> current.getExtensionPendingAuthJson(string("extension_id")).ifEmpty { null }
|
||||
"setExtensionAuthCode" -> current.environment().use { it.setAuthCode(string("extension_id"), string("auth_code")); null }
|
||||
"completeExtensionSessionGrant" -> {
|
||||
completeSessionGrant(current, string("extension_id"), string("grant"))
|
||||
true
|
||||
}
|
||||
"setExtensionTokens" -> current.environment().use {
|
||||
it.setAuthTokens(string("extension_id"), string("access_token"), string("refresh_token"), (args["expires_in"] as? Int)?.toLong() ?: 0L)
|
||||
null
|
||||
}
|
||||
"clearExtensionPendingAuth" -> current.environment().use { it.clearPendingAuth(string("extension_id")); null }
|
||||
"isExtensionAuthenticated" -> current.environment().use { it.isAuthenticated(string("extension_id")) }
|
||||
"getAllPendingAuthRequests" -> current.environment().use { it.allPendingAuth() }
|
||||
"getAllDownloadProgress" -> current.environment().use { environment ->
|
||||
environment.downloadState().use { state -> state.allProgress() }
|
||||
}
|
||||
"cleanupConnections" -> current.environment().use { it.cleanupConnections(); null }
|
||||
"getPendingFFmpegCommand", "getAllPendingFFmpegCommands", "setFFmpegCommandResult" -> current.environment().use { environment ->
|
||||
environment.ffmpegCommands().use { commands ->
|
||||
when (method) {
|
||||
"getPendingFFmpegCommand" -> commands.getCommand(string("command_id"))
|
||||
"getAllPendingFFmpegCommands" -> commands.pending()
|
||||
else -> {
|
||||
commands.complete(string("command_id"), args["success"] as? Boolean ?: false, string("output"), string("error"))
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"clearItemProgress", "cancelDownload", "resetDownloadCancel" -> current.environment().use { environment ->
|
||||
environment.downloadState().use { state ->
|
||||
when (method) {
|
||||
|
||||
Reference in new issue
Block a user