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  uint32_t m_magic;
53  uint32_t m_id;
54  #define MR_CHAT_ID_DEADDROP 1
55  #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) */
56  #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) */
57  #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) */
58  #define MR_CHAT_ID_STARRED 5
59  #define MR_CHAT_ID_ARCHIVED_LINK 6
60  #define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
61 
62 
64  int m_type;
65  #define MR_CHAT_TYPE_UNDEFINED 0
66  #define MR_CHAT_TYPE_NORMAL 100
67  #define MR_CHAT_TYPE_GROUP 120
68 
69  char* m_name;
70  char* m_draft_text;
71  time_t m_draft_timestamp;
72  int m_archived;
73  mrmailbox_t* m_mailbox;
74  char* m_grpid;
75  mrparam_t* m_param;
76 } mrchat_t;
77 
78 
79 mrchat_t* mrchat_new (mrmailbox_t*);
80 void mrchat_empty (mrchat_t*);
81 void mrchat_unref (mrchat_t*);
82 
84 char* mrchat_get_name (mrchat_t*);
87 char* mrchat_get_draft (mrchat_t*);
91 
92 /* library-internal */
93 int mrchat_load_from_db__ (mrchat_t*, uint32_t id);
94 int mrchat_update_param__ (mrchat_t*);
95 
96 #define MR_CHAT_PREFIX "Chat:" /* you MUST NOT modify this or the following strings */
97 #define MR_CHATS_FOLDER "Chats" /* if we want to support Gma'l-labels - "Chats" is a reserved word for Gma'l */
98 
99 
100 #ifdef __cplusplus
101 } /* /extern "C" */
102 #endif
103 #endif /* __MRCHAT_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:194
void mrchat_unref(mrchat_t *chat)
Free a chat object.
Definition: mrchat.c:68
int mrchat_get_archived(mrchat_t *chat)
Get archived state.
Definition: mrchat.c:303
char * mrchat_get_draft(mrchat_t *chat)
Get draft for the chat, if any.
Definition: mrchat.c:277
char * mrchat_get_name(mrchat_t *chat)
Get name of a chat.
Definition: mrchat.c:156
int mrchat_is_self_talk(mrchat_t *chat)
Check if a chat is a self talk.
Definition: mrchat.c:346
int mrchat_get_type(mrchat_t *chat)
Get chat type.
Definition: mrchat.c:132
char * mrchat_get_profile_image(mrchat_t *chat)
Get the chat's profile image.
Definition: mrchat.c:254
int mrchat_is_unpromoted(mrchat_t *chat)
Check if a chat is still unpromoted.
Definition: mrchat.c:327
uint32_t m_id
Chat ID under which the chat is filed in the database.
Definition: mrchat.h:53
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:178