-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
5,852 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
target/ | ||
Cargo.lock | ||
|
||
platforms/android/jmbackend | ||
platforms/android/jmcomic-rs | ||
platforms/test/ | ||
|
||
/.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "jmbackend" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
jmcomic = { path = "../jmcomic-rs" } | ||
lazy_static = "1.4.0" | ||
sea-orm = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"], default-features = false } | ||
sea-orm-migration = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls"], default-features = false } | ||
chrono = "0.4.31" | ||
libc = "0.2.149" | ||
bytes = "1.5.0" | ||
tokio = { version = "1.33.0", features = ["full"] } | ||
reqwest = { version = "0.11.22", features = ["socks", "stream", "rustls", "tokio-rustls", "rustls-tls"], default-features = false } | ||
hex = "0.4.3" | ||
md5 = "0.7.0" | ||
image = { version = "0.24.7", features = ["png", "jpeg", "bmp", "gif", "webp"] } | ||
rand = "0.8.5" | ||
itertools = "0.11.0" | ||
async-trait = "0.1.74" | ||
anyhow = "1.0.75" | ||
rsa = "0.6.1" | ||
base64 = "0.13.0" | ||
once_cell = "1.18.0" | ||
regex = "1.10.2" | ||
num-iter = "0.1.43" | ||
futures-util = "0.3.29" | ||
grouping_by = "0.2.2" | ||
tokio-util = { version = "0.7.10", features = ["full"] } | ||
async_zip = { version = "0.0.9", features = ["deflate"], default-features = false } | ||
serde = { version = "1.0.190", features = ["derive"] } | ||
serde_derive = "1.0.190" | ||
serde_json = "1.0.108" | ||
|
||
[features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
jni = "0.21.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pub use jmbackend::*; | ||
use jni::objects::JClass; | ||
use jni::objects::JString; | ||
use jni::JNIEnv; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "system" fn Java_opensource_jenny_Jni_init<'local>( | ||
mut env: JNIEnv<'local>, | ||
_class: JClass<'local>, | ||
params: JString<'local>, | ||
) { | ||
let params: String = env.get_string(¶ms).unwrap().into(); | ||
init_sync(params.as_str()); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn Java_opensource_jenny_Jni_invoke<'local>( | ||
mut env: JNIEnv<'local>, | ||
_: JClass<'local>, | ||
params: JString<'local>, | ||
) -> JString<'local> { | ||
let params: String = env.get_string(¶ms).unwrap().into(); | ||
env.new_string(invoke(params.as_str())).unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use jmbackend::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use jmbackend::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
lazy_static = "1.4.0" | ||
reqwest = { version = "0.11.9", features = ["rustls", "tokio-rustls", "rustls-tls"], default-features = false } | ||
serde = { version = "1.0.152", features = ["derive"] } | ||
serde_derive = "1.0.152" | ||
serde_json = "1.0.93" | ||
warp = "0.3.2" | ||
tokio = { version = "1.26.0", features = ["full"] } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::process::exit; | ||
use std::time::Duration; | ||
|
||
use serde_json::to_string; | ||
use warp::Filter; | ||
|
||
pub use jmbackend::*; | ||
|
||
#[derive(Debug, serde::Deserialize, serde::Serialize)] | ||
pub struct DartQuery { | ||
pub method: String, | ||
pub params: String, | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn init_http_server() { | ||
let ping = warp::get() | ||
.and(warp::path("ping")) | ||
.map(|| "pong".to_owned()); | ||
let invoke = warp::post() | ||
.and(warp::path("invoke")) | ||
.and(warp::body::json()) | ||
.map(invoke); | ||
std::thread::spawn(move || { | ||
jmbackend::RUNTIME.block_on(warp::serve(ping.or(invoke)).run(([127, 0, 0, 1], 52764))) | ||
}); | ||
jmbackend::RUNTIME.block_on(test_startup()); | ||
} | ||
|
||
fn invoke(dq: DartQuery) -> String { | ||
jmbackend::RUNTIME.block_on(jmbackend::invoke_async(to_string(&dq).unwrap().as_str())) | ||
} | ||
|
||
async fn test_startup() { | ||
for i in 0..6 { | ||
if i == 5 { | ||
exit(2); | ||
} | ||
std::thread::sleep(Duration::new(1, 0)); | ||
match reqwest::get("http://127.0.0.1:52764/ping").await { | ||
Ok(req) => match req.text().await { | ||
Ok(txt) => { | ||
println!("OK : {}", txt); | ||
break; | ||
} | ||
Err(err) => println!("ERR : {}", err), | ||
}, | ||
Err(err) => { | ||
println!("ERR : {}", err) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use jmbackend::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jmbackend = { path = "../../" } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use jmbackend::*; |
Oops, something went wrong.