From 30ca377586287341bbaf2002313af608b2f1aca2 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 20 Jul 2019 19:43:05 +0300 Subject: [PATCH 1/5] src/top_evil_rs.py: fix shebang to always use Python 3 and make it executable PEP-0394 (https://www.python.org/dev/peps/pep-0394/) recommends to use more specific shebangs. For example, Debian allows /usr/bin/python to be configured to python2 via `update-alternatives python`, but the script does not work with Python 2. --- src/top_evil_rs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/top_evil_rs.py diff --git a/src/top_evil_rs.py b/src/top_evil_rs.py old mode 100644 new mode 100755 index 483166b53..21a4820cc --- a/src/top_evil_rs.py +++ b/src/top_evil_rs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os From 3dfd623db723a9644697b108dde42bde6bd811ea Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 21 Jul 2019 00:35:49 +0300 Subject: [PATCH 2/5] Use constants instead of hardcoded values in dc_mimefactory.rs --- src/dc_mimefactory.rs | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index d1eb9dcc7..53b0f48cf 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -8,7 +8,7 @@ use mmime::mailmime_write_mem::*; use mmime::mmapstring::*; use mmime::other::*; -use crate::constants::DC_VERSION_STR; +use crate::constants::*; use crate::context::Context; use crate::dc_chat::*; use crate::dc_contact::*; @@ -539,7 +539,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: let msg: *mut dc_msg_t = (*factory).msg; let mut meta_part: *mut mailmime = 0 as *mut mailmime; let mut placeholdertext: *mut libc::c_char = 0 as *mut libc::c_char; - if (*chat).type_0 == 130 { + if (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int { mailimf_fields_add( imf_fields, mailimf_field_new_custom( @@ -563,7 +563,9 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: } /* build header etc. */ let command: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0); - if (*chat).type_0 == 120 || (*chat).type_0 == 130 { + if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int + || (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int + { mailimf_fields_add( imf_fields, mailimf_field_new_custom( @@ -750,7 +752,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: } if !grpimage.is_null() { let mut meta: *mut dc_msg_t = dc_msg_new_untyped((*factory).context); - (*meta).type_0 = 20; + (*meta).type_0 = DC_MSG_IMAGE as libc::c_int; dc_param_set((*meta).param, 'f' as i32, grpimage); let mut filename_as_sent: *mut libc::c_char = 0 as *mut libc::c_char; meta_part = build_body_file( @@ -769,8 +771,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: } dc_msg_unref(meta); } - if (*msg).type_0 == 41 || (*msg).type_0 == 40 || (*msg).type_0 == 50 { - if (*msg).type_0 == 41 { + if (*msg).type_0 == DC_MSG_VOICE as libc::c_int + || (*msg).type_0 == DC_MSG_AUDIO as libc::c_int + || (*msg).type_0 == DC_MSG_VIDEO as libc::c_int + { + if (*msg).type_0 == DC_MSG_VOICE as libc::c_int { mailimf_fields_add( imf_fields, mailimf_field_new_custom( @@ -845,12 +850,12 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: free(fwdhint as *mut libc::c_void); free(placeholdertext as *mut libc::c_void); /* add attachment part */ - if (*msg).type_0 == 20 - || (*msg).type_0 == 21 - || (*msg).type_0 == 40 - || (*msg).type_0 == 41 - || (*msg).type_0 == 50 - || (*msg).type_0 == 60 + if (*msg).type_0 == DC_MSG_IMAGE as libc::c_int + || (*msg).type_0 == DC_MSG_GIF as libc::c_int + || (*msg).type_0 == DC_MSG_AUDIO as libc::c_int + || (*msg).type_0 == DC_MSG_VOICE as libc::c_int + || (*msg).type_0 == DC_MSG_VIDEO as libc::c_int + || (*msg).type_0 == DC_MSG_FILE as libc::c_int { if 0 == is_file_size_okay(msg) { let error: *mut libc::c_char = dc_mprintf( @@ -1103,7 +1108,9 @@ unsafe fn get_subject( }; if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 { ret = dc_stock_str(context, 42) - } else if (*chat).type_0 == 120 || (*chat).type_0 == 130 { + } else if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int + || (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int + { ret = dc_mprintf( b"Chat: %s: %s%s\x00" as *const u8 as *const libc::c_char, (*chat).name, @@ -1167,7 +1174,7 @@ unsafe fn build_body_file( let mut filename_to_send: *mut libc::c_char = 0 as *mut libc::c_char; let mut filename_encoded: *mut libc::c_char = 0 as *mut libc::c_char; if !pathNfilename.is_null() { - if (*msg).type_0 == 41 { + if (*msg).type_0 == DC_MSG_VOICE as libc::c_int { let ts = chrono::Utc.timestamp((*msg).timestamp_sort as i64, 0); let suffix = if !suffix.is_null() { @@ -1179,9 +1186,11 @@ unsafe fn build_body_file( .format(&format!("voice-message_%Y-%m-%d_%H-%M-%S.{}", suffix)) .to_string(); filename_to_send = strdup(to_cstring(res).as_ptr()); - } else if (*msg).type_0 == 40 { + } else if (*msg).type_0 == DC_MSG_AUDIO as libc::c_int { filename_to_send = dc_get_filename(pathNfilename) - } else if (*msg).type_0 == 20 || (*msg).type_0 == 21 { + } else if (*msg).type_0 == DC_MSG_IMAGE as libc::c_int + || (*msg).type_0 == DC_MSG_GIF as libc::c_int + { if base_name.is_null() { base_name = b"image\x00" as *const u8 as *const libc::c_char } @@ -1194,7 +1203,7 @@ unsafe fn build_body_file( b"dat\x00" as *const u8 as *const libc::c_char }, ) - } else if (*msg).type_0 == 50 { + } else if (*msg).type_0 == DC_MSG_VIDEO as libc::c_int { filename_to_send = dc_mprintf( b"video.%s\x00" as *const u8 as *const libc::c_char, if !suffix.is_null() { From a7c8ebc089ee9c86ff69fd61395fac3f41d096ff Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 21 Jul 2019 15:44:04 +0300 Subject: [PATCH 3/5] Replace DC_ARRAY_MAGIC #define with a constant --- src/dc_array.rs | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/dc_array.rs b/src/dc_array.rs index be10d86ec..52d0270a3 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -3,6 +3,8 @@ use crate::dc_tools::*; use crate::types::*; use crate::x::*; +const DC_ARRAY_MAGIC: uint32_t = 0x000a11aa; + /* * the structure behind dc_array_t */ #[derive(Copy, Clone)] #[repr(C)] @@ -23,7 +25,7 @@ pub struct dc_array_t { * To free an array object, use dc_array_unref(). */ pub unsafe fn dc_array_unref(mut array: *mut dc_array_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return; } if (*array).type_0 == 1i32 { @@ -35,7 +37,7 @@ pub unsafe fn dc_array_unref(mut array: *mut dc_array_t) { } pub unsafe fn dc_array_free_ptr(array: *mut dc_array_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return; } let mut i: size_t = 0i32 as size_t; @@ -53,7 +55,7 @@ pub unsafe fn dc_array_free_ptr(array: *mut dc_array_t) { } pub unsafe fn dc_array_add_uint(mut array: *mut dc_array_t, item: uintptr_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return; } if (*array).count == (*array).allocated { @@ -78,21 +80,21 @@ pub unsafe fn dc_array_add_ptr(array: *mut dc_array_t, item: *mut libc::c_void) } pub unsafe fn dc_array_get_cnt(array: *const dc_array_t) -> size_t { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return 0i32 as size_t; } (*array).count } pub unsafe fn dc_array_get_uint(array: *const dc_array_t, index: size_t) -> uintptr_t { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count { return 0i32 as uintptr_t; } *(*array).array.offset(index as isize) } pub unsafe fn dc_array_get_id(array: *const dc_array_t, index: size_t) -> uint32_t { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count { return 0i32 as uint32_t; } if (*array).type_0 == 1i32 { @@ -102,7 +104,7 @@ pub unsafe fn dc_array_get_id(array: *const dc_array_t, index: size_t) -> uint32 } pub unsafe fn dc_array_get_ptr(array: *const dc_array_t, index: size_t) -> *mut libc::c_void { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count { return 0 as *mut libc::c_void; } *(*array).array.offset(index as isize) as *mut libc::c_void @@ -110,7 +112,7 @@ pub unsafe fn dc_array_get_ptr(array: *const dc_array_t, index: size_t) -> *mut pub unsafe fn dc_array_get_latitude(array: *const dc_array_t, index: size_t) -> libc::c_double { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -122,7 +124,7 @@ pub unsafe fn dc_array_get_latitude(array: *const dc_array_t, index: size_t) -> pub unsafe fn dc_array_get_longitude(array: *const dc_array_t, index: size_t) -> libc::c_double { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -134,7 +136,7 @@ pub unsafe fn dc_array_get_longitude(array: *const dc_array_t, index: size_t) -> pub unsafe fn dc_array_get_accuracy(array: *const dc_array_t, index: size_t) -> libc::c_double { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -146,7 +148,7 @@ pub unsafe fn dc_array_get_accuracy(array: *const dc_array_t, index: size_t) -> pub unsafe fn dc_array_get_timestamp(array: *const dc_array_t, index: size_t) -> i64 { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -158,7 +160,7 @@ pub unsafe fn dc_array_get_timestamp(array: *const dc_array_t, index: size_t) -> pub unsafe fn dc_array_get_chat_id(array: *const dc_array_t, index: size_t) -> uint32_t { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -170,7 +172,7 @@ pub unsafe fn dc_array_get_chat_id(array: *const dc_array_t, index: size_t) -> u pub unsafe fn dc_array_get_contact_id(array: *const dc_array_t, index: size_t) -> uint32_t { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -182,7 +184,7 @@ pub unsafe fn dc_array_get_contact_id(array: *const dc_array_t, index: size_t) - pub unsafe fn dc_array_get_msg_id(array: *const dc_array_t, index: size_t) -> uint32_t { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -194,7 +196,7 @@ pub unsafe fn dc_array_get_msg_id(array: *const dc_array_t, index: size_t) -> ui pub unsafe fn dc_array_get_marker(array: *const dc_array_t, index: size_t) -> *mut libc::c_char { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -216,7 +218,7 @@ pub unsafe fn dc_array_get_marker(array: *const dc_array_t, index: size_t) -> *m */ pub unsafe fn dc_array_is_independent(array: *const dc_array_t, index: size_t) -> libc::c_int { if array.is_null() - || (*array).magic != 0xa11aai32 as libc::c_uint + || (*array).magic != DC_ARRAY_MAGIC || index >= (*array).count || (*array).type_0 != 1i32 || *(*array).array.offset(index as isize) == 0 @@ -232,7 +234,7 @@ pub unsafe fn dc_array_search_id( needle: uint32_t, ret_index: *mut size_t, ) -> bool { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return false; } let data: *mut uintptr_t = (*array).array; @@ -251,7 +253,7 @@ pub unsafe fn dc_array_search_id( } pub unsafe fn dc_array_get_raw(array: *const dc_array_t) -> *const uintptr_t { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return 0 as *const uintptr_t; } (*array).array @@ -266,7 +268,7 @@ pub unsafe fn dc_array_new_typed(type_0: libc::c_int, initsize: size_t) -> *mut array = calloc(1, ::std::mem::size_of::()) as *mut dc_array_t; assert!(!array.is_null()); - (*array).magic = 0xa11aai32 as uint32_t; + (*array).magic = DC_ARRAY_MAGIC; (*array).count = 0i32 as size_t; (*array).allocated = if initsize < 1 { 1 } else { initsize }; (*array).type_0 = type_0; @@ -282,7 +284,7 @@ pub unsafe fn dc_array_new_typed(type_0: libc::c_int, initsize: size_t) -> *mut } pub unsafe fn dc_array_empty(mut array: *mut dc_array_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return; } (*array).count = 0i32 as size_t; @@ -290,7 +292,7 @@ pub unsafe fn dc_array_empty(mut array: *mut dc_array_t) { pub unsafe fn dc_array_duplicate(array: *const dc_array_t) -> *mut dc_array_t { let mut ret: *mut dc_array_t; - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC { return 0 as *mut dc_array_t; } ret = dc_array_new((*array).allocated); @@ -306,7 +308,7 @@ pub unsafe fn dc_array_duplicate(array: *const dc_array_t) -> *mut dc_array_t { } pub unsafe fn dc_array_sort_ids(array: *mut dc_array_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || (*array).count <= 1 { return; } qsort( @@ -330,7 +332,7 @@ unsafe extern "C" fn cmp_intptr_t(p1: *const libc::c_void, p2: *const libc::c_vo } pub unsafe fn dc_array_sort_strings(array: *mut dc_array_t) { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || (*array).count <= 1 { return; } qsort( @@ -355,7 +357,7 @@ pub unsafe fn dc_array_get_string( array: *const dc_array_t, sep: *const libc::c_char, ) -> *mut libc::c_char { - if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || sep.is_null() { + if array.is_null() || (*array).magic != DC_ARRAY_MAGIC || sep.is_null() { return dc_strdup(b"\x00" as *const u8 as *const libc::c_char); } let cnt = (*array).count as usize; From c116d6f73f23f99df6d9d54b75387eb93279c526 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 21 Jul 2019 20:11:36 +0300 Subject: [PATCH 4/5] Use Rust for instead of C while in dc_array test --- src/dc_array.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/dc_array.rs b/src/dc_array.rs index 52d0270a3..a23c24544 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -412,22 +412,17 @@ mod tests { let arr = dc_array_new(7 as size_t); assert_eq!(dc_array_get_cnt(arr), 0); - let mut i: libc::c_int = 0; - while i < 1000 { + for i in 0..1000 { dc_array_add_id(arr, (i + 2) as uint32_t); - i += 1 } assert_eq!(dc_array_get_cnt(arr), 1000); - i = 0; - - while i < 1000i32 { + for i in 0..1000 { assert_eq!( dc_array_get_id(arr, i as size_t), (i + 1i32 * 2i32) as libc::c_uint ); - i += 1 } assert_eq!(dc_array_get_id(arr, -1i32 as size_t), 0); From 686678c96c0007f8a961b3277ef4dcdf1c814b96 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 21 Jul 2019 21:38:18 +0300 Subject: [PATCH 5/5] Spellcheck --- .gitattributes | 2 +- deltachat-ffi/deltachat.h | 16 ++++++++-------- deltachat-ffi/src/lib.rs | 2 +- src/config.rs | 2 +- src/constants.rs | 16 ++++++++-------- src/dc_chat.rs | 8 ++++---- src/dc_contact.rs | 2 +- src/dc_e2ee.rs | 4 ++-- src/dc_mimeparser.rs | 2 +- src/dc_msg.rs | 4 ++-- src/dc_param.rs | 6 +++--- src/dc_qr.rs | 2 +- src/dc_receive_imf.rs | 8 ++++---- src/dc_simplify.rs | 2 +- src/dc_tools.rs | 4 ++-- src/sql.rs | 2 +- 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.gitattributes b/.gitattributes index f99faebe8..10cbc599e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,7 @@ # ensures this even if the user has not set core.autocrlf. * text=auto -# binary files should be detected by git, however, to be sure, you can add them here explictly +# binary files should be detected by git, however, to be sure, you can add them here explicitly *.png binary *.jpg binary *.gif binary diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index e73ac7ec5..0e5c1bd56 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -503,8 +503,8 @@ int dc_chat_is_sending_locations (const dc_chat_t*); #define DC_STATE_OUT_MDN_RCVD 28 -#define DC_MAX_GET_TEXT_LEN 30000 // approx. max. lenght returned by dc_msg_get_text() -#define DC_MAX_GET_INFO_LEN 100000 // approx. max. lenght returned by dc_get_msg_info() +#define DC_MAX_GET_TEXT_LEN 30000 // approx. max. length returned by dc_msg_get_text() +#define DC_MAX_GET_INFO_LEN 100000 // approx. max. length returned by dc_get_msg_info() dc_msg_t* dc_msg_new (dc_context_t*, int viewtype); @@ -667,7 +667,7 @@ int64_t dc_lot_get_timestamp (const dc_lot_t*); * A voice message that was directly recorded by the user. * For all other audio messages, the type #DC_MSG_AUDIO should be used. * File and duration are set via dc_msg_set_file(), dc_msg_set_duration() - * and retieved via dc_msg_get_file(), dc_msg_get_duration() + * and retrieved via dc_msg_get_file(), dc_msg_get_duration() */ #define DC_MSG_VOICE 41 @@ -768,9 +768,9 @@ int64_t dc_lot_get_timestamp (const dc_lot_t*); * @} */ -#define DC_LP_AUTH_FLAGS (DC_LP_AUTH_OAUTH2|DC_LP_AUTH_NORMAL) // if none of these flags are set, the default is choosen -#define DC_LP_IMAP_SOCKET_FLAGS (DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_SSL|DC_LP_IMAP_SOCKET_PLAIN) // if none of these flags are set, the default is choosen -#define DC_LP_SMTP_SOCKET_FLAGS (DC_LP_SMTP_SOCKET_STARTTLS|DC_LP_SMTP_SOCKET_SSL|DC_LP_SMTP_SOCKET_PLAIN) // if none of these flags are set, the default is choosen +#define DC_LP_AUTH_FLAGS (DC_LP_AUTH_OAUTH2|DC_LP_AUTH_NORMAL) // if none of these flags are set, the default is chosen +#define DC_LP_IMAP_SOCKET_FLAGS (DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_SSL|DC_LP_IMAP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen +#define DC_LP_SMTP_SOCKET_FLAGS (DC_LP_SMTP_SOCKET_STARTTLS|DC_LP_SMTP_SOCKET_SSL|DC_LP_SMTP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen @@ -851,7 +851,7 @@ int64_t dc_lot_get_timestamp (const dc_lot_t*); * The library-user should report an error to the end-user. * Passed to the callback given to dc_context_new(). * - * As most things are asynchrounous, things may go wrong at any time and the user + * As most things are asynchronous, things may go wrong at any time and the user * should not be disturbed by a dialog or so. Instead, use a bubble or so. * * However, for ongoing processes (eg. dc_configure()) @@ -882,7 +882,7 @@ int64_t dc_lot_get_timestamp (const dc_lot_t*); * * Moreover, if the UI detects that the device is offline, * it is probably more useful to report this to the user - * instread of the string from data2. + * instead of the string from data2. * * @param data1 (int) 1=first/new network error, should be reported the user; * 0=subsequent network error, should be logged only diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index a477a59b1..c1efcc9be 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -481,7 +481,7 @@ pub unsafe extern "C" fn dc_delete_chat(context: *mut dc_context_t, chat_id: u32 assert!(!context.is_null()); let context = &*context; - // TODO: update to indiciate public api success/failure of deletion + // TODO: update to indicate public api success/failure of deletion dc_chat::dc_delete_chat(context, chat_id); } diff --git a/src/config.rs b/src/config.rs index b5a2e65a4..0f0cc2aa8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -100,7 +100,7 @@ impl Context { } /// Set the given config key. - /// If `None` is passed as a value the value is cleared and set to the deafult if there is one. + /// If `None` is passed as a value the value is cleared and set to the default if there is one. pub fn set_config(&self, key: Config, value: Option<&str>) -> Result<(), Error> { match key { Config::Selfavatar if value.is_some() => { diff --git a/src/constants.rs b/src/constants.rs index a56d6b887..ac956be43 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -80,9 +80,9 @@ pub const DC_STATE_OUT_FAILED: usize = 24; pub const DC_STATE_OUT_DELIVERED: usize = 26; pub const DC_STATE_OUT_MDN_RCVD: usize = 28; -/// approx. max. lenght returned by dc_msg_get_text() +/// approx. max. length returned by dc_msg_get_text() pub const DC_MAX_GET_TEXT_LEN: usize = 30000; -/// approx. max. lenght returned by dc_get_msg_info() +/// approx. max. length returned by dc_get_msg_info() pub const DC_MAX_GET_INFO_LEN: usize = 100000; pub const DC_CONTACT_ID_SELF: usize = 1; @@ -119,7 +119,7 @@ pub const DC_MSG_AUDIO: usize = 40; /// A voice message that was directly recorded by the user. /// For all other audio messages, the type #DC_MSG_AUDIO should be used. /// File and duration are set via dc_msg_set_file(), dc_msg_set_duration() -/// and retieved via dc_msg_get_file(), dc_msg_get_duration() +/// and retrieved via dc_msg_get_file(), dc_msg_get_duration() pub const DC_MSG_VOICE: usize = 41; /// Video messages. @@ -173,12 +173,12 @@ pub const DC_LP_SMTP_SOCKET_SSL: usize = 0x20000; /// If this flag is set, automatic configuration is skipped. pub const DC_LP_SMTP_SOCKET_PLAIN: usize = 0x40000; -/// if none of these flags are set, the default is choosen +/// if none of these flags are set, the default is chosen pub const DC_LP_AUTH_FLAGS: usize = (DC_LP_AUTH_OAUTH2 | DC_LP_AUTH_NORMAL); -/// if none of these flags are set, the default is choosen +/// if none of these flags are set, the default is chosen pub const DC_LP_IMAP_SOCKET_FLAGS: usize = (DC_LP_IMAP_SOCKET_STARTTLS | DC_LP_IMAP_SOCKET_SSL | DC_LP_IMAP_SOCKET_PLAIN); -/// if none of these flags are set, the default is choosen +/// if none of these flags are set, the default is chosen pub const DC_LP_SMTP_SOCKET_FLAGS: usize = (DC_LP_SMTP_SOCKET_STARTTLS | DC_LP_SMTP_SOCKET_SSL | DC_LP_SMTP_SOCKET_PLAIN); @@ -237,7 +237,7 @@ pub enum Event { /// The library-user should report an error to the end-user. /// Passed to the callback given to dc_context_new(). /// - /// As most things are asynchrounous, things may go wrong at any time and the user + /// As most things are asynchronous, things may go wrong at any time and the user /// should not be disturbed by a dialog or so. Instead, use a bubble or so. /// /// However, for ongoing processes (eg. dc_configure()) @@ -265,7 +265,7 @@ pub enum Event { /// /// Moreover, if the UI detects that the device is offline, /// it is probably more useful to report this to the user - /// instread of the string from data2. + /// instead of the string from data2. /// /// @param data1 (int) 1=first/new network error, should be reported the user; /// 0=subsequent network error, should be logged only diff --git a/src/dc_chat.rs b/src/dc_chat.rs index 715e77fc2..f0c5aab39 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -1550,7 +1550,7 @@ pub unsafe fn dc_add_contact_to_chat_ex( "Cannot add contact to group; self not in group.", ); } else { - /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ + /* we should respect this - whatever we send to the group, it gets discarded anyway! */ if 0 != flags & 0x1 && dc_param_get_int((*chat).param, 'U' as i32, 0) == 1 { dc_param_set((*chat).param, 'U' as i32, 0 as *const libc::c_char); dc_chat_update_param(chat); @@ -1710,7 +1710,7 @@ pub unsafe fn dc_remove_contact_from_chat( "Cannot remove contact from chat; self not in group.", ); } else { - /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ + /* we should respect this - whatever we send to the group, it gets discarded anyway! */ if !contact.is_null() { if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 { (*msg).type_0 = 10; @@ -1812,7 +1812,7 @@ pub unsafe fn dc_set_chat_name( "Cannot set chat name; self not in group", ); } else { - /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ + /* we should respect this - whatever we send to the group, it gets discarded anyway! */ if sql::execute( context, &context.sql, @@ -1881,7 +1881,7 @@ pub unsafe fn dc_set_chat_profile_image( "Cannot set chat profile image; self not in group.", ); } else { - /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ + /* we should respect this - whatever we send to the group, it gets discarded anyway! */ if !new_image.is_null() { new_image_rel = dc_strdup(new_image); if 0 == dc_make_rel_and_copy(context, &mut new_image_rel) { diff --git a/src/dc_contact.rs b/src/dc_contact.rs index e35a40eb4..5e0565aa6 100644 --- a/src/dc_contact.rs +++ b/src/dc_contact.rs @@ -259,7 +259,7 @@ pub unsafe fn dc_contact_empty(mut contact: *mut dc_contact_t) { /* address is in our address book */ /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verified() ! */ -/* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ +/* contact added manually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */ /* contacts with at least this origin value are shown in the contact list */ /* contacts with at least this origin value are verified and known not to be spam */ /* contacts with at least this origin value start a new "normal" chat, defaults to off */ diff --git a/src/dc_e2ee.rs b/src/dc_e2ee.rs index 3cf4569bb..af31b6415 100644 --- a/src/dc_e2ee.rs +++ b/src/dc_e2ee.rs @@ -31,7 +31,7 @@ use crate::x::*; // attachments of 25 mb brutto should work on the majority of providers // (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100). // as an upper limit, we double the size; the core won't send messages larger than this -// to get the netto sizes, we substract 1 mb header-overhead and the base64-overhead. +// to get the netto sizes, we subtract 1 mb header-overhead and the base64-overhead. // some defaults #[derive(Clone)] pub struct dc_e2ee_helper_t { @@ -1010,7 +1010,7 @@ unsafe fn has_decrypted_pgp_armor( * that we could use the normal Autocrypt processing. * * @private - * @param mime The mime struture to check + * @param mime The mime structure to check * @return 1=multipart/report found in MIME, 0=no multipart/report found */ // TODO should return bool /rtn diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index d6d57afb5..ce6b80b11 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -1440,7 +1440,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known( } } } - /* add object? (we do not add all objetcs, eg. signatures etc. are ignored) */ + /* add object? (we do not add all objects, eg. signatures etc. are ignored) */ dc_simplify_unref(simplifier); if !transfer_decoding_buffer.is_null() { mmap_string_unref(transfer_decoding_buffer); diff --git a/src/dc_msg.rs b/src/dc_msg.rs index 66e6ccd52..a470b62c2 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -224,8 +224,8 @@ pub unsafe fn dc_msg_new_untyped<'a>(context: &'a Context) -> *mut dc_msg_t<'a> * If you want an update, you have to recreate the object. */ // to check if a mail was sent, use dc_msg_is_sent() -// approx. max. lenght returned by dc_msg_get_text() -// approx. max. lenght returned by dc_get_msg_info() +// approx. max. length returned by dc_msg_get_text() +// approx. max. length returned by dc_get_msg_info() pub unsafe fn dc_msg_new<'a>(context: &'a Context, viewtype: libc::c_int) -> *mut dc_msg_t<'a> { let mut msg: *mut dc_msg_t; msg = calloc(1, ::std::mem::size_of::()) as *mut dc_msg_t; diff --git a/src/dc_param.rs b/src/dc_param.rs index f6591771a..8f2f6ff8b 100644 --- a/src/dc_param.rs +++ b/src/dc_param.rs @@ -18,7 +18,7 @@ pub const DC_PARAM_GUARANTEE_E2EE: char = 'c'; pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e'; /// for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u'; -/// for msgs: an incoming message which requestes a MDN (aka read receipt) +/// for msgs: an incoming message which requests a MDN (aka read receipt) pub const DC_PARAM_WANTS_MDN: char = 'r'; /// for msgs pub const DC_PARAM_FORWARDED: char = 'a'; @@ -60,10 +60,10 @@ pub const DC_PARAM_SELFTALK: char = 'K'; pub const DC_FP_ADD_AUTOCRYPT_HEADER: u8 = 1; pub const DC_FP_NO_AUTOCRYPT_HEADER: u8 = 2; -/// An object for handling key=value parameter lists; for the key, curently only +/// An object for handling key=value parameter lists; for the key, currently only /// a single character is allowed. /// -/// The object is used eg. by Chat or dc_msg_t, for readable paramter names, +/// The object is used eg. by Chat or dc_msg_t, for readable parameter names, /// these classes define some DC_PARAM_* constantats. /// /// Only for library-internal use. diff --git a/src/dc_qr.rs b/src/dc_qr.rs index 1b72ab2d6..eb7e38102 100644 --- a/src/dc_qr.rs +++ b/src/dc_qr.rs @@ -188,7 +188,7 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc match current_block { 16562876845594826114 => {} _ => { - /* check the paramters + /* check the parameters ---------------------- */ if !addr.is_null() { /* urldecoding is needed at least for OPENPGP4FPR but should not hurt in the other cases */ diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 1483e74d6..f11652162 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -884,7 +884,7 @@ unsafe fn calc_timestamps( } /* the function tries extracts the group-id from the message and returns the -corresponding chat_id. If the chat_id is not existant, it is created. +corresponding chat_id. If the chat_id is not existent, it is created. If the message contains groups commands (name, profile image, changed members), they are executed as well. @@ -1397,7 +1397,7 @@ unsafe fn create_or_lookup_adhoc_group( /* we do not check if the message is a reply to another group, this may result in chats with unclear member list. instead we create a new group in the following lines ... */ /* create a new ad-hoc group - - there is no need to check if this group exists; otherwise we would have catched it above */ + - there is no need to check if this group exists; otherwise we would have caught it above */ grpid = create_adhoc_grp_id(context, member_ids); if !grpid.is_null() { if !mime_parser.subject.is_null() @@ -1477,7 +1477,7 @@ fn create_group_record( unsafe fn create_adhoc_grp_id(context: &Context, member_ids: *mut dc_array_t) -> *mut libc::c_char { /* algorithm: - sort normalized, lowercased, e-mail addresses alphabetically - - put all e-mail addresses into a single string, separate the addresss by a single comma + - put all e-mail addresses into a single string, separate the address by a single comma - sha-256 this string (without possibly terminating null-characters) - encode the first 64 bits of the sha-256 output as lowercase hex (results in 16 characters from the set [0-9a-f]) */ @@ -1702,7 +1702,7 @@ unsafe fn check_verified_properties( to_addr )); cleanup(); - return Err(failure::format_err!("not a valid memember").into()); + return Err(failure::format_err!("not a valid member").into()); } } Ok(()) diff --git a/src/dc_simplify.rs b/src/dc_simplify.rs index dcf3aecd2..48abc7373 100644 --- a/src/dc_simplify.rs +++ b/src/dc_simplify.rs @@ -261,7 +261,7 @@ unsafe fn is_quoted_headline(buf: *const libc::c_char) -> bool { /* This function may be called for the line _directly_ before a quote. The function checks if the line contains sth. like "On 01.02.2016, xy@z wrote:" in various languages. - Currently, we simply check if the last character is a ':'. - - Checking for the existance of an email address may fail (headlines may show the user's name instead of the address) */ + - Checking for the existence of an email address may fail (headlines may show the user's name instead of the address) */ let buf_len: libc::c_int = strlen(buf) as libc::c_int; if buf_len > 80i32 { return false; diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 52797b0c2..42c875b5d 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -563,7 +563,7 @@ pub unsafe fn dc_str_to_color(str: *const libc::c_char) -> libc::c_int { /* the colors must fulfill some criterions as: - contrast to black and to white - work as a text-color - - being noticable on a typical map + - being noticeable on a typical map - harmonize together while being different enough (therefore, we cannot just use random rgb colors :) */ static mut colors: [uint32_t; 16] = [ @@ -1582,7 +1582,7 @@ pub fn as_path<'a>(s: *const libc::c_char) -> &'a std::path::Path { as_path_unicode(s) } -// Implmentation for as_path() on Windows. +// Implementation for as_path() on Windows. // // Having this as a separate function means it can be tested on unix // too. diff --git a/src/sql.rs b/src/sql.rs index 4863d8ecd..2dd8fb025 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -844,7 +844,7 @@ pub fn get_rowid( ) -> u32 { // alternative to sqlite3_last_insert_rowid() which MUST NOT be used due to race conditions, see comment above. // the ORDER BY ensures, this function always returns the most recent id, - // eg. if a Message-ID is splitted into different messages. + // eg. if a Message-ID is split into different messages. let query = format!( "SELECT id FROM {} WHERE {}='{}' ORDER BY id DESC", table.as_ref(),