Вы находитесь на странице: 1из 22

Apadmi

Native C++ Symbian Development

Berlin Bootcamp 23/09/09


Adam Fleming
adamf@apadmi.com
Apadmi Introduction

 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
 Technical Workshops & Training
 Prototyping
 Design, Development, Testing/Certification

 Working in Partnership to Deliver Quality Solutions:


Presentation Overview
 Overview
 How does Native C++ fit into the development
picture?
 First Steps
 Getting set up, installation, “HelloWorld”
 UI Designer
 Moving on
 Accessing System Services (doing cool stuff)
 Some Essential Symbian Idioms (briefly)
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
 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
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
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
 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
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 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
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
 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_Symbi
an_C%2B%2B_Applications
Basic Application Structure
class Hello World

CHelloWo rldAppUi

CAknVie wAppUi CAknView CButto n1 CAknButton

CApaApplication CAknDocument

CHelloWorldContainerView CHelloWorldContainer CCoeCo ntrol

CHelloWorld Application CHelloWorldDocument

CLab el1 CEikLabel


Initialisation
Initialisation

App Doc AppUi

Your
View Container
controls
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!


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
An Example
 Going to look at File Server as an example
class Bootcamp

RFs RSessi onBase

RFor mat

CDir Scan CFil eMan

RDir

CBa se RSubSess ionBase RFi le


RFs (abridged) f32file.h
class 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 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);
};
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)
Actually Using RFs
Actually using RFs

RFs rfs;  Creates an empty file


rfs.Connect();
in the private directory
rfs.CreatePrivatePath(EDriveC);
TFileName newFileName;  Useful for storing
rfs.PrivatePath(newFileName);
application local
_LIT(KCDrive,"C:");
_LIT(KNewFileName,"HelloWorld.txt"); information
newFileName.Insert(0,KCDrive);
newFileName.Append(KNewFileName);
 Not useful for debug
RFile newFile;
logs – user can’t get
newFile.Create(rfs,
newFileName,
to this path!
EFileShareExclusive|EFileWrite);

newFile.Close();
rfs.Close();
A note about sessions and subsessions

 All subsessions are associated with a session

 Closing the session before the subsession will


cause an error

 Closing the subsession doesn’t close the


session
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 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)
UIDs
UIDs
 Unique Identifiers
 Each application has its own
 Used to mark its executable
 Also present in data files
 Also used to determine private file area

 2 Ranges
 Protected 0x 2xxx xxxx (Obtained from Symbian)
 Unprotected 0x Exxx xxxx (allocated by Carbide)
Security Model
Security Model

 Data Caging
 Applications have a secure directory not visible to
other apps
 Applications cannot access critical system locations
 Capabilities
 Some APIs require a capability to be present in the
executable.
 Static or Dynamic
 Applied to executables
Symbian Signing
 Provides revocation and traceability framework
 Process for granting Capabilities
 Externally enforced
 Different levels
 Self-Signed
 Capabilities have to be approved by user
 Open/Express/Certified
 Capabilities granted without user intervention
 Application signed with a publisher ID
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)
 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: info@apadmi.com

Вам также может понравиться