Commit Graph

147 Commits

Author SHA1 Message Date
Steve Holme b06a786226 imap: Updated the coding style for state changes after a send operation
Some state changes would be performed after a failure test that
performed a hard return, whilst others would be performed within a test
for success. Updated the code, for consistency, so all instances are
performed within a success test.
2013-02-28 22:46:22 +00:00
Jiri Hruska 10549ee08f imap: FETCH response handler cleanup before further changes
Removed superfluous NULL assignment after Curl_safefree() and rewrote
some comments and logging messages.
2013-02-28 22:13:34 +00:00
Steve Holme 6ff7197e70 imap: Small tidy up of function arguments 2013-02-28 21:18:36 +00:00
Steve Holme 11a22f3264 imap: Corrected debug message for IMAP_AUTHENTICATE_FINAL constant
Following commit 13006f3de9 corrected the debug message in state()
from AUTHENTICATE to AUTHENTICATE_FINAL.
2013-02-28 21:09:27 +00:00
Jiri Hruska 025ba6e9be imap: Fixed error code returned for invalid FETCH response
If the FETCH command does not result in an untagged response the the
UID is probably invalid. As such do not return CURLE_OK.
2013-02-28 21:00:13 +00:00
Jiri Hruska cdea86ff67 imap: Added processing of the final FETCH responses
Not processing the final FETCH responses was not optimal, not only
because the response code would be ignored but it would also leave data
unread on the socket which would prohibit connection reuse.
2013-02-28 21:00:11 +00:00
Jiri Hruska 974c663471 imap: Introduced FETCH_FINAL state for processing final fetch responses
A typical FETCH response can be broken down into four parts:

  1) "* <uid> FETCH (<what> {<size>}\r\n", using continuation syntax
  2) <size> bytes of the actual message
  3) ")\r\n", finishing the untagged response
  4) "<tag> OK ...", finishing the command

Part 1 is read in imap_fetch_resp(), part 2 is consumed in the PERFORM
phase by the transfer subsystem, parts 3 and 4 are currently ignored.
2013-02-28 21:00:10 +00:00
Steve Holme 692ef0e158 imap: fix autobuild warning
Removed whitespace from imap_perform()
2013-02-28 10:23:50 +00:00
Steve Holme 17f032c0d9 imap: fix compiler warning
error: declaration of 'imap' shadows a previous local
2013-02-28 07:31:41 +00:00
Steve Holme 13006f3de9 imap: Re-factored final IMAP_AUTHENTICATE constant
Changed the final IMAP_AUTHENTICATE constant to IMAP_AUTHENTICATE_FINAL
for consistency with the response function.
2013-02-27 21:19:48 +00:00
Steve Holme 1d86d813c3 imap: Updated the coding style of imap_state_servergreet_resp()
Updated the coding style, in this function, to be consistant with other
response functions rather then performing a hard return on failure.
2013-02-27 21:00:35 +00:00
Steve Holme f53ed631b3 imap: Reversed the logic of the (un)successful tagged SELECT response
Reversed the logic of the unsuccessful vs successful tagged SELECT
response in imap_state_select_resp() to be more logical to read.
2013-02-27 20:53:34 +00:00
Steve Holme 5b3736b533 imap: Reversed the logic of the (un)successful tagged CAPABILITY response
Reversed the logic of the unsuccessful vs successful tagged CAPABILITY
response in imap_state_capability_resp() to be more logical to read.
2013-02-27 20:48:24 +00:00
Steve Holme cce08581ac imap: Corrected char* references with char *
Corrected char* references made in commit: 709b3506cd.
2013-02-27 20:35:04 +00:00
Jiri Hruska c368fbcb10 imap: Added processing of more than one response when sent in same packet
Added a loop to imap_statemach_act() in which Curl_pp_readresp() is
called until the cache is drained. Without this multiple responses
received in a single packet could result in a hang or delay.
2013-02-27 20:08:04 +00:00
Jiri Hruska b644c47192 imap: Added skipping of SELECT command if already in the same mailbox
Added storage and checking of the last mailbox userd to prevent
unnecessary switching.
2013-02-27 20:08:02 +00:00
Jiri Hruska d03aa16164 imap: Introduced the mailbox variable
Added the mailbox variable to the per-connection structure in
preparation for checking for an already selected mailbox.
2013-02-27 20:08:00 +00:00
Jiri Hruska a8eb059203 imap: Added verification of UIDVALIDITY mailbox attribute
Added support for checking the UIDVALIDITY, and aborting the request, if
it has been specified in the URL and the server response is different.
2013-02-26 22:09:21 +00:00
Jiri Hruska 59c71c7fc7 imap: Added support for parsing the UIDVALIDITY property
Added support for parsing the UIDVALIDITY property from the SELECT
response and storing it in the per-connection structure.
2013-02-26 22:09:19 +00:00
Jiri Hruska 58efa46a5d imap: Introduced the mailbox_uidvalidity variable
Added the mailbox_uidvalidity variable to the per-connection structure
in preparation for checking the UIDVALIDITY mailbox attribute.
2013-02-26 22:09:18 +00:00
Steve Holme acd22f05dd imap: Corrected comment in imap_endofresp() 2013-02-26 20:40:22 +00:00
Steve Holme ce9a0a6d65 imap: Corrected whitespace 2013-02-26 20:37:08 +00:00
Jiri Hruska f92f341a3f imap: Added filtering of CAPABILITY and FETCH untagged responses
Only responses that contain "CAPABILITY" and "FETCH", respectively,
will be sent to their response handler.
2013-02-26 20:35:41 +00:00
Jiri Hruska 91b2184e1b imap: Added a helper function for upcoming untagged response filtering
RFC 3501 states that "the client MUST be prepared to accept any response
at all times" yet we assume anything received with "* " at the beginning
is the untagged response we want.

