Browse Source

Make Xcode project easier to use. Implemented CONDSTORE.

dvh-chacham15-master
DINH Viet Hoa 9 years ago
parent
commit
fbc88c1386
19 changed files with 2183 additions and 1228 deletions
  1. +198
    -1074
      build-mac/libetpan.xcodeproj/project.pbxproj
  2. +31
    -14
      build-mac/update.sh
  3. +3
    -2
      src/low-level/imap/Makefile.am
  4. +1139
    -0
      src/low-level/imap/condstore.c
  5. +96
    -0
      src/low-level/imap/condstore.h
  6. +19
    -0
      src/low-level/imap/condstore_private.h
  7. +100
    -0
      src/low-level/imap/condstore_types.c
  8. +51
    -0
      src/low-level/imap/condstore_types.h
  9. +47
    -0
      src/low-level/imap/mailimap.c
  10. +1
    -0
      src/low-level/imap/mailimap.h
  11. +3
    -1
      src/low-level/imap/mailimap_extension.c
  12. +4
    -2
      src/low-level/imap/mailimap_extension_types.h
  13. +6
    -5
      src/low-level/imap/mailimap_keywords.c
  14. +192
    -7
      src/low-level/imap/mailimap_parser.c
  15. +15
    -0
      src/low-level/imap/mailimap_parser.h
  16. +223
    -100
      src/low-level/imap/mailimap_sender.c
  17. +10
    -8
      src/low-level/imap/mailimap_sender.h
  18. +11
    -1
      src/low-level/imap/mailimap_types.c
  19. +34
    -14
      src/low-level/imap/mailimap_types.h

+ 198
- 1074
build-mac/libetpan.xcodeproj/project.pbxproj
File diff suppressed because it is too large
View File


+ 31
- 14
build-mac/update.sh View File

@ -6,20 +6,37 @@ fi
logfile="`pwd`/update.log"
cd ..
echo configuring
./autogen.sh > "$logfile" 2>&1
if [[ "$?" != "0" ]]; then
echo "configure failed"
exit 1
if test x$SRCROOT = x ; then
echo Should be run from Xcode
exit 1
fi
make stamp-prepare-target >> "$logfile" 2>&1
make libetpan-config.h >> "$logfile" 2>&1
cd build-mac
mkdir -p include/libetpan >> "$logfile" 2>&1
cp -r ../include/libetpan/ include/libetpan/
cp ../config.h include
cp ../libetpan-config.h include
if test x$ACTION = x ; then
if test ! -f Makefile ; then
echo configuring
./autogen.sh > "$logfile" 2>&1
if [[ "$?" != "0" ]]; then
echo "configure failed"
exit 1
fi
make stamp-prepare-target >> "$logfile" 2>&1
make libetpan-config.h >> "$logfile" 2>&1
fi
if test x$PLATFORM_NAME = xiphoneos ; then
if test ! -d build-mac/libsasl-ios ; then
# build dependencies for iOS
cd build-mac
sh ./prepare-ios.sh
fi
fi
elif test x$ACTION = xclean ; then
if test -f Makefile ; then
make maintainer-clean >/dev/null
cd build-mac
rm -rf libsasl-ios
rm -rf dependencies/build
fi
fi
# build dependencies for iOS
sh ./prepare-ios.sh

+ 3
- 2
src/low-level/imap/Makefile.am View File

@ -44,7 +44,7 @@ etpaninclude_HEADERS = \
namespace.h namespace_parser.h namespace_sender.h namespace_types.h \
xlist.h xgmlabels.h xgmmsgid.h \
mailimap_id.h mailimap_id_types.h \
enable.h
enable.h condstore.h condstore_types.h
AM_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_srcdir)/src/data-types
@ -90,5 +90,6 @@ libimap_la_SOURCES = \
mailimap_id_types.h mailimap_id_types.c \
mailimap_id_sender.h mailimap_id_sender.c \
mailimap_id_parser.h mailimap_id_parser.c \
enable.h enable.c
enable.h enable.c \
condstore.h condstore.c condstore_types.h condstore_types.c

+ 1139
- 0
src/low-level/imap/condstore.c
File diff suppressed because it is too large
View File


+ 96
- 0
src/low-level/imap/condstore.h View File

