• No results found

Avoiding Connection Timeouts

5.3 Windows Mobile demonstration application

5.3.4 Avoiding Connection Timeouts

During the IDLE command the client does not send any commands to the server and the server only sends data if message or mailbox information changes. This means the connection might remain idle for a long period of time which can lead to timeouts. As stated in [22] there are mainly two timeouts which may occur:

• IMAP server timeout: Typically occurs after 30 minutes with no activity.

• NAT Gateway timeout: Most mobile devices access the Internet through a device operated by the mobile service provider called a NAT (Network Address Transla-tion) gateway. These will typically time out an idle connection after 15 minutes.

To avoid this problem the IDLE command should be re-issued every 14:th minute. This is the way it is solved in the demonstration application.

Chapter 6

Results

After reviewing the work flow in detail in the previous chapter the final result will be described in this chapter. Section 6.1 describes all the implemented functionality of the platform independent library (TfwLib) and the mail library (LemonadeLib), while section 6.2 demonstrates the demonstration application and its features.

6.1 System

The resulting system is displayed in figure 6.1. As seen the three main components outlined in section 2.4 are in place, namely TfwLib, LemonadeLib and the demonstration application running on Windows Mobile.

L e m o n a d e L i b

T f w L i b

W i n d o w s

M o b i l e S y m b i a n F u t u r e p l a t f o r m

W i n d o w s M o b i l e d e m o a p p l i c a t i o n

S y s t e m p l a t f o r m A p p l i c a t i o n

P l a t f o r m i n d e p e n d e n t s y s t e m l i b r a r y M a i l l i b r a r y

Figure 6.1: System overview

41

Apart from encapsulating simple data types TfwLib currently supports the following complex data types and system functionality, making them truly platform independent:

• ByteBuffer: Dynamic byte buffer

• String: UNICODE and ASCII supporting string class

• Vector: Generic item container

• Map: Generic container for string - item pairs

• Socket: Socket communication supporting SSL3 and TLS1

• File: File access

Using the functionality given by TfwLib the implementation of LemonadeLib enabled the following IMAP functions:

• Connect to IMAP server, optionally using encrypted transfers via SSL/TLS

• Login to IMAP server either using plain text login or PLAIN authentication mech-anism

• Select INBOX folder

• Fetch mail envelopes

• Fetch mail flags

• Fetch first plain text part in mail

• Enter IDLE mode, receiving notifications from server without polling

• Logout from IMAP server

• Disconnect from IMAP server

To fully understand what the first plain text part of a mail is, a look on the mail structure found in appendix A.2 is beneficial. The mail structure given there corresponds to the mail message example given in appendix A.1. As seen the message has two parts, one plain text part and one multipart part. Of course the first plain text part is the one labeled 1, however even if part 2 also would have been a plain text part only part 1 would have been fetched.

6.2 Windows Mobile demonstration application

The Windows Mobile demonstration application was developed to demonstrate all the current features of LemonadeLib. In this section a short introduction to the application will be given along with an illustrated user guide.

In figure 6.2 the welcome screen along with the main graphical user interface (GUI) for the application is shown. As seen the GUI consists of a top bar for checking message

6.2. Windows Mobile demonstration application 43

Figure 6.2: Demonstration application welcome screen

flags and expunging messages and a bar on the bottom for configuring and logging in to an account as well as navigating messages using the arrow buttons. Most of the space is however occupied by the message list.

Figure 6.3: Configure and connect to IMAP server

To access the Account Configuration seen in the left image of figure 6.3 the Config button in the main GUI is clicked. By filling in the settings and clicking OK the settings are saved in a file and the program returns to the main GUI. Clicking Login will display the password prompt seen in the right most picture in figure 6.3. After entering the correct password and clicking OK the client will connect and login to the specified IMAP server and fetch the initial window of messages.

After a successful login the message list will be populated with messages as seen in figure

Figure 6.4: Demonstration application GUI

