diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 49ee1ec3..a1577cc7 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -87,13 +87,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
Here are the classes, structs, unions and interfaces with brief descriptions:
- - - - - - - + + + + + + +
 Cmrarray_tAn object containing a simple array
 Cmrchat_tAn object representing a single chat in memory
 Cmrchatlist_tAn object representing a single chatlist in memory
 Cmrcontact_tAn object representing a single contact in memory
 Cmrlot_tAn object containing a set of values
 Cmrmailbox_tAn object representing a single mailbox
 Cmrmsg_tAn object representing a single message in memory
 Cmrarray_tAn object containing a simple array
 Cmrchat_tAn object representing a single chat in memory
 Cmrchatlist_tAn object representing a single chatlist in memory
 Cmrcontact_tAn object representing a single contact in memory
 Cmrlot_tAn object containing a set of values
 Cmrmailbox_tAn object representing a single mailbox
 Cmrmsg_tAn object representing a single message in memory
diff --git a/docs/html/classes.html b/docs/html/classes.html index 140e2e96..9ef6a02e 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -88,9 +88,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
M
- - + + +
  m  
-
mrchat_t   mrcontact_t   mrmailbox_t   
mrchatlist_t   mrlot_t   mrmsg_t   
mrarray_t   
mrchat_t   mrcontact_t   mrmailbox_t   
mrchatlist_t   mrlot_t   mrmsg_t   
mrarray_t   
M
diff --git a/docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index e5f07256..fcfc024f 100644 --- a/docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -93,7 +93,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

Files

file  mrevent.h [code] - The following constants are used as events reported to the callback given to mrmailbox_new().
+ The following constants are used as events reported to the callback given to mrmailbox_new().
  diff --git a/docs/html/files.html b/docs/html/files.html index bd926c89..2ee1c8c5 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -90,34 +90,41 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');   src  mraheader.h  mrapeerstate.h - mrarray.h - mrchat.h - mrchatlist.h - mrcontact.h - mrdehtml.h - mrevent.hThe following constants are used as events reported to the callback given to mrmailbox_new() - mrhash.h - mrimap.h - mrjob.h - mrkey.h - mrkeyring.h - mrloginparam.h - mrlot.h - mrmailbox.h - mrmailbox_internal.h - mrmimefactory.h - mrmimeparser.h - mrmsg.h - mrosnative.h - mrparam.h - mrpgp.h - mrpoortext.h - mrsaxparser.h - mrsimplify.h - mrsmtp.h - mrsqlite3.h - mrstock.h - mrtools.h + mrarray-private.h + mrarray.h + mrchat-private.h + mrchat.h + mrchatlist-private.h + mrchatlist.h + mrcontact-private.h + mrcontact.h + mrdehtml.h + mrevent.hThe following constants are used as events reported to the callback given to mrmailbox_new() + mrhash.h + mrimap.h + mrjob.h + mrkey.h + mrkeyring.h + mrloginparam.h + mrlot-private.h + mrlot.h + mrmailbox-private.h + mrmailbox.h + mrmailbox_internal.h + mrmimefactory.h + mrmimeparser.h + mrmsg-private.h + mrmsg.h + mrosnative.h + mrparam.h + mrpgp.h + mrpoortext.h + mrsaxparser.h + mrsimplify.h + mrsmtp.h + mrsqlite3.h + mrstock.h + mrtools.h diff --git a/docs/html/functions.html b/docs/html/functions.html index a45a667b..984df723 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -69,7 +69,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); @@ -97,385 +96,401 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
Here is a list of all documented class members with links to the class documentation for each member:

- m -

diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 93be4acb..3f35748e 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -69,7 +69,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); @@ -98,349 +97,397 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

- m -

diff --git a/docs/html/functions_type.html b/docs/html/functions_type.html index 16dc554f..e67ebe15 100644 --- a/docs/html/functions_type.html +++ b/docs/html/functions_type.html @@ -69,7 +69,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); @@ -91,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
 
diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html deleted file mode 100644 index fc6765bf..00000000 --- a/docs/html/functions_vars.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - -Delta Chat Core C-API: Class Members - Variables - - - - - - - - - - - -
-
- - - - - - -
-
Delta Chat Core C-API -
-
-
- - - - - - -
- -
-
- - -
- -
- -
-
- - - - diff --git a/docs/html/index.html b/docs/html/index.html index c4ce7fef..ac4508dd 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -82,12 +82,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

This document describes how to handle the Delta Chat core library.For general information about Delta Chat itself, see https://delta.chat and https://github.com/deltachat.

Let's start.

First of all, you have to define a function that is called by the library on specific events (eg. when the configuration is done or when fresh messages arrive). Your function should look like the following:

-
#include <mrmailbox.h>
uintptr_t my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
{
return 0; // for unhandled events, it is always safe to return 0
}

After that, you can create and configure a mrmailbox_t object easily as follows:

-
mrmailbox_t* mailbox = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mailbox, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mailbox, "mail_pw", "***");

mrmailbox_configure_and_connect() may take a while and saves the result in the database. On subsequent starts, you can call mrmailbox_connect() instead if mrmailbox_is_configured() returns true.

+
#include <mrmailbox.h>
uintptr_t my_delta_handler(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
{
return 0; // for unhandled events, it is always safe to return 0
}

After that, you can create and configure a mrmailbox_t object easily as follows:

+
mrmailbox_t* mailbox = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mailbox, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mailbox, "mail_pw", "***");

mrmailbox_configure_and_connect() may take a while and saves the result in the database. On subsequent starts, you can call mrmailbox_connect() instead if mrmailbox_is_configured() returns true.

However, now you can send your first message:

-
uint32_t contact_id = mrmailbox_create_contact(mailbox, NULL, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mailbox, contact_id);
mrmailbox_send_text_msg(mailbox, chat_id, "Hi, here is my first message!");

