1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00
This commit is contained in:
B. Petersen 2017-11-13 18:51:48 +01:00
parent e0dd037cb0
commit 077897c6ab
6 changed files with 448 additions and 0 deletions

74
src/mrchat.h Normal file
View file

@ -0,0 +1,74 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRCHAT_H__
#define __MRCHAT_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mrmailbox_t mrmailbox_t;
typedef struct mrparam_t mrparam_t;
/**
* Create and access chat objects. Chat objects are created using eg. mrmailbox_get_chat() and
* are not updated on database changes; if you want an update, you have to recreate the
* object.
*/
typedef struct mrchat_t
{
#define MR_CHAT_ID_DEADDROP 1 /* messages send from unknown/unwanted users to us, chats_contacts is not set up. This group may be shown normally. */
#define MR_CHAT_ID_TO_DEADDROP 2 /* messages send from us to unknown/unwanted users (this may happen when deleting chats or when using CC: in the email-program) */
#define MR_CHAT_ID_TRASH 3 /* messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again) */
#define MR_CHAT_ID_MSGS_IN_CREATION 4 /* a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be send and shown) */
#define MR_CHAT_ID_STARRED 5 /* virtual chat containing all starred messages */
#define MR_CHAT_ID_ARCHIVED_LINK 6 /* a link at the end of the chatlist, if present the UI should show the button "Archived chats" */
#define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
uint32_t m_id;
#define MR_CHAT_TYPE_UNDEFINED 0
#define MR_CHAT_TYPE_NORMAL 100 /* a normal chat is a chat with a single contact, chats_contacts contains one record for the user, MR_CONTACT_ID_SELF is not added. */
#define MR_CHAT_TYPE_GROUP 120 /* a group chat, chats_contacts conain all group members, incl. MR_CONTACT_ID_SELF */
int m_type;
char* m_name; /**< NULL if unset */
time_t m_draft_timestamp; /**< 0 if there is no draft */
char* m_draft_text; /**< NULL if unset */
mrmailbox_t* m_mailbox; /**< != NULL */
int m_archived; /**< 1=chat archived, this state should always be shown the UI, eg. the search will also return archived chats */
mrparam_t* m_param; /**< != NULL */
/** @privatesection */
char* m_grpid; /* NULL if unset */
} mrchat_t;
void mrchat_unref (mrchat_t*);
char* mrchat_get_subtitle (mrchat_t*);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRCHAT_H__ */

61
src/mrchatlist.h Normal file
View file

@ -0,0 +1,61 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRCHATLIST_H__
#define __MRCHATLIST_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mrmailbox_t mrmailbox_t;
typedef struct mrpoortext_t mrpoortext_t;
typedef struct mrchat_t mrchat_t;
/**
* Chatlist objects contain a chat IDs and, if possible, message IDs belonging to them.
* Chatlist objects are created eg. using mrmailbox_get_chatlist().
* The chatlist object is not updated. If you want an update, you have to recreate
* the object.
*/
typedef struct mrchatlist_t
{
mrmailbox_t* m_mailbox; /**< The mailbox, the chatlist belongs to */
/** @privatesection */
size_t m_cnt;
carray* m_chatNlastmsg_ids;
} mrchatlist_t;
void mrchatlist_unref (mrchatlist_t*);
size_t mrchatlist_get_cnt (mrchatlist_t*);
uint32_t mrchatlist_get_chat_id (mrchatlist_t*, size_t index);
uint32_t mrchatlist_get_msg_id (mrchatlist_t*, size_t index);
mrpoortext_t* mrchatlist_get_summary (mrchatlist_t*, size_t index, mrchat_t*);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRCHATLIST_H__ */

62
src/mrcontact.h Normal file
View file

@ -0,0 +1,62 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRCONTACT_H__
#define __MRCONTACT_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mrsqlite3_t mrsqlite3_t;
/**
* The contact object.
* The contact object is not updated. If you want an update, you have to recreate
* the object.
*/
typedef struct mrcontact_t
{
#define MR_CONTACT_ID_SELF 1
#define MR_CONTACT_ID_SYSTEM 2
#define MR_CONTACT_ID_LAST_SPECIAL 9
uint32_t m_id;
char* m_name; /* may be NULL or empty, this name should not be spreaded as it may be "Daddy" and so on; initially set to m_authname */
char* m_authname; /* may be NULL or empty, this is the name authorized by the sender, only this name may be speaded to others, eg. in To:-lists; for displaying in the app, use m_name */
char* m_addr; /* may be NULL or empty */
int m_origin;
int m_blocked;
} mrcontact_t;
mrcontact_t* mrcontact_new (); /* the returned pointer is ref'd and must be unref'd after usage */
void mrcontact_empty (mrcontact_t*);
void mrcontact_unref (mrcontact_t*);
int mrcontact_load_from_db__ (mrcontact_t*, mrsqlite3_t*, uint32_t contact_id);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRCONTACT_H__ */

