diff --git a/docs/Doxyfile b/docs/Doxyfile index a10b6133..4420c71e 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -854,7 +854,7 @@ EXCLUDE_PATTERNS = ###################################################### EXCLUDE_SYMBOLS = mraheader_t mrapeerstate_t mrmailbox_e2ee_helper_t mrimap_t mrjob_t mrkey_t mrkeyring_t mrloginparam_t mrmime*_t EXCLUDE_SYMBOLS += mrsaxparser_t mrsimplify_t mrsmtp_t mrsqlite3_t mrstrbuilder_t mrparam_t mrhash_t mrhashelem_t -EXCLUDE_SYMBOLS += _mrchat _mrchatlist _mrcontact _mrmsg _mrmailbox _mrlot _mrarray +EXCLUDE_SYMBOLS += _dc_chat _dc_chatlist _dc_contact _dc_msg _dc_context _dc_lot _dc_array ###################################################### # The EXAMPLE_PATH tag can be used to specify one or more files or directories diff --git a/src/deltachat.h b/src/deltachat.h index 72ce1ba9..40fda9ea 100644 --- a/src/deltachat.h +++ b/src/deltachat.h @@ -173,7 +173,7 @@ typedef struct _dc_lot dc_lot_t; * * @memberof dc_context_t * - * @param mailbox the mailbox object as returned by dc_context_new(). + * @param context The context object as returned by dc_context_new(). * * @param event one of the DC_EVENT_* constants as defined in dc_event.h * @@ -366,7 +366,7 @@ size_t dc_chatlist_get_cnt (dc_chatlist_t*); uint32_t dc_chatlist_get_chat_id (dc_chatlist_t*, size_t index); uint32_t dc_chatlist_get_msg_id (dc_chatlist_t*, size_t index); dc_lot_t* dc_chatlist_get_summary (dc_chatlist_t*, size_t index, dc_chat_t*); -dc_context_t* dc_chatlist_get_mailbox (dc_chatlist_t*); +dc_context_t* dc_chatlist_get_context (dc_chatlist_t*); /** @@ -511,7 +511,7 @@ int dc_contact_is_verified (const dc_contact_t*); * @class dc_lot_t * * An object containing a set of values. The meaning of the values is defined by the function returning the set object. - * Set objects are created eg. by mrchatlist_get_summary(), mrmsg_get_summary() or by mrmsg_get_mediainfo(). + * Set objects are created eg. by dc_chatlist_get_summary(), dc_msg_get_summary() or by dc_msg_get_mediainfo(). * * NB: _Lot_ is used in the meaning _heap_ here. */ diff --git a/src/mrarray.c b/src/mrarray.c index 182b1994..1056c5e8 100644 --- a/src/mrarray.c +++ b/src/mrarray.c @@ -29,14 +29,14 @@ /** * Create an array object in memory. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param mailbox The mailbox object that should be stored in the array object. May be NULL. * @param initsize Initial maximal size of the array. If you add more items, the internal data pointer is reallocated. * * @return New array object of the requested size, the data should be set directly. */ -mrarray_t* mrarray_new(mrmailbox_t* mailbox, size_t initsize) +dc_array_t* dc_array_new(dc_context_t* mailbox, size_t initsize) { mrarray_t* array; @@ -61,14 +61,14 @@ mrarray_t* mrarray_new(mrmailbox_t* mailbox, size_t initsize) /** * Free an array object. Does not free any data items. * - * @memberof mrarray_t + * @memberof dc_array_t * - * @param array The array object to free, created eg. by mrmailbox_get_chatlist(), mrmailbox_get_contacts() and so on. + * @param array The array object to free, created eg. by dc_get_chatlist(), dc_get_contacts() and so on. * * @return None. * */ -void mrarray_unref(mrarray_t* array) +void dc_array_unref(dc_array_t* array) { if( array==NULL || array->m_magic != MR_ARRAY_MAGIC ) { return; @@ -84,14 +84,14 @@ void mrarray_unref(mrarray_t* array) * Calls free() for each item and sets the item to 0 afterwards. * The array object itself is not deleted and the size of the array stays the same. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object. * * @return None. * */ -void mrarray_free_ptr(mrarray_t* array) +void mrarray_free_ptr(dc_array_t* array) { size_t i; @@ -110,14 +110,14 @@ void mrarray_free_ptr(mrarray_t* array) * Duplicates the array, take care if the array contains pointers to objects, take care to free them only once afterwards! * If the array only contains integers, you are always save. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object. * * @return The duplicated array. * */ -mrarray_t* mrarray_duplicate(const mrarray_t* array) +mrarray_t* mrarray_duplicate(const dc_array_t* array) { mrarray_t* ret = NULL; @@ -143,14 +143,14 @@ static int cmp_intptr_t(const void* p1, const void* p2) /** * Sort the array, assuming it contains unsigned integers. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object. * * @return The duplicated array. * */ -void mrarray_sort_ids(mrarray_t* array) +void mrarray_sort_ids(dc_array_t* array) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC || array->m_count <= 1 ) { return; @@ -170,14 +170,14 @@ static int cmp_strings_t(const void* p1, const void* p2) /** * Sort the array, assuming it contains pointers to strings. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object. * * @return The duplicated array. * */ -void mrarray_sort_strings(mrarray_t* array) +void mrarray_sort_strings(dc_array_t* array) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC || array->m_count <= 1 ) { return; @@ -189,13 +189,13 @@ void mrarray_sort_strings(mrarray_t* array) /** * Empty an array object. Allocated data is not freed by this function, only the count is set to null. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object to empty. * * @return None. */ -void mrarray_empty(mrarray_t* array) +void dc_array_empty(dc_array_t* array) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC ) { return; @@ -216,7 +216,7 @@ void mrarray_empty(mrarray_t* array) * * @return None. */ -void mrarray_add_uint(mrarray_t* array, uintptr_t item) +void dc_array_add_uint(dc_array_t* array, uintptr_t item) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC ) { return; @@ -246,7 +246,7 @@ void mrarray_add_uint(mrarray_t* array, uintptr_t item) * * @return None. */ -void mrarray_add_id(mrarray_t* array, uint32_t item) +void dc_array_add_id(dc_array_t* array, uint32_t item) { mrarray_add_uint(array, item); } @@ -263,7 +263,7 @@ void mrarray_add_id(mrarray_t* array, uint32_t item) * * @return None. */ -void mrarray_add_ptr(mrarray_t* array, void* item) +void dc_array_add_ptr(dc_array_t* array, void* item) { mrarray_add_uint(array, (uintptr_t)item); } @@ -272,13 +272,13 @@ void mrarray_add_ptr(mrarray_t* array, void* item) /** * Find out the number of items in an array. * - * @memberof mrarray_t + * @memberof dc_array_t * * @param array The array object. * - * @return Returns the number of items in a mrarray_t object. 0 on errors or if the array is empty. + * @return Returns the number of items in a dc_array_t object. 0 on errors or if the array is empty. */ -size_t mrarray_get_cnt(const mrarray_t* array) +size_t dc_array_get_cnt(const dc_array_t* array) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC ) { return 0; @@ -292,14 +292,14 @@ size_t mrarray_get_cnt(const mrarray_t* array) * Get the item at the given index as an unsigned integer. * The size of the integer is always larget enough to hold a pointer. * - * @memberof mrarray_t + * @memberof dc_array_t * * @param array The array object. - * @param index Index of the item to get. Must be between 0 and mrarray_get_cnt()-1. + * @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. * * @return Returns the item at the given index. Returns 0 on errors or if the array is empty. */ -uintptr_t mrarray_get_uint(const mrarray_t* array, size_t index) +uintptr_t dc_array_get_uint(const dc_array_t* array, size_t index) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC || index < 0 || index >= array->m_count ) { return 0; @@ -312,14 +312,14 @@ uintptr_t mrarray_get_uint(const mrarray_t* array, size_t index) /** * Get the item at the given index as an ID. * - * @memberof mrarray_t + * @memberof dc_array_t * * @param array The array object. - * @param index Index of the item to get. Must be between 0 and mrarray_get_cnt()-1. + * @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. * * @return Returns the item at the given index. Returns 0 on errors or if the array is empty. */ -uint32_t mrarray_get_id(const mrarray_t* array, size_t index) +uint32_t dc_array_get_id(const dc_array_t* array, size_t index) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC || index < 0 || index >= array->m_count ) { return 0; @@ -332,14 +332,14 @@ uint32_t mrarray_get_id(const mrarray_t* array, size_t index) /** * Get the item at the given index as an ID. * - * @memberof mrarray_t + * @memberof dc_array_t * * @param array The array object. - * @param index Index of the item to get. Must be between 0 and mrarray_get_cnt()-1. + * @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. * * @return Returns the item at the given index. Returns 0 on errors or if the array is empty. */ -void* mrarray_get_ptr(const mrarray_t* array, size_t index) +void* dc_array_get_ptr(const dc_array_t* array, size_t index) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC || index < 0 || index >= array->m_count ) { return 0; @@ -352,7 +352,7 @@ void* mrarray_get_ptr(const mrarray_t* array, size_t index) /** * Check if a given ID is present in an array. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object to search in. * @param needle The ID to search for. @@ -360,7 +360,7 @@ void* mrarray_get_ptr(const mrarray_t* array, size_t index) * * @return 1=ID is present in array, 0=ID not found. */ -int mrarray_search_id(const mrarray_t* array, uint32_t needle, size_t* ret_index) +int dc_array_search_id(const dc_array_t* array, uint32_t needle, size_t* ret_index) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC ) { return 0; @@ -385,14 +385,14 @@ int mrarray_search_id(const mrarray_t* array, uint32_t needle, size_t* ret_index /** * Get raw pointer to the data. * - * @private @memberof mrarray_t + * @private @memberof dc_array_t * * @param array The array object. * * @return Raw pointer to the array. You MUST NOT free the data. You MUST NOT access the data beyond the current item count. - * It is not possible to enlarge the array this way. Calling any other mrarray-function may discard the returned pointer. + * It is not possible to enlarge the array this way. Calling any other dc_array-function may discard the returned pointer. */ -const uintptr_t* mrarray_get_raw(const mrarray_t* array) +const uintptr_t* dc_array_get_raw(const dc_array_t* array) { if( array == NULL || array->m_magic != MR_ARRAY_MAGIC ) { return NULL; @@ -431,7 +431,7 @@ char* mr_arr_to_string(const uint32_t* arr, int cnt) } -char* mrarray_get_string(const mrarray_t* array, const char* sep) +char* mrarray_get_string(const dc_array_t* array, const char* sep) { char* ret = NULL; diff --git a/src/mrchat.c b/src/mrchat.c index 34846a55..999329c6 100644 --- a/src/mrchat.c +++ b/src/mrchat.c @@ -33,17 +33,17 @@ /** * Create a chat object in memory. * - * @private @memberof mrchat_t + * @private @memberof dc_chat_t * * @param mailbox The mailbox object that should be stored in the chat object. * - * @return New and empty chat object, must be freed using mrchat_unref(). + * @return New and empty chat object, must be freed using dc_chat_unref(). */ -mrchat_t* mrchat_new(mrmailbox_t* mailbox) +dc_chat_t* dc_chat_new(dc_context_t* mailbox) { - mrchat_t* ths = NULL; + dc_chat_t* ths = NULL; - if( mailbox == NULL || (ths=calloc(1, sizeof(mrchat_t)))==NULL ) { + if( mailbox == NULL || (ths=calloc(1, sizeof(dc_chat_t)))==NULL ) { exit(14); /* cannot allocate little memory, unrecoverable error */ } @@ -59,13 +59,13 @@ mrchat_t* mrchat_new(mrmailbox_t* mailbox) /** * Free a chat object. * - * @memberof mrchat_t + * @memberof dc_chat_t * - * @param chat Chat object are returned eg. by mrmailbox_get_chat(). + * @param chat Chat object are returned eg. by dc_get_chat(). * * @return None. */ -void mrchat_unref(mrchat_t* chat) +void dc_chat_unref(dc_chat_t* chat) { if( chat==NULL || chat->m_magic != MR_CHAT_MAGIC ) { return; @@ -81,13 +81,13 @@ void mrchat_unref(mrchat_t* chat) /** * Empty a chat object. * - * @private @memberof mrchat_t + * @private @memberof dc_chat_t * * @param chat The chat object to empty. * * @return None. */ -void mrchat_empty(mrchat_t* chat) +void dc_chat_empty(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return; @@ -122,19 +122,19 @@ void mrchat_empty(mrchat_t* chat) * Get chat ID. The chat ID is the ID under which the chat is filed in the database. * * Special IDs: - * - MR_CHAT_ID_DEADDROP (1) - Virtual chat containing messages which senders are not confirmed by the user. - * - MR_CHAT_ID_STARRED (5) - Virtual chat containing all starred messages- - * - MR_CHAT_ID_ARCHIVED_LINK (6) - A link at the end of the chatlist, if present the UI should show the button "Archived chats"- + * - DC_CHAT_ID_DEADDROP (1) - Virtual chat containing messages which senders are not confirmed by the user. + * - DC_CHAT_ID_STARRED (5) - Virtual chat containing all starred messages- + * - DC_CHAT_ID_ARCHIVED_LINK (6) - A link at the end of the chatlist, if present the UI should show the button "Archived chats"- * - * "Normal" chat IDs are larger than these special IDs (larger than MR_CHAT_ID_LAST_SPECIAL). + * "Normal" chat IDs are larger than these special IDs (larger than DC_CHAT_ID_LAST_SPECIAL). * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Chat ID. 0 on errors. */ -uint32_t mrchat_get_id(mrchat_t* chat) +uint32_t dc_chat_get_id(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -149,24 +149,23 @@ uint32_t mrchat_get_id(mrchat_t* chat) * * Currently, there are two chat types: * - * - MR_CHAT_TYPE_SINGLE (100) - a normal chat is a chat with a single contact, - * chats_contacts contains one record for the user. MR_CONTACT_ID_SELF - * (see mrcontact_t::m_id) is added _only_ for a self talk; in addition to - * this, for self talks also the flag MRP_SELFTALK is set. + * - DC_CHAT_TYPE_SINGLE (100) - a normal chat is a chat with a single contact, + * chats_contacts contains one record for the user. DC_CONTACT_ID_SELF + * (see dc_contact_t::m_id) is added _only_ for a self talk. * - * - MR_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts conain all group - * members, incl. MR_CONTACT_ID_SELF + * - DC_CHAT_TYPE_GROUP (120) - a group chat, chats_contacts conain all group + * members, incl. DC_CONTACT_ID_SELF * - * - MR_CHAT_TYPE_VERIFIED_GROUP (130) - a verified group chat. In verified groups, + * - DC_CHAT_TYPE_VERIFIED_GROUP (130) - a verified group chat. In verified groups, * all members are verified and encryption is always active and cannot be disabled. * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Chat type. */ -int mrchat_get_type(mrchat_t* chat) +int dc_chat_get_type(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return MR_CHAT_TYPE_UNDEFINED; @@ -177,20 +176,20 @@ int mrchat_get_type(mrchat_t* chat) /** * Get name of a chat. For one-to-one chats, this is the name of the contact. - * For group chats, this is the name given eg. to mrmailbox_create_group_chat() or + * For group chats, this is the name given eg. to dc_create_group_chat() or * received by a group-creation message. * - * To change the name, use mrmailbox_set_chat_name() + * To change the name, use dc_set_chat_name() * - * See also: mrchat_get_subtitle() + * See also: dc_chat_get_subtitle() * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Chat name as a string. Must be free()'d after usage. Never NULL. */ -char* mrchat_get_name(mrchat_t* chat) +char* dc_chat_get_name(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return safe_strdup("Err"); @@ -204,15 +203,15 @@ char* mrchat_get_name(mrchat_t* chat) * Get a subtitle for a chat. The subtitle is eg. the email-address or the * number of group members. * - * See also: mrchat_get_name() + * See also: dc_chat_get_name() * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object to calulate the subtitle for. * * @return Subtitle as a string. Must be free()'d after usage. Never NULL. */ -char* mrchat_get_subtitle(mrchat_t* chat) +char* dc_chat_get_subtitle(dc_chat_t* chat) { /* returns either the address or the number of chat members */ char* ret = NULL; @@ -268,17 +267,17 @@ char* mrchat_get_subtitle(mrchat_t* chat) /** * Get the chat's profile image. - * The profile image is set using mrmailbox_set_chat_profile_image() for groups. - * For normal chats, the profile image is set using mrmailbox_set_contact_profile_image() (not yet implemented). + * The profile image is set using dc_set_chat_profile_image() for groups. + * For normal chats, the profile image is set using dc_set_contact_profile_image() (not yet implemented). * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Path and file if the profile image, if any. NULL otherwise. * Must be free()'d after usage. */ -char* mrchat_get_profile_image(mrchat_t* chat) +char* dc_chat_get_profile_image(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return NULL; @@ -290,18 +289,18 @@ char* mrchat_get_profile_image(mrchat_t* chat) /** * Get draft for the chat, if any. A draft is a message that the user started to - * compose but that is not sent yet. You can save a draft for a chat using mrmailbox_set_draft(). + * compose but that is not sent yet. You can save a draft for a chat using dc_set_draft(). * * Drafts are considered when sorting messages and are also returned eg. - * by mrchatlist_get_summary(). + * by dc_chatlist_get_summary(). * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Draft text, must be free()'d. Returns NULL if there is no draft. */ -char* mrchat_get_draft(mrchat_t* chat) +char* dc_chat_get_draft(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return NULL; @@ -314,15 +313,15 @@ char* mrchat_get_draft(mrchat_t* chat) /** * Get timestamp of the draft. * - * The draft itself can be get using mrchat_get_draft(). + * The draft itself can be get using dc_chat_get_draft(). * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Timestamp of the draft. 0 if there is no draft. */ -time_t mrchat_get_draft_timestamp(mrchat_t* chat) +time_t dc_chat_get_draft_timestamp(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -338,17 +337,17 @@ time_t mrchat_get_draft_timestamp(mrchat_t* chat) * - 1 = chat archived * - 2 = chat sticky (reserved for future use, if you do not support this value, just treat the chat as a normal one) * - * To archive or unarchive chats, use mrmailbox_archive_chat(). + * To archive or unarchive chats, use dc_archive_chat(). * If chats are archived, this should be shown in the UI by a little icon or text, * eg. the search will also return archived chats. * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return Archived state. */ -int mrchat_get_archived(mrchat_t* chat) +int dc_chat_get_archived(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -362,17 +361,17 @@ int mrchat_get_archived(mrchat_t* chat) * message is sent. With unpromoted chats, members can be sent, settings can be * modified without the need of special status messages being sent. * - * After the creation with mrmailbox_create_group_chat() the chat is usuall unpromoted - * until the first call to mrmailbox_send_msg() or mrmailbox_send_text_msg(). + * After the creation with dc_create_group_chat() the chat is usuall unpromoted + * until the first call to dc_send_msg() or dc_send_text_msg(). * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return 1=chat is still unpromoted, no message was ever send to the chat, * 0=chat is not unpromoted, messages were send and/or received */ -int mrchat_is_unpromoted(mrchat_t* chat) +int dc_chat_is_unpromoted(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -384,15 +383,15 @@ int mrchat_is_unpromoted(mrchat_t* chat) /** * Check if a chat is verified. Verified chats contain only verified members * and encryption is alwasy enabled. Verified chats are created using - * mrmailbox_create_group_chat() by setting the 'verified' parameter to true. + * dc_create_group_chat() by setting the 'verified' parameter to true. * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return 1=chat verified, 0=chat is not verified */ -int mrchat_is_verified(mrchat_t* chat) +int dc_chat_is_verified(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -401,7 +400,7 @@ int mrchat_is_verified(mrchat_t* chat) } -int mrchat_are_all_members_verified__(mrchat_t* chat) +int mrchat_are_all_members_verified__(dc_chat_t* chat) { int chat_verified = 0; sqlite3_stmt* stmt; @@ -441,15 +440,15 @@ cleanup: /** * Check if a chat is a self talk. Self talks are normal chats with - * the only contact MR_CONTACT_ID_SELF. + * the only contact DC_CONTACT_ID_SELF. * - * @memberof mrchat_t + * @memberof dc_chat_t * * @param chat The chat object. * * @return 1=chat is self talk, 0=chat is no self talk */ -int mrchat_is_self_talk(mrchat_t* chat) +int dc_chat_is_self_talk(dc_chat_t* chat) { if( chat == NULL || chat->m_magic != MR_CHAT_MAGIC ) { return 0; @@ -463,7 +462,7 @@ int mrchat_is_self_talk(mrchat_t* chat) ******************************************************************************/ -int mrchat_update_param__(mrchat_t* ths) +int mrchat_update_param__(dc_chat_t* ths) { int success = 0; sqlite3_stmt* stmt = mrsqlite3_prepare_v2_(ths->m_mailbox->m_sql, "UPDATE chats SET param=? WHERE id=?"); @@ -475,7 +474,7 @@ int mrchat_update_param__(mrchat_t* ths) } -static int mrchat_set_from_stmt__(mrchat_t* ths, sqlite3_stmt* row) +static int mrchat_set_from_stmt__(dc_chat_t* ths, sqlite3_stmt* row) { int row_offset = 0; const char* draft_text; @@ -535,16 +534,16 @@ static int mrchat_set_from_stmt__(mrchat_t* ths, sqlite3_stmt* row) * * Calling this function is not thread-safe, locking is up to the caller. * - * @private @memberof mrchat_t + * @private @memberof dc_chat_t * * @param chat The chat object that should be filled with the data from the database. - * Existing data are free()'d before using mrchat_empty(). + * Existing data are free()'d before using dc_chat_empty(). * * @param chat_id Chat ID that should be loaded from the database. * * @return 1=success, 0=error. */ -int mrchat_load_from_db__(mrchat_t* chat, uint32_t chat_id) +int mrchat_load_from_db__(dc_chat_t* chat, uint32_t chat_id) { sqlite3_stmt* stmt; diff --git a/src/mrchatlist.c b/src/mrchatlist.c index a81a77da..687e18dd 100644 --- a/src/mrchatlist.c +++ b/src/mrchatlist.c @@ -28,17 +28,17 @@ /** * Create a chatlist object in memory. * - * @private @memberof mrchatlist_t + * @private @memberof dc_chatlist_t * * @param mailbox The mailbox object that should be stored in the chatlist object. * - * @return New and empty chatlist object, must be freed using mrchatlist_unref(). + * @return New and empty chatlist object, must be freed using dc_chatlist_unref(). */ -mrchatlist_t* mrchatlist_new(mrmailbox_t* mailbox) +dc_chatlist_t* dc_chatlist_new(dc_context_t* mailbox) { - mrchatlist_t* ths = NULL; + dc_chatlist_t* ths = NULL; - if( (ths=calloc(1, sizeof(mrchatlist_t)))==NULL ) { + if( (ths=calloc(1, sizeof(dc_chatlist_t)))==NULL ) { exit(20); } @@ -55,14 +55,14 @@ mrchatlist_t* mrchatlist_new(mrmailbox_t* mailbox) /** * Free a chatlist object. * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * - * @param chatlist The chatlist object to free, created eg. by mrmailbox_get_chatlist(), mrmailbox_search_msgs(). + * @param chatlist The chatlist object to free, created eg. by dc_get_chatlist(), dc_search_msgs(). * * @return None. * */ -void mrchatlist_unref(mrchatlist_t* chatlist) +void dc_chatlist_unref(dc_chatlist_t* chatlist) { if( chatlist==NULL || chatlist->m_magic != MR_CHATLIST_MAGIC ) { return; @@ -78,13 +78,13 @@ void mrchatlist_unref(mrchatlist_t* chatlist) /** * Empty a chatlist object. * - * @private @memberof mrchatlist_t + * @private @memberof dc_chatlist_t * * @param chatlist The chatlist object to empty. * * @return None. */ -void mrchatlist_empty(mrchatlist_t* chatlist) +void dc_chatlist_empty(dc_chatlist_t* chatlist) { if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC ) { return; @@ -98,13 +98,13 @@ void mrchatlist_empty(mrchatlist_t* chatlist) /** * Find out the number of chats in a chatlist. * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * - * @param chatlist The chatlist object as created eg. by mrmailbox_get_chatlist(). + * @param chatlist The chatlist object as created eg. by dc_get_chatlist(). * - * @return Returns the number of items in a mrchatlist_t object. 0 on errors or if the list is empty. + * @return Returns the number of items in a dc_chatlist_t object. 0 on errors or if the list is empty. */ -size_t mrchatlist_get_cnt(mrchatlist_t* chatlist) +size_t dc_chatlist_get_cnt(dc_chatlist_t* chatlist) { if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC ) { return 0; @@ -117,18 +117,18 @@ size_t mrchatlist_get_cnt(mrchatlist_t* chatlist) /** * Get a single chat ID of a chatlist. * - * To get the message object from the message ID, use mrmailbox_get_chat(). + * To get the message object from the message ID, use dc_get_chat(). * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * - * @param chatlist The chatlist object as created eg. by mrmailbox_get_chatlist(). + * @param chatlist The chatlist object as created eg. by dc_get_chatlist(). * * @param index The index to get the chat ID for. * * @return Returns the chat_id of the item at the given index. Index must be between - * 0 and mrchatlist_get_cnt()-1. + * 0 and dc_chatlist_get_cnt()-1. */ -uint32_t mrchatlist_get_chat_id(mrchatlist_t* chatlist, size_t index) +uint32_t dc_chatlist_get_chat_id(dc_chatlist_t* chatlist, size_t index) { if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC || chatlist->m_chatNlastmsg_ids == NULL || index >= chatlist->m_cnt ) { return 0; @@ -141,18 +141,18 @@ uint32_t mrchatlist_get_chat_id(mrchatlist_t* chatlist, size_t index) /** * Get a single message ID of a chatlist. * - * To get the message object from the message ID, use mrmailbox_get_msg(). + * To get the message object from the message ID, use dc_get_msg(). * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * - * @param chatlist The chatlist object as created eg. by mrmailbox_get_chatlist(). + * @param chatlist The chatlist object as created eg. by dc_get_chatlist(). * * @param index The index to get the chat ID for. * * @return Returns the message_id of the item at the given index. Index must be between - * 0 and mrchatlist_get_cnt()-1. If there is no message at the given index (eg. the chat may be empty), 0 is returned. + * 0 and dc_chatlist_get_cnt()-1. If there is no message at the given index (eg. the chat may be empty), 0 is returned. */ -uint32_t mrchatlist_get_msg_id(mrchatlist_t* chatlist, size_t index) +uint32_t dc_chatlist_get_msg_id(dc_chatlist_t* chatlist, size_t index) { if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC || chatlist->m_chatNlastmsg_ids == NULL || index >= chatlist->m_cnt ) { return 0; @@ -165,32 +165,32 @@ uint32_t mrchatlist_get_msg_id(mrchatlist_t* chatlist, size_t index) /** * Get a summary for a chatlist index. * - * The summary is returned by a mrlot_t object with the following fields: + * The summary is returned by a dc_lot_t object with the following fields: * - * - mrlot_t::m_text1: contains the username or the strings "Me", "Draft" and so on. + * - dc_lot_t::m_text1: contains the username or the strings "Me", "Draft" and so on. * The string may be colored by having a look at m_text1_meaning. * If there is no such name or it should not be displayed, the element is NULL. * - * - mrlot_t::m_text1_meaning: one of MR_TEXT1_USERNAME, MR_TEXT1_SELF or MR_TEXT1_DRAFT. - * Typically used to show mrlot_t::m_text1 with different colors. 0 if not applicable. + * - dc_lot_t::m_text1_meaning: one of DC_TEXT1_USERNAME, DC_TEXT1_SELF or DC_TEXT1_DRAFT. + * Typically used to show dc_lot_t::m_text1 with different colors. 0 if not applicable. * - * - mrlot_t::m_text2: contains an excerpt of the message text or strings as + * - dc_lot_t::m_text2: contains an excerpt of the message text or strings as * "No messages". May be NULL of there is no such text (eg. for the archive link) * - * - mrlot_t::m_timestamp: the timestamp of the message. 0 if not applicable. + * - dc_lot_t::m_timestamp: the timestamp of the message. 0 if not applicable. * - * - mrlot_t::m_state: The state of the message as one of the MR_STATE_* constants (see #mrmsg_get_state()). 0 if not applicable. + * - dc_lot_t::m_state: The state of the message as one of the DC_STATE_* constants (see #dc_msg_get_state()). 0 if not applicable. * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * - * @param chatlist The chatlist to query as returned eg. from mrmailbox_get_chatlist(). + * @param chatlist The chatlist to query as returned eg. from dc_get_chatlist(). * @param index The index to query in the chatlist. * @param chat To speed up things, pass an already available chat object here. * If the chat object is not yet available, it is faster to pass NULL. * - * @return The summary as an mrlot_t object. Must be freed using mrlot_unref(). NULL is never returned. + * @return The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned. */ -mrlot_t* mrchatlist_get_summary(mrchatlist_t* chatlist, size_t index, mrchat_t* chat /*may be NULL*/) +dc_lot_t* dc_chatlist_get_summary(dc_chatlist_t* chatlist, size_t index, dc_chat_t* chat /*may be NULL*/) { /* The summary is created by the chat, not by the last message. This is because we may want to display drafts here or stuff as @@ -282,13 +282,13 @@ cleanup: /** * Helper function to get the associated mailbox object. * - * @memberof mrchatlist_t + * @memberof dc_chatlist_t * * @param chatlist The chatlist object to empty. * * @return Mailbox object associated with the chatlist. NULL if none or on errors. */ -mrmailbox_t* mrchatlist_get_mailbox(mrchatlist_t* chatlist) +dc_context_t* dc_chatlist_get_context(dc_chatlist_t* chatlist) { if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC ) { return NULL; @@ -302,9 +302,9 @@ mrmailbox_t* mrchatlist_get_mailbox(mrchatlist_t* chatlist) * * Calling this function is not thread-safe, locking is up to the caller. * - * @private @memberof mrchatlist_t + * @private @memberof dc_chatlist_t */ -int mrchatlist_load_from_db__(mrchatlist_t* ths, int listflags, const char* query__, uint32_t query_contact_id) +int mrchatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* query__, uint32_t query_contact_id) { //clock_t start = clock(); diff --git a/src/mrcontact.c b/src/mrcontact.c index 880e7c0f..bb9cf838 100644 --- a/src/mrcontact.c +++ b/src/mrcontact.c @@ -30,17 +30,17 @@ /** * Create a new contact object in memory. * Typically the user does not call this function directly but gets contact - * objects using mrmailbox_get_contact(). + * objects using dc_get_contact(). * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t * - * @return The contact object. Must be freed using mrcontact_unref() when done. + * @return The contact object. Must be freed using dc_contact_unref() when done. */ -mrcontact_t* mrcontact_new(mrmailbox_t* mailbox) +dc_contact_t* dc_contact_new(dc_context_t* mailbox) { - mrcontact_t* ths = NULL; + dc_contact_t* ths = NULL; - if( (ths=calloc(1, sizeof(mrcontact_t)))==NULL ) { + if( (ths=calloc(1, sizeof(dc_contact_t)))==NULL ) { exit(19); /* cannot allocate little memory, unrecoverable error */ } @@ -54,13 +54,13 @@ mrcontact_t* mrcontact_new(mrmailbox_t* mailbox) /** * Free a contact object. * - * @memberof mrcontact_t + * @memberof dc_contact_t * - * @param contact The contact object as created eg. by mrmailbox_get_contact(). + * @param contact The contact object as created eg. by dc_get_contact(). * * @return None. */ -void mrcontact_unref(mrcontact_t* contact) +void dc_contact_unref(dc_contact_t* contact) { if( contact==NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return; @@ -75,15 +75,15 @@ void mrcontact_unref(mrcontact_t* contact) /** * Empty a contact object. * Typically not needed by the user of the library. To free a contact object, - * use mrcontact_unref(). + * use dc_contact_unref(). * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t * * @param contact The contact object to free. * * @return None. */ -void mrcontact_empty(mrcontact_t* contact) +void dc_contact_empty(dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return; @@ -113,13 +113,13 @@ void mrcontact_empty(mrcontact_t* contact) /** * Get the ID of the contact. * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return the ID of the contact, 0 on errors. */ -uint32_t mrcontact_get_id(const mrcontact_t* contact) +uint32_t dc_contact_get_id(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return 0; @@ -131,13 +131,13 @@ uint32_t mrcontact_get_id(const mrcontact_t* contact) /** * Get email address. The email address is always set for a contact. * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return String with the email address, must be free()'d. Never returns NULL. */ -char* mrcontact_get_addr(const mrcontact_t* contact) +char* dc_contact_get_addr(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return safe_strdup(NULL); @@ -153,15 +153,15 @@ char* mrcontact_get_addr(const mrcontact_t* contact) * * This name is typically used in a form where the user can edit the name of a contact. * This name must not be spreaded via mail (To:, CC: ...) as it as it may be sth. like "Daddy". - * To get a fine name to display in lists etc., use mrcontact_get_display_name() or mrcontact_get_name_n_addr(). + * To get a fine name to display in lists etc., use dc_contact_get_display_name() or dc_contact_get_name_n_addr(). * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return String with the name to display, must be free()'d. Empty string if unset, never returns NULL. */ -char* mrcontact_get_name(const mrcontact_t* contact) +char* dc_contact_get_name(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return safe_strdup(NULL); @@ -176,15 +176,15 @@ char* mrcontact_get_name(const mrcontact_t* contact) * modified by the user or, if both are unset, the email address. * * This name is typically used in lists and must not be speaded via mail (To:, CC: ...). - * To get the name editable in a formular, use mrcontact_get_name(). + * To get the name editable in a formular, use dc_contact_get_name(). * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return String with the name to display, must be free()'d. Never returns NULL. */ -char* mrcontact_get_display_name(const mrcontact_t* contact) +char* dc_contact_get_display_name(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return safe_strdup(NULL); @@ -209,13 +209,13 @@ char* mrcontact_get_display_name(const mrcontact_t* contact) * * The summary must not be spreaded via mail (To:, CC: ...) as it as it may contain sth. like "Daddy". * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return Summary string, must be free()'d. Never returns NULL. */ -char* mrcontact_get_name_n_addr(const mrcontact_t* contact) +char* dc_contact_get_name_n_addr(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return safe_strdup(NULL); @@ -234,13 +234,13 @@ char* mrcontact_get_name_n_addr(const mrcontact_t* contact) * the prename. If there is no space, the full display name is returned. * If the display name is not set, the e-mail address is returned. * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return String with the name to display, must be free()'d. Never returns NULL. */ -char* mrcontact_get_first_name(const mrcontact_t* contact) +char* dc_contact_get_first_name(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return safe_strdup(NULL); @@ -257,15 +257,15 @@ char* mrcontact_get_first_name(const mrcontact_t* contact) /** * Check if a contact is blocked. * - * To block or unblock a contact, use mrmailbox_block_contact(). + * To block or unblock a contact, use dc_block_contact(). * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * * @return 1=contact is blocked, 0=contact is not blocked. */ -int mrcontact_is_blocked(const mrcontact_t* contact) +int dc_contact_is_blocked(const dc_contact_t* contact) { if( contact == NULL || contact->m_magic != MR_CONTACT_MAGIC ) { return 0; @@ -274,7 +274,7 @@ int mrcontact_is_blocked(const mrcontact_t* contact) } -int mrcontact_is_verified__(const mrcontact_t* contact, const mrapeerstate_t* peerstate) +int mrcontact_is_verified__(const dc_contact_t* contact, const mrapeerstate_t* peerstate) { int contact_verified = MRV_NOT_VERIFIED; @@ -300,14 +300,14 @@ cleanup: * * The UI may draw a checkbox or sth. like that beside verified contacts. * - * @memberof mrcontact_t + * @memberof dc_contact_t * * @param contact The contact object. * - * @return MRV_NOT_VERIFIED (0): contact is not verified. - * MRV_BIDIRECTIONAL (2): SELF and contact have verified their fingerprints in both directions; in the UI typically checkmarks are shown. + * @return 0: contact is not verified. + * 2: SELF and contact have verified their fingerprints in both directions; in the UI typically checkmarks are shown. */ -int mrcontact_is_verified(const mrcontact_t* contact) +int dc_contact_is_verified(const dc_contact_t* contact) { int contact_verified = MRV_NOT_VERIFIED; int locked = 0; @@ -341,7 +341,7 @@ cleanup: * In a string, get the part before the first space. * If there is no space in the string, the whole string is returned. * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t * * @param full_name Full name of the contact. * @@ -378,7 +378,7 @@ char* mr_get_first_name(const char* full_name) * * Typically, this function is not needed as it is called implicitly by mrmailbox_add_address_book() * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t * * @param full_name Buffer with the name, is modified during processing; the * resulting string may be shorter but never longer. @@ -431,7 +431,7 @@ void mr_normalize_name(char* full_name) * Not sure if we should also unifiy international characters before the @, * see also https://autocrypt.readthedocs.io/en/latest/address-canonicalization.html * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t * * @param email_addr__ The email address to normalize. * @@ -456,9 +456,9 @@ char* mr_normalize_addr(const char* email_addr__) * * Calling this function is not thread-safe, locking is up to the caller. * - * @private @memberof mrcontact_t + * @private @memberof dc_contact_t */ -int mrcontact_load_from_db__(mrcontact_t* ths, mrsqlite3_t* sql, uint32_t contact_id) +int mrcontact_load_from_db__(dc_contact_t* ths, mrsqlite3_t* sql, uint32_t contact_id) { int success = 0; sqlite3_stmt* stmt; diff --git a/src/mrjob.c b/src/mrjob.c index 14e8eab9..799af6dc 100644 --- a/src/mrjob.c +++ b/src/mrjob.c @@ -669,11 +669,11 @@ cleanup: /** * Execute pending jobs. * - * @memberof mrmailbox_t + * @memberof dc_context_t * @param mailbox The mailbox object. * @return None */ -void dc_perform_imap_jobs(mrmailbox_t* mailbox) +void dc_perform_imap_jobs(dc_context_t* mailbox) { mrmailbox_log_info(mailbox, 0, "IMAP-jobs started..."); @@ -690,11 +690,11 @@ void dc_perform_imap_jobs(mrmailbox_t* mailbox) /** * Poll for new messages. * - * @memberof mrmailbox_t + * @memberof dc_context_t * @param mailbox The mailbox object. * @return None. */ -void dc_perform_imap_fetch(mrmailbox_t* mailbox) +void dc_perform_imap_fetch(dc_context_t* mailbox) { clock_t start = clock(); @@ -720,11 +720,11 @@ void dc_perform_imap_fetch(mrmailbox_t* mailbox) /** * Wait for messages. * - * @memberof mrmailbox_t + * @memberof dc_context_t * @param mailbox The mailbox object. * @return None. */ -void dc_perform_imap_idle(mrmailbox_t* mailbox) +void dc_perform_imap_idle(dc_context_t* mailbox) { connect_to_imap(mailbox, NULL); // also idle if connection fails because of not-configured, no-network, whatever. mrimap_idle() will handle this by the fake-idle and log a warning @@ -745,13 +745,13 @@ void dc_perform_imap_idle(mrmailbox_t* mailbox) /** - * Interrupt the mrmailbox_perform_imap_idle(). + * Interrupt dc_perform_imap_idle(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * @param mailbox The mailbox object. * @return None */ -void dc_interrupt_imap_idle(mrmailbox_t* mailbox) +void dc_interrupt_imap_idle(dc_context_t* mailbox) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || mailbox->m_imap == NULL ) { mrmailbox_log_warning(mailbox, 0, "Interrupt IMAP-IDLE: Bad parameters."); diff --git a/src/mrlot.c b/src/mrlot.c index 9ed5881d..8bb0074f 100644 --- a/src/mrlot.c +++ b/src/mrlot.c @@ -43,16 +43,16 @@ mrlot_t* mrlot_new() /** * Frees an object containing a set of parameters. * If the set object contains strings, the strings are also freed with this function. - * Set objects are created eg. by mrchatlist_get_summary(), mrmsg_get_summary or by - * mrmsg_get_mediainfo(). + * Set objects are created eg. by dc_chatlist_get_summary(), dc_msg_get_summary or by + * dc_msg_get_mediainfo(). * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param set The object to free. * * @return None */ -void mrlot_unref(mrlot_t* set) +void dc_lot_unref(dc_lot_t* set) { if( set==NULL || set->m_magic != MR_LOT_MAGIC ) { return; @@ -93,15 +93,15 @@ void mrlot_empty(mrlot_t* ths) /** - * Get first string. The meaning of the string is defined by the creator of the object and may be roughly described by mrlot_get_text1_meaning(). + * Get first string. The meaning of the string is defined by the creator of the object and may be roughly described by dc_lot_get_text1_meaning(). * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return A string, the string may be empty and the returned value must be free()'d. NULL if there is no such string. */ -char* mrlot_get_text1(mrlot_t* lot) +char* dc_lot_get_text1(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return NULL; @@ -113,13 +113,13 @@ char* mrlot_get_text1(mrlot_t* lot) /** * Get second string. The meaning of the string is defined by the creator of the object. * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return A string, the string may be empty and the returned value must be free()'d . NULL if there is no such string. */ -char* mrlot_get_text2(mrlot_t* lot) +char* dc_lot_get_text2(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return NULL; @@ -130,16 +130,16 @@ char* mrlot_get_text2(mrlot_t* lot) /** * Get the meaning of the first string. Posssible meanings of the string are defined by the creator of the object and may be returned eg. - * as MR_TEXT1_DRAFT, MR_TEXT1_USERNAME or MR_TEXT1_SELF. + * as DC_TEXT1_DRAFT, DC_TEXT1_USERNAME or DC_TEXT1_SELF. * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return Returns the meaning of the first string, possible meanings are defined by the creator of the object. * 0 if there is no concrete meaning or on errors. */ -int mrlot_get_text1_meaning(mrlot_t* lot) +int dc_lot_get_text1_meaning(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return 0; @@ -151,13 +151,13 @@ int mrlot_get_text1_meaning(mrlot_t* lot) /** * Get the associated state. The meaning of the state is defined by the creator of the object. * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return The state as defined by the creator of the object. 0 if there is not state or on errors. */ -int mrlot_get_state(mrlot_t* lot) +int dc_lot_get_state(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return 0; @@ -169,13 +169,13 @@ int mrlot_get_state(mrlot_t* lot) /** * Get the associated ID. The meaning of the ID is defined by the creator of the object. * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return The state as defined by the creator of the object. 0 if there is not state or on errors. */ -uint32_t mrlot_get_id(mrlot_t* lot) +uint32_t dc_lot_get_id(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return 0; @@ -187,13 +187,13 @@ uint32_t mrlot_get_id(mrlot_t* lot) /** * Get the associated timestamp. The meaning of the timestamp is defined by the creator of the object. * - * @memberof mrlot_t + * @memberof dc_lot_t * * @param lot The lot object. * * @return The timestamp as defined by the creator of the object. 0 if there is not timestamp or on errors. */ -time_t mrlot_get_timestamp(mrlot_t* lot) +time_t dc_lot_get_timestamp(dc_lot_t* lot) { if( lot == NULL || lot->m_magic != MR_LOT_MAGIC ) { return 0; diff --git a/src/mrmailbox.c b/src/mrmailbox.c index 3e9d35d4..97938f8d 100644 --- a/src/mrmailbox.c +++ b/src/mrmailbox.c @@ -70,23 +70,23 @@ static void cb_receive_imf(mrimap_t* imap, const char* imf_raw_not_terminated, s /** * Create a new mailbox object. After creation it is usually * opened, connected and mails are fetched. - * After usage, the object should be deleted using mrmailbox_unref(). + * After usage, the object should be deleted using dc_context_unref(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param cb a callback function that is called for events (update, * state changes etc.) and to get some information form the client (eg. translation * for a given string). * See mrevent.h for a list of possible events that may be passed to the callback. * - The callback MAY be called from _any_ thread, not only the main/GUI thread! - * - The callback MUST NOT call any mrmailbox_* and related functions unless stated + * - The callback MUST NOT call any dc_* and related functions unless stated * otherwise! * - The callback SHOULD return _fast_, for GUI updates etc. you should * post yourself an asynchronous message to your GUI thread, if needed. * - If not mentioned otherweise, the callback should return 0. * * @param userdata can be used by the client for any purpuse. He finds it - * later in mrmailbox_get_userdata(). + * later in dc_get_userdata(). * * @param os_name is only for decorative use and is shown eg. in the `X-Mailer:` header * in the form "Delta Chat for ". @@ -94,9 +94,9 @@ static void cb_receive_imf(mrimap_t* imap, const char* imf_raw_not_terminated, s * It is okay to give NULL, in this case `X-Mailer:` header is set to "Delta Chat ". * * @return a mailbox object with some public members the object must be passed to the other mailbox functions - * and the object must be freed using mrmailbox_unref() after usage. + * and the object must be freed using dc_context_unref() after usage. */ -mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userdata, const char* os_name) +dc_context_t* dc_context_new(dc_callback_t cb, void* userdata, const char* os_name) { mrmailbox_t* ths = NULL; @@ -145,13 +145,13 @@ mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userdata, const char* os_name * Free a mailbox object. * If app runs can only be terminated by a forced kill, this may be superfluous. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @return none */ -void mrmailbox_unref(mrmailbox_t* mailbox) +void dc_context_unref(dc_context_t* mailbox) { if( mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return; @@ -189,13 +189,13 @@ void mrmailbox_unref(mrmailbox_t* mailbox) /** * Get user data associated with a mailbox object. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * - * @return User data, this is the second parameter given to mrmailbox_new(). + * @return User data, this is the second parameter given to dc_context_new(). */ -void* mrmailbox_get_userdata(mrmailbox_t* mailbox) +void* dc_get_userdata(dc_context_t* mailbox) { if( mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return NULL; @@ -204,7 +204,7 @@ void* mrmailbox_get_userdata(mrmailbox_t* mailbox) } -static void update_config_cache__(mrmailbox_t* ths, const char* key) +static void update_config_cache__(dc_context_t* ths, const char* key) { if( key==NULL || strcmp(key, "e2ee_enabled")==0 ) { ths->m_e2ee_enabled = mrsqlite3_get_config_int__(ths->m_sql, "e2ee_enabled", MR_E2EE_DEFAULT_ENABLED); @@ -214,25 +214,23 @@ static void update_config_cache__(mrmailbox_t* ths, const char* key) /** * Open mailbox database. If the given file does not exist, it is - * created and can be set up using mrmailbox_set_config() afterwards. + * created and can be set up using dc_set_config() afterwards. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox: the mailbox object as created by mrmailbox_new + * @param mailbox: the mailbox object as created by dc_context_new() * * @param dbfile the file to use to store the database, sth. like "~/file" won't * work on all systems, if in doubt, use absolute paths. - * You can find the file path later in mrmailbox_t::m_dbfile * * @param blobdir a directory to store the blobs in, the trailing slash is added * by us, so if you want to avoid double slashes, do not add one. If you * give NULL as blobdir, `dbfile-blobs` is used in the same directory as * _dbfile_ will be created in. - * You can find the path to the blob direcrory later in mrmailbox_t::m_blobdir * * @return 1 on success, 0 on failure */ -int mrmailbox_open(mrmailbox_t* mailbox, const char* dbfile, const char* blobdir) +int dc_open(dc_context_t* mailbox, const char* dbfile, const char* blobdir) { int success = 0; int db_locked = 0; @@ -285,13 +283,13 @@ cleanup: /** * Close mailbox database. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new() + * @param mailbox the mailbox object as created by dc_context_new() * * @return none */ -void mrmailbox_close(mrmailbox_t* mailbox) +void dc_close(dc_context_t* mailbox) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return; @@ -319,13 +317,13 @@ void mrmailbox_close(mrmailbox_t* mailbox) /** * Check if the mailbox database is open. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @return 0=mailbox is not open, 1=mailbox is open. */ -int mrmailbox_is_open(const mrmailbox_t* mailbox) +int dc_is_open(const dc_context_t* mailbox) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return 0; /* error - database not opened */ @@ -338,14 +336,14 @@ int mrmailbox_is_open(const mrmailbox_t* mailbox) /** * Get the blob directory. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @return Blob directory associated with the mailbox object, empty string if unset or on errors. NULL is never returned. * The returned string must be free()'d. */ -char* mrmailbox_get_blobdir(mrmailbox_t* mailbox) +char* dc_get_blobdir(dc_context_t* mailbox) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return safe_strdup(NULL); @@ -376,7 +374,7 @@ char* mrmailbox_get_blobdir(mrmailbox_t* mailbox) * - selfstatus = Own status to display eg. in email footers, defaults to a standard text * - e2ee_enabled = 0=no e2ee, 1=prefer encryption (default) * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param ths the mailbox object * @@ -386,7 +384,7 @@ char* mrmailbox_get_blobdir(mrmailbox_t* mailbox) * * @return 0=failure, 1=success */ -int mrmailbox_set_config(mrmailbox_t* ths, const char* key, const char* value) +int dc_set_config(dc_context_t* ths, const char* key, const char* value) { int ret; @@ -406,11 +404,11 @@ int mrmailbox_set_config(mrmailbox_t* ths, const char* key, const char* value) /** - * Get a configuration option. The configuration option is typically set by mrmailbox_set_config() or by the library itself. + * Get a configuration option. The configuration option is typically set by dc_set_config() or by the library itself. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param ths the mailbox object as created by mrmmailbox_new() + * @param ths the mailbox object as created by dc_context_new() * * @param key the key to query * @@ -419,7 +417,7 @@ int mrmailbox_set_config(mrmailbox_t* ths, const char* key, const char* value) * @return Returns current value of "key", if "key" is unset, "def" is returned (which may be NULL) * If the returned values is not NULL, the return value must be free()'d, */ -char* mrmailbox_get_config(mrmailbox_t* ths, const char* key, const char* def) +char* dc_get_config(dc_context_t* ths, const char* key, const char* def) { char* ret; @@ -438,12 +436,12 @@ char* mrmailbox_get_config(mrmailbox_t* ths, const char* key, const char* def) /** - * Configure the mailbox. Similar to mrmailbox_set_config() but sets an integer instead of a string. + * Configure the mailbox. Similar to dc_set_config() but sets an integer instead of a string. * If there is already a key with a string set, this is overwritten by the given integer value. * - * @memberof mrmailbox_t + * @memberof dc_context_t */ -int mrmailbox_set_config_int(mrmailbox_t* ths, const char* key, int32_t value) +int dc_set_config_int(dc_context_t* ths, const char* key, int32_t value) { int ret; @@ -463,11 +461,11 @@ int mrmailbox_set_config_int(mrmailbox_t* ths, const char* key, int32_t value) /** - * Get a configuration option. Similar as mrmailbox_get_config() but gets the value as an integer instead of a string. + * Get a configuration option. Similar as dc_get_config() but gets the value as an integer instead of a string. * - * @memberof mrmailbox_t + * @memberof dc_context_t */ -int32_t mrmailbox_get_config_int(mrmailbox_t* ths, const char* key, int32_t def) +int32_t dc_get_config_int(dc_context_t* ths, const char* key, int32_t def) { int32_t ret; @@ -488,11 +486,11 @@ int32_t mrmailbox_get_config_int(mrmailbox_t* ths, const char* key, int32_t def) /** * Find out the version of the Delta Chat core library. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @return String with version number as `major.minor.revision`. The return value must be free()'d. */ -char* mrmailbox_get_version_str(void) +char* dc_get_version_str(void) { return mr_mprintf("%i.%i.%i", (int)MR_VERSION_MAJOR, (int)MR_VERSION_MINOR, (int)MR_VERSION_REVISION); } @@ -502,13 +500,13 @@ char* mrmailbox_get_version_str(void) * Get information about the mailbox. The information is returned by a multi-line string and contains information about the current * configuration and the last log entries. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as returned by mrmailbox_new(). + * @param mailbox Mailbox object as returned by dc_context_new(). * * @return String which must be free()'d after usage. Never returns NULL. */ -char* mrmailbox_get_info(mrmailbox_t* mailbox) +char* dc_get_info(dc_context_t* mailbox) { const char* unset = "0"; char *displayname = NULL, *temp = NULL, *l_readable_str = NULL, *l2_readable_str = NULL, *fingerprint_str = NULL; @@ -661,20 +659,20 @@ int mrmailbox_get_archived_count__(mrmailbox_t* mailbox) /** * Get a list of chats. The list can be filtered by query parameters. - * To get the chat messages, use mrmailbox_get_chat_msgs(). + * To get the chat messages, use dc_get_chat_msgs(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned by mrmailbox_new() + * @param mailbox The mailbox object as returned by dc_context_new() * * @param listflags A combination of flags: - * - if the flag MR_GCL_ARCHIVED_ONLY is set, only archived chats are returned. - * if MR_GCL_ARCHIVED_ONLY is not set, only unarchived chats are returned and - * the pseudo-chat MR_CHAT_ID_ARCHIVED_LINK is added if there are _any_ archived + * - if the flag DC_GCL_ARCHIVED_ONLY is set, only archived chats are returned. + * if DC_GCL_ARCHIVED_ONLY is not set, only unarchived chats are returned and + * the pseudo-chat DC_CHAT_ID_ARCHIVED_LINK is added if there are _any_ archived * chats - * - if the flag MR_GCL_NO_SPECIALS is set, deaddrop and archive link are not added + * - if the flag DC_GCL_NO_SPECIALS is set, deaddrop and archive link are not added * to the list (may be used eg. for selecting chats on forwarding, the flag is - * not needed when MR_GCL_ARCHIVED_ONLY is already set) + * not needed when DC_GCL_ARCHIVED_ONLY is already set) * * @param query_str An optional query for filtering the list. Only chats matching this query * are returned. Give NULL for no filtering. @@ -682,10 +680,10 @@ int mrmailbox_get_archived_count__(mrmailbox_t* mailbox) * @param query_id An optional contact ID for filtering the list. Only chats including this contact ID * are returned. Give 0 for no filtering. * - * @return A chatlist as an mrchatlist_t object. Must be freed using - * mrchatlist_unref() when no longer used + * @return A chatlist as an dc_chatlist_t object. Must be freed using + * dc_chatlist_unref() when no longer used */ -mrchatlist_t* mrmailbox_get_chatlist(mrmailbox_t* mailbox, int listflags, const char* query_str, uint32_t query_id) +dc_chatlist_t* dc_get_chatlist(dc_context_t* mailbox, int listflags, const char* query_str, uint32_t query_id) { int success = 0; int db_locked = 0; @@ -725,15 +723,15 @@ cleanup: /** * Get chat object by a chat ID. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The ID of the chat to get the chat object for. * - * @return A chat object of the type mrchat_t, must be freed using mrchat_unref() when done. + * @return A chat object of the type dc_chat_t, must be freed using dc_chat_unref() when done. */ -mrchat_t* mrmailbox_get_chat(mrmailbox_t* mailbox, uint32_t chat_id) +dc_chat_t* dc_get_chat(dc_context_t* mailbox, uint32_t chat_id) { int success = 0; int db_locked = 0; @@ -768,21 +766,21 @@ cleanup: /** * Mark all messages in a chat as _noticed_. * _Noticed_ messages are no longer _fresh_ and do not count as being unseen. - * IMAP/MDNs is not done for noticed messages. See also mrmailbox_marknoticed_contact() - * and mrmailbox_markseen_msgs() + * IMAP/MDNs is not done for noticed messages. See also dc_marknoticed_contact() + * and dc_markseen_msgs() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The chat ID of which all messages should be marked as being noticed. * * @return None. */ -void mrmailbox_marknoticed_chat(mrmailbox_t* mailbox, uint32_t chat_id) +void dc_marknoticed_chat(dc_context_t* mailbox, uint32_t chat_id) { /* marking a chat as "seen" is done by marking all fresh chat messages as "noticed" - - "noticed" messages are not counted as being unread but are still waiting for being marked as "seen" using mrmailbox_markseen_msgs() */ + "noticed" messages are not counted as being unread but are still waiting for being marked as "seen" using dc_markseen_msgs() */ sqlite3_stmt* stmt; if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { @@ -802,11 +800,11 @@ void mrmailbox_marknoticed_chat(mrmailbox_t* mailbox, uint32_t chat_id) /** * Check, if there is a normal chat with a given contact. - * To get the chat messages, use mrmailbox_get_chat_msgs(). + * To get the chat messages, use dc_get_chat_msgs(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param contact_id The contact ID to check. * @@ -814,7 +812,7 @@ void mrmailbox_marknoticed_chat(mrmailbox_t* mailbox, uint32_t chat_id) * returned. If there is no normal chat with the contact_id, the function * returns 0. */ -uint32_t mrmailbox_get_chat_id_by_contact_id(mrmailbox_t* mailbox, uint32_t contact_id) +uint32_t dc_get_chat_id_by_contact_id(dc_context_t* mailbox, uint32_t contact_id) { uint32_t chat_id = 0; int chat_id_blocked = 0; @@ -861,23 +859,23 @@ cleanup: /** * Create a normal chat with a single user. To create group chats, - * see mrmailbox_create_group_chat(). + * see dc_create_group_chat(). * * If there is already an exitant chat, this ID is returned and no new chat is * crated. If there is no existant chat with the user, a new chat is created; * this new chat may already contain messages, eg. from the deaddrop, to get the - * chat messages, use mrmailbox_get_chat_msgs(). + * chat messages, use dc_get_chat_msgs(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param contact_id The contact ID to create the chat for. If there is already * a chat with this contact, the already existing ID is returned. * * @return The created or reused chat ID on success. 0 on errors. */ -uint32_t mrmailbox_create_chat_by_contact_id(mrmailbox_t* mailbox, uint32_t contact_id) +uint32_t dc_create_chat_by_contact_id(dc_context_t* mailbox, uint32_t contact_id) { uint32_t chat_id = 0; int chat_blocked = 0; @@ -924,13 +922,13 @@ cleanup: /** * Create a normal chat or a group chat by a messages ID that comes typically - * from the deaddrop, MR_CHAT_ID_DEADDROP (1). + * from the deaddrop, DC_CHAT_ID_DEADDROP (1). * * If the given message ID already belongs to a normal chat or to a group chat, * the chat ID of this chat is returned and no new chat is created. * If a new chat is created, the given message ID is moved to this chat, however, * there may be more messages moved to the chat from the deaddrop. To get the - * chat messages, use mrmailbox_get_chat_msgs(). + * chat messages, use dc_get_chat_msgs(). * * If the user should be start asked the chat is created, he should just be * asked whether he wants to chat with the _contact_ belonging to the message; @@ -942,15 +940,15 @@ cleanup: * same group may be shown or not - so, all in all, it is fine to show the * contact name only. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param msg_id The message ID to create the chat for. * * @return The created or reused chat ID on success. 0 on errors. */ -uint32_t mrmailbox_create_chat_by_msg_id(mrmailbox_t* mailbox, uint32_t msg_id) +uint32_t dc_create_chat_by_msg_id(dc_context_t* mailbox, uint32_t msg_id) { int locked = 0; uint32_t chat_id = 0; @@ -1010,22 +1008,22 @@ static mrarray_t* mrmailbox_get_chat_media__(mrmailbox_t* mailbox, uint32_t chat /** * Returns all message IDs of the given types in a chat. Typically used to show - * a gallery. The result must be mrarray_unref()'d + * a gallery. The result must be dc_array_unref()'d * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The chat ID to get all messages with media from. * - * @param msg_type Specify a message type to query here, one of the MR_MSG_* constats. + * @param msg_type Specify a message type to query here, one of the DC_MSG_* constats. * - * @param or_msg_type Another message type to return, one of the MR_MSG_* constats. + * @param or_msg_type Another message type to return, one of the DC_MSG_* constats. * The function will return both types then. 0 if you need only one. * * @return An array with messages from the given chat ID that have the wanted message types. */ -mrarray_t* mrmailbox_get_chat_media(mrmailbox_t* mailbox, uint32_t chat_id, int msg_type, int or_msg_type) +dc_array_t* dc_get_chat_media(dc_context_t* mailbox, uint32_t chat_id, int msg_type, int or_msg_type) { mrarray_t* ret = NULL; @@ -1048,9 +1046,9 @@ mrarray_t* mrmailbox_get_chat_media(mrmailbox_t* mailbox, uint32_t chat_id, int * Typically used to implement the "next" and "previous" buttons on a media * player playing eg. voice messages. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param curr_msg_id This is the current (image) message displayed. * @@ -1058,10 +1056,10 @@ mrarray_t* mrmailbox_get_chat_media(mrmailbox_t* mailbox, uint32_t chat_id, int * * @return Returns the message ID that should be played next. The * returned message is in the same chat as the given one and has the same type. - * Typically, this result is passed again to mrmailbox_get_next_media() + * Typically, this result is passed again to dc_get_next_media() * later on the next swipe. If there is not next/previous message, the function returns 0. */ -uint32_t mrmailbox_get_next_media(mrmailbox_t* mailbox, uint32_t curr_msg_id, int dir) +uint32_t dc_get_next_media(dc_context_t* mailbox, uint32_t curr_msg_id, int dir) { uint32_t ret_msg_id = 0; mrmsg_t* msg = mrmsg_new(); @@ -1120,23 +1118,23 @@ cleanup: * Get contact IDs belonging to a chat. * * - for normal chats, the function always returns exactly one contact, - * MR_CONTACT_ID_SELF is _not_ returned. + * DC_CONTACT_ID_SELF is _not_ returned. * - * - for group chats all members are returned, MR_CONTACT_ID_SELF is returned + * - for group chats all members are returned, DC_CONTACT_ID_SELF is returned * explicitly as it may happen that oneself gets removed from a still existing * group * - * - for the deaddrop, all contacts are returned, MR_CONTACT_ID_SELF is not + * - for the deaddrop, all contacts are returned, DC_CONTACT_ID_SELF is not * added * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to get the belonging contact IDs for. * - * @return an array of contact IDs belonging to the chat; must be freed using mrarray_unref() when done. + * @return an array of contact IDs belonging to the chat; must be freed using dc_array_unref() when done. */ -mrarray_t* mrmailbox_get_chat_contacts(mrmailbox_t* mailbox, uint32_t chat_id) +dc_array_t* dc_get_chat_contacts(dc_context_t* mailbox, uint32_t chat_id) { /* Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a groupchat but the chats stays visible, moreover, this makes displaying lists easier) */ @@ -1176,11 +1174,11 @@ cleanup: * Returns the message IDs of all _fresh_ messages of any chat. Typically used for implementing * notification summaries. The result must be free()'d. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). */ -mrarray_t* mrmailbox_get_fresh_msgs(mrmailbox_t* mailbox) +dc_array_t* dc_get_fresh_msgs(dc_context_t* mailbox) { int show_deaddrop, success = 0, locked = 0; mrarray_t* ret = mrarray_new(mailbox, 128); @@ -1233,21 +1231,21 @@ cleanup: * Optionally, some special markers added to the ID-array may help to * implement virtual lists. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The chat ID of which the messages IDs should be queried. * - * @param flags If set to MR_GCM_ADD_DAY_MARKER, the marker MR_MSG_ID_DAYMARKER will + * @param flags If set to DC_GCM_ADD_DAY_MARKER, the marker DC_MSG_ID_DAYMARKER will * be added before each day (regarding the local timezone). Set this to 0 if you do not want this behaviour. * - * @param marker1before An optional message ID. If set, the id MR_MSG_ID_MARKER1 will be added just + * @param marker1before An optional message ID. If set, the id DC_MSG_ID_MARKER1 will be added just * before the given ID in the returned array. Set this to 0 if you do not want this behaviour. * - * @return Array of message IDs, must be mrarray_unref()'d when no longer used. + * @return Array of message IDs, must be dc_array_unref()'d when no longer used. */ -mrarray_t* mrmailbox_get_chat_msgs(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t flags, uint32_t marker1before) +dc_array_t* dc_get_chat_msgs(dc_context_t* mailbox, uint32_t chat_id, uint32_t flags, uint32_t marker1before) { //clock_t start = clock(); @@ -1354,23 +1352,23 @@ cleanup: * Searching can be done globally (chat_id=0) or in a specified chat only (chat_id * set). * - * Global chat results are typically displayed using mrmsg_get_summary(), chat + * Global chat results are typically displayed using dc_msg_get_summary(), chat * search results may just hilite the corresponding messages and present a * prev/next button. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id ID of the chat to search messages in. * Set this to 0 for a global search. * * @param query The query to search for. * - * @return An array of message IDs. Must be freed using mrarray_unref() when no longer needed. + * @return An array of message IDs. Must be freed using dc_array_unref() when no longer needed. * If nothing can be found, the function returns NULL. */ -mrarray_t* mrmailbox_search_msgs(mrmailbox_t* mailbox, uint32_t chat_id, const char* query) +dc_array_t* dc_search_msgs(dc_context_t* mailbox, uint32_t chat_id, const char* query) { //clock_t start = clock(); @@ -1460,7 +1458,7 @@ cleanup: } -static void set_draft_int(mrmailbox_t* mailbox, mrchat_t* chat, uint32_t chat_id, const char* msg) +static void set_draft_int(dc_context_t* mailbox, mrchat_t* chat, uint32_t chat_id, const char* msg) { sqlite3_stmt* stmt; mrchat_t* chat_to_delete = NULL; @@ -1517,11 +1515,11 @@ cleanup: /** * Save a draft for a chat. * - * To get the draft for a given chat ID, use mrchat_t::m_draft_text + * To get the draft for a given chat ID, use dc_chat_get_draft() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The chat ID to save the draft for. * @@ -1529,7 +1527,7 @@ cleanup: * * @return None. */ -void mrmailbox_set_draft(mrmailbox_t* mailbox, uint32_t chat_id, const char* msg) +void dc_set_draft(dc_context_t* mailbox, uint32_t chat_id, const char* msg) { set_draft_int(mailbox, NULL, chat_id, msg); } @@ -1731,15 +1729,15 @@ void mrmailbox_unarchive_chat__(mrmailbox_t* mailbox, uint32_t chat_id) /** * Get the total number of messages in a chat. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The ID of the chat to count the messages for. * * @return Number of total messages in the given chat. 0 for errors or empty chats. */ -int mrmailbox_get_total_msg_count(mrmailbox_t* mailbox, uint32_t chat_id) +int dc_get_total_msg_count(dc_context_t* mailbox, uint32_t chat_id) { int ret; @@ -1759,15 +1757,15 @@ int mrmailbox_get_total_msg_count(mrmailbox_t* mailbox, uint32_t chat_id) * Get the number of _fresh_ messages in a chat. Typically used to implement * a badge with a number in the chatlist. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The ID of the chat to count the messages for. * * @return Number of fresh messages in the given chat. 0 for errors or if there are no fresh messages. */ -int mrmailbox_get_fresh_msg_count(mrmailbox_t* mailbox, uint32_t chat_id) +int dc_get_fresh_msg_count(dc_context_t* mailbox, uint32_t chat_id) { int ret; @@ -1787,19 +1785,19 @@ int mrmailbox_get_fresh_msg_count(mrmailbox_t* mailbox, uint32_t chat_id) * Archive or unarchive a chat. * * Archived chats are not included in the default chatlist returned - * by mrmailbox_get_chatlist(). Instead, if there are _any_ archived chats, - * the pseudo-chat with the chat_id MR_CHAT_ID_ARCHIVED_LINK will be added the the + * by dc_get_chatlist(). Instead, if there are _any_ archived chats, + * the pseudo-chat with the chat_id DC_CHAT_ID_ARCHIVED_LINK will be added the the * end of the chatlist. * - * To get a list of archived chats, use mrmailbox_get_chatlist() with the flag MR_GCL_ARCHIVED_ONLY. + * To get a list of archived chats, use dc_get_chatlist() with the flag DC_GCL_ARCHIVED_ONLY. * - * To find out the archived state of a given chat, use mrchat_t::m_archived + * To find out the archived state of a given chat, use dc_chat_get_archived() * * Calling this function usually results in the event #MR_EVENT_MSGS_CHANGED * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The ID of the chat to archive or unarchive. * @@ -1807,7 +1805,7 @@ int mrmailbox_get_fresh_msg_count(mrmailbox_t* mailbox, uint32_t chat_id) * * @return None */ -void mrmailbox_archive_chat(mrmailbox_t* mailbox, uint32_t chat_id, int archive) +void dc_archive_chat(dc_context_t* mailbox, uint32_t chat_id, int archive) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || chat_id <= MR_CHAT_ID_LAST_SPECIAL || (archive!=0 && archive!=1) ) { return; @@ -1850,18 +1848,18 @@ void mrmailbox_archive_chat(mrmailbox_t* mailbox, uint32_t chat_id, int archive) * really unexpected when deletion results in contacting all members again, * (3) only leaving groups is also a valid usecase. * - * To leave a chat explicitly, use mrmailbox_remove_contact_from_chat() with - * chat_id=MR_CONTACT_ID_SELF) + * To leave a chat explicitly, use dc_remove_contact_from_chat() with + * chat_id=DC_CONTACT_ID_SELF) * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id The ID of the chat to delete. * * @return None */ -void mrmailbox_delete_chat(mrmailbox_t* mailbox, uint32_t chat_id) +void dc_delete_chat(dc_context_t* mailbox, uint32_t chat_id) { /* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */ int locked = 0, pending_transaction = 0; @@ -2083,38 +2081,22 @@ cleanup: * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * To send a simple text message, you can also use mrmailbox_send_text_msg() + * To send a simple text message, you can also use dc_send_text_msg() * which is easier to use. * - * @private @memberof mrmailbox_t + * @private @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * * @param chat_id Chat ID to send the message to. * * @param msg Message object to send to the chat defined by the chat ID. * The function does not take ownership of the object, so you have to - * free it using mrmsg_unref() as usual. + * free it using dc_msg_unref() as usual. * * @return The ID of the message that is about being sent. - * - * Examples: - * - * ``` - * mrmsg_t* msg1 = mrmsg_new(); - * mrmsg_set_type(msg1, MR_MSG_TEXT); - * mrmsg_set_text(msg1, "Hi there!"); - * mrmailbox_send_msg(mailbox, chat_id, msg1); // send a simple text message - * mrmsg_unref(msg1); - * - * mrmsg_t* msg2 = mrmsg_new(); - * mrmsg_set_type(msg2, MR_MSG_IMAGE); - * mrmsg_set_file(msg2, "/path/to/image.jpg"); - * mrmailbox_send_msg(mailbox, chat_id, msg2); // send a simple text message - * mrmsg_unref(msg1); - * ``` */ -uint32_t mrmailbox_send_msg_object(mrmailbox_t* mailbox, uint32_t chat_id, mrmsg_t* msg) +uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, mrmsg_t* msg) { int locked = 0, transaction_pending = 0; char* pathNfilename = NULL; @@ -2243,17 +2225,17 @@ cleanup: * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * See also mrmailbox_send_image_msg(). + * See also dc_send_image_msg(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the text message to. * @param text_to_send Text to send to the chat defined by the chat ID. * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_text_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* text_to_send) +uint32_t dc_send_text_msg(dc_context_t* mailbox, uint32_t chat_id, const char* text_to_send) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2281,11 +2263,11 @@ cleanup: * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * See also mrmailbox_send_text_msg(). + * See also dc_send_text_msg(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the image to. * @param file Full path of the image file to send. The core may make a copy of the file. * @param filemime Mime type of the file to send. NULL if you don't know or don't care. @@ -2294,7 +2276,7 @@ cleanup: * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_image_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int width, int height) +uint32_t dc_send_image_msg(dc_context_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int width, int height) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2325,11 +2307,11 @@ cleanup: * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * See also mrmailbox_send_image_msg(). + * See also dc_send_image_msg(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the video to. * @param file Full path of the video file to send. The core may make a copy of the file. * @param filemime Mime type of the file to send. NULL if you don't know or don't care. @@ -2339,7 +2321,7 @@ cleanup: * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_video_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int width, int height, int duration) +uint32_t dc_send_video_msg(dc_context_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int width, int height, int duration) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2366,16 +2348,16 @@ cleanup: /** * Send a voice message to a chat. Voice messages are messages just recorded though the device microphone. - * For sending music or other audio data, use mrmailbox_send_audio_msg(). + * For sending music or other audio data, use dc_send_audio_msg(). * * Sends the event #MR_EVENT_MSGS_CHANGED on succcess. * However, this does not imply, the message really reached the recipient - * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the voice message to. * @param file Full path of the file to send. The core may make a copy of the file. * @param filemime Mime type of the file to send. NULL if you don't know or don't care. @@ -2383,7 +2365,7 @@ cleanup: * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_voice_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int duration) +uint32_t dc_send_voice_msg(dc_context_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int duration) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2407,16 +2389,16 @@ cleanup: /** * Send an audio file to a chat. Audio messages are eg. music tracks. - * For voice messages just recorded though the device microphone, use mrmailbox_send_voice_msg(). + * For voice messages just recorded though the device microphone, use dc_send_voice_msg(). * * Sends the event #MR_EVENT_MSGS_CHANGED on succcess. * However, this does not imply, the message really reached the recipient - * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the audio to. * @param file Full path of the file to send. The core may make a copy of the file. * @param filemime Mime type of the file to send. NULL if you don't know or don't care. @@ -2426,7 +2408,7 @@ cleanup: * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_audio_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int duration, const char* author, const char* trackname) +uint32_t dc_send_audio_msg(dc_context_t* mailbox, uint32_t chat_id, const char* file, const char* filemime, int duration, const char* author, const char* trackname) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2459,16 +2441,16 @@ cleanup: * sending may be delayed eg. due to network problems. However, from your * view, you're done with the message. Sooner or later it will find its way. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as returned from mrmailbox_new(). + * @param mailbox The mailbox object as returned from dc_context_new(). * @param chat_id Chat ID to send the document to. * @param file Full path of the file to send. The core may make a copy of the file. * @param filemime Mime type of the file to send. NULL if you don't know or don't care. * * @return The ID of the message that is about being sent. */ -uint32_t mrmailbox_send_file_msg(mrmailbox_t* mailbox, uint32_t chat_id, const char* file, const char* filemime) +uint32_t dc_send_file_msg(dc_context_t* mailbox, uint32_t chat_id, const char* file, const char* filemime) { mrmsg_t* msg = mrmsg_new(); uint32_t ret = 0; @@ -2498,12 +2480,12 @@ cleanup: * Typically used to share a contact to another member or to a group of members. * * Internally, the function just creates an appropriate text message and sends it - * using mrmailbox_send_text_msg(). + * using dc_send_text_msg(). * * NB: The "vcard" in the function name is just an abbreviation of "visiting card" and * is not related to the VCARD data format. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @@ -2513,7 +2495,7 @@ cleanup: * * @return Returns the ID of the message sent. */ -uint32_t mrmailbox_send_vcard_msg(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id) +uint32_t dc_send_vcard_msg(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id) { uint32_t ret = 0; mrmsg_t* msg = mrmsg_new(); @@ -2672,7 +2654,7 @@ int mrmailbox_add_to_chat_contacts_table__(mrmailbox_t* mailbox, uint32_t chat_i * Create a new group chat. * * After creation, the group has one member with the - * ID MR_CONTACT_ID_SELF and is in _unpromoted_ state. This means, you can + * ID DC_CONTACT_ID_SELF and is in _unpromoted_ state. This means, you can * add or remove members, change the name, the group image and so on without * messages being sent to all group members. * @@ -2680,20 +2662,20 @@ int mrmailbox_add_to_chat_contacts_table__(mrmailbox_t* mailbox, uint32_t chat_i * the group becomes _promoted_. After that, all changes are synced with all * group members by sending status message. * - * To check, if a chat is still unpromoted, you mrchat_is_unpromoted() + * To check, if a chat is still unpromoted, you dc_chat_is_unpromoted() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * @param verified If set to 1 the function creates a secure verfied group. * Only secure-verified members are allowd in these groups and end-to-end-encryption is always enabled. * @param chat_name The name of the group chat to create. - * The name may be changed later using mrmailbox_set_chat_name(). - * To find out the name of a group later, see mrchat_t::m_name + * The name may be changed later using dc_set_chat_name(). + * To find out the name of a group later, see dc_chat_get_name() * * @return The chat ID of the new group chat, 0 on errors. */ -uint32_t mrmailbox_create_group_chat(mrmailbox_t* mailbox, int verified, const char* chat_name) +uint32_t dc_create_group_chat(dc_context_t* mailbox, int verified, const char* chat_name) { uint32_t chat_id = 0; int locked = 0; @@ -2751,17 +2733,17 @@ cleanup: * * Sends out #MR_EVENT_CHAT_MODIFIED and #MR_EVENT_MSGS_CHANGED if a status message was sent. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param chat_id The chat ID to set the name for. Must be a group chat. * * @param new_name New name of the group. * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * * @return 1=success, 0=error */ -int mrmailbox_set_chat_name(mrmailbox_t* mailbox, uint32_t chat_id, const char* new_name) +int dc_set_chat_name(dc_context_t* mailbox, uint32_t chat_id, const char* new_name) { /* the function only sets the names of group chats; normal chats get their names from the contacts */ int success = 0, locked = 0; @@ -2829,11 +2811,11 @@ cleanup: * * Sends out #MR_EVENT_CHAT_MODIFIED and #MR_EVENT_MSGS_CHANGED if a status message was sent. * - * To find out the profile image of a chat, use mrchat_get_profile_image() + * To find out the profile image of a chat, use dc_chat_get_profile_image() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * * @param chat_id The chat ID to set the image for. * @@ -2842,7 +2824,7 @@ cleanup: * * @return 1=success, 0=error */ -int mrmailbox_set_chat_profile_image(mrmailbox_t* mailbox, uint32_t chat_id, const char* new_image /*NULL=remove image*/) +int dc_set_chat_profile_image(dc_context_t* mailbox, uint32_t chat_id, const char* new_image /*NULL=remove image*/) { int success = 0, locked = 0;; mrchat_t* chat = mrchat_new(mailbox); @@ -2920,18 +2902,18 @@ int mrmailbox_is_contact_in_chat__(mrmailbox_t* mailbox, uint32_t chat_id, uint3 /** * Check if a given contact ID is a member of a group chat. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * * @param chat_id The chat ID to check. * * @param contact_id The contact ID to check. To check if yourself is member - * of the chat, pass MR_CONTACT_ID_SELF (1) here. + * of the chat, pass DC_CONTACT_ID_SELF (1) here. * * @return 1=contact ID is member of chat ID, 0=contact is not in chat */ -int mrmailbox_is_contact_in_chat(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id) +int dc_is_contact_in_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id) { /* this function works for group and for normal chats, however, it is more useful for group chats. MR_CONTACT_ID_SELF may be used to check, if the user itself is in a group chat (MR_CONTACT_ID_SELF is not added to normal chats) */ @@ -3052,9 +3034,9 @@ cleanup: * * Sends out #MR_EVENT_CHAT_MODIFIED and #MR_EVENT_MSGS_CHANGED if a status message was sent. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * * @param chat_id The chat ID to add the contact to. Must be a group chat. * @@ -3062,7 +3044,7 @@ cleanup: * * @return 1=member added to group, 0=error */ -int mrmailbox_add_contact_to_chat(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/) +int dc_add_contact_to_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/) { return mrmailbox_add_contact_to_chat_ex(mailbox, chat_id, contact_id, 0); } @@ -3076,9 +3058,9 @@ int mrmailbox_add_contact_to_chat(mrmailbox_t* mailbox, uint32_t chat_id, uint32 * * Sends out #MR_EVENT_CHAT_MODIFIED and #MR_EVENT_MSGS_CHANGED if a status message was sent. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * * @param chat_id The chat ID to remove the contact from. Must be a group chat. * @@ -3086,7 +3068,7 @@ int mrmailbox_add_contact_to_chat(mrmailbox_t* mailbox, uint32_t chat_id, uint32 * * @return 1=member removed from group, 0=error */ -int mrmailbox_remove_contact_from_chat(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/) +int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/) { int success = 0, locked = 0; mrcontact_t* contact = mrmailbox_get_contact(mailbox, contact_id); @@ -3383,16 +3365,16 @@ cleanup: * Add a single contact as a result of an _explicit_ user action. * * We assume, the contact name, if any, is entered by the user and is used "as is" therefore, - * mr_normalize_name() is _not_ called for the name. If the contact is blocked, it is unblocked. + * normalize() is _not_ called for the name. If the contact is blocked, it is unblocked. * - * To add a number of contacts, see mrmailbox_add_address_book() which is much faster for adding + * To add a number of contacts, see dc_add_address_book() which is much faster for adding * a bunch of addresses. * * May result in a #MR_EVENT_CONTACTS_CHANGED event. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param name Name of the contact to add. If you do not know the name belonging * to the address, you can give NULL here. @@ -3403,7 +3385,7 @@ cleanup: * * @return Contact ID of the created or reused contact. */ -uint32_t mrmailbox_create_contact(mrmailbox_t* mailbox, const char* name, const char* addr) +uint32_t dc_create_contact(dc_context_t* mailbox, const char* name, const char* addr) { uint32_t contact_id = 0; int sth_modified = 0; @@ -3436,16 +3418,16 @@ cleanup: * Add a number of contacts. * * Typically used to add the whole address book from the OS. As names here are typically not - * well formatted, we call mr_normalize_name() for each name given. + * well formatted, we call normalize() for each name given. * - * To add a single contact entered by the user, you should prefer mrmailbox_create_contact(), + * To add a single contact entered by the user, you should prefer dc_create_contact(), * however, for adding a bunch of addresses, this function is _much_ faster. * - * The function takes are of not overwriting names manually added or edited by mrmailbox_create_contact(). + * The function takes are of not overwriting names manually added or edited by dc_create_contact(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @param adr_book A multi-line string in the format in the format * `Name one\nAddress one\nName two\Address two`. If an email address @@ -3454,7 +3436,7 @@ cleanup: * * @return The number of modified or added contacts. */ -int mrmailbox_add_address_book(mrmailbox_t* mailbox, const char* adr_book) /* format: Name one\nAddress one\nName two\Address two */ +int dc_add_address_book(dc_context_t* mailbox, const char* adr_book) /* format: Name one\nAddress one\nName two\Address two */ { carray* lines = NULL; size_t i, iCnt; @@ -3497,23 +3479,23 @@ cleanup: /** * Returns known and unblocked contacts. * - * To get information about a single contact, see mrmailbox_get_contact(). + * To get information about a single contact, see dc_get_contact(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param listflags A combination of flags: - * - if the flag MR_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters - * - if the flag MR_GCL_VERIFIED_ONLY is set, only verified contacts are returned. - * if MR_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned. + * - if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters + * - if the flag DC_GCL_VERIFIED_ONLY is set, only verified contacts are returned. + * if DC_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned. * @param query A string to filter the list. Typically used to implement an * incremental search. NULL for no filtering. * - * @return An array containing all contact IDs. Must be mrarray_unref()'d + * @return An array containing all contact IDs. Must be dc_array_unref()'d * after usage. */ -mrarray_t* mrmailbox_get_contacts(mrmailbox_t* mailbox, uint32_t listflags, const char* query) +dc_array_t* dc_get_contacts(dc_context_t* mailbox, uint32_t listflags, const char* query) { int locked = 0; char* self_addr = NULL; @@ -3591,14 +3573,14 @@ cleanup: /** * Get blocked contacts. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * - * @return An array containing all blocked contact IDs. Must be mrarray_unref()'d + * @return An array containing all blocked contact IDs. Must be dc_array_unref()'d * after usage. */ -mrarray_t* mrmailbox_get_blocked_contacts(mrmailbox_t* mailbox) +dc_array_t* dc_get_blocked_contacts(dc_context_t* mailbox) { mrarray_t* ret = mrarray_new(mailbox, 100); sqlite3_stmt* stmt; @@ -3628,11 +3610,11 @@ cleanup: /** * Get the number of blocked contacts. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). */ -int mrmailbox_get_blocked_count(mrmailbox_t* mailbox) +int dc_get_blocked_count(dc_context_t* mailbox) { int ret = 0, locked = 0; sqlite3_stmt* stmt; @@ -3663,22 +3645,22 @@ cleanup: /** - * Get a single contact object. For a list, see eg. mrmailbox_get_contacts(). + * Get a single contact object. For a list, see eg. dc_get_contacts(). * - * For contact MR_CONTACT_ID_SELF (1), the function returns the name - * MR_STR_SELF (typically "Me" in the selected language) and the email address - * defined by mrmailbox_set_config(). + * For contact DC_CONTACT_ID_SELF (1), the function returns sth. + * like "Me" in the selected language and the email address + * defined by dc_set_config(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param contact_id ID of the contact to get the object for. * - * @return The contact object, must be freed using mrcontact_unref() when no + * @return The contact object, must be freed using dc_contact_unref() when no * longer used. NULL on errors. */ -mrcontact_t* mrmailbox_get_contact(mrmailbox_t* mailbox, uint32_t contact_id) +dc_contact_t* dc_get_contact(dc_context_t* mailbox, uint32_t contact_id) { mrcontact_t* ret = mrcontact_new(mailbox); @@ -3706,18 +3688,18 @@ static void marknoticed_contact__(mrmailbox_t* mailbox, uint32_t contact_id) /** * Mark all messages sent by the given contact - * as _noticed_. See also mrmailbox_marknoticed_chat() and - * mrmailbox_markseen_msgs() + * as _noticed_. See also dc_marknoticed_chat() and + * dc_markseen_msgs() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmmailbox_new() + * @param mailbox The mailbox object as created by dc_context_new() * * @param contact_id The contact ID of which all messages should be marked as noticed. * * @return none */ -void mrmailbox_marknoticed_contact(mrmailbox_t* mailbox, uint32_t contact_id) +void dc_marknoticed_contact(dc_context_t* mailbox, uint32_t contact_id) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return; @@ -3757,9 +3739,9 @@ void mrmailbox_unblock_chat__(mrmailbox_t* mailbox, uint32_t chat_id) * * May result in a #MR_EVENT_CONTACTS_CHANGED event. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param contact_id The ID of the contact to block or unblock. * @@ -3767,7 +3749,7 @@ void mrmailbox_unblock_chat__(mrmailbox_t* mailbox, uint32_t chat_id) * * @return None. */ -void mrmailbox_block_contact(mrmailbox_t* mailbox, uint32_t contact_id, int new_blocking) +void dc_block_contact(dc_context_t* mailbox, uint32_t contact_id, int new_blocking) { int locked = 0, send_event = 0, transaction_pending = 0; mrcontact_t* contact = mrcontact_new(mailbox); @@ -3855,15 +3837,15 @@ static void cat_fingerprint(mrstrbuilder_t* ret, const char* addr, const char* f * Get a multi-line encryption info, containing your fingerprint and the * fingerprint of the contact, used eg. to compare the fingerprints for a simple out-of-band verification. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param contact_id ID of the contact to get the encryption info for. * * @return multi-line text, must be free()'d after usage. */ -char* mrmailbox_get_contact_encrinfo(mrmailbox_t* mailbox, uint32_t contact_id) +char* dc_get_contact_encrinfo(dc_context_t* mailbox, uint32_t contact_id) { int locked = 0; mrloginparam_t* loginparam = mrloginparam_new(); @@ -3961,15 +3943,15 @@ cleanup: * * May result in a #MR_EVENT_CONTACTS_CHANGED event. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * * @param contact_id ID of the contact to delete. * * @return 1=success, 0=error */ -int mrmailbox_delete_contact(mrmailbox_t* mailbox, uint32_t contact_id) +int dc_delete_contact(dc_context_t* mailbox, uint32_t contact_id) { int locked = 0, success = 0; sqlite3_stmt* stmt; @@ -4148,19 +4130,19 @@ void mrmailbox_update_server_uid__(mrmailbox_t* mailbox, const char* rfc724_mid, /** - * Get a single message object of the type mrmsg_t. - * For a list of messages in a chat, see mrmailbox_get_chat_msgs() - * For a list or chats, see mrmailbox_get_chatlist() + * Get a single message object of the type dc_msg_t. + * For a list of messages in a chat, see dc_get_chat_msgs() + * For a list or chats, see dc_get_chatlist() * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new() + * @param mailbox Mailbox object as created by dc_context_new() * * @param msg_id The message ID for which the message object should be created. * - * @return A mrmsg_t message object. When done, the object must be freed using mrmsg_unref() + * @return A dc_msg_t message object. When done, the object must be freed using dc_msg_unref() */ -mrmsg_t* mrmailbox_get_msg(mrmailbox_t* mailbox, uint32_t msg_id) +dc_msg_t* dc_get_msg(dc_context_t* mailbox, uint32_t msg_id) { int success = 0; int db_locked = 0; @@ -4197,22 +4179,22 @@ cleanup: * contain eg. the raw text of the message. * * The max. text returned is typically longer (about 100000 characters) than the - * max. text returned by mrmsg_get_text() (about 30000 characters). + * max. text returned by dc_msg_get_text() (about 30000 characters). * * If the library is compiled for andoid, some basic html-formatting for he * subject and the footer is added. However we should change this function so * that it returns eg. an array of pairwise key-value strings and the caller * can show the whole stuff eg. in a table. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @param msg_id the message id for which information should be generated * * @return text string, must be free()'d after usage */ -char* mrmailbox_get_msg_info(mrmailbox_t* mailbox, uint32_t msg_id) +char* dc_get_msg_info(dc_context_t* mailbox, uint32_t msg_id) { mrstrbuilder_t ret; int locked = 0; @@ -4398,9 +4380,9 @@ cleanup: /** * Forward messages to another chat. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new() + * @param mailbox the mailbox object as created by dc_context_new() * * @param msg_ids an array of uint32_t containing all message IDs that should be forwarded * @@ -4410,7 +4392,7 @@ cleanup: * * @return none */ -void mrmailbox_forward_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id) +void dc_forward_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id) { mrmsg_t* msg = mrmsg_new(); mrchat_t* chat = mrchat_new(mailbox); @@ -4484,11 +4466,11 @@ cleanup: /** * Star/unstar messages by setting the last parameter to 0 (unstar) or 1 (star). * Starred messages are collected in a virtual chat that can be shown using - * mrmailbox_get_chat_msgs() using the chat_id MR_CHAT_ID_STARRED. + * dc_get_chat_msgs() using the chat_id DC_CHAT_ID_STARRED. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new() + * @param mailbox The mailbox object as created by dc_context_new() * * @param msg_ids An array of uint32_t message IDs defining the messages to star or unstar * @@ -4498,7 +4480,7 @@ cleanup: * * @return none */ -void mrmailbox_star_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_cnt, int star) +void dc_star_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt, int star) { int i; @@ -4532,9 +4514,9 @@ void mrmailbox_star_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_ * Delete messages. The messages are deleted on the current device and * on the IMAP server. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox the mailbox object as created by mrmailbox_new() + * @param mailbox the mailbox object as created by dc_context_new() * * @param msg_ids an array of uint32_t containing all message IDs that should be deleted * @@ -4542,7 +4524,7 @@ void mrmailbox_star_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_ * * @return none */ -void mrmailbox_delete_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_cnt) +void dc_delete_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt) { int i; @@ -4571,11 +4553,11 @@ void mrmailbox_delete_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int ms /** * Mark a message as _seen_, updates the IMAP state and - * sends MDNs. if the message is not in a real chat (eg. a contact request), the + * sends MDNs. If the message is not in a real chat (eg. a contact request), the * message is only marked as NOTICED and no IMAP/MDNs is done. See also - * mrmailbox_marknoticed_chat() and mrmailbox_marknoticed_contact() + * dc_marknoticed_chat() and dc_marknoticed_contact() * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @@ -4585,7 +4567,7 @@ void mrmailbox_delete_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int ms * * @return none */ -void mrmailbox_markseen_msgs(mrmailbox_t* mailbox, const uint32_t* msg_ids, int msg_cnt) +void dc_markseen_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt) { int locked = 0, transaction_pending = 0; int i, send_event = 0; diff --git a/src/mrmailbox.h b/src/mrmailbox.h index 53f6c993..d00c5dd3 100644 --- a/src/mrmailbox.h +++ b/src/mrmailbox.h @@ -135,7 +135,7 @@ extern "C" { #define mrchatlist_get_chat_id dc_chatlist_get_chat_id #define mrchatlist_get_msg_id dc_chatlist_get_msg_id #define mrchatlist_get_summary dc_chatlist_get_summary -#define mrchatlist_get_mailbox dc_chatlist_get_mailbox +#define mrchatlist_get_mailbox dc_chatlist_get_context // chat functions #define MR_CHAT_ID_DEADDROP DC_CHAT_ID_DEADDROP diff --git a/src/mrmailbox_configure.c b/src/mrmailbox_configure.c index f013769f..e4cddb55 100644 --- a/src/mrmailbox_configure.c +++ b/src/mrmailbox_configure.c @@ -691,39 +691,34 @@ cleanup: /** * Configure and connect a mailbox. * For this, the function creates a job that is executed in the IMAP-thread then; - * this requires to call mrmailbox_perform_jobs() regulary. + * this requires to call dc_perform_imap_jobs() regulary. * * - Before your call this function, you should set at least `addr` and `mail_pw` - * using mrmailbox_set_config(). + * using dc_set_config(). * - * - mrmailbox_configure() may take a while, - * you can use mrmailbox_stop_ongoing_process(). + * - While dc_configure() returns immediately, the started configuration-job may take a while, + * you can stop it using dc_stop_ongoing_process(). * * - The function sends out a number of #MR_EVENT_CONFIGURE_PROGRESS events that may be used to create * a progress bar or stuff like that. * - * - ongoing idle processed will be killed and calling mrimap_idle() while this function - * has not terminated will fail; if needed, call mrimap_idle() when this function succeeds. + * @memberof dc_context_t * - * @memberof mrmailbox_t - * - * @param mailbox the mailbox object as created by mrmailbox_new(). + * @param mailbox the mailbox object as created by dc_context_new(). * * @return None. * * There is no need to call this every program start, the result is saved in the - * database and you can call mrmailbox_poll() or mrmailbox_idle() directly: + * database and you can call use the connection directly: * * ``` - * if( !mrmailbox_is_configured(mailbox) ) { - * if( !mrmailbox_configure(mailbox) ) { - * // show an error and/or try over - * } + * if( !dc_is_configured(context) ) { + * dc_configure(context); + * // wait for progress events * } - * mrmailbox_idle(mailbox); * ``` */ -void mrmailbox_configure(mrmailbox_t* mailbox) +void dc_configure(dc_context_t* mailbox) { mrjob_kill_actions(mailbox, MRJ_CONFIGURE_IMAP, 0); mrjob_add(mailbox, MRJ_CONFIGURE_IMAP, 0, NULL, 0); // results in a call to mrmailbox_configure_job() @@ -734,16 +729,16 @@ void mrmailbox_configure(mrmailbox_t* mailbox) * Check if the mailbox is already configured. * * Typically, for unconfigured mailboxes, the user is prompeted for - * to enter some settings and mrmailbox_configure() is called in a thread then. + * to enter some settings and dc_configure() is called in a thread then. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox The mailbox object as created by mrmailbox_new(). + * @param mailbox The mailbox object as created by dc_context_new(). * - * @return 1=mailbox is configured and mrmailbox_poll() or mrmailbox_idle() will work as expected; - * 0=mailbox is not configured and a configuration by mrmailbox_configure() is required. + * @return 1=context is configuredc can be used; + * 0=context is not configured and a configuration by dc_configure() is required. */ -int mrmailbox_is_configured(mrmailbox_t* mailbox) +int dc_is_configured(dc_context_t* mailbox) { int is_configured; @@ -806,28 +801,28 @@ void mrmailbox_free_ongoing(mrmailbox_t* mailbox) /** * Signal an ongoing process to stop. * - * After that, mrmailbox_stop_ongoing_process() returns _without_ waiting + * After that, dc_stop_ongoing_process() returns _without_ waiting * for the ongoing process to return. * * The ongoing process will return ASAP then, however, it may * still take a moment. If in doubt, the caller may also decide to kill the * thread after a few seconds; eg. the process may hang in a * function not under the control of the core (eg. #MR_EVENT_HTTP_GET). Another - * reason for mrmailbox_stop_ongoing_process() not to wait is that otherwise it + * reason for dc_stop_ongoing_process() not to wait is that otherwise it * would be GUI-blocking and should be started in another thread then; this * would make things even more complicated. * - * Typical ongoing processes are started by mrmailbox_configure(), - * mrmailbox_initiate_key_transfer() or mrmailbox_imex(). As there is always at most only + * Typical ongoing processes are started by dc_configure(), + * dc_initiate_key_transfer() or dc_imex(). As there is always at most only * one onging process at the same time, there is no need to define _which_ process to exit. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * * @return None */ -void mrmailbox_stop_ongoing_process(mrmailbox_t* mailbox) +void dc_stop_ongoing_process(dc_context_t* mailbox) { if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) { return; diff --git a/src/mrmailbox_imex.c b/src/mrmailbox_imex.c index 7f5b8462..fa900e61 100644 --- a/src/mrmailbox_imex.c +++ b/src/mrmailbox_imex.c @@ -92,7 +92,7 @@ * mrmailbox_render_setup_file() renders the body after the second * `-==break1==` in this example. * - * @private @memberof mrmailbox_t + * @private @memberof dc_context_t * * @param mailbox The mailbox object * @param passphrase The setup code that shall be used to encrypt the message. @@ -100,7 +100,7 @@ * @return String with the HTML-code of the message on success, NULL on errors. * The returned value must be free()'d */ -char* mrmailbox_render_setup_file(mrmailbox_t* mailbox, const char* passphrase) +char* mrmailbox_render_setup_file(dc_context_t* mailbox, const char* passphrase) { int locked = 0; sqlite3_stmt* stmt = NULL; @@ -298,7 +298,7 @@ cleanup: /** * Parse the given file content and extract the private key. * - * @private @memberof mrmailbox_t + * @private @memberof dc_context_t * * @param mailbox The mailbox object * @param passphrase The setup code that shall be used to decrypt the message. @@ -310,7 +310,7 @@ cleanup: * @return The decrypted private key as armored-ascii-data or NULL on errors. * Must be mrkey_unref()'d. */ -char* mrmailbox_decrypt_setup_file(mrmailbox_t* mailbox, const char* passphrase, const char* filecontent) +char* mrmailbox_decrypt_setup_file(dc_context_t* mailbox, const char* passphrase, const char* filecontent) { char* fc_buf = NULL; const char *fc_headerline = NULL, *fc_base64 = NULL; @@ -360,13 +360,13 @@ cleanup: * * A higher-level function to initiate the key transfer is mrmailbox_initiate_key_transfer(). * - * @private @memberof mrmailbox_t + * @private @memberof dc_context_t * * @param mailbox Mailbox object as created by mrmailbox_new(). * * @return Setup code, must be free()'d after usage. NULL on errors. */ -char* mrmailbox_create_setup_code(mrmailbox_t* mailbox) +char* mrmailbox_create_setup_code(dc_context_t* mailbox) { #define CODE_ELEMS 9 uint16_t random_val; @@ -425,7 +425,7 @@ char* mrmailbox_normalize_setup_code(mrmailbox_t* mailbox, const char* in) /** * Initiate Autocrypt Key Transfer. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @@ -442,7 +442,7 @@ char* mrmailbox_normalize_setup_code(mrmailbox_t* mailbox, const char* in) * After that, this function should be called to send the Autocrypt setup message. * The function creates the setup message and waits until it is really sent. * As this may take a while, it is recommended to start the function in a separate thread; - * to interrupt it, you can use mrmailbox_stop_ongoing_process(). + * to interrupt it, you can use dc_stop_ongoing_process(). * * * After everything succeeded, the required setup code is returned in the following format: @@ -465,13 +465,13 @@ char* mrmailbox_normalize_setup_code(mrmailbox_t* mailbox, const char* in) * Once you're done, your other device will be ready to use Autocrypt." * ``` * - * On the _other device_ you will call mrmailbox_continue_key_transfer() then - * for setup messages identified by mrmsg_is_setupmessage(). + * On the _other device_ you will call dc_continue_key_transfer() then + * for setup messages identified by dc_msg_is_setupmessage(). * * For more details about the Autocrypt setup process, please refer to * https://autocrypt.org/en/latest/level1.html#autocrypt-setup-message */ -char* mrmailbox_initiate_key_transfer(mrmailbox_t* mailbox) +char* dc_initiate_key_transfer(dc_context_t* mailbox) { int success = 0; char* setup_code = NULL; @@ -629,26 +629,26 @@ cleanup: /** * Continue the Autocrypt Key Transfer on another device. * - * If you have started the key transfer on another device using mrmailbox_initiate_key_transfer() - * and you've detected a setup message with mrmsg_is_setupmessage(), you should prompt the + * If you have started the key transfer on another device using dc_initiate_key_transfer() + * and you've detected a setup message with dc_msg_is_setupmessage(), you should prompt the * user for the setup code and call this function then. * - * You can use mrmsg_get_setupcodebegin() to give the user a hint about the code (useful if the user + * You can use dc_msg_get_setupcodebegin() to give the user a hint about the code (useful if the user * has created several messages and should not enter the wrong code). * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @param msg_id ID of the setup message to decrypt. * @param setup_code Setup code entered by the user. This is the same setup code as returned from - * mrmailbox_initiate_key_transfer() on the other device. + * dc_initiate_key_transfer() on the other device. * There is no need to format the string correctly, the function will remove all spaces and other characters and * insert the `-` characters at the correct places. * * @return 1=key successfully decrypted and imported; both devices will use the same key now; * 0=key transfer failed eg. due to a bad setup code. */ -int mrmailbox_continue_key_transfer(mrmailbox_t* mailbox, uint32_t msg_id, const char* setup_code) +int dc_continue_key_transfer(dc_context_t* mailbox, uint32_t msg_id, const char* setup_code) { int success = 0; mrmsg_t* msg = NULL; @@ -1165,22 +1165,22 @@ cleanup: * * What to do is defined by the _what_ parameter which may be one of the following: * - * - **MR_IMEX_EXPORT_BACKUP** (11) - Export a backup to the directory given as `param1`. + * - **DC_IMEX_EXPORT_BACKUP** (11) - Export a backup to the directory given as `param1`. * The backup contains all contacts, chats, images and other data and device independent settings. * The backup does not contain device dependent settings as ringtones or LED notification settings. * The name of the backup is typically `delta-chat..bak`, if more than one backup is create on a day, * the format is `delta-chat.-.bak` * - * - **MR_IMEX_IMPORT_BACKUP** (12) - `param1` is the file (not: directory) to import. The file is normally - * created by MR_IMEX_EXPORT_BACKUP and detected by mrmailbox_imex_has_backup(). Importing a backup + * - **DC_IMEX_IMPORT_BACKUP** (12) - `param1` is the file (not: directory) to import. The file is normally + * created by DC_IMEX_EXPORT_BACKUP and detected by dc_imex_has_backup(). Importing a backup * is only possible as long as the mailbox is not configured or used in another way. * - * - **MR_IMEX_EXPORT_SELF_KEYS** (1) - Export all private keys and all public keys of the user to the + * - **DC_IMEX_EXPORT_SELF_KEYS** (1) - Export all private keys and all public keys of the user to the * directory given as `param1`. The default key is written to the files `public-key-default.asc` * and `private-key-default.asc`, if there are more keys, they are written to files as * `public-key-.asc` and `private-key-.asc` * - * - **MR_IMEX_IMPORT_SELF_KEYS** (2) - Import private keys found in the directory given as `param1`. + * - **DC_IMEX_IMPORT_SELF_KEYS** (2) - Import private keys found in the directory given as `param1`. * The last imported key is made the default keys unless its name contains the string `legacy`. Public keys are not imported. * * The function may take a long time until it finishes, so it might be a good idea to start it in a @@ -1192,19 +1192,19 @@ cleanup: * - For each file written on export, the function sends #MR_EVENT_IMEX_FILE_WRITTEN * * Only one import-/export-progress can run at the same time. - * To cancel an import-/export-progress, use mrmailbox_stop_ongoing_process(). + * To cancel an import-/export-progress, use dc_stop_ongoing_process(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). - * @param what One of the MR_IMEX_* constants. - * @param param1 Meaning depends on the MR_IMEX_* constants. If this parameter is a directory, it should not end with + * @param mailbox Mailbox object as created by dc_context_new(). + * @param what One of the DC_IMEX_* constants. + * @param param1 Meaning depends on the DC_IMEX_* constants. If this parameter is a directory, it should not end with * a slash (otherwise you'll get double slashes when receiving #MR_EVENT_IMEX_FILE_WRITTEN). Set to NULL if not used. - * @param param2 Meaning depends on the MR_IMEX_* constants. Set to NULL if not used. + * @param param2 Meaning depends on the DC_IMEX_* constants. Set to NULL if not used. * * @return 1=success, 0=error or progress canceled. */ -int mrmailbox_imex(mrmailbox_t* mailbox, int what, const char* param1, const char* param2) +int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* param2) { int success = 0; @@ -1282,14 +1282,14 @@ cleanup: /** * Check if there is a backup file. * - * May only be used on fresh installations (eg. mrmailbox_is_configured() returns 0). + * May only be used on fresh installations (eg. dc_is_configured() returns 0). * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * @param dir_name Directory to search backups in. * - * @return String with the backup file, typically given to mrmailbox_imex(), returned strings must be free()'d. + * @return String with the backup file, typically given to dc_imex(), returned strings must be free()'d. * The function returns NULL if no backup was found. * * Example: @@ -1300,7 +1300,7 @@ cleanup: * void ask_user_for_credentials() * { * // - ask the user for email and password - * // - save them using mrmailbox_set_config() + * // - save them using dc_set_config() * } * * int ask_user_whether_to_import() @@ -1311,26 +1311,26 @@ cleanup: * return 1; * } * - * if( !mrmailbox_is_configured(mailbox) ) + * if( !dc_is_configured(mailbox) ) * { * char* file = NULL; - * if( (file=mrmailbox_imex_has_backup(mailbox, dir))!=NULL && ask_user_whether_to_import() ) + * if( (file=dc_imex_has_backup(mailbox, dir))!=NULL && ask_user_whether_to_import() ) * { - * mrmailbox_imex(mailbox, MR_IMEX_IMPORT_BACKUP, file, NULL); - * mrmailbox_connect(mailbox); + * dc_imex(mailbox, DC_IMEX_IMPORT_BACKUP, file, NULL); + * // connect * } * else * { * do { * ask_user_for_credentials(); * } - * while( !mrmailbox_configure(mailbox) ) + * while( !configure_succeeded() ) * } * free(file); * } * ``` */ -char* mrmailbox_imex_has_backup(mrmailbox_t* mailbox, const char* dir_name) +char* dc_imex_has_backup(dc_context_t* mailbox, const char* dir_name) { char* ret = NULL; time_t ret_backup_time = 0; @@ -1389,14 +1389,14 @@ cleanup: * Check if the user is authorized by the given password in some way. * This is to promt for the password eg. before exporting keys/backup. * - * @memberof mrmailbox_t + * @memberof dc_context_t * - * @param mailbox Mailbox object as created by mrmailbox_new(). + * @param mailbox Mailbox object as created by dc_context_new(). * @param test_pw Password to check. * * @return 1=user is authorized, 0=user is not authorized. */ -int mrmailbox_check_password(mrmailbox_t* mailbox, const char* test_pw) +int dc_check_password(dc_context_t* mailbox, const char* test_pw) { /* Check if the given password matches the configured mail_pw. This is to prompt the user before starting eg. an export; this is mainly to avoid doing people bad thinkgs if they have short access to the device. diff --git a/src/mrmailbox_qr.c b/src/mrmailbox_qr.c index aad689e4..31563392 100644 --- a/src/mrmailbox_qr.c +++ b/src/mrmailbox_qr.c @@ -37,14 +37,14 @@ * The function should be called after a QR code is scanned. * The function takes the raw text scanned and checks what can be done with it. * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @param qr The text of the scanned QR code. * - * @return Parsed QR code as an mrlot_t object. + * @return Parsed QR code as an dc_lot_t object. */ -mrlot_t* mrmailbox_check_qr(mrmailbox_t* mailbox, const char* qr) +dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr) { int locked = 0; char* payload = NULL; diff --git a/src/mrmailbox_securejoin.c b/src/mrmailbox_securejoin.c index 78b5422d..bad6ada9 100644 --- a/src/mrmailbox_securejoin.c +++ b/src/mrmailbox_securejoin.c @@ -337,11 +337,11 @@ static void end_bobs_joining(mrmailbox_t* mailbox, int status) * fingerprint comparison also works eg. with K-9 or OpenKeychain. * * The scanning Delta Chat device will pass the scanned content to - * mrmailbox_check_qr() then; if this function returns - * MR_QR_ASK_VERIFYCONTACT or MR_QR_ASK_VERIFYGROUP an out-of-band-verification - * can be joined using mrmailbox_join_securejoin() + * dc_check_qr() then; if this function returns + * DC_QR_ASK_VERIFYCONTACT or DC_QR_ASK_VERIFYGROUP an out-of-band-verification + * can be joined using dc_join_securejoin() * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object. * @@ -350,7 +350,7 @@ static void end_bobs_joining(mrmailbox_t* mailbox, int status) * * @return Text that should go to the qr code. */ -char* mrmailbox_get_securejoin_qr(mrmailbox_t* mailbox, uint32_t group_chat_id) +char* dc_get_securejoin_qr(dc_context_t* mailbox, uint32_t group_chat_id) { /* ========================================================= ==== Alice - the inviter side ==== @@ -444,19 +444,19 @@ cleanup: /** - * Join an out-of-band-verification initiated on another device with mrmailbox_get_securejoin_qr(). - * This function is typically called when mrmailbox_check_qr() returns - * lot.m_state=MR_QR_ASK_VERIFYCONTACT or lot.m_state=MR_QR_ASK_VERIFYGROUP. + * Join an out-of-band-verification initiated on another device with dc_get_securejoin_qr(). + * This function is typically called when dc_check_qr() returns + * lot.m_state=DC_QR_ASK_VERIFYCONTACT or lot.m_state=DC_QR_ASK_VERIFYGROUP. * * This function takes some time and sends and receives several messages. * You should call it in a separate thread; if you want to abort it, you should - * call mrmailbox_stop_ongoing_process(). + * call dc_stop_ongoing_process(). * - * @memberof mrmailbox_t + * @memberof dc_context_t * * @param mailbox The mailbox object * @param qr The text of the scanned QR code. Typically, the same string as given - * to mrmailbox_check_qr(). + * to dc_check_qr(). * * @return 0=Out-of-band verification failed or aborted, 1=Out-of-band * verification successfull, the UI may redirect to the corresponding chat @@ -468,7 +468,7 @@ cleanup: * - for a qr-scan to add a contact (even without handshake), opening the created normal-chat is better * (for vg-request always the new group is shown, this is perfect) */ -uint32_t mrmailbox_join_securejoin(mrmailbox_t* mailbox, const char* qr) +uint32_t dc_join_securejoin(dc_context_t* mailbox, const char* qr) { /* ========================================================== ==== Bob - the joiner's side ===== diff --git a/src/mrmsg.c b/src/mrmsg.c index 97a3aa1a..aef0ae92 100644 --- a/src/mrmsg.c +++ b/src/mrmsg.c @@ -32,19 +32,19 @@ /** * Create new message object. Message objects are needed eg. for sending messages using - * mrmailbox_send_msg(). Moreover, they are returned eg. from mrmailbox_get_msg(), + * dc_send_msg(). Moreover, they are returned eg. from dc_get_msg(), * set up with the current state of a message. The message object is not updated; * to achieve this, you have to recreate it. * - * @private @memberof mrmsg_t + * @private @memberof dc_msg_t * * @return The created message object. */ -mrmsg_t* mrmsg_new() +dc_msg_t* dc_msg_new() { - mrmsg_t* ths = NULL; + dc_msg_t* ths = NULL; - if( (ths=calloc(1, sizeof(mrmsg_t)))==NULL ) { + if( (ths=calloc(1, sizeof(dc_msg_t)))==NULL ) { exit(15); /* cannot allocate little memory, unrecoverable error */ } @@ -58,15 +58,15 @@ mrmsg_t* mrmsg_new() /** - * Free a message object. Message objects are created eg. by mrmailbox_get_msg(). + * Free a message object. Message objects are created eg. by dc_get_msg(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object to free. * * @return None. */ -void mrmsg_unref(mrmsg_t* msg) +void dc_msg_unref(dc_msg_t* msg) { if( msg==NULL || msg->m_magic != MR_MSG_MAGIC ) { return; @@ -82,13 +82,13 @@ void mrmsg_unref(mrmsg_t* msg) /** * Empty a message object. * - * @private @memberof mrmsg_t + * @private @memberof dc_msg_t * * @param msg The message object to empty. * * @return None. */ -void mrmsg_empty(mrmsg_t* msg) +void dc_msg_empty(dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return; @@ -119,13 +119,13 @@ void mrmsg_empty(mrmsg_t* msg) /** * Get the ID of the message. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return the ID of the message, 0 on errors. */ -uint32_t mrmsg_get_id(const mrmsg_t* msg) +uint32_t dc_msg_get_id(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -137,20 +137,20 @@ uint32_t mrmsg_get_id(const mrmsg_t* msg) /** * Get the ID of contact who wrote the message. * - * If the ID is equal to MR_CONTACT_ID_SELF (1), the message is an outgoing + * If the ID is equal to DC_CONTACT_ID_SELF (1), the message is an outgoing * message that is typically shown on the right side of the chat view. * * Otherwise, the message is an incoming message; to get details about the sender, - * pass the returned ID to mrmailbox_get_contact(). + * pass the returned ID to dc_get_contact(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * - * @return the ID of the contact who wrote the message, MR_CONTACT_ID_SELF (1) + * @return the ID of the contact who wrote the message, DC_CONTACT_ID_SELF (1) * if this is an outgoing message, 0 on errors. */ -uint32_t mrmsg_get_from_id(const mrmsg_t* msg) +uint32_t dc_msg_get_from_id(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -161,17 +161,17 @@ uint32_t mrmsg_get_from_id(const mrmsg_t* msg) /** * Get the ID of chat the message belongs to. - * To get details about the chat, pass the returned ID to mrmailbox_get_chat(). - * If a message is still in the deaddrop, the ID MR_CHAT_ID_DEADDROP is returned + * To get details about the chat, pass the returned ID to dc_get_chat(). + * If a message is still in the deaddrop, the ID DC_CHAT_ID_DEADDROP is returned * although internally another ID is used. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return the ID of the chat the message belongs to, 0 on errors. */ -uint32_t mrmsg_get_chat_id(const mrmsg_t* msg) +uint32_t dc_msg_get_chat_id(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -183,15 +183,15 @@ uint32_t mrmsg_get_chat_id(const mrmsg_t* msg) /** * Get the type of the message. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * - * @return One of MR_MSG_TEXT (10), MR_MSG_IMAGE (20), MR_MSG_GIF (21), - * MR_MSG_AUDIO (40), MR_MSG_VOICE (41), MR_MSG_VIDEO (50), MR_MSG_FILE (60) - * or MR_MSG_UNDEFINED (0) if the type is undefined. + * @return One of DC_MSG_TEXT (10), DC_MSG_IMAGE (20), DC_MSG_GIF (21), + * DC_MSG_AUDIO (40), DC_MSG_VOICE (41), DC_MSG_VIDEO (50), DC_MSG_FILE (60) + * or DC_MSG_UNDEFINED (0) if the type is undefined. */ -int mrmsg_get_type(const mrmsg_t* msg) +int dc_msg_get_type(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return MR_MSG_UNDEFINED; @@ -204,32 +204,32 @@ int mrmsg_get_type(const mrmsg_t* msg) * Get the state of a message. * * Incoming message states: - * - MR_STATE_IN_FRESH (10) - Incoming _fresh_ message. Fresh messages are not noticed nor seen and are typically shown in notifications. Use mrmailbox_get_fresh_msgs() to get all fresh messages. - * - MR_STATE_IN_NOTICED (13) - Incoming _noticed_ message. Eg. chat opened but message not yet read - noticed messages are not counted as unread but did not marked as read nor resulted in MDNs. Use mrmailbox_marknoticed_chat() or mrmailbox_marknoticed_contact() to mark messages as being noticed. - * - MR_STATE_IN_SEEN (16) - Incoming message, really _seen_ by the user. Marked as read on IMAP and MDN may be send. Use mrmailbox_markseen_msgs() to mark messages as being seen. + * - DC_STATE_IN_FRESH (10) - Incoming _fresh_ message. Fresh messages are not noticed nor seen and are typically shown in notifications. Use dc_get_fresh_msgs() to get all fresh messages. + * - DC_STATE_IN_NOTICED (13) - Incoming _noticed_ message. Eg. chat opened but message not yet read - noticed messages are not counted as unread but did not marked as read nor resulted in MDNs. Use dc_marknoticed_chat() or dc_marknoticed_contact() to mark messages as being noticed. + * - DC_STATE_IN_SEEN (16) - Incoming message, really _seen_ by the user. Marked as read on IMAP and MDN may be send. Use dc_markseen_msgs() to mark messages as being seen. * * Outgoing message states: - * - MR_STATE_OUT_PENDING (20) - The user has send the "send" button but the + * - DC_STATE_OUT_PENDING (20) - The user has send the "send" button but the * message is not yet sent and is pending in some way. Maybe we're offline (no checkmark). - * - MR_STATE_OUT_ERROR (24) - _Unrecoverable_ error (_recoverable_ errors result in pending messages) - * - MR_STATE_OUT_DELIVERED (26) - Outgoing message successfully delivered to server (one checkmark). Note, that already delivered messages may get into the state MR_STATE_OUT_ERROR if we get such a hint from the server. + * - DC_STATE_OUT_ERROR (24) - _Unrecoverable_ error (_recoverable_ errors result in pending messages) + * - DC_STATE_OUT_DELIVERED (26) - Outgoing message successfully delivered to server (one checkmark). Note, that already delivered messages may get into the state DC_STATE_OUT_ERROR if we get such a hint from the server. * If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_DELIVERED. - * - MR_STATE_OUT_MDN_RCVD (28) - Outgoing message read by the recipient (two checkmarks; this requires goodwill on the receiver's side) + * - DC_STATE_OUT_MDN_RCVD (28) - Outgoing message read by the recipient (two checkmarks; this requires goodwill on the receiver's side) * If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_READ. * - * If you just want to check if a message is sent or not, please use mrmsg_is_sent() which regards all states accordingly. + * If you just want to check if a message is sent or not, please use dc_msg_is_sent() which regards all states accordingly. * - * The state of just created message objects is MR_STATE_UNDEFINED (0). + * The state of just created message objects is DC_STATE_UNDEFINED (0). * The state is always set by the core-library, users of the library cannot set the state directly, but it is changed implicitly eg. - * when calling mrmailbox_marknoticed_chat() or mrmailbox_markseen_msgs(). + * when calling dc_marknoticed_chat() or dc_markseen_msgs(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return The state of the message. */ -int mrmsg_get_state(const mrmsg_t* msg) +int dc_msg_get_state(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return MR_STATE_UNDEFINED; @@ -244,13 +244,13 @@ int mrmsg_get_state(const mrmsg_t* msg) * Cave: the message list is sorted by receiving time (otherwise new messages would non pop up at the expected place), * however, if a message is delayed for any reason, the correct sending time will be displayed. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return The time of the message. */ -time_t mrmsg_get_timestamp(const mrmsg_t* msg) +time_t dc_msg_get_timestamp(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -273,15 +273,15 @@ time_t mrmsg_get_timestamp(const mrmsg_t* msg) * result eg. from decoding errors (assume some bytes missing in a mime structure, forcing * an attachment to be plain text). * - * To get information about the message and more/raw text, use mrmailbox_get_msg_info(). + * To get information about the message and more/raw text, use dc_get_msg_info(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return Message text. The result must be free()'d. Never returns NULL. */ -char* mrmsg_get_text(const mrmsg_t* msg) +char* dc_msg_get_text(const dc_msg_t* msg) { char* ret; @@ -302,7 +302,7 @@ char* mrmsg_get_text(const mrmsg_t* msg) * Typically files are associated with images, videos, audios, documents. * Plain text messages do not have a file. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * @@ -310,7 +310,7 @@ char* mrmsg_get_text(const mrmsg_t* msg) * message. If there is no file associated with the message, an emtpy * string is returned. NULL is never returned and the returned value must be free()'d. */ -char* mrmsg_get_file(const mrmsg_t* msg) +char* dc_msg_get_file(const dc_msg_t* msg) { char* ret = NULL; @@ -327,9 +327,9 @@ cleanup: /** * Get base file name without path. The base file name includes the extension; the path - * is not returned. To get the full path, use mrmsg_get_file(). + * is not returned. To get the full path, use dc_msg_get_file(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * @@ -337,7 +337,7 @@ cleanup: * associated with the message, an empty string is returned. The returned * value must be free()'d. */ -char* mrmsg_get_filename(const mrmsg_t* msg) +char* dc_msg_get_filename(const dc_msg_t* msg) { char* ret = NULL, *pathNfilename = NULL; @@ -363,13 +363,13 @@ cleanup: * If there is no associated mime type with the file, the function guesses on; if * in doubt, `application/octet-stream` is returned. NULL is never returned. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return String containing the mime type. Must be free()'d after usage. NULL is never returned. */ -char* mrmsg_get_filemime(const mrmsg_t* msg) +char* dc_msg_get_filemime(const dc_msg_t* msg) { char* ret = NULL; char* file = NULL; @@ -403,13 +403,13 @@ cleanup: * * Typically, this is used to show the size of document messages, eg. a PDF. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return File size in bytes, 0 if not applicable or on errors. */ -uint64_t mrmsg_get_filebytes(const mrmsg_t* msg) +uint64_t dc_msg_get_filebytes(const dc_msg_t* msg) { uint64_t ret = 0; char* file = NULL; @@ -434,24 +434,24 @@ cleanup: /** * Get real author and title. * - * The information is returned by a mrlot_t object with the following fields: + * The information is returned by a dc_lot_t object with the following fields: * - * - mrlot_t::m_text1: Author of the media. For voice messages, this is the sender. + * - dc_lot_t::m_text1: Author of the media. For voice messages, this is the sender. * For music messages, the information are read from the filename. NULL if unknown. * - * - mrlot_t::m_text2: Title of the media. For voice messages, this is the date. + * - dc_lot_t::m_text2: Title of the media. For voice messages, this is the date. * For music messages, the information are read from the filename. NULL if unknown. * * Currently, we do not read ID3 and such at this stage, the needed libraries are too complicated and oversized. * However, this is no big problem, as the sender usually sets the filename in a way we expect it. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * - * @return Media information as an mrlot_t object. Must be freed using mrlot_unref(). NULL is never returned. + * @return Media information as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned. */ -mrlot_t* mrmsg_get_mediainfo(const mrmsg_t* msg) +dc_lot_t* dc_msg_get_mediainfo(const dc_msg_t* msg) { mrlot_t* ret = mrlot_new(); char* pathNfilename = NULL; @@ -502,17 +502,17 @@ cleanup: * 0 is returned. * * Often the ascpect ratio is the more interesting thing. You can calculate - * this using mrmsg_get_width() / mrmsg_get_height(). + * this using dc_msg_get_width() / dc_msg_get_height(). * - * See also mrmsg_get_duration(). + * See also dc_msg_get_duration(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return Width in pixels, if applicable. 0 otherwise or if unknown. */ -int mrmsg_get_width(const mrmsg_t* msg) +int dc_msg_get_width(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -527,17 +527,17 @@ int mrmsg_get_width(const mrmsg_t* msg) * 0 is returned. * * Often the ascpect ratio is the more interesting thing. You can calculate - * this using mrmsg_get_width() / mrmsg_get_height(). + * this using dc_msg_get_width() / dc_msg_get_height(). * - * See also mrmsg_get_duration(). + * See also dc_msg_get_duration(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return Height in pixels, if applicable. 0 otherwise or if unknown. */ -int mrmsg_get_height(const mrmsg_t* msg) +int dc_msg_get_height(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -551,15 +551,15 @@ int mrmsg_get_height(const mrmsg_t* msg) * If the duration is unknown or if the associated file is no audio or video file, * 0 is returned. * - * See also mrmsg_get_width() and mrmsg_get_height(). + * See also dc_msg_get_width() and dc_msg_get_height(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return Duration in milliseconds, if applicable. 0 otherwise or if unknown. */ -int mrmsg_get_duration(const mrmsg_t* msg) +int dc_msg_get_duration(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -571,13 +571,13 @@ int mrmsg_get_duration(const mrmsg_t* msg) /** * Check if a padlock should be shown beside the message. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=padlock should be shown beside message, 0=do not show a padlock beside the message. */ -int mrmsg_get_showpadlock(const mrmsg_t* msg) +int dc_msg_get_showpadlock(const dc_msg_t* msg) { /* a padlock guarantees that the message is e2ee _and_ answers will be as well */ int show_encryption_state = 0; @@ -608,33 +608,33 @@ int mrmsg_get_showpadlock(const mrmsg_t* msg) /** * Get a summary for a message. * - * The summary is returned by a mrlot_t object with the following fields: + * The summary is returned by a dc_lot_t object with the following fields: * - * - mrlot_t::m_text1: contains the username or the string "Me". + * - dc_lot_t::m_text1: contains the username or the string "Me". * The string may be colored by having a look at m_text1_meaning. * If the name should not be displayed, the element is NULL. * - * - mrlot_t::m_text1_meaning: one of MR_TEXT1_USERNAME or MR_TEXT1_SELF. - * Typically used to show mrlot_t::m_text1 with different colors. 0 if not applicable. + * - dc_lot_t::m_text1_meaning: one of DC_TEXT1_USERNAME or DC_TEXT1_SELF. + * Typically used to show dc_lot_t::m_text1 with different colors. 0 if not applicable. * - * - mrlot_t::m_text2: contains an excerpt of the message text. + * - dc_lot_t::m_text2: contains an excerpt of the message text. * - * - mrlot_t::m_timestamp: the timestamp of the message. + * - dc_lot_t::m_timestamp: the timestamp of the message. * - * - mrlot_t::m_state: The state of the message as one of the MR_STATE_* constants (see #mrmsg_get_state()). + * - dc_lot_t::m_state: The state of the message as one of the DC_STATE_* constants (see #dc_msg_get_state()). * - * Typically used to display a search result. See also mrchatlist_get_summary() to display a list of chats. + * Typically used to display a search result. See also dc_chatlist_get_summary() to display a list of chats. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @param chat To speed up things, pass an already available chat object here. * If the chat object is not yet available, it is faster to pass NULL. * - * @return The summary as an mrlot_t object. Must be freed using mrlot_unref(). NULL is never returned. + * @return The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned. */ -mrlot_t* mrmsg_get_summary(const mrmsg_t* msg, const mrchat_t* chat) +dc_lot_t* dc_msg_get_summary(const dc_msg_t* msg, const dc_chat_t* chat) { mrlot_t* ret = mrlot_new(); mrcontact_t* contact = NULL; @@ -668,7 +668,7 @@ cleanup: * Get a message summary as a single line of text. Typically used for * notifications. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * @@ -677,7 +677,7 @@ cleanup: * @return A summary for the given messages. The returned string must be free()'d. * Returns an empty string on errors, never returns NULL. */ -char* mrmsg_get_summarytext(const mrmsg_t* msg, int approx_characters) +char* dc_msg_get_summarytext(const dc_msg_t* msg, int approx_characters) { if( msg==NULL || msg->m_magic != MR_MSG_MAGIC ) { return safe_strdup(NULL); @@ -691,15 +691,15 @@ char* mrmsg_get_summarytext(const mrmsg_t* msg, int approx_characters) * Check if a message was sent successfully. * * Currently, "sent" messages are messages that are in the state "delivered" or "mdn received", - * see mrmsg_get_state(). + * see dc_msg_get_state(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=message sent successfully, 0=message not yet sent or message is an incoming message. */ -int mrmsg_is_sent(const mrmsg_t* msg) +int dc_msg_is_sent(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -713,16 +713,16 @@ int mrmsg_is_sent(const mrmsg_t* msg) * with a "star" or something like that. Starred messages can typically be shown * easily and are not deleted automatically. * - * To star one or more messages, use mrmailbox_star_msgs(), to get a list of starred messages, - * use mrmailbox_get_chat_msgs() using MR_CHAT_ID_STARRED as the chat_id. + * To star one or more messages, use dc_star_msgs(), to get a list of starred messages, + * use dc_get_chat_msgs() using DC_CHAT_ID_STARRED as the chat_id. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=message is starred, 0=message not starred. */ -int mrmsg_is_starred(const mrmsg_t* msg) +int dc_msg_is_starred(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -731,7 +731,6 @@ int mrmsg_is_starred(const mrmsg_t* msg) } - /** * Check if the message is a forwarded message. * @@ -744,13 +743,13 @@ int mrmsg_is_starred(const mrmsg_t* msg) * "forwared"; you won't expect other data to be send to the new recipient, * esp. as the new recipient may not be in any relationship to the original author) * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=message is a forwarded message, 0=message not forwarded. */ -int mrmsg_is_forwarded(const mrmsg_t* msg) +int dc_msg_is_forwarded(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -762,22 +761,22 @@ int mrmsg_is_forwarded(const mrmsg_t* msg) /** * Check if the message is an informational message, created by the * device or by another users. Such messages are not "typed" by the user but - * created due to other actions, eg. mrmailbox_set_chat_name(), mrmailbox_set_chat_profile_image() - * or mrmailbox_add_contact_to_chat(). + * created due to other actions, eg. dc_set_chat_name(), dc_set_chat_profile_image() + * or dc_add_contact_to_chat(). * * These messages are typically shown in the center of the chat view, - * mrmsg_get_text() returns a descriptive text about what is going on. + * dc_msg_get_text() returns a descriptive text about what is going on. * * There is no need to perfrom any action when seeing such a message - this is already done by the core. * Typically, these messages are displayed in the center of the chat. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=message is a system command, 0=normal message */ -int mrmsg_is_info(const mrmsg_t* msg) +int dc_msg_is_info(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC ) { return 0; @@ -800,18 +799,18 @@ int mrmsg_is_info(const mrmsg_t* msg) * * Setup messages should be shown in an unique way eg. using a different text color. * On a click or another action, the user should be prompted for the setup code - * which is forwarded to mrmailbox_continue_key_transfer() then. + * which is forwarded to dc_continue_key_transfer() then. * - * Setup message are typically generated by mrmailbox_initiate_key_transfer() on another device. + * Setup message are typically generated by dc_initiate_key_transfer() on another device. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return 1=message is a setup message, 0=no setup message. - * For setup messages, mrmsg_get_type() returns MR_MSG_FILE. + * For setup messages, dc_msg_get_type() returns DC_MSG_FILE. */ -int mrmsg_is_setupmessage(const mrmsg_t* msg) +int dc_msg_is_setupmessage(const dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_type != MR_MSG_FILE ) { return 0; @@ -827,17 +826,17 @@ int mrmsg_is_setupmessage(const mrmsg_t* msg) * Typically, this is used to pre-fill the first entry field of the setup code. * If the user has several setup messages, he can be sure typing in the correct digits. * - * To check, if a message is a setup message, use mrmsg_is_setupmessage(). - * To decrypt a secret key from a setup message, use mrmailbox_continue_key_transfer(). + * To check, if a message is a setup message, use dc_msg_is_setupmessage(). + * To decrypt a secret key from a setup message, use dc_continue_key_transfer(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * * @return Typically, the first two digits of the setup code or an empty string if unknown. * NULL is never returned. Must be free()'d when done. */ -char* mrmsg_get_setupcodebegin(const mrmsg_t* msg) +char* dc_msg_get_setupcodebegin(const dc_msg_t* msg) { char* filename = NULL; char* buf = NULL; @@ -882,7 +881,7 @@ cleanup: " m.param,m.starred,m.hidden,c.blocked " -static int mrmsg_set_from_stmt__(mrmsg_t* ths, sqlite3_stmt* row, int row_offset) /* field order must be MR_MSG_FIELDS */ +static int mrmsg_set_from_stmt__(dc_msg_t* ths, sqlite3_stmt* row, int row_offset) /* field order must be MR_MSG_FIELDS */ { mrmsg_empty(ths); @@ -922,9 +921,9 @@ static int mrmsg_set_from_stmt__(mrmsg_t* ths, sqlite3_stmt* row, int row_offset * * Calling this function is not thread-safe, locking is up to the caller. * - * @private @memberof mrmsg_t + * @private @memberof dc_msg_t */ -int mrmsg_load_from_db__(mrmsg_t* ths, mrmailbox_t* mailbox, uint32_t id) +int mrmsg_load_from_db__(dc_msg_t* ths, mrmailbox_t* mailbox, uint32_t id) { sqlite3_stmt* stmt; @@ -955,11 +954,11 @@ int mrmsg_load_from_db__(mrmsg_t* ths, mrmailbox_t* mailbox, uint32_t id) /** * Guess message type from suffix. * - * @private @memberof mrmsg_t + * @private @memberof dc_msg_t * * @param pathNfilename Path and filename of the file to guess the type for. * - * @param[out] ret_msgtype Guessed message type is copied here as one of the MR_MSG_* constants. + * @param[out] ret_msgtype Guessed message type is copied here as one of the DC_MSG_* constants. * May be NULL if you're not interested in this value. * * @param[out] ret_mime The pointer to a string buffer is set to the guessed MIME-type. May be NULL. Must be free()'d by the caller. @@ -1095,7 +1094,7 @@ char* mrmsg_get_summarytext_by_raw(int type, const char* text, mrparam_t* param, } -int mrmsg_is_increation__(const mrmsg_t* msg) +int mrmsg_is_increation__(const dc_msg_t* msg) { int is_increation = 0; if( MR_MSG_NEEDS_ATTACHMENT(msg->m_type) ) @@ -1123,14 +1122,14 @@ int mrmsg_is_increation__(const mrmsg_t* msg) * Typically, this is used for videos that should be recoded by the user before * they can be sent. * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg the message object * * @return 1=message is still in creation (`.increation` exists), * 0=message no longer in creation */ -int mrmsg_is_increation(const mrmsg_t* msg) +int dc_msg_is_increation(const dc_msg_t* msg) { /* surrounds mrmsg_is_increation__() with locking and error checking */ int is_increation = 0; @@ -1152,7 +1151,7 @@ int mrmsg_is_increation(const mrmsg_t* msg) } -void mrmsg_save_param_to_disk__(mrmsg_t* msg) +void mrmsg_save_param_to_disk__(dc_msg_t* msg) { if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_mailbox == NULL || msg->m_mailbox->m_sql == NULL ) { return; @@ -1175,12 +1174,12 @@ void mrmsg_save_param_to_disk__(mrmsg_t* msg) * If, in these cases, the frontend can provide the information, it can save * them together with the message object for later usage. * - * This function should only be used if mrmsg_get_width(), mrmsg_get_height() or mrmsg_get_duration() + * This function should only be used if dc_msg_get_width(), dc_msg_get_height() or dc_msg_get_duration() * do not provide the expected values. * - * To get the stored values later, use mrmsg_get_width(), mrmsg_get_height() or mrmsg_get_duration(). + * To get the stored values later, use dc_msg_get_width(), dc_msg_get_height() or dc_msg_get_duration(). * - * @memberof mrmsg_t + * @memberof dc_msg_t * * @param msg The message object. * @@ -1192,7 +1191,7 @@ void mrmsg_save_param_to_disk__(mrmsg_t* msg) * * @return None. */ -void mrmsg_latefiling_mediasize(mrmsg_t* msg, int width, int height, int duration) +void dc_msg_latefiling_mediasize(dc_msg_t* msg, int width, int height, int duration) { int locked = 0;