Tuesday, July 01, 2008

How to call python module from Symbian C++

You can execute python code from Symbian C++ application ! Here's an simple example :

CSPyInterpreter* it = CSPyInterpreter::NewInterpreterL();
CleanupStack::PushL(it);
PyEval_RestoreThread(PYTHON_TLS->thread_state);

PyRun_SimpleString("open(r'c:\\foo.txt', 'w').write('hello')\n");

PyEval_SaveThread();
CleanupStack::PopAndDestroy(it);
How to create an instance of a T–class into heap with a new operator

It is possible to create an instance of a T Class with a new operator, but these precautions must be taken:

* Instances of T Classes can be safely placed into the CleanupStack, assuming that they do not contain any pointers or references to external objects. CleanupStack handles the cleanup simply by calling User::Free().

* Member variables are not zeroed automatically on construction. Only CBase’s new operator zeroes members.
How to take Control of the Call Application

RWindowGroup *pWG = &CCoeEnv::Static()->RootWin();
pWG->SetOrdinalPosition(0, 2000);
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
TBuf16<30>message;
message.ZeroTerminate();
message.Copy(_L("Calling"));
message.Append(aNumber);
informationNote->ExecuteLD(message);
How to add any app to "Go To" for pre-v9 phones

TInt eError;
TBuf8<KMaxFileName> lBuf;
CPinbLinkBase *lBaseLnk = CPinbLinkBase::NewL(KLinkUidApplication);
CleanupStack::PushL(lBaseLnk);
lBaseLnk->SetNameL(_L("Hunter"));
lBaseLnk->SetDocumentIdIconL(EPinbUnknown);
lBaseLnk->SetParametersL(_L8("E:\\System\\Apps\\MyApp\\MyApp.app"));
lBaseLnk->SetTailParametersL();
lBaseLnk->SetLinkFileNameL(_L("C:\\system\\favourites\\MyApp.lnk"));
lBaseLnk->SetApplicationUidL(KUidMyApp);
TInt lError = lBaseLnk->ValidateLinkL();
lBaseLnk->UpdateLinkInDiskL();
CleanupStack::PopAndDestroy(lBaseLnk);


Note: Above method does not work for symbian v9.x

Friday, June 27, 2008

How to Open Browser with a url in UIQ3.x

OpenBrowserWithUrlL(const TDesC& aUrl, CCoeEnv& aCoeEnv)
{
TVwsViewId id( KUidQWebApp, KUidQWebPageView);
TQWebDNLUrlEntry obj;
obj.iUrl = aUrl;
TQWebDNLUrlEntryBuf buf(obj);
aCoeEnv.AppUi()->ActivateViewL(id, KQWebCustomMsgId, buf);
}

Thursday, June 26, 2008

Auto-start In UIQ

The auto starter in UIQ did not have any particular order

To register with the auto starter your application must write a .ast file to the auto starter's import folder [\private\10274b9f]. On start-up the auto launcher parses the .ast files and will then add new ast files to its database of applications to be started. The ast format contains only the .exe name in plain text as the following example indicates:
calc.ast:

calc.exe

Note:
1. No path is needed: the file is a plain text, one-line executable name. The auto launcher will look across different drives for the executable to launch and no path need be specified; if you install to a MS then the auto launcher will launch from the MS; if the executable cannot be found it will be ignored. The ast file must be written (either by the application or via SIS) to the following import folder:- c:\private\10274b9f\import\

2. Security : The Auto starter will only start your application if it has the capability "WriteUserData".

Using Linux(Ubuntu) for Symbian.C++ 3rd edition application


Below are the steps i followed.
Step 1: Setup EPOCROOT and Points where you have symbian tools.
a) export PATH=~/gnupoc:${PATH}
b) export EPOCROOT=~/symbian-sdks/s60_31/

Step 2: Compile source code
a) cd ~/symbian-sdks/s60_31/s60ex/helloworldbasic/group
b) bldmake bldfiles
c) abld build gcce urel

Step 3: Create a SIS File
a) cd ../sis
b) makesis helloworldbasic_gcce.pkg helloworldbasic.sis

Step 4: Genearet key and certificate pair
makekeys -cert myselfcer.key myselfcer.cer

Step 5: Sign SIS
signsis helloworldbasic.sis helloworldbasic.sisx myselfcer.cer myselfcer.key
Setting Up a Symbian C++ Development Environment with Linux(Ubuntu)

Below are the steps i followed.

Step 1: Install Ubuntu 8.04 on a 32Bit system.

