没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Porting from Windows Mobile to Symbian OS v9.x
Paul Todd
Published by the Symbian Developer Network
Version: 1.0 – September 2008
1
INTRODUCTION................................................................................................................2
2 COMPARING MICROSOFT WINDOWS MOBILE AND SYMBIAN OS............................2
3 GETTING STARTED .........................................................................................................6
4 PORTING TIPS .................................................................................................................. 9
5 RELEASING THE APPLICATION................................................................................... 14
6 USEFUL TOOLS..............................................................................................................15
7 SUMMARY.......................................................................................................................15
8 GLOSSARY .....................................................................................................................16
9 TECHNICAL RESOURCES............................................................................................. 16
10 AUTHOR PROFILE .........................................................................................................17
2
1 Introduction
When someone familiar with developing for Microsoft Windows Mobile and the Microsoft Windows
platform moves to developing for Symbian OS, there is a period of uncertainty about where to start.
The APIs, tools and development environments are so dissimilar that it comes as quite a shock to
many.
The intent of this paper is to provide intermediate and advanced Windows CE/Windows Mobile
developers with an introduction to porting applications from Windows Mobile to Symbian OS v9.x.
2 Comparing Microsoft Windows Mobile and Symbian OS
Windows CE is the base platform for Microsoft mobile technologies. Windows Mobile and Pocket
PC
1
are customizations of the Windows CE platform and 90% of the APIs are the same across all
the platforms, including Windows desktop and server. Symbian OS is very similar to Microsoft
Windows CE in that it is a base platform which is customized by licensees and OEMs to produce
new platforms, such as UIQ and S60.
It is important to remember that Pocket PC devices typically have a keyboard and a touch screen.
Windows Mobile devices on the other hand are typically non-touch screen with either a keyboard
or keypad. These look a lot like UIQ and S60 respectively.
Note that we are not going to consider the impact of those features which are not present on both
the Windows Mobile and Symbian OS devices involved in the port (for example, Windows Mobile
devices may not all support GPS or the accelerometer APIs), or user experience issues such as
connectivity differences.
2.1 API History
It is difficult to directly compare the C-based Windows API with the C++ API of Symbian OS, and
therefore many of the examples in the paper will look at the MFC (Microsoft Foundation Classes),
as these align more naturally with Symbian C++.
Symbian OS was built with C++ from the start, even before Standard C++ was defined. This
means that the APIs are C++ classes and exception handling is the norm. Like current Microsoft
Windows releases, the APIs are Unicode enabled and work most efficiently with Unicode.
Both MFC and Symbian OS have a rich application layer where there is a lot of pre-wrapped
functionality, albeit using different API names and classes. This high level of abstraction makes
porting a challenge.
2.2 Resources
Symbian OS is a fully pre-emptive multi-threaded operating system and has support for all the
standard synchronization objects, such as critical sections and mutexes, that Microsoft Windows
does. The main difference is that in the Windows API these are handles, rather than being class-
based. In MFC there are classes which provide wrappers over the handles.
Typically, developers write their own data structures when using the Windows C-based API. MFC,
however, has a rich collection of type-safe data structure manipulation classes such as arrays,
maps and lists. Symbian OS has the same rich data structures, but in different classes. In Symbian
1
Recently renamed Windows Mobile Standard and Windows Mobile Professional.
3
OS, arrays are handled by either the RArray classes or one of the classes inherited from these
base classes. Maps are handled by the
RHashMap and RHashSet classes, and lists are handled by
the
TSglQue class. Both platforms now support the Standard Template Library to provide a
common library of data structures.
A key problem when moving from the Windows environment to Symbian OS is the handling of
strings. The C API uses the Standard C library for handling strings (
string.h), and MFC uses its
own string class called
CString. Symbian OS, however, has its own hierarchy of string objects and
interfaces called descriptors. Descriptors are one of the most fundamental classes in Symbian OS
and emphasis needs to be placed on learning them in depth, especially how they are used in place
of
CString. Due to their complex, inheritance-based nature, a full description of these classes and
their usage is beyond the scope of this paper; there are additional links to descriptor tutorials in the
‘Technical Resources’ section.
It is standard to use a client-server model for interaction with system services on Symbian OS. This
allows for controlled access to the service. Normally in Symbian OS, a connection is made to a
service and the connection is used to create other objects based on that session. Whilst in MFC a
CFile object would be created, in Symbian OS this requires a connection to the file server (RFs)
and then a file object (
RFile) to be opened on the file server session.
2.3 Application Structure
Most native code developers on Windows Mobile will be familiar with the Windows message
architecture. In Windows, there is a main message loop that waits for a message and, when one is
received, dispatches it to the correct window via
GetMessage()/DispatchMessage() and a
WndProc() handler for each type of registered window. This allows for asynchronous and
synchronous processing using the
PostMessage() and SendMessage() functions.
The equivalent on Symbian OS uses the active object framework, with the active scheduler
performing the same role as the message pump.
2
The active scheduler waits for an active object to
be signaled and when this happens the active scheduler calls the
RunL() method of the
appropriate active object. It is important to note that the active object framework is, by definition,
non-pre-emptive and requires the developer to break long running tasks into a number of states,
otherwise the thread may become unresponsive whilst processing a request. This should be very
familiar to most Windows developers and the same rule applies during the processing in the
WndProc() function of the window class instance.
MFC provides for a full application framework, with a model/view/controller type framework for the
user interface. This translates easily on to the Symbian OS UIKON UI framework which has
classes that are very similar in design to the MFC classes. There is a document object, an
Application UI (frame window) object, view and container (
CWnd) support. The MFC framework
itself is responsible for routing commands in the framework; much like the Application UI does for
Symbian OS and its licensees’ derivatives.
A list of MFC classes with their corresponding Symbian C++ and S60 APIs is shown in Table 1.
2
Fibers on the Microsoft Windows platform is similar to active objects. However, unlike Symbian OS, the
scheduling of the fibers is left to the application developer.
4
MFC Symbian S60 (Licensee extensions)
CWinApp CEikApplication CAknApplication
CDocument CEikDcoument CAknDocument
CFrameWnd CEikAppUi CAknAppUi
CDialog CEikDialog CAknForm/CAknDialog
CView MCoeView CAknView
CWindow RWindow/CCoeControl
CArray CArray/RArray/RPointerArray
CList TSglQue
3
CMap RHashMap
4
CCriticalSection RCriticalSection
CMutex RMutex
CSemaphone RSemaphore
CDatabase RDb/RDbNamedDatabase
CRecordset RDbView
CSocket RSocket
CInternetConnection RConnection
CInternetSession RHttpSession/RHttpTransaction
CRect TRect
CPoint TPoint
CSize TSize
CString HBufC/TBuf/RBuf
5
CTime TTime
CTimeSpan TTimeInterval….
CDC CGraphicsContext
6
CFont CFont AknFontUtils
CRgn RRegion
CBitmap CWsBitmap/CFbsBitmap CAknIcon
Table 1: MFC - Symbian class comparisons.
7
3
Note that this class always uses dynamically allocated objects.
4
Not part of the S60 SDK – it was omitted in error.
5
For more information on the descriptor architecture see the descriptors FAQ.
6
Symbian does not have handles to individual objects such as brushes; these are methods on the graphics context.
剩余16页未读,继续阅读
资源评论
leptonic
- 粉丝: 11
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功