diff --git a/docs/html/functions.html b/docs/html/functions.html index 8a011234..49a2961b 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -241,7 +241,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : mrmailbox_t
  • mrmailbox_configure_and_connect() -: mrmailbox_t +: mrmailbox_t
  • mrmailbox_configure_cancel() : mrmailbox_t diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index dac0ff2d..4c01f9aa 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -158,7 +158,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : mrmailbox_t
  • mrmailbox_configure_and_connect() -: mrmailbox_t +: mrmailbox_t
  • mrmailbox_configure_cancel() : mrmailbox_t diff --git a/docs/html/globals.html b/docs/html/globals.html index 17044df7..7934fa1e 100644 --- a/docs/html/globals.html +++ b/docs/html/globals.html @@ -91,9 +91,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • MR_EVENT_CHAT_MODIFIED : mrevent.h
  • -
  • MR_EVENT_CONFIGURE_ENDED -: mrevent.h -
  • MR_EVENT_CONFIGURE_PROGRESS : mrevent.h
  • diff --git a/docs/html/globals_defs.html b/docs/html/globals_defs.html index 69a399bb..626cf01a 100644 --- a/docs/html/globals_defs.html +++ b/docs/html/globals_defs.html @@ -91,9 +91,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • MR_EVENT_CHAT_MODIFIED : mrevent.h
  • -
  • MR_EVENT_CONFIGURE_ENDED -: mrevent.h -
  • MR_EVENT_CONFIGURE_PROGRESS : mrevent.h
  • diff --git a/docs/html/index.html b/docs/html/index.html index d29b4141..e1fbf1f8 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);

    After that, you can send 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/mrchat_8h_source.html b/docs/html/mrchat_8h_source.html index 4634eff3..97eec32f 100644 --- a/docs/html/mrchat_8h_source.html +++ b/docs/html/mrchat_8h_source.html @@ -90,7 +90,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    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 {
    51  uint32_t m_id;
    52  #define MR_CHAT_ID_DEADDROP 1
    53  #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) */
    54  #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) */
    55  #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) */
    56  #define MR_CHAT_ID_STARRED 5
    57  #define MR_CHAT_ID_ARCHIVED_LINK 6
    58  #define MR_CHAT_ID_LAST_SPECIAL 9 /* larger chat IDs are "real" chats, their messages are "real" messages. */
    59 
    60 
    69  int m_type;
    70  #define MR_CHAT_TYPE_UNDEFINED 0
    71  #define MR_CHAT_TYPE_NORMAL 100
    72  #define MR_CHAT_TYPE_GROUP 120
    73 
    74 
    75  char* m_name;
    77  char* m_draft_text;
    79  int m_archived;
    83  char* m_grpid; /* NULL if unset */
    84 } mrchat_t;
    85 
    86 
    87 mrchat_t* mrchat_new (mrmailbox_t*);
    88 void mrchat_empty (mrchat_t*);
    89 void mrchat_unref (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__ */
    int m_type
    Chat type.
    Definition: mrchat.h:69
    -
    An object representing a single mailbox.
    Definition: mrmailbox.h:179
    +
    An object representing a single mailbox.
    Definition: mrmailbox.h:178
    void mrchat_unref(mrchat_t *chat)
    Free a chat object.
    Definition: mrchat.c:65
    char * m_draft_text
    NULL if unset.
    Definition: mrchat.h:77
    mrmailbox_t * m_mailbox
    != NULL
    Definition: mrchat.h:78
    diff --git a/docs/html/mrchatlist_8h_source.html b/docs/html/mrchatlist_8h_source.html index 66215e75..34ccedc1 100644 --- a/docs/html/mrchatlist_8h_source.html +++ b/docs/html/mrchatlist_8h_source.html @@ -92,7 +92,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    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 __MRCHATLIST_H__
    24 #define __MRCHATLIST_H__
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    28 
    29 
    30 typedef struct mrmailbox_t mrmailbox_t;
    31 typedef struct mrpoortext_t mrpoortext_t;
    32 typedef struct mrchat_t mrchat_t;
    33 
    34 
    42 typedef struct mrchatlist_t
    43 {
    47  #define MR_CHATLIST_IDS_PER_RESULT 2
    48  size_t m_cnt;
    49  carray* m_chatNlastmsg_ids;
    50 } mrchatlist_t;
    51 
    52 
    53 mrchatlist_t* mrchatlist_new (mrmailbox_t*);
    57 uint32_t mrchatlist_get_chat_id (mrchatlist_t*, size_t index);
    58 uint32_t mrchatlist_get_msg_id (mrchatlist_t*, size_t index);
    60 
    61 /* library-internal */
    62 int mrchatlist_load_from_db__ (mrchatlist_t*, int listflags, const char* query);
    63 
    64 
    65 #ifdef __cplusplus
    66 } /* /extern "C" */
    67 #endif
    68 #endif /* __MRCHATLIST_H__ */
    mrmailbox_t * m_mailbox
    The mailbox, the chatlist belongs to.
    Definition: mrchatlist.h:44
    An object representing a single chatlist in memory.
    Definition: mrchatlist.h:42
    mrpoortext_t * mrchatlist_get_summary(mrchatlist_t *chatlist, size_t index, mrchat_t *chat)
    Get a summary for a chatlist index.
    Definition: mrchatlist.c:205
    -
    An object representing a single mailbox.
    Definition: mrmailbox.h:179
    +
    An object representing a single mailbox.
    Definition: mrmailbox.h:178
    void mrchatlist_empty(mrchatlist_t *chatlist)
    Empty a chatlist object.
    Definition: mrchatlist.c:83
    uint32_t mrchatlist_get_msg_id(mrchatlist_t *chatlist, size_t index)
    Get a single message ID of a chatlist.
    Definition: mrchatlist.c:155
    An object representing text with some attributes.
    Definition: mrpoortext.h:35
    diff --git a/docs/html/mrevent_8h.html b/docs/html/mrevent_8h.html index 6e6c581a..4a15ef3b 100644 --- a/docs/html/mrevent_8h.html +++ b/docs/html/mrevent_8h.html @@ -126,11 +126,8 @@ Macros #define MR_EVENT_CONTACTS_CHANGED   2030  Contact(s) created, renamed, blocked or deleted. More...
      -#define MR_EVENT_CONFIGURE_ENDED   2040 - Configurartion enden. More...
    -  #define MR_EVENT_CONFIGURE_PROGRESS   2041 - Inform about the configuration progress started by mrmailbox_configure_and_connect(). More...
    + Inform about the configuration progress started by mrmailbox_configure_and_connect(). More...
      #define MR_EVENT_IMEX_ENDED   2050  Import/export done. More...
    @@ -181,29 +178,6 @@ Macros
    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
    -
    @@ -216,7 +190,7 @@ Macros
    -

    Inform about the configuration progress started by mrmailbox_configure_and_connect().

    +

    Inform about the configuration progress started by mrmailbox_configure_and_connect().

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

    Parameters
    diff --git a/docs/html/mrevent_8h_source.html b/docs/html/mrevent_8h_source.html index 61294e00..88bfe171 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 
    49 #define MR_EVENT_INFO 100
    50 
    51 
    63 #define MR_EVENT_WARNING 300
    64 
    65 
    76 #define MR_EVENT_ERROR 400
    77 
    78 
    89 #define MR_EVENT_MSGS_CHANGED 2000
    90 
    91 
    102 #define MR_EVENT_INCOMING_MSG 2005
    103 
    104 
    115 #define MR_EVENT_MSG_DELIVERED 2010
    116 
    117 
    128 #define MR_EVENT_MSG_READ 2015
    129 
    130 
    140 #define MR_EVENT_CHAT_MODIFIED 2020
    141 
    142 
    152 #define MR_EVENT_CONTACTS_CHANGED 2030
    153 
    154 
    165 #define MR_EVENT_CONFIGURE_ENDED 2040
    166 
    167 
    178 #define MR_EVENT_CONFIGURE_PROGRESS 2041
    179 
    180 
    191 #define MR_EVENT_IMEX_ENDED 2050
    192 
    193 
    203 #define MR_EVENT_IMEX_PROGRESS 2051
    204 
    205 
    220 #define MR_EVENT_IMEX_FILE_WRITTEN 2052
    221 
    222 
    223 /*******************************************************************************
    224  * The following events are functions that should be provided by the frontends
    225  ******************************************************************************/
    226 
    227 
    239 #define MR_EVENT_IS_OFFLINE 2081
    240 
    241 
    253 #define MR_EVENT_GET_STRING 2091
    254 
    255 
    270 #define MR_EVENT_GET_QUANTITY_STRING 2092
    271 
    272 
    284 #define MR_EVENT_HTTP_GET 2100
    285 
    299 #define MR_EVENT_WAKE_LOCK 2110
    300 
    301 
    302 #ifdef __cplusplus
    303 } /* /extern "C" */
    304 #endif
    305 #endif /* __MREVENT_H__ */
    306 
    +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 
    49 #define MR_EVENT_INFO 100
    50 
    51 
    63 #define MR_EVENT_WARNING 300
    64 
    65 
    76 #define MR_EVENT_ERROR 400
    77 
    78 
    89 #define MR_EVENT_MSGS_CHANGED 2000
    90 
    91 
    102 #define MR_EVENT_INCOMING_MSG 2005
    103 
    104 
    115 #define MR_EVENT_MSG_DELIVERED 2010
    116 
    117 
    128 #define MR_EVENT_MSG_READ 2015
    129 
    130 
    140 #define MR_EVENT_CHAT_MODIFIED 2020
    141 
    142 
    152 #define MR_EVENT_CONTACTS_CHANGED 2030
    153 
    154 
    165 #define MR_EVENT_CONFIGURE_PROGRESS 2041
    166 
    167 
    178 #define MR_EVENT_IMEX_ENDED 2050
    179 
    180 
    190 #define MR_EVENT_IMEX_PROGRESS 2051
    191 
    192 
    207 #define MR_EVENT_IMEX_FILE_WRITTEN 2052
    208 
    209 
    210 /*******************************************************************************
    211  * The following events are functions that should be provided by the frontends
    212  ******************************************************************************/
    213 
    214 
    226 #define MR_EVENT_IS_OFFLINE 2081
    227 
    228 
    240 #define MR_EVENT_GET_STRING 2091
    241 
    242 
    257 #define MR_EVENT_GET_QUANTITY_STRING 2092
    258 
    259 
    271 #define MR_EVENT_HTTP_GET 2100
    272 
    286 #define MR_EVENT_WAKE_LOCK 2110
    287 
    288 
    289 #ifdef __cplusplus
    290 } /* /extern "C" */
    291 #endif
    292 #endif /* __MREVENT_H__ */
    293 
    - + diff --git a/docs/html/structmrmailbox__t.html b/docs/html/structmrmailbox__t.html index 606b5058..c4e8d2cb 100644 --- a/docs/html/structmrmailbox__t.html +++ b/docs/html/structmrmailbox__t.html @@ -266,11 +266,11 @@ Public Member Functions - - - + + + - + @@ -562,12 +562,12 @@ void * 
    mrmailbox_block_contact(mrmailbox_t *mailbox, uint32_t contact_id, int new_blocking)mrmailbox_t
    mrmailbox_check_password(mrmailbox_t *mailbox, const char *test_pw)mrmailbox_t
    mrmailbox_close(mrmailbox_t *mailbox)mrmailbox_t
    mrmailbox_configure_and_connect(mrmailbox_t *mailbox)mrmailbox_t
    mrmailbox_configure_and_connect(mrmailbox_t *mailbox)mrmailbox_t
    mrmailbox_configure_cancel(mrmailbox_t *mailbox)mrmailbox_t
    mrmailbox_connect(mrmailbox_t *mailbox)mrmailbox_t
    mrmailbox_create_chat_by_contact_id(mrmailbox_t *mailbox, uint32_t contact_id)mrmailbox_t
    void mrmailbox_markseen_msgs (mrmailbox_t *mailbox, const uint32_t *msg_ids, int msg_cnt)
     Mark a message as seen, updates the IMAP state and sends MDNs. More...
     
    void mrmailbox_configure_and_connect (mrmailbox_t *mailbox)
     Configure and connect a mailbox. More...
     
    int mrmailbox_configure_and_connect (mrmailbox_t *mailbox)
     Configure and connect a mailbox. More...
     
    void mrmailbox_configure_cancel (mrmailbox_t *mailbox)
     Cancel an configuration started by mrmailbox_configure_and_connect(). More...
     Signal the configure-process to stop. More...
     
    int mrmailbox_is_configured (mrmailbox_t *mailbox)
     Check if the mailbox is already configured. More...
    +
    - + @@ -579,17 +579,16 @@ void * 
    void mrmailbox_configure_and_connect int mrmailbox_configure_and_connect ( mrmailbox_t mailbox)mrmailbox_set_config(). -
  • mrmailbox_configure_and_connect() returns immediately, configuration is done in another thread; when done, the event MR_EVENT_CONFIGURE_ENDED ist posted
  • +
  • mrmailbox_configure_and_connect() may take a while, so it might be a good idea to let it run in a non-GUI-thread; to cancel the configuration progress, you can then use mrmailbox_configure_cancel()
  • There is no need to call this every program start, the result is saved in the database.
  • -
  • mrmailbox_configure_and_connect() should be called after any settings change.
  • Parameters
    - +
    mailboxthe mailbox object as created by mrmailbox_new()
    mailboxthe mailbox object as created by mrmailbox_new().
    -
    Returns
    none
    +
    Returns
    1=configured and connected, 0=not configured, not explicitly connected, however, an existing connection may still be present
    @@ -607,7 +606,9 @@ void * 
    -

    Cancel an configuration started by mrmailbox_configure_and_connect().

    +

    Signal the configure-process to stop.

    +

    After that, mrmailbox_configure_cancel() returns without waiting for mrmailbox_configure_and_connect() to return.

    +

    mrmailbox_configure_and_connect() will return ASAP then, however, it may still take a second. If in doubt, the caller may also decide the kill the thread after a few seconds; eg. the configuration process may hang in a function not under the control of the core (eg. MR_EVENT_HTTP_GET)

    Parameters
    @@ -1876,7 +1877,7 @@ void * 
    mailboxThe mailbox object as created by mrmailbox_new()

    Check if the mailbox is already configured.

    -

    Typically, for unconfigured mailboxes, the user is prompeted for to enter some settings and mrmailbox_configure_and_connect() is called with them.

    +

    Typically, for unconfigured mailboxes, the user is prompeted for to enter some settings and mrmailbox_configure_and_connect() is called with them.

    Parameters
    mailboxThe mailbox object as created by mrmailbox_new()