Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Creating a S60 UI to an existing Open C component

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: ebra (13 Jun 2007)
Last edited: hamishwillee (16 Dec 2011)

Contents

Introduction

This article discusses how to create and what kind of options there are when creating a S60 user interface to an existing Open C component. Two ported desktop console applications Potrace and MkBitmap are used as an example.Porting a desktop console application Potrace to S60 using Open C

Creating application skeleton

The easiest way to start creating the UI is using the application wizard which comes with Carbide.C++. This example evaluates to usage of the free Carbide.C++ version 1.2 Express.

GUI1.png

The type of the application is S60 3rd Ed. GUI Application

GUI2.png

The Application UID 0xA0002AD9 has been requested from Symbian http://licensing.symbian.org/. The tool gives a warning because a real UID is used instead of a test UID.

GUI3.png

The directory structure for the application

Adding interface to Open C component

The application wizard basically creates a copy the HelloWorldBasic application. The class names and UID are the only different things.

Original function

// -----------------------------------------------------------------------------
// COpenCUIExampleAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void COpenCUIExampleAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
 
case ECommand1:
{
 
// Load a string from the resource file and display it
HBufC* textResource = StringLoader::LoadLC( R_COMMAND1_TEXT );
CAknInformationNote* informationNote;
 
informationNote = new ( ELeave ) CAknInformationNote;
 
// Show the information Note with
// textResource loaded with StringLoader.
informationNote->ExecuteLD( *textResource );
 
// Pop HBuf from CleanUpStack and Destroy it.
CleanupStack::PopAndDestroy( textResource );
}
break;
case ECommand2:
{
 
RFs fsSession;
RFile rFile;
 
// Connects a client process to the fileserver
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
 
//Open file where the stream text is
User::LeaveIfError(rFile.Open(fsSession,KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText));
CleanupClosePushL(rFile);
 
// copy stream from file to RFileStream object
RFileReadStream inputFileStream(rFile);
CleanupClosePushL(inputFileStream);
 
// HBufC descriptor is created from the RFileStream object.
HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
 
CAknInformationNote* informationNote;
 
informationNote = new ( ELeave ) CAknInformationNote;
// Show the information Note
informationNote->ExecuteLD( *fileData);
 
// Pop loaded resources from the cleanup stack
CleanupStack::PopAndDestroy(4); // filedata, inputFileStream, rFile, fsSession
fsSession.Close();
}
break;
case EHelp:
{
 
CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
}
break;
case EAbout:
{
 
CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog();
dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
dlg->QueryHeading()->SetTextL(*title);
CleanupStack::PopAndDestroy(); //title
HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
dlg->SetMessageTextL(*msg);
CleanupStack::PopAndDestroy(); //msg
dlg->RunLD();
}
break;
default:
Panic( EOpenCUIExampleUi );
break;
}
}

Passing data between processes

This page was last modified on 16 December 2011, at 03:54.
30 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×