Monday, February 9, 2009

Central Repository

I have decided to blog on Symbian , based on my work experience.
Symbian is an Operating System for Mobiles.
Please Google out Symbian for more information.
Thereby I am directly blogging on a topic called Central Repository and not focusing on Symbian OS essentials.

Central Repository is a mechanism to save Data permanently in mobiles. Can be viewed as Global Data but very much secured.Data is in the form of int, float and string. Applications can store data using Central Repository.

We also have a mechanism named as RProperty which is not persistent type of storage.Its a temporary mechanism to store the data. Data is valid for the present boot. Loose the content as soon as the system shuts down whereas Central Repository stores permanently.

Temporary data can be saved in RProperty and while turning the device OFF, can shift the data from RProperty to Central Repository.

If a factory reset is performed, then we have the option to retain the latest value of the data or the data can hold the initial value.For data to hold initial value, RFS setting of the data should be set. Overhead is that for every factory reset, additional time is required as Initial value of data should be restored.

While creating a central repository item, settings can be attributed to the item. As mentioned before one can have the option of RFs as well as back up,read write permission (security aspect) etc.

Following is the procedure to use Central Repository.

Step 1 : Create uid3.txt and export it to Z:
Step 2 : uid3.txt contains number of keys and initial attributes
Step 3 : From source code ; create a handle to access central repository.
Step 4 :If necessary change the attribute on the FLY.
Step 5 :Central Repository exposes a set of APIs to manipulate the data.
Step 6 :The storage data types are int,real,strings and binary.


The application uid can be used to create the text file. A file can have 2^32 number of keys.

Export the txt file from your project location to
\epoc32\RELEASE\WINSCW\UDEB\Z\private\10202be9\

The format of txt file is as below
----------------------Start of txt file------------------------

cenrep
version 1
[owner]
//uid of ur apps
0x101F6CFE
[defaultmeta]
0
[platsec]
//Attribute to the whole file
cap_rd=alwayspass cap_wr=WriteDeviceData
[Main]
//Attribute to individual key
//key 1
0x1 string "0" 0 cap_rd=alwayspass cap_wr=WriteDeviceData
//key 2
0x2 int 0 16777216 cap_rd=ReadDeviceData cap_wr=WriteDeviceData

-------------------------------End of txt file----------------------

To access central repository from source code

-----------------------.cpp-------------------------------
TUid Uid;
//uid of your app
Uid::TUid(0x101F6CFE);
//create a handle
iCenRep = CRepository::NewL(Uid);
if (iCenrep)
{
//data to hold value
TInt val;
//Now val holds the latest value of key 0x2 i.e 0 since we have assigned 0 in txt file
iCenRep.Get (0x2,val);
//Set the key 0x2 to some other value
iCenRep.Set (0x2,10);
//now val has the value 10
iCenRep.Get (0x2,val);
}
----------------------------------------------------------
My team mate Jagamohan has reviewed this topic and I thank him for corrections.

No comments: