Lines Matching refs:imap
22 * RFC2595 Using TLS with IMAP, POP3 and ACAP
28 * RFC4959 IMAP Extension for SASL Initial Client Response
29 * RFC5092 IMAP URL Scheme
70 #include "imap.h"
114 * IMAP protocol handler.
118 "IMAP", /* scheme */
165 * HTTP-proxyed IMAP protocol handler.
169 "IMAP", /* scheme */
215 /* SASL parameters for the imap protocol */
217 "imap", /* The service name */
291 struct IMAP *imap = conn->data->req.protop;
325 if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
326 (imap->custom && !imap_matchresp(line, len, imap->custom) &&
327 (strcmp(imap->custom, "STORE") ||
329 strcmp(imap->custom, "SELECT") &&
330 strcmp(imap->custom, "EXAMINE") &&
331 strcmp(imap->custom, "SEARCH") &&
332 strcmp(imap->custom, "EXPUNGE") &&
333 strcmp(imap->custom, "LSUB") &&
334 strcmp(imap->custom, "UID") &&
335 strcmp(imap->custom, "NOOP")))
367 if(imap && !imap->custom && ((len == 3 && !memcmp("+", line, 1)) ||
421 * This is the ONLY way to change IMAP state!
448 infof(conn->data, "IMAP %p state change from %s to %s\n",
652 struct IMAP *imap = data->req.protop;
655 if(imap->custom)
657 result = imap_sendf(conn, "%s%s", imap->custom,
658 imap->custom_params ? imap->custom_params : "");
661 mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup("");
687 struct IMAP *imap = data->req.protop;
696 if(!imap->mailbox) {
702 mailbox = imap_atom(imap->mailbox, false);
726 struct IMAP *imap = conn->data->req.protop;
729 if(!imap->uid) {
735 if(imap->partial)
737 imap->uid,
738 imap->section ? imap->section : "",
739 imap->partial);
742 imap->uid,
743 imap->section ? imap->section : "");
760 struct IMAP *imap = conn->data->req.protop;
764 if(!imap->mailbox) {
776 mailbox = imap_atom(imap->mailbox, false);
801 struct IMAP *imap = conn->data->req.protop;
804 if(!imap->query) {
810 result = imap_sendf(conn, "SEARCH %s", imap->query);
848 failf(data, "Got unexpected imap-server response");
1055 struct IMAP *imap = conn->data->req.protop;
1071 if(imap->uidvalidity && imapc->mailbox_uidvalidity &&
1072 strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
1078 imapc->mailbox = strdup(imap->mailbox);
1080 if(imap->custom)
1082 else if(imap->query)
1174 /* IMAP download */
1225 /* IMAP upload */
1262 /* Busy upgrading the connection; right now all I/O is SSL/TLS, not IMAP */
1283 /* We have now received a full IMAP server response */
1374 /* Allocate and initialize the struct IMAP for the current Curl_easy if
1380 struct IMAP *imap;
1382 imap = data->req.protop = calloc(sizeof(struct IMAP), 1);
1383 if(!imap)
1389 /* For the IMAP "protocol connect" and "doing" phases only */
1414 /* We always support persistent connections in IMAP */
1415 connkeep(conn, "IMAP default");
1460 struct IMAP *imap = data->req.protop;
1464 if(!imap)
1468 connclose(conn, "IMAP done with bad status"); /* marked for closure */
1471 else if(!data->set.connect_only && !imap->custom &&
1472 (imap->uid || data->set.upload)) {
1494 Curl_safefree(imap->mailbox);
1495 Curl_safefree(imap->uidvalidity);
1496 Curl_safefree(imap->uid);
1497 Curl_safefree(imap->section);
1498 Curl_safefree(imap->partial);
1499 Curl_safefree(imap->query);
1500 Curl_safefree(imap->custom);
1501 Curl_safefree(imap->custom_params);
1504 imap->transfer = FTPTRANSFER_BODY;
1513 * This is the actual DO function for IMAP. Fetch or append a message, or do
1519 /* This is IMAP and no proxy */
1522 struct IMAP *imap = data->req.protop;
1530 imap->transfer = FTPTRANSFER_INFO;
1537 if(imap->mailbox && imapc->mailbox &&
1538 !strcmp(imap->mailbox, imapc->mailbox) &&
1539 (!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
1540 !strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)))
1547 else if(imap->custom && (selected || !imap->mailbox))
1550 else if(!imap->custom && selected && imap->uid)
1553 else if(!imap->custom && selected && imap->query)
1556 else if(imap->mailbox && !selected &&
1557 (imap->custom || imap->uid || imap->query))
1612 * Disconnect from an IMAP server. Cleanup protocol-specific per-connection
1623 /* The IMAP session may or may not have been allocated/setup at this
1645 struct IMAP *imap = conn->data->req.protop;
1649 if(imap->transfer != FTPTRANSFER_BODY)
1711 /* Initialise the IMAP layer */
1721 /* Unless we have asked to tunnel IMAP operations through the proxy, we
1738 failf(data, "IMAP over http proxy requires HTTP support built-in!");
1752 * Sends the formated string as an IMAP command to the server.
1972 /* The imap struct is already initialised in imap_connect() */
1975 struct IMAP *imap = data->req.protop;
1989 result = Curl_urldecode(data, begin, end - begin, &imap->mailbox, NULL,
1995 imap->mailbox = NULL;
2028 DEBUGF(infof(conn->data, "IMAP URL parameter '%s' = '%s'\n", name, value));
2034 if(Curl_raw_equal(name, "UIDVALIDITY") && !imap->uidvalidity) {
2038 imap->uidvalidity = value;
2041 else if(Curl_raw_equal(name, "UID") && !imap->uid) {
2045 imap->uid = value;
2048 else if(Curl_raw_equal(name, "SECTION") && !imap->section) {
2052 imap->section = value;
2055 else if(Curl_raw_equal(name, "PARTIAL") && !imap->partial) {
2059 imap->partial = value;
2075 if(imap->mailbox && !imap->uid && *ptr == '?') {
2082 result = Curl_urldecode(data, begin, ptr - begin, &imap->query, NULL,
2105 struct IMAP *imap = data->req.protop;
2110 result = Curl_urldecode(data, custom, 0, &imap->custom, NULL, TRUE);
2114 const char *params = imap->custom;
2120 imap->custom_params = strdup(params);
2121 imap->custom[params - imap->custom] = '\0';
2123 if(!imap->custom_params)