Searching for an IAP Record by Name and Loading the Associated Service and the Bearer Table: Tutorial

This 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.

Context

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.

Prerequisites

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

Steps

  1. Make sure that you have created a session.

  2. Create an empty IAP record in the tool or application process.

    You create a [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBRecordSet <T> object and specify [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]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 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]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.

    Example:

    ...
    
    // 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));
    ...
  3. 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 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]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 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBField <TDesC>.

    Example:

    ...
    // 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
        ...
        }
    
    ...
  4. Load the NTRas with Null Modem service and the associated bearer table.

    Example:

    ...
    // 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;
        }         
    ...

Related concepts