Now, go to the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and you will get the message from delta as follows:

-
mrarray_t* msglist = mrmailbox_get_chat_msgs(mailbox, chat_id, 0, 0);
for( size_t i = 0; i < mrarray_get_cnt(msglist); i++ )
{
uint32_t msg_id = mrarray_get_id(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mailbox, msg_id);
char* text = mrmsg_get_text(msg);
printf("message %i: %s\n", i+1, text);
free(text);
}
mrarray_unref(msglist);

This will output the following two lines:

-
Message 1: Hi, here is my first message!
Message 2: Got it!

I think, you got the idea. For further reading, please dive into the mrmailbox_t class.

+
uint32_t contact_id = mrmailbox_create_contact(mailbox, NULL, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mailbox, contact_id);
mrmailbox_send_text_msg(mailbox, chat_id, "Hi, here is my first message!");

Now, go to the testing address (bob) and you should have received a normal email. Answer this email in any email program with "Got it!" and you will get the message from delta as follows:

+
mrarray_t* msglist = mrmailbox_get_chat_msgs(mailbox, chat_id, 0, 0);
for( size_t i = 0; i < mrarray_get_cnt(msglist); i++ )
{
uint32_t msg_id = mrarray_get_id(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mailbox, msg_id);
char* text = mrmsg_get_text(msg);
printf("message %i: %s\n", i+1, text);
free(text);
}
mrarray_unref(msglist);

This will output the following two lines:

+
Message 1: Hi, here is my first message!
Message 2: Got it!

I think, you got the idea. For further reading, please dive into the mrmailbox_t class.

Class reference

For a class reference, see the "Classes" link atop.

Further hints

diff --git a/docs/html/mrapeerstate_8h_source.html b/docs/html/mrapeerstate_8h_source.html index 4a38e818..c967a9a3 100644 --- a/docs/html/mrapeerstate_8h_source.html +++ b/docs/html/mrapeerstate_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrapeerstate.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 __MRAPEERSTATE_H__
24 #define __MRAPEERSTATE_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrkey.h"
31 
32 
33 typedef struct mraheader_t mraheader_t;
34 
35 
36 #define MRA_PE_NOPREFERENCE 0 /* prefer-encrypt states */
37 #define MRA_PE_MUTUAL 1
38 #define MRA_PE_GOSSIP 2
39 #define MRA_PE_RESET 20
40 
41 
45 typedef struct mrapeerstate_t
46 {
48  char* m_addr;
49  time_t m_last_seen;
50  time_t m_last_seen_autocrypt;
51  mrkey_t* m_public_key;
52  int m_prefer_encrypt;
53 
54  #define MRA_SAVE_LAST_SEEN 0x01
55  #define MRA_SAVE_ALL 0x02
56  int m_to_save;
57 } mrapeerstate_t;
58 
59 
60 mrapeerstate_t* mrapeerstate_new (); /* the returned pointer is ref'd and must be unref'd after usage */
61 void mrapeerstate_unref (mrapeerstate_t*);
62 
63 int mrapeerstate_init_from_header (mrapeerstate_t*, const mraheader_t*, time_t message_time);
64 int mrapeerstate_degrade_encryption(mrapeerstate_t*, time_t message_time);
65 int mrapeerstate_apply_header (mrapeerstate_t*, const mraheader_t*, time_t message_time); /*returns 1 on changes*/
66 
67 int mrapeerstate_load_from_db__ (mrapeerstate_t*, mrsqlite3_t*, const char* addr);
68 int mrapeerstate_save_to_db__ (const mrapeerstate_t*, mrsqlite3_t*, int create);
69 
70 
71 #ifdef __cplusplus
72 } /* /extern "C" */
73 #endif
74 #endif /* __MRAPEERSTATE_H__ */
75 
+
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 __MRAPEERSTATE_H__
24 #define __MRAPEERSTATE_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include "mrkey.h"
31 
32 
33 typedef struct mraheader_t mraheader_t;
34 
35 
36 #define MRA_PE_NOPREFERENCE 0 /* prefer-encrypt states */
37 #define MRA_PE_MUTUAL 1
38 #define MRA_PE_GOSSIP 2
39 #define MRA_PE_RESET 20
40 
41 
45 typedef struct mrapeerstate_t
46 {
48  char* m_addr;
49  time_t m_last_seen;
50  time_t m_last_seen_autocrypt;
51  mrkey_t* m_public_key;
52  int m_prefer_encrypt;
53 
54  #define MRA_SAVE_LAST_SEEN 0x01
55  #define MRA_SAVE_ALL 0x02
56  int m_to_save;
57 } mrapeerstate_t;
58 
59 
60 mrapeerstate_t* mrapeerstate_new (); /* the returned pointer is ref'd and must be unref'd after usage */
61 void mrapeerstate_unref (mrapeerstate_t*);
62 
63 int mrapeerstate_init_from_header (mrapeerstate_t*, const mraheader_t*, time_t message_time);
64 int mrapeerstate_degrade_encryption(mrapeerstate_t*, time_t message_time);
65 int mrapeerstate_apply_header (mrapeerstate_t*, const mraheader_t*, time_t message_time); /*returns 1 on changes*/
66 
67 char* mrapeerstate_render_gossip_header(mrapeerstate_t*);
68 
69 int mrapeerstate_load_from_db__ (mrapeerstate_t*, mrsqlite3_t*, const char* addr);
70 int mrapeerstate_save_to_db__ (const mrapeerstate_t*, mrsqlite3_t*, int create);
71 
72 
73 #ifdef __cplusplus
74 } /* /extern "C" */
75 #endif
76 #endif /* __MRAPEERSTATE_H__ */
77