@ -0,0 +1,96 @@
/*
* libEtPan! -- a mail stuff library
*
* Copyright (C) 2001, 2013 - DINH Viet Hoa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the libEtPan! project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef CONDSTORE_H
#define CONDSTORE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <libetpan/libetpan-config.h>
#include <libetpan/mailimap_extension.h>
#include <libetpan/condstore_types.h>
LIBETPAN_EXPORT
extern struct mailimap_extension_api mailimap_extension_condstore;
LIBETPAN_EXPORT
int mailimap_store_unchangedsince(mailimap * session,
struct mailimap_set * set, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
LIBETPAN_EXPORT
int mailimap_uid_store_unchangedsince(mailimap * session,
struct mailimap_set * set, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
LIBETPAN_EXPORT
int mailimap_fetch_changedsince(mailimap * session,
struct mailimap_set * set,
struct mailimap_fetch_type * fetch_type, uint64_t mod_sequence_value,
clist ** result);
LIBETPAN_EXPORT
int mailimap_uid_fetch_changedsince(mailimap * session,
struct mailimap_set * set,
struct mailimap_fetch_type * fetch_type, uint64_t mod_sequence_value,
clist ** result);
LIBETPAN_EXPORT
struct mailimap_fetch_att * mailimap_fetch_att_new_modseq(void);
LIBETPAN_EXPORT
struct mailimap_msg_att_modseq * mailimap_msg_att_modseq_new(uint64_t mod_sequence_value);
LIBETPAN_EXPORT
int mailimap_search_modseq(mailimap * session, const char * charset,
struct mailimap_search_key * key, clist ** result, uint64_t * p_mod_sequence_value);
LIBETPAN_EXPORT
int mailimap_uid_search_modseq(mailimap * session, const char * charset,
struct mailimap_search_key * key, clist ** result, uint64_t * p_mod_sequence_value);
LIBETPAN_EXPORT
int mailimap_select_condstore(mailimap * session, const char * mb, uint64_t * p_mod_sequence_value);
LIBETPAN_EXPORT
int mailimap_examine_condstore(mailimap * session, const char * mb, uint64_t * p_mod_sequence_value);
LIBETPAN_EXPORT
int mailimap_has_condstore(mailimap * session);
#ifdef __cplusplus
}
#endif
#endif

+ 19
- 0
src/low-level/imap/condstore_private.h View File

@ -0,0 +1,19 @@
#ifndef CONDSTORE_PRIVATE_H
#define CONDSTORE_PRIVATE_H
int mailimap_examine_condstore_optional(mailimap * session, const char * mb,
int condstore, uint64_t * p_mod_sequence_value);
int mailimap_select_condstore_optional(mailimap * session, const char * mb,
int condstore, uint64_t * p_mod_sequence_value);
int mailimap_store_unchangedsince_optional(mailimap * session,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
int mailimap_uid_store_unchangedsince_optional(mailimap * session,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
#endif

+ 100
- 0
src/low-level/imap/condstore_types.c View File

@ -0,0 +1,100 @@
#include "condstore_types.h"
#include <stdlib.h>
struct mailimap_condstore_fetch_mod_resp * mailimap_condstore_fetch_mod_resp_new(uint64_t cs_modseq_value)
{
struct mailimap_condstore_fetch_mod_resp * fetch_data;
fetch_data = malloc(sizeof(* fetch_data));
if (fetch_data == NULL)
return NULL;
fetch_data->cs_modseq_value = cs_modseq_value;
return fetch_data;
}
void mailimap_condstore_fetch_mod_resp_free(struct mailimap_condstore_fetch_mod_resp * fetch_data)
{
free(fetch_data);
}
struct mailimap_condstore_resptextcode * mailimap_condstore_resptextcode_new(int cs_type,
uint64_t cs_modseq_value, struct mailimap_set * cs_modified_set)
{
struct mailimap_condstore_resptextcode * resptextcode;
resptextcode = malloc(sizeof(* resptextcode));
if (resptextcode == NULL)
return NULL;
resptextcode->cs_type = cs_type;
switch (cs_type) {
case MAILIMAP_CONDSTORE_RESPTEXTCODE_HIGHESTMODSEQ:
resptextcode->cs_data.cs_modseq_value = cs_modseq_value;
break;
case MAILIMAP_CONDSTORE_RESPTEXTCODE_NOMODSEQ:
break;
case MAILIMAP_CONDSTORE_RESPTEXTCODE_MODIFIED:
resptextcode->cs_data.cs_modified_set = cs_modified_set;
break;
}
return resptextcode;
}
void mailimap_condstore_resptextcode_free(struct mailimap_condstore_resptextcode * resptextcode)
{
switch (resptextcode->cs_type) {
case MAILIMAP_CONDSTORE_RESPTEXTCODE_HIGHESTMODSEQ:
break;
case MAILIMAP_CONDSTORE_RESPTEXTCODE_NOMODSEQ:
break;
case MAILIMAP_CONDSTORE_RESPTEXTCODE_MODIFIED:
mailimap_set_free(resptextcode->cs_data.cs_modified_set);
break;
}
}
struct mailimap_condstore_search * mailimap_condstore_search_new(clist * cs_search_result, uint64_t cs_modseq_value)
{
struct mailimap_condstore_search * search_data;
search_data = malloc(sizeof(* search_data));
if (search_data == NULL)
return NULL;
search_data->cs_search_result = cs_search_result;
search_data->cs_modseq_value = cs_modseq_value;
return search_data;
}
void mailimap_condstore_search_free(struct mailimap_condstore_search * search_data)
{
if (search_data->cs_search_result != NULL) {
clist_foreach(search_data->cs_search_result, (clist_func) free, NULL);
clist_free(search_data->cs_search_result);
}
free(search_data);
}
struct mailimap_condstore_status_info * mailimap_condstore_status_info_new(uint64_t cs_highestmodseq_value)
{
struct mailimap_condstore_status_info * status_info;
status_info = malloc(sizeof(* status_info));
if (status_info == NULL)
return NULL;
status_info->cs_highestmodseq_value = cs_highestmodseq_value;
return status_info;
}
void mailimap_condstore_status_info_free(struct mailimap_condstore_status_info * status_info)
{
free(status_info);
}

+ 51
- 0
src/low-level/imap/condstore_types.h View File

@ -0,0 +1,51 @@
#ifndef CONDSTORE_TYPE_H
#define CONDSTORE_TYPE_H
#include <libetpan/mailimap_types.h>
struct mailimap_condstore_fetch_mod_resp {
uint64_t cs_modseq_value;
};
enum {
MAILIMAP_CONDSTORE_RESPTEXTCODE_HIGHESTMODSEQ,
MAILIMAP_CONDSTORE_RESPTEXTCODE_NOMODSEQ,
MAILIMAP_CONDSTORE_RESPTEXTCODE_MODIFIED
};
struct mailimap_msg_att_modseq {
uint64_t att_modseq;
};
struct mailimap_condstore_resptextcode {
int cs_type;
union {
uint64_t cs_modseq_value;
struct mailimap_set * cs_modified_set;
} cs_data;
};
struct mailimap_condstore_search {
clist * cs_search_result; /* uint32_t */
uint64_t cs_modseq_value;
};
struct mailimap_condstore_status_info {
uint64_t cs_highestmodseq_value;
};
struct mailimap_condstore_fetch_mod_resp * mailimap_condstore_fetch_mod_resp_new(uint64_t cs_modseq_value);
void mailimap_condstore_fetch_mod_resp_free(struct mailimap_condstore_fetch_mod_resp * fetch_data);
struct mailimap_condstore_resptextcode * mailimap_condstore_resptextcode_new(int cs_type,
uint64_t cs_modseq_value, struct mailimap_set * cs_modified_set);
void mailimap_condstore_resptextcode_free(struct mailimap_condstore_resptextcode * resptextcode);
struct mailimap_condstore_search * mailimap_condstore_search_new(clist * cs_search_result, uint64_t cs_modseq_value);
void mailimap_condstore_search_free(struct mailimap_condstore_search * search_data);
struct mailimap_condstore_status_info * mailimap_condstore_status_info_new(uint64_t cs_highestmodseq_value);
void mailimap_condstore_status_info_free(struct mailimap_condstore_status_info * status_info);
#endif

