April 21, 2010
March 24, 2010
December 11, 2009
April 24, 2009
Logs in the code – RFileLogger
1] Declare the following variable as a member of your Container class which is in Container.h file:
class MyprojContainer
{
…
…
private:
RFileLogger iLog;
};
2] Add the following forward declaration in your Container.h file:
class RFileLogger;
3] Include the following header file in your Container.cpp file:
#include
4] Add the following code to the ConstructL of your container.cpp file:
iLog.Connect();
iLog.CreateLog(_L(“logdir”),_L(“maincontainer”),
EFileLoggingModeOverwrite);
iLog.SetDateAndTime(EFalse,EFalse);
5] Add the following code in the destructor of your Container.cpp file
iLog.CloseLog();
iLog.Close();
6] Add the following code in your functions, where you want to put logs in your code:
iLog.Write(_L(“test1″));
iLog.Write(_L(“test2″));
there are many other public functions of RFileLogger class which is in flogger.h [epoc32\include] header file:
April 23, 2009
Listbox – CAknSingleStyleListBox
1] Add the following resource definition of list box to your myproj.rss file:
RESOURCE LISTBOX r_list_box
{
flags = EAknListBoxSelectionList;
array_id= r_list_box_item_array;
}
RESOURCE ARRAY r_list_box_item_array
{
items =
{
LBUF { txt = “\t text1 \t”;}
LBUF { txt = “\t text2 \t”;}
LBUF { txt = “\t text3 \t”;}
LBUF { txt = “\t text4 \t”;}
LBUF { txt = “\t text5 \t”;}
};
}
2]
a) Add the following declaration to the myprojcontainer.h file:
#include <aknlist.h>
b) Add the following declaration to the container class of myprojcontainer.h file:
class Cmyproj
{
…
…
private:
CAknSingleStyleListBox* iListBox;
};
3] Add the following code to the myprojcontainer.cpp file:
a) ConstructL()
{
CreateWindowL();
iListBox= new (ELeave) CAknSingleStyleListBox();
iListBox->SetContainerWindowL(*this);
TResourceReader rr;
iCoeEnv->CreateResourceReaderLC(rr, R_LIST_BOX);
iListBox->ConstructFromResourceL(rr);
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
CleanupStack::PopAndDestroy();
SetRect(aRect);
ActivateL();
}
b) ~myprojcontainer()
{
if(iListBox)
delete iListBox;
}
c) SizeChanged()
{
iListBox->SetExtent(TPoint(0,0), iListBox->MinimumSize() );
}
d) CountComponentControls() const
{
return 1; // return no. of controls inside the container
}
e) ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
f) TKeyResponse CMyViewContainer2::OfferKeyEventL(
const TKeyEvent &aKeyEvent, TEventCode aType)
{
return iListBox->OfferKeyEventL(aKeyEvent,aType);
}
Data Query Dialog – EPhoneLayout
1] Add the following resource definition to the .rss file of your project .
RESOURCE DIALOG r_demo_data_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = EPhoneLayout;
label = “”; // prompt text
control = EDWIN
{
width = 5;
lines = 1;
maxlength = 15;
};
};
}
};
}
2] Add the following function definition in .cpp file of your project and corresponding function declaration in .h file
In header file:(.h)
private:
void launchDataQuery();
In source file:(.cpp)
void launchDataQuery()
{
// The descriptor used for the editor
TBuf text;
// The descriptor contained the prompt text for the query. The prompt // text can also be defined in the resource structure of the query
TBuf prompt(_L(“Enter phone number:”));
// create dialog instance
CAknTextQueryDialog* dlg = new( ELeave ) CAknTextQueryDialog( text, prompt );
// Prepares the dialog, constructing it from the specified resource
dlg->PrepareLC( R_DEMO_DATA_QUERY );
// Sets the maximum length of the text editor
dlg->SetMaxLength(15);
// Launch the dialog
if (dlg->RunLD())
{
// if ok is pressed
}else{
// if cancel is pressed
}
}
3] Add the .rsg file [is generated after compilation of .rss file] to the .cpp file where launchDataQuery() function is defined.
#include “myprog.rsg”
4] Compile and Build your project:
As the layout for the data Query is EPhoneLayout with maxlength 15, only 15 digits will be accepted in the query dialog.
February 3, 2009
data types in symbian
[data_types_in_symbian]
1] symbian os provides a set of typedef’s for the built-in types which are defined in
e32def.h for example : typedef signed char TInt8
2] there are different varients (alternatives or options) for each of the data types.
[INTEGER TYPES] – TInt8,TInt16,TInt32
3] in integer data types we are having : 1) TInt8,TInt16,TInt32 (signed integer types)
2) TUint8,TUint16,TUint32 (unsigned integer types)
they have been typedef’ d as follows :
a)
typedef signed char TInt8 – [signed type]
TInt8 i;
Size of variable i : 8 bits (1 byte)
range of variable i : [ -128 to +127 ]
typedef unsigned char TUint8 – [unsigned type]
TUint8 i;
Size of variable i : 8 bits (1 byte)
range of variable i : [ 0 to 255 ]
b)
typedef short int TInt16
TInt16 i;
Size of variable i : 16 bits (2 bytes)
range of variable i : [ -32768 to +32767 ]
typedef unsigned short int TUint16
TUint16 i;
Size of variable i : 16 bits (2 bytes)
range of variable i : [ 0 to +65535 ]
c)
typedef long int TInt32
TInt32 i;
Size of variable i : 32 bits (4 bytes)
range of variable i : [ -2^31 to 2^31 - 1 ]
: [-2147483648 to 2147483647]
typedef unsigned long int TUint32
TUint32 i;
Size of variable i : 32 bits (4 bytes)
range of variable i : [ 0 to 2^32 - 1 ]
: [0 to 4294967295]
these are termed as the specific variants. they are independent of the
underlying implementation.
4] there are also generic varients of these data types ex: [TInt and TUint]
Size of these generic varients is the size of the [natural machine word length] on that particular system, which is atleast 32 bits (4 bytes).
they are dependant on the underlying implementation.
they have been typedef’ d as follows:
typedef signed int TInt
typedef unsigned int TUint
[INTEGER TYPES] – TInt64
5] a) Before symbian os version 8.0, there was no default ARM support for 64 bit arithmetic.
b) thats is, operations on 64 bit values cannot be performed directly as with 32 bit, 16 bit or 8 bit values respectively.
c) so , 64 bit values were implemented as an object of class TInt64, where each object internally contains 2 unsigned 32 bit integers as follows:
TUint iLow;
TUint iHigh;
6] a) After symbian os version 8.0, there is built in support for 64 bit arithmetic.
b) so 64 bit values were typedef’ d, instead of an object implementation containing 2 unsigned integers.
c] [64 bit values typedef as long]
typedef long long Int64
typedef Int64 TInt64
typedef unsigned long long Uint64
typedef Uint64 TUint64
[REAL TYPES] – TReal32,TReal64
7] a) Floating point numbers can be represented in symbian os using type TReal,TReal32 and
TReal64.
b) they are typedef as follows:
typedef float TReal32
typedef double TReal64
c) by default, TReal is typedef as double.
typedef double TReal
d) symbian os does not have a dedicated floating point unit, so floating point calculations
in symbian os are much slower as compared to integer calculations.
[CHARACTER TYPES] – TText,TText8 and TText16.
8] a] Characters in symbian are represented using type TText,TText8 and TText16.
they are typedef as follows:
b]
typedef unsigned char TText8
where the character size is 8 bit (1 byte). It represents a narrow character.
TText8 has been typedef’d as unsigned char whose range is 0 to 255.
TText8 ch;
A variable of type TText8 can represent can represent any character whose
ascii number is between 0 to 255.
c]
typedef unsigned short int TText16
where the character size is 16 bit (2 bytes). It represents a wide character.
TText16 has been typedef’d as unsigned short int whose range is 0 to 65535.
TText16 ch;
A variable of type TText16 can represent can represent any unicode character whose
unicode number is between 0 to 65535.
d) TText can also be used to represent a character.
Implicitely TText is mapped to TText8 for non-unicode builds, and for unicode builds
TText is mapped to Text16.
[VOID TYPE] – TAny
9] a] In standard C++, void means nothing. that is when ever a function takes no argument
or returns nothing it can be declared as follows:
void add(void);
b) In standard C++, (void *) means “pointer to anything”, i.e pointer to any data type.
It is also termed as a generic pointer.
c) In symbian C++ void has been typedef ‘d as follows:
typedef void TAny in e32def.h
d) In symbian C++, in context where void means ‘nothing’,that is when a function takes no argument or it returns no argument as: void add(void);
[void] is used instead of [TAny] as void is effectively compiler independent when referring to ‘‘nothing’’.
e) In symbian C++, in context where a function takes void pointer as an argument (void *), that is ‘pointer to anything’ , or anywhere in the code,
when we are using ‘pointer to any thing’, [TAny *] is used instead of [void *] in symbian.
[BOOLEAN TYPE] – TBool
10] a) boolean values in symbian are represented using type TBool.
b) It has been typedef’ d as follows:
typedef int TBool in e32def.h
c) A variable of type TBool takes 32 bits, as it has been typedef to an int.
d) A variable of type TBool can have either of the two values [ETrue] or [EFalse].
ex : TBool var
a) var = ETrue
here the variable var takes 32 bits in size, and stores value 1 in those 32 bits.
[ETrue is equivalent to 1]
b) var = EFalse
here the variable var takes 32 bits in size, and stores value 0 in those 32 bits.
[EFalse is equivalent to 0]
11]
[Comparison or relation between symbian os fundamental types and native C++ built types]
native types symbian types
————— ——————
1) signed char TInt8
2) unsigned char TUint8
3) short int TInt16
4] unsigned short int TUint16
5] long int TInt32
6] unsigned long int TUint32
7] long long Int64
Int64 TInt64
8] unsigned long long Uint64
Uint64 TUint64
9] float TReal32
10] double TReal64
11] unsigned char TText8
12] unsigned short int TText16
13] void* TAny*
14] int TBool
12]
You can mix symbian [C++ fundamental types] with [native C++ types], but it is more recommended as symbian os fundamental types as independant of the underlying implementation.
December 23, 2008
symbian error codes list
Following is the link of error codes in symbian :
Undefined reference error
1] This error occurs in [GCCE] build only , and not in the [WINSCW] emulator build.
2] Rebuild the project from the command prompt for target build(gcce) , by going to the correct path of your abld batch file, and type the following commands:
a) abld clean gcce
b) abld build gcce urel
This wil resolve the error.
multiply defined section error
1] This error ocurs, when you have two source lines in your mmp, for the same .cpp file.
ex :
SOURCE Test.cpp
SOURCE Test.cpp
You may have accidently duplicated the code in your mmp file in this way.
2] It is a linker error and it displays the following message :
————————————————————————–
mwldsym2.exe: Multiply defined section: class Test* Test::NewL(void) (?NewL@CValidator@@SAPAV1@XZ) in
mwldsym2.exe: files Test.o, Test.o
…
…
…
————————————————————————–
The same .o file name is displayed twice in the error, and this is repeated for all the functions
in that [.cpp] file.




