This completes the heavy lifting of persisting messages locally. The strategy is that the local database may be sparsely populated, both in the availability of messages in a folder and the fields of a message that is partially stored. As data is pulled from the remote server it's always stored in the database. Future requests will always go to the database first, preventing unnecessary network traffic.
Also, this patch will detect when a message is stored in multiple folders on the server. The database uses soft links from the folder to the message, so the message is stored only once in the database. This technique relies heavily on the availability and validity of the Message-ID header, but we expect this to be reliable the vast majority of the time.
This iteration now stores headers locally and fetches them first before going to the network. Work done in the database to deal with IMAPisms. More work on the GMime bindings (couple of mistakes in prior commit).
InternetAddress and its children and brethren were not properly bound by vapigen, probably because they aren't prefixed with "GMime" (unlike everything else in the library). Still some problems here, notably that certain private data members are exposed, but I've been unable to coax vapigen into not displaying them. Will work for now.
Much of the API between the local and net stores had to be reworked for consistency as well as planning ahead for how messages will be retrieved and stored efficiently. This work also attempts to keep in mind that other mail sources (POP, etc.) may be required in the future, and hopefully can be added without major rework.
Engine now uses a master Folder object that synchronizes between the network and the local store. Also, the Geary.Folder interface was getting ugly to code when the implementation was more than trivial, so moved to standard getters for it.
This large diff represents a growth of the architecture to persist IMAP data as its downloaded. When listing folders, a local database is consulted first to immediately feed to the caller. In the background, network calls fetch the "real" list. The two are collated for differences which are reported to the caller via signals, who are then responsible for updating the user interface appropriately. No other synchronization work is represented in this diff.
Note that this breaks functionality: when a folder is selected, no messages appear in the message list. Fixing this requires more work, and this patch was already large enough. It's ticketed here: #3741
--save-temps only speeds up compilation when valac is invoked for compile-only and C compilation and linking are done separately and in parallel. Since --save-temps leaves a lot of extraneous files sitting around that clutter "git status" (see #3690), removing it from the Makefile.
Keepalive could cause a segfault if the server closed the connection. This fixes that as well as updates some of the exception-throwing code to use more appropriate ImapErrors.
Message contents are now fetched from the server and displayed in the third pane when a message is selected. Also made session management a bit smarter via ReferenceSemantics.
The result of a SELECT or EXAMINE command is now parsed and returned to the caller. This information is boiled down to the Geary.Folder interface, which adds information about the folder to the object.
The ClientSessionManager maintains a pool of connections to an IMAP server, reusing them whenever possible. It allows for multiple folders to be managed and monitored by an application without having to change contexts constantly (which also introduces side-effects, esp. with expunging deleted messages).
geary now has an (unsorted) list of folders in its sidebar. When one is clicked on the messages in that folder are displayed. This patch also fixes an issue in the Serializer that wasn't dealing with quoted strings properly.
This adds a VAPI (including generation files and Makefile) for GMime to the repo, which we'll be using extensively to come. This VAPI is incomplete in many ways, so care should be used going forward.
Also, with GMime now interpreting RFC822 dates, can now pretty-print them. Prettier From: names also added this time around.
Client code will display a window listing Date, Subject, and From of all messages in inbox. Username and password must be specified as a command argument. Note that current IMAP envelope parsing doesn't handle group lists, which means some messages will be skipped over.
ClientSession can now automatically send NOOP commands as keepalives at a specified interval. Also, the CommandResponse decoders have been moved into their own directory (they will soon be fertile and multiply). More work ahead on the FetchResults object, which should be like NoopResults and completely encapsulate all the information returned from a FETCH.
Implemented a first stab at buffer management for IMAP literals. Added FETCH decoding of various RFC822 elements. Implemented a crude readmail program which will dump the full RFC822 message of any message in a mailbox.
Library now uses an extensible system for decoding the various structured data that FETCH returns. This system may be expanded later for decoding other CommandResponses (although FETCH is the command most in need of this). Also created an RFC822 directory for data structures and code to deal with mail messages and a common directory for code that is used throughout the library but doesn't belong to util as they're "core" classes.
Fleshed out the ClientSession state machine to follow the session state graph described by the IMAP specification. ClientSession is now firmly a single-connection object that tracks the server state appropriately. A higher-level class will need to be defined that manages multiple sessions (for when dealing with multiple folders, monitoring, etc.)
The input mode for Deserializer meant that the caller needed to manage the input stream and push data in an appropriate way; this is error-prone. Now Deserializer manages the input stream and the modes it must be read from. Serializer still works in a similar fashion as before, but now it deals with literal data more efficiently, writing it to the output stream directly (via splice_async()) rather than into the in-memory temporary buffer. Serializable's serialize() method is now async, meaning that all serialization can occur asynchronously, which is how we want it going forward.