6.4. The message list contains at most twelve messages and presents Subject, Sender and Date of those messages. The left most column allows for selecting of messages which al-lows marking of message flags by selecting the appropriate flag (Delete/Undelete/Read/Unread ) and clicking Mark:. Examples of this can be seen in figure 6.5 together with the mes-sage icons indicating the current state of mesmes-sages (unread/deleted/answered). To se-lect/deselect all messages at once the left most column header is clicked.

Figure 6.5: Setting message flags

The numbers displayed in the middle of the bottom bar shows the number of the first message displayed in the list along with the total number of messages in the mailbox.

If more than twelve messages were available in the mailbox the arrow buttons would be used to display the next/previous set of messages and the number information would be

6.2. Windows Mobile demonstration application 45

updated accordingly.

The IDLE command is automatically initiated after any other command, such as suc-cessful login or flag marking, if it is supported by the current IMAP server. The I in the left most message list column header indicates that IDLE is active and the client will be notified immediately of mailbox and message updates. In the leftmost picture of figure 6.6 such a notification is displayed.

Figure 6.6: New message arrival and preview

By double clicking any message, in this case the newly arrived message, the first plain text part of the message is displayed (see middle picture of figure 6.6). When closing the message window by clicking OK the program returns to the main window as seen in the right most picture of figure 6.6.

To terminate the application OK is clicked. Terminating the application will not ex-punge any messages flagged for deletion. Expunging is only accomplished by clicking Expunge.

Chapter 7

Discussion

The platform independence was achieved through the application of well known design patterns along with some clever programming techniques. This proved to be a very good approach and since design patterns and the ideas presented in this thesis are highly generic they could very well be applied to other platforms and other projects.

At first hand a platform independent approach could seem unnecessary, especially for projects which at first targets only one platform, however building the project using a platform independent code base could prove beneficial in the end. The time spent on developing the code base does not pay off by itself but when finished it can be used for a multitude of different projects decreasing the code duplication necessary during porting.

Since no application was developed for the Symbian environment the LemonadeLib func-tionality is not thoroughly tested on that platform. Despite this fact the funcfunc-tionality has been tested using small test programs in the Symbian emulator and the results there have been satisfactory. The limited amount of device testing on both Windows Mobile and Symbian along with the fact that no strict test protocols were set up certainly im-plies that the functionality needs to undergo further testing. However as long as the circumstances, such as usage and network connection, remains reasonable the presented solution works well for its intended use.

A related issue, which was addressed in section 5.1.5, is the way errors are handled within TfwLib and its dependencies. Although there is an error handling strategy it is not widely used in practice. For most system functions an error is reported through a return value as well as an error in the error store. The error in the error store is not checked in most situations and is therefore redundant in most cases. Its usage could be to present a detailed description to the user of what went wrong but most often the end user is not very interested what the underlying reason was, only the fact that the requested operation did not perform as expected. There is also a situation where no return values are available but the error store could be populated with an error, and that is within object constructors. In these situations the error store is still not checked, instead the error will present itself on the next function call of that object. Overall the error handling for the entire project is optimistic, meaning that error conditions are not checked as frequently as desirable.

47

Performance has been neglected in favor of functionality within this solution. Although no major problems have occurred due to this fact some problems have been observed during parsing of server responses. One test included a mail which had around 200 recipient addresses and when fetching its envelope the parsing was extremely slow. Since all operations are synchronous this also meant the GUI froze during processing. The parsing did complete eventually and usage could continue but performance issues should be considered during any future development.

Chapter 8

Conclusions

As stated in section 2.2 the goals for this thesis were:

1. Create a platform independent code library for handheld devices in C++ encapsulating system functions such as file handling, socket com-munication and data types.

2. Use the platform independent code library to implement a mail library for handheld devices supporting the Lemonade Profile.

Both these objectives have been achieved, however the Lemonade Profile implementation only realizes the IDLE capability.

It turned out that creating a platform independent code library required a considerable amount of effort, both in design and implementation. The design process however was simplified by studying suitable design patterns such as the Abstract Factory and Bridge design pattern. Turning the design patterns into actual code revealed some practical problems, such as using templates along with virtual functions. The differences in behaviour between the two platforms, like synchronous versus asynchronous function calls, also posed a big problem since TfwLib needed to behave the same no matter which platform it was running on. Overall the design chosen for TfwLib worked really well and it now offers a platform independent code base which is easily customized and expanded.

