Native Symbian C++ Development Bootcamp Sept 2009

22
Apadmi Native C++ Symbian Development Berlin Bootcamp 23/09/09 Adam Fleming [email protected]

description

Presentation given to a bootcamp in Berlin in September 2009 about Symbian C++ development. Original material created and presented by Apadmi.

Transcript of Native Symbian C++ Development Bootcamp Sept 2009

Page 1: Native Symbian C++ Development Bootcamp Sept 2009

ApadmiNative C++ Symbian Development

Berlin Bootcamp 23/09/09

Adam [email protected]

Page 2: Native Symbian C++ Development Bootcamp Sept 2009

� 10 Years Cross Platform Mobile Experience� We worked on the first Symbian device in 1998

� Developing Innovation - Device Technology & Applications

� Providing Expert Consultancy & Development Service� Roadmap Planning

Feasibility Studies

Apadmi Introduction

� Feasibility Studies

� Technical Workshops & Training

� Prototyping

� Design, Development, Testing/Certification

� Working in Partnership to Deliver Quality Solutions:

Page 3: Native Symbian C++ Development Bootcamp Sept 2009

Presentation Overview

� Overview

� How does Native C++ fit into the development

picture?

� First Steps

� Getting set up, installation, “HelloWorld”

UI Designer� UI Designer

� Moving on

� Accessing System Services (doing cool stuff)

� Some Essential Symbian Idioms (briefly)

Page 4: Native Symbian C++ Development Bootcamp Sept 2009

How Does Native C++ Fit?

� Symbian platform now supports many

development environments

� Qt, Open C, Java ME, Python, Flash Lite

� So Why Native C++?

� Executables are faster and smaller

� The only way to get to the full power of the system� The only way to get to the full power of the system

� No interface/encapsulation/abstraction layers

� No Sandbox

� Underlying OS is almost entirely Native C++

� The only way to do some things� Extending built-in functionality (eg, new codecs)

� Integrating tightly with built-in apps

Page 5: Native Symbian C++ Development Bootcamp Sept 2009

Important Considerations

� Learning Curve

� Symbian C++ is not standardised C++!

� Highly optimised system

� Complexity arises from underlying systems

� Security Model

� Implications during and after development

� Code is not portable to other platforms

� But this is true for all forms of native dev

� Multiple tools to learn and understand

� Carbide is great, but there’s no substitute for

understanding the whole process

Page 6: Native Symbian C++ Development Bootcamp Sept 2009

Setting Up The Environment

� 3 Files to download

� Perl – install this 1st

� ActiveState Perl Version 5.6.1.638

� (Don’t attempt to use a later version!)

� ADT – install this 2nd

� Toolchain including IDE� Toolchain including IDE

� SDK – install this (or these) last

� Platform code

� S60 v5/Symbian^1 – new base-version

� S60 3rd Edition – 3 flavours still important for supporting current handsets (MR, FP1, FP2)

http://developer.symbian.org/wiki/index.php/Symbian_C%2B%2B_Quick_Start

Page 7: Native Symbian C++ Development Bootcamp Sept 2009

First Run – a tip born of experience

� Run the emulator

� \epoc32\release\winscw\udeb\epoc.exe

� Enter the Locale, time/date

� Start any relevant applications

� Open contacts app, the web browser, check everything works but don’t enter any dataworks but don’t enter any data

� Archive the whole epoc32 directory tree

� BEFORE you do any development

� Put it somewhere safe

� Write a batch file to replace the epoc32 tree in your

SDK

Page 8: Native Symbian C++ Development Bootcamp Sept 2009

Hello World!

� Carbide IDE will auto-generate the framework

code and give you a runnable application

� UI Designer allows you to drag and drop

components to develop a UI

� Demo – HelloWorld� Demo – HelloWorld

� 5 minutes to your first application� http://developer.symbian.org/wiki/index.php/Symbian_C%2B%2B_Quick_Start

� http://developer.symbian.org/wiki/index.php/Going_Beyond_Hello:_A_Tutorial_for_Symbian_C%2B%2B_Applications

Page 9: Native Symbian C++ Development Bootcamp Sept 2009

Basic Application Structure class Hello World

CHelloWorldAppUi

CAknViewAppUi CAknView CButton1 CAknButton

CHelloWorldApplication

CApaApplication

CHelloWorldDocument

CAknDocument

CHelloWorldContainerView CHelloWorldContainer CCoeControl

CLabel1 CEikLabel

Page 10: Native Symbian C++ Development Bootcamp Sept 2009

App Doc AppUi

InitialisationInitialisation

View ContainerYour

controls

Page 11: Native Symbian C++ Development Bootcamp Sept 2009

Another Experience to Share

� UI Designer won’t update the generated code

until you hit save – do this often!

� Be careful not to edit the generated code

� Unless you know you’re done with the UI Designer

� If you think you’re done, you’re probably not

� Check your UI in all the screen configurations!

Page 12: Native Symbian C++ Development Bootcamp Sept 2009

Accessing a System Service

� Virtually anything interesting is a Server

� File System

� Internet Connectivity

� Positioning

� Telephony

� etc

� Servers are separate processes (address

spaces)

� Need create a session to handle IPC

� Frequently multiple classes involved in a single

server

Page 13: Native Symbian C++ Development Bootcamp Sept 2009

An Example

� Going to look at File Server as an example

class Bootcamp

RFs

RFormat

RSessionBase

RFi le

RDir

