author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 14 | 63aabac4416d |
parent 28 | 075425b8d9a4 |
permissions | -rw-r--r-- |
24 | 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 <StringLoader.h> |
|
20 |
#include <utf.h> |
|
21 |
||
22 |
// User includes |
|
23 |
#include "radioengineutils.h" |
|
24 |
#include "cradioenginetls.h" |
|
25 |
||
26 |
// --------------------------------------------------------------------------- |
|
27 |
// |
|
28 |
// --------------------------------------------------------------------------- |
|
29 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
30 |
EXPORT_C void RadioEngineUtils::InitializeL() |
24 | 31 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
32 |
CRadioEngineTls::InitializeL(); |
24 | 33 |
CRadioEngineTls::Instance().AddRef(); |
34 |
} |
|
35 |
||
36 |
// --------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
// --------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
EXPORT_C void RadioEngineUtils::Release() |
|
41 |
{ |
|
42 |
CRadioEngineTls::Instance().Release(); |
|
43 |
} |
|
44 |
||
45 |
// --------------------------------------------------------------------------- |
|
46 |
// |
|
47 |
// --------------------------------------------------------------------------- |
|
48 |
// |
|
49 |
EXPORT_C MRadioEngineLogger* RadioEngineUtils::Logger() |
|
50 |
{ |
|
51 |
return CRadioEngineTls::Instance().Logger(); |
|
52 |
} |
|
53 |
||
54 |
// --------------------------------------------------------------------------- |
|
55 |
// Returns the file server session |
|
56 |
// --------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
EXPORT_C RFs& RadioEngineUtils::FsSession() |
|
59 |
{ |
|
60 |
return CRadioEngineTls::Instance().FsSession(); |
|
61 |
} |
|
62 |
||
63 |
// --------------------------------------------------------------------------- |
|
64 |
// Utility method for frequency formatting. |
|
65 |
// Frequency is assumed to be in kilohertz format. |
|
66 |
// --------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
EXPORT_C HBufC* RadioEngineUtils::ReadFrequencyStringLC( TUint32 aFreq, |
|
69 |
TInt aDecimalCount, |
|
70 |
TInt aResourceId ) |
|
71 |
{ |
|
72 |
TBuf<KDefaultRealWidth> freqText; |
|
73 |
freqText.AppendNum( static_cast<TReal>( aFreq ) / 1000.0f, TRealFormat( KDefaultRealWidth, aDecimalCount ) ); // Converts kilohertz to megahertz. |
|
74 |
||
75 |
// Converts the numbers to the proper display mode. |
|
76 |
||
77 |
HBufC* channelFreq = NULL; |
|
78 |
||
79 |
if ( aResourceId == KErrNotFound ) // No resource string. |
|
80 |
{ |
|
81 |
channelFreq = freqText.AllocLC(); |
|
82 |
} |
|
83 |
else |
|
84 |
{ |
|
85 |
channelFreq = StringLoader::LoadLC( aResourceId, freqText ); |
|
86 |
} |
|
87 |
||
88 |
return channelFreq; |
|
89 |
} |
|
90 |
||
91 |
// --------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
// --------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
EXPORT_C void RadioEngineUtils::FormatFrequencyString( TDes& aDest, |
|
96 |
TUint32 aFreq, |
|
97 |
TInt aDecimalCount, |
|
98 |
TDesC& aFormat ) |
|
99 |
{ |
|
100 |
TBuf<KDefaultRealWidth> freqText; |
|
101 |
freqText.AppendNum( static_cast<TReal>( aFreq ) / 1000.0f, TRealFormat( KDefaultRealWidth, aDecimalCount ) ); // Converts kilohertz to megahertz. |
|
102 |
||
103 |
// Converts the numbers to the proper display mode. |
|
104 |
||
105 |
if ( aFormat.Length() <= 0 || freqText.Length() > aDest.MaxLength() ) // No format. |
|
106 |
{ |
|
107 |
aDest.Copy( freqText.Left( aDest.Length() ) ); |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
StringLoader::Format( aDest, aFormat, KErrNotFound, freqText ); |
|
112 |
} |
|
113 |
} |
|
114 |