Delta Chat Core C-API
mrchat.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRCHAT_H__
24 #define __MRCHAT_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct mrmailbox_t mrmailbox_t;
31 typedef struct mrparam_t mrparam_t;
32 
33 
39 typedef struct mrchat_t
40 {
41  #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. */
42  #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) */
43  #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) */
44  #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) */
45  #define MR_CHAT_ID_STARRED 5 /* virtual chat containing all starred messages */
46  #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" */
47  #define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
48  uint32_t m_id;
50  #define MR_CHAT_TYPE_UNDEFINED 0
51  #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. */
52  #define MR_CHAT_TYPE_GROUP 120 /* a group chat, chats_contacts conain all group members, incl. MR_CONTACT_ID_SELF */
53  int m_type;
55  char* m_name;
57  char* m_draft_text;
59  int m_archived;
63  char* m_grpid; /* NULL if unset */
64 } mrchat_t;
65 
66 
67 mrchat_t* mrchat_new (mrmailbox_t*);
68 void mrchat_empty (mrchat_t*);
69 void mrchat_unref (mrchat_t*);
71 
72 /* library-internal */
73 int mrchat_load_from_db__ (mrchat_t*, uint32_t id);
74 int mrchat_update_param__ (mrchat_t*);
75 
76 #define MR_CHAT_PREFIX "Chat:" /* you MUST NOT modify this or the following strings */
77 #define MR_CHATS_FOLDER "Chats" /* if we want to support Gma'l-labels - "Chats" is a reserved word for Gma'l */
78 
79 
80 #ifdef __cplusplus
81 } /* /extern "C" */
82 #endif
83 #endif /* __MRCHAT_H__ */
int m_type
Chat type, one of the MR_CHAT_TYPE_* constants.
Definition: mrchat.h:53
An object representing a single mailbox.
Definition: mrmailbox.h:176
void mrchat_unref(mrchat_t *chat)
Free a chat object.
Definition: mrchat.c:65
char * m_draft_text
NULL if unset.
Definition: mrchat.h:57
mrmailbox_t * m_mailbox
!= NULL
Definition: mrchat.h:58
mrparam_t * m_param
!= NULL
Definition: mrchat.h:60
void mrchat_empty(mrchat_t *chat)
Empty a chat object.
Definition: mrchat.c:86
int m_archived
1=chat archived, this state should always be shown the UI, eg.
Definition: mrchat.h:59
char * m_name
NULL if unset.
Definition: mrchat.h:55
An object for handling key=value parameter lists.
Definition: mrparam.h:36
time_t m_draft_timestamp
0 if there is no draft
Definition: mrchat.h:56
uint32_t m_id
Chat ID under which this object is available in the database.
Definition: mrchat.h:48
An object representing a single chat in memory.
Definition: mrchat.h:39
char * mrchat_get_subtitle(mrchat_t *chat)
Get a subtitle for a chat.
Definition: mrchat.c:120