Jiri Hruska [Sun, 3 Mar 2013 10:33:53 +0000 (11:33 +0100)]
imap: Fixed custom request handling in imap_done()
Fixed imap_done() so that neither the FINAL states are not entered when
a custom command has been performed.
Jiri Hruska [Sun, 3 Mar 2013 10:27:18 +0000 (11:27 +0100)]
imap: Enabled custom requests in imap_select_resp()
Changed imap_select_resp() to invoke imap_custom() instead of
imap_fetch() after the mailbox has been selected if a custom
command has been set.
Jiri Hruska [Sun, 3 Mar 2013 10:21:29 +0000 (11:21 +0100)]
imap: Enabled custom requests in imap_perform()
Modified imap_perform() to start with the custom command instead of
SELECT when a custom command is to be performed and no mailbox has
been given.
Jiri Hruska [Sun, 3 Mar 2013 10:09:44 +0000 (11:09 +0100)]
imap: Added custom request perform and response handler functions
Added imap_custom(), which initiates the custom command processing,
and an associated response handler imap_state_custom_resp(), which
handles any responses by sending them to the client as body data.
All untagged responses with the same name as the first word of the
custom request string are accepted, with the exception of SELECT and
EXAMINE which have responses that cannot be easily identified. An
extra check has been provided for them so that any untagged responses
are accepted for them.
Steve Holme [Sun, 3 Mar 2013 11:10:24 +0000 (11:10 +0000)]
pop3: Fixed unnecessary parent structure reference
Updated pop3 code following recent imap changes.
Jiri Hruska [Sun, 3 Mar 2013 09:49:37 +0000 (10:49 +0100)]
imap: Added custom request parsing
Added imap_parse_custom_request() for parsing the CURLOPT_CUSTOMREQUEST
parameter which URL decodes the value and separates the request from
any parameters - This makes it easier to filter untagged responses
by the request command.
Jiri Hruska [Sun, 3 Mar 2013 09:12:27 +0000 (10:12 +0100)]
imap: Introduced custom request parameters
Added custom request parameters to the per-request structure.
Jiri Hruska [Sun, 3 Mar 2013 09:10:01 +0000 (10:10 +0100)]
imap: Introduced IMAP_CUSTOM state
Steve Holme [Sat, 2 Mar 2013 21:22:44 +0000 (21:22 +0000)]
imap: Minor code tidy up
Minor tidy up of code layout and comments following recent changes.
Steve Holme [Sat, 2 Mar 2013 20:40:38 +0000 (20:40 +0000)]
imap: Simplified the imap_state_append_resp() function
Introduced the result code variable to simplify the state changes and
remove the hard returns.
Steve Holme [Sat, 2 Mar 2013 20:35:03 +0000 (20:35 +0000)]
imap: Changed successful response logic in imap_state_append_resp()
For consistency changed the logic of the imap_state_append_resp()
function to test for an unsucessful continuation response rather than a
succesful one.
Steve Holme [Sat, 2 Mar 2013 20:29:27 +0000 (20:29 +0000)]
imap: Standardised imapcode condition tests
For consistency changed two if(constant != imapcode) tests to be
if(imapcode != constant).
Steve Holme [Sat, 2 Mar 2013 20:24:49 +0000 (20:24 +0000)]
imap: Moved imap_append() to be with the other perform functions
Jiri Hruska [Fri, 1 Mar 2013 19:49:14 +0000 (20:49 +0100)]
imap: Enabled APPEND support in imap_perform()
Added logic in imap_perform() to perform an APPEND rather than SELECT
and FETCH if an upload has been specified.
Jiri Hruska [Fri, 1 Mar 2013 19:34:51 +0000 (20:34 +0100)]
imap: Implemented APPEND final processing
The APPEND operation needs to be performed in several steps:
1) We send "<tag> APPEND <mailbox> <flags> {<size>}\r\n"
2) Server responds with continuation respose "+ ...\r\n"
3) We start the transfer and send <size> bytes of data
4) Only now we end the request command line by sending "\r\n"
5) Server responds with "<tag> OK ...\r\n"
This commit performs steps 4 and 5, in the DONE phase, as more
processing is required after the transfer.
Jiri Hruska [Fri, 1 Mar 2013 19:06:18 +0000 (20:06 +0100)]
imap: Added APPEND perform and response handler functions
Added imap_append() function to initiate upload and imap_append_resp()
to handle the continuation response and start the transfer.
Jiri Hruska [Fri, 1 Mar 2013 19:04:56 +0000 (20:04 +0100)]
imap: Introduced IMAP_APPEND and IMAP_APPEND_FINAL states
Jiri Hruska [Fri, 1 Mar 2013 18:38:27 +0000 (19:38 +0100)]
imap: Updated setting of transfer variables in imap_state_fetch_resp()
Add number of bytes retrieved from the PP cache to req.bytecount and set
req.maxdownload only when starting a proper download.
Jiri Hruska [Fri, 1 Mar 2013 18:24:56 +0000 (19:24 +0100)]
imap: Improved FETCH response parsing
Added safer parsing of the untagged FETCH response line and the size of
continuation data.
Steve Holme [Thu, 28 Feb 2013 23:09:28 +0000 (23:09 +0000)]
imap: Fixed accidentally lossing the result code
Accidentally lost the result code in imap_state_capability() and
imap_state_login() with commit
b06a78622609.
Steve Holme [Thu, 28 Feb 2013 22:51:32 +0000 (22:51 +0000)]
imap: Another minor comment addition / tidy up
Steve Holme [Thu, 28 Feb 2013 22:46:22 +0000 (22:46 +0000)]
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.
Steve Holme [Thu, 28 Feb 2013 22:26:46 +0000 (22:26 +0000)]
pop3 / smtp: Small comment tidy up
Small tidy up to keep some comments consistant across each of the email
protocols.
Jiri Hruska [Thu, 28 Feb 2013 20:32:10 +0000 (21:32 +0100)]
imap: FETCH response handler cleanup before further changes
Removed superfluous NULL assignment after Curl_safefree() and rewrote
some comments and logging messages.
Steve Holme [Thu, 28 Feb 2013 21:22:49 +0000 (21:22 +0000)]
pop3: Small tidy up of function arguments
Steve Holme [Thu, 28 Feb 2013 21:18:36 +0000 (21:18 +0000)]
imap: Small tidy up of function arguments
Steve Holme [Thu, 28 Feb 2013 21:11:02 +0000 (21:11 +0000)]
smtp: Corrected debug message for POP3_AUTH_FINAL constant
Following commit
ad3177da24b8 corrected the debug message in state()
from AUTH to AUTH_FINAL.
Steve Holme [Thu, 28 Feb 2013 21:10:11 +0000 (21:10 +0000)]
pop3: Corrected debug message for POP3_AUTH_FINAL constant
Following commit
afad1ce753a1 corrected the debug message in state()
from AUTH to AUTH_FINAL.
Steve Holme [Thu, 28 Feb 2013 21:09:27 +0000 (21:09 +0000)]
imap: Corrected debug message for IMAP_AUTHENTICATE_FINAL constant
Following commit
13006f3de9ec corrected the debug message in state()
from AUTHENTICATE to AUTHENTICATE_FINAL.
Jiri Hruska [Thu, 28 Feb 2013 18:56:52 +0000 (19:56 +0100)]
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.
Jiri Hruska [Thu, 28 Feb 2013 18:42:42 +0000 (19:42 +0100)]
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.
Jiri Hruska [Thu, 28 Feb 2013 18:16:33 +0000 (19:16 +0100)]
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.
Steve Holme [Thu, 28 Feb 2013 10:23:50 +0000 (10:23 +0000)]
imap: fix autobuild warning
Removed whitespace from imap_perform()
Steve Holme [Thu, 28 Feb 2013 07:31:41 +0000 (07:31 +0000)]
imap: fix compiler warning
error: declaration of 'imap' shadows a previous local
Steve Holme [Wed, 27 Feb 2013 21:20:55 +0000 (21:20 +0000)]
smtp: Re-factored the final SMTP_AUTH constant
Changed the final SMTP_AUTH constant to SMTP_AUTH_FINAL for consistency
with the response function.
Steve Holme [Wed, 27 Feb 2013 21:20:11 +0000 (21:20 +0000)]
pop3: Re-factored the final POP3_AUTH constant
Changed the final POP3_AUTH constant to POP3_AUTH_FINAL for consistency
with the response function.
Steve Holme [Wed, 27 Feb 2013 21:19:48 +0000 (21:19 +0000)]
imap: Re-factored final IMAP_AUTHENTICATE constant
Changed the final IMAP_AUTHENTICATE constant to IMAP_AUTHENTICATE_FINAL
for consistency with the response function.
Steve Holme [Wed, 27 Feb 2013 21:00:35 +0000 (21:00 +0000)]
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.
Steve Holme [Wed, 27 Feb 2013 20:53:34 +0000 (20:53 +0000)]
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.
Steve Holme [Wed, 27 Feb 2013 20:48:24 +0000 (20:48 +0000)]
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.
Steve Holme [Wed, 27 Feb 2013 20:35:04 +0000 (20:35 +0000)]
imap: Corrected char* references with char *
Corrected char* references made in commit:
709b3506cd9b.
Jiri Hruska [Wed, 27 Feb 2013 18:49:00 +0000 (19:49 +0100)]
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.
Jiri Hruska [Wed, 27 Feb 2013 18:02:53 +0000 (19:02 +0100)]
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.
Jiri Hruska [Wed, 27 Feb 2013 17:31:08 +0000 (18:31 +0100)]
imap: Introduced the mailbox variable
Added the mailbox variable to the per-connection structure in
preparation for checking for an already selected mailbox.
Steve Holme [Tue, 26 Feb 2013 23:15:16 +0000 (23:15 +0000)]
email: Slight reordering of connection based variables
Reordered the state and ssl_done variables in order to provide more
consistency between the email protocols as well as for for an upcoming
change.
Steve Holme [Tue, 26 Feb 2013 23:07:37 +0000 (23:07 +0000)]
imap: Tidied up comments for connection based variables
Steve Holme [Tue, 26 Feb 2013 22:22:26 +0000 (22:22 +0000)]
DOCS: Added the IMAP UIDVALIDITY property to the CURLOPT_URL section
Jiri Hruska [Tue, 26 Feb 2013 21:12:24 +0000 (22:12 +0100)]
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.
Jiri Hruska [Tue, 26 Feb 2013 20:56:14 +0000 (21:56 +0100)]
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.
Jiri Hruska [Tue, 26 Feb 2013 20:42:01 +0000 (21:42 +0100)]
imap: Introduced the mailbox_uidvalidity variable
Added the mailbox_uidvalidity variable to the per-connection structure
in preparation for checking the UIDVALIDITY mailbox attribute.
Steve Holme [Tue, 26 Feb 2013 20:40:22 +0000 (20:40 +0000)]
imap: Corrected comment in imap_endofresp()
Steve Holme [Tue, 26 Feb 2013 20:37:08 +0000 (20:37 +0000)]
imap: Corrected whitespace
Jiri Hruska [Tue, 26 Feb 2013 18:22:42 +0000 (19:22 +0100)]
imap: Added filtering of CAPABILITY and FETCH untagged responses
Only responses that contain "CAPABILITY" and "FETCH", respectively,
will be sent to their response handler.
Jiri Hruska [Tue, 26 Feb 2013 17:52:19 +0000 (18:52 +0100)]
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.
Jiri Hruska [Tue, 26 Feb 2013 17:10:54 +0000 (18:10 +0100)]
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.
Linus Nielsen Feltzing [Tue, 26 Feb 2013 08:05:25 +0000 (09:05 +0100)]
Remove unused variable in smtp_state_data_resp()
Steve Holme [Mon, 25 Feb 2013 23:00:08 +0000 (23:00 +0000)]
email: Small tidy up following recent changes
Steve Holme [Mon, 25 Feb 2013 22:28:14 +0000 (22:28 +0000)]
smtp: Removed bytecountp from the per-request structure
Removed this pointer to a downloaded bytes counter because it was set in
smtp_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.
Steve Holme [Mon, 25 Feb 2013 21:46:37 +0000 (21:46 +0000)]
pop3: Removed bytecountp from the per-request structure
Removed this pointer to a downloaded bytes counter because it was set in
pop3_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.
Jiri Hruska [Mon, 25 Feb 2013 17:40:32 +0000 (18:40 +0100)]
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.
Jiri Hruska [Mon, 25 Feb 2013 17:06:02 +0000 (18:06 +0100)]
imap: Adjusted SELECT and FETCH function order
Moved imap_select() and imap_fetch() to be grouped with the other
perform functions.
Jiri Hruska [Mon, 25 Feb 2013 16:59:05 +0000 (17:59 +0100)]
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.
Steve Holme [Mon, 25 Feb 2013 15:53:24 +0000 (15:53 +0000)]
imap: Minor tidy up of comments in imap_parse_url_path()
Tidy up of comments before next round of imap changes.
Steve Holme [Mon, 25 Feb 2013 09:43:23 +0000 (09:43 +0000)]
imap: Fixed incorrect comparison for STARTTLS in imap_endofresp()
Corrected the comparison type in addition to commit
1dac29fa83a9.
Steve Holme [Mon, 25 Feb 2013 09:36:52 +0000 (09:36 +0000)]
DOCS: Corrected IMAP URL examples according to RFC5092
URL examples that included the UID weren't technically correct although
would pass the curl parser.
Nick Zitzmann [Sun, 24 Feb 2013 22:39:15 +0000 (15:39 -0700)]
darwinssl: fix undefined $ssllib warning in runtests.pl
I also added --with-darwinssl to the list of SSL options in configure.
Steve Holme [Sun, 24 Feb 2013 19:23:33 +0000 (19:23 +0000)]
imap: Added check for new internal imap response code
Steve Holme [Sun, 24 Feb 2013 16:14:16 +0000 (16:14 +0000)]
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.
Jiri Hruska [Sun, 24 Feb 2013 13:54:25 +0000 (14:54 +0100)]
imap: Added stricter parsing of continuation responses
Enhanced the parsing to only allow continuation responses in some
states.
Steve Holme [Sun, 24 Feb 2013 12:45:04 +0000 (12:45 +0000)]
imap: Simplified memcmp() in tagged response parsing
Jiri Hruska [Sun, 24 Feb 2013 12:27:49 +0000 (13:27 +0100)]
imap: Reworked the logic of untagged command responses
Steve Holme [Sun, 24 Feb 2013 12:05:15 +0000 (12:05 +0000)]
imap: Corrected spacing of trailing brace
Jiri Hruska [Sun, 24 Feb 2013 11:48:43 +0000 (12:48 +0100)]
imap: Added stricter parsing of tagged command responses
Enhanced the parsing of tagged responses which must start with "OK",
"NO" or "BAD"
Jiri Hruska [Sun, 24 Feb 2013 11:23:06 +0000 (12:23 +0100)]
imap: Simplified command response test in imap_endofresp()
Jiri Hruska [Sun, 24 Feb 2013 11:21:53 +0000 (12:21 +0100)]
imap: Corrected comment in imap_endofresp()
Steve Holme [Sun, 24 Feb 2013 00:47:38 +0000 (00:47 +0000)]
DOCS: Corrected layout of POP3 and IMAP URL examples
Corrected layout issues with the POP3 and IMAP URL examples introduced
in commit
cb3ae6894fb2.
Steve Holme [Sat, 23 Feb 2013 23:14:12 +0000 (23:14 +0000)]
DOCS: Updated CURLOPT_URL section following recent POP3 and IMAP changes
Updated the POP3 sub-section to refer to message ID rather than mailbox.
Added an IMAP sub-section with example URLs depicting the specification
of mailbox, uid and section.
Steve Holme [Sat, 23 Feb 2013 21:43:59 +0000 (21:43 +0000)]
pop3: Refactored the mailbox variable as it didn't reflect it's purpose
Updated the mailbox variable to correctly reflect it's purpose. The
name mailbox was a leftover from when IMAP and POP3 support was
initially added to curl.
Steve Holme [Sat, 23 Feb 2013 21:15:06 +0000 (21:15 +0000)]
FEATURES: Updated following recent IMAP changes
Jiri Hruska [Sat, 23 Feb 2013 21:05:19 +0000 (22:05 +0100)]
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.
Steve Holme [Sat, 23 Feb 2013 20:02:05 +0000 (20:02 +0000)]
email: Additional tidy up of comments following recent changes
Steve Holme [Sat, 23 Feb 2013 19:46:21 +0000 (19:46 +0000)]
smtp: Removed some FTP heritage leftovers
Removed user and passwd from the SMTP struct as these cannot be set on
a per-request basis and are leftover from legacy FTP code.
Changed some comments still using FTP terminology.
Steve Holme [Sat, 23 Feb 2013 19:39:22 +0000 (19:39 +0000)]
smtp: Moved the per-request variables to the per-request data structure
Moved the rcpt variable from the per-connection struct smtp_conn to the
new per-request struct and fixed references accordingly.
Steve Holme [Sat, 23 Feb 2013 19:31:59 +0000 (19:31 +0000)]
pop3: Introduced a custom SMTP structure for per-request data
Created a new SMTP structure and changed the type of the smtp proto
variable in connectdata from FTP* to SMTP*.
Steve Holme [Sat, 23 Feb 2013 18:57:18 +0000 (18:57 +0000)]
imap: Minor correction of comments for max line length
Daniel Stenberg [Sat, 23 Feb 2013 18:51:05 +0000 (19:51 +0100)]
strcasestr: remove check for this unused function
Daniel Stenberg [Sat, 23 Feb 2013 18:44:00 +0000 (19:44 +0100)]
pop3: fix compiler warning
error: declaration of 'pop3' shadows a previous local
Jiri Hruska [Sat, 23 Feb 2013 18:35:48 +0000 (19:35 +0100)]
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.
Jiri Hruska [Sat, 23 Feb 2013 18:07:41 +0000 (19:07 +0100)]
imap: Introduced imap_is_bchar() function
Added imap_is_bchar() for testing if a given character is a valid bchar
or not.
Jiri Hruska [Sat, 23 Feb 2013 17:24:53 +0000 (18:24 +0100)]
imap: Introduced new per-request veriables
Added uidvalidity, uid and section variables to the per-request IMAP
structure in preparation for upcoming URL parsing.
Steve Holme [Sat, 23 Feb 2013 17:09:24 +0000 (17:09 +0000)]
pingpong: Renamed curl_ftptransfer to curl_pp_transfer
Steve Holme [Sat, 23 Feb 2013 16:27:17 +0000 (16:27 +0000)]
pop3: Removed some FTP heritage leftovers
Removed user and passwd from the POP3 struct as these cannot be set on
a per-request basis and are leftover from legacy FTP code.
Changed some comments still using FTP terminology.
Steve Holme [Sat, 23 Feb 2013 16:15:38 +0000 (16:15 +0000)]
pop3: Moved the per-request variables to the per-request data structure
Moved the mailbox and custom request variables from the per-connection
struct pop3_conn to the new per-request struct and fixed references
accordingly.
Steve Holme [Sat, 23 Feb 2013 16:06:54 +0000 (16:06 +0000)]
pop3: Introduced a custom POP3 structure for per-request data
Created a new POP3 structure and changed the type of the pop3 proto
variable in connectdata from FTP* to POP*.
Jiri Hruska [Tue, 12 Feb 2013 13:47:37 +0000 (14:47 +0100)]
imap: Fixed escaping of mailbox names
Used imap_atom() to escape mailbox names in imap_select().
Steve Holme [Sat, 23 Feb 2013 15:26:26 +0000 (15:26 +0000)]
pingpong: Moved curl_ftptransfer definition to pingpong.h
Moved the ftp transfer structure into pingpong.h so other protocols that
require it don't have to include ftp.h.
Steve Holme [Sat, 23 Feb 2013 12:31:12 +0000 (12:31 +0000)]
urldata.h: Fixed comment for opt_no_body variable
Corrected comment for opt_no_body variable to CURLOPT_NOBODY.
Steve Holme [Sat, 23 Feb 2013 11:34:52 +0000 (11:34 +0000)]
email: Minor tidy up following IMAP changes
Jiri Hruska [Sat, 23 Feb 2013 09:48:52 +0000 (10:48 +0100)]
imap: Removed more FTP leftovers
Changed some variables and comments still using FTP terminology.
Jiri Hruska [Sat, 23 Feb 2013 09:41:47 +0000 (10:41 +0100)]
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.