RSubSess ionBase

CDirScan CFileMan

CBa se

Page 14: Native Symbian C++ Development Bootcamp Sept 2009

RFs (abridged) f32file.hclass RFs : public RSessionBase

{

public:

IMPORT_C TInt Connect(TInt aMessageSlots=KFileServerDefaultMessageSlots);

IMPORT_C TVersion Version() const;

IMPORT_C void NotifyChange(TNotifyType aType,TRequestStatus& aStat);

IMPORT_C void NotifyChange(TNotifyType aType,TRequestStatus& aStat,const TDesC& aPathName);

IMPORT_C void NotifyChangeCancel();

IMPORT_C void NotifyChangeCancel(TRequestStatus& aStat);

IMPORT_C TInt DriveList(TDriveList& aList) const;

IMPORT_C TInt DriveList(TDriveList& aList, TUint aFlags) const;

IMPORT_C TInt Drive(TDriveInfo& anInfo,TInt aDrive=KDefaultDrive) const;IMPORT_C TInt Drive(TDriveInfo& anInfo,TInt aDrive=KDefaultDrive) const;

IMPORT_C TInt MkDir(const TDesC& aPath);

IMPORT_C TInt MkDirAll(const TDesC& aPath);

IMPORT_C TInt RmDir(const TDesC& aPath);

IMPORT_C TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey,CDir*& anEntryList) const;

IMPORT_C TInt Delete(const TDesC& aName);

IMPORT_C TInt Rename(const TDesC& anOldName,const TDesC& aNewName);

IMPORT_C TInt Replace(const TDesC& anOldName,const TDesC& aNewName);

IMPORT_C TInt Att(const TDesC& aName,TUint& aAttValue) const;

IMPORT_C TInt Modified(const TDesC& aName,TTime& aTime) const;

IMPORT_C TInt PrivatePath(TDes& aPath);

IMPORT_C TInt CreatePrivatePath(TInt aDrive);

};

Page 15: Native Symbian C++ Development Bootcamp Sept 2009

Descriptors

� Symbian OS String Representations

� Designed to be as resource efficient as possible

� At the cost of increased complexity

http://developer.symbian.org/wiki/index.php/Descriptors_(Fundamentals_of_Symbian_C%2B%2B)

Page 16: Native Symbian C++ Development Bootcamp Sept 2009

Actually Using RFsActually using RFs

RFs rfs;

rfs.Connect();

rfs.CreatePrivatePath(EDriveC);

TFileName newFileName;

rfs.PrivatePath(newFileName);

_LIT(KCDrive,"C:");

_LIT(KNewFileName,"HelloWorld.txt");

� Creates an empty file

in the private directory

� Useful for storing

application local

information

newFileName.Insert(0,KCDrive);

newFileName.Append(KNewFileName);

RFile newFile;

newFile.Create(rfs,

newFileName,

EFileShareExclusive|EFileWrite);

newFile.Close();

rfs.Close();

� Not useful for debug

logs – user can’t get

to this path!

Page 17: Native Symbian C++ Development Bootcamp Sept 2009

A note about sessions and subsessions

� All subsessions are associated with a session

� Closing the session before the subsession will

cause an errorcause an error

� Closing the subsession doesn’t close the

session

Page 18: Native Symbian C++ Development Bootcamp Sept 2009

Active Objects

� Effectively event handlers

� Fit into an optimised wait-loop which is encapsulated within system architecture

� Removes the need to create new threads for handling asynchronicity in most caseshandling asynchronicity in most cases

� Can massively simplify coding highly asynchronous

systems

� Carbide can auto-generate framework objects for you to adapt

� Worth spending time to truly understand

http://developer.symbian.org/wiki/index.php/Active_Objects_(Fundamentals_of_Symbian_C%2B%2B)

Page 19: Native Symbian C++ Development Bootcamp Sept 2009

UIDsUIDs

� Unique Identifiers

� Each application has its own

� Used to mark its executable

� Also present in data files

� Also used to determine private file area� Also used to determine private file area

� 2 Ranges

� Protected 0x 2xxx xxxx (Obtained from Symbian)

� Unprotected 0x Exxx xxxx (allocated by Carbide)

Page 20: Native Symbian C++ Development Bootcamp Sept 2009

Security ModelSecurity Model

� Data Caging

� Applications have a secure directory not visible to

other apps

� Applications cannot access critical system locations

� Capabilities� Capabilities

� Some APIs require a capability to be present in the

executable.

� Static or Dynamic

� Applied to executables

Page 21: Native Symbian C++ Development Bootcamp Sept 2009

Symbian Signing

� Provides revocation and traceability framework

� Process for granting Capabilities

� Externally enforced

� Different levels

� Self-Signed� Self-Signed

� Capabilities have to be approved by user

� Open/Express/Certified

� Capabilities granted without user intervention

� Application signed with a publisher ID

Page 22: Native Symbian C++ Development Bootcamp Sept 2009

Just the tip of the iceberg

� 45 minutes really isn’t enough!

� Not even talked about some key concepts

� Follow Up Assistance

� Apadmi Training

� Symbian OS Training & Bootcamps (3-5 days)� Symbian OS Training & Bootcamps (3-5 days)

� Open Courses in Manchester – Oct, Nov, Dec

� Standard/Customised courses in your office

� Consultancy

� Advise/assist your development projects

� Workshops, Technical Support, Q&A, Problem Solving

� Talk to me or email: [email protected]