Symbian Mobile Programming: G.Rossetti & A.Schneider HTI Biel 2005 - 2007
Symbian Mobile Programming: G.Rossetti & A.Schneider HTI Biel 2005 - 2007
This course is based on our collective experiences over the last years, we have
worked on Symbian mobile programming. We are indebted to all the people,
that made our work fun and helped us reaching the insights that fill this course.
We would also like to thank our employers for providing support and accommo-
dation to teach this lecture.
These are Swisscom Innovations and SwissQual AG.
CONTENTS
Contents
1 Course Overview 1
1.1 Lecturers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 Course contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Introduction to Symbian 3
2.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 EPOC OS Releases 1-4 . . . . . . . . . . . . . . . . . . . 3
2.1.2 Symbian 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.3 Symbian 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.4 Symbian 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.5 Symbian 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.6 Symbian 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Symbian OS Architecture . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Instruction Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 IDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 SDKs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.6 Useful links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6.1 Symbian OS manufacturer . . . . . . . . . . . . . . . . . . 8
2.6.2 Symbian OS licensees . . . . . . . . . . . . . . . . . . . . 8
2.6.3 3th party links . . . . . . . . . . . . . . . . . . . . . . . . 8
2.7 Lecture Focus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Framework 9
3.1 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Launch sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Basic Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.1 Project File . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.2 Source- and Header-Files . . . . . . . . . . . . . . . . . . 11
3.3.3 Building Project . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.4 Creating Installation File . . . . . . . . . . . . . . . . . . 17
4 Symbian Types 19
4.1 Class Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.1.1 T Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.1.2 C Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.1.3 R Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.4 M Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2 Numeric Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 Descriptors (Strings) . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3.1 Buffer descriptors . . . . . . . . . . . . . . . . . . . . . . . 21
4.3.2 Heap descriptor . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.3 UTF16 ←→ UTF8 . . . . . . . . . . . . . . . . . . . . . . 22
4.3.4 Integer ←→ String . . . . . . . . . . . . . . . . . . . . . . 22
4.4 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4.1 Fixed Size Arrays . . . . . . . . . . . . . . . . . . . . . . . 23
4.4.2 Dynamic Arrays . . . . . . . . . . . . . . . . . . . . . . . 23
I
CONTENTS
7 GUI Components 32
7.1 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.2 Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
8 Multitasking 34
8.1 Threads, Multitasking and Preemption . . . . . . . . . . . . . . . 34
8.2 Acvtive Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
9 GSM API 38
9.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
9.2 ETel Implementation . . . . . . . . . . . . . . . . . . . . . . . . . 38
9.2.1 RPhone . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
9.2.2 RLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9.2.3 RCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9.3 Using ETel client API . . . . . . . . . . . . . . . . . . . . . . . . 39
9.3.1 Initialising basic objects . . . . . . . . . . . . . . . . . . . 40
9.3.2 Setting up a call . . . . . . . . . . . . . . . . . . . . . . . 40
9.3.3 Listening for incoming call . . . . . . . . . . . . . . . . . . 41
9.3.4 Answering incoming call . . . . . . . . . . . . . . . . . . . 41
9.3.5 Observing call state changes . . . . . . . . . . . . . . . . . 41
9.3.6 Hangig up a call . . . . . . . . . . . . . . . . . . . . . . . 42
11 Bluetooth 46
11.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
11.2 Symbian OS Bluetooth architecture . . . . . . . . . . . . . . . . 46
11.3 Bluetooth Application development . . . . . . . . . . . . . . . . . 47
11.3.1 Bluetooth Protocols . . . . . . . . . . . . . . . . . . . . . 47
11.3.2 Bluetooth Profiles . . . . . . . . . . . . . . . . . . . . . . 47
11.3.3 Service Advertisement and Service Discovery . . . . . . . 48
11.4 Basic Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
II
LIST OF FIGURES
A.4.1 Codewarrior . . . . . . . . . . . . . . . . . . . . . . . . . . 4
A.4.2 Carbide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
List of Figures
1 Symbian OS Architecture . . . . . . . . . . . . . . . . . . . . . . 6
2 Framework UML . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 ViewApp Example . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4 DrawingApp Example . . . . . . . . . . . . . . . . . . . . . . . . 31
5 NotesApp Example . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6 QueryApp Example . . . . . . . . . . . . . . . . . . . . . . . . . 33
7 GSM Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8 ETel related classes . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9 Call state machine . . . . . . . . . . . . . . . . . . . . . . . . . . 39
10 Bluetooth Architecture . . . . . . . . . . . . . . . . . . . . . . . . 46
11 Bluetooth state machine . . . . . . . . . . . . . . . . . . . . . . . 1
III
1 COURSE OVERVIEW
1 Course Overview
1.1 Lecturers
• Gian Rossetti, Solothurn
[email protected] , +41794671138
SW Engineer, Swisscom Innovations
• Adrian Schneider, Thun
[email protected]
Symbian SW Engineer, formerly working at SwissQual AG
1.2 Examples
Example projects are available in a protected web directory:
url : http://www.eidelen.ch/SymbianMobile/load/
user : symbianer
passw : mobilehti
1.3 Motivation
Our motivation is to provide the necessary impulse, which awakes your own
interests to become a Symbian expert. We hope, programming Symbian will
inspire you, as it inspired us at that time.
1
1 COURSE OVERVIEW
21-22 to be defined
23-24 Project
25-26 Project
27-28 Project
2
2 INTRODUCTION TO SYMBIAN
2 Introduction to Symbian
2.1 History
2.1.1 EPOC OS Releases 1-4
1980, Psion Software was founded by David Potter. He was physics lecturer, no
Wizard.
In between 1991 and 1998 Psion released several devices based on the EPOC16
architecture (also known as SIBO / EPOC Releases 1-3). 1997 EPOC Release
4 (ER4) was introduced based on a real 32-bit architecture (EPOC32). In 1998,
Symbian Ltd. had been formed as a partnership between Ericsson, Nokia, Mo-
torola and Psion, to explore the convergence between PDAs and mobile phones.
2.1.2 Symbian 5
EPOC Release 5 was released in 1999. A rich suite of application engines, in-
cluding contacts, schedule, browsing, voice, office, utility and system control
has been presented. It’s first devices were the Ericsson MC218 and Ericsson
R380. These were not ’open’ phones, software could not be installed. Later the
netBook and the netPad were introduced, using ER5U (U = Unicode), which
had been presented in 2000. Developers can make use of Symbian OS 5 SDKs
and SDK extensions to target devices in C++ and OPL1 .
2.1.3 Symbian 6
The first ’open’ Symbian OS phone, the famous Nokia 9210, was released on
Symbian 6.0. A C++ SDK including development tools and an emulator based
on the Crystal GTK was available for free download. Using MS Visual Studio
6.0 as IDE, development has been facilitated for Nokia 9210 communicator se-
ries. Symbian 6 was conform to mobile telephony protocols, such as 2G voice
and circuit-switched data, 2.5G packet-switched data and SMS. Communication
protocols such as TCP, IPv4, GPRS, WAP, Bluetooth, IrDA, and serial support
were covered as well as a large set of features, like email (POP3, IMAP4, SMTP
and MHTML), Fax, encryption, certificate management, secure communications
protocols (HTTPS, WTLS and SSL), certificate-based application installation,
OBEX, a multimedia server with support for several audio and image formats
and the extensions for PersonalJava 3.0 have been introduced.
The Nokia 7650, 3650 imaging phones and the forthcoming N-Gage mobile game
deck are based on Symbian 6.1 and introduced the Series60 generation. Symbian
devices are now sold on th mass market. Borland and Metrowerks announce
plans to deliver C++ tools for Series 60. Metrowerks are extending the capa-
bility of their existing CodeWarrior Development Tools for Symbian OS.
2.1.4 Symbian 7
The new Symbian OS 7 enabled devices, developed for 2.5G as well as 3G net-
works worldwide, opened a wide range of simple, attractive, revenue-generating
applications and services. The Nokia 6600 is the most famous Series60 device,
produced for Symbian 7.0. It was announced long before shipped effectively.
Symbian 7.0 covers a comprehensive integrated messaging environment using
1 OPL is an interpreted language targeted at Symbian OS phones. OPL is an entry-level
development tool that enables rapid development of applications. OPL consists of phone-side
code (runtime and translator) and PC-side code (translator and tools)
MMS, EMS and SMS, support for a full web browser, shared access to screen,
keyboard, fonts and bitmaps, audio recording and playback, an API for graph-
ics acceleration and streaming functionality, extended communication protocols
such IPv6 (with IPSec), USB support, over the air (OTA) data synchronization
using SyncML and PIM data synchronization, the WIM framework, Bluetooth
v1.1 and additional support for Java (J2ME MIDP 1.0 and PersonalJava 3.0
with JavaPhone 1.0 options). Symbian OS v7.0s is a fit-for-purpose platform
for the 3G market, offering new functionality to enable 3GPP compliance and
the delivery of 3G services.The major new features of Symbian OS v7.0s are:
Lightweight multi-threaded multimedia framework, support for W-CDMA and
Java MIDP 2.0. Java developers developing PersonalJava or J2ME applications
(MIDlets) can use Sun’s SDK, and the Wireless Toolkit (WTK), both of which
are available for free download.
Nevertheless with the release of Symbian OS v7.0 in 2003, the OS was split into
two big subcategories:
• Series60
• UIQ
UIQ Sony Ericsson P800, P900, P910, and P990 smartphones are based on the
this framework. Originally UIQ was an abbreviation of ’User Interface Quartz’.
The UI is designed and optimized for touchscreen displays. As developing for
UIQ is just supported using the CodeWarrior IDE, (no SDK’s available for MS
Visual Studio 6.0) C++ developers will need to obtain CodeWarrior Develop-
ment Studio for Symbian OS.
S60 The Series60 UI just supports conventional display and user interaction.
Other to the UIQ SDK, the Series60 SDK contains per default additional mul-
timedia APIs, which in turn is of great interest among developers. Both IDEs,
MS Visual Studio 6.0 and Metrowerks CodeWarrior IDE can be used to target
Series60 devices.
When developing Symbian applications, it’s best to separate the UI and ap-
plication logic. This limits the amount of code that needs to be ported between
platforms. In fact there is a third subcategory, the Nokia communicator series,
which used from it’s beginning a separate UI framework (Crystal GTK). As this
generation of devices did never target the mass market, it has been buried in
oblivion for a while. At a later date it will become the Series80.
In 2004, Psion sold its stake in Symbian.
2.1.5 Symbian 8
Symbian OS v8.0 is ready for the 3G market with support for WCDMA (3GPP
R4), GSM circuit switched voice and data (CSD, EDGE ECSD) and packet-
based data (GPRS and EDGE EGPRS), CDMA (IS-95 and cdma2000), sim-
ply a UMTS enabled 3G phone. It provided also the SIM, R-UIM and UICC
Toolkit. Enhanced features like OBEX for exchanging appointments (vCalen-
dar) and business cards (vCard), the latest wireless Java standards MIDP 2.0,
CLDC 1.1, additional JSR2 namely Mobile Media API (JSR 135), Bluetooth
(JSR 082), Wireless Messaging (JSR 120), the SIM Application Toolkit class
3, QoS on GPRS and UMTS networks, SyncML DM 1.1.2 compliance, and se-
cure protocols such TLS have been added. Symbian OS v8.0, first shipped in
2004, offered the choice between two different kernels (EKA1 / EKA2). The
2 Java Specification Request: An J2ME runtime can additionally to its specification (f.ex.
MIDP2.0) include further JSR implementations, which can be considered as API extensions
kernels behave very similar from user-side, but are internally quite different.
EKA1 maintains compatibility with old device drivers, whereas EKA2 offered
advantages such as single-chip phone support and a hard real-time capability.
Unfortunately EKA2 kernel version did not ship until Symbian OS v8.1b.
Symbian OS v8.1. was basically a cleaned-up version of 8.0, available as 8.1a
and 8.1b (EKA1 / EKA2). The 8.1b version was popular among Japanese
phone companies (DoCoMo OCD) desiring the realtime support but not al-
lowing open application installation. Symbian 8.1 covered support for CDMA
circuit switched voice, data and packet-based data (IS-95 and 1xRTT), Blue-
tooth v1.2, as well as additional JSRs such as the Mobile 3D Graphics API (JSR
184) and Personal Information Management and File GCF APIs (JSR 075). It
provided support for USB client specification v2.0 (full speed), IPSec and VPN
client support, as well as further Bluetooth profiles. In 2004, the first worm
for Symbian phones was developed. ’Cabir’ uses Bluetooth to spread itself to
phones in its neighborhood.
2.1.6 Symbian 9
Symbian OS v9.0 was just used for internal Symbian purposes and discontinued
in 2004.
In 2005, Symbian OS v9.1 was announced. The new ARM EABI binary model
conditions developers to rebuild their applications and possibly to re-code some
parts of the application. A completely new security model has been introduced.
The Nokia N91 was probably the first Symbian OS 9.1 device on the market.
Symbian OS has generally maintained reasonable binary compatibility. The OS
was compatible from ER1 to ER5, then from 6.0 to 8.1b. Substantial changes,
related to the security model, were needed for 9.0, but this should be a unique
event. The Symbian OS is now better protected than ever. It might even be
an overkill in some way, as development for Symbian devices has been compli-
cated. The new security model forces developers to submit their application to a
TestHouse, where the application will be tested against a set of security and ca-
pability tests. If all tests are successfully approved, the application will be signed
digitally by ’SymbianSigned’. The new Symbian OS contains on one hand an
OS architecture that allows applications to have a protected data store, which
is well separated among each other and on the other hand a proactive defense
mechanism, based on granting and monitoring application capabilities through
SymbianSigned certification. Symbian OS v9.1 provides additional support for
WCDMA (3GPP R4 and R5 IMS), CDMA network roaming, third party OTA
API, NAM programming mode, CDMA SMS stack, NAI handset identification,
interfaces to enable Mobile IP, bridge and router gateway modes of operation,
support for PPP and Mobile IP CDMA specifications, Connectionless WSP
and WAP Push, OMA DM 1.1.2 compliance, OMA Client provisioning v1.1,
email with support for POP3, IMAP4, MIME attachments, SMTP, SMTP au-
thentication, communication protocols such MSCHAP v2 and RTP, HTTP 1.1,
Pipelining, Multihoming, Cryptographic algorithms (DES, 3DES, RC2, ARC4,
RC5 and AES), X509 Certificate management and the Bluetooth stereo headset
support.
Symbian OS V 9.2 has just been released, it contains support for RTCP, SIP,
an additional JSRs namely JTWI (JSR 185), Content Handling API (JSR 211),
Smart Card access APIs, OMA Device Management v1.2 and OMA Client pro-
visioning v1.1 compliance and Bluetooth v2.0
tion is compiled for ARM4 it can only call function, that are itself compiled for
ARM4 or ARMI. ARM4 builds run faster than THUMB builds.
ARMI is a 32-bit instruction set with interworking for ARM based proces-
sors. An application complied using the ARMI instruction set can call any
other function. It is entirely compiled as ARM yet still able to support installed
applications compiled as Thumb. In our course ARMI is the recommended de-
fault build format for compatibility purposes.
2.4 IDEs
There are three IDEs for Symbian programming. First of all, the well known
MS Visual Studio C++ 6.0, secondly Metrowerks CodeWarrior for Symbian OS
and recently released Nokia Carbide. Visual Studio C++ does on one hand not
cover all needed functionalities and building tools (just the very basic ones) and
on the other hand it’s strictly restricted to Nokia S60 devices. Therefore VC++
will not be further discussed.
For a long time Codewarrior was the only IDE, which could handle all Symbian
SDKs. It seems that Codewarrior is not being further enhanced, while Carbide
is a new generation of mobile development tools from Nokia. Carbide allows
developing software for multiple platforms and multiple languages. Based on
the open Eclipse framework, Carbide can be extended with other eclipse plug-
ins and products. As this course has been written, before Carbide was released,
you will find some hints for Codewarrior developers inside this script. The goal
for long terms is to alter this script tailored for Carbide developers
2.5 SDKs
Nokia SDKs support development using all IDEs, Visual Studio, CodeWarrior
and Carbide. The SDKs provide binaries and tools to facilitate development,
building and deployment for Symbian OS devices, including a PC-based emu-
lator, and lots of example applications, as well as a documentation of the APIs
and tools. Especially the SDK-documentation will be very helpful during this
course.
SonyEricsson SDKs do not support developing with MS Visual Studio at all,
just CodeWarrior and Carbide IDE. Therefore UIQ development can just take
place using the CodeWarrior or Carbide IDE. Of course you could build your
project using command line tools3 , but this is rather uncomfortable.
Motorola provides their own SDK, it is very similar to the one of SonyEricsson.
Motorola manufactured Symbian devices use the same UI API as SonyEricsson,
as they have a touchscreen display too. Motorola SDKs are supported by Code-
warrior, but not yet using Carbide.
3 more information about command line tools will be provided later in the course
3 Framework
Similar to frameworks such as MFC (C++) and the old style of Windows pro-
gramming (C), Symbian applications have to implement a basic framework,
which provides the OS a necessary handle to the application. Generally, the
project wizard will generate these files for you. Alternatively you can copy it
from an existing project.
3.1 Classes
There are several levels of inheritance within the basic framework. In figure 2
you will see a detailed class diagram. Important is the difference between the two
main Symbian platforms Series60 an UIQ. Of course, the third platform called
Cristal (Nokia Communicator Series) will have a specific top level inheritance
too.
// kind of project
TARGETTYPE app
SOURCEPATH ..\data
RESOURCE BApp.rss
RESOURCE BApp_caption.rss
//import libraries
LIBRARY euser.lib apparc.lib cone.lib eikcore.lib
LIBRARY eikcoctl.lib avkon.lib
#include <aknapp.h>
#endif
BAppApp.cpp
#include "BAppApp.h"
#include "BAppDocument.h"
// Creates Document
CApaDocument* CBAppApp::CreateDocumentL()
{
return CBAppDocument::NewL( *this );
}
#include <akndoc.h>
class CEikAppUi;
private:
CBAppDocument(CEikApplication& aApp);
void ConstructL();
private:
CEikAppUi* CreateAppUiL();
};
#endif
BAppDocument.cpp
#include "BAppDocument.h"
#include "BAppAppui.h"
CBAppDocument::CBAppDocument(CEikApplication& aApp)
: CAknDocument(aApp)
{
}
CBAppDocument::~CBAppDocument()
{
}
void CBAppDocument::ConstructL()
{
}
return self;
}
CEikAppUi* CBAppDocument::CreateAppUiL()
{
return new (ELeave) CBAppAppUi;
}
#include <aknappui.h>
class CBAppContainer;
private:
void HandleCommandL(TInt aCommand);
private:
CBAppContainer* iAppContainer;
};
#endif
BAppAppui.cpp
#include "BAppAppui.h"
#include "BAppContainer.h"
#include <BApp.rsg>
#include "BApp.hrh"
#include <avkon.hrh>
// for CAknInformationNote
#include <aknnotewrappers.h>
void CBAppAppUi::ConstructL()
{
// Passing Screen-Area
iAppContainer->ConstructL( ClientRect() );
CBAppAppUi::~CBAppAppUi()
{
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
}
break;
}
default:
break;
}
}
#include <coecntrl.h>
class CEikLabel;
{
public:
void ConstructL(const TRect& aRect);
~CBAppContainer();
private:
// From CoeControl,SizeChanged.
void SizeChanged();
// From CoeControl,CountComponentControls.
TInt CountComponentControls() const;
// From CCoeControl,ComponentControl.
CCoeControl* ComponentControl(TInt aIndex) const;
// From CCoeControl,Draw.
void Draw(const TRect& aRect) const;
private:
CEikLabel* iLabel; // example label
};
#endif
BAppContainer.cpp
#include "BAppContainer.h"
#include <eiklabel.h>
// Init Label
iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL( *this );
iLabel->SetTextL( _L("Example View") );
CBAppContainer::~CBAppContainer()
{
delete iLabel;
}
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbWhite );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
Tools for building Symbian executables are part of the sdk installation and
free for use (gcc). Depending on the IDE, there are more or less things to do.
But understanding command-line tool is inevitably.
Following we look at three (there exists no more) different initial positions and
learn how to get executables running on Win32 Symbian Emulator (EPOC) and
target devices.
Without IDE
1. To select sdk version, set default sdk with command devices -setdefault
2. Go to mmp-file directory (group)
3. Execute cmd-command bldmake bldfiles, which will generate Abld.bat,
used for further building.
4. Type abld build wins for VC++ sdk or abld build winscw for Code-
Warrior sdk. Now, emulator binaries will be builded and stored in em-
ulator directory epoc32/release/wins(cw)/. If not, trace build-output for
errors.
5. Cmd-command abld build armi will make the target executables. They
will be placed in epoc32/release/armi/. Of course you can use thumb or
arm4 instead of armi.
If you have to build a Symbian application consisting of many projects (a fron-
tend app and some selfwritten DLLs), pure cmd-building is the only existing
solution to do that in one step. Write your own .bat file, that executes these
commands for each project.
VC++ As you know, VC++ isn’t a development tool for Symbian. So you
shouldn’t expect good programmers support like code completion or closer to our
current topic, building. Fortunately, the variable and modular project settings
of Microsofts VC++ opens the door to develop, build and debug for emulator.
That means, you have to build only for target platform by your self.
CodeWarrior Building for both, emulator and target platform, will be sup-
ported within Metrowerks CodeWarrior. Because Nokia, Symbian and SonyEr-
icsson use CodeWarrior, new SDKs are firstly available for this IDE.
Carbide Carbide behaves very similar to Codewarrior, building for all targets
is supported. There is only one issue, that needs specific building procedere. The
first released SDK (based on Symbian 6.x) is not officially supported by Carbide.
Therefore building for Symbian 6.x devices must be done using command line
instructions (as described above). This will be a good exercise for getting used
to command line instructions. Nevertheless Carbide can then be used to run
the Symbian 6.x application in the Emulator. As the Carbide IDE is very new,
the example applications in this lecture are still based on Codewarrior. This
implies, that you first have to import the project based on the mmp-file, and
then you call the Eclipse-built-in functionality ’Update Symbian MMP File’ by
clicking the project with the right mouse button and choosing it in the context-
menu. Afterwards you should delete the intermediate build files in the Carbide
workspace (but not the sources). Now you can again import the mmp-file and
everything should be fine. A big remark when using Carbide concerns the
following point. Other to Codewarrior, Carbide will not allow to import and
compile a project if there is already a project using the same namespace (target
and source project name) in the workspace. Therefore you will need to delete
all project specific intermediate and binary files, when re-importing the same
project again.
"c:\Symbian\8.0a\S60_2nd_FP2_CW\Epoc32\data\z\system\apps\BApp\BApp.rsc"
- "!:\system\apps\BApp\BApp.rsc"
"c:\Symbian\8.0a\S60_2nd_FP2_CW\Epoc32\data\z\system\apps\BApp\BApp_caption.rsc"
- "!:\system\apps\BApp\BApp_caption.rsc"
"c:\Symbian\8.0a\S60_2nd_FP2_CW\Epoc32\data\z\system\apps\BApp\BApp.aif"
- "!:\system\apps\BApp\BApp.aif"
4 Symbian Types
4.1 Class Types
On Symbian OS there are four general class types. It’s a kind of class naming
convention for grouping object types by their characteristics. Programmers are
not obligated to follow that guideline. But it is helpfully to understand the
Symbian API, because Symbian Ltd. programmers should made use of it.
4.1.1 T Classes
The most fundamental classes are simple value types, which class names begin-
ning with letter T.
T characteristics:
• T types contain their value. They do not own any external object.
• T types may be allocated either on the stack or as class-members.
• Many T types don’t need a constructor. Those that do, use the constructor
to initialise own data.
• T types have no destructor.
T examples:
• Integer, without constructor
TInt myInt = 2;
• String, using constructor
TBuf<3> myBuf(_L("abc"));
4.1.2 C Classes
Most none T classes in sdk are C classes and if you are going to implement your
own thing, mostly it belongs to characteristics of a typical C class. Like T class
naming, C classes beginning with letter C.
C characteristics:
• C classes are derived from CBase.
• C classes are allocated on the heap.
• C classes are passed by pointer or reference.
• C classes uses a constructor and a destructor.
C examples:
• Create a label
CEikLabel* myLabel = new (ELeave) CEikLabel();
• Call function from label
myLabel->SetTextL( _L("Bienne") );
• Call destructor
delete myLabel;
4.1.3 R Classes
R classes are proxies for external objects, which mostly owned by the OS itself
and belongs to a limited pool of ressources. Of course, classes starts with letter
R.
R characteristics:
• R classes don’t make use of a constructor. Instead, they have to open or
connect.
• R classes don’t have implemented a destructor. They will be released by
close.
R examples:
• Open access to file system
RFs fileserver;
fileserver.Connect();
• Close access
fileserver.Close();
4.1.4 M Classes
M classes define interfaces. Mostly they will be used for callbacks.
An example:
TInt limit = 10;
TUint counter = 0;
TReal accum = 0.0;
TBool go = ETrue;
while(go)
{
accum += ((TReal)(counter)) / 2;
counter++;
go = counter < limit;
}
str.Length(); // returns 7
str.MaxLength(); // returns 20
delete myHeapDesc;
4.4 Arrays
Symbian offres a number of easy to use object containers. In advantage to
standard arrays, Symbians predefined classes built in nice functionalities and
error handling (comparable with JAVA Vector and basic Array).
TInt myBasicArray[23]; // C-Array Stack
TInt* myBasicArrayHeap = (TInt*)calloc(23,sizeof(TInt)); //C Heap
TFixedArray<TInt,23> mySymbianArray; // Symbian-Array
//Indexing out-of-range
myBasicArray[23];
mySymbianArray[23]; //USER 133 Panic - can be handled
//copy element
TInt myCopy = intArray.At(2); //myCopy = 3
//edit element
intArray.At(2) = TInt(99); //intArray = [1,2,99,4]
intArray.Reset();
Element properties
• Fixed length: All elements are of the same size.
• Variable length: Elements can be of different sizes.
• Pointer: Elements are pointers to CBase-derived objects.
• Untyped: Elements are TAny objects.
Storage type
• Flat buffer: The elements are stored in a single memory area, and are of
fixed length.
• Segmented: The elements are stored in multiple memory areas.
4 In the purchase to the run time.
• Packed: The elements are stored in a single memory area, but can be of
variable length.
Following code defines a simple object. Later, we will use that object as array
element.
// definition
class CMyObject: public CBase
{
public:
CMyObject(TInt aInt, TDesC& aText); //Constructor
~CMyObject(); //Destructor
// implementation
CMyObject::CMyObject(TInt aInt, TDesC& aText)
{
iInt = aInt;
CMyObject::~CMyObject()
{
//free allocated memory
delete iText;
}
TBuf<20> objBuf(_L("first"));
objPtr1 = new CMyObject(13,objBuf);
objBuf = _L("second");
dynamicArr->At(0)->iInt = 43;
TBuf<45> newText(_L("abcdefghi"));
*(dynamicArr->At(1)->iText) = newText;
//deletes all
dynamicArr->Reset();
delete objPtr1;
delete objPtr2;
delete dynamicArr;
• Menu-Action-Events
• Menu-GUI-Events
• Key-Events
Below you will see the rss-file from our example MenuEventApp:
BApp.rss
// RESOURCE IDENTIFIER
NAME AWIZ // 4 letter ID
#include <eikon.rh>
#include "BApp.hrh"
#include <avkon.rsg>
#include <avkon.rh>
#include <avkon.mbg>
RESOURCE RSS_SIGNATURE { }
RESOURCE EIK_APP_INFO
{
menubar = r_bapp_menubar;
cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
}
//open submenu
MENU_ITEM { cascade = r_sub_menu; txt = "Menu Event 2"; }
};
}
It’s not recommended to define event-codes like command = 22122. We did that
only for illustration reasons. Usually you should define events in an enumera-
tion!!
//added events
MyPopUp(outBuf);
break;
}
MyPopUp(outBuf);
break;
}
default:
break;
}
}
break;
}
}
return EKeyWasNotConsumed;
}
#include <coecntrl.h>
Classes which inherit from CCoeControl are received the obligation to imple-
ment few functions used by framework:
• void SizeChanged() Responds to size changes to sets the size and posi-
tion of the contents of this control.
• TInt CountComponentControls() Gets the number of controls contained
in a compound control.
• CCoeControl* ComponentControl(TInt aIndex) Gets the specified com-
ponent of a compound control.
• void Draw(const TRect& aRect) Draw a control; called by window server.
6.2 Drawing
Code for drawing can be placed in the function body of void Draw(const TRect& aRect).
A complete overview of all drawing methods you will find in sdk-help under
CWindowGc!
In example DrawingApp you will see some frquently used drawing functions:
• void DrawRect(const TRect& aRect) to draw a rect
• void DrawEllipse(const TRect& aRect) to draw a ellipse bordering
aRect
7 GUI Components
In that section we will learn to provide user interaction by using Symbians
graphical user interface components. There exists a lot of GUI-Elements within
Symbian and usually releasing new OS version brings up some more of theme.
So we going to process only basics... in generally components existing since
Symbian 6.1.
7.1 Notes
A Note is used as feedback component that informs the user about application
states, occurred errors and much more.
There are 6 types of notes:
• Confirmation Note to show a successfully operation
7.2 Dialogs
A Dialog is used to query user input. Different to Notes, a Dialog needs a
resource entry in the *.rss file. First it appears to be difficult. The resource
The following course example contains the most frequently used dialog types.
//resource language
RESOURCE DIALOG r_integer_input
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items=
{
DLG_LINE
{
type = EAknCtQuery;
id = 1;
control = AVKON_DATA_QUERY
{
layout = ENumberLayout;
label = "Number input";
control = AVKON_INTEGER_EDWIN
{
min = 0;
max = 1000;
};
};
}
};
}
//cpp
TInt passedRet = 50;
CAknNumberQueryDialog* dlgStctPT =
CAknNumberQueryDialog::NewL(passedRet,CAknQueryDialog::ENoTone);
dlgStctPT->ExecuteLD(R_INTEGER_INPUT))
8 Multitasking
8.1 Threads, Multitasking and Preemption
Symbian has it’s application area in the world of portable, battery-powered,
wireless devices. Compared with desktop systems, resources are rare. First
priority is efficiency, and not to claim to the most powefull processor or ”unlim-
ited” memory. Batterypower considerations are always present. As the systems
must be responsive to it’s users, and to the real-time needs of communications-
intensive protocols, the number of threads running concurrently must be kept
minimal. Although Symbian is implemented as a preemptive multi-tasking
OS, the usage of real Threads (class RThread) is discouraged and not covered
in the scope of this course, because of its inefficiency. Using many Threads (and
an unlucky set priority) could slow down the OS and should only be considered
for strong reasons. The paradigm ”to make efficient use of the available re-
sources” is still valid in the world of mobile devices. Each application, and each
system server, is given its own thread (mostly also its own process). Thanks
to Active Objects, it is extremely rare that applications require more than one
thread, which contributes significantly to the OS’s reliability. Active Objects
are efficient and, thanks to object orientation, easy to work with.
When implemeting an Active Object, at least the two functions listed below
must be present (by inheritance):
• RunL();
• DoCancel();
Almost all code in an EPOC system executes under the control of active-object
RunL() member function. This is the function that will be called by the oper-
ating system once the asynchronous request has completed. The iHost object
is a reference to the class that constructs and uses the MyTimer object. All it
does, it notifies that the request has completed and returns a time event.
MyTimer.cpp
//From CActive
void CMyTimer::RunL()
{
iHost.MyTimerEventNotify(iTimeEvent);
}
DoCancel() is the 2nd function that must be implemented when inheriting from
CActive. This function can be called when a outstanding asynchronous request
must be canceled. Here DoCancel() just calls the function Cancel() of class
RTimer.
MyTimer.cpp
//From CActive
void CMyTimer::DoCancel()
{
iTimer.Cancel();
}
As you have seen now, how the Active Object can be canceled, you probably
may ask how it can be started. The function below starts the execution of
the asynchronous task. It musn’t be named ’After’ (by inheritance), it just
makes sense in our context. Firstly the asynchronous function ’After’ of class
RTimer is initialised, and a reference to iStatus is passed to the RTimer ob-
ject. Immediately afterwards the object is set active by calling SetActive().
This function-call triggers the execution of the asynchronous function. An Ac-
tive Object might also be triggered in the constructor. Once the asynchronous
request has finished, the RunL() function, described above, will be called.
MyTimer.cpp
In the next listing you see the complete Header file declaration of the class
CMyTimer. The public function NewL(), which is used to construct the
CMyTimer object, is supposed to receive a MMyTimerHostNotifier object. The
reason for this construct will be explained in the next section. Furthermore you
see in the private data section the declaration of the member object iTimer of
class RTimer.
MyTimer.h
#ifndef __MYTIMER_H
#define __MYTIMER_H
#include <e32std.h>
#include <w32std.h>
protected:
static CMyTimer* NewLC( MMyTimerHostNotifier& aHost );
CMyTimer( MMyTimerHostNotifier& aHost );
void ConstructL();
private: //data
MMyTimerHostNotifier& iHost;
TTimeIntervalMicroSeconds32 iDelay;
RTimer iTimer;
TInt iTimeEvent;
};
#endif
Now, let’s have a look at the definition of the Interface class MyTimerHostNo-
tifier. It just consists of the virtual callback function MyTimerEventNotify,
which is used to notify the calling class that the timer has finished. In the
examples we put this declaration in the same Header file as the declaration of
MyTimer, but it could also be put in a separate header file.
MyTimer.h
class MMyTimerHostNotifier
{
public:
virtual void MyTimerEventNotify(TInt aEventCode) = 0;
};
Class MyTimer and and MyTimerHostNotifier are now complete. Let’s con-
struct an instance of our class MyTimer. Therefore we go into the Header
file of our basic class BAppAppui, from which we construct the CMyTimer
object. To complete the construct, class BAppAppui inherits directly from
our Interface class MyTimerHostNotifier, in return we must define the function
’MyTimerEventNotify’.
BAppAppui.h
#ifndef BAPPAPPUI_H
#define BAPPAPPUI_H
#include <aknappui.h>
#include "MyTimer.h"
class CBAppContainer;
public:
void ConstructL();
~CBAppAppUi();
//From MMyTimerHostNotifier
void MyTimerEventNotify(TInt aEventCode);
private:
void HandleCommandL(TInt aCommand);
private:
CBAppContainer* iAppContainer;
CMyTimer* iMyTimer;
};
#endif
//...somwhere in BAppAppui
iMyTimer = CMyTimer::NewL(*this);
TTimeIntervalMicroSeconds32 aDelay = 1000000 * timeToSleep;
TInt callbackEvent = 911;
iMyTimer->After(aDelay, callbackEvent);
9 GSM API
9.1 Overview
Similar to the Socket-Server and the Comms-Server, there is a ETel Server in-
frastructure that allows to deal with the telephony API. ETel provides control
over standard phone features such as answering and initiating calls. In addition
the phone and line status and capabilities can be queried. The ETel Server
provides the management of multiple concurrent connections and offers the ca-
pability to load plugin-modules (also called TSY), that are used to add support
for several hardware types, without affecting the client side API.
• RPhone
• RLine
• RCall
9.2.1 RPhone
A telephony device is represented by the class RPhone. It’s API provides ac-
cess to the status and the capabilities of the phone and provides a notification
9.2.2 RLine
A phone can have one or more lines. RLine objects represents a single line.
Again the capabilities, status and status changes can be gained by accessing the
RLine object.
9.2.3 RCall
RCall is the class where real telephony calls are implemented. The functionality
of dialing a number, hanging up a call or receiving incoming calls can be imple-
mented using the class RCall. RCall objects represent a single active call (Each
line might have zero or one active calls). Same as in the two classes described
above, RCall can be used to notify status changes as well as call capabilities.
User::LeaveIfError(iServer.Connect());
User::LeaveIfError(iServer.LoadPhoneModule(KTsyName));
this->iState = EIdle;
this->iCreaterClass = createrClass;
}
TInt numberPhones;
User::LeaveIfError(iServer.EnumeratePhones(numberPhones));
if (numberPhones < 1)
{
User::Leave(KErrNotFound);
}
User::LeaveIfError(iServer.GetPhoneInfo(0, this->iTelPhoneInfo));
User::LeaveIfError(iPhone.Open(iServer, this->iTelPhoneInfo.iName));
User::LeaveIfError(iPhone.GetLineInfo(0, this->iPhoneLineInfo));
User::LeaveIfError(iLine.Open(iPhone, this->iPhoneLineInfo.iName));
User::LeaveIfError(iCall.OpenNewCall(iLine, this->iCallName));
this->iState = EDial;
iCall.Dial(iStatus,telNbr);
SetActive();
}
void CCallModule::WaitingForIncomingCall()
{
this->Cancel();
this->iCall.Close();
this->iLine.Close();
this->iPhone.Close();
TInt numberPhones;
User::LeaveIfError(iServer.EnumeratePhones(numberPhones));
if (numberPhones < 1)
{
User::Leave(KErrNotFound);
}
User::LeaveIfError(iServer.GetPhoneInfo(0, this->iTelPhoneInfo));
User::LeaveIfError(iPhone.Open(iServer, this->iTelPhoneInfo.iName));
User::LeaveIfError(iPhone.GetLineInfo(0, this->iPhoneLineInfo));
User::LeaveIfError(iLine.Open(iPhone, this->iPhoneLineInfo.iName));
this->iLine.NotifyIncomingCall(iStatus, this->iCallName);
this->iState = EWaitingForIncomingCall;
SetActive();
}
...
//somwhere in the nirvana ;-)
this->iState = EAnsweringIncomingCall;
this->iCall.AnswerIncomingCall(iStatus);
SetActive();
...
void CCallModule::HookStateChange()
{
this->iState = EObserveCall;
this->iCall.NotifyStatusChange(iStatus, iHookState);
SetActive();
}
void CCallModule::TerminateCall()
{
//cancel any remaining activities
this->Cancel();
//terminate call, if it is connected
RCall::TStatus status = RCall::EStatusUnknown;
iCall.GetStatus(status);
if (status == RCall::EStatusConnected)
{
//indicate, that call is being hung up
this->iCreaterClass->Call_Module_Notifier(
MCallModuleNF::E_Call_HangingUp_Notifier, status);
//terminate call, synchronous version
this->iCall.HangUp();
//indicate, that call has been hung up
this->iCreaterClass->Call_Module_Notifier(
MCallModuleNF::E_Call_Terminated_Notifier, status);
//call is now terminated, the creating class can now
//safely delete its instance of this object
}
}
private:
// Client session on the message server
CMsvSession* iSession;
// Mtm client registry for creating new mtms
CClientMtmRegistry* iMtmReg;
...
}
void CSMSEngine::CompleteConstructL()
{
iMtmReg = CClientMtmRegistry::NewL(*iSession);
iMtm = iMtmReg->NewMtmL(KUidMsgTypeSMS);
}
{
//server is ready
CompleteConstructL();
break;
}
case EMsvEntriesCreated:
{
TMsvId* entryId = static_cast<TMsvId*>(aArg2);
if ( *entryId == KMsvGlobalInBoxIndexEntryId )
{
//Incoming Messages
}
break;
}
// this event is given when message entries are moved
case EMsvEntriesMoved:
{
break;
}
case EMsvEntriesChanged:
{
break;
}
case EMsvEntriesDeleted:
{
break;
}
case EMsvGeneralError:
{
break;
}
default:
{
break;
}
}
}
Now you have the basics to do more operations like deleting messages, sending,
receiving, and iterating the inbox as well as the outbox...
10.2 Example
The following example SMSApp implements a simple SMS-Router, based on a
self defined syntax within SMS content.
General: ”AppName@ControlString@Arg1@Arg2”
For MMS-Handling, which covers lots of additional details you’ll find a very
good example in the SDK-Example-Library.
11 Bluetooth
11.1 Overview
Bluetooth technology is an open specification for wireless communications of
data and voice. It is based on a low-cost short-range radio link (2,4 GHz) which
operates on a globally-available radio frequency. Bluetooth uses FHSS and
splits it’s frequency-band into 79 1-MHz channels. It can be used to connect
to other mobile phones, computers, network access points and other devices.
Class 2 devices have a range of about 10 meters, Class 1 devices even about
100 meters. Although the Bluetooth-Specification supports both, synchronous
and asynchronous protocols, not all protocols can be accessed using the existing
SDK’s. Nevertheless the implementation of a variety of services, such as voice
and video can be done.
Bluetooth Radio This layer, at the very bottom, is the Bluetooth radio trans-
ceiver. Often it is also called Physical layer, although this is a bit misleading,
because you might assume, that this is the only layer implemented in hardware,
which is not correct.
Baseband Directly above, you’ll find the Baseband. This layer is responsible
for establishing connections and controlling the data transfer using the Blue-
tooth Radio layer.
Bluetooth Profiles Topmost on the Bluetooth stack there are the Bluetooth
Profiles. These are high-level software components, that implement services,
that ensure correct interoperability with other Bluetooth devices. Not all Blue-
tooth specifications (Bluetooth v1.1 vs Bluetooth v2.0) support the same set of
Bluetooth Profiles. Neither do all brands support all profiles.
L2CAP The Logical Link Control and Adaptation Protocol offers connection-
oriented and connectionless data services between the baseband device and the
upper layers. It is responsible for stream segmentation and reassembly, which
allows the upper-layer protocols to transmit data packets larger than the base-
band can handle.
SDP The Service Discovery protocol allows Bluetooth devices to discover ser-
vices offered by remote devices. Broadcast queries can be sent and the responses
parsed, in order to determine which services are offered by the remote devices.
Dial-up Networking profile Two main scenarios are implemented: The Us-
age of a mobile phone (i.e it’s modem) by a computer as a wireless modem for
connecting to dial-up internet access server and the usage of mobile phones by
a computer in order to receive data calls.
File Transfer profile Typically this protocol allows remote device browsing ,
transferring and manipulating objects on/with another Bluetooth device.
Serial Port profile defines the requirements necessary for setting up emulated
RS232 serial cable connections using RFCOMM between two peer devices. The
scenario covered by this profile deals with legacy applications using Bluetooth
as a cable replacement, through a virtual serial port abstraction (which in itself
is operating system-dependent). Often this profile is used as data carrier for
other profiles and applications.
Cordless Telephony profile This profile defines the features and procedures
that are required for interoperability between different units active in the 3-in-1
phone use case. 3-in-1 phone is a solution for providing an extra mode of op-
eration to mobile phones, using Bluetooth as a short-range bearer for accessing
fixed network telephony services via a base station.
• Nokia N73
• Nokia N75
• Nokia N76
• Nokia N77
• Nokia N80
• Nokia N91
• Nokia N92
• Nokia N93i
• Nokia N95
Phones based on S60 2nd Edition FP3 (Symbian OS v8.1)
• Nokia N70
• Nokia N72
• Nokia N90
Phones based on S60 2nd Edition FP2 (Symbian OS v8.0a)
• Nokia 6630
• Lenovo P930
• Nokia 6680
• Nokia 6681
• Nokia 6682
Phones based on S60 2nd Edition FP1 (Symbian OS v7.0s enhanced)
• Nokia 3230
• Nokia 6670
• Nokia 7610
• Nokia 6620
• Nokia 6260
• Panasonic X700
• Panasonic X800
• Samsung SDH-D720
Phones based on S60 2nd Edition (Symbian OS v7.0s)
• Nokia 6600
• Samsung SDH-G720
• Samsung SDH-G730
Phones based on S60 1st Edition (Symbian OS v6.1)
• Nokia 7650
• Nokia N-Gage QD
• Sendo X
• Siemens SX1
• Samsung SDH-D720
Error : Too many include paths! Please reduce the number of include
paths or use non-recursive paths
CodeWarrior gets it project settings from SDK scripts. Locate the file
”C:/Symbian/UIQ 21/epoc32/tools/ide cw.pm”
Change the the value ”Recursive” to flase (in the addSystemSearchPaths func-
tion, not in the addUserSearchPaths).
ide cw.pm
Alternatively you could (in stead of the Action described above) adapt the XML
project template file. This file is contained in the same folder as above. In fact
there are to different templates, it’s recommended just to adapt the one that
you are actually using:
• scw project template.xml
• scw project template v2.xml
Again, change it’s recursive value to false
scw project template.xml
<SETTING>
<NAME>Recursive</NAME>
<VALUE>false</VALUE>
</SETTING>
A.3.2 Carbide
Keep the directory where the whole Symbian project is located and the Carbide
workspace strictly apart. The Symbian project should not be located within
the workspace.
A.4.2 Carbide
• Carbide can not handle spaces in the workspace path. Also the source file
directory is not allowed to include spaces in it’s path.