Permalink
Browse files

implemented Gmail X-GM-LABELS extension

  • Loading branch information...
dinhviethoa committed Dec 28, 2011
1 parent e23e23e commit 01b2aedbd3ff8febe85beb7227f81895bb2eee3a
@@ -359,6 +359,9 @@
C69AB2DA1054704000F32FBD /* uidplus_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EA1D105335BC0059C3BA /* uidplus_parser.c */; };
C69AB2DC1054704000F32FBD /* uidplus_sender.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EA1F105335BC0059C3BA /* uidplus_sender.c */; };
C69AB2DE1054704000F32FBD /* uidplus_types.c in Sources */ = {isa = PBXBuildFile; fileRef = C6F9EA21105335BC0059C3BA /* uidplus_types.c */; };
+ C69AD25F14AB2062003D04D5 /* xgmlabels.c in Sources */ = {isa = PBXBuildFile; fileRef = C6CE9B1514AA9C8900D20BA6 /* xgmlabels.c */; };
+ C6CE9B1614AA9C8B00D20BA6 /* xgmlabels.c in Sources */ = {isa = PBXBuildFile; fileRef = C6CE9B1514AA9C8900D20BA6 /* xgmlabels.c */; };
+ C6CE9B1914AA9C9D00D20BA6 /* xgmlabels.h in Headers */ = {isa = PBXBuildFile; fileRef = C6CE9B1814AA9C9C00D20BA6 /* xgmlabels.h */; };
C6DC671C1083CDA000FA050B /* acl.h in Headers */ = {isa = PBXBuildFile; fileRef = C6DC66931083CDA000FA050B /* acl.h */; settings = {ATTRIBUTES = (Public, ); }; };
C6DC671D1083CDA000FA050B /* acl_types.h in Headers */ = {isa = PBXBuildFile; fileRef = C6DC66941083CDA000FA050B /* acl_types.h */; settings = {ATTRIBUTES = (Public, ); }; };
C6DC671E1083CDA000FA050B /* annotatemore.h in Headers */ = {isa = PBXBuildFile; fileRef = C6DC66951083CDA000FA050B /* annotatemore.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -707,6 +710,8 @@
C68C6205130FFE7E00F16728 /* quota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = quota.h; sourceTree = "<group>"; };
C69AAFB51054298E00F32FBD /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
C69AB10A10546FE500F32FBD /* libetpan.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libetpan.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ C6CE9B1514AA9C8900D20BA6 /* xgmlabels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xgmlabels.c; sourceTree = "<group>"; };
+ C6CE9B1814AA9C9C00D20BA6 /* xgmlabels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xgmlabels.h; sourceTree = "<group>"; };
C6DC66931083CDA000FA050B /* acl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acl.h; sourceTree = "<group>"; };
C6DC66941083CDA000FA050B /* acl_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acl_types.h; sourceTree = "<group>"; };
C6DC66951083CDA000FA050B /* annotatemore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = annotatemore.h; sourceTree = "<group>"; };
@@ -1887,6 +1892,8 @@
C6F9EA22105335BC0059C3BA /* uidplus_types.h */,
C6667DED1342ACCD00969A8E /* xlist.c */,
C6667DEE1342ACCD00969A8E /* xlist.h */,
+ C6CE9B1514AA9C8900D20BA6 /* xgmlabels.c */,
+ C6CE9B1814AA9C9C00D20BA6 /* xgmlabels.h */,
);
path = imap;
sourceTree = "<group>";
@@ -2379,6 +2386,7 @@
C68C620D130FFE7E00F16728 /* quota.h in Headers */,
C6667DF01342ACCD00969A8E /* xlist.h in Headers */,
C6EFB8791433F1F300F805C0 /* mailstream_cfstream.h in Headers */,
+ C6CE9B1914AA9C9D00D20BA6 /* xgmlabels.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2621,6 +2629,7 @@
C6517A0E130E86D3004ADD56 /* namespace_sender.c in Sources */,
C6667DEF1342ACCD00969A8E /* xlist.c in Sources */,
C6EFB8781433F1F300F805C0 /* mailstream_cfstream.c in Sources */,
+ C6CE9B1614AA9C8B00D20BA6 /* xgmlabels.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2787,6 +2796,7 @@
C6517A10130E86D3004ADD56 /* namespace_sender.c in Sources */,
C6667DF11342ACCD00969A8E /* xlist.c in Sources */,
C6EFB87A1433F1F300F805C0 /* mailstream_cfstream.c in Sources */,
+ C69AD25F14AB2062003D04D5 /* xgmlabels.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -42,7 +42,7 @@ etpaninclude_HEADERS = \
quota.h quota_parser.h quota_sender.h quota_types.h \
idle.h \
namespace.h namespace_parser.h namespace_sender.h namespace_types.h \
- xlist.h
+ xlist.h xgmlabels.h
AM_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_srcdir)/src/data-types
@@ -81,4 +81,5 @@ libimap_la_SOURCES = \
namespace_parser.c namespace_parser.h \
namespace_sender.c namespace_sender.h \
namespace_types.c namespace_types.h \
- xlist.c xlist.h
+ xlist.c xlist.h \
+ xgmlabels.c xgmlabels.h
@@ -55,6 +55,7 @@ extern "C" {
#include <libetpan/quota.h>
#include <libetpan/namespace.h>
#include <libetpan/xlist.h>
+#include <libetpan/xgmlabels.h>
/*
mailimap_connect()
@@ -46,6 +46,7 @@
#include "quota.h"
#include "namespace.h"
#include "xlist.h"
+#include "xgmlabels.h"
/*
the list of registered extensions (struct mailimap_extension_api *)
@@ -62,6 +63,7 @@ static struct mailimap_extension_api * internal_extension_list[] = {
&mailimap_extension_quota,
&mailimap_extension_namespace,
&mailimap_extension_xlist,
+ &mailimap_extension_xgmlabels,
};
LIBETPAN_EXPORT
@@ -13,7 +13,8 @@ enum {
MAILIMAP_EXTENSION_UIDPLUS, /* UIDPLUS */
MAILIMAP_EXTENSION_QUOTA, /* quota */
MAILIMAP_EXTENSION_NAMESPACE, /* namespace */
- MAILIMAP_EXTENSION_XLIST /* XLIST (Gmail and Zimbra have this) */
+ MAILIMAP_EXTENSION_XLIST, /* XLIST (Gmail and Zimbra have this) */
+ MAILIMAP_EXTENSION_XGMLABELS /* X-GM-LABELS (Gmail) */
};
@@ -25,7 +26,8 @@ enum {
enum {
MAILIMAP_EXTENDED_PARSER_RESPONSE_DATA,
MAILIMAP_EXTENDED_PARSER_RESP_TEXT_CODE,
- MAILIMAP_EXTENDED_PARSER_MAILBOX_DATA
+ MAILIMAP_EXTENDED_PARSER_MAILBOX_DATA,
+ MAILIMAP_EXTENDED_PARSER_FETCH_DATA
};
/*
@@ -7457,6 +7457,7 @@ mailimap_msg_att_item_parse_progress(mailstream * fd, MMAPString * buffer,
int type;
struct mailimap_msg_att_dynamic * msg_att_dynamic;
struct mailimap_msg_att_static * msg_att_static;
+ struct mailimap_extension_data * msg_att_extension;
size_t cur_token;
struct mailimap_msg_att_item * item;
int r;
@@ -7466,6 +7467,7 @@ mailimap_msg_att_item_parse_progress(mailstream * fd, MMAPString * buffer,
msg_att_dynamic = NULL;
msg_att_static = NULL;
+ msg_att_extension = NULL;
type = MAILIMAP_MSG_ATT_ITEM_ERROR; /* XXX - removes a gcc warning */
@@ -7484,12 +7486,19 @@ mailimap_msg_att_item_parse_progress(mailstream * fd, MMAPString * buffer,
type = MAILIMAP_MSG_ATT_ITEM_STATIC;
}
+ if (r == MAILIMAP_ERROR_PARSE) {
+ r = mailimap_extension_data_parse(MAILIMAP_EXTENDED_PARSER_FETCH_DATA,
+ fd, buffer, &cur_token, &msg_att_extension, progr_rate, progr_fun);
+ if (r == MAILIMAP_NO_ERROR)
+ type = MAILIMAP_MSG_ATT_ITEM_EXTENSION;
+ }
+
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
- item = mailimap_msg_att_item_new(type, msg_att_dynamic, msg_att_static);
+ item = mailimap_msg_att_item_new(type, msg_att_dynamic, msg_att_static, msg_att_extension);
if (item == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto free;
@@ -7501,6 +7510,8 @@ mailimap_msg_att_item_parse_progress(mailstream * fd, MMAPString * buffer,
return MAILIMAP_NO_ERROR;
free:
+ if (msg_att_extension != NULL)
+ mailimap_extension_data_free(msg_att_extension);
if (msg_att_dynamic != NULL)
mailimap_msg_att_dynamic_free(msg_att_dynamic);
if (msg_att_static != NULL)
@@ -1247,6 +1247,12 @@ static int mailimap_fetch_att_send(mailstream * fd,
}
return MAILIMAP_NO_ERROR;
+ case MAILIMAP_FETCH_ATT_EXTENSION:
+ r = mailimap_token_send(fd, fetch_att->att_extension);
+ if (r != MAILIMAP_NO_ERROR)
+ return r;
+ return MAILIMAP_NO_ERROR;
+
default:
/* should not happen */
return MAILIMAP_ERROR_INVAL;
@@ -1586,7 +1586,8 @@ mailimap_message_data_free(struct mailimap_message_data * msg_data)
struct mailimap_msg_att_item *
mailimap_msg_att_item_new(int att_type,
struct mailimap_msg_att_dynamic * att_dyn,
- struct mailimap_msg_att_static * att_static)
+ struct mailimap_msg_att_static * att_static,
+ struct mailimap_extension_data * att_extension_data)
{
struct mailimap_msg_att_item * item;
@@ -1602,6 +1603,9 @@ mailimap_msg_att_item_new(int att_type,
case MAILIMAP_MSG_ATT_ITEM_STATIC:
item->att_data.att_static = att_static;
break;
+ case MAILIMAP_MSG_ATT_ITEM_EXTENSION:
+ item->att_data.att_extension_data = att_extension_data;
+ break;
}
return item;
@@ -1617,6 +1621,9 @@ mailimap_msg_att_item_free(struct mailimap_msg_att_item * item)
case MAILIMAP_MSG_ATT_ITEM_STATIC:
mailimap_msg_att_static_free(item->att_data.att_static);
break;
+ case MAILIMAP_MSG_ATT_ITEM_EXTENSION:
+ mailimap_extension_data_free(item->att_data.att_extension_data);
+ break;
}
free(item);
}
@@ -2558,7 +2565,7 @@ void mailimap_date_free(struct mailimap_date * date)
struct mailimap_fetch_att *
mailimap_fetch_att_new(int att_type, struct mailimap_section * att_section,
- uint32_t att_offset, uint32_t att_size)
+ uint32_t att_offset, uint32_t att_size, char * att_extension)
{
struct mailimap_fetch_att * fetch_att;
@@ -2569,12 +2576,15 @@ mailimap_fetch_att_new(int att_type, struct mailimap_section * att_section,
fetch_att->att_section = att_section;
fetch_att->att_offset = att_offset;
fetch_att->att_size = att_size;
+ fetch_att->att_extension = att_extension;
return fetch_att;
}
void mailimap_fetch_att_free(struct mailimap_fetch_att * fetch_att)
{
+ if (fetch_att->att_extension != NULL)
+ free(fetch_att->att_extension);
if (fetch_att->att_section != NULL)
mailimap_section_free(fetch_att->att_section);
free(fetch_att);
@@ -1824,35 +1824,40 @@ mailimap_message_data_free(struct mailimap_message_data * msg_data);
enum {
MAILIMAP_MSG_ATT_ITEM_ERROR, /* on parse error */
MAILIMAP_MSG_ATT_ITEM_DYNAMIC, /* dynamic message attributes (flags) */
- MAILIMAP_MSG_ATT_ITEM_STATIC /* static messages attributes
+ MAILIMAP_MSG_ATT_ITEM_STATIC, /* static messages attributes
(message content) */
+ MAILIMAP_MSG_ATT_ITEM_EXTENSION /* extension data */
};
/*
mailimap_msg_att_item is a message attribute
- type is the type of message attribute, the value can be
- MAILIMAP_MSG_ATT_ITEM_DYNAMIC or MAILIMAP_MSG_ATT_ITEM_STATIC
+ MAILIMAP_MSG_ATT_ITEM_DYNAMIC, MAILIMAP_MSG_ATT_ITEM_STATIC or MAILIMAP_MSG_ATT_ITEM_EXTENSION
- - msg_att_dyn is a dynamic message attribute when type is
+ - att_dyn is a dynamic message attribute when type is
MAILIMAP_MSG_ATT_ITEM_DYNAMIC
- - msg_att_static is a static message attribute when type is
+ - att_static is a static message attribute when type is
MAILIMAP_MSG_ATT_ITEM_STATIC
+
+ - att_extension_data is an extension data.
*/
struct mailimap_msg_att_item {
int att_type;
union {
struct mailimap_msg_att_dynamic * att_dyn; /* can be NULL */
struct mailimap_msg_att_static * att_static; /* can be NULL */
+ struct mailimap_extension_data * att_extension_data; /* can be NULL */
} att_data;
};
struct mailimap_msg_att_item *
mailimap_msg_att_item_new(int att_type,
struct mailimap_msg_att_dynamic * att_dyn,
- struct mailimap_msg_att_static * att_static);
+ struct mailimap_msg_att_static * att_static,
+ struct mailimap_extension_data * att_extension_data);
void
mailimap_msg_att_item_free(struct mailimap_msg_att_item * item);
@@ -2659,8 +2664,9 @@ enum {
additional information */
MAILIMAP_FETCH_ATT_UID, /* to fetch the unique identifier */
MAILIMAP_FETCH_ATT_BODY_SECTION, /* to fetch a given part */
- MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION /* to fetch a given part without
+ MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION, /* to fetch a given part without
marking the message as read */
+ MAILIMAP_FETCH_ATT_EXTENSION
};
@@ -2673,27 +2679,31 @@ enum {
MAILIMAP_FETCH_ATT_RFC822_HEADER, MAILIMAP_FETCH_ATT_RFC822_SIZE,
MAILIMAP_FETCH_ATT_RFC822_TEXT, MAILIMAP_FETCH_ATT_BODY,
MAILIMAP_FETCH_ATT_BODYSTRUCTURE, MAILIMAP_FETCH_ATT_UID,
- MAILIMAP_FETCH_ATT_BODY_SECTION or MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION
+ MAILIMAP_FETCH_ATT_BODY_SECTION, MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION,
+ MAILIMAP_FETCH_ATT_EXTENSION
- section is the location of the part to fetch if type is
MAILIMAP_FETCH_ATT_BODY_SECTION or MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION
- offset is the first byte to fetch in the given part
- size is the maximum size of the part to fetch
+
+ - att_extension: keyword to send when MAILIMAP_FETCH_ATT_EXTENSION is used
*/
struct mailimap_fetch_att {
int att_type;
struct mailimap_section * att_section;
uint32_t att_offset;
uint32_t att_size;
+ char * att_extension; /* can be NULL */
};
LIBETPAN_EXPORT
struct mailimap_fetch_att *
mailimap_fetch_att_new(int att_type, struct mailimap_section * att_section,
- uint32_t att_offset, uint32_t att_size);
+ uint32_t att_offset, uint32_t att_size, char * att_extension);
LIBETPAN_EXPORT
Oops, something went wrong.

0 comments on commit 01b2aed

Please sign in to comment.