Step 2: The Default Ubuntu Install does not come with any Development Tools so you have to use ubuntu apt-get command to install tools and libraries we require.
a) sudo apt-get install build-essential [Compiler to build symbian build system ]
b) sudo apt-get install zlib1g zlib1g-dev [ZLIB Header files needed while building symbian build system ]
c) sudo apt-get install libssl-dev [OpenSSL Header files needed while building symbian build system (signsis / createsis etc)]
d) sudo apt-get install flex [Requred if you want to compile the gcce cross compiler on your own].
e) sudo apt-get install bison [Requred if you want to compile the gcce cross compiler on your own].

Step 3: You have to download some build scripts, compiler [/code] and SDKs
a) gnupoc-package latest. {http://www.4shared.com/account/file/52785287/c117ddb6/gnupoc-package-109tar.html}[It will contain the EKA2 and EKA1 toolchain].
b) gcc cross compiler for symbian source. {http://www.symbianos.org/download/gcc-539-2aeh-source.tar.bz2} [If you are compiling for Pre-v9 devices]
c) gcce cross compiler for symbian source. {http://www.codesourcery.com/gnu_toolchains/arm/releases/2005Q1C} [If you are compiling for 9.x devices]
d) gcc and gcce cross compiler binaries for symbian [If you donot want to compile gcc / gcce from source]
i. http://www.4shared.com/account/file/52785285/2f19bc9a/gnu-csl-arm-2005Q1C-arm-none-symbianelf-i686-pc-linux-gnutar.html

Step 4: Copy all downloaded files [step 3] files to "~/" of your system.

Step 5: Install symbian install Scripts for linux:
tar -zxvf gnupoc-package-1.09.tar.gz

Step 6: Install ARM Build system
If you want to compile tools your self:
a) cd gnupoc-package-1.09/tools
b) ./install_gcc_539 ../../gcc-539-2aeh-source.tar.bz2 ~/symbian-gcc [If using for EKA1]
c) ./install_csl_gcc ../../gnu-csl-arm-2005Q1C-arm-none-symbianelf.src.tar.bz2 ~/csl-gcc [If using for EKA2]

If you want to use pre-compiles tools:
a) mkdir csl-gcc
b) cd csl-gcc
c) tar -jxvf ../gnu-csl-arm-2005Q1C-arm-none-symbianelf-i686-pc-linux-gnu.tar.bz2

Step 7: Install remaining tools
a) cd gnupoc-package-1.09/tools
b) ./install_eka1_tools ~/symbian-gcc [If using for EKA2]
b) ./install_eka2_tools ~/csl-gcc [If using for EKA2]

Step 8: To Set Evenvironment variable to point to your SDK and add the toolchain directory.
./install_wrapper ~/gnupoc

What you can't do with this method:
1. you can't build for emulator.
2. you can't run emulator.

Note:
1. I don't mind using any other Ubuntu linux infect i have tried using OpenSuse and RedHat. Will post the steps for OpenSuse Soon.
2. Some of the sort comes like emulator specific can be over come with WINE will post how to use WINE in coming posts.
2. Refer to http://martin.st/symbian/ for more info.
3. Contact me at skumar.mobiledev@gmail.com with Subject [symbian on linux] if you have any problem.
How to launch a UI application with Arguments and Handle in Launched UI application

H to launch a application with Arguments.

LaunchApplicationWithArgumentL(const TDesC& aExeName, const TDesC8& aArg = KNullDesC8())
{
CApaCommandLine* commandLine = CApaCommandLine::NewLC();
commandLine->SetCommandL(EApaCommandRun);
commandLine->SetExecutableNameL(aExecName);
commandLine->SetTailEndL(aArg);
RApaLsSession apaLsSession;
User::LeaveIfError(apaLsSession.Connect());
CleanupClosePushL(apaLsSession);
User::LeaveIfError(apaLsSession.StartApp(*commandLine));
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy(commandLine);
}


Handle Arguments in UI Application.

Over ride the virtual function ProcessCommandParametersL() of AppUi Class. 3rd parameter of the function aTail contains application parameters

TBool CMySymbianAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName &aDocumentName, const TDesC8 &aTail)
{
iLogger.WriteFormat(_L("ProcessCommandParametersL %d"), aTail.Length());
}

Friday, June 13, 2008

What does the Application framework takes care while launching an application ?