By having the platform independent code base in place the task of writing a platform independent mail library was simply a task of using available tools when realizing the IMAP and Lemonade Profile standards. Although time consuming there were not many problems along the way which further emphasizes the potential for the code base.

8.1 Future work

Considering the positive results of this project there are various ways to continue the work. For TfwLib the following objectives would be of interest in the future:

49

• Extend its functionality

• Extend it onto another platform

The current functionality of TfwLib is highly restricted for solving the specified problem, although its components have been designed in a generic way to allow extendability and usage in various ways. It would be interesting to extend this functionality to incorporate more system functions but some areas are better left outside such a library. One of those things could be the GUI functionality since it is one area where platforms are very different. The effort needed to create such a solution would probably be to high and the solution itself would most likely be very complicated and hard to manage.

Since TfwLib is designed with a future platform expansion in mind it would be in-teresting to expand the library onto another platform. Since LiMo uses C++ and its application programming interface (API) specification is to be released soon this is def-initely a candidate for such an expansion.

The Lemonade Profile has very much potential for mobile email and the implemented LemonadeLib could be extended in the following ways:

• Making it fully IMAP4rev1 standard compliant

• Add SMTP support

• Add MIME support

• Implement the missing pieces of the current Lemonade Profile

• Add functionality according to the draft for the new Lemonade Profile [9]

The functionality of the current Lemonade Profile offers many benefits for mobile email and a complete implementation would offer an interesting alternative for mobile email users. However since the coverage of fully compliant Lemonade Profile servers is still very low the question is how many users actually could benefit from such an application.

References

[1] Adobe Systems. Develop on Adobe AIR with HTML and JavaScript. http://labs.

adobe.com/technologies/air/develop_ajax.html, 2007. [Online; accessed 28-September-2007].

[2] Andrei Alexandrescu. Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley Professional, August 2001.

[3] Chris Ambrosio. 2008 Handset Outlook: Smart Phones at Heart of OEM Strategies. http://www.strategyanalytics.net/default.aspx?mod=

ReportAbstractViewer&a0=3587, 2007. [Online; accessed 22-january-2008].

[4] Steve Babin. Developing Software for Symbian OS. Wiley, 2006.

[5] Wolfgang Blochinger and Wolfgang K¨uchlin. Cross-Platform Development of High Performance Applications Using Generic Programming. In T. Gonzales, editor, Proc. of the IASTED Intl. Conference Parallel and Distributed Computing and Sys-tems (PDCS 2003), volume 2, pages 654–659, Marina del Rey, CA, USA, November 2003. ACTA Press.

[6] Jon Box and Dan Fox. An Introduction to P/Invoke and Marshaling on the Microsoft .NET Compact Framework. http://msdn2.microsoft.com/en-us/

library/aa446536.aspx, 2003. [Online; accessed 31-january-2008].

[7] Bernd Bruegge and Allen H. Dutoit. Object-Oriented Software Engineering: Using UML, Patterns and Java, Second Edition. Prentice Hall, 2003.

[8] Canalys. APAC smart mobile device market hits new peak. http://www.canalys.

com/pr/2007/r2007051.htm, 2007. [Online; accessed 22-january-2008].

[9] D. Cridland, A. Melnikov, and S. Maes. The Lemonade Profile – draft-ietf-lemonade-profile-bis-07.txt. http://tools.ietf.org/html/

draft-ietf-lemonade-profile-bis-07, 2007. [Online; accessed 04-february-2008].

[10] M. Crispin. INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1.

http://www.ietf.org/rfc/rfc3501.txt, 2003. [Online; accessed 01-february-2008].

[11] Martin de Jode. Symbian on Java. http://www.symbian.com/symbianos/

standards/standards.html, 2004. [Online; accessed 01-october-2007].

51

[12] DotGNU team. DotGNU Portable.NET. http://dotgnu.info/pnet.html, 2007.

