Symbian3/SDK/Source/GUID-AA5DEEB2-0B13-5FA8-8494-EC2F5C654FEF.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     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><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>This example application demonstrates the usage of Central Repository API
       
    15 for persistent storage. </p>
       
    16 <section id="GUID-E2129D18-6FBB-55B9-8D79-420EB2CF2401"><title>Description</title> <p>Several
       
    17 Symbian OS components have state and settings information that need to be
       
    18 persistent. There is also a global state that needs to persist, for example,
       
    19 default filenames, locale settings, user preferences. </p> <p>The CentRep
       
    20 example application first registers a group of settings with the central repository
       
    21 server. It uses <filepath>E80000AD.txt</filepath>, a UTF-16 format text file
       
    22 to initialise the repository. This text file contains access control structure
       
    23 and the initial content of the repository. It is recommended to convert the
       
    24 initialisation text file into a binary file using the central repository converter
       
    25 tool to speed up the execution. </p> <p>The application creates a <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> object
       
    26 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 to access a repository
       
    27 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
       
    28 with the contents in the initialisation file. </p> <p>Each setting stored
       
    29 in the repository will have a unique key to identify the setting. This unique
       
    30 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
       
    31 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
       
    32 and deletes them from their original location. </p> <p>The application also
       
    33 creates another <codeph>CRepository</codeph> object to demonstrate that, at
       
    34 any given point a repository cannot be opened with <i>READ/WRITE</i> access
       
    35 by more than one client. In such situations, it is recommended to start a
       
    36 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.
       
    37 A transaction guarantees the consistency and persistence of all values read
       
    38 and written during the transaction. </p> <p>Finally, the application requests
       
    39 the central repository server to notify any changes to the original settings. </p><p><b>Related
       
    40 APIs</b></p><ul>
       
    41 <li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> - Provides access to a repository.</p></li>
       
    42 <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>
       
    43 <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>
       
    44 <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>
       
    45 <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>
       
    46 <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>
       
    47 <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>
       
    48 </ul> </section>
       
    49 <section><title>Download</title> <p>Click on the following link to download
       
    50 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>
       
    51 <section id="GUID-DCCBE8DE-0BBD-5528-A460-E1645116DD4F"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian OS build process</xref> describes
       
    52 how to build an application. </p> <p>The <codeph>CentRepExample</codeph> builds
       
    53 an executable called <filepath>CentRepExample.exe</filepath> in the standard
       
    54 location (\epoc32\release\winscw\&lt;<i>build_variant</i> &gt; for CodeWarrior).
       
    55 After launching the executable, depending on the emulator you are using, you
       
    56 may need to task away from the app launcher/shell screen to view the console. </p> </section>
       
    57 </conbody></concept>