diff -r 51a74ef9ed63 -r ae94777fff8f Symbian3/SDK/Source/GUID-504EB40B-AC98-5AB2-9263-185887C29A7E.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-504EB40B-AC98-5AB2-9263-185887C29A7E.dita Fri Jun 11 12:39:03 2010 +0100 @@ -0,0 +1,161 @@ + + + + + +Searching +for an IAP Record by Name and Loading the Associated Service and the Bearer +Table: TutorialThis tutorial shows you how to search for a Symbian platform defined +Internet Access Points Configuration (IAP) record by name. The tutorial, then +shows you how load the connected service and the bearer table. + + +

Before you start, +you must understand:

    +
  • the general concept +of the Comms Database

  • +
  • the specific concept +of fields, records, links and tables

  • +
  • how to write and build +application code to run on Symbian platform

  • +
+

This tutorial shows +you:

    +
  • how to search the Internet +Access Points Configuration table for a record defined by name. This table +is also called the IAP table

  • +
  • how to load the connected +service.

  • +
  • how to load the connected +bearer table.

  • +

The principles that apply here also apply to the other Symbian platform +defined tables.

+ +Make sure that you +have created a session. + +Create an empty +IAP record in the tool or application process. + +You create a CMDBRecordSet <T> object +and specify CCDIAPRecord as the template +parameter. + +Symbian platform defines the CCDIAPRecord class to +represent a IAP record. The class is a schema for the record. The class defines +the fields and links that make a IAP record. +Symbian platform defines unique +numeric Id s for Symbian platform defined tables. The symbol KCDTIdIAPRecord also defines the value of this +Id for records in the IAP table. The Id allows the CommsDat API to get the +record from the Comms Database. +To work with other Symbian platform defined tables, use the correct +class name and the correct unique numeric Id values. The Reference section +contains a list of all Symbian platform defined tables. +... + +// This code fragment assumes that a session with the Comms Database has been created. +// iDb is a pointer to a CMDBSession object +... + +// When we search by Name or Id, there can be only one record to be returned +// Create an empty IAP record. +// +// Note: +// 1. the template parameter CCDIAPRecord defines +// the "IAP" record type. +// 2. to create a record, you use a factory function and pass the unique +// numeric Id KCDTIdIAPRecord as a parameter to the constructor. +// + +CCDIAPRecord* ptrIAPRecord = + static_cast<CCDIAPRecord *>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); +... + +Define the name +of the IAP record to be found and set the name in IAP record. Do the search +for the record in the Comms Database. + +In this tutorial, the name of the IAP record is NTRas with Null Modem. + +Use the assignment operator to add the data to a field. A field that +has type T accepts a type T item as the right-hand argument +of an assignment call. + +A descriptor field needs an additional call to set the size of the descriptor. +Call SetMaxLengthL() to set the size of the descriptor. This +function is a member of the field class CMDBField <TDesC>. +Internally, the function causes the allocation of a descriptor. You must set +the size of the descriptor before you assign the data. You can also use the SetL() function. +This function sets the length and assigns the data. The function is a member +of the field class CMDBField <TDesC>. +... +// Define the name of the IAP record. +_LIT(KMyIap, "NTRas with Null Modem"); + +// Either +ptrIAPRecord->iRecordName.SetMaxLengthL(KMyIap().Length()); +ptrIAPRecord->iRecordName = KMyIap; + +// Or +ptrIAPRecord->iRecordName.SetL(KMyIap); + + +// Search the Comms Database +if(ptrIAPRecord->FindL(*iDb)) + { + // Found a matching record + ... + } + +... + +Load the NTRas with +Null Modem service and the associated bearer table. +... +// Search the Comms Database +if(ptrIAPRecord->FindL(*iDb)) + { + // Found a matching record + + // Now load the the associated service and bearer tables, + // The variables iService,iBearer, etc + // are links that point to other records. These links have a "Value" and + // "iLinkedRecord". + // + // The "Value" represent the id of the target field,and gets initialized along with the + // parent record(ptrIAPRecord). When we explictly call load on these LinkedFields, + // the "iLinkedRecord" pointer points to the appropriate object. + // + // The "iLinkedRecord" pointer is owned by the parent record and gets + // deleted along with it.THis means that it must be set to NULL + // if the user wants to take ownership. + + ptrIAPRecord->iService.LoadL(*iDb); + ptrIAPRecord->iBearer.LoadL(*iDb); + + // Take ownership of the loaded service record cache + CCDServiceRecordBase* ptrService = + static_cast< CCDServiceRecordBase *> (ptrIAPRecord->iService.iLinkedRecord); + (ptrIAPRecord->iService).iLinkedRecord = NULL; + + // Deleting ptrIAPRecord also deletes all the loaded iLinkedRecord + // pointers it owns unless set to null. + + delete ptrIAPRecord; + + //delete the service view. + delete ptrService; + } +... + + +
+Comms Database + concepts +
\ No newline at end of file