+ 47
- 0
src/low-level/imap/mailimap.c View File

@ -42,6 +42,8 @@
#include "mailimap_sender.h"
#include "mailimap_extension.h"
#include "mail.h"
#include "condstore.h"
#include "condstore_private.h"
#include <stdio.h>
#include <stdlib.h>
@ -1239,6 +1241,7 @@ int mailimap_delete(mailimap * session, const char * mb)
}
}
#if 0
LIBETPAN_EXPORT
int mailimap_examine(mailimap * session, const char * mb)
{
@ -1292,12 +1295,21 @@ int mailimap_examine(mailimap * session, const char * mb)
return MAILIMAP_ERROR_EXAMINE;
}
}
#else
LIBETPAN_EXPORT
int mailimap_examine(mailimap * session, const char * mb)
{
uint64_t dummy;
return mailimap_examine_condstore_optional(session, mb, 0, &dummy);
}
#endif
LIBETPAN_EXPORT
int
mailimap_fetch(mailimap * session, struct mailimap_set * set,
struct mailimap_fetch_type * fetch_type, clist ** result)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -1347,6 +1359,9 @@ mailimap_fetch(mailimap * session, struct mailimap_set * set,
mailimap_fetch_list_free(* result);
return MAILIMAP_ERROR_FETCH;
}
#else
return mailimap_fetch_changedsince(session, set, fetch_type, 0, result);
#endif
}
LIBETPAN_EXPORT
@ -1362,6 +1377,7 @@ mailimap_uid_fetch(mailimap * session,
struct mailimap_set * set,
struct mailimap_fetch_type * fetch_type, clist ** result)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -1412,6 +1428,9 @@ mailimap_uid_fetch(mailimap * session,
mailimap_fetch_list_free(* result);
return MAILIMAP_ERROR_UID_FETCH;
}
#else
return mailimap_uid_fetch_changedsince(session, set, fetch_type, 0, result);
#endif
}
LIBETPAN_EXPORT
@ -1948,6 +1967,7 @@ int
mailimap_search(mailimap * session, const char * charset,
struct mailimap_search_key * key, clist ** result)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -1991,6 +2011,9 @@ mailimap_search(mailimap * session, const char * charset,
default:
return MAILIMAP_ERROR_SEARCH;
}
#else
return mailimap_search_modseq(session, charset, key, result, NULL);
#endif
}
LIBETPAN_EXPORT
@ -1998,6 +2021,7 @@ int
mailimap_uid_search(mailimap * session, const char * charset,
struct mailimap_search_key * key, clist ** result)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -2041,6 +2065,9 @@ mailimap_uid_search(mailimap * session, const char * charset,
default:
return MAILIMAP_ERROR_UID_SEARCH;
}
#else
return mailimap_uid_search_modseq(session, charset, key, result, NULL);
#endif
}
LIBETPAN_EXPORT
@ -2050,6 +2077,7 @@ void mailimap_search_result_free(clist * search_result)
clist_free(search_result);
}
#if 0
LIBETPAN_EXPORT
int
mailimap_select(mailimap * session, const char * mb)
@ -2104,6 +2132,15 @@ mailimap_select(mailimap * session, const char * mb)
return MAILIMAP_ERROR_SELECT;
}
}
#else
LIBETPAN_EXPORT
int
mailimap_select(mailimap * session, const char * mb)
{
uint64_t dummy;
return mailimap_select_condstore_optional(session, mb, 0, &dummy);
}
#endif
LIBETPAN_EXPORT
int
@ -2164,6 +2201,7 @@ mailimap_store(mailimap * session,
struct mailimap_set * set,
struct mailimap_store_att_flags * store_att_flags)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -2204,6 +2242,10 @@ mailimap_store(mailimap * session,
default:
return MAILIMAP_ERROR_STORE;
}
#else
return mailimap_store_unchangedsince_optional(session,
set, 0, 0, store_att_flags);
#endif
}
LIBETPAN_EXPORT
@ -2212,6 +2254,7 @@ mailimap_uid_store(mailimap * session,
struct mailimap_set * set,
struct mailimap_store_att_flags * store_att_flags)
{
#if 0
struct mailimap_response * response;
int r;
int error_code;
@ -2252,6 +2295,10 @@ mailimap_uid_store(mailimap * session,
default:
return MAILIMAP_ERROR_UID_STORE;
}
#else
return mailimap_uid_store_unchangedsince_optional(session,
set, 0, 0, store_att_flags);
#endif
}
LIBETPAN_EXPORT


