author | hgs |
Fri, 15 Oct 2010 16:26:27 +0300 | |
changeset 57 | 21be958eb3ce |
parent 38 | f8c3d4e6102c |
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 <bautils.h> |
|
20 |
#include <coemain.h> |
|
21 |
#include <ConeResLoader.h> |
|
22 |
#include <f32file.h> |
|
23 |
#include <data_caging_path_literals.hrh> |
|
24 |
||
25 |
// User includes |
|
26 |
#include "cradiosettingsimp.h" |
|
27 |
#include "cradioapplicationsettings.h" |
|
28 |
#include "cradioenginesettings.h" |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
29 |
//#include "radioengineutils.h" |
24 | 30 |
#include "cradioenginelogger.h" |
31 |
||
32 |
||
33 |
// ======== MEMBER FUNCTIONS ======== |
|
34 |
||
35 |
// --------------------------------------------------------------------------- |
|
36 |
// |
|
37 |
// --------------------------------------------------------------------------- |
|
38 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
39 |
CRadioSettingsImp* CRadioSettingsImp::NewL() |
24 | 40 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
41 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 42 |
CRadioSettingsImp* self = new (ELeave) CRadioSettingsImp; |
43 |
CleanupStack::PushL( self ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
44 |
self->ConstructL(); |
24 | 45 |
CleanupStack::Pop( self ); |
46 |
return self; |
|
47 |
} |
|
48 |
||
49 |
// --------------------------------------------------------------------------- |
|
50 |
// |
|
51 |
// --------------------------------------------------------------------------- |
|
52 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
53 |
void CRadioSettingsImp::ConstructL() |
24 | 54 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
55 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
56 |
iFsSession = new ( ELeave ) RFs; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
57 |
User::LeaveIfError( iFsSession->Connect() ); |
24 | 58 |
|
59 |
// Constructs the implementors of the interfaces. |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
60 |
iApplicationSettings = CRadioApplicationSettings::NewL(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
61 |
iEngineSettings = CRadioEngineSettings::NewL( *this ); |
24 | 62 |
} |
63 |
||
64 |
// --------------------------------------------------------------------------- |
|
65 |
// |
|
66 |
// --------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
CRadioSettingsImp::CRadioSettingsImp() |
|
69 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
70 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 71 |
} |
72 |
||
73 |
// --------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
// --------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
CRadioSettingsImp::~CRadioSettingsImp() |
|
78 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
79 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 80 |
delete iEngineSettings; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
delete iApplicationSettings; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
82 |
if ( iFsSession ) |
24 | 83 |
{ |
38 | 84 |
iFsSession->Close(); |
24 | 85 |
} |
38 | 86 |
delete iFsSession; |
24 | 87 |
} |
88 |
||
89 |
// --------------------------------------------------------------------------- |
|
90 |
// Determines if region is allowed. |
|
91 |
// --------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
TBool CRadioSettingsImp::IsRegionAllowed( TRadioRegion aRegionId ) const |
|
94 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
95 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 96 |
return iEngineSettings->IsRegionAllowed( aRegionId ); |
97 |
} |
|
98 |
||
99 |
// --------------------------------------------------------------------------- |
|
100 |
// Returns the application settings interface. |
|
101 |
// --------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
MRadioApplicationSettings& CRadioSettingsImp::ApplicationSettings() const |
|
104 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
105 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 106 |
return *iApplicationSettings; |
107 |
} |
|
108 |
||
109 |
// --------------------------------------------------------------------------- |
|
110 |
// Returns the radio settings interface. |
|
111 |
// --------------------------------------------------------------------------- |
|
112 |
// |
|
113 |
MRadioEngineSettings& CRadioSettingsImp::EngineSettings() const |
|
114 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
115 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 116 |
return *iEngineSettings; |
117 |
} |
|
118 |
||
119 |
// --------------------------------------------------------------------------- |
|
120 |
// Returns the radio settings setter interface. |
|
121 |
// --------------------------------------------------------------------------- |
|
122 |
// |
|
123 |
MRadioSettingsSetter& CRadioSettingsImp::RadioSetter() const |
|
124 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
125 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 126 |
return *iEngineSettings; |
127 |
} |
|
128 |
||
129 |
// --------------------------------------------------------------------------- |
|
130 |
// Static version of ResolveDriveL. |
|
131 |
// --------------------------------------------------------------------------- |
|
132 |
// |
|
133 |
void CRadioSettingsImp::ResolveDriveL( TFileName& aFileName, const TDesC& aPath ) |
|
134 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
135 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
136 |
LEVEL3( LOG_FORMAT( "aFileName = %S, aPath = %S", &aFileName, &aPath ) ); |
38 | 137 |
|
24 | 138 |
TFileName fileName; |
139 |
TFileName baseResource; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
140 |
TFindFile finder( *iFsSession ); |
24 | 141 |
TLanguage language( ELangNone ); |
142 |
||
143 |
_LIT( resourceFileExt, ".rsc" ); |
|
144 |
_LIT( resourceFileWildExt, ".r*" ); |
|
145 |
||
146 |
TParsePtrC parse( aFileName ); |
|
147 |
TBool isResourceFile = ( parse.Ext() == resourceFileExt() ); |
|
148 |
||
149 |
TInt err = KErrUnknown; |
|
150 |
if ( isResourceFile ) |
|
151 |
{ |
|
152 |
CDir* entries = NULL; |
|
153 |
fileName.Copy( parse.Name() ); |
|
154 |
fileName.Append( resourceFileWildExt() ); |
|
155 |
err = finder.FindWildByDir( fileName, aPath, entries ); |
|
156 |
delete entries; |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
160 |
// TFindFile applies search order that is from |
|
161 |
// drive Y to A, then Z |
|
162 |
err = finder.FindByDir( aFileName, aPath ); |
|
163 |
} |
|
164 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
165 |
LEVEL3( LOG_FORMAT( "err = %d", err ) ); |
24 | 166 |
TBool found = EFalse; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
167 |
if ( !isResourceFile && ( KErrNone == err ) ) |
24 | 168 |
{ |
169 |
found = ETrue; |
|
170 |
aFileName.Zero(); |
|
171 |
aFileName.Append( finder.File() ); |
|
172 |
} |
|
173 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
174 |
while ( !found && ( KErrNone == err ) && isResourceFile ) |
24 | 175 |
{ |
176 |
// Found file |
|
177 |
fileName.Zero(); |
|
178 |
TParsePtrC foundPath( finder.File() ); |
|
179 |
fileName.Copy( foundPath.DriveAndPath() ); |
|
180 |
fileName.Append( aFileName ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
181 |
BaflUtils::NearestLanguageFile( *iFsSession, fileName, language ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
182 |
if ( language != ELangNone && BaflUtils::FileExists( *iFsSession, fileName ) ) |
24 | 183 |
{ |
184 |
found = ETrue; |
|
185 |
aFileName.Zero(); |
|
186 |
aFileName.Copy( fileName ); |
|
187 |
} |
|
188 |
else |
|
189 |
{ |
|
190 |
if ( language == ELangNone && |
|
191 |
!baseResource.Compare( KNullDesC ) && |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
192 |
BaflUtils::FileExists( *iFsSession, fileName ) ) |
24 | 193 |
{ |
194 |
baseResource.Copy( fileName ); |
|
195 |
} |
|
196 |
CDir* entries = NULL; |
|
197 |
err = finder.FindWild( entries ); |
|
198 |
delete entries; |
|
199 |
} |
|
200 |
} |
|
201 |
||
202 |
if ( !found && baseResource.Compare( KNullDesC ) ) |
|
203 |
{ |
|
204 |
// If we found *.rsc then better to use that than nothing |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
205 |
if ( BaflUtils::FileExists( *iFsSession, baseResource ) ) |
24 | 206 |
{ |
207 |
found = ETrue; |
|
208 |
aFileName.Zero(); |
|
209 |
aFileName.Append( baseResource ); |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
if ( !found ) |
|
214 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
LEVEL3( LOG_FORMAT( "File %S not found ( err = %d )!", &aFileName, err ) ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
216 |
if ( !err ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
217 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
218 |
err = KErrNotFound; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
219 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
220 |
User::Leave( err ); |
24 | 221 |
} |
222 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
223 |
LEVEL3( LOG_FORMAT( "aFileName = %S", &aFileName ) ); |
24 | 224 |
} |
225 |
||
226 |
// --------------------------------------------------------------------------- |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
227 |
// Returns the file server session |
24 | 228 |
// --------------------------------------------------------------------------- |
229 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
230 |
RFs& CRadioSettingsImp::FsSession() |
24 | 231 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
232 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
233 |
return *iFsSession; |
24 | 234 |
} |