The Framework will do following before starting the application.
    1. Create a connection to the file server.
    2. Create a connection to the window server.
    3. Create a connection to the memory manager.
    4. Do some application registration.
    5. Make sure the application is able to handle erroe and out-of-memory situtions.
    6. Initalize other application services like font etc.
    7. create default screen elements like status bar, menu bar, soft keys etc.
    8. Start active scheduler. (or you can send event loop)
What the term "Downgrade path" mean in UIQ3.

If a application is not coded to work on all available "UI Configurations" the UIQ3 UI framework will try to look for a nearest match and configures the Screen to that configuration, this process is called "Downgrade path".

"Downgrade path" also makes it possible for an application to run on a device which has a UI configuration that was not available at the time the application was written.

Thursday, June 12, 2008

How to configure UIQ3 emulator to a specific "UI Configuration" ?

When launching the emulator we have to pass -ui parameter to it get the desired "UI Configuration"
eg. uiqenv -ui softkey
OR
We can use the SDKConfig application provided by the SDK.
What does UIQ3 UI Configuration is consist of ?

UI of UIQ3 is very versatile and can be configured by a 4 high-level configuration parameters. Combination all these parameters are called a UI configuration.
    1. Screen Mode.
        The following resolutions are commonly used.
        a) Portrait (QVGA, 240x320 pixels)
        b) Landscape (QVGA, 320x240 pixels)
        c) Portrait Small(240x256 pixels)
        d) Landscape Small(256x240 pixels)
    2. Screen orientation.
        Indicates whether screen is used in
        a) Normal Mode.
        b) Inverted Mode. (screen roated in 180 degrees)
    3. Touch Screen.
        Indicates whether to use advanced digitizer (Touch Screen) or Not.
    4. Interaction style.
        There are 2 general interaction styles used.
        a) Pen-Style. Optimized for pen use. also know as (Point Touch method)
        b) Softkey-Style. Optimized for one-handed navigation.
        
UI Configurations are enumerated in "Qikon.hrh" as

#define KQikSoftkeyStylePortrait (EQikScreenModePortrait  | EQikTouchScreenNo | EQikUiStyleSoftkey | EQikOrientationNormal)

As you can see the UI Configuration can have any combination above 4 parameters. But most commonly used paramets are
    a) KQikSoftkeyStylePortrait. Generally known as "SoftKey Style"
    b) KQikPenTouchPortrait. Generally known as "Pen Style".
What a UIQ3 SDK contains ?

    1. Library, header and binary files.
    2. Compilers 
        a) GCCE compiler for device build,
        b) Nokia x86 compiler for emulator builds.
    3. Tools and scripts (including perl scripts) for building application in C++ and creating installation files to distribute applications.
    4. PC-Based emulator (No Simulator) of the UIQ3 platform to enable fast development and turn around time.
    5. Documentation.
        a) API reference.
        b) Guides.
        c) Sample code.

Thursday, May 22, 2008

Suggested Development process for Symbian S60 C++ Development.

1. Analysis and design:
Before starting to develop an application with an S60 C++ SDK, you must define at least
a) requirements,
b) scope, and
c) functionality
that you wish to implement in the application.
It is good idea to take into account the various capabilities required by the APIs that you intend to utilize in your application at this Phase only.

2. Coding
It is recommended that you use one of the supported IDEs [Visual Studio 2003/2005 with carbide.vs or Carbide.C++]. They provide project templates that you can use to create a standard project from a selection of project types. The template takes care of creating some of the basic folders and files that you need in developing an application. So developer donot have to worry and waste about creating repeated code sections.
note: I will be realsing a set of perl scripts that will generate templates projects to help development by avaoiding IDE. [I am making fixed to these scripts hopfully soon i will complete]

3. Creating and updating your build files.
Before you can build your project, you must first create or update the bld.inf, mmp and extension makefiles.
note: Different IDEs support these files in different ways. Your development environment may maintain these files or just use them when importing the existing project into the IDE, then you are a lucky developer.

4. Building the source files.
In S60 application development, builds are typically created for two different environments:

a) the emulator and
An emulator build is intended to be run on an SDK emulator for debugging purposes. The build process outputs are placed in the correct folder under the SDK emulator directory

b) the target mobile device.
The device build is intended to be run on a mobile device and the output is a file that can be installed on a mobile device. You have to specify which file goes where in a PKG file. Or your IDE can handle it.

Because the operating systems of the emulator and target device are different, two separate builds using different compilers are required. Here are some of the differances between both the builds.
01) emulator and device builds require different compilers.
02) installation of an application on a target device requires a sis file for installation
03) the emulator and device environments treat the processes and threads differently
04) the emulator and device environments treat the maximum stack sizes for applications differently