+ 1
- 0
src/low-level/imap/mailimap.h View File

@ -59,6 +59,7 @@ extern "C" {
#include <libetpan/xlist.h>
#include <libetpan/xgmlabels.h>
#include <libetpan/xgmmsgid.h>
#include <libetpan/condstore.h>
/*
mailimap_connect()


+ 3
- 1
src/low-level/imap/mailimap_extension.c View File

@ -50,6 +50,7 @@
#include "xgmmsgid.h"
#include "mailimap_id.h"
#include "enable.h"
#include "condstore.h"
/*
the list of registered extensions (struct mailimap_extension_api *)
@ -69,7 +70,8 @@ static struct mailimap_extension_api * internal_extension_list[] = {
&mailimap_extension_xgmlabels,
&mailimap_extension_xgmmsgid,
&mailimap_extension_id,
&mailimap_extension_enable
&mailimap_extension_enable,
&mailimap_extension_condstore
};
LIBETPAN_EXPORT


+ 4
- 2
src/low-level/imap/mailimap_extension_types.h View File

@ -17,7 +17,8 @@ enum {
MAILIMAP_EXTENSION_XGMLABELS, /* X-GM-LABELS (Gmail) */
MAILIMAP_EXTENSION_XGMMSGID, /* X-GM-MSGID (Gmail) */
MAILIMAP_EXTENSION_ID, /* ID */
MAILIMAP_EXTENSION_ENABLE /* ENABLE */
MAILIMAP_EXTENSION_ENABLE, /* ENABLE */
MAILIMAP_EXTENSION_CONDSTORE /* CONDSTORE */
};
@ -30,7 +31,8 @@ enum {
MAILIMAP_EXTENDED_PARSER_RESPONSE_DATA,
MAILIMAP_EXTENDED_PARSER_RESP_TEXT_CODE,
MAILIMAP_EXTENDED_PARSER_MAILBOX_DATA,
MAILIMAP_EXTENDED_PARSER_FETCH_DATA
MAILIMAP_EXTENDED_PARSER_FETCH_DATA,
MAILIMAP_EXTENDED_PARSER_STATUS_ATT
};
/*


+ 6
- 5
src/low-level/imap/mailimap_keywords.c View File

@ -177,11 +177,12 @@ static int mailimap_get_token_value_size(mailstream * fd, MMAPString * buffer,
static struct mailimap_token_value status_att_tab[] = {
{MAILIMAP_STATUS_ATT_MESSAGES, "MESSAGES"},
{MAILIMAP_STATUS_ATT_RECENT, "RECENT"},
{MAILIMAP_STATUS_ATT_UIDNEXT, "UIDNEXT"},
{MAILIMAP_STATUS_ATT_UIDVALIDITY, "UIDVALIDITY"},
{MAILIMAP_STATUS_ATT_UNSEEN, "UNSEEN"}
{MAILIMAP_STATUS_ATT_MESSAGES, "MESSAGES"},
{MAILIMAP_STATUS_ATT_RECENT, "RECENT"},
{MAILIMAP_STATUS_ATT_UIDNEXT, "UIDNEXT"},
{MAILIMAP_STATUS_ATT_UIDVALIDITY, "UIDVALIDITY"},
{MAILIMAP_STATUS_ATT_UNSEEN, "UNSEEN"},
{MAILIMAP_STATUS_ATT_HIGHESTMODSEQ, "HIGHESTMODSEQ"},
};
int mailimap_status_att_get_token_value(mailstream * fd, MMAPString * buffer,


+ 192
- 7
src/low-level/imap/mailimap_parser.c View File

@ -708,9 +708,6 @@ mailimap_section_text_parse(mailstream * fd, MMAPString * buffer,
progress_function * progr_fun);
static int mailimap_status_att_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, int * result);
static int mailimap_tag_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, char ** result,
size_t progr_rate,
@ -1303,7 +1300,7 @@ mailimap_custom_string_parse(mailstream * fd, MMAPString * buffer,
static int
int
mailimap_nz_number_alloc_parse(mailstream * fd, MMAPString * buffer,
size_t * indx,
uint32_t ** result,
@ -6363,6 +6360,30 @@ mailimap_status_info_parse(mailstream * fd, MMAPString * buffer,
value = 0;
r = mailimap_status_att_parse(fd, buffer, &cur_token, &status_att);
if (r == MAILIMAP_NO_ERROR) {
/* Force parse error when HIGHESTMODSEQ is parsed */
if (status_att == MAILIMAP_STATUS_ATT_HIGHESTMODSEQ) {
r = MAILIMAP_ERROR_PARSE;
}
}
if (r == MAILIMAP_ERROR_PARSE) {
struct mailimap_extension_data * ext_data;
r = mailimap_extension_data_parse(MAILIMAP_EXTENDED_PARSER_STATUS_ATT,
fd, buffer, &cur_token, &ext_data,
progr_rate, progr_fun);
if (r == MAILIMAP_NO_ERROR) {
info = mailimap_status_info_new(MAILIMAP_STATUS_ATT_EXTENSION, 0, ext_data);
if (info == NULL)
return MAILIMAP_ERROR_MEMORY;
* result = info;
* indx = cur_token;
return MAILIMAP_NO_ERROR;
}
}
if (r != MAILIMAP_NO_ERROR)
return r;
@ -6374,7 +6395,7 @@ mailimap_status_info_parse(mailstream * fd, MMAPString * buffer,
if (r != MAILIMAP_NO_ERROR)
return r;
info = mailimap_status_info_new(status_att, value);
info = mailimap_status_info_new(status_att, value, NULL);
if (info == NULL)
return MAILIMAP_ERROR_MEMORY;
@ -10528,8 +10549,8 @@ mailimap_section_text_parse(mailstream * fd, MMAPString * buffer,
"UNSEEN"
*/
static int mailimap_status_att_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, int * result)
int mailimap_status_att_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, int * result)
{
int type;
size_t cur_token;
@ -10880,3 +10901,167 @@ static int mailimap_zone_parse(mailstream * fd, MMAPString * buffer,
return MAILIMAP_NO_ERROR;
}
int mailimap_mod_sequence_value_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, uint64_t * result)
{
size_t cur_token;
int digit;
uint64_t number;
int parsed;
int r;
cur_token = * indx;
parsed = 0;
mailimap_space_parse(fd, buffer, &cur_token);
number = 0;
while (1) {
r = mailimap_digit_parse(fd, buffer, &cur_token, &digit);
if (r == MAILIMAP_ERROR_PARSE)
break;
else if (r == MAILIMAP_NO_ERROR) {
number *= 10;
number += digit;
parsed = 1;
}
else
return r;
}
if (!parsed)
return MAILIMAP_ERROR_PARSE;
* result = number;
* indx = cur_token;
return MAILIMAP_NO_ERROR;
}
static int mailimap_seq_number_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, uint32_t * result)
{
int r;
uint32_t value;
size_t cur_token;
cur_token = * indx;
r = mailimap_nz_number_parse(fd, buffer, &cur_token, &value);
if (r == MAILIMAP_NO_ERROR) {
* indx = cur_token;
* result = value;
return MAILIMAP_NO_ERROR;
}
r = mailimap_star_parse(fd, buffer, &cur_token);
if (r == MAILIMAP_NO_ERROR) {
* indx = cur_token;
* result = 0;
return MAILIMAP_NO_ERROR;
}
return MAILIMAP_ERROR_PARSE;
}
static int mailimap_seq_range_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, uint32_t * result_left, uint32_t * result_right)
{
size_t cur_token;
int r;
uint32_t left;
uint32_t right;
cur_token = * indx;
r = mailimap_seq_number_parse(fd, buffer, &cur_token, &left);
if (r != MAILIMAP_NO_ERROR) {
return r;
}
r = mailimap_colon_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
return r;
}
r = mailimap_seq_number_parse(fd, buffer, &cur_token, &right);
if (r != MAILIMAP_NO_ERROR) {
return r;
}
* indx = cur_token;
* result_left = left;
* result_right = right;
return MAILIMAP_NO_ERROR;
}
static int mailimap_set_item_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, struct mailimap_set_item ** result,
size_t progr_rate,
progress_function * progr_fun)
{
int r;
uint32_t value;
uint32_t left;
uint32_t right;
size_t cur_token;
cur_token = * indx;
r = mailimap_seq_range_parse(fd, buffer, &cur_token, &left, &right);
if (r == MAILIMAP_NO_ERROR) {
struct mailimap_set_item * item;
item = mailimap_set_item_new(left, right);
if (item == NULL) {
return MAILIMAP_ERROR_MEMORY;
}
* result = item;
* indx = cur_token;
return MAILIMAP_NO_ERROR;
}
r = mailimap_seq_number_parse(fd, buffer, &cur_token, &value);
if (r == MAILIMAP_NO_ERROR) {
struct mailimap_set_item * item;
item = mailimap_set_item_new(value, value);
if (item == NULL) {
return MAILIMAP_ERROR_MEMORY;
}
* result = item;
* indx = cur_token;
return MAILIMAP_NO_ERROR;
}
return MAILIMAP_ERROR_PARSE;
}
int mailimap_set_parse(mailstream * fd,
MMAPString * buffer, size_t * indx, struct mailimap_set ** result)
{
size_t cur_token;
struct mailimap_set * set;
clist * item_list;
int r;
cur_token = * indx;
r = mailimap_struct_list_parse(fd, buffer, indx, &item_list,
' ', (mailimap_struct_parser *) mailimap_set_item_parse, (mailimap_struct_destructor *)mailimap_set_item_free,
0, NULL);
if (r != MAILIMAP_NO_ERROR)
return r;
set = mailimap_set_new(item_list);
if (set == NULL) {
clist_foreach(item_list, (clist_func) mailimap_set_item_free, NULL);
clist_free(item_list);
return MAILIMAP_ERROR_MEMORY;
}
* indx = cur_token;
* result = set;
return MAILIMAP_NO_ERROR;
}