Introduced a helper function that checks whether the input looks like a
response to specified command, so that we may filter the ones we are
interested in according to the current state.
2013-02-26 20:23:13 +00:00
Jiri Hruska 1ffdc5058e imap: Moved CAPABILITY response handling to imap_state_capability_resp()
Introduced similar handling to the FETCH responses, where even the
untagged data responses are handled by the response handler of the
individual state.
2013-02-26 19:51:16 +00:00
Steve Holme 764b818934 email: Small tidy up following recent changes 2013-02-25 23:00:08 +00:00
Jiri Hruska 005ad9e60d imap: Removed bytecountp from the per-request structure
Removed this pointer to a downloaded bytes counter because it was set in
imap_init() to point to the same variable the transfer functions keep
the count in (k->bytecount), effectively making the code in transfer.c
"*k->bytecountp = k->bytecount" a no-op.
2013-02-25 22:05:20 +00:00
Jiri Hruska a360944ed6 imap: Adjusted SELECT and FETCH function order
Moved imap_select() and imap_fetch() to be grouped with the other
perform functions.
2013-02-25 21:40:32 +00:00
Jiri Hruska 6f02209cc8 imap: Adjusted SELECT and FETCH state order in imap_statemach_act()
Exchanged the position of these states in the switch statements to
match the state enum, execution and function order.
2013-02-25 21:26:40 +00:00
Steve Holme 015ceb4706 imap: Minor tidy up of comments in imap_parse_url_path()
Tidy up of comments before next round of imap changes.
2013-02-25 15:53:24 +00:00
Steve Holme e63c33d88d imap: Fixed incorrect comparison for STARTTLS in imap_endofresp()
Corrected the comparison type in addition to commit 1dac29fa83.
2013-02-25 09:43:23 +00:00
Steve Holme d23d2f2bd8 imap: Added check for new internal imap response code 2013-02-24 19:23:33 +00:00
Steve Holme 37f0caeabd imap: Changed the order of the response types in imap_endofresp()
From a maintenance point of view the code reads better to view tagged
responses, then untagged followed by continuation responses.

Additionally, this matches the order of responses in POP3.
2013-02-24 16:14:16 +00:00
Jiri Hruska 671f896c0b imap: Added stricter parsing of continuation responses
Enhanced the parsing to only allow continuation responses in some
states.
2013-02-24 14:38:54 +00:00
Steve Holme 7f5824a106 imap: Simplified memcmp() in tagged response parsing 2013-02-24 12:45:04 +00:00
Jiri Hruska 797b004738 imap: Reworked the logic of untagged command responses 2013-02-24 12:39:09 +00:00
Steve Holme 1ff6a8338d imap: Corrected spacing of trailing brace 2013-02-24 12:05:15 +00:00
Jiri Hruska 66149248ba imap: Added stricter parsing of tagged command responses
Enhanced the parsing of tagged responses which must start with "OK",
"NO" or "BAD"
2013-02-24 12:02:59 +00:00
Jiri Hruska c38d69f06a imap: Simplified command response test in imap_endofresp() 2013-02-24 12:02:57 +00:00
Jiri Hruska 324b7fe47b imap: Corrected comment in imap_endofresp() 2013-02-24 12:02:55 +00:00
Jiri Hruska 5c5b7c7146 imap: Added the ability to FETCH a specific UID and SECTION
Updated the FETCH command to send the UID and SECTION parsed from the
URL. By default the BODY specifier doesn't include a section, BODY[] is
now sent whereas BODY[TEXT] was previously sent. In my opinion
retrieving just the message text is rarely useful when dealing with
emails, as the headers are required for example, so that functionality
is not retained. In can however be simulated by adding SECTION=TEXT to
the URL.

Also updated test801 and test1321 due to the BODY change.
2013-02-23 21:11:47 +00:00
Steve Holme 7f6c7331b2 email: Additional tidy up of comments following recent changes 2013-02-23 20:02:05 +00:00
Steve Holme 8960d81b0d imap: Minor correction of comments for max line length 2013-02-23 19:04:13 +00:00
Jiri Hruska e756641040 imap: Added URL parsing of new variables
Updated the imap_parse_url_path() function to parse uidvalidity, uid and
section parameters based on RFC-5092.
2013-02-23 18:40:47 +00:00
Jiri Hruska 2f638a8f5e imap: Introduced imap_is_bchar() function
Added imap_is_bchar() for testing if a given character is a valid bchar
or not.
2013-02-23 18:40:45 +00:00
Jiri Hruska b6f32464e9 imap: Introduced new per-request veriables
Added uidvalidity, uid and section variables to the per-request IMAP
structure in preparation for upcoming URL parsing.
2013-02-23 17:26:51 +00:00
Jiri Hruska 4cfc7f951c imap: Fixed escaping of mailbox names
Used imap_atom() to escape mailbox names in imap_select().
2013-02-23 15:42:33 +00:00
Steve Holme d415327bd7 email: Minor tidy up following IMAP changes 2013-02-23 11:34:52 +00:00
Jiri Hruska 35fb6bee0e imap: Removed more FTP leftovers
Changed some variables and comments still using FTP terminology.
2013-02-23 11:27:05 +00:00
Jiri Hruska 13625a0d09 imap: Removed some FTP heritage leftovers
Removed user and passwd from the IMAP struct as these cannot be set on
a per-request basis and are leftover from legacy FTP code.
2013-02-23 11:27:04 +00:00