put jsonrpc stuff in own module

This commit is contained in:
Simon Laux
2022-06-25 23:56:56 +02:00
parent 2319dfc3eb
commit c5ff7427be

View File

@@ -4440,17 +4440,16 @@ pub unsafe extern "C" fn dc_accounts_get_next_event(
}
#[cfg(feature = "jsonrpc")]
mod jsonrpc {
use super::*;
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,
@@ -4471,7 +4470,6 @@ 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() {
@@ -4482,7 +4480,6 @@ 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,
@@ -4501,7 +4498,6 @@ 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,
@@ -4515,3 +4511,4 @@ pub unsafe extern "C" fn dc_get_next_json_response(
.map(|result| serde_json::to_string(&result).unwrap_or_default().strdup())
.unwrap_or(ptr::null_mut())
}
}