+ 15
- 0
src/low-level/imap/mailimap_parser.h View File

@ -183,6 +183,21 @@ int mailimap_capability_data_parse(mailstream * fd, MMAPString * buffer,
size_t progr_rate,
progress_function * progr_fun);
int mailimap_status_att_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, int * result);
int mailimap_nz_number_alloc_parse(mailstream * fd, MMAPString * buffer,
size_t * indx,
uint32_t ** result,
size_t progr_rate,
progress_function * progr_fun);
int mailimap_mod_sequence_value_parse(mailstream * fd, MMAPString * buffer,
size_t * indx, uint64_t * result);
int mailimap_set_parse(mailstream * fd,
MMAPString * buffer, size_t * indx, struct mailimap_set ** result);
#ifdef __cplusplus
}
#endif


+ 223
- 100
src/low-level/imap/mailimap_sender.c View File

@ -1030,7 +1030,7 @@ static int mailimap_digit_send(mailstream * fd, int digit)
=> examine = "EXAMINE" SP mailbox
*/
int mailimap_examine_send(mailstream * fd, const char * mb)
int mailimap_examine_send(mailstream * fd, const char * mb, int condstore)
{
int r;
@ -1046,6 +1046,24 @@ int mailimap_examine_send(mailstream * fd, const char * mb)
if (r != MAILIMAP_NO_ERROR)
return r;
if (condstore) {
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_oparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_token_send(fd, "CONDSTORE");
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_cparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
}
return MAILIMAP_NO_ERROR;
}
@ -1934,49 +1952,49 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_BCC:
r = mailimap_token_send(fd, "BCC");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_bcc);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_BEFORE:
r = mailimap_token_send(fd, "BEFORE");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_before);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_BODY:
r = mailimap_token_send(fd, "BODY");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_body);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_CC:
r = mailimap_token_send(fd, "CC");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_cc);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
@ -1988,25 +2006,25 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_FROM:
r = mailimap_token_send(fd, "FROM");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_from);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_KEYWORD:
r = mailimap_token_send(fd, "KEYWORD");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_flag_keyword_send(fd, key->sk_data.sk_keyword);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_flag_keyword_send(fd, key->sk_data.sk_keyword);
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
@ -2018,13 +2036,13 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_ON:
r = mailimap_token_send(fd, "ON");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_on);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_on);
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
@ -2036,49 +2054,49 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_SINCE:
r = mailimap_token_send(fd, "SINCE");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_since);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_SUBJECT:
r = mailimap_token_send(fd, "SUBJECT");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_subject);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_TEXT:
r = mailimap_token_send(fd, "TEXT");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_text);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_TO:
r = mailimap_token_send(fd, "TO");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd, key->sk_data.sk_text);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
@ -2093,14 +2111,14 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_UNKEYWORD:
r = mailimap_token_send(fd, "UNKEYWORD");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_flag_keyword_send(fd, key->sk_data.sk_keyword);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_UNSEEN:
@ -2111,123 +2129,123 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_HEADER:
r = mailimap_token_send(fd, "HEADER");
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_header_fld_name_send(fd,
key->sk_data.sk_header.sk_header_name);
if (r != MAILIMAP_NO_ERROR)
return r;
key->sk_data.sk_header.sk_header_name);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_astring_send(fd,
key->sk_data.sk_header.sk_header_value);
if (r != MAILIMAP_NO_ERROR)
return r;
key->sk_data.sk_header.sk_header_value);
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_LARGER:
r = mailimap_token_send(fd, "LARGER");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_number_send(fd, key->sk_data.sk_larger);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_NOT:
r = mailimap_token_send(fd, "NOT");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_search_key_send(fd, key->sk_data.sk_not);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_OR:
r = mailimap_token_send(fd, "OR");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_search_key_send(fd, key->sk_data.sk_or.sk_or1);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_search_key_send(fd, key->sk_data.sk_or.sk_or2);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_SENTBEFORE:
r = mailimap_token_send(fd, "SENTBEFORE");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_sentbefore);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_SENTON:
r = mailimap_token_send(fd, "SENTON");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_senton);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_SENTSINCE:
r = mailimap_token_send(fd, "SENTSINCE");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_date_send(fd, key->sk_data.sk_sentsince);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_SMALLER:
r = mailimap_token_send(fd, "SMALLER");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_number_send(fd, key->sk_data.sk_smaller);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_UID:
r = mailimap_token_send(fd, "UID");
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_set_send(fd, key->sk_data.sk_set);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
@ -2239,26 +2257,89 @@ static int mailimap_search_key_send(mailstream * fd,
case MAILIMAP_SEARCH_KEY_MULTIPLE:
r = mailimap_oparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_struct_spaced_list_send(fd, key->sk_data.sk_multiple,
(mailimap_struct_sender *)
mailimap_search_key_send);
if (r != MAILIMAP_NO_ERROR)
(mailimap_struct_sender *) mailimap_search_key_send);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_cparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
case MAILIMAP_SEARCH_KEY_MODSEQ:
r = mailimap_token_send(fd, "MODSEQ");
if (r != MAILIMAP_NO_ERROR)
return r;
if (key->sk_data.sk_modseq.sk_entry_name != NULL) {
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
mailimap_dquote_send(fd);
r = mailimap_token_send(fd, "/flags/");
if (r != MAILIMAP_NO_ERROR)
return r;
if (key->sk_data.sk_modseq.sk_entry_name->fl_type != MAILIMAP_FLAG_KEYWORD) {
r = mailimap_token_send(fd, "\\");
if (r != MAILIMAP_NO_ERROR)
return r;
}
r = mailimap_flag_send(fd, key->sk_data.sk_modseq.sk_entry_name);
if (r != MAILIMAP_NO_ERROR)
return r;
mailimap_dquote_send(fd);
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
switch (key->sk_data.sk_modseq.sk_entry_type_req) {
case MAILIMAP_SEARCH_KEY_MODSEQ_ENTRY_TYPE_REQ_PRIV:
r = mailimap_token_send(fd, "priv");
if (r != MAILIMAP_NO_ERROR)
return r;
break;
case MAILIMAP_SEARCH_KEY_MODSEQ_ENTRY_TYPE_REQ_SHARED:
r = mailimap_token_send(fd, "shared");
if (r != MAILIMAP_NO_ERROR)
return r;
break;
case MAILIMAP_SEARCH_KEY_MODSEQ_ENTRY_TYPE_REQ_ALL:
r = mailimap_token_send(fd, "all");
if (r != MAILIMAP_NO_ERROR)
return r;
break;
}
}
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_mod_sequence_value_send(fd, key->sk_data.sk_modseq.sk_modseq_valzer);
if (r != MAILIMAP_NO_ERROR)
return r;
return MAILIMAP_NO_ERROR;
default:
/* should not happend */
return MAILIMAP_ERROR_INVAL;
}
}
int mailimap_mod_sequence_value_send(mailstream * fd, uint64_t modseq)
{
char modseqstr[30];
snprintf(modseqstr, sizeof(modseqstr), "%llu", (long long unsigned) modseq);
return mailimap_token_send(fd, modseqstr);
}
/*
=> section = "[" [section-spec] "]"
*/
@ -2428,7 +2509,7 @@ mailimap_section_text_send(mailstream * fd,
*/
int
mailimap_select_send(mailstream * fd, const char * mb)
mailimap_select_send(mailstream * fd, const char * mb, int condstore)
{
int r;
@ -2442,6 +2523,24 @@ mailimap_select_send(mailstream * fd, const char * mb)
if (r != MAILIMAP_NO_ERROR)
return r;
if (condstore) {
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_oparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_token_send(fd, "CONDSTORE");
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_cparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
}
return MAILIMAP_NO_ERROR;
}
@ -2580,7 +2679,7 @@ static int mailimap_status_att_send(mailstream * fd, int * status_att)
int
mailimap_store_send(mailstream * fd,
struct mailimap_set * set,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags)
{
int r;
@ -2594,6 +2693,29 @@ mailimap_store_send(mailstream * fd,
r = mailimap_set_send(fd, set);
if (r != MAILIMAP_NO_ERROR)
return r;
if (use_unchangedsince) {
r = mailimap_oparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_token_send(fd, "UNCHANGEDSINCE");
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_mod_sequence_value_send(fd, mod_sequence_valzer);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_cparenth_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
}
r = mailimap_space_send(fd);
if (r != MAILIMAP_NO_ERROR)
return r;
@ -2607,7 +2729,7 @@ mailimap_store_send(mailstream * fd,
int
mailimap_uid_store_send(mailstream * fd,
struct mailimap_set * set,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags)
{
int r;
@ -2619,7 +2741,8 @@ mailimap_uid_store_send(mailstream * fd,
if (r != MAILIMAP_NO_ERROR)
return r;
return mailimap_store_send(fd, set, store_att_flags);
return mailimap_store_send(fd, set,
use_unchangedsince, mod_sequence_valzer, store_att_flags);
}
/*


+ 10
- 8
src/low-level/imap/mailimap_sender.h View File

@ -81,7 +81,7 @@ int mailimap_create_send(mailstream * fd,
int mailimap_delete_send(mailstream * fd, const char * mb);
int mailimap_examine_send(mailstream * fd, const char * mb);
int mailimap_examine_send(mailstream * fd, const char * mb, int condstore);
int
mailimap_fetch_send(mailstream * fd,
@ -114,21 +114,21 @@ mailimap_uid_search_send(mailstream * fd, const char * charset,
struct mailimap_search_key * key);
int
mailimap_select_send(mailstream * fd, const char * mb);
mailimap_select_send(mailstream * fd, const char * mb, int condstore);
int
mailimap_status_send(mailstream * fd, const char * mb,
struct mailimap_status_att_list * status_att_list);
int
mailimap_store_send(mailstream * fd,
struct mailimap_set * set,
struct mailimap_store_att_flags * store_att_flags);
mailimap_store_send(mailstream * fd,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
int
mailimap_uid_store_send(mailstream * fd,
struct mailimap_set * set,
struct mailimap_store_att_flags * store_att_flags);
mailimap_uid_store_send(mailstream * fd,
struct mailimap_set * set, int use_unchangedsince, uint64_t mod_sequence_valzer,
struct mailimap_store_att_flags * store_att_flags);
int mailimap_subscribe_send(mailstream * fd, const char * mb);
@ -188,6 +188,8 @@ int mailimap_oparenth_send(mailstream * fd);
int mailimap_cparenth_send(mailstream * fd);
int mailimap_mod_sequence_value_send(mailstream * fd, uint64_t modseq);
#ifdef __cplusplus
}
#endif


+ 11
- 1
src/low-level/imap/mailimap_types.c View File

@ -1272,7 +1272,8 @@ void mailimap_mailbox_free(char * mb)
struct mailimap_status_info *
mailimap_status_info_new(int st_att, uint32_t st_value)
mailimap_status_info_new(int st_att, uint32_t st_value,
struct mailimap_extension_data * st_ext_data)
{
struct mailimap_status_info * info;
@ -1281,12 +1282,16 @@ mailimap_status_info_new(int st_att, uint32_t st_value)
return NULL;
info->st_att = st_att;
info->st_value = st_value;
info->st_ext_data = st_ext_data;
return info;
}
void mailimap_status_info_free(struct mailimap_status_info * info)
{
if (info->st_ext_data != NULL) {
mailimap_extension_data_free(info->st_ext_data);
}
free(info);
}
@ -2829,6 +2834,11 @@ void mailimap_search_key_free(struct mailimap_search_key * key)
(clist_func) mailimap_search_key_free, NULL);
clist_free(key->sk_data.sk_multiple);
break;
case MAILIMAP_SEARCH_KEY_MODSEQ:
if (key->sk_data.sk_modseq.sk_entry_name != NULL) {
mailimap_flag_free(key->sk_data.sk_modseq.sk_entry_name);
}