Symbian3/SDK/Source/GUID-504EB40B-AC98-5AB2-9263-185887C29A7E.dita
changeset 8 ae94777fff8f
equal deleted inserted replaced
7:51a74ef9ed63 8:ae94777fff8f
       
     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 task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-504EB40B-AC98-5AB2-9263-185887C29A7E" xml:lang="en"><title>Searching
       
    13 for an IAP Record by Name and Loading the Associated Service and the Bearer
       
    14 Table: Tutorial</title><shortdesc>This tutorial shows you how to search for a Symbian platform defined
       
    15 Internet Access Points Configuration (IAP) record by name. The tutorial, then
       
    16 shows you how load the connected service and the bearer table. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    17 
       
    18 
       
    19 <prereq id="GUID-8F09964A-B8AC-5601-817C-B1C243B1CB92"><p>Before you start,
       
    20 you must understand: </p> <ul>
       
    21 <li id="GUID-95E91894-42A9-569A-BCBD-D9CAE502B289"><p>the general concept
       
    22 of the Comms Database </p> </li>
       
    23 <li id="GUID-127FB886-98D0-5F17-997F-CD1134BA7F57"><p>the specific concept
       
    24 of fields, records, links and tables </p> </li>
       
    25 <li id="GUID-8AF15E7D-44F0-5F28-94A1-C4A6E6DE3B93"><p>how to write and build
       
    26 application code to run on Symbian platform </p> </li>
       
    27 </ul> </prereq>
       
    28 <context id="GUID-37F9160E-EAE2-5975-B064-255EA353CB72"><p>This tutorial shows
       
    29 you: </p> <ul>
       
    30 <li id="GUID-84E5F473-8F05-5FDD-B1BB-ED301420CD89"><p>how to search the <i>Internet
       
    31 Access Points Configuration</i> table for a record defined by name. This table
       
    32 is also called the IAP table </p> </li>
       
    33 <li id="GUID-08BA5682-4AF9-526B-9CD2-48BFDEE7E162"><p>how to load the connected
       
    34 service. </p> </li>
       
    35 <li id="GUID-545EC3CC-F771-50AF-8388-CA0AC4B84B10"><p>how to load the connected
       
    36 bearer table. </p> </li>
       
    37 </ul> <p>The principles that apply here also apply to the other Symbian platform
       
    38 defined tables. </p> </context>
       
    39 <steps id="GUID-6A94C40E-59E3-5F22-A778-0734773900C4">
       
    40 <step id="GUID-FFA9D8F4-6683-52EC-B9F7-7D1AAB904D48"><cmd>Make sure that you
       
    41 have created a session. </cmd>
       
    42 </step>
       
    43 <step id="GUID-D00E9CCC-8046-5E43-9D8E-CCA971C79ED2"><cmd>Create an empty
       
    44 IAP record in the tool or application process. </cmd>
       
    45 
       
    46 <info>You create a <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBRecordSet</apiname></xref> <codeph>&lt;T&gt;</codeph> object
       
    47 and specify <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CCDIAPRecord</apiname></xref> as the template
       
    48 parameter. </info>
       
    49 
       
    50 <info>Symbian platform defines the <codeph>CCDIAPRecord</codeph> class to
       
    51 represent a IAP record. The class is a schema for the record. The class defines
       
    52 the fields and links that make a IAP record. </info>
       
    53 <info>Symbian platform defines <xref href="GUID-32E556BC-55C3-5FBD-9A60-9708139C20D6.dita">unique
       
    54 numeric Id</xref> s for Symbian platform defined tables. The symbol <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>KCDTIdIAPRecord</apiname></xref> also defines the value of this
       
    55 Id for records in the IAP table. The Id allows the CommsDat API to get the
       
    56 record from the Comms Database. </info>
       
    57 <info>To work with other Symbian platform defined tables, use the correct
       
    58 class name and the correct unique numeric Id values. The <xref href="GUID-58089281-9DD0-502D-8DFD-831E7BAA931E.dita">Reference</xref> section
       
    59 contains a list of all Symbian platform defined tables. </info>
       
    60 <stepxmp><codeblock id="GUID-629FD205-82F8-5383-AEC8-1645309B994B" xml:space="preserve">...
       
    61 
       
    62 // This code fragment assumes that a session with the Comms Database has been created.
       
    63 // iDb is a pointer to a CMDBSession object
       
    64 ...
       
    65 
       
    66 // When we search by Name or Id, there can be only one record to be returned
       
    67 // Create an empty IAP record.
       
    68 //
       
    69 // Note:
       
    70 // 1. the template parameter CCDIAPRecord defines 
       
    71 //    the "IAP" record type.
       
    72 // 2. to create a record, you use a factory function and pass the unique
       
    73 //    numeric Id KCDTIdIAPRecord as a parameter to the constructor.
       
    74 //
       
    75 
       
    76 CCDIAPRecord* ptrIAPRecord = 
       
    77               static_cast&lt;CCDIAPRecord *&gt;(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
    78 ...</codeblock> </stepxmp>
       
    79 </step>
       
    80 <step id="GUID-82296CE1-8682-56E6-8847-FB6A2348479A"><cmd>Define the name
       
    81 of the IAP record to be found and set the name in IAP record. Do the search
       
    82 for the record in the Comms Database. </cmd>
       
    83 
       
    84 <info>In this tutorial, the name of the IAP record is NTRas with Null Modem. </info>
       
    85 
       
    86 <info>Use the assignment operator to add the data to a field. A field that
       
    87 has type <codeph>T</codeph> accepts a type T item as the right-hand argument
       
    88 of an assignment call. </info>
       
    89 
       
    90 <info>A descriptor field needs an additional call to set the size of the descriptor.
       
    91 Call <codeph>SetMaxLengthL()</codeph> to set the size of the descriptor. This
       
    92 function is a member of the field class <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBField</apiname></xref> <codeph>&lt;TDesC&gt;</codeph>.
       
    93 Internally, the function causes the allocation of a descriptor. You must set
       
    94 the size of the descriptor before you assign the data. You can also use the <codeph>SetL()</codeph> function.
       
    95 This function sets the length and assigns the data. The function is a member
       
    96 of the field class <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBField</apiname></xref> <codeph>&lt;TDesC&gt;</codeph>. </info>
       
    97 <stepxmp><codeblock id="GUID-8427EB95-2BE7-59C7-9A21-DF9DDB3607AF" xml:space="preserve">...
       
    98 // Define the name of the IAP record.
       
    99 _LIT(KMyIap, "NTRas with Null Modem");
       
   100 
       
   101 // Either 
       
   102 ptrIAPRecord-&gt;iRecordName.SetMaxLengthL(KMyIap().Length());
       
   103 ptrIAPRecord-&gt;iRecordName = KMyIap;
       
   104 
       
   105 // Or 
       
   106 ptrIAPRecord-&gt;iRecordName.SetL(KMyIap);
       
   107 
       
   108 
       
   109 // Search the Comms Database
       
   110 if(ptrIAPRecord-&gt;FindL(*iDb))
       
   111     {
       
   112     // Found a matching record
       
   113     ...
       
   114     }
       
   115 
       
   116 ...</codeblock> </stepxmp>
       
   117 </step>
       
   118 <step id="GUID-119EC7CA-0E0E-5062-BC7D-FC023205FA1A"><cmd>Load the NTRas with
       
   119 Null Modem service and the associated bearer table. </cmd>
       
   120 <stepxmp><codeblock id="GUID-C3994C1F-61BD-5BCC-9E29-FACAEE5C198C" xml:space="preserve">...
       
   121 // Search the Comms Database
       
   122 if(ptrIAPRecord-&gt;FindL(*iDb))
       
   123     {
       
   124     // Found a matching record
       
   125 
       
   126     // Now load the the associated service and bearer tables, 
       
   127     // The variables iService,iBearer, etc
       
   128     // are links that point to other records. These links have a "Value" and 
       
   129     // "iLinkedRecord".
       
   130     // 
       
   131     // The "Value" represent the id of the target field,and gets initialized along with the
       
   132     // parent record(ptrIAPRecord). When we explictly call load on these LinkedFields,
       
   133     // the "iLinkedRecord" pointer points to the appropriate object.
       
   134     //
       
   135     // The "iLinkedRecord" pointer is  owned by the parent record and gets
       
   136     // deleted along with it.THis means that it must be set to NULL
       
   137     // if the user wants to take ownership.
       
   138  
       
   139     ptrIAPRecord-&gt;iService.LoadL(*iDb);
       
   140     ptrIAPRecord-&gt;iBearer.LoadL(*iDb);
       
   141 
       
   142     // Take ownership of the loaded service record cache
       
   143     CCDServiceRecordBase* ptrService = 
       
   144         static_cast&lt; CCDServiceRecordBase *&gt; (ptrIAPRecord-&gt;iService.iLinkedRecord);
       
   145     (ptrIAPRecord-&gt;iService).iLinkedRecord = NULL;
       
   146 
       
   147     // Deleting ptrIAPRecord also deletes all the loaded iLinkedRecord
       
   148     // pointers it owns unless set to null.
       
   149 
       
   150     delete ptrIAPRecord;         
       
   151  
       
   152    //delete the service view.
       
   153     delete ptrService;
       
   154     }         
       
   155 ...</codeblock> </stepxmp>
       
   156 </step>
       
   157 </steps>
       
   158 </taskbody><related-links>
       
   159 <link href="GUID-1AFDDD6F-CB99-587D-A0B5-D3F5B27F7135.dita"><linktext>Comms Database
       
   160                 concepts</linktext></link>
       
   161 </related-links></task>