Warning, /pim/trojita/docs/thesis/thesis.tex is written in an unsupported language. File is not indexed.
0001 % vim: spelllang=en spell 0002 0003 0004 \documentclass[12pt,notitlepage]{report} 0005 %\pagestyle{headings} 0006 \pagestyle{plain} 0007 0008 %\frenchspacing 0009 0010 \usepackage[utf8]{inputenc} 0011 %\usepackage{czech} 0012 \usepackage{a4wide} 0013 %\usepackage{index} % nutno použít v případě tvorby rejstříku balíčkem makeindex 0014 %\usepackage{fancybox} % umožňuje pokročilé rámečkování :-) 0015 \usepackage{graphicx} % nezbytné pro standardní vkládání obrázků do dokumentu 0016 0017 \usepackage[left=4cm]{geometry} 0018 \usepackage{xspace} 0019 0020 %\newindex{default}{idx}{ind}{Rejstřík} % zavádí rejstřík v případě použití balíku index 0021 0022 \title{Trojita: A Qt IMAP Client} 0023 \author{Jan Kundrát} 0024 0025 \newcommand{\trojita}{Trojita\xspace} 0026 0027 \hyphenation{WebKit Imap Trojita} 0028 0029 %\date{} 0030 0031 \begin{document} 0032 0033 0034 \begin{titlepage} 0035 \begin{center} 0036 %\ \\ 0037 0038 \vspace{15mm} 0039 0040 \large 0041 Charles University in Prague\\ 0042 Faculty of Mathematics and Physics\\ 0043 0044 \vspace{5mm} 0045 0046 {\Large\bf BACHELOR THESIS} 0047 0048 \vspace{10mm} 0049 0050 \includegraphics[scale=0.3]{logo.eps} 0051 0052 \vspace{25mm} 0053 0054 %\normalsize 0055 {\Large Jan Kundrát}\\ 0056 \vspace{5mm} 0057 {\Large\bf IMAP E-mail Client}\\ 0058 \vspace{5mm} 0059 Department of Software Engineering\\ 0060 %\end{center} 0061 \vspace{15mm} 0062 0063 \large 0064 \noindent Supervisor: Mgr. Vlastimil Babka 0065 \vspace{1mm} 0066 0067 \noindent Study Program: Computer Science, Programming 0068 0069 \vspace{20mm} 0070 0071 %\begin{center} 0072 2009 0073 \end{center} 0074 0075 \end{titlepage} 0076 0077 \normalsize 0078 \setcounter{page}{2} 0079 \ \vspace{10mm} 0080 0081 \noindent I'd like to thank my supervisor, Mgr. Vlastimil Babka, for his 0082 numerous advices during the writing of this thesis, Ms. Anna Adamcová for her 0083 great patience and support, and my parents for supporting my studies. 0084 0085 \vspace{\fill} 0086 \noindent I hereby declare that I wrote this thesis myself using the referenced 0087 sources only. I also agree with lending and publishing of this thesis. 0088 0089 \vspace{5mm} 0090 \bigskip 0091 \noindent Prague, May 29, 2009 \hspace{\fill}Jan Kundrát\\ 0092 0093 \tableofcontents 0094 0095 \newpage 0096 0097 \noindent 0098 Název práce: IMAP E-mail Client\\ 0099 Autor: Jan Kundrát\\ 0100 Katedra (ústav): Katedra softwarového inženýrství\\ 0101 Vedoucí bakalářské práce: Mgr. Vlastimil Babka\\ 0102 E-mail vedoucího: Vlastimil.Babka@mff.cuni.cz\\ 0103 0104 \noindent Abstrakt: Předložená práce popisuje implementaci pokročilého klienta 0105 pro práci s~poštou pomocí protokolu IMAP. Hlavním zaměřením je podpora 0106 relevantních standardů s~důrazem na efektivní implementaci; využívá se 0107 pokročilých vlastností IMAPu, jako například IDLE notifikací, parsování zpráv na 0108 straně serveru či lokálního ukládání e-mailů s možností práce offline. Spojení 0109 s~IMAP serverem je realizováno protokolem TCP s~volitelnou možností TLS 0110 šifrování či přes lokálně bežící proces. Projekt umožňuje psaní a odesílání 0111 jednoduchých mailů, podporováno je odesílání pomocí protokolu SMTP a sendmailem. 0112 Cílová platforma je framework Qt na Linuxu, avšak aplikace je portovatelná i na 0113 jiné platformy.\\ 0114 0115 \noindent Klíčová slova: IMAP, e-mail, MIME, Qt, SMTP 0116 0117 \vspace{10mm} 0118 0119 \noindent 0120 Title: IMAP E-mail Client\\ 0121 Author: Jan Kundrát\\ 0122 Department: Department of Software Engineering\\ 0123 Supervisor: Mgr. Vlastimil Babka\\ 0124 Supervisor's e-mail address: Vlastimil.Babka@mff.cuni.cz\\ 0125 0126 \noindent Abstract: This thesis describes the implementation of an advanced IMAP 0127 e-mail client, \trojita. Focusing on standards compliance, the client supports 0128 a wide range of IMAP features crucial for an efficient implementation such as IDLE 0129 notifications, server-side message parsing and caching of retrieved body data 0130 for offline operation. Connecting to the IMAP server is supported over TCP 0131 sockets, optionally secured via the TLS encryption, as well as through a local 0132 process. Basic message composition and sending via both SMTP and a local 0133 sendmail instance is supported. The target platform is the Qt framework on 0134 Linux, but the application is reasonably portable. 0135 \\ 0136 0137 \noindent Keywords: IMAP, e-mail, MIME, Qt, SMTP 0138 0139 \newpage 0140 0141 \chapter{Introduction} 0142 0143 Although being surpassed in popularity by other technologies like the World Wide 0144 Web and peer-to-peer applications, the electronic mail is still one of the few 0145 services that an average user can name when talking about the Internet. There are 0146 many ways how to send and receive e-mail, some of them being more popular 0147 than the others. In this thesis, we try to resurrect the older approach to 0148 reading e-mail, that is, using an standalone application. 0149 0150 In the recent years, the improvements in the field of web browsers and related 0151 technologies allowed rapid development of new features that were not conceivable 0152 just five years ago. Using these new functions, the popularity of web-based 0153 e-mail readers grew accordingly. However, using a proper standalone application 0154 has numerous benefits from being able to work when not connected to the Internet 0155 to providing a truly instant feedback, a feature that is still somewhat missing 0156 from most of the web applications. Managing e-mail over a standardized protocol 0157 also avoids vendor lock-in, a highly dangerous phenomenon associated with 0158 using proprietary messaging solutions. To date, the {\em Internet Message 0159 Access Protocol}~\cite{rfc-imap} (or IMAP) is the only such protocol. 0160 0161 \section{Motivation} 0162 0163 Implementing an IMAP client is far from trivial. While there are certainly 0164 numerous stable and widely-used Mail User Agents on the market, none of them 0165 fulfills all the expectations of reasonable performance and efficiency. Indeed, 0166 most of these applications started as MUAs speaking the POP3 protocol only, 0167 adding support for IMAP later on. Typically, this support was implemented long 0168 since the initial design phase of the product was completed, resulting in 0169 suboptimal design choices~\cite{crispin-ten-commandments}. Therefore, we 0170 believe there is still a place on the market for a stable, highly performing 0171 IMAP e-mail application. 0172 0173 \section{Structure of the thesis} 0174 0175 In the following chapter, we provide a gentle introduction to the world of IMAP 0176 and related standards such as MIME. Chapter \ref{trojita-design} explains some 0177 of the design choices made during the development process of \trojita, as well as 0178 elaborates on the internal application architecture and structure. An overview 0179 of other IMAP implementations on the market is provided in 0180 chapter \ref{other-imap-implementations}, including a comparison about how well 0181 they operate when compared to \trojita. The User's Guide is 0182 available in chapter \ref{users-guide}. Finally, the whole thesis is concluded by a 0183 wrap-up providing an overview of what we implemented and how the result is 0184 usable. 0185 0186 \chapter{IMAP and Related Technologies} 0187 0188 Electronic mail, or a SMTP-mail, is a public service suitable for automated 0189 message exchange among connected entities. Interoperability is guaranteed by 0190 several {\em Internet standards}, usually codified in the form of RFC documents. 0191 Subject to these standards are various protocols specifying the rules of what 0192 entities can communicate to each other as well as definition of the format of 0193 all transmitted messages. In this section, we provide a gentle introduction to 0194 the numerous standards which deal with this highly complex topic. 0195 0196 \section{Basic Concepts} 0197 0198 An {\em email message}, or a RFC-822\footnote{As defined by the RFC~822 standard 0199 and subsequently modified by RFC~2822~\cite{rfc-2822} and others} message, 0200 consists of three parts: {\em Envelope}, {\em Header} and {\em Body}. The {\em 0201 envelope} is the only relevant part for mail exchange among Internet 0202 hosts; it includes basic information like addresses of the sender and recipient. 0203 A {\em header} provides more detailed metadata about the message, from 0204 human-readable sender addresses and message route traces to user-defined 0205 fields. Some pieces of this information are used when the original delivery 0206 fails for some reason, like the {\tt Return-Path} header. The {\em header} also 0207 serves as a basis for an {\em IMAP envelope data} which is explained later 0208 in chapter \ref{imap-envelope}. Finally, a {\em message body} is what an 0209 average user typically refers to as ``the e-mail''. It might contain just a 0210 plain US-ASCII text, an HTML message with embedded images or it could be a 0211 recursively defined entity with rich tree structure. 0212 0213 An {\em IMAP server} is a host in the Internet which provides access to local 0214 mail store via the standard protocol, IMAP4rev1 in this case. The IMAP server 0215 might be located in an employer's data center or on the user's laptop, for 0216 example. 0217 0218 An {\em MTA}\footnote{Mail Transfer Agent} or an {\em SMTP Server} is an 0219 Internet host whose purpose is delivery of the RFC 2822 mail. MTAs in the 0220 Internet communicate with each other, determining routing information from 0221 MX-records\footnote{Mail eXchange, a special record in the Domain Name Service 0222 which specifies what servers are responsible for accepting all incoming e-mail 0223 for the particular domain} in the DNS. As a common practice nowadays, these 0224 servers also accept outgoing e-mail from their own users, provided the 0225 connection is properly authenticated, either by simple fact that it originates 0226 from a trusted network or that the user has provided her credentials, typically as 0227 a user name and password combination or in the form of an X.509 certificate. 0228 0229 A {\em Mailbox} or a {\em Mail Folder} is a place on the IMAP server where the 0230 messages are logically stored. A mailbox might contain number of child 0231 mailboxes if the server implementation allows it. Certain IMAP servers have to 0232 be told in advance whether the mailbox just being created is supposed to contain 0233 only other mailboxes or only regular e-mail messages, while others allow free 0234 mixing of both. 0235 0236 \section{IMAP-specific Attributes} 0237 0238 A message in the IMAP sense is {\em immutable}, that is, its contents (e.g., 0239 header, structure of the body or the actual message parts) cannot change, ever. 0240 Each message also has mutable attributes, the most important being {\em flags}. 0241 0242 Messages in a remote IMAP mailbox are identified by two partially independent 0243 numbers, the {\em sequence number} and the {\em UID}. Sequence numbers start at 0244 one and are consecutive, that is, they dynamically change when a message in the 0245 middle of the mailbox is removed. This means that one particular message can 0246 have multiple sequence numbers assigned over time and that one sequence number 0247 can refer to totally unrelated messages, as the numbering changes. 0248 0249 On the other hand, the {\em UIDs} work differently. When a message is delivered 0250 to the mailbox, it receives a UID one greater than the previous one. After the 0251 UID is assigned, it will never change for that particular message, and the 0252 mailbox remembers the biggest assigned UID so far. This means that UIDs are 0253 never recycled over the normal life span of a mailbox and they can be used as a 0254 persistent identifier to one message in a particular mailbox. 0255 0256 Sometimes a non-standard situation might happen, e.g., when a third-party 0257 accessed the mailbox data behind the back of the IMAP server. Perhaps the user 0258 tried a utility program that removes huge attachment from an otherwise valuable 0259 message, or a spam classifier modified message headers directly, bypassing 0260 standard mechanisms for proper flagging. In any such case, the IMAP guarantee 0261 of immutable nature of the messages does not hold, and a compliant IMAP server 0262 has to communicate this problem to all clients. The {\em UIDVALIDITY} mailbox 0263 attribute serves this purpose. Whenever the UIDVALIDITY changes, a compliant 0264 client is required to throw away any cached information about a mailbox because 0265 the UID assignment starts over again. 0266 0267 UID and UIDVALIDITY combined together form a 64bit integer which is absolutely 0268 guaranteed to be a unique identifier for any message in the given mailbox -- if 0269 the IMAP client once retrieved any immutable part from mailbox A with this 64bit 0270 identifier, subsequent queries for the part identified by the same 64bit number 0271 in the same mailbox can be satisfied from the client's cache. 0272 0273 It should be noted that this UID/UIDNEXT numbering is strictly per-mailbox and 0274 not per-server, and that different users accessing the same server might see the 0275 same 64bit number for totally unrelated messages. While RFC~3501~\cite{rfc-imap} 0276 strongly recommends that UIDVALIDITY should be kept constant if at all possible, 0277 a compliant IMAP client has to deal with UIDVALIDITY changes nonetheless. 0278 0279 The \label{imap-envelope}{\em IMAP envelope} is a data structure holding 0280 interesting values determined mostly from various message headers. It is {\em 0281 not} the same thing as the SMTP envelope, which typically stores less 0282 information. 0283 0284 The {\em Internal date} holds a time stamp about when the message was delivered 0285 to the IMAP server. {\em Size} attribute is the number of octets required for 0286 storing a full copy of message in RFC~2822 format. {\em Body structure} 0287 represents the tree-like structure of the MIME message. 0288 0289 The \label{imap-msg-flags}{\em IMAP flags} is an attribute holding a set of zero 0290 or more named tokens associated with the message. A flag can be either {\em 0291 permanent} or {\em session-only}. Permanent flags are stored in the mailbox 0292 itself, while the session-only flags disappear on a subsequent reconnect to the 0293 mailbox. Some of the flags are defined by the RFC 3501 standard itself, others 0294 are added by various recommendations and extension standards. An IMAP server 0295 might allow IMAP clients to store their own message flags. A special means of 0296 communicating this via the protocol exist\footnote{The {\tt PERMANENTFLAGS} 0297 response code}. 0298 0299 Finally, message contents itself is distributed in form of {\em message texts}. 0300 Clients are free to choose from retrieving MIME message parts separately or as 0301 one blob. 0302 0303 \section{MIME} 0304 0305 Multipurpose Internet Mail Extensions~\cite{rfc-2045}, \cite{rfc-2046}, 0306 \cite{rfc-2047}, or just MIME, is a set of standards for extending the old SMTP 0307 mail from 7bit ASCII texts to rich multimedia contents. Parts of the standard 0308 deal with encapsulation of non-ASCII characters in message headers, as well as 0309 providing instructions about how to embed non-textual data in e-mail messages. 0310 0311 \subsection{Message as a Container} 0312 0313 An important aspect of MIME is its introduction of an internal structure to 0314 e-mail message bodies. Previously, a message body was just a plain text, while 0315 since the codification of this standard, it became possible to exchange more 0316 structured information. Contemporary users are probably familiar with HTML 0317 e-mails containing embedded images and a PDF attachment for seamless printing. 0318 Users routinely send e-mails with attached photographs from their holidays, or an 0319 archive containing business presentation. 0320 0321 MIME standard achieves this by defining a {\em content type} for message 0322 bodies. This content type, usually set by an RFC 2822 header of a 0323 message, determines how a compliant mail client displays the message. The 0324 old-school non-MIME mails have a default MIME type of {\tt text/plain}, an 0325 unformatted text in 7bit US-ASCII encoding. 0326 0327 Another portion of the standard defines generic-purpose containers, i.e., 0328 abstract content types which contains other message parts within. Using 0329 these containers, a message can suddenly evolve from an unstructured blob of 0330 text to a deep tree of unrelated body parts. 0331 0332 Most of these containers are defined in RFC~2045~\cite{rfc-2045} and 0333 2046~\cite{rfc-2046}, one was added in RFC~2387~\cite{rfc-multipart-related}. 0334 0335 The {\tt multipart/alternative} encoding provides a mean of transmitting a 0336 message that comes in several different formats, but each of them contains the same data. The 0337 MUA is expected to pick one of the underlying parts and display it, perhaps 0338 allowing the user to override this selection as a nice bonus. 0339 0340 The {\tt multipart/mixed} is a generic catch-all MIME type for multipart 0341 messages. If a compliant MUA sees a multipart content type that it can not 0342 recognize, it should behave as if it was the mixed multipart. A typical action is 0343 showing all embedded parts next to each other. 0344 0345 There are several more content types defined, but describing them in detail is 0346 out of scope for this thesis. 0347 0348 \subsection{International Characters in Messages} 0349 0350 Original SMTP mail as defined by RFC 822 is suitable only for transferring 0351 7bit data. Nowadays, 8bit transport channels are far more common, both for representation of 0352 international characters and for transfers of binary data. Therefore, the MIME 0353 family defines {\em transfer encodings} for conversion of generic 8bit binary 0354 data into a 7bit character stream and a portable way of expressing national 0355 characters using 7bit ASCII characters only. 0356 0357 For the former, two standard encodings are available, the {\em Quoted printable} 0358 and {\em Base64} (as well as a ``fake'' {\em binary} or {\em 8bit} encoding for 0359 transport of binary data over less restrictive tunnels), the latter is supported 0360 by a similar approach, as defined in RFC~2047~\cite{rfc-2047}. 0361 0362 \subsection{MIME Support in IMAP} 0363 0364 A large part of work involving the MIME support can be performed by the IMAP 0365 server. This is especially true for message structure parsing, where the IMAP 0366 specification provisions ways to explore the ``tree'' of a message, as well as 0367 methods for retrieving the resulting body parts separately (and even including 0368 byte ranges for more convenient download). 0369 0370 The IMAP protocol does not, however, handle the rest of MIME support, nor much of 0371 other header parsing. While it is common to ask the server for just a named 0372 subset of RFC 2822 mail headers, the returned data are not pre-parsed in any 0373 way. Therefore, much of the work from coalescing several header parts to 0374 decoding international character data is left as an exercise to the client. 0375 0376 Fortunately, various message attributes in the IMAP protocol can serve as a 0377 substitute for parsing the RFC 2822 headers. Sender and recipient data is 0378 available from the IMAP {\tt ENVELOPE}, message size as {\tt RFC822.SIZE}, IMAP 0379 itself provides extensions for message threading~\cite{rfc-threading}, etc. 0380 0381 \section{IMAP Protocol Flow} 0382 0383 Upon a successful connection to a remote IMAP server, client might choose to 0384 authenticate itself if the server has not already pre-authenticated it automatically 0385 under a particular user account. After that or in case the authentication is 0386 not required, the connection enters the {\em authenticated} state. In this 0387 phase, no mailbox is selected and only a subset of commands is valid. Clients 0388 can, for example, ask for listings of the mailbox tree, get quick information 0389 about number of messages in a particular mailbox or otherwise manage mailboxes 0390 as a whole. They have to, however, {\em select} a mailbox in order to do 0391 anything else, like retrieving messages or marking them as read. 0392 0393 A mailbox can be opened as read-only or for both reading and writing, provided the 0394 authenticated user has sufficient privileges. Retrieving messages can be done in 0395 both modes, but write operations (like storing a new message to the mailbox or 0396 manipulating the message flags) require read-write access. 0397 0398 \subsection{Commands and responses} 0399 \label{response-code} 0400 0401 IMAP is a line-oriented text protocol. Anything that a server sends to its client 0402 is called a {\em response} while all data flowing in the opposite direction are 0403 known as {\em commands}. Each command generated by client begins with a unique 0404 identifier called {\em tag} which is followed by the actual command identifier. 0405 Most commands also accept (or require) a {\em parameter} which might be a string 0406 literal, a number, an atom, a parenthesized list of other types, etc. 0407 Transmission of generic string literals requires an explicit confirmation from 0408 the server unless the LITERAL+~\cite{rfc-literalplus} extension is active. 0409 Support for this extension is crucial for good performance, as if absent, most 0410 commands would be delayed by at least network round-trip-time and no support for 0411 pipelining of such commands would be possible. Clients are free to issue several 0412 commands without waiting for their completion, subject to certain ambiguity 0413 rules\footnote{See section 5.5 of RFC 3501}. 0414 0415 Each command usually leads to at least one server response, the {\em tagged 0416 reply}. This response contains the same tag as the client sent in the original 0417 command, allowing the client to find out whether command failed or succeeded. 0418 Some commands may result in sending further replies, the {\em untagged replies}. 0419 An important detail of the protocol is that such untagged replies are allowed to 0420 occur at almost any time during the conversation and {\em not} only as a result 0421 of a particular command. A compliant client must be prepared for this situation 0422 and handle it correctly, for there is no difference between those unilaterally 0423 generated and ``requested'' replies. 0424 0425 Each tagged reply indicates a completion of a particular command. If the 0426 command succeeded, an {\tt OK} status is received, if it failed, server returns 0427 a {\tt NO}. Should the server had troubles figuring out the client's intention, 0428 a {\tt BAD} response is returned. More fine-grained control over results is 0429 achieved via {\em response codes}, textual entities with strictly defined 0430 meaning. Examples of such response codes are ``mailbox opened in read-only 0431 mode'', ``specified character set no supported'' or ``please show this error 0432 message to the user''. 0433 0434 \subsection{Mailbox Synchronization} 0435 0436 For efficiency reasons, each client usually keeps some data in its persistent 0437 cache. Good candidates for caching are message texts, a copy of body structure or 0438 perhaps even flags from the previous session. Because some server replies, namely 0439 the {\tt EXPUNGE} which informs the client that a message has been removed from 0440 the mailbox, refer to messages only by their sequence numbers and clients 0441 usually identify messages by UIDs in order to allow message texts caching, a 0442 compliant client has also to keep its UID-to-sequence number mapping up-to-speed 0443 with the server. Doing so for just a visible (in the GUI) part of the mailbox 0444 might seem tempting, but the risks involved therein (like not knowing what to 0445 purge from local cache as a result of received EXPUNGE without extra {\tt 0446 FETCH}) are high and usually outweigh possible initial savings. 0447 0448 An IMAP server fully conforming to RFC 3501 is required to sent a few ``status'' 0449 replies when a mailbox is selected. Interesting fields for the mailbox 0450 synchronization are updates on UIDVALIDITY, UIDNEXT and EXISTS. After receiving 0451 all three, client has enough information to decide about what actions are 0452 necessary to bring the particular mailbox back to a fully synchronized state. 0453 Clients only have to deal with mutable message attributes, which are the 0454 sequence number, the UID number and message flags. 0455 0456 If the UIDVALIDITY value changed, the client is required to throw away any data it 0457 might have in its local cache that refers to this particular mailbox. Some UIDs 0458 might have changed, message parts got modified or the client just happens to 0459 talk to a buggy server implementation. This situation is then identical to 0460 syncing form an initial state where client has no knowledge about the target 0461 mailbox. In the following text, we will assume that the UIDVALIDITY value is the 0462 same as on the previous synchronization. 0463 0464 If the UIDNEXT value did not change either, no messages were delivered to the 0465 mailbox since the last time. If the EXISTS number is the same as well, there 0466 have been no changes at all and the only item to re-synchronize are message 0467 flags. If the EXISTS number changed, some messages were permanently removed. 0468 Clients usually re-fetch their UID-to-sequences mapping as a whole, but 0469 implementations which prefer to transfer the lowest amount of data over the 0470 number of iterations over the network could use an algorithm similar 0471 to binary search to find out which regions of the UID mapping were left intact 0472 and which require re-synchronization. 0473 0474 If the UIDNEXT changed\footnote{It could only grow up, because UID numbers are 0475 strictly ascending} and the $\Delta UID$ is the same as $\Delta EXISTS$, some 0476 new messages arrived, but none were deleted and the client only has to ask for 0477 UIDs of these new messages (and FLAGS for all messages in the mailbox). If the 0478 increments of UIDNEXT and EXISTS differ, a fallback to generic 0479 synchronizing approach where client retrieves UIDs of all messages in the mailbox is 0480 necessary. It is also reasonable to transfer flags as a part of this step. 0481 0482 If there were no cached information or a UIDVALIDITY change occurred, clients 0483 would typically fetch a complete UID mapping and message flags. 0484 0485 After performing these steps and having received all relevant replies, the 0486 client is in a fully synchronized state and ready for receiving mailbox updates. 0487 0488 \subsection{Changes to Mailbox} 0489 0490 The mailbox that is selected is typically of some interest to the user. The 0491 original IMAP RFC mandated that all clients must be prepared for receiving 0492 updates about number of messages contained therein, removal of old ones and 0493 deliver of new, but due to the lack of support by clients at that time, this feature 0494 was rarely fully utilized. Instead, the {\em NOOP} command was widely used as a 0495 polling check for new messages. However, this had all the disadvantages of a 0496 polling-based approach, especially unnecessary increase of network traffic, lower 0497 possibility to enter deep sleep for battery powered devices and even delays in 0498 mail delivery, for some clients were rather hesitant to poll for changes too 0499 often. A solution to this problem is presented in RFC~2177~\cite{rfc-idle} 0500 where client enters a special mode (which is syntactically similar to 0501 synchronizing literals that are used when support for LITERAL+ 0502 \cite{rfc-literalplus} is absent) to tell the server that it can really send 0503 real-time notifications to the client. 0504 0505 Changes to the number of messages in the mailbox are communicated mainly by two 0506 kinds of untagged replies, {\em EXISTS} and {\em EXPUNGE}. The EXPUNGE reply 0507 contains a sequence number of the message that has been permanently removed from the 0508 mailbox and immediately causes all messages with sequence number higher than 0509 the message being deleted to decrement their assigned sequence numbers by one. 0510 This means that clients have to work with sequence numbers, unless they are 0511 prepared to update their UID map on each expunge, which would be a rather 0512 expensive approach. The EXISTS reply is used to inform the client that new message 0513 was delivered, or it could follow an EXPUNGE to provide a redundant information 0514 to the client about number of messages in the mail store. Under no 0515 circumstances could it be used to decrease the number of messages in current 0516 mailbox, as this is already handled by EXPUNGE. 0517 0518 \subsection{Fetching and Manipulating Messages} 0519 0520 Once selected, messages in the mailbox can be queried and downloaded to the 0521 client. The {\em FETCH} command serves for retrieving all data from body 0522 structures and IMAP envelopes to actual message parts. Message flags are 0523 updated by the {\em STORE} command and its variants. Existing messages can be 0524 copied to other mailboxes with the {\em COPY} command, new messages can be 0525 stored into a mail folder by the {\em APPEND} command. 0526 0527 \subsection{Queries Against Other Mailboxes} 0528 0529 Because most graphical MUAs want to show the user more than one mailbox at a 0530 time, at least in a collapsed view with counts of new or unread messages, and 0531 frequent switching among several mailboxes is not a cheap operation, IMAP also 0532 provides a command for determining state of other than currently selected mailbox, 0533 the {\em STATUS} command. Using this command for querying state of a currently 0534 selected mailbox is explicitly forbidden by the RFC, for a conforming client 0535 already has all required information to compute all possible message counts. 0536 Another reason for disallowing STATUS on current mailbox is that in some server 0537 implementations, this operation might cause a process to open the mailbox once 0538 more which might in turn provide inconsistent results and confuse the client 0539 even more. 0540 0541 \subsection{Searching, Sorting and Threading} 0542 0543 Even the base specification of the IMAP protocol provides facilities for 0544 searching the messages stored in current mailbox. This was extended over time 0545 by ways to request specific message ordering or threading~\cite{rfc-threading}. 0546 Most e-mail clients therefore do not need to have all message bodies and headers 0547 fetched and available in a local cache in order to allow their users to search 0548 through messages. However, this searching and sorting is not available in 0549 offline clients which have to implement their own code for such purposes, or 0550 disallow these operations when network access is disabled. 0551 0552 The following revisions also specified certain extensions related to the 0553 internationalization of e-mail traffic. For example, searching for non-ASCII 0554 characters in messages would be very hard using the bare-bone SEARCH command 0555 only, as each message in mailbox can be stored in one of the myriad encodings 0556 available in the MIME standard. Subsequent revisions to IMAP therefore defined 0557 support for more intelligent searches which support unified searching through 0558 messages that arrived in different character sets. 0559 0560 \subsection{Manipulating Mailboxes} 0561 0562 Due to some historic reasons (especially the old versions of SMTP protocol being 0563 7bit), IMAP does not use any standard encoding for mailbox names. Instead, a 0564 modified version of UTF-7 called simply {\em modified UTF-7} is mandated. The 0565 standard does not specify what to do if the other side uses 8bit data in mailbox 0566 name, but most implementations nowadays fall back to UTF-8, which is arguably a 0567 good thing to do. 0568 0569 Mailboxes can be created, deleted and renamed by IMAP clients. If the server 0570 supports it, they form a tree hierarchy. Some servers distinguish between 0571 mailboxes for storing messages and those that contain only other mailboxes, 0572 while other implementations allow free mixing of both. Unfortunately there is 0573 no reliable way to tell to which class the target server belongs, but provisions 0574 are given about how to create a folder for message and how for other mailboxes. 0575 If mailboxes form a tree, the server implementation specifies which character is 0576 used as a hierarchy delimiter. Most common choices in today's mainstream IMAP 0577 servers are dot ({\tt .}) which is common among servers exporting Maildir 0578 folders and slash ({\tt /}) as used by servers exporting traditional mbox UNIX 0579 mail store. This inconsistence might lead to user confusion, but cannot be 0580 avoided without breaking backward compatibility. 0581 0582 \subsection{Session termination} 0583 0584 IMAP session ends when the server sends the client an untagged {\tt BYE} 0585 response. This might be caused either by client's request via the {\tt 0586 LOGOUT} command or by an auto-logout timer on the server side. Server 0587 implementations are required to allow at least 30 minutes of inactivity before 0588 sending this reply\footnote{Many real networks, however, enforce much stricter 0589 policies with shorter timers. Real world client implementations therefore send 0590 keep-alive messages once in a few minutes to avoid connection termination.}. 0591 0592 \subsection{IMAP Extensions} 0593 0594 The IMAP protocol also has support for extending its functionality. Extensions 0595 can add new commands, replies and reply codes and even change basic aspects of 0596 the protocol, as demonstrated by the introduction of non-synchronizing literals 0597 in RFC~2088~\cite{rfc-literalplus}. Support for these extensions is strictly 0598 voluntary, though, and each compliant IMAP protocol entity has to function 0599 properly even when talking to an implementation supporting bare IMAP4rev1 as 0600 specified by RFC~3051. 0601 0602 \section{Other Methods of Mail Store Access} 0603 0604 IMAP is not the only protocol for accessing mails stored on a remote server. In 0605 this section, we will introduce some of the alternatives and discuss their 0606 advantages and disadvantages when compared to IMAP. 0607 0608 \subsection{POP3} 0609 0610 The main difference between IMAP and POP3\footnote{Post Office Protocol version 0611 3} protocol is their philosophy --- IMAP was designed for scenarios where user 0612 leaves all her e-mail at a central place which has authoritative answer about 0613 what messages are supposed to ``be there'' while POP3 expects their users to 0614 download all e-mail to a computer where the POP3 client runs and then {\em 0615 permanently remove the original messages from the server}. Upon each reconnect, 0616 the POP3 client downloads and deletes all new messages again. This fundamental 0617 difference leads to troubles when the user wants to use POP3 in situations it was not 0618 designed for -- a classic example is accessing one mailbox from two places over 0619 time, like a work computer and a laptop at home. While there are certain ways 0620 to work around these POP3 design limitations which allow leaving a copy of each 0621 message on the POP3 server, they all remain just hot fixes 0622 instead of providing a proper and reliable solution. An excellent comparison of 0623 these two paradigms is available from Grey's paper~\cite{imap-vs-pop}. 0624 0625 \subsection{MAPI} 0626 0627 A proprietary protocol from Microsoft whose documentation got recently opened 0628 for public access after a pressure from both government an non-government 0629 organisations. It has some nice features comparable to IMAP, but offers no real 0630 advantage besides tight integration with other Exchange services (which might or 0631 actually might not be considered an advantage). Implementations from other 0632 parties than the original vendor are scarce. 0633 0634 \subsection{Webmail} 0635 0636 Several years ago, a boom of online services from well-known companies like 0637 Google or regional Internet portals grew in popularity. Despite inherent 0638 limitations of web-based user interfaces, most ``casual'' users of e-mail, 0639 especially the second ``home mailboxes'' of regular employees, are today hosted 0640 and accessed via a webmail interface. Although hardly any of these services 0641 offers any guarantee about availability or performing backups, regular users 0642 typically are not concerned about these issues. Reliability of these services 0643 is, on the other hand, typically greater than that of a typical home PC with 0644 aging hardware, and friendliness of the UI improved with advent of recent 0645 web technologies. 0646 0647 \subsection{IMAP Criticism} 0648 0649 During more than 20 years of the IMAP history, the standard has certainly 0650 accumulated some aging dust. A typical example are the synchronizing literals, 0651 originally the only way to send more complex data to the server, which require 0652 explicit server's acknowledgment before continuation. Given a typical GPRS 0653 connection which is still common in many countries, a latency of 500~ms can delay 0654 all interaction with the IMAP server considerably. Many similar aspects were 0655 fixed by subsequent modifications to the standard, others are rather unfixable 0656 design limitations. 0657 0658 A fine example of such limitation, at least when perceived by the contemporary 0659 optics, is the concept of mailboxes. Online messaging services like GMail 0660 introduced a new way of thinking about messages -- previously a message would 0661 belong to exactly one mailbox and if the user wanted to have it available from two 0662 places (perhaps in ``work related'' and ``mailing list'' folders), she would 0663 have to store two copies. IMAP has no concept of a ``link'' between two 0664 messages. When one of them is flagged, the other copy is left intact. Another 0665 prehistoric feature of IMAP is its modified UTF-7 encoding which is not used 0666 anywhere else besides the IMAP protocol. Another point -- IMAP usually does a 0667 good job in shielding the client implementation from the need to parse all MIME 0668 data, but certain pieces remain, like the RFC 2822 headers with international 0669 characters. 0670 0671 Some authors also criticize the protocol on basis of its complexity and being 0672 loosely-defined in certain aspects. An example is the IDLE~\cite{rfc-idle} 0673 extension, which adds an explicit mode indicating to the server that the client 0674 is really ready to process any updates to mailbox state, while the original RFC 0675 mandated the client to be in such condition all the time. Most common MUAs also 0676 have troubles with getting all side-corners of IMAP right. 0677 0678 That being said, the IMAP is the only widely implemented standard for accessing 0679 an online or disconnected mail store. It has certain deficiencies, but all in 0680 all, it is a perfectly usable protocol. 0681 0682 \chapter{\trojita Design} 0683 \label{trojita-design} 0684 0685 As evidenced by numerous available MUAs on the market, there are many possible 0686 ways on how to implement a usable e-mail client. In this chapter, we explain 0687 some design choices behind \trojita. 0688 0689 \section{Overview} 0690 0691 \trojita is composed of several logically decoupled layers of independent 0692 components, see figure \ref{fig:trojita-design} on page 0693 \pageref{fig:trojita-design}. Communication between them adheres to a strictly 0694 defined interface. 0695 0696 \begin{figure}[h!] 0697 \centering 0698 \includegraphics[clip, trim=0cm 7cm 0cm 0cm, scale=0.6]{fig-trojita-design} 0699 \caption{A diagram showing the \trojita architecture} 0700 \label{fig:trojita-design} 0701 \end{figure} 0702 0703 On the top of the hierarchy lies the {\em GUI}. This part is what the user 0704 interacts with; it provides views showing all mailboxes on a server, a list of 0705 messages in the currently selected mailbox and the contents of the e-mail 0706 messages themselves. The GUI is based on the Qt framework, making use of 0707 various standard components. A substantial part is based on the Interview 0708 framework~\cite{qt-interview} and the WebKit~\cite{qt-webkit} as well as certain 0709 custom widgets, especially the Message View (section \ref{message-view}). 0710 0711 The GUI is fed with data by the {\em Model}, a model-view implementation created 0712 with the Qt item views. This part works in close collaboration with the IMAP 0713 server. It is responsible for processing server replies, building a 0714 representation of data stored on the remote host and sending commands to the 0715 server in response to user actions. Most of the IMAP protocol logic is 0716 concentrated on this layer. 0717 0718 The Model is assisted by a {\em Cache}. The cache provides persistent storage 0719 for certain data which are convenient to be present on next invocation of the 0720 application. Examples of such data include message parts or mailbox state 0721 information which allows a quick resynchronization after a reconnect. While the 0722 role of the cache and the data stored therein is not critical for \trojita's 0723 operation, having a local cache can considerably speed up the runtime. A layer 0724 serving a similar purpose is common among other e-mail clients as well. 0725 0726 Beneath the Model is the IMAP {\em Parser}, a component converting the stream of 0727 data flowing from the server into structured (and as the name suggests, parsed) 0728 data. The parser is assisted by a {\em Low-level parser}, an entity responsible 0729 for analysing the byte stream into tokens of data such as strings or numbers. 0730 0731 Finally, all network I/O is managed by a {\em Stream} and associated classes 0732 which provide a consistent interface for managing connections to the remote 0733 server. 0734 0735 \section{Model-View Architecture} 0736 \label{big-tree} 0737 0738 \trojita's heart, the Model, implements an interface of the QAbstractItemModel, 0739 a variant of the well-known Model-View-Controller design pattern. 0740 This architecture provides natural separation between how data are stored and 0741 how they are displayed. In case of \trojita, we went a bit ahead compared to 0742 the common approach and made essentially everything just a node, a part in one 0743 big tree which exports all data available on the server. This tree then 0744 contains all mailboxes, all messages stored in them and even the message 0745 structure and actual message body parts as its nodes. Several {\em filtering 0746 models} provide more user-oriented view, like ``all mailboxes'' or ``messages in 0747 a mailbox''. An alternative to this one-big-tree approach were separate models 0748 for list of mailboxes and for each opened mailbox. While the latter might make 0749 more sense at a first glance and from the perspective of a reader who just went 0750 through the IMAP protocol standard, subsequent analysis suggests that one big 0751 model actually fits the situation better, unless we wanted to deal with nasty 0752 issues that would immediately pop up as a result of sharing one Parser instance 0753 among several Models facing several mailboxes. The upper layers are not 0754 affected by this decision, as they use a strictly defined model-view interface 0755 for actual data retrieval. 0756 0757 The model-view architecture subsequently affects how \trojita and her Model 0758 operate. Upon successful startup, for example, \trojita will not execute many 0759 IMAP commands besides making sure that a connection to the remote IMAP server 0760 enters the authenticated state. This might involve issuing a {\tt STARTTLS} 0761 command for establishing a secure channel, optional user authentication, etc., 0762 but none of tasks like mailbox listing or even opening some of them. This 0763 listing is only fetched as a result of a call from the GUI which asks the model 0764 what should be shown in the view representing a list of mailboxes. 0765 0766 After the list of mailboxes is received and processed, the model tells all the 0767 attached views that its layout has changed and that the views should update what 0768 they show to the user. The views react by requesting more information from the 0769 Model, e.g., a number of unread messages or a total message count for each 0770 visible mailbox. 0771 0772 When a user clicks on a particular mailbox, another view is pointed to a subset 0773 of the big model, now containing a list of messages in the mailbox. Again, the 0774 action of clicking to the mailbox does not involve any direct action in the 0775 model itself; the mailbox synchronization is initiated only after the new view 0776 asks the model about how many messages to show, and then for more data 0777 concerning those messages that are visible in the current viewport. 0778 0779 One important feature implemented in \trojita which is absent from most e-mail 0780 clients (especially those whose data model was designed with only POP3 in mind) 0781 is delayed on-demand fetching with an intelligent preloading. Suppose a user 0782 has a big mailbox with more than 30,000 e-mail messages. A naive client would 0783 open a connection to the server, select the mailbox and then fetch envelopes for 0784 all messages in the mailbox. Most of these messages would never be shown to the 0785 user, though, as thirty thousands messages is too much to be displayed on one 0786 screen. What \trojita does is, however, more clever -- it creates thirty 0787 thousand of {\em fake} entries in the Model, each displaying a {\em 0788 loading\ldots} sign, and ask for the real data only for those that are actually 0789 visible (with some read-ahead and read-behind for increased efficiency). This 0790 effectively minimizes the amount of network traffic as well as the local cache 0791 size and the load on the remote IMAP server, while the user barely notices any 0792 slowdown. 0793 0794 Being the central part of \trojita, the Model and related components is 0795 described in section \ref{model-in-detail} at the end of this chapter. 0796 0797 \section{Parser} 0798 0799 The {\em Parser} is responsible for converting raw network replies into data 0800 suitable for processing by the Model. 0801 0802 \subsection{Low-level Parser} 0803 0804 Certain low-level tasks like extraction of a string literal from the input 0805 stream are offloaded to a lower-level class, the LowLevelParser. Reading raw, 0806 unstructured byte stream as the input, its job is to extract a certain field and 0807 return it in the specified form. The resulting type of this tokenizing is not, 0808 however, determined by the LowLevelParser itself, but by the upper layers. 0809 LowLevelParser thus works as a dumb context-free extractor rather than a full 0810 parser. Should an error occur (for example when the higher-level code requests 0811 an integer, but the data at the current offset are textual), an exception is 0812 thrown. Examples of functions implemented in the LowLevelParser are {\tt 0813 getAtom()\footnote{For reading an {\em atom}, which is usually used for 0814 transmission of integer values or ASCII words not containing ``complicated'' 0815 characters like spaces}}, {\tt parseList()\footnote{For retrieving a 0816 parenthesized list of other items. The other items might be atoms, string 0817 literals or even nested lists.}} or {\tt getNString()\footnote{ {\tt 0818 getNString()} returns string as parsed by {\tt getAString()} and adds special 0819 handling for {\tt NIL} items.}}. Details about their implementation are 0820 available in the Doxygen documentation. 0821 0822 \subsection{Parser} 0823 0824 The Parser listens to events from the underlying Socket, sending queued commands 0825 to the server and processing incoming data as they arrive. During the 0826 development of \trojita (and thanks to being the first component to be actually 0827 implemented), design of the Parser changed several times. Originally it started 0828 as a threaded implementation due to certain concerns about interactivity and 0829 network I/O, but after encountering some issues with Qt's handling of 0830 asynchronous event signalling and a recommendation from one of the core Qt 0831 developers, it was refactored into a single-threaded state machine with a more 0832 conservative handling of the network I/O, which closely mimics common Qt idioms. 0833 0834 When a reply from the server arrives, Parser instructs the auxiliary 0835 LowLevelParser instance to read tokens from the byte stream. These tokens are 0836 then used to build a complex {\tt AbstractResponse} instance on-the-fly. Due to 0837 the limitations of polymorphism in C++ and concerns about object lifetime and 0838 ownership, the Parser makes heavy use of C++ smart pointers, as introduced in 0839 the TR1~\cite{std-tr1}. An alternative would be to use smart pointer 0840 implementation from the Qt framework, the QSharedPointer. It provides a similar 0841 interface, so the possibility of eliminating a dependency on TR1 implementation 0842 is open for further consideration. 0843 0844 This part of \trojita has an extensive unit test coverage based both on 0845 real-world traffic and artificial corner cases. Error handling is implemented 0846 via exceptions. Being a class derived from QObject, the Parser uses signals and 0847 slots for communication with the rest of the application -- incoming data are 0848 read and parsed in code connected to the {\tt readyRead()} signal from the 0849 underlying socket and availability of processed server replies is announced by 0850 emission of {\tt responseReceived()} signal. The responses themselves are not 0851 serialized to the Qt's event delivery system, though, but remain stored in an 0852 internal queue in the Parser which provides queue-like semantics for accessing 0853 them. 0854 0855 \section{Cache} 0856 0857 A main purpose of the Cache is providing a persistent copy of certain useful 0858 data for speeding up mailbox re-synchronization upon a subsequent select as well 0859 as storing already requested message structure and message body parts. 0860 0861 \trojita is ready for multiple cache implementations. The implementation and 0862 interface are properly separated -- an abstract class\footnote{{\tt 0863 Imap::Mailbox::AbstractCache} as defined in {\tt Imap/Model/Cache.h}} specifies 0864 the only required methods of interaction between the Model and the Cache. 0865 0866 A simple cache implementation storing all data in operational memory with an 0867 optional possibility of persistent data store on the disk is provided. As no 0868 object life management or partial updates of the on-disk representation are 0869 implemented in this simple cache, it is not recommended for production use. 0870 Advanced caching implementations are expected to be developed after the thesis 0871 is finished. Candidates include using an sqlite database or an Qt caching 0872 object from WebKit, the {\tt QNetworkDiskCache}. One reason for developing a 0873 simple, in-house caching solution is the fact that the Qt caching framework was 0874 introduced only in Qt 4.5 while \trojita still supports building against the 4.4 0875 release, albeit with reduced feature set. Therefore, it was deemed that a 0876 simple custom caching framework is worth the extra work. 0877 0878 0879 \section{Streams} 0880 0881 The Qt framework already provides an implementation of an entity with support 0882 for sequential reading and writing as well as informing the rest of the 0883 application about the availability of new data. However, no unified interface 0884 for reporting errors is provided. Therefore, most of the classes in the Stream 0885 sub-library are just thin wrappers around various {\tt QIODevice} subclasses, 0886 adding unified signals and functions for error handling. 0887 0888 \trojita includes support for communication over unencrypted TCP sockets, over a 0889 connection secured by SSL\footnote{Secure Socket Layers}/TLS\footnote{Transport 0890 Layer Security} with the possibility to defer the SSL/TLS negotiation to a later 0891 point during the IMAP conversation\footnote{The STARTTLS command, cf. section 0892 6.2.1 of RFC~3501~\cite{rfc-imap}}, and finally over a UNIX pipe to a local 0893 process. For the latter, two implementations are actually included, first one 0894 being a wrapper around the QProcess from Qt and the other a standalone class 0895 making direct use of POSIX syscalls. The standalone implementation is no longer 0896 necessary, but was used in an earlier implementation of the Parser which made 0897 heavy use of nested calls to QIODevice's {\tt waitForReadyRead()} method. This 0898 usage led to hard-to-debug failures in the networking code when using other 0899 QIODevices than QTcpSocket. After a communication with Qt Software support 0900 personnel~\cite{qt-qprocess-sigpipe}, it was suggested to abandon these nested 0901 waitForReadyRead() calls and follow an approach common to Qt applications which 0902 simply ignore the availability of new data until there is enough bytes to 0903 process a whole response at once. In addition to more obvious and cleaner code, 0904 this eliminated the need for blocking I/O and subsequently any advantages of a 0905 threaded design of the Parser. Therefore, multithreading was abandoned and a new 0906 single-threaded network handler was implemented. 0907 0908 0909 \section{Model in Detail} 0910 \label{model-in-detail} 0911 0912 The {\em Model} is the most complex part of \trojita. It is responsible for 0913 correctly figuring out the meaning of various IMAP server replies, requesting 0914 further data as they are to be shown to the user, managing a pool of connections 0915 to opened mailboxes as well as handling of certain non-standard situations. 0916 0917 \subsection{The Tree} 0918 0919 Being an implementation of QAbstractItemModel, the Model has to provide an interface 0920 through which the attached views and proxy models\footnote{Proxy models are 0921 auxiliary models which do not supply their own data, but instead provide a 0922 filtered and modified view of data published by the parent model. More on this 0923 topic is explained in section \ref{model-proxies}.} can operate. 0924 0925 As most of other complex implementations of the QAbstractItemModel which provide 0926 a tree view with deep hierarchy, the Model maintains an internal tree of classes 0927 representing different entities in the big tree. These entities are: 0928 0929 \begin{description} 0930 \item[TreeItem] An abstract parent class providing a common interface for 0931 all specialized implementations 0932 \item[TreeItemMailbox] A class representing a remote mailbox on the IMAP 0933 server. Children of the mailbox are other mailboxes and a {\em list of 0934 messages}. 0935 \item[TreeItemMsgList] A container holding all messages in the mailbox 0936 \item[TreeItemMessage] One message in a particular mailbox 0937 \item[TreeItemPart] One MIME body part of a message 0938 \end{description} 0939 0940 Each of the mentioned classes contains enough information to be able to handle 0941 all delegated operations related to the Interview framework. For example, when 0942 the Model is asked for a displayable textual data for a particular index, it 0943 delegates the query to the corresponding TreeItem instance using virtual 0944 methods. The target instance then decides about {\em what is actually 0945 requested} and {\em how to retrieve that data}. Certain requests might be 0946 satisfied from the data already stored in the TreeItem instance itself while 0947 other require a query against the IMAP server. If the latter happens, the 0948 TreeItem asks the Model to submit a request to the IMAP server and returns some 0949 {\em temporary data} in response to the original request which most likely 0950 originated from the GUI. A typical temporary representation is a translated 0951 form of {\em ``loading\ldots''} or a question mark. As soon as the real data 0952 arrive from the server, the view is asked to update the display with new value. 0953 0954 To illustrate this rather complex theory on a concrete example, suppose a view just scrolled to a 0955 new message in the mailbox. The view obtained a {\em model index\footnote{A 0956 temporary index used for referring to certain item in the Model. The model 0957 index is a standard term from the Qt Interview framework, and as such is not 0958 described in detail in this thesis. Readers are referred to excellent Qt online 0959 documentation for details.}} from the Model and called the Model's {\tt data()} 0960 function to find out what should be displayed on screen. This function call was 0961 immediately propagated to the newly created TreeItemMessage instance. As the 0962 message just arrived to the mailbox, the class didn't have time to request more 0963 data about it yet. The TreeItemMessage instance is therefore in an {\em initial 0964 state} indicating that no attempt to load the data from the server has been 0965 performed, and thus the {\tt data()} implementation does not have any real 0966 answer to the original query. Therefore, it submits a request to the Model 0967 asking it to fetch the IMAP envelope of the particular message. However, the reply to this 0968 message is not guaranteed to arrive in a timely manner and the TreeItemMessage 0969 implementation cannot afford to block the GUI while it waits for the 0970 corresponding reply. Therefore, it returns an empty placeholder (or some 0971 intuitive string like the {\em loading\ldots} text already mentioned) for the 0972 time being. This text is then displayed in the GUI, for the Model does not have 0973 anything better to show to the user yet. In addition to that, the 0974 TreeItemMessage changes its state to {\em loading} which indicates that the 0975 remote server was already asked for the data and there is no point in requesting 0976 it over and over again\footnote{If the {\tt data()} function concerning the same 0977 index is called again, the same placeholder data is returned, but no further 0978 requests to the IMAP server are initiated.}. 0979 0980 In the meanwhile, the Model receives TreeItemMessage's request for fetching an 0981 envelope. It decides that the requested data belong to, e.g., message No. 666 in 0982 the mailbox. The total message count is 670 and no messages between 660 0983 and 670 were fetched yet. To enhance the user experience and minimize network 0984 round-trips, the Model submits a batched request to fetch message envelopes of all these 0985 messages at once, as chances are high that most of them will be queried for data soon 0986 anyway. As a part of this request, they are all flagged as {\em loading} in 0987 order to prevent duplicate fetching requests. 0988 0989 After a while, the response from the server arrives. As usual, the Model 0990 delegates the actual processing of the reply to the TreeItemMailbox or 0991 TreeItemMessage instance. The class notices that enough data for updating 0992 its state from {\em loading} to {\em fetched} has arrived, so it marks itself as 0993 {\em fetched} and tells the Model to broadcast this change to the attached 0994 consumers (views). Each view, upon receiving a {\tt dataChanged()} signal from 0995 the Model, asks for the displayable data again. Model passes the {\tt data()} function call 0996 to the TreeItemMessage instance which discovers that it has the data already 0997 available in memory and returns the real text field (like a message Subject) 0998 this time. 0999 1000 The ultimate goal of this lazy population is reducing network traffic and server 1001 load, as well as the client's memory usage. 1002 1003 The delayed loading is employed in all places in the Model where possible. For 1004 the efficiency reasons, though, certain data items which are known to be needed 1005 shortly after each other are requested in one block. Examples of such data are 1006 groups of the message envelope, the IMAP internal date, the message size, the 1007 UID, the body structure and the message flags concerning a particular message. 1008 As suggested earlier, these fields are also preloaded for previous and following 1009 messages in a sequence. 1010 1011 One notable exception to this approach is building a list of mailboxes. Due to 1012 the way the {\tt LIST} response is defined\footnote{Consult the 1013 RFC~3501~\cite{rfc-imap}, section 7.2.2}, no reliable way of requesting a 1014 partial listing of the mailbox tree is provided besides indicating that the 1015 result should include mailboxes from the specified hierarchy level only. 1016 \trojita therefore has to fetch all the names of top-level mailboxes at once. 1017 Requesting a listing of their children is then delayed until the user clicks the 1018 ``expand'' widget next to the mailbox name. Also the numbers 1019 indicating a total message count or the number of new messages in a mailbox are 1020 not requested for mailboxes that were not shown yet. 1021 1022 The tree nodes do not make use of smart pointers, instead, the parent node is 1023 responsible for properly freeing all resources associated with it, including 1024 destroying the children. 1025 1026 \trojita already tries to minimize the memory footprint, not fetching data 1027 until needed, yet an empty TreeItemMessage instance is still created for each 1028 message in the opened mailbox. The memory consumption associated with these 1029 operations is difficult to measure\footnote{The increase in memory usage 1030 includes internal QTreeView data structures which could not be eliminated even 1031 if \trojita did not create any new objects for its own purposes}. Experiments 1032 show that opening a mailbox with more than 43,000 messages increases the 1033 overall memory usage by about 6.5~MB on an x86 machine. Slightly less than one 1034 third of this memory is consumed by the QTreeView itself. 1035 1036 \subsection{Proxy Models} 1037 \label{model-proxies} 1038 1039 While browsing the huge mailbox tree itself is certainly an educating experience 1040 for users wishing to become familiar with e-mail processing and the IMAP 1041 standard, it is far from being user-friendly. Therefore, \trojita provides {\em 1042 proxy models} for presenting a more conservative view to the remote server's 1043 resources. 1044 1045 A proxy model works in close collaboration with the parent model, providing a 1046 modified and filtered view of the parent's data to the attached views. \trojita 1047 uses two proxy models, one for providing a list of mailboxes and the other for 1048 listing messages in the opened mailbox. Neither of these models contain 1049 significant intelligence, as most of the hard work is already done by the 1050 original parent Model. 1051 1052 \subsection{Offline and Expensive Network Mode} 1053 1054 In addition to the mode of operation described above, the Model can be 1055 instructed to change its behavior in order to either reduce the network traffic 1056 even further or to avoid any communication with the remote IMAP server 1057 altogether. For the former, and {\em expensive network} mode is provided, the 1058 latter is handled by an {\em offline mode}. 1059 1060 When offline, essentially any network traffic\footnote{Besides shutting down the 1061 already established connection} is blocked. All requests which cannot be 1062 satisfied from the cache will fail, and the corresponding TreeItem's state will 1063 be changed to {\em offline}. This particular status is reflected in the GUI in 1064 an intuitive way, mostly by changing the unknown message subjects to {\em 1065 offline}, etc. 1066 1067 The expensive mode mostly eliminates various optimistic preloading, as well as 1068 changes the operation of the message view to not show all body parts 1069 automatically. 1070 1071 \section{Message View} 1072 \label{message-view} 1073 1074 Rendering an e-mail message is not as simple as it seems. First problem that 1075 the implementation has to face is the delayed on-demand loading of the message 1076 parts. Due to the rich tree structure of MIME messages, \trojita does not know 1077 which parts are required to be shown before an attempt to render the message is 1078 made, and loading all of them in advance would be not only suboptimal in terms 1079 of network utilization, but could cause an inconvenient delay when displaying 1080 huge messages as well. Similarly, blocking for a full delivery of all required 1081 message parts when the rendering starts is not an option, as this process should 1082 not block the GUI. 1083 1084 The second problem originates in the complex nested structure of MIME messages. 1085 There is no limit for the maximal allowed depth of the body part nesting, so a 1086 message could have an attachment which in turn is another message containing 1087 further complex structure, easily stretching for many levels. 1088 1089 A first version implemented in \trojita dealt with the first problem, while 1090 leaving the second one unsolved. Since that, the message view widget was 1091 rewritten and the version presented in this thesis supports unlimited nesting of 1092 messages. 1093 1094 The core of both message rendering widgets is based on the WebKit 1095 \cite{qt-webkit}, a standards compliant HTML rendering engine. 1096 1097 \subsection{Network Manager} 1098 \label{network-manager} 1099 1100 The QWebView class is a component providing the HTML rendering engine as well as 1101 certain auxiliary infrastructure such as a client implementation of the HTTP 1102 stack. These parts combined together contain everything required for building an 1103 application which displays HTML pages retrieved from the network via a standard 1104 protocol like HTTP. Messages stored on a remote IMAP server are not, however, 1105 usually available over HTTP. Therefore, the QWebView had to be extended in order 1106 to be usable in \trojita. 1107 1108 Luckily the QWebView provides a straightforward way to delegate the network 1109 processing to a custom component via the QNetworkAccessManager interface. That 1110 custom component is then responsible for handling all network requests that 1111 originate as part of the processing of the HTML page. 1112 1113 In \trojita, we created a special network manager\footnote{The {\tt 1114 MsgPartNetworkAccessmanager}} whose job is to provide an access to the message 1115 bodies stored on the remote IMAP server as well as filter out any access to the 1116 ``regular Internet''. 1117 1118 The reason for the former is security and spam filtering. For example, when an HTML 1119 message contains a reference to a remote image, a naive e-mail client which 1120 allows the retrieval of external entities via HTTP would provide an accurate 1121 indication about when the message was read and even confirm the very existence 1122 of the addressee's e-mail address to the attacker. 1123 1124 The most interesting part of the network manager is, however, providing an 1125 access to the body parts. When the URL to be retrieved specifies the {\tt 1126 trojita-imap} scheme and {\tt message} as the ``host name'', the {\em path} of 1127 the URL is directly used as a logical address of the requested body part. If 1128 such a part exists, an auxiliary helper structure, a subclass of QNetworkReply, 1129 is returned which immediately requests the retrieval of the corresponding part 1130 from the IMAP server (or the local cache, if available therein). 1131 1132 In an old implementation, the QNetworkReply itself was responsible for properly 1133 handling the MIME content-type of the body part. For example, it contained a 1134 code for selecting the preferred part among several available in the 1135 multipart/alternative, or including multiple commands in case of 1136 multipart/mixed. This approach, however, did not scale. Therefore, the new 1137 implementation moves this logic to the upper layer where it arguably belongs. 1138 1139 The QNetworkReply subclasses in the new implementation do not handle any 1140 formatting logic. They are, as their name indicates, just thin wrappers dealing 1141 with raw data I/O from the TreeItemPart instance. For handling the formatting, 1142 a new class, the {\tt PartWidgetfactory}, factory was created. 1143 1144 \subsection{Widget Factory} 1145 1146 The {\tt PartWidgetfactory} is a classic example of the well-known {\em Factory} 1147 design pattern~\cite{GoF}. Its only public method, {\tt create()}, is responsible for 1148 returning a QWidget which is supposed to display a representation of the actual 1149 body part. 1150 1151 For some ``trivial''\footnote{{\em Trivial} in this context refers to a message 1152 part which could not be decomposed to more elementary parts. Examples of {\em 1153 trivial} content-types are {\tt text/plain} or {\tt image/jpeg} while examples 1154 of {\em non-trivial} ones are {\tt multipart/mixed} or {\tt message/rfc822}.} 1155 content-types, the factory returns an instance of a slightly 1156 modified\footnote{The modifications include filtering of the mouse wheel events, 1157 because the widget is supposed to be as large as required and leave implementing 1158 a scrolling view to itself to an upper layer.} QWebView. 1159 1160 If the type is complex, a wrapping widget is created. A classic example of the 1161 wrapper is the handler of {\tt multipart/alternative} MIME content-type. In 1162 this case, a QTabWidget whose tabs contain the actual nested parts is returned. 1163 Widgets for the nested parts are obtained by a recursive call to the {\tt 1164 create()} function, solving the problem of the nested body parts in an elegant 1165 way. 1166 1167 RFC~2183~\cite{rfc-content-disposition} introduced a method for specifying 1168 whether a body part is to be shown {\em inline}, that is, as any other regular 1169 part, or as an {\em attachment} through the Content-Disposition header. If the 1170 part is an attachment, most MUAs would not render its contents, but instead show 1171 a control for downloading the body part to the disk. \trojita works in a 1172 similar way. Unfortunately, certain e-mail clients don't distinguish among an 1173 attachment and an inline part, labeling data such as attached ZIP files as {\em 1174 inline}. Therefore, \trojita process the Content-Disposition header only as a 1175 suggestion if it asks for an inline display. 1176 1177 This part of \trojita is ready for further extensions. One particular extension 1178 which would be extremely useful to be implemented is support for signed and 1179 encrypted messages. Signatures are currently only recognized and indicated in 1180 the GUI, but not verified at all. 1181 1182 \subsection{HTML Mail} 1183 1184 A common format for today's commercial e-mail messages is the {\em HTML mail}. 1185 Building on top of the RFC~2387~\cite{rfc-multipart-related} and 1186 RFC~2111~\cite{rfc-content-id}, the HTML e-mail allows grouping HTML text and 1187 related data such as images into one MIME message part. 1188 1189 Conforming to the above mentioned standards, \trojita supports the {\tt cid} URL 1190 scheme. The network access manager (see section \ref{network-manager}) is 1191 extended with support for those URLs -- if a message part with the corresponding 1192 Content-ID header is found among the current message bodies, it is returned in 1193 response to a {\tt cid:} URL. 1194 1195 An interesting fact about \trojita is that her support for the {\tt cid:} URLs 1196 is more feature-complete than that of Thunderbird/2.0.0.14 which has troubles 1197 identifying certain body parts in some HTML messages\footnote{For example those 1198 from the {\tt http://mon.itor.us/} monitoring service.}. 1199 1200 \section{GUI} 1201 1202 No matter how advanced the underlying engine is, if the GUI does not keep up 1203 with the features offered or is not intuitive enough, users will switch to a 1204 competing product. 1205 1206 \trojita makes use of standard widgets from the Qt library whenever possible. 1207 Common and well-known components such as tree views builds the core of the GUI, 1208 showing list of messages and list of mailboxes. When the standard widgets did 1209 not exist or were not usable, new were implemented, re-using the existing ones 1210 as much as possible. 1211 1212 An example of a well-done re-use is the Message View. Building on already 1213 complex parts such as the WebKit and the associated helper classes, it combines 1214 the widgets with whom the user is probably already familiar into a big 1215 functional part. Without an unneeded user confusion, it manages to render the 1216 MIME structure of the received message faithfully. 1217 1218 The mail composer widget closely mimics the {\em Write New Mail} window from 1219 Mozilla Thunderbird. The recipients matrix was implemented in a similar way, 1220 providing users with a familiar experience and reducing the need of getting 1221 accustomed to yet another software. 1222 1223 Similarly, the icons indicating message state (such as being flagged for 1224 deletion, already replied to, forwarded to another recipient, etc.) are 1225 indicated by standard icons. \trojita will, thanks to the 1226 QtIconLoader~\cite{qticonloader}, try to load standard icons as per the relevant 1227 FreeDesktop.org standard~\cite{xdg-icons}, and for those that are absent from 1228 the system, a built-in icon from Thunderbird is used. 1229 1230 Drag and drop is used for copying and moving messages between mailboxes. No 1231 support for drag and drop outside of the \trojita is available yet, mainly due 1232 to a lack of widely accepted standard MIME type for doing so. 1233 1234 \chapter{Other IMAP Implementations} 1235 \label{other-imap-implementations} 1236 1237 Albeit the guarantee of interoperability is arguably the most important aspect 1238 of a standardization process, certain e-mail clients perform better than the 1239 others. In this section, we try to provide a basic overview of selected e-mail 1240 implementations. 1241 1242 This overview is by no means complete, for there are many more e-mail client 1243 implementations than pages in this thesis. We therefore focus on highlighting 1244 issues observed during the course of interoperability testing and on a 1245 comparison with \trojita. 1246 1247 Each client was tested against an instance of the Dovecot IMAP 1248 server~\cite{dovecot}. INBOX contained roughly five thousands messages, most of 1249 them were trivial text/plain e-mails with just one line of the message body. 1250 Other mail folders were however filed with certain testing messages representing 1251 a typical e-mail usage of the author of this thesis. Samples include GnuPG 1252 signed mail (the multipart/signed MIME type) and a special ``MIME Torture 1253 Test''~\cite{mime-torture-test} message whose purpose is to test deep MIME part 1254 nesting as well some common decoder errors. 1255 1256 \section{Alpine 2.0} 1257 1258 Alpine~\cite{alpine}, a successor of {\tt pine}, is a console e-mail client by 1259 Mark Crispin, the principal author of the IMAP protocol. As such, its qualities 1260 are widely acknowledged. When coupled with the UW-imapd, an IMAP server 1261 implementation from the University of Washington from the same author, they 1262 offer some non-standard features such as multi-mailbox search. The IMAP part of 1263 the code base is available as the {\tt c-client}, an implementation of the IMAP 1264 protocol in the C programming language. 1265 1266 The testing process showed that Alpine performs as an {\em online client}, that 1267 is, a client with no local persistent cache for retrieved message parts. These 1268 parts are cached for the session life time, but any downloaded data will be 1269 fetched again on a subsequent Alpine invocation. A nice feature of Alpine is, 1270 on the other hand, that it does not fetch any data about messages not currently 1271 visible on screen at all, achieving the lowest amount of initial network traffic 1272 among all tested IMAP implementations. 1273 1274 As a surprise comes the marketed lack of support for the {\tt IDLE} IMAP 1275 command. Crispin argues~\cite{pine-idle} that in today's world of 1276 NAT\footnote{Network Address Translation}, a real client will have its 1277 connection to the server sewered by a network device much sooner than before the 1278 30~minutes timeout period guaranteed by the RFC, and suggests to use {\tt 1279 NOOP}-based polling instead. This opinion is arguable, and most e-mail clients' 1280 authors do not seem to share it. 1281 1282 \section{Mutt 1.5.19} 1283 1284 The second console e-mail client, the Mutt~\cite{mutt}, is a popular text-based 1285 application. Controlling its user interface is slightly less intuitive than 1286 that of Alpine, but the advanced users praise its speed and the fact that the 1287 GUI does not block their operations. 1288 1289 Similar to Alpine, the Mutt is an {\em online client} without any persistent 1290 IMAP cache for downloaded message parts. In addition, Mutt will not issue the 1291 {\tt IDLE} IMAP command unless specifically told so in the configuration file. 1292 As a reason for this are stated issues with certain server 1293 implementations\footnote{Interestingly enough, Dovecot is blamed, while new 1294 version of Dovecot contain a workaround claimed to ``fix Mutt issues'', so 1295 figuring out which party to blame is left as an exercise to the reader.}. Even 1296 when IDLE is enabled, Mutt only enters this mode when showing a list of 1297 messages in the mailbox and not when viewing one message. 1298 1299 \section{KMail 3.5} 1300 1301 Being the default e-mail client in KDE 3.5, the KMail~\cite{kmail} has a broad 1302 user community. However, its IMAP support might sometimes seem a bit rusty -- 1303 there is, for one, no support for IDLE\footnote{The authors state that this 1304 limitation is present due to the architecture of the KDE's KIO framework which 1305 does not really allow similar modes of operation but is designed for 1306 client-initiated actions only.}, and quite a number of bugs against the IMAP 1307 implementation is reported at its Bugzilla. 1308 1309 In fact, the KMail contains two distinct implementations of IMAP, the first one 1310 being an {\em online mode} and the second one a {\em disconnected mode}. In the 1311 disconnected mode, all message bodies selected for being available when offline 1312 are transfered and all MIME parsing is deferred to the client, no matter what 1313 structure the e-mail message has. 1314 1315 In the online mode, a first surprise is KMail's handling of the IMAP message 1316 flags. In spite of using the proper command forms for {\em updating} certain 1317 individual flags instead of blindly specifying the resulting state of {\em all} 1318 flags for a particular message, the operations are apparently aimed too wide, 1319 targeting most of the messages in the mailbox even when some of them were not 1320 shown to the user yet. In addition, KMail needlessly introduces its own flag 1321 names even for those flags whose names are either standardized or their use 1322 widely supported. An example is setting both {\tt KMAILFORWARDED} and {\tt 1323 \$FORWARDED} flags instead of just the former, 1324 semi-standardized~\cite{imap-keywords-flags} one. 1325 1326 The body parts of the complex MIME message from the MIME Torture Test are 1327 retrieved separately and the rendered representation of the message corresponds 1328 to the original body structure, which is an impressive result that no other 1329 e-mail client in this test (besides \trojita) achieved. The {\tt text/plain} 1330 messages are, however, fetched as one compact entity along with their headers. 1331 1332 Common to both implementations, the mailbox hierarchy discovery is performed as 1333 recommended by the IMAP best-practices~\cite{client-best-practices}, i.e., using 1334 the {\tt ``\%''} wild character instead of {\tt ``*''}. 1335 1336 KMail 1.11.1 with KDE 4.2.1 performed in a similar way to the already discussed 1337 version. 1338 1339 \section{Mozilla Thunderbird 2.0} 1340 1341 Mozilla Thunderbird~\cite{thunderbird} has been the e-mail client of choice for 1342 the author of this thesis. The GUI is excellent, not only well-looking, but 1343 also extremely convenient to use. However, its support for detecting changes to 1344 the mailbox performed by another session leaves much to be desired -- sometimes 1345 it is prone to not updating the displayed state based on what is received from 1346 the server. 1347 1348 Thunderbird by default shows only {\em subscribed mailboxes}, i.e., those that 1349 were flagged by the user as interesting in some way. Their discovery is 1350 performed using the {\tt ``*''} wild mask, which might potentially result in a 1351 large list to fetch. On the other hand, assuming that the user did not mark 1352 too many mailboxes is probably acceptable. The MIME parsing is deferred to the 1353 e-mail client, as a common choice among the graphical Mail User Agents. We assume that 1354 this is a direct result of support for other protocols than IMAP which do not 1355 provide any form of server-side MIME support, and the client therefore has no 1356 reason not to decompose the message itself after receiving the full body in one 1357 part. 1358 1359 Thunderbird by default opens several connections to the IMAP server and uses 1360 IDLE for asynchronous notifications about new messages in each of them. The 1361 limit on number of concurrent connections is configurable~\cite{mozilla-imap}, 1362 which is probably the only reasonable approach to figuring out how many of them 1363 will not yet be considered an abuse by the server operators\footnote{Client 1364 developers might argue that leaving tens of concurrent connections to the server 1365 open at the same time, each of them in the IDLE mode in a particular mailbox, is 1366 actually {\em better} for the server than multiplexing the access using just one 1367 or a few of IMAP threads. The client developers are of course right, but the 1368 server administrators usually cannot be expected to have such a deep 1369 understanding of the IMAP protocol. Indeed, most of them would prefer to ban 1370 such a user.}. 1371 1372 \section{Mailody} 1373 1374 Mailody~\cite{mailody} originally started as a standalone IMAP e-mail client, an 1375 alternative to KMail. During the development of KDE4, its code base became the 1376 foundation of the IMAP support in Akonady, a framework for PIM\footnote{Personal 1377 Information Management} information exchange in the then-upcoming KDE4 desktop. 1378 1379 We were unable to test the version identified as ``1.5.0-beta1'' on KDE 4.2.1 as 1380 it crashed with a segmentation fault each time we tried to make it talk to our 1381 testing Dovecot instance. A similar result was observed when trying the older 1382 0.5.0 version on KDE 3.5.10. 1383 1384 From the IMAP traffic dumps obtained before the application crashed, it is 1385 evident that while the authors of Mailody certainly thought about how to 1386 implement IMAP properly (as documented, e.g., by an attempt to group a large 1387 message set to smaller parts), it is not a finished product yet. As an example, 1388 IMAP allows packing of a contiguous sequence into an interval specified by both 1389 boundaries. Mailody fails to use this feature, requesting the range by 1390 enumerating all values contained therein. It also does not seem to notice the 1391 IMAP envelope at all, fetching the corresponding headers directly. While the 1392 latter it not an error, strictly speaking, it at least makes the reader of the 1393 source code wonder what led to that particular choice. 1394 1395 Earlier versions of Mailody had troubles even with mailbox names being passed as 1396 literals instead of quoted strings. This might be caused by the fact that the 1397 source code used rigid regular expressions for parsing of server replies which 1398 did not account for each possible response variation. For example, such a naive 1399 parser would have troubles recognizing a reply containing a response 1400 code\footnote{Consult Section \ref{response-code} for more on the concept of 1401 response codes}, which is free to be present in most situations. 1402 1403 \section{Outlook Express} 1404 1405 The Outlook Express is the built-in e-mail client in various versions of 1406 Microsoft Windows. The version we tested was shipped with Windows XP, and is 1407 the latest release of the Outlook Express ever\footnote{The product got 1408 re-branded to {\em Windows Mail} and subsequently to {\em Windows Live Mail}}. 1409 1410 The IMAP support in the Outlook Express is suboptimal, to say the least. An 1411 example of the ``efficiency'' of the protocol implementation is how the Outlook 1412 Express behaves when the user has selected several folders to be subscribed. At 1413 first, the application opens multiple connections to the server. Each of these 1414 connections then changes the subscription status of {\em one} mailbox, enters 1415 IDLE for a short time and finally terminates. 1416 1417 When the application opened a mailbox with roughly five thousand test messages, 1418 it began an immediate full download of all of them. Each messages was fetched 1419 by a dedicated command, adding one useless parameter to the list of items to 1420 fetch, and the IDLE mode was entered and immediately left between each two 1421 commands. That accounts for circa five thousand attempts to enter the IDLE 1422 mode, each of them lasting several milliseconds. 1423 1424 The GUI part of the application leaves much to be desired, too. A notable 1425 example is its handling of {\tt multipart/signed} message parts -- if the 1426 signature is made according to MIME/OpenPGP~\cite{rfc-mime-openpgp}, Outlook 1427 Express displays an empty message with two attachments, the signed body and the 1428 signature itself. This effectively prevents most users from actually reading 1429 the PGP-signed e-mails, as they do not expect the ``real message body'' to be 1430 available as an attachment only. Another problem exists with the display of the 1431 X-509 signed e-mails which contain a valid signature that cannot be verified. 1432 If such a signature is found, the Outlook Express displays a misleading warning 1433 about a possible security threat to the {\em local computer} instead of calmly 1434 informing the user about the fact that the certificate of the 1435 CA\footnote{Certificate Authority, an entity which issues certificates to other 1436 entities} is not found and thus the signature could not be verified. An extra 1437 click or two is needed to display the actual message body. This again presents 1438 a big obstacle to the actual usage of the signed e-mail on the Internet, for the 1439 Outlook Express still has a substantial market share. 1440 1441 \section{Windows Live Mail} 1442 1443 After the deprecation of the Outlook Express during the development phase of 1444 Windows Vista, a new e-mail application called {\em Windows Mail} has been 1445 introduced. However, it was not being shipped for a long time, as yet another 1446 successor, the {\em Windows Live Mail}, got introduced. Windows Live Mail is 1447 expected to be the e-mail application distributed with the upcoming Windows 1448 Seven operating system. 1449 1450 Unfortunately, most of the issues mentioned in the section about Outlook Express 1451 still stand. Both applications apparently use not only the same (or remarkably 1452 similar) IMAP code, but also a not-so-different GUI layer -- while the overall 1453 appearance has certainly changed since Outlook Express, the issues with 1454 presentation of, e.g., the PGP/MIME signed e-mail messages persist. We will 1455 therefore end this section by an observation that the IMAP experience is almost 1456 the same as with the Outlook Express. 1457 1458 \section{\trojita} 1459 1460 \trojita is an IMAP client with support for various mail access modes. It 1461 can be told not to request data which were not loaded from the network yet, 1462 supports an efficient re-synchronization mode which tries to minimize the 1463 network traffic and tries to deal with even the most advanced MIME messages 1464 reasonably. The IMAP conversation could still be improved, though -- for 1465 example, an initial LIST is issued even before the user is properly 1466 authenticated. 1467 1468 In general, we believe that we have implemented the IMAP protocol completely and 1469 properly. We tried to follow the IMAP RFC to the letter, but were sometimes 1470 forced to relax our requirements a bit, for example when talking to the Cyrus 1471 IMAP server which regularly sends replies which do not contain a textual part at 1472 all, in spite of the protocol grammar mandating its presence. We try to handle 1473 most situations gracefully, e.g., by resorting to a full mailbox 1474 re-synchronization when \trojita detects that the mailbox state changed in other 1475 ways than the server already acknowledged. 1476 1477 When compared to Alpine and Mutt, \trojita supports an offline message cache 1478 which allows its operation even when the connection to the remote IMAP server 1479 cannot be obtained. Its support for IDLE is also arguably better than that of 1480 Mutt, entering the IDLE more often. 1481 1482 Comparing with the messaging platform from Microsoft would not be fair. It is 1483 commonly accepted that the Outlook Express managed to implement IMAP in such a 1484 broken way that any further comment would be redundant. 1485 1486 The KMail offers a nice GUI and integration with the rest of the KDE desktop. 1487 Its IMAP support is, however, not that polished up. If \trojita had the GUI and 1488 related features of KMail, it would be hard to beat in terms of usability. 1489 1490 Finally, Mozilla Thunderbird is quite an impressive application. Even though we 1491 might have certain reservations to the overall Mozilla architecture, the GUI is 1492 user friendly and clean, and the application just works most of the time. In 1493 certain corner-cases, such as when working over a low-bandwidth network 1494 connection, \trojita has potential for outperforming the Thunderbird thanks to 1495 the employment of server-side MIME parsing. In fact, \trojita has already 1496 bitten Thunderbird when dealing with one particular HTML-formatted message which 1497 Mozilla fails to render properly, while \trojita handles it without any problem. 1498 1499 A conclusion of \trojita's overall usability is provided in the end of the 1500 thesis. 1501 1502 \chapter{User's Guide} 1503 \label{users-guide} 1504 1505 \section{About Trojita} 1506 1507 \trojita is a standards-compliant IMAP Mail User Agent. Designed with portability 1508 and efficiency in mind, it allows the user to operate over congested network 1509 lines with high latency, while still providing sufficient comfort. 1510 1511 \section{Installation} 1512 1513 \subsection{Prerequisites} 1514 1515 In order to build \trojita from source, several libraries and helper programs are 1516 required to be present on the system. 1517 1518 \begin{enumerate} 1519 \item{CMake 2.6 or later} 1520 \item{Qt 4.4 or later} 1521 \item{Working implementation of the TR1 C++ standard such as GCC 4.3 or 1522 newer or the Boost libraries} 1523 \end{enumerate} 1524 1525 A recommended version of the Qt framework~\cite{qt} is at least 4.5. \trojita, 1526 however, includes compatibility code for older versions of Qt. The minimal supported 1527 version is Qt/4.4. Any older release cannot be supported, as the WebKit HTML 1528 engine which we use for e-mail rendering was added during the 4.4 1529 development. If users choose to build against 4.4, some \trojita features might 1530 be missing. 1531 1532 Unlike most Qt projects, \trojita uses CMake~\cite{cmake} instead of {\tt qmake}, 1533 especially due to author's familiarity with the former system. 1534 1535 \trojita makes use of some standard C++ features that were adding during the TR1 1536 \cite{std-tr1} standardisation, namely the {\tt std::tr1::shared\_ptr} smart 1537 pointer. A working implementation of said class is required. \trojita build 1538 system will make use of compiler's built-in TR1 support, if available, and 1539 resort to using Boost if the compiler does not support this extension. 1540 1541 Some third-party code is also bundled in the source code distribution. A list of 1542 such products including the reason for not just using an external library 1543 follows: 1544 1545 \begin{enumerate} 1546 \item{QwwSmtpClient~\cite{qwwsmtpclient} is a Qt SMTP client library written 1547 by Witold Wysota. Released to public only in mid May 2009, obtaining a 1548 package of it might prove challenging. The copy in \trojita's codebase 1549 also contains some fixes which did not made it to the publicly released 1550 version yet.} 1551 \item{ModelTest~\cite{modeltest}, a class for verifying certain assumptions 1552 of the Interview Model-View framework of Qt. Qt Software (former 1553 Trolltech) does not ship it with Qt sources, so \trojita includes a copy 1554 for developers' convenience. This feature is not turned on by default 1555 in release builds.} 1556 \item{QtIconLoader~\cite{qticonloader}, another helper library from Qt 1557 Software. Its purpose is to provide a unified icon set, as per 1558 relevant XDG standards.} 1559 \item{KCodecs~\cite{kcodecs}, an implementation of UTF-7, Base64, 1560 Quoted-Printable and related RFC 2047 standards. These functions are 1561 reasonably self-contained, so they are bundled with \trojita instead of 1562 depending on quite heavyweight {\tt kdelibs}.} 1563 \end{enumerate} 1564 1565 \subsection{Obtaining source code} 1566 1567 Source code is available from the CD (see \ref{cd-content}) attached to this thesis or online at {\tt 1568 http://trojita.flaska.net/}. 1569 1570 \subsection{Installing} 1571 1572 Unpack the source tarball, prepare the build environment and launch the compile 1573 process by entering these commands: 1574 1575 \begin{enumerate} 1576 \item{{\tt tar -xf trojita-1.0.tar.bz2}} 1577 \item{{\tt cd trojita-1.0}} 1578 \item{{\tt mkdir \_build}} 1579 \item{{\tt cd \_build}} 1580 \item{{\tt cmake -DCMAKE\_BUILD\_TYPE=RelWithDebInfo ..}} (the {\tt ..} are 1581 not a typo) 1582 \item{{\tt make}} 1583 \end{enumerate} 1584 1585 After a while, a new binary, {\tt trojita}, will appear in the build directory. 1586 Launch it to start \trojita. 1587 1588 \section{Using \trojita} 1589 \subsection{Configuration} 1590 1591 All configuration is, thanks to the Qt's QSettings, stored in target platform's 1592 common storage location. The only supported mean of configuring \trojita is 1593 through its built-in configuration dialog that will automatically appear on the 1594 first run. It can also be launched any time later from the application menu. 1595 1596 % FIXME: screenshot 1597 1598 On the first page, user is asked to provide identity data. These are used for 1599 composing e-mail messages. 1600 1601 Second page is the most important one in configuration of \trojita. It is the 1602 place where the user tells the application which IMAP server is it supposed to 1603 talk to, which credentials should be used for authentication, etc. 1604 1605 One unusual thing which is not common among other MUAs is the choice of how to 1606 connect to the IMAP server. Most users are probably familiar with connections 1607 over TCP, optionally secured by SSL/TLS, but the last option, the {\em Local 1608 Process}, is unique to \trojita. If selected, it replaces the usual TCP 1609 connection to the IMAP server with launching a local process, which is in turn 1610 used instead of the remote IMAP server. The most interesting use case is to set 1611 up SSH connection to the remote server (along with proper SSH keys) and use that 1612 as a secure, reliable and convenient way for accessing e-mail, without having to 1613 enter passwords all the time. For example, to launch an instance of Dovecot IMAP 1614 server on host {\tt mail.example.org}, user should enter {\tt ssh 1615 mail.example.org dovecot --exec-mail imap}. 1616 1617 The last page serves for configuring the message composition and sending. 1618 \trojita supports mail submission via SMTP\footnote{Simple Mail Transfer 1619 Protocol} and local {\tt sendmail}-compatible MSA\footnote{Mail Submission 1620 Agent\cite{rfc-msa}, a local gateway whose purpose is forwarding e-mail to the 1621 network of MTAs} application. 1622 1623 \subsection{Basic usage} 1624 1625 After the configuration is complete, the user is presented with a familiar user 1626 interface. The left pane presents a view of remote mailboxes, or folders, on the 1627 IMAP server. The top widget contains a list of messages in the currently opened 1628 folder, and finally the bottom area is reserved for displaying the actual 1629 e-mail messages. 1630 1631 Depending on the network parameters and server load, it might take a while 1632 before the list of mailboxes appears. The delay is only significant when 1633 launching \trojita for the first time, for the retrieved list of mailboxes is 1634 cached on a persistent disk cache for later use. 1635 1636 After the list of mailboxes is loaded, user can click on them to open them in 1637 the {\em Message List} widget on the upper right corner of the application 1638 window. After having selected a mailbox, the list of messages appears shortly. 1639 Again, the loading is faster next time \trojita is launched. 1640 1641 Depending on user settings, \trojita typically will not transfer all message 1642 metadata upon opening a mailbox. This feature is implemented to conserve 1643 both server's and client's resources and to be nice to the network traffic. In 1644 a typical mode, that is, when not being told to be extra-mean with resources, 1645 \trojita fetches only metadata of those messages that are displayed on the 1646 visible screen region, and some more to make scrolling smoother. More on this 1647 topic is said in section \ref{model-in-detail} of this thesis. 1648 1649 Message contents is transfered on-demand only, that is, when user selects a 1650 message for viewing. As before, all persistent contents once downloaded from 1651 the server is cached in a persistent on-disk cache for future use. This applies 1652 to both message metadata and the real contents of e-mails. 1653 1654 \subsection{Managing Messages and Mailboxes} 1655 1656 Messages displayed to the user are automatically marked as read after some delay. 1657 The idea behind this feature is to allow users to peek on a particular message, 1658 shortly judge its contents, classify it as a ``process later'' and then move on 1659 to another one. This is a common approach shared with other MUAs as well. 1660 1661 Manipulating with {\em message flags} (see chapter \ref{imap-msg-flags}) is possible 1662 via the context menu (appearing on the message list) as well by standard 1663 keyboard shortcuts. The {\tt M} key toggles the {\em Read} status and {\tt 1664 Delete} key schedules messages for removal. 1665 1666 In consistency with the usual IMAP approach (and unlike the common modus operandi on 1667 mainstream desktop MUAs), \trojita has no concept of {\em Trash} 1668 \footnote{A {\em Trash} is a mailbox that presents a view of all deleted 1669 messages. It might or might not be a real mailbox on the server, or just a 1670 virtual folder implemented purely in the e-mail client.} for 1671 messages. Instead, each message can be marked as deleted. If flagged as such, 1672 \trojita displays a graphical indicator next to the message subject. A deleted 1673 message will not be physically removed from the mailbox until the user explicitly 1674 requests such an action. This operation, called {\em expunge} in the IMAP 1675 dictionary, is available from the application menu. Expunging happens on one 1676 mailbox at a time, there is no way to tell the IMAP server to permanently remove 1677 all deleted messages from all mailboxes. 1678 1679 To create new mailbox, user is expected to use the context menu on the left {\em 1680 mailbox view} pane. Due to technical limitations, some IMAP servers distinguish 1681 among folders that can contain other mailboxes and folders for message store 1682 only. Additionally, there is no reliable way for the IMAP client to tell 1683 whether the remote server is affected by this limitation or not. Therefore, 1684 \trojita uses the same approach as other common MUAs and ask user what kind of 1685 mailbox she wants to create. 1686 1687 % FIXME screenshot 1688 1689 Mailbox removal is triggered from the context menu as well. Due to the possibly 1690 serious consequences of this action (there is no way to undelete a removed 1691 mailbox), user is presented with a confirmation dialogue asking her whether she 1692 is serious in her intent to remove the mailbox. 1693 1694 Messages can be copied or moved between mailboxes by simple drag-and-drop 1695 operations. To place a copy of one or more messages into another mailbox, 1696 simply select the messages to copy in the opened mailbox and then drag them with 1697 mouse to the target mailbox. If user wants to move them instead of performing a 1698 copy, she is supposed to hold the {\tt Shift} key. This behavior is determined 1699 by the Qt framework, so it might vary among the supported platforms. 1700 1701 \subsection{Message Composition} 1702 1703 Message Composition widget is triggered by the corresponding item in the menus. 1704 The displayed dialog should be familiar to most users. 1705 1706 \subsection{Checking Mail} 1707 1708 \trojita automatically checks the current folder for new messages. If the 1709 remote server supports the IDLE extension~\cite{rfc-idle}, the method used is 1710 extremely friendly to both network and server resources. In cases the server 1711 does not support this feature, \trojita resorts to polling with all it 1712 disadvantages. 1713 1714 \section{Advanced usage} 1715 1716 \subsection{Partial Message Fetching} 1717 1718 Thanks to unique features of the IMAP protocol, it is not necessary to fetch the 1719 whole message in order to display just a fragment of it. \trojita handles this 1720 automatically, fetching message parts on demand. It also will not transfer message 1721 metadata (like its RFC~2822 envelope) unless really needed. 1722 1723 \subsection{Offline Mode} 1724 1725 When put into {\em offline mode}, \trojita will prevent itself from accessing 1726 the network at all. Users will be still able to view already transfered data, but 1727 no checks for new messages will be performed and those that are not stored in 1728 local offline cache will not have actual message bodies displayed until the user 1729 selects either {\em online} or {\em expensive network} mode from the menu. 1730 1731 \subsection{Expensive Network} 1732 1733 Some users connect to their IMAP servers over a slow or otherwise unsuitable 1734 network. Examples include dial-up connections or various mobile solutions like 1735 GPRS\footnote{General packet radio service (GPRS) is a mobile data service 1736 typically offering low bandwidth, high latency Internet connection with billing 1737 based on the amount of transfered data} where the overall convenience of having 1738 all messages immediately available is usually held back by the need to conserve 1739 network resources. In such environments, it might be desirable to fetch only 1740 the absolute minimum data required to provide properly synchronized view of the 1741 remote mailbox. 1742 1743 In this situation, the user is expected to choose the {\em Expensive Network} mode 1744 from the application menu. \trojita will not preload data to improve 1745 interactivity, nor will it show all message parts by default. Upon viewing a 1746 message, only parts smaller than a certain size are transfered automatically, 1747 others will be loaded after clicking a button. This on-demand loading is 1748 implemented separately for each part, allowing great flexibility for the user to 1749 choose what is interesting and what can be ignored. 1750 1751 \subsection{Online Mode} 1752 1753 {\em Online mode}, the common mode of operation, is what users are familiar from 1754 other IMAP clients. \trojita employs intelligent preloading of interesting 1755 contents to minimize waiting times, yet does not blindly download everything, 1756 including parts that will not be ever shown. 1757 1758 \subsection{Local Cache} 1759 1760 All data once transfered form the network\footnote{Subject to some restrictions 1761 like maximal message part size and cache parameters} are kept in a persistent 1762 offline on-disk cache. If a message data is transfered twice, it means that at 1763 least one of the following conditions was met: 1764 1765 \begin{enumerate} 1766 \item{The server could not guarantee the immutability of messages. This might 1767 happen when some process touches on-disk data internal to the IMAP 1768 server in a non-standard way.} 1769 \item{User has changed her settings. Whenever any data used to access the 1770 remote server changes, the only safe thing to do is to throw away 1771 anything in the local cache and start over again.} 1772 \end{enumerate} 1773 1774 \subsection{Full Tree View} 1775 1776 As an optional part of the GUI, the {\em full tree view}, activated by the 1777 corresponding item in the menu, provides a full view of the server contents, 1778 including mailbox hierarchy, messages in mailboxes and mailbox parts. This 1779 widget is a nice demonstration of a complex nature of MIME messages -- while 1780 most users are probably familiar with the concept of attachments, the truth is 1781 that MIME defines a fully recursive structure that one message can consist of. 1782 For example, it is perfectly possible to have a message composed of six parts, 1783 each of them being a forwarded message, and each of these forwarded messages 1784 being rich-structured as well. \trojita does its best at formatting the message 1785 in a sane and familiar way, but unfortunately some senders do not really follow 1786 the same philosophy and produce messages whose structure leaves much to be 1787 desired. 1788 1789 More on this matter can be found in section \ref{big-tree}. 1790 1791 \chapter{Conclusion} 1792 1793 The goal of this thesis was to demonstrate that an IMAP e-mail client could be 1794 usable, yet implement the relevant RFCs properly and behave in an efficient way. 1795 1796 After an introduction to the world of IMAP and other Internet messaging 1797 standards in the second chapter of the thesis, we described the design of 1798 \trojita, the application implemented in this thesis, as well as provided a 1799 comparison with other commonly used IMAP e-mail clients. 1800 1801 While it is evident that the GUI of \trojita is not as mature as the interface 1802 of other, more established Mail User Agents such as Mozilla Thunderbird or the 1803 KMail, the core IMAP engine design is sound. Already offering complete support 1804 for the IMAP4rev1 protocol as defined by RFC~3501~\cite{rfc-imap}, \trojita 1805 implements most important IMAP extensions such as IDLE~\cite{rfc-idle} and 1806 conforms to various IMAP client implementation recommendations which accumulated 1807 over more than twenty years of the IMAP history. Special emphasis is placed at 1808 transferring only the required data, minimizing network transfers as well as 1809 memory consumption. As a result of these optimizations, \trojita operates 1810 swiftly even when faced with huge mailboxes containing tens of thousands of 1811 e-mail messages. 1812 1813 Mailbox re-synchronization uses as much data from the previously recorded 1814 mailbox state as permitted by the standards while the persistent offline cache 1815 with a pluggable architecture allows storing of already downloaded message parts 1816 among sessions and enables offline browsing of the remote server's contents when 1817 no network connection is available. 1818 1819 The rendering of the MIME messages provides a faithful reflection of the MIME 1820 structure, yet sustains an acceptable level of user-friendliness. 1821 1822 A feature unique to \trojita is its support of operation over a UNIX pipe to the 1823 local process instead of through a TCP socket. When combined with SSH and the 1824 ssh-agent, it allows a convenient password-less operation without sacrificing 1825 security. 1826 1827 Finally, \trojita, as presented in this thesis, is a result of several years of 1828 the author's involvement in the area of Internet messaging. \trojita, being 1829 written in a modular way, provides a mature design platform, enabling the 1830 convenient and rapid integration of new features. It is the ultimate goal of 1831 the author to deliver a fully usable IMAP client aimed at advanced users who 1832 need to work with lots of e-mail in an effective way. Therefore, he plans to 1833 continue the maintenance of the project and develop new features in the years to 1834 come. After the GUI is matured, whole range of possibilities for new functions 1835 is open, from message encryption to supporting even experimental IMAP 1836 extensions. 1837 1838 Thanks to its unique design which employs both well-known software design 1839 patterns as well as new features offered by the modern Qt toolkit, \trojita 1840 certainly has the potential of becoming a competitive IMAP client on the open source 1841 desktop scene. 1842 1843 \begin{thebibliography}{99} 1844 \addcontentsline{toc}{chapter}{Bibliography} 1845 \bibitem{rfc-imap}Crispin, M.: Internet Message Access Protocol - Version 1846 4rev1, {\em RFC~3501}, March~2003, \\ 1847 {\tt http://tools.ietf.org/html/rfc3501} 1848 \bibitem{crispin-ten-commandments}Crispin, M.: Ten Commandments of How to 1849 Write an IMAP client, September~2006, Washington,\\ 1850 {\tt http://www.washington.edu/imap/documentation/commndmt.txt.html} 1851 \bibitem{rfc-2822}Resnick, P. (editor) et al.: Internet Message Format, {\em 1852 RFC~2822}, April~2001, \\ 1853 {\tt http://tools.ietf.org/html/rfc2822} 1854 \bibitem{rfc-2045}Freed, N., Borenstein, N.: Multipurpose Internet 1855 Mail Extensions (MIME) Part One: Format of Internet Message Bodies, {\em 1856 RFC~2045}, November~1996, \\ 1857 {\tt http://tools.ietf.org/html/rfc2045} 1858 \bibitem{rfc-2046}Freed, N., Borenstein, N..: Multipurpose Internet 1859 Mail Extensions (MIME) Part Two: Media Types, {\em RFC~2046}, 1860 November~1996, \\ 1861 {\tt http://tools.ietf.org/html/rfc2046} 1862 \bibitem{rfc-2047}Moore, K.: MIME (Multipurpose Internet Mail Extensions) 1863 Part Three: Message Header Extensions for Non-ASCII Text, {\em RFC~2047}, 1864 November~1996, \\ 1865 {\tt http://tools.ietf.org/html/rfc2047} 1866 \bibitem{rfc-multipart-related}Levinson, E.: The MIME Multipart/Related 1867 Content-type, {\em RFC~2387}, August~1998, \\ 1868 {\tt http://tools.ietf.org/html/rfc2387} 1869 \bibitem{rfc-threading}Crispin, M., Murchison, K.: Internet Message Access 1870 Protocol - SORT and THREAD Extensions, {\em RFC~5256}, June~2008, \\ 1871 {\tt http://tools.ietf.org/html/rfc5256} 1872 \bibitem{rfc-literalplus}Myers, J.: IMAP4 non-synchronizing literals, {\em 1873 RFC~2088}, January~1997, \\ 1874 {\tt http://tools.ietf.org/html/rfc2088} 1875 \bibitem{rfc-idle}Leiba, B.: IMAP4 IDLE command, {\em RFC~2177}, June~1997 1876 \bibitem{imap-vs-pop}Gray, T.: Message Access Paradigms and Protocols, 1877 September~1995, online at {\tt 1878 ftp://ftp.cac.washington.edu/mail/imap.vs.pop} 1879 \bibitem{qt-interview}Qt Software: The Interview Framework, \\ 1880 {\tt http://doc.trolltech.com/4.5/qt4-interview.html} 1881 \bibitem{qt-webkit}Qt Software: QtWebKit Module, \\ 1882 {\tt http://doc.trolltech.com/4.5/qtwebkit.html} 1883 \bibitem{std-tr1} ISO/IEC TR 19768, C++ Library Extensions 1884 \bibitem{qt-qprocess-sigpipe}QProcess could close the reading pipe, thus 1885 killing the child process with SIGPIPE, {\em a thread on the qt-interest 1886 mailing list}, {\tt 1887 http://lists.trolltech.com/pipermail/qt-interest/2009-May/\\006341.html} 1888 \bibitem{GoF}Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design 1889 Patterns: Elements of Reusable Object-Oriented Software, Boston: 1890 Addison-Wesley, 1995 1891 \bibitem{rfc-content-disposition}Troost, R., Dorner, S., Moore, K.: 1892 Communicating Presentation Information in Internet Messages: The 1893 Content-Disposition Header Field, {\em RFC~2183}, August~1997, \\ 1894 {\tt http://tools.ietf.org/html/rfc2183} 1895 \bibitem{rfc-content-id}Levinson, E.: Content-ID and Message-ID Uniform 1896 Resource Locators, {\em RFC~2111}, March~1997, \\ 1897 {\tt http://tools.ietf.org/html/rfc2111} 1898 \bibitem{qticonloader} Qt Software, February~2009, \\ {\tt 1899 http://labs.trolltech.com/blogs/2009/02/13/\\freedesktop-icons-in-qt/} 1900 \bibitem{xdg-icons}Dawes, R., The FreeDesktop Project: Icon Naming 1901 Specification v.~0.8.90, \\{\tt 1902 http://standards.freedesktop.org/icon-naming-spec/\\icon-naming-spec-0.8.90.html} 1903 \bibitem{dovecot}Dovecot, Secure IMAP server, \\ 1904 {\tt http://www.dovecot.org/} 1905 \bibitem{mime-torture-test}Crispin, M.: The MIME Torture Test Mailbox, \\ 1906 {\tt ftp://ftp.cac.washington.edu/imap/mime-examples/\\torture-test.mbox} 1907 \bibitem{alpine}Alpine Messaging System, \\ 1908 {\tt http://www.washington.edu/alpine/} 1909 \bibitem{pine-idle}Does pine make use of the IMAP IDLE command?, {\em 1910 discussion board}, \\ 1911 {\tt http://objectmix.com/pine/\\ 1912 206216-does-pine-make-use-imap-idle-command.html} 1913 \bibitem{mutt}The Mutt E-mail Client, \\ 1914 {\tt http://www.mutt.org/} 1915 \bibitem{kmail}KMail: Kontact Mail, \\ 1916 {\tt http://kontact.kde.org/kmail/} 1917 \bibitem{imap-keywords-flags}Melnikov, A.: Common IMAP keywords, {\em 1918 Expired Internet Draft}, \\ 1919 {\tt http://tools.ietf.org/html/draft-melnikov-imap-keywords-03} 1920 \bibitem{client-best-practices}Sirainen, T., Cridland, D. et al.: Best 1921 Practices for Implementing an IMAP Client, {\tt 1922 http://www.imapwiki.org/ClientImplementation} 1923 \bibitem{thunderbird}Mozilla Thunderbird, \\{\tt 1924 http://www.mozillamessaging.com/en-US/thunderbird/} 1925 \bibitem{mozilla-imap}Mozilla Developer Center: IMAP, \\ 1926 {\tt https://developer.mozilla.org/en/IMAP} 1927 \bibitem{mailody}Mailody, \\{\tt http://www.mailody.net/} 1928 \bibitem{rfc-mime-openpgp}Elkins, M. et al.: MIME Security with OpenPGP, 1929 {\em RFC~3156}, August~2001\\ 1930 {\tt http://tools.ietf.org/html/rfc3156} 1931 \bibitem{qt} Qt Reference Documentation, \\ 1932 {\tt http://doc.trolltech.com/4.5/} 1933 \bibitem{cmake} CMake Documentation, \\{\tt 1934 http://www.cmake.org/cmake/help/documentation.html} 1935 \bibitem{qwwsmtpclient} Wysota, W.: QwwSmtpClient released, May~2009, \\ 1936 {\tt 1937 http://blog.wysota.eu.org/index.php/2009/05/13/\\qwwsmtpclient-released/} 1938 \bibitem{modeltest} Qt Software, ModelTest, February~2008, \\ 1939 {\tt http://labs.trolltech.com/page/Projects/Itemview/Modeltest} 1940 \bibitem{kcodecs} The KDE Project: kdelibs, \\{\tt 1941 http://api.kde.org/4.x-api/kdelibs-apidocs/} 1942 \bibitem{rfc-msa}Gellens, R., Klensin, J.: Message Submission, {\em 1943 RFC~2476}, December~1998, \\ 1944 {\tt http://tools.ietf.org/html/rfc2476} 1945 \end{thebibliography} 1946 1947 \begin{appendix} 1948 \chapter{Contents of the CD} 1949 \label{cd-content} 1950 1951 The attached CD-ROM is an integral part of this thesis. The contents of the 1952 top-level {\tt trojita} directory is the following: 1953 1954 \begin{description} 1955 \item[bin] Compiled binaries of \trojita suitable for running on several 1956 Linux flavours 1957 \item[doc] A copy of each publicly available document referenced in the 1958 bibliography 1959 \item[doxygen] An automatically generated API documentation of \trojita 1960 \item[src] The source code of \trojita 1961 \item[thesis] A printable PDF file with the text of this thesis 1962 \end{description} 1963 1964 1965 \end{appendix} 1966 1967 \end{document}