[Online; accessed 25-September-2007].

[13] Double Precision, Inc. Courier-IMAP. http://www.courier-mta.org/imap/, 2007. [Online; accessed 31-january-2008].

[14] Dovecot Team. Dovecot. http://www.dovecot.org/, 2008. [Online; accessed 31-january-2008].

[15] Alexandre Duret-Lutz, Thierry G´eraud, and Akim Demaille. Design Patterns for Generic Programming in C++. In Proc. of the 6th USENIX Conference on Object-Oriented Technologies and Systems (COOTS ’01), San Antonio, Texas, USA, February 2001. USENIX.

[16] Ecma International. Standard ECMA-335, 4th Ed. http://www.

ecma-international.org/publications/standards/Ecma-335.htm, June 2006. [Online; accessed 05-October-2007].

[17] Ferris Research. Industry Statistics. http://www.ferris.com/?page_id=1078, 2008. [Online; accessed 22-january-2008].

[18] Free Software Foundation, Inc. GNU General Public License. http://www.gnu.

org/copyleft/gpl.html, 2007. [Online; accessed 11-February-2008].

[19] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns:

Elements of Reusable Object-Oriented Software. Addison-Wesley Professional, April 1995.

[20] hMailServer Team. hMailServer – Free email server for Microsoft Windows. http:

//www.hmailserver.com/, 2008. [Online; accessed 31-january-2008].

[21] Steven Holzner. Java 2 - Black Book. The Coriolis Group, June 2001.

[22] Isode. IMAP IDLE: The best approach for ’push’ email. http://www.isode.com/

whitepapers/imap-idle.html, 2006. [Online; accessed 06-february-2008].

[23] Isode. LEMONADE Profile: The Key Standard for Mobile Messaging. http://

www.isode.com/whitepapers/lemonade-profile.html, 2007. [Online; accessed 25-january-2008].

[24] Michael Kircher. Pattern-Oriented Software Architecture, Volume 3: Patterns for Resource Management. John Wiley & Sons Inc., Hoboken, NJ, USA, 2005.

[25] J. Klensin. Simple Mail Transfer Protocol. http://www.ietf.org/rfc/rfc2821.

txt, 2001. [Online; accessed 01-february-2008].

[26] James F. Kurose and Keith W. Ross. Computer Networking: A Top-Down Approach Featuring the Internet. Pearson Education, 2005.

[27] LiMo Foundation. What is the Platform. http://www.limofoundation.org/

what-is-the-platform.html, 2008. [Online; accessed 14-january-2008].

[28] S. Maes and A. Melnikov. Internet Email to Support Diverse Service Environments (Lemonade) Profile. http://www.ietf.org/rfc/rfc4550.txt, 2006. [Online; ac-cessed 25-january-2008].

REFERENCES 53

[29] Mono team. Supported Platforms - Mono. http://www.mono-project.com/

Supported_Platforms, 2007. [Online; accessed 25-September-2007].

[30] Laurence Moroney. Getting Started with Silverlight. http://silverlight.net/

content/GetStarted.aspx, 2007. [Online; accessed 28-September-2007].

[31] Tommy Niittula. Windows Mobile-programmering. Studentlitteratur, Lund, 2005.

[32] Open Handset Alliance. Android. http://www.openhandsetalliance.com/

android_overview.html, 2007. [Online; accessed 14-january-2008].

[33] Open Mobile Alliance Ltd. OMA Email Notification V1.0. http:

//cms.openmobilealliance.org/Technical/release_program/emn_v10.aspx, 2007. [Online; accessed 11-February-2008].

[34] Gabriel Dos Reis and Mat Marcus. Proposal to add template aliases to C++, document no. WG21/N1449 J16/03-0032. www.open-std.org/jtc1/sc22/wg21/

docs/papers/2003/n1449.pdf, 2003. [Online; accessed 30-january-2008].

[35] rPath, Inc. Appliance:Port25 Appliance. http://wiki.rpath.com/wiki/

Appliance:Port25_Appliance, 2007. [Online; accessed 31-january-2008].

