|
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 // |
|
30 EXPORT_C void RadioEngineUtils::InitializeL( CCoeEnv* aCoeEnv ) |
|
31 { |
|
32 CRadioEngineTls::InitializeL( aCoeEnv ); |
|
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 // Return the cone environment |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CCoeEnv* RadioEngineUtils::Env() |
|
59 { |
|
60 return CRadioEngineTls::Instance().Env(); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Returns the file server session |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C RFs& RadioEngineUtils::FsSession() |
|
68 { |
|
69 return CRadioEngineTls::Instance().FsSession(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Utility method for frequency formatting. |
|
74 // Frequency is assumed to be in kilohertz format. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C HBufC* RadioEngineUtils::ReadFrequencyStringLC( TUint32 aFreq, |
|
78 TInt aDecimalCount, |
|
79 TInt aResourceId ) |
|
80 { |
|
81 TBuf<KDefaultRealWidth> freqText; |
|
82 freqText.AppendNum( static_cast<TReal>( aFreq ) / 1000.0f, TRealFormat( KDefaultRealWidth, aDecimalCount ) ); // Converts kilohertz to megahertz. |
|
83 |
|
84 // Converts the numbers to the proper display mode. |
|
85 |
|
86 HBufC* channelFreq = NULL; |
|
87 |
|
88 if ( aResourceId == KErrNotFound ) // No resource string. |
|
89 { |
|
90 channelFreq = freqText.AllocLC(); |
|
91 } |
|
92 else |
|
93 { |
|
94 channelFreq = StringLoader::LoadLC( aResourceId, freqText ); |
|
95 } |
|
96 |
|
97 return channelFreq; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C void RadioEngineUtils::FormatFrequencyString( TDes& aDest, |
|
105 TUint32 aFreq, |
|
106 TInt aDecimalCount, |
|
107 TDesC& aFormat ) |
|
108 { |
|
109 TBuf<KDefaultRealWidth> freqText; |
|
110 freqText.AppendNum( static_cast<TReal>( aFreq ) / 1000.0f, TRealFormat( KDefaultRealWidth, aDecimalCount ) ); // Converts kilohertz to megahertz. |
|
111 |
|
112 // Converts the numbers to the proper display mode. |
|
113 |
|
114 if ( aFormat.Length() <= 0 || freqText.Length() > aDest.MaxLength() ) // No format. |
|
115 { |
|
116 aDest.Copy( freqText.Left( aDest.Length() ) ); |
|
117 } |
|
118 else |
|
119 { |
|
120 StringLoader::Format( aDest, aFormat, KErrNotFound, freqText ); |
|
121 } |
|
122 } |
|
123 |