This page was last modified 22:25, 28 September 2007.
Creating a S60 UI to an existing Open C component
From Forum Nokia Wiki
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.
The type of the application is S60 3rd Ed. GUI Application
The Application UID 0xA0002AD9 has been requested from Symbian http://www.symbian.com. The tool gives a warning because a real UID is used instead of a test UID.
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
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem porting from 2nd Edition to 3rd Edition | kamalakshan | General Symbian C++ | 7 | 2007-10-19 10:09 |
| Nokia N95 8GB Black Edition | HachemK | General Discussion | 4 | 2007-09-18 13:57 |
| Rfid | Alistair Jenkins | Bluetooth Technology | 0 | 2004-12-06 14:01 |
| series 60 memory full | rawpsycho | Mobile Java General | 5 | 2004-12-06 15:11 |
| application does not run on phone??? | bthyaga | Symbian Signing, Certification and Security | 17 | 2007-06-30 09:38 |