5. Testing and signing
All S60 C++ application installation files must be signed before they can be installed to a mobile device. Typically, builds are first tested in the emulator and then final testing is performed on the target device.

6. Deploying
Once your application is ready for deploying in a general release, package and deploy your application according to the steps in "Deploying". And you start making money if your application is not Free Application.

Note:
1. This development process is only a suggestion. Your process may different completely or partially from this, depending your type of application and organizational environment.
How to Set-up S60 v9.x CommandLineInterface(CLI) environment

Install
1. ActivePerl Active Perl 5.6.1.x .... [Upper Versions may not work with out editing some scripts]
2. Java Run-Time Environment (JRE) latest and
3. S60 Platform SDK for Symbian OS, for C++ Feature Pack 1.
4. Carbide.c++ Express .

5. Locate "Carbide.c++ Express" Installation folder usually
"C:\Program Files\Nokia\Carbide.c++ v1.x\x86Build" -> "env_switch" -> "env_update.exe"
6. Run "env_update.exe" by double-clicking on the exe file.
7. You will be provided with all available WINSCW compiler versions.
8. Choose select the latest one.
9. Close the command prompt window.

Now you are ready to build emulator builds using command line.

Types of Compilers Supported in S60 v9.x SDKs.

1. WINSCW : Used to build an S60 application for the emulator. A WINSCW compiler is delivered with the Carbide products.
2. GCCE : A free GNU C Compiler (GCC) Embedded Application Binary Interface (EABI). The compiler is delivered with the S60 SDK and can be used for compiling S60 applications for mobile devices.
3. ARMV5 : ARMV5 builds are created with ARM Real View Compilation Tools (RVCT, version 2.2). ARM Real View Compilation Tools are usually used for performance reasons, when compiling S60 applications for mobile devices.

Note:
1. When compiling for Device code compiled with ARMV5 is usually faster and small size then GCCE.
2. If you want to improve GCCE performance or want to upgrade to newer version then you can get it from http://www.codesourcery.com/gnu_toolchains/arm
3. Abouve recommendations are not must have but what i use, so you can differ with it.
Required Environment and Tools for Symbian S60 C++ Development.

1. Computer running
a. Microsoft Windows 2000 SP4 / XP SP2 [Stay away from Vista]
b. Active Perl 5.6.1.x .... [Upper Versions may not work with out editing some scripts]
c. Java Run-Time Environment (JRE) latest.
2. S60 Platform SDK for Symbian OS, for C++ (S60 C++ SDK)
You can get the S60 SDKs Free from forum.nokia.com. Loging required.
3. A C++ IDE or Good Source Code Editor
If are looking for free IDE then i suggest Carbide.C++ Express.
If are looking for a free Source code Editor then i suggest NotePad++.
4. A target device [mobile device] based on the platform version that matches your development SDK.
5. Setup connection between your PC and your mobile device. [Bluetooth or USB], i suggest using PC Suites that come with Phone Driver CD.

Thursday, April 24, 2008

What is "S60 platform services"

S60 platform services are the fundamental services provided by the S60 platform, these include:

1. Application Framework Services — providing the basic capabilities for 
a) launching applications and servers, 
b) state persistence management, and 
c) UI components.
2. UI Framework Services — providing 
a) concrete look and feel for UI components and 
b) handling UI events.

3. Graphics Services — providing 
a) capabilities for the creation of graphics and
b) drawing to the screen.

4. Location Services — allowing the S60 platform to be aware of a device’s location.

5. Web-Based Services — providing 
a) services to establish connections and interact with Web-based functionality, including browsing, file download, and messaging.

6. Multimedia Services — providing 
a) capabilities to play audio and video, 
b) support for streaming and speech recognition.

7. Communication Services — providing 
a) support for local and wide area communications, ranging from Bluetooth technology to voice calls.

Monday, April 21, 2008

How how to get information about my Certificate [Dev Cert].

I do generate a lots of numbers of dev certs for development in office and personal use. and i am not used to generating a dev cert that have all the capabilities that it can have and all my device IMEIs. So each dev cert is different from other by following parameters.

1. Capabilities.
2. IMEIs

let us say if i forget which capabilities and IMEIs a particular Dev cert has, and i do not have time to generate new ones.

;-)

I simple found the answer .... as follows.

devertlist [/c] [/i] [/b] [/?] devcert.cer

- /c - List the capabilities associated
- /i - List the IMEI's associated with the devcert
- /b - List the output as bare, suitable for pipelining
- /? - print out the about information and command list
stats counter