diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 320e43dad..95771b4d1 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -25,7 +25,6 @@ typedef struct _dc_event dc_event_t; typedef struct _dc_event_emitter dc_event_emitter_t; typedef struct _dc_jsonrpc_instance dc_jsonrpc_instance_t; typedef struct _dc_backup_provider dc_backup_provider_t; -typedef struct _dc_http_response dc_http_response_t; // Alias for backwards compatibility, use dc_event_emitter_t instead. typedef struct _dc_event_emitter dc_accounts_event_emitter_t; @@ -5185,72 +5184,6 @@ int dc_provider_get_status (const dc_provider_t* prov void dc_provider_unref (dc_provider_t* provider); -/** - * Return an HTTP(S) GET response. - * This function can be used to download remote content for HTML emails. - * - * @memberof dc_context_t - * @param context The context object to take proxy settings from. - * @param url HTTP or HTTPS URL. - * @return The response must be released using dc_http_response_unref() after usage. - * NULL is returned on errors. - */ -dc_http_response_t* dc_get_http_response (const dc_context_t* context, const char* url); - - -/** - * @class dc_http_response_t - * - * An object containing an HTTP(S) GET response. - * Created by dc_get_http_response(). - */ - - -/** - * Returns HTTP response MIME type as a string, e.g. "text/plain" or "text/html". - * - * @memberof dc_http_response_t - * @param response HTTP response as returned by dc_get_http_response(). - * @return The string which must be released using dc_str_unref() after usage. May be NULL. - */ -char* dc_http_response_get_mimetype (const dc_http_response_t* response); - -/** - * Returns HTTP response encoding, e.g. "utf-8". - * - * @memberof dc_http_response_t - * @param response HTTP response as returned by dc_get_http_response(). - * @return The string which must be released using dc_str_unref() after usage. May be NULL. - */ -char* dc_http_response_get_encoding (const dc_http_response_t* response); - -/** - * Returns HTTP response contents. - * - * @memberof dc_http_response_t - * @param response HTTP response as returned by dc_get_http_response(). - * @return The blob which must be released using dc_str_unref() after usage. NULL is never returned. - */ -uint8_t* dc_http_response_get_blob (const dc_http_response_t* response); - -/** - * Returns HTTP response content size. - * - * @memberof dc_http_response_t - * @param response HTTP response as returned by dc_get_http_response(). - * @return The blob size. - */ -size_t dc_http_response_get_size (const dc_http_response_t* response); - -/** - * Free an HTTP response object. - * - * @memberof dc_http_response_t - * @param response HTTP response as returned by dc_get_http_response(). - */ -void dc_http_response_unref (const dc_http_response_t* response); - - /** * @class dc_lot_t * diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 081e7198a..336654894 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -31,7 +31,6 @@ use deltachat::ephemeral::Timer as EphemeralTimer; use deltachat::imex::BackupProvider; use deltachat::key::preconfigure_keypair; use deltachat::message::MsgId; -use deltachat::net::read_url_blob; use deltachat::qr_code_generator::{generate_backup_qr, get_securejoin_qr_svg}; use deltachat::reaction::{get_msg_reactions, send_reaction, Reactions}; use deltachat::stock_str::StockMessage; @@ -4590,96 +4589,6 @@ pub unsafe extern "C" fn dc_provider_unref(provider: *mut dc_provider_t) { // this may change once we start localizing string. } -// dc_http_response_t - -pub type dc_http_response_t = net::HttpResponse; - -#[no_mangle] -pub unsafe extern "C" fn dc_get_http_response( - context: *const dc_context_t, - url: *const libc::c_char, -) -> *mut dc_http_response_t { - if context.is_null() || url.is_null() { - eprintln!("ignoring careless call to dc_get_http_response()"); - return ptr::null_mut(); - } - - let context = &*context; - let url = to_string_lossy(url); - if let Ok(response) = block_on(read_url_blob(context, &url)) - .context("read_url_blob") - .log_err(context) - { - Box::into_raw(Box::new(response)) - } else { - ptr::null_mut() - } -} - -#[no_mangle] -pub unsafe extern "C" fn dc_http_response_get_mimetype( - response: *const dc_http_response_t, -) -> *mut libc::c_char { - if response.is_null() { - eprintln!("ignoring careless call to dc_http_response_get_mimetype()"); - return ptr::null_mut(); - } - - let response = &*response; - response.mimetype.strdup() -} - -#[no_mangle] -pub unsafe extern "C" fn dc_http_response_get_encoding( - response: *const dc_http_response_t, -) -> *mut libc::c_char { - if response.is_null() { - eprintln!("ignoring careless call to dc_http_response_get_encoding()"); - return ptr::null_mut(); - } - - let response = &*response; - response.encoding.strdup() -} - -#[no_mangle] -pub unsafe extern "C" fn dc_http_response_get_blob( - response: *const dc_http_response_t, -) -> *mut libc::c_char { - if response.is_null() { - eprintln!("ignoring careless call to dc_http_response_get_blob()"); - return ptr::null_mut(); - } - - let response = &*response; - let blob_len = response.blob.len(); - let ptr = libc::malloc(blob_len); - libc::memcpy(ptr, response.blob.as_ptr() as *mut libc::c_void, blob_len); - ptr as *mut libc::c_char -} - -#[no_mangle] -pub unsafe extern "C" fn dc_http_response_get_size( - response: *const dc_http_response_t, -) -> libc::size_t { - if response.is_null() { - eprintln!("ignoring careless call to dc_http_response_get_size()"); - return 0; - } - - let response = &*response; - response.blob.len() -} - -#[no_mangle] -pub unsafe extern "C" fn dc_http_response_unref(response: *mut dc_http_response_t) { - if response.is_null() { - eprintln!("ignoring careless call to dc_http_response_unref()"); - return; - } - drop(Box::from_raw(response)); -} - // -- Accounts /// Reader-writer lock wrapper for accounts manager to guarantee thread safety when using