improve info string and version setting

This commit is contained in:
dignifiedquire
2019-04-27 15:55:27 +03:00
parent 8a99151252
commit 2d057cba56
4 changed files with 93 additions and 34 deletions

View File

@@ -75,5 +75,5 @@ fn main() {
link_dylib("etpan"); link_dylib("etpan");
} }
generate_bindings(); // generate_bindings();
} }

View File

@@ -1,5 +1,7 @@
//! Constants //! Constants
pub const VERSION: &'static [u8; 7] = b"0.42.0\x00";
pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01; pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01;
pub const DC_GCL_NO_SPECIALS: usize = 0x02; pub const DC_GCL_NO_SPECIALS: usize = 0x02;
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04; pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;

View File

@@ -1,7 +1,7 @@
use c2rust_bitfields::BitfieldStruct; use c2rust_bitfields::BitfieldStruct;
use libc; use libc;
use crate::constants::Event; use crate::constants::{Event, VERSION};
use crate::dc_array::*; use crate::dc_array::*;
use crate::dc_chat::*; use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
@@ -546,7 +546,7 @@ static mut sys_config_keys: [*const libc::c_char; 3] = [
]; ];
unsafe fn get_sys_config_str(mut key: *const libc::c_char) -> *mut libc::c_char { unsafe fn get_sys_config_str(mut key: *const libc::c_char) -> *mut libc::c_char {
if strcmp(key, b"sys.version\x00" as *const u8 as *const libc::c_char) == 0i32 { if strcmp(key, b"sys.version\x00" as *const u8 as *const libc::c_char) == 0i32 {
return dc_strdup(b"0.42.0\x00" as *const u8 as *const libc::c_char); return dc_strdup(VERSION as *const u8 as *const libc::c_char);
} else if strcmp( } else if strcmp(
key, key,
b"sys.msgsize_max_recommended\x00" as *const u8 as *const libc::c_char, b"sys.msgsize_max_recommended\x00" as *const u8 as *const libc::c_char,
@@ -734,34 +734,90 @@ pub unsafe fn dc_get_info(mut context: *mut dc_context_t) -> *mut libc::c_char {
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char, b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
b"<unset>\x00" as *const u8 as *const libc::c_char, b"<unset>\x00" as *const u8 as *const libc::c_char,
); );
temp =
dc_mprintf(b"deltachat_core_version=v%s\nsqlite_version=%s\nsqlite_thread_safe=%i\nlibetpan_version=%i.%i\nopenssl_version=%i.%i.%i%c\nrpgp_enabled=%i\ncompile_date=Apr 26 2019, 00:51:50\narch=%i\nnumber_of_chats=%i\nnumber_of_chat_messages=%i\nmessages_in_contact_requests=%i\nnumber_of_contacts=%i\ndatabase_dir=%s\ndatabase_version=%i\nblobdir=%s\ndisplay_name=%s\nis_configured=%i\nentered_account_settings=%s\nused_account_settings=%s\ninbox_watch=%i\nsentbox_watch=%i\nmvbox_watch=%i\nmvbox_move=%i\nfolders_configured=%i\nconfigured_sentbox_folder=%s\nconfigured_mvbox_folder=%s\nmdns_enabled=%i\ne2ee_enabled=%i\nprivate_key_count=%i\npublic_key_count=%i\nfingerprint=%s\n\x00" temp = dc_mprintf(
as *const u8 as *const libc::c_char, b"deltachat_core_version=v%s\n\
b"0.42.0\x00" as *const u8 as *const libc::c_char, sqlite_version=%s\n\
b"3.24.0\x00" as *const u8 as *const libc::c_char, sqlite_thread_safe=%i\n\
sqlite3_threadsafe(), libetpan_get_version_major(), libetpan_version=%i.%i\n\
libetpan_get_version_minor(), openssl_version=%i.%i.%i%c\n\
(0x1000212fi64 >> 28i32) as libc::c_int, rpgp_enabled=%i\n\
(0x1000212fi64 >> 20i32) as libc::c_int & 0xffi32, compile_date=Apr 26 2019, 00:51:50\n\
(0x1000212fi64 >> 12i32) as libc::c_int & 0xffi32, arch=%i\n\
(('a' as i32 - 1i32) as libc::c_long + number_of_chats=%i\n\
(0x1000212fi64 >> 4i32 & 0xffi32 as libc::c_long)) as number_of_chat_messages=%i\n\
libc::c_char as libc::c_int, rpgp_enabled, messages_in_contact_requests=%i\n\
(::std::mem::size_of::<*mut libc::c_void>() as number_of_contacts=%i\n\
libc::c_ulong).wrapping_mul(8i32 as libc::c_ulong), database_dir=%s\n\
chats, real_msgs, deaddrop_msgs, contacts, database_version=%i\n\
if !(*context).dbfile.is_null() { blobdir=%s\n\
(*context).dbfile display_name=%s\n\
} else { unset }, dbversion, is_configured=%i\n\
if !(*context).blobdir.is_null() { entered_account_settings=%s\n\
(*context).blobdir used_account_settings=%s\n\
} else { unset }, inbox_watch=%i\n\
if !displayname.is_null() { displayname } else { unset }, sentbox_watch=%i\n\
is_configured, l_readable_str, l2_readable_str, mvbox_watch=%i\n\
inbox_watch, sentbox_watch, mvbox_watch, mvbox_move, mvbox_move=%i\n\
folders_configured, configured_sentbox_folder, folders_configured=%i\n\
configured_mvbox_folder, mdns_enabled, e2ee_enabled, configured_sentbox_folder=%s\n\
prv_key_cnt, pub_key_cnt, fingerprint_str); configured_mvbox_folder=%s\n\
mdns_enabled=%i\n\
e2ee_enabled=%i\n\
private_key_count=%i\n\
public_key_count=%i\n\
fingerprint=%s\n\x00" as *const u8 as *const libc::c_char,
VERSION as *const u8 as *const libc::c_char,
libsqlite3_sys::SQLITE_VERSION as *const u8 as *const libc::c_char,
sqlite3_threadsafe(),
libetpan_get_version_major(),
libetpan_get_version_minor(),
// openssl (none used, so setting to 0)
0 as libc::c_int,
0 as libc::c_int,
0 as libc::c_int,
'a' as libc::c_char as libc::c_int,
rpgp_enabled,
// arch
(::std::mem::size_of::<*mut libc::c_void>() as libc::c_ulong)
.wrapping_mul(8i32 as libc::c_ulong),
chats,
real_msgs,
deaddrop_msgs,
contacts,
if !(*context).dbfile.is_null() {
(*context).dbfile
} else {
unset
},
dbversion,
if !(*context).blobdir.is_null() {
(*context).blobdir
} else {
unset
},
if !displayname.is_null() {
displayname
} else {
unset
},
is_configured,
l_readable_str,
l2_readable_str,
inbox_watch,
sentbox_watch,
mvbox_watch,
mvbox_move,
folders_configured,
configured_sentbox_folder,
configured_mvbox_folder,
mdns_enabled,
e2ee_enabled,
prv_key_cnt,
pub_key_cnt,
fingerprint_str,
);
dc_strbuilder_cat(&mut ret, temp); dc_strbuilder_cat(&mut ret, temp);
free(temp as *mut libc::c_void); free(temp as *mut libc::c_void);
dc_loginparam_unref(l); dc_loginparam_unref(l);
@@ -776,7 +832,7 @@ pub unsafe fn dc_get_info(mut context: *mut dc_context_t) -> *mut libc::c_char {
return ret.buf; return ret.buf;
} }
pub unsafe fn dc_get_version_str() -> *mut libc::c_char { pub unsafe fn dc_get_version_str() -> *mut libc::c_char {
return dc_strdup(b"0.42.0\x00" as *const u8 as *const libc::c_char); return dc_strdup(VERSION as *const u8 as *const libc::c_char);
} }
pub unsafe fn dc_get_fresh_msgs(mut context: *mut dc_context_t) -> *mut dc_array_t { pub unsafe fn dc_get_fresh_msgs(mut context: *mut dc_context_t) -> *mut dc_array_t {
let mut show_deaddrop: libc::c_int = 0i32; let mut show_deaddrop: libc::c_int = 0i32;

View File

@@ -1,6 +1,7 @@
use c2rust_bitfields::BitfieldStruct; use c2rust_bitfields::BitfieldStruct;
use libc; use libc;
use crate::constants::VERSION;
use crate::dc_chat::*; use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_context::dc_context_t; use crate::dc_context::dc_context_t;
@@ -457,7 +458,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
strdup(b"X-Mailer\x00" as *const u8 as *const libc::c_char), strdup(b"X-Mailer\x00" as *const u8 as *const libc::c_char),
dc_mprintf( dc_mprintf(
b"Delta Chat Core %s%s%s\x00" as *const u8 as *const libc::c_char, b"Delta Chat Core %s%s%s\x00" as *const u8 as *const libc::c_char,
b"0.42.0\x00" as *const u8 as *const libc::c_char, VERSION as *const u8 as *const libc::c_char,
if !(*(*factory).context).os_name.is_null() { if !(*(*factory).context).os_name.is_null() {
b"/\x00" as *const u8 as *const libc::c_char b"/\x00" as *const u8 as *const libc::c_char
} else { } else {
@@ -914,7 +915,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
message_text2 = message_text2 =
dc_mprintf(b"Reporting-UA: Delta Chat %s\r\nOriginal-Recipient: rfc822;%s\r\nFinal-Recipient: rfc822;%s\r\nOriginal-Message-ID: <%s>\r\nDisposition: manual-action/MDN-sent-automatically; displayed\r\n\x00" dc_mprintf(b"Reporting-UA: Delta Chat %s\r\nOriginal-Recipient: rfc822;%s\r\nFinal-Recipient: rfc822;%s\r\nOriginal-Message-ID: <%s>\r\nDisposition: manual-action/MDN-sent-automatically; displayed\r\n\x00"
as *const u8 as *const libc::c_char, as *const u8 as *const libc::c_char,
b"0.42.0\x00" as *const u8 as *const libc::c_char, VERSION as *const u8 as *const libc::c_char,
(*factory).from_addr, (*factory).from_addr, (*factory).from_addr, (*factory).from_addr,
(*(*factory).msg).rfc724_mid); (*(*factory).msg).rfc724_mid);
let mut content_type_0: *mut mailmime_content = mailmime_content_new_with_str( let mut content_type_0: *mut mailmime_content = mailmime_content_new_with_str(