[36] Dan Saks. Reducing Run-Time Overhead in C++ Programs. In Proc. of the Embedded Systems Conference, San Francisco, CA, USA, 2002.

[37] ISO/IEC JTC1 SC22. ISO/IEC TR 18015:2006 – Technical Report on C++

Performance. http://standards.iso.org/ittf/PubliclyAvailableStandards/

c043351_ISO_IEC_TR_18015_2006(E).zip, 2006. [Online; accessed 06-february-2008].

[38] Douglas C. Schmidt. Wrapper Facade: A Structural Pattern for Encapsulating Functions within Classes. In C++ Report, volume 11(2). SIGS, February 1999.

[39] SEVEN. SEVEN | GET IT. http://www.seven.com/get_it/europe/sweden/

index.html, 2008. [Online; accessed 23-january-2008].

[40] Maarten Struys. Using COM Interop in .NET Compact Framework 2.0. http://

msdn2.microsoft.com/en-us/library/aa446497.aspx, 2005. [Online; accessed 31-january-2008].

[41] Sun Microsystems. JavaFX. http://www.sun.com/software/javafx/index.jsp, 2007. [Online; accessed 28-September-2007].

[42] RFC Editor Team. Search the RFC Index. http://www.rfc-editor.org/

rfcsearch.html, 2008. [Online; accessed 01-february-2008].

[43] Julian Templeman and David Vitter. Visual Studio .NET: The .NET Framework - Black Book. The Coriolis Group, January 2002.

[44] Wikipedia. .NET Framework — Wikipedia, The Free Encyclopedia. http://en.

wikipedia.org/w/index.php?title=.NET_Framework&oldid=159944983, 2007.

[Online; accessed 24-September-2007].

[45] Paul Yao and David Durant. .NET Compact Framework Programming with Visual Basic .NET. Pearson Education, 2004.

Appendix A

Example MIME message

A.1 Message source

Date: Thu, 20 Dec 2007 09:16:53 +0100 From: Someone <[email protected]>

MIME-Version: 1.0

To: Someone Else <[email protected]>

Subject: A multipart example

Content-Type: multipart/alternative;

boundary="unique-boundary-1"

This is a multi-part message in MIME format.

--unique-boundary-1

Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit

... Some text in ISO-8859-1 character set appears here ...

--unique-boundary-1

Content-Type: multipart/related;

boundary="unique-boundary-2"

--unique-boundary-2

Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

</head>

<body bgcolor="#ffffff" text="#000000">

... Some html code appears here ...

55

</body>

</html>

--unique-boundary-2 Content-Type: image/gif

Content-Transfer-Encoding: base64

... Base64 encoded GIF-image appears here ...

--unique-boundary-2--

--unique-boundary-1--A.2 Message structure

HEADER // Message headers

1.MIME // text/plain

1 // First plain text part

2.MIME // multipart/related 2.1.MIME // text/html

2.1 // HTML part

2.2.MIME // image/gif

2.2 // GIF-image

Appendix B

Library Usage

The project consists of four code libraries:

• TfwLib (Windows Mobile and Symbian compiled)

• TfwWMInt (Windows Mobile integration)

• TfwSymInt (Symbian integration)

• LemonadeLib (Windows Mobile and Symbian compiled)

TfwLib is combined with the appropriate platform integration library, which means either TfwWMInt or TfwSymInt, to form the platform independent code base. Lemon-adeLib relies completely on this code base meaning that it will be compiled for the target platform by linking it to TfwLib and the appropriate integration library.

For projects wishing to utilize LemonadeLib it must link to LemonadeLib as well as the correct code base library. In addition to this when using TfwLib along with its integration for the Symbian platform in a project, that project needs to include the following libraries for it to work:

• estlib

• esock

• insock

• efsrv

• bafl

• euser

• securesocket

No matter which the target platform is the project must also add the correct include paths for the libraries.

57

Appendix C

Known Issues

C.1 Windows Mobile

One issue on Windows Mobile which is not resolved regards connections using SSL/TLS.

One issue on Windows Mobile which is not resolved regards connections using SSL/TLS.

Related documents