|
|
@ -19,7 +19,7 @@ import java.io.File |
|
|
|
import java.net.URLDecoder |
|
|
|
import java.net.URLDecoder |
|
|
|
|
|
|
|
|
|
|
|
object RemoteBookWebDav : RemoteBookManager() { |
|
|
|
object RemoteBookWebDav : RemoteBookManager() { |
|
|
|
private val remoteBookUrl get() = "${AppWebDav.rootWebDavUrl}${remoteBookFolder}" |
|
|
|
val rootBookUrl get() = "${AppWebDav.rootWebDavUrl}${remoteBookFolder}" |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
runBlocking { |
|
|
|
runBlocking { |
|
|
@ -29,7 +29,7 @@ object RemoteBookWebDav : RemoteBookManager() { |
|
|
|
|
|
|
|
|
|
|
|
override suspend fun initRemoteContext() { |
|
|
|
override suspend fun initRemoteContext() { |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
WebDav(remoteBookUrl, it).makeAsDir() |
|
|
|
WebDav(rootBookUrl, it).makeAsDir() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -37,11 +37,11 @@ object RemoteBookWebDav : RemoteBookManager() { |
|
|
|
* 获取远程书籍列表 |
|
|
|
* 获取远程书籍列表 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Throws(Exception::class) |
|
|
|
@Throws(Exception::class) |
|
|
|
override suspend fun getRemoteBookList(): MutableList<RemoteBook> { |
|
|
|
override suspend fun getRemoteBookList(path: String): MutableList<RemoteBook> { |
|
|
|
val remoteBooks = mutableListOf<RemoteBook>() |
|
|
|
val remoteBooks = mutableListOf<RemoteBook>() |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
//读取文件列表 |
|
|
|
//读取文件列表 |
|
|
|
val remoteWebDavFileList: List<WebDavFile> = WebDav(remoteBookUrl, it).listFiles() |
|
|
|
val remoteWebDavFileList: List<WebDavFile> = WebDav(path, it).listFiles() |
|
|
|
//转化远程文件信息到本地对象 |
|
|
|
//转化远程文件信息到本地对象 |
|
|
|
remoteWebDavFileList.forEach { webDavFile -> |
|
|
|
remoteWebDavFileList.forEach { webDavFile -> |
|
|
|
var webDavFileName = webDavFile.displayName |
|
|
|
var webDavFileName = webDavFile.displayName |
|
|
@ -93,7 +93,7 @@ object RemoteBookWebDav : RemoteBookManager() { |
|
|
|
if (!NetworkUtils.isAvailable()) return false |
|
|
|
if (!NetworkUtils.isAvailable()) return false |
|
|
|
|
|
|
|
|
|
|
|
val localBookName = localBookUri.path?.substringAfterLast(File.separator) |
|
|
|
val localBookName = localBookUri.path?.substringAfterLast(File.separator) |
|
|
|
val putUrl = "${remoteBookUrl}${File.separator}${localBookName}" |
|
|
|
val putUrl = "${rootBookUrl}${File.separator}${localBookName}" |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
AppWebDav.authorization?.let { |
|
|
|
if (localBookUri.isContentScheme()) { |
|
|
|
if (localBookUri.isContentScheme()) { |
|
|
|
WebDav(putUrl, it).upload( |
|
|
|
WebDav(putUrl, it).upload( |
|
|
|