1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 03:50:08 +02:00

Merge branch 'master' into caller-idle

This commit is contained in:
Björn Petersen 2018-06-05 01:03:32 +02:00 committed by GitHub
commit a2a0756f18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 11 deletions

View file

@ -61,7 +61,7 @@ int mrchat_are_all_members_verified__ (mrchat_t*);
#define MR_CHAT_PREFIX "Chat:" /* you MUST NOT modify this or the following strings */
#define MR_CHATS_FOLDER "Chats" /* if we want to support Gma'l-labels - "Chats" is a reserved word for Gma'l */
#define MR_CHATS_FOLDER "DeltaChat" // make sure not to use reserved words here, eg. "Chats" or "Chat" are reserved in gmail
#ifdef __cplusplus

View file

@ -240,9 +240,16 @@ static clist* list_folders__(mrimap_t* ths)
goto cleanup;
}
//default IMAP delimiter if none is returned by the list command
ths->m_imap_delimiter = '.';
for( iter1 = clist_begin(imap_list); iter1 != NULL ; iter1 = clist_next(iter1) )
{
struct mailimap_mailbox_list* imap_folder = (struct mailimap_mailbox_list*)clist_content(iter1);
if (imap_folder->mb_delimiter) {
/* Set IMAP delimiter */
ths->m_imap_delimiter = imap_folder->mb_delimiter;
}
mrimapfolder_t* ret_folder = calloc(1, sizeof(mrimapfolder_t));
if( strcasecmp(imap_folder->mb_name, "INBOX")==0 ) {
@ -318,11 +325,16 @@ static int init_chat_folders__(mrimap_t* ths)
free(ths->m_moveto_folder);
ths->m_moveto_folder = NULL;
//this sets ths->m_imap_delimiter as side-effect
folder_list = list_folders__(ths);
//as a fallback, the chats_folder is created under INBOX as required e.g. for DomainFactory
char fallback_folder[64];
snprintf(fallback_folder, sizeof(fallback_folder), "INBOX%c%s", ths->m_imap_delimiter, MR_CHATS_FOLDER);
for( iter1 = clist_begin(folder_list); iter1 != NULL ; iter1 = clist_next(iter1) ) {
mrimapfolder_t* folder = (struct mrimapfolder_t*)clist_content(iter1);
if( strcmp(folder->m_name_utf8, MR_CHATS_FOLDER)==0 ) {
if( strcmp(folder->m_name_utf8, MR_CHATS_FOLDER)==0 || strcmp(folder->m_name_utf8, fallback_folder)==0 ) {
chats_folder = safe_strdup(folder->m_name_to_select);
break;
}
@ -338,8 +350,16 @@ static int init_chat_folders__(mrimap_t* ths)
mrmailbox_log_info(ths->m_mailbox, 0, "Creating IMAP-folder \"%s\"...", MR_CHATS_FOLDER);
int r = mailimap_create(ths->m_hEtpan, MR_CHATS_FOLDER);
if( is_error(ths, r) ) {
/* continue on errors, we'll just use a different folder then */
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using default.");
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using trying INBOX subfolder.");
r = mailimap_create(ths->m_hEtpan, fallback_folder);
if( is_error(ths, r) ) {
/* continue on errors, we'll just use a different folder then */
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using default.");
}
else {
chats_folder = safe_strdup(fallback_folder);
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-folder created (inbox subfolder).");
}
}
else {
chats_folder = safe_strdup(MR_CHATS_FOLDER);

View file

@ -65,8 +65,9 @@ typedef struct mrimap_t
int m_can_idle;
int m_has_xlist;
char* m_moveto_folder;/* Folder, where reveived chat messages should go to. Normally "Chats" but may be NULL to leave them in the INBOX */
char* m_sent_folder; /* Folder, where send messages should go to. Normally "Chats". */
char* m_moveto_folder;// Folder, where reveived chat messages should go to. Normally MR_CHATS_FOLDER, may be NULL to leave them in the INBOX
char* m_sent_folder; // Folder, where send messages should go to. Normally MR_CHATS_FOLDER.
char m_imap_delimiter;/* IMAP Path separator. Set as a side-effect in list_folders__ */
pthread_mutex_t m_idlemutex; /* set, if idle is not possible; morover, the interrupted IDLE thread waits a second before IDLEing again; this allows several jobs to be executed */
pthread_mutex_t m_inwait_mutex; /* only used to wait for mailstream_wait_idle()/mailimap_idle_done() to terminate. */

View file

@ -1261,17 +1261,17 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
mrmailbox_unarchive_chat__(mailbox, chat_id);
/* if the message is not sent by a messenger, check if it is sent at least as a reply to a messenger message
(later, we move these replies to the Chats-folder) */
(later, we move these replies to the folder used for DeltaChat messages) */
int msgrmsg = mime_parser->m_is_send_by_messenger; /* 1 or 0 for yes/no */
if( msgrmsg )
{
mrmailbox_log_info(mailbox, 0, "Message sent by another messenger (will be moved to Chats-folder).");
mrmailbox_log_info(mailbox, 0, "Message sent by another messenger.");
}
else
{
if( mrmailbox_is_reply_to_messenger_message__(mailbox, mime_parser) )
{
mrmailbox_log_info(mailbox, 0, "Message is a reply to a messenger message (will be moved to Chats-folder).");
mrmailbox_log_info(mailbox, 0, "Message is a reply to a messenger message.");
msgrmsg = 2; /* 2=no, but is reply to messenger message */
}
}

View file

@ -1862,7 +1862,7 @@ int mrmimeparser_sender_equals_recipient(mrmimeparser_t* mimeparser)
const struct mailimf_field* fld;
const struct mailimf_from* fld_from;
struct mailimf_mailbox* mb;
char* from_addr_norm;
char* from_addr_norm = NULL;
mrhash_t* recipients = NULL;
if( mimeparser == NULL || mimeparser->m_header_root == NULL ) {