The parser would think the flag was a response code if the flag started
with a '[' character. Flags like these are sometimes returned by Gmail
which broke fetching emails from Gmail.
This commit checks if the parser is already parsing flags and if so
treats any starting '[' characters as part of the flag string.
Convert `get_protocol_state` to an automatic property, so that rather
than requiring explcit signals for lifecycle events, a GObject notify
signal can be used instead.
Convert disconnect signal to a property so it can be accessed if needed.
Convert code listening to the disconnect signal to listen to notify
signals for `protocol_state` instead, and hence also treat the session
as disconnected when a logout is in progress.
Fixes#986
Since both submitting a command no longer requires a cancellable, and it
is desirable to avoid sending a queued command that has already been
cancelled beforehand, add a new `Command.should_send` Cancellable
property to specify if a command should (still) be sent or not, and stop
passing a cancellable to ClientSession when submitting commands.
Allow call sites to pass in existing cancellable objects, and thus also
add it it as a ctor property to the Command class and all subclasses.
Lastly, throw a cancelled exception in `wait_until_complete` if send
was cancelled so that the caller knows what happened.
Remove redundant cancellable argument from
`Imap.Client.command_transaction_async` and rename it to
`submit_command` to make it more obvious about what it does.
Some servers (e.g. Dovecot) use placeholder strings instead of the empty
string (e.g. "MISSING_DOMAIN") in FETCH Envelope responses when a
required address part (e.g. local part, domain) are empty.
This adds a quirk that can be enabled for such servers to check for the
placeholders and if found, replace them with empty strings.
Add a quirks object as a property so code that parses the response has
access to it. Simplify constructing server responses slightly and pass
the IMAP connection's quirks when doing so.
GMail doesn't seem to quote IMAP email flags when they contain spaces
or `]`, a reserved character under RFC 3501. We can't do anything
about the former, but we can work around the latter.
This patch adds a quirk allowing `]` in IMAP flags in general for
GMail accounts, and adds some additional unit tests to that end.
The `SpecialFolderType` was somewhat mis-named, since the special use
does not (in most cases) confer any special type, rather it's simply
defines what a particular folder is used /for/.
As such, rename the enum to to `Geary.Folder.SpecialUse`, moving it in
to the `Folder` class, since it relates specifically to folders, also
rename `Folder::special_folder_type` and
`Folder::special_folder_type_changed` reflect the above and not
duplicate the type name, and similarly rename
`Account::folders_special_type`.
Update the many call sites.
Convert mailbox and mailbox RW/RO state accessors to properties and
rename to be more explicit about what they mean. Remove mailbox arg
from ::getProtocolState() since it's unused.
Add namespace accessors, handle updating namespaces when processing
the received data, not when executing the command so that unsolicited
namespaces are still recognised. Clear namespaces when new data is
receieved and when not in selected and auth states. Add unit tests.
Move Capabilities to the api directory and make immutable.
Don't pass around out params to simply increment the revision and use a
field in ClientSession, just use the last capability instance. Ensure
after starting a TLS session capabilities are cleared. Add unit tests
for getting both implicit and explicity capaibilities when initiating
a client session.
Allow specifying the connect greeting timeout length, ensure that
any connect errors are in place before releasing the connect waiter,
add unit test to ensure it works properly.
Remove connect, disconnect and close_error signals, since they are
implied by their respective methods completing and/or throwing an
error. Remove Deserializer pass-through signals, treat all three kinds
as generic receive errors instead.
Make Deserializer emit end-of-stream signal only on EOS, not on EOS and
on receive error, so it only signals an error condition once.
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.
To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
Instead, make the args property a parameter list, and add params to that.
This means Command's serialize method have a different signature compared
to Parameter's, letting us do some more interesting things with it.
The ListParameter.parent property only existed to make the deserialier's
life easier, but is also why sketchy code was needed for appending search
criteria from a ServerSearchEmail replay op to the actual IMAP search
command sent to the server.
This removes the property altogether, and replaces its only use in
Deserialier with a stack, as nature intended. This means lists can be
added to more than one other list, and e.g. when a search is executed,
the search critera can be used for multiple requests.
Since MailboxParameter inherited from StringParameter directly, it meant
that we could never send mailbox names as quoted strings. Also, the
modified-UTF-7 encoding used for mailbox names does not encode
atom-specials such as "\", so if a mailbox name contained one or more of
these, it would be sent to the mail server unquoted.
This removes the MailboxParameter class altogether, and does the
parameter conversion to/from appropriate StringParameter subclasses as
needed. Also adds unit tests for param conversion for ASCII,
atom-specials, and non-ASCII mailbox names.
Fixes issue #40
* test/api/*.vala: Renamed files that contained mock objects to *-mock.vala,
not *-test.vala.
* test/testcase.vala: Renamed to test-case.vala for consistency, remove
TestCase class from Gee package since that's really not true. Clean up
code for consistency.
* test/meson.build, test/CMakeLists.txt: Split TestCase compilation out
into a separate test lib.
Add unit tests.
* src/engine/imap/transport/imap-deserializer.vala (Deserialiser): Add a
new EOL even handler to the FAILED state that is the one place where
the deserialize_failure() signal is fired and that any existing params
are reset.
(Deserialiser::push_line): Remove signal calls and unused return
value. Don't use EOS to detect NUL to avoid some confusion. Ensure an
EOL event is always fired so that the FAILED EOF handler is always run.
(Deserialiser::push_data): Remove signal calls and unused return value.
(Deserialiser::flush_params): Don't bother returning a state, since we
now always know what the next one should be when calling it. Only
trigger the parameters_ready() signal if there is a valid
parameter. Make logging consistent with the rest of the class.
(Deserialiser::reset_params): New common method for resetting any
existing deserialised message.
(Deserialiser::on_literal_char): Minor tidy up.
(Deserialiser::on_eos): Ensure that any existing param is sent on EOS
so that any BYE+EOS sent by the server is picked up.
Fixes Bug 781488.
* src/engine/imap/transport/imap-deserializer.vala (Deserializer): Update
char handling in START_PARAM state to be more explict and to handle all
possible chars, not just a subset. Then, simply defer to START_PARAM to
determine what to do when an invalid atom char is encountered when in
the ATOM state. Rename SYSTEM_FLAG state to just FLAG since it also
handles extension flags, and only use it for handling the first char in
the flag so "\*" can be treated appropriately, then defer to the ATOM
state, so flag keywords are treated in the same way as regular
atoms. Add unit tests.