refactor cm -> ui_cm_interface for sciter and flutter

This commit is contained in:
csf
2022-09-05 19:41:09 +08:00
parent 09b769d92f
commit 7eeb0f7335
12 changed files with 878 additions and 1237 deletions

View File

@@ -105,43 +105,30 @@ class MainService : Service() {
@Keep
fun rustSetByName(name: String, arg1: String, arg2: String) {
when (name) {
"try_start_without_auth" -> {
try {
val jsonObject = JSONObject(arg1)
val id = jsonObject["id"] as Int
val username = jsonObject["name"] as String
val peerId = jsonObject["peer_id"] as String
val type = if (jsonObject["is_file_transfer"] as Boolean) {
translate("File Connection")
} else {
translate("Screen Connection")
}
loginRequestNotification(id, type, username, peerId)
} catch (e: JSONException) {
e.printStackTrace()
}
}
"on_client_authorized" -> {
Log.d(logTag, "from rust:on_client_authorized")
"add_connection" -> {
try {
val jsonObject = JSONObject(arg1)
val id = jsonObject["id"] as Int
val username = jsonObject["name"] as String
val peerId = jsonObject["peer_id"] as String
val authorized = jsonObject["authorized"] as Boolean
val isFileTransfer = jsonObject["is_file_transfer"] as Boolean
val type = if (isFileTransfer) {
translate("File Connection")
} else {
translate("Screen Connection")
}
if (!isFileTransfer && !isStart) {
startCapture()
if (authorized) {
if (!isFileTransfer && !isStart) {
startCapture()
}
onClientAuthorizedNotification(id, type, username, peerId)
} else {
loginRequestNotification(id, type, username, peerId)
}
onClientAuthorizedNotification(id, type, username, peerId)
} catch (e: JSONException) {
e.printStackTrace()
}
}
"stop_capture" -> {
Log.d(logTag, "from rust:stop_capture")