radioengine/settings/src/cradioregion.cpp
branchRCL_3
changeset 19 cce62ebc198e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/radioengine/settings/src/cradioregion.cpp	Tue Aug 31 15:15:02 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// System includes
+#include <barsread.h>
+
+// User includes
+#include "cradioregion.h"
+#include "cradioenginelogger.h"
+
+// Used to convert kilohertz values to hertz values
+const TInt KRadioThousand = 1000;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CRadioRegion::CRadioRegion()
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CRadioRegion::ConstructL( TResourceReader& aRr )
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    iId = static_cast<TRadioRegion>( aRr.ReadUint16());
+    iStepSize =  aRr.ReadUint32() * KRadioThousand;
+    iMinFreq = aRr.ReadUint32() * KRadioThousand;
+    iMaxFreq = aRr.ReadUint32() * KRadioThousand;
+    iDecimalCount = aRr.ReadInt16();
+
+    TInt countryCodeCount = aRr.ReadInt16();
+    for ( TInt i = 0; i < countryCodeCount; ++i )
+        {
+        TPtrC code;
+        code.Set( aRr.ReadTPtrC());
+        User::LeaveIfError( iCountryCodes.Append( code.AllocL()));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CRadioRegion* CRadioRegion::NewL( TResourceReader& aRr )
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    CRadioRegion* self = new ( ELeave ) CRadioRegion;
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aRr );
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CRadioRegion::~CRadioRegion()
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    iCountryCodes.ResetAndDestroy();
+    iCountryCodes.Close();
+    }
+
+// ---------------------------------------------------------
+// Get the id of region
+// ---------------------------------------------------------
+//
+EXPORT_C TRadioRegion CRadioRegion::Id() const
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iId;
+    }
+
+// ---------------------------------------------------------
+// Get the step interval of region
+// ---------------------------------------------------------
+//
+EXPORT_C TUint32 CRadioRegion::StepSize() const
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iStepSize;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+EXPORT_C TUint32 CRadioRegion::MinFrequency() const
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iMinFreq;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+EXPORT_C TUint32 CRadioRegion::MaxFrequency() const
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iMaxFreq;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CRadioRegion::DecimalCount() const
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iDecimalCount;
+    }
+
+// ---------------------------------------------------------
+// Get the country code of region
+// ---------------------------------------------------------
+//
+EXPORT_C const RRadioCountryCodeArray& CRadioRegion::CountryCodes()
+    {
+    LEVEL3( LOG_METHOD_AUTO );
+    return iCountryCodes;
+    }