radioengine/settings/src/cradioregion.cpp
changeset 23 a2b50a479edf
parent 19 afea38384506
child 24 6df133bd92e1
equal deleted inserted replaced
19:afea38384506 23:a2b50a479edf
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <barsread.h>
       
    20 
       
    21 // User includes
       
    22 #include "cradioregion.h"
       
    23 
       
    24 // Used to convert kilohertz values to hertz values
       
    25 const TInt KRadioThousand = 1000;
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CRadioRegion::CRadioRegion()
       
    34     {
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CRadioRegion::ConstructL( TResourceReader& aRr )
       
    42     {
       
    43     iId = static_cast<TRadioRegion>( aRr.ReadUint16());
       
    44     iStepSize = static_cast<TUint16>( aRr.ReadUint16() ) * KRadioThousand;
       
    45     iMinFreq = aRr.ReadUint32() * KRadioThousand;
       
    46     iMaxFreq = aRr.ReadUint32() * KRadioThousand;
       
    47     iDecimalCount = aRr.ReadInt16();
       
    48 
       
    49     TInt countryCodeCount = aRr.ReadInt16();
       
    50     for ( TInt i = 0 ; i < countryCodeCount ; i++)
       
    51         {
       
    52         TPtrC code;
       
    53         code.Set( aRr.ReadTPtrC());
       
    54         User::LeaveIfError( iCountryCodes.Append( code.AllocL()));
       
    55         }
       
    56 
       
    57     iName = aRr.ReadHBufC16L();
       
    58     iSettingName = aRr.ReadHBufC16L();
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CRadioRegion* CRadioRegion::NewL( TResourceReader& aRr )
       
    66     {
       
    67     CRadioRegion* self = new ( ELeave ) CRadioRegion;
       
    68 
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( aRr );
       
    71     CleanupStack::Pop();
       
    72 
       
    73     return self;
       
    74     }
       
    75 
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CRadioRegion::~CRadioRegion()
       
    82     {
       
    83     iCountryCodes.ResetAndDestroy();
       
    84     iCountryCodes.Close();
       
    85     delete iName;
       
    86     delete iSettingName;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // Get the id of region
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 EXPORT_C TRadioRegion CRadioRegion::Id() const
       
    94     {
       
    95     return iId;
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // Get the step interval of region
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 EXPORT_C TUint32 CRadioRegion::StepSize() const
       
   103     {
       
   104     return iStepSize;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 EXPORT_C TUint32 CRadioRegion::MinFrequency() const
       
   112     {
       
   113     return iMinFreq;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 EXPORT_C TUint32 CRadioRegion::MaxFrequency() const
       
   121     {
       
   122     return iMaxFreq;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 EXPORT_C TInt CRadioRegion::DecimalCount() const
       
   130     {
       
   131     return iDecimalCount;
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 // Get the country code of region
       
   136 // ---------------------------------------------------------
       
   137 //
       
   138 EXPORT_C const RRadioCountryCodeArray& CRadioRegion::CountryCodes()
       
   139     {
       
   140     return iCountryCodes;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------
       
   144 // Get the name of region
       
   145 // ---------------------------------------------------------
       
   146 //
       
   147 EXPORT_C const TDesC16& CRadioRegion::Name() const
       
   148     {
       
   149     return *iName;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // Get the name of region
       
   154 // ---------------------------------------------------------
       
   155 //
       
   156 EXPORT_C const TDesC16& CRadioRegion::SettingItemName() const
       
   157     {
       
   158     return *iSettingName;
       
   159     }