add jsonrpc feature flag

This commit is contained in:
Simon Laux
2022-06-13 19:01:06 +02:00
parent 63e7179191
commit b51814aaaa
4 changed files with 12 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ crate-type = ["cdylib", "staticlib"]
[dependencies]
deltachat = { path = "../", default-features = false }
deltachat-jsonrpc = { path = "../deltachat-jsonrpc" }
deltachat-jsonrpc = { path = "../deltachat-jsonrpc", optional = true }
libc = "0.2"
human-panic = "1"
num-traits = "0.2"
@@ -28,7 +28,8 @@ rand = "0.7"
once_cell = "1.12.0"
[features]
default = ["vendored"]
default = ["vendored", "jsonrpc"]
vendored = ["deltachat/vendored"]
nightly = ["deltachat/nightly"]
jsonrpc = ["deltachat-jsonrpc"]

View File

@@ -4439,14 +4439,18 @@ pub unsafe extern "C" fn dc_accounts_get_next_event(
.unwrap_or_else(ptr::null_mut)
}
#[cfg(feature = "jsonrpc")]
use deltachat_jsonrpc::api::CommandApi;
#[cfg(feature = "jsonrpc")]
use deltachat_jsonrpc::yerpc::{MessageHandle, RpcHandle};
#[cfg(feature = "jsonrpc")]
pub struct dc_json_api_instance_t {
receiver: async_std::channel::Receiver<deltachat_jsonrpc::yerpc::Message>,
handle: MessageHandle<CommandApi>,
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_get_json_api(
account_manager: *mut dc_accounts_t,
@@ -4467,6 +4471,7 @@ pub unsafe extern "C" fn dc_get_json_api(
Box::into_raw(Box::new(instance))
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_json_api_unref(json_api_instance: *mut dc_json_api_instance_t) {
if json_api_instance.is_null() {
@@ -4477,6 +4482,7 @@ pub unsafe extern "C" fn dc_json_api_unref(json_api_instance: *mut dc_json_api_i
Box::from_raw(json_api_instance);
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_json_request(
json_api_instance: *mut dc_json_api_instance_t,
@@ -4495,6 +4501,7 @@ pub unsafe extern "C" fn dc_json_request(
});
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_get_next_json_response(
json_api_instance: *mut dc_json_api_instance_t,