Symbian3/SDK/Source/GUID-AA5DEEB2-0B13-5FA8-8494-EC2F5C654FEF.dita
changeset 7 51a74ef9ed63
child 13 48780e181b38
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-AA5DEEB2-0B13-5FA8-8494-EC2F5C654FEF" xml:lang="en"><title>CentRepExample:
       
    13 Using Central Repository for Persistent Storage</title><shortdesc>This example application demonstrates the usage of Central Repository
       
    14 API for persistent storage.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <section id="GUID-E2129D18-6FBB-55B9-8D79-420EB2CF2401"><title>Description</title> <p>Several
       
    16 Symbian platform components have state and settings information that need
       
    17 to be persistent. There is also a global state that needs to persist, for
       
    18 example, default filenames, locale settings, user preferences. </p> <p>The
       
    19 CentRep example application first registers a group of settings with the central
       
    20 repository server. It uses <filepath>E80000AD.txt</filepath>, a UTF-16 format
       
    21 text file to initialise the repository. This text file contains access control
       
    22 structure and the initial content of the repository. It is recommended to
       
    23 convert the initialisation text file into a binary file using the central
       
    24 repository converter tool to speed up the execution. </p> <p>The application
       
    25 creates a <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> object using the <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-B8DD1F6F-5A03-30C7-A5B5-51053D9FBDD3"><apiname>CRepository::NewLC()</apiname></xref> method
       
    26 to access a repository using its UID. It resets the whole repository using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-BA806B9D-C347-3722-886E-1290A4A0618A"><apiname>CRepository::Reset()</apiname></xref> method
       
    27 with the contents in the initialisation file. </p> <p>Each setting stored
       
    28 in the repository will have a unique key to identify the setting. This unique
       
    29 key is used to read and change the setting by calling the <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-AB3918A5-BA69-3EE8-89B4-51DD8A899AF5"><apiname>CRepository::Get()</apiname></xref> and <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-114079A1-A8CA-3FE7-8FAD-F5E61453FF6B"><apiname>CRepository::Set()</apiname></xref> methods
       
    30 respectively. The application moves these keys to a different location using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-4F005B5F-2664-3F7C-848D-B6F93462F2F4"><apiname>CRepository::Move()</apiname></xref> method
       
    31 and deletes them from their original location. </p> <p>The application also
       
    32 creates another <codeph>CRepository</codeph> object to demonstrate that, at
       
    33 any given point a repository cannot be opened with <i>READ/WRITE</i> access
       
    34 by more than one client. In such situations, it is recommended to start a
       
    35 transaction before a write operation using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-1F14EB0C-89CF-3A76-A678-5F6F86F50B32"><apiname>CRepository::StartTransaction()</apiname></xref> method.
       
    36 A transaction guarantees the consistency and persistence of all values read
       
    37 and written during the transaction. </p> <p>Finally, the application requests
       
    38 the central repository server to notify any changes to the original settings. </p><p><b>Related
       
    39 APIs</b></p><ul>
       
    40 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> - Provides access to a repository.</p></li>
       
    41 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-AB3918A5-BA69-3EE8-89B4-51DD8A899AF5"><apiname>CRepository::Get()</apiname></xref></p></li>
       
    42 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-4F005B5F-2664-3F7C-848D-B6F93462F2F4"><apiname>CRepository::Move()</apiname></xref></p></li>
       
    43 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-B8DD1F6F-5A03-30C7-A5B5-51053D9FBDD3"><apiname>CRepository::NewLC()</apiname></xref></p></li>
       
    44 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-BA806B9D-C347-3722-886E-1290A4A0618A"><apiname>CRepository::Reset()</apiname></xref></p></li>
       
    45 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-114079A1-A8CA-3FE7-8FAD-F5E61453FF6B"><apiname>CRepository::Set()</apiname></xref></p></li>
       
    46 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-1F14EB0C-89CF-3A76-A678-5F6F86F50B32"><apiname>CRepository::StartTransaction()</apiname></xref></p></li>
       
    47 </ul> </section>
       
    48 <section id="GUID-3B353EAA-5FE4-426B-A0A5-6800CE0BC9E3"><title>Download</title> <p>Click
       
    49 on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-e78b3d2c-7205-45ca-abe0-163e33a0fcc3.zip" scope="external">CentRepExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-e78b3d2c-7205-45ca-abe0-163e33a0fcc3.html" scope="peer">browse</xref> to view the example code.</p> </section>
       
    50 <section id="GUID-DCCBE8DE-0BBD-5528-A460-E1645116DD4F"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian build process</xref> describes
       
    51 how to build an application. </p> <p>The <codeph>CentRepExample</codeph> builds
       
    52 an executable called <filepath>CentRepExample.exe</filepath> in the standard
       
    53 location (\epoc32\release\winscw\&lt;<i>build_variant</i> &gt; for CodeWarrior).
       
    54 After launching the executable, depending on the emulator you are using, you
       
    55 may need to task away from the app launcher/shell screen to view the console. </p> </section>
       
    56 </conbody></concept>