101
src/mrmsg.h Normal file
View file

@ -0,0 +1,101 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRMSG_H__
#define __MRMSG_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mrmailbox_t mrmailbox_t;
typedef struct mrparam_t mrparam_t;
/**
* The message object and some function for helping accessing it. The message
* object is not updated. If you want an update, you have to recreate the
* object.
*/
typedef struct mrmsg_t
{
#define MR_MSG_ID_MARKER1 1 /**< any user-defined marker */
#define MR_MSG_ID_DAYMARKER 9 /**< in a list, the next message is on a new day, useful to show headlines */
#define MR_MSG_ID_LAST_SPECIAL 9
uint32_t m_id;
uint32_t m_from_id; /**< contact, 0=unset, 1=self .. >9=real contacts */
uint32_t m_to_id; /**< contact, 0=unset, 1=self .. >9=real contacts */
uint32_t m_chat_id; /**< the chat, the message belongs to: 0=unset, 1=unknwon sender .. >9=real chats */
time_t m_timestamp; /**< unix time the message was sended */
#define MR_MSG_UNDEFINED 0
#define MR_MSG_TEXT 10
#define MR_MSG_IMAGE 20 /**< param: MRP_FILE, MRP_WIDTH, MRP_HEIGHT */
#define MR_MSG_GIF 21 /**< param: MRP_FILE, MRP_WIDTH, MRP_HEIGHT */
#define MR_MSG_AUDIO 40 /**< param: MRP_FILE, MRP_DURATION */
#define MR_MSG_VOICE 41 /**< param: MRP_FILE, MRP_DURATION */
#define MR_MSG_VIDEO 50 /**< param: MRP_FILE, MRP_WIDTH, MRP_HEIGHT, MRP_DURATION */
#define MR_MSG_FILE 60 /**< param: MRP_FILE */
int m_type;
#define MR_STATE_UNDEFINED 0
#define MR_STATE_IN_FRESH 10 /**< incoming message, not noticed nor seen */
#define MR_STATE_IN_NOTICED 13 /**< incoming message noticed (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) */
#define MR_STATE_IN_SEEN 16 /**< incoming message marked as read on IMAP and MDN may be send */
#define MR_STATE_OUT_PENDING 20 /**< hit "send" button - but the message is pending in some way, maybe we're offline (no checkmark) */
#define MR_STATE_OUT_ERROR 24 /**< unrecoverable error (recoverable errors result in pending messages) */
#define MR_STATE_OUT_DELIVERED 26 /**< outgoing message successfully delivered to server (one checkmark) */
#define MR_STATE_OUT_MDN_RCVD 28 /**< outgoing message read (two checkmarks; this requires goodwill on the receiver's side) */
int m_state;
char* m_text; /**< message text or NULL if unset */
mrparam_t* m_param; /**< MRP_FILE, MRP_WIDTH, MRP_HEIGHT etc. depends on the type, != NULL */
int m_starred;
/** @privatesection */
int m_is_msgrmsg;
mrmailbox_t* m_mailbox; /* may be NULL, set on loading from database and on sending */
char* m_rfc724_mid;
char* m_server_folder;
uint32_t m_server_uid;
} mrmsg_t;
mrmsg_t* mrmsg_new ();
void mrmsg_unref (mrmsg_t*);
void mrmsg_empty (mrmsg_t*);
mrpoortext_t* mrmsg_get_summary (mrmsg_t*, mrchat_t*);
char* mrmsg_get_summarytext (mrmsg_t*, int approx_characters);
int mrmsg_show_padlock (mrmsg_t*);
char* mrmsg_get_fullpath (mrmsg_t*);
char* mrmsg_get_filename (mrmsg_t*);
mrpoortext_t* mrmsg_get_mediainfo (mrmsg_t*);
int mrmsg_is_increation (mrmsg_t*);
void mrmsg_save_param_to_disk (mrmsg_t*);
void mrmsg_set_text (mrmsg_t*, const char* text);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRMSG_H__ */

87
src/mrparam.h Normal file
View file

@ -0,0 +1,87 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRPARAM_H__
#define __MRPARAM_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* Handle key=value parameters.
* The parameter object is used eg. by mrchat_t or mrmsg_t.
* To access the single parameters use the setter and getter functions with an
* MRP_* constant.
*/
typedef struct mrparam_t
{
/** @privatesection */
char* m_packed; /**< Always set, never NULL. */
} mrparam_t;
#define MRP_FILE 'f' /* for msgs */
#define MRP_WIDTH 'w' /* for msgs */
#define MRP_HEIGHT 'h' /* for msgs */
#define MRP_DURATION 'd' /* for msgs */
#define MRP_MIMETYPE 'm' /* for msgs */
#define MRP_AUTHORNAME 'N' /* for msgs: name of author or artist */
#define MRP_TRACKNAME 'n' /* for msgs: name of author or artist */
#define MRP_GUARANTEE_E2EE 'c' /* for msgs: 'c'rypted in original/guarantee E2EE or the message is not send */
#define MRP_ERRONEOUS_E2EE 'e' /* for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted */
#define MRP_WANTS_MDN 'r' /* for msgs: an incoming message which requestes a MDN (aka read receipt) */
#define MRP_FORWARDED 'a' /* for msgs */
#define MRP_SYSTEM_CMD 'S' /* for msgs */
#define MRP_SYSTEM_CMD_PARAM 'E' /* for msgs */
#define MRP_SERVER_FOLDER 'Z' /* for jobs */
#define MRP_SERVER_UID 'z' /* for jobs */
#define MRP_TIMES 't' /* for jobs: times a job was tried */
#define MRP_TIMES_INCREATION 'T' /* for jobs: times a job was tried, used for increation */
#define MRP_REFERENCES 'R' /* for groups and chats: References-header last used for a chat */
#define MRP_UNPROMOTED 'U' /* for groups */
#define MRP_PROFILE_IMAGE 'i' /* for groups and contacts */
#define MRP_DEL_AFTER_SEND 'P' /* for groups and msgs: physically delete group after message sending if msg-value matches group-value */
/* user functions */
int mrparam_exists (mrparam_t*, int key);
char* mrparam_get (mrparam_t*, int key, const char* def); /* the value may be an empty string, "def" is returned only if the value unset. The result must be free()'d in any case. */
int32_t mrparam_get_int (mrparam_t*, int key, int32_t def);
void mrparam_set (mrparam_t*, int key, const char* value);
void mrparam_set_int (mrparam_t*, int key, int32_t value);
/* library-private */
mrparam_t* mrparam_new ();
void mrparam_empty (mrparam_t*);
void mrparam_unref (mrparam_t*);
void mrparam_set_packed (mrparam_t*, const char*);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRPARAM_H__ */

63
src/mrpoortext.h Normal file
View file

@ -0,0 +1,63 @@
/*******************************************************************************
*
* Delta Chat Core
* Copyright (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
#ifndef __MRPOORTEXT_H__
#define __MRPOORTEXT_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* the poortext object and some function accessing it. A poortext object
* contains some strings together with their meaning and some attributes. The
* object is mainly used for summary returns of chats and chatlists
*/
typedef struct mrpoortext_t
{
int m_text1_meaning; /**< One of MR_TEXT1_NORMAL, MR_TEXT1_DRAFT, MR_TEXT1_USERNAME or MR_TEXT1_SELF */
char* m_text1; /**< may be NULL */
char* m_text2; /**< may be NULL */
time_t m_timestamp; /**< may be 0 */
int m_state; /**< may be 0 */
} mrpoortext_t;
#define MR_TEXT1_NORMAL 0 /**< @memberof mrpoortext_t */
#define MR_TEXT1_DRAFT 1 /**< @memberof mrpoortext_t */
#define MR_TEXT1_USERNAME 2 /**< @memberof mrpoortext_t */
#define MR_TEXT1_SELF 3 /**< @memberof mrpoortext_t */
mrpoortext_t* mrpoortext_new ();
void mrpoortext_empty (mrpoortext_t*);
void mrpoortext_unref (mrpoortext_t*);
#define MR_SUMMARY_CHARACTERS 160 /* in practice, the user additionally cuts the string himself pixel-accurate */
void mrpoortext_fill (mrpoortext_t*, const mrmsg_t*, const mrchat_t*, const mrcontact_t*);
#ifdef __cplusplus
} /* /extern "C" */
#endif
#endif /* __MRPOORTEXT_H__ */