diff --git a/docs/html/index.html b/docs/html/index.html index b89f5173..d29b4141 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -83,7 +83,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

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* nb, 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* mb = mrmailbox_new(my_delta_handler, NULL, NULL);
mrmailbox_set_config(mb, "addr", "alice@delta.chat"); // use some real test credentials here
mrmailbox_set_config(mb, "mail_pw", "***");
mrmailbox_configure_and_connect(mb);

If this works, you'll receive the event MR_EVENT_CONFIGURE_ENDED with data1 set to 1 - and you can start sending your first message:

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

If this works, you'll receive the event MR_EVENT_CONFIGURE_ENDED with data1 set to 1 - and you can start sending your first message:

uint32_t contact_id = mrmailbox_create_contact(mb, "bob@delta.chat"); // use a real testing address here
uint32_t chat_id = mrmailbox_create_chat_by_contact_id(mb, contact_id);
mrmailbox_send_text_msg(mb, 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:

carray* msglist = mrmailbox_get_chat_msgs(mb, chat_id, 0, 0);
for( size_t i = 0; i < carray_count(msglist); i++ )
{
uint32_t msg_id = carray_get_uint32(msglist, i);
mrmsg_t* msg = mrmailbox_get_msg(mb, msg_id);
printf("message %i: %s\n", i+1, msg->m_text);
}

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.

diff --git a/docs/html/mrevent_8h.html b/docs/html/mrevent_8h.html index 25b3336e..e86565fa 100644 --- a/docs/html/mrevent_8h.html +++ b/docs/html/mrevent_8h.html @@ -120,29 +120,23 @@ Macros #define MR_EVENT_MSG_READ   2015  A single message is read by the receiver (state changed from MR_STATE_OUT_DELIVERED to MR_STATE_OUT_MDN_RCVD, see mrmsg_t::m_state). More...
  - -#define MR_EVENT_CHAT_MODIFIED   2020 - group name/image changed or members added/removed
+#define MR_EVENT_CHAT_MODIFIED   2020 + Group name/image changed or members added/removed. More...
  - -#define MR_EVENT_CONTACTS_CHANGED   2030 - contact(s) created, renamed, blocked or deleted
+#define MR_EVENT_CONTACTS_CHANGED   2030 + Contact(s) created, renamed, blocked or deleted. More...
  - -#define MR_EVENT_CONFIGURE_ENDED   2040 - connection state changed, data1=0:failed-not-connected, 1:configured-and-connected
+#define MR_EVENT_CONFIGURE_ENDED   2040 + Configurartion enden. More...
  - -#define MR_EVENT_CONFIGURE_PROGRESS   2041 - data1=percent
+#define MR_EVENT_CONFIGURE_PROGRESS   2041 + Inform about the configuration progress. More...
  - -#define MR_EVENT_IMEX_ENDED   2050 - mrmailbox_imex() done: data1=0:failed, 1=success
+#define MR_EVENT_IMEX_ENDED   2050 + Import/export done. More...
  - -#define MR_EVENT_IMEX_PROGRESS   2051 - data1=permille
+#define MR_EVENT_IMEX_PROGRESS   2051 + Inform about the import/export progress. More...
  #define MR_EVENT_IMEX_FILE_WRITTEN   2052  file written, event may be needed to make the file public to some system services. More...
@@ -171,6 +165,94 @@ Macros

Detailed Description

The following constants are used as events reported to the callback given to mrmailbox_new().

Macro Definition Documentation

+ +
+
+ + + + +
#define MR_EVENT_CHAT_MODIFIED   2020
+
+ +

Group name/image changed or members added/removed.

+
Parameters
+ + + +
data1chat_id
data20
+
+
+
Returns
0
+ +
+
+ +
+
+ + + + +
#define MR_EVENT_CONFIGURE_ENDED   2040
+
+ +

Configurartion enden.

+

You'll get this event from a call to mrmailbox_configure_and_connect()

Parameters
+ + + +
data10=failed-not-connected, 1=configured-and-connected
data20
+
+
+
Returns
0
+ +
+
+ +
+
+ + + + +
#define MR_EVENT_CONFIGURE_PROGRESS   2041
+
+ +

Inform about the configuration progress.

+

As we want to get rid of the threads in the core, this event may be deleted.

Parameters
+ + + +
data1permille
data20
+
+
+
Returns
0
+ +
+
+ +
+
+ + + + +
#define MR_EVENT_CONTACTS_CHANGED   2030
+
+ +

Contact(s) created, renamed, blocked or deleted.

+
Parameters
+ + + +
data10
data20
+
+
+
Returns
0
+ +
+
@@ -191,6 +273,28 @@ Macros
Returns
0
+
+
+ +
+
+ + + + +
#define MR_EVENT_IMEX_ENDED   2050
+
+ +

Import/export done.

+

You'll get this event from a call to mrmailbox_imex(). As we want to get rid of the threads in the core, this event may be deleted.

Parameters
+ + + +
data10:failed, 1=success
data20
+
+
+
Returns
0
+
@@ -206,6 +310,28 @@ Macros

file written, event may be needed to make the file public to some system services.

data1=file name, data2=mime type

+ + + +
+
+ + + + +
#define MR_EVENT_IMEX_PROGRESS   2051
+
+ +

Inform about the import/export progress.

+
Parameters
+ + + +
data1permille
data20
+
+
+
Returns
0
+
diff --git a/docs/html/mrevent_8h_source.html b/docs/html/mrevent_8h_source.html index 65ce5472..be90241b 100644 --- a/docs/html/mrevent_8h_source.html +++ b/docs/html/mrevent_8h_source.html @@ -89,7 +89,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
mrevent.h
-Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Contact: r10s@b44t.com, http://b44t.com
5  *
6  * This program is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License as published by the Free Software
8  * Foundation, either version 3 of the License, or (at your option) any later
9  * version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program. If not, see http://www.gnu.org/licenses/ .
18  *
19  ******************************************************************************/
20 
21 
22 #ifndef __MREVENT_H__
23 #define __MREVENT_H__
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
44 #define MR_EVENT_INFO 100
45 
46 
55 #define MR_EVENT_WARNING 300
56 
57 
65 #define MR_EVENT_ERROR 400
66 
67 
76 #define MR_EVENT_MSGS_CHANGED 2000
77 
78 
86 #define MR_EVENT_INCOMING_MSG 2005
87 
88 
96 #define MR_EVENT_MSG_DELIVERED 2010
97 
98 
106 #define MR_EVENT_MSG_READ 2015
107 
108 
110 #define MR_EVENT_CHAT_MODIFIED 2020
111 
112 
114 #define MR_EVENT_CONTACTS_CHANGED 2030
115 
116 
119 #define MR_EVENT_CONFIGURE_ENDED 2040
120 
121 
123 #define MR_EVENT_CONFIGURE_PROGRESS 2041
124 
125 
128 #define MR_EVENT_IMEX_ENDED 2050
129 
130 
132 #define MR_EVENT_IMEX_PROGRESS 2051
133 
134 
137 #define MR_EVENT_IMEX_FILE_WRITTEN 2052
138 
139 
140 /* The following events are functions that should be provided by the frontends */
141 
142 
145 #define MR_EVENT_IS_ONLINE 2080
146 
147 
150 #define MR_EVENT_GET_STRING 2091
151 
152 
155 #define MR_EVENT_GET_QUANTITY_STRING 2092
156 
157 
160 #define MR_EVENT_HTTP_GET 2100
161 
164 #define MR_EVENT_WAKE_LOCK 2110
165 
166 
167 #ifdef __cplusplus
168 } /* /extern "C" */
169 #endif
170 #endif /* __MREVENT_H__ */
171 
+Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Contact: r10s@b44t.com, http://b44t.com
5  *
6  * This program is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License as published by the Free Software
8  * Foundation, either version 3 of the License, or (at your option) any later
9  * version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program. If not, see http://www.gnu.org/licenses/ .
18  *
19  ******************************************************************************/
20 
21 
22 #ifndef __MREVENT_H__
23 #define __MREVENT_H__
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
44 #define MR_EVENT_INFO 100
45 
46 
55 #define MR_EVENT_WARNING 300
56 
57 
65 #define MR_EVENT_ERROR 400
66 
67 
76 #define MR_EVENT_MSGS_CHANGED 2000
77 
78 
86 #define MR_EVENT_INCOMING_MSG 2005
87 
88 
96 #define MR_EVENT_MSG_DELIVERED 2010
97 
98 
106 #define MR_EVENT_MSG_READ 2015
107 
108 
115 #define MR_EVENT_CHAT_MODIFIED 2020
116 
117 
124 #define MR_EVENT_CONTACTS_CHANGED 2030
125 
126 
134 #define MR_EVENT_CONFIGURE_ENDED 2040
135 
136 
144 #define MR_EVENT_CONFIGURE_PROGRESS 2041
145 
146 
154 #define MR_EVENT_IMEX_ENDED 2050
155 
156 
163 #define MR_EVENT_IMEX_PROGRESS 2051
164 
165 
168 #define MR_EVENT_IMEX_FILE_WRITTEN 2052
169 
170 
171 /* The following events are functions that should be provided by the frontends */
172 
173 
176 #define MR_EVENT_IS_ONLINE 2080
177 
178 
181 #define MR_EVENT_GET_STRING 2091
182 
183 
186 #define MR_EVENT_GET_QUANTITY_STRING 2092
187 
188 
191 #define MR_EVENT_HTTP_GET 2100
192 
195 #define MR_EVENT_WAKE_LOCK 2110
196 
197 
198 #ifdef __cplusplus
199 } /* /extern "C" */
200 #endif
201 #endif /* __MREVENT_H__ */
202