|
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @internalComponent |
|
18 @released |
|
19 */ |
|
20 |
|
21 #include "ssmuiproviderdll.h" |
|
22 #include "ssmpanic.h" |
|
23 #include <e32property.h> |
|
24 #include "ssmdebug.h" |
|
25 |
|
26 const TUid KPSStartupUid = {0x2000E65E}; |
|
27 const TUid KSecurityPinNotifierUid = {0x2000E667}; |
|
28 const TUid KScreenOutputChannel = {0x10009D48}; |
|
29 const TUid KEmergencyCallPropertyCategory = {0x2001032C}; |
|
30 |
|
31 const TUint KEmergencyCallPropertyKey = 0x0101; |
|
32 const TUint KSimStatusPropertyKey = 0x0102; |
|
33 |
|
34 const TUid KSecurityStatusPropertyCategory = {0x2000E664}; |
|
35 |
|
36 const TUid KRFStatusPropertyCategory = {0x2000D75B}; |
|
37 const TUint KRFStatusPropertyKey = 0x2001D2A9; |
|
38 const TUid KValidateRTCPropertyCategory = {0x2000D75B}; |
|
39 const TUint KValidateRTCPropertyKey = 0x2001D2AB; |
|
40 //Number of clusterSize to be reserve for phone memory space |
|
41 const TInt KNumberOfCluster = 2; |
|
42 |
|
43 _LIT(KTsyModuleName, "mm.tsy"); |
|
44 _LIT(KTsyPhoneName, "GsmPhone1"); |
|
45 |
|
46 CSsmUiSpecific::CSsmUiSpecific() |
|
47 : iReferenceCount(1), iReservedPhoneMemory(0) |
|
48 { |
|
49 } |
|
50 |
|
51 EXPORT_C CSsmUiSpecific::~CSsmUiSpecific() |
|
52 { |
|
53 iReservedPhoneMemoryFs.Close(); |
|
54 } |
|
55 |
|
56 EXPORT_C TUid CSsmUiSpecific::StartupPSUid() |
|
57 { |
|
58 return KPSStartupUid; |
|
59 } |
|
60 |
|
61 EXPORT_C TUid CSsmUiSpecific::SecurityPinNotifierUid() |
|
62 { |
|
63 return KSecurityPinNotifierUid; |
|
64 } |
|
65 |
|
66 EXPORT_C TUint CSsmUiSpecific::EmergencyCallPropertyKey() |
|
67 { |
|
68 return KEmergencyCallPropertyKey; |
|
69 } |
|
70 |
|
71 EXPORT_C TUid CSsmUiSpecific::EmergencyCallPropertyCategory() |
|
72 { |
|
73 return KEmergencyCallPropertyCategory; |
|
74 } |
|
75 |
|
76 EXPORT_C TBool CSsmUiSpecific::IsSimSupported() |
|
77 { |
|
78 return ETrue; |
|
79 } |
|
80 |
|
81 EXPORT_C void CSsmUiSpecific::SetSecurityStatus(const TStrtSecurityStatus& aSecurityStatus) |
|
82 { |
|
83 iStrtSecurityStatus = aSecurityStatus; |
|
84 } |
|
85 |
|
86 EXPORT_C TStrtSecurityStatus CSsmUiSpecific::SecurityStatus() const |
|
87 { |
|
88 return iStrtSecurityStatus; |
|
89 } |
|
90 |
|
91 EXPORT_C CSsmUiSpecific* CSsmUiSpecific::InstanceL() |
|
92 { |
|
93 CSsmUiSpecific* self; |
|
94 |
|
95 //Check Tls data |
|
96 if (NULL == Dll::Tls()) |
|
97 { |
|
98 //Instantiate CSsmUiSpecific if TLS is null |
|
99 self = new (ELeave) CSsmUiSpecific(); |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(); |
|
102 //Copy CSsmUiSpecific pointer in TLS |
|
103 User::LeaveIfError(Dll::SetTls(self)); |
|
104 CleanupStack::Pop(self); |
|
105 } |
|
106 else |
|
107 { |
|
108 //CSsmUiSpecific has already been instantiated |
|
109 self = static_cast<CSsmUiSpecific*>(Dll::Tls()); |
|
110 ++self->iReferenceCount; |
|
111 } |
|
112 return self; |
|
113 } |
|
114 |
|
115 EXPORT_C void CSsmUiSpecific::Release() |
|
116 { |
|
117 TAny* tlsPtr = Dll::Tls(); |
|
118 __ASSERT_DEBUG(NULL != tlsPtr, User::Panic(KPanicSsmUiSpecific, KErrNotFound)); |
|
119 |
|
120 CSsmUiSpecific* self = static_cast<CSsmUiSpecific*>(tlsPtr); |
|
121 if (0 == --self->iReferenceCount) |
|
122 { |
|
123 Dll::FreeTls(); |
|
124 delete self; |
|
125 } |
|
126 } |
|
127 |
|
128 EXPORT_C TUid CSsmUiSpecific::ScreenOutputChannelUid() |
|
129 { |
|
130 return KScreenOutputChannel; |
|
131 } |
|
132 |
|
133 EXPORT_C TUint CSsmUiSpecific::SimStatusPropertyKey() |
|
134 { |
|
135 return KSimStatusPropertyKey; |
|
136 } |
|
137 |
|
138 EXPORT_C TBool CSsmUiSpecific::IsSimStateChangeAllowed() |
|
139 { |
|
140 return ETrue; |
|
141 } |
|
142 |
|
143 EXPORT_C TBool CSsmUiSpecific::IsAmaStarterSupported() |
|
144 { |
|
145 return ETrue; |
|
146 } |
|
147 |
|
148 EXPORT_C HBufC* CSsmUiSpecific::GetTsyModuleNameL() |
|
149 { |
|
150 HBufC* tstModuleName = KTsyModuleName().AllocL(); |
|
151 return tstModuleName; |
|
152 } |
|
153 |
|
154 EXPORT_C TUid CSsmUiSpecific::StarterPSUid() |
|
155 { |
|
156 return KSecurityStatusPropertyCategory; |
|
157 } |
|
158 |
|
159 EXPORT_C HBufC* CSsmUiSpecific::PhoneTsyNameL() |
|
160 { |
|
161 HBufC* tsyPhoneName = KTsyPhoneName().AllocL(); |
|
162 return tsyPhoneName; |
|
163 } |
|
164 |
|
165 EXPORT_C TBool CSsmUiSpecific::IsSimPresent() |
|
166 { |
|
167 return ETrue; |
|
168 } |
|
169 |
|
170 EXPORT_C TBool CSsmUiSpecific::IsSimlessOfflineSupported() |
|
171 { |
|
172 return ETrue; |
|
173 } |
|
174 |
|
175 EXPORT_C TBool CSsmUiSpecific::IsNormalBoot() |
|
176 { |
|
177 return ETrue; |
|
178 } |
|
179 |
|
180 EXPORT_C TBool CSsmUiSpecific::IsSimChangedReset() |
|
181 { |
|
182 return ETrue; |
|
183 } |
|
184 |
|
185 EXPORT_C TUint CSsmUiSpecific::RFStatusPropertyKey() |
|
186 { |
|
187 return KRFStatusPropertyKey; |
|
188 } |
|
189 |
|
190 EXPORT_C TUid CSsmUiSpecific::RFStatusPropertyCategory() |
|
191 { |
|
192 return KRFStatusPropertyCategory; |
|
193 } |
|
194 EXPORT_C TUint CSsmUiSpecific::ValidateRTCPropertyKey() |
|
195 { |
|
196 return KValidateRTCPropertyKey; |
|
197 } |
|
198 |
|
199 EXPORT_C TUid CSsmUiSpecific::ValidateRTCPropertyCategory() |
|
200 { |
|
201 return KValidateRTCPropertyCategory; |
|
202 } |
|
203 |
|
204 EXPORT_C TInt CSsmUiSpecific::PhoneMemoryRootDriveId() |
|
205 { |
|
206 return EDriveC; |
|
207 } |
|
208 |
|
209 /** |
|
210 Leaving construction inside ConstructL |
|
211 */ |
|
212 void CSsmUiSpecific::ConstructL() |
|
213 { |
|
214 User::LeaveIfError( iReservedPhoneMemoryFs.Connect() ); |
|
215 } |
|
216 |
|
217 /** |
|
218 Reserve two ClusterSize in Phone Memory Space on H/W |
|
219 and 512 bytes for __WINS__ |
|
220 @return KErrNone if successful or systemwide error |
|
221 */ |
|
222 EXPORT_C TInt CSsmUiSpecific::ReservePhoneMemorySpace() |
|
223 { |
|
224 TVolumeIOParamInfo volumeParamInfo; |
|
225 const TInt phoneMemoryDriveID = PhoneMemoryRootDriveId(); |
|
226 TInt errorCode = iReservedPhoneMemoryFs.VolumeIOParam(phoneMemoryDriveID, volumeParamInfo); |
|
227 if( KErrNone == errorCode ) |
|
228 { |
|
229 #ifdef __WINS__ |
|
230 //512 bytes for __WINS__ |
|
231 const TInt reservedMemory = 512; |
|
232 #else |
|
233 //Reserving two clusterSize Phone memory |
|
234 const TInt reservedMemory = KNumberOfCluster * (volumeParamInfo.iClusterSize); |
|
235 #endif //__WINS__ |
|
236 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace(phoneMemoryDriveID, reservedMemory); |
|
237 |
|
238 if ( KErrNone == errorCode ) |
|
239 { |
|
240 iReservedPhoneMemory = reservedMemory; |
|
241 } |
|
242 } |
|
243 return errorCode; |
|
244 } |
|
245 |
|
246 /** |
|
247 Free reserved bytes from Phone Memory Space. If aSpaceToFree is 0 bytes |
|
248 then free complete reserved memory |
|
249 @param aSpaceToFree request to free memory |
|
250 @return KErrNone if successful or systemwide error |
|
251 */ |
|
252 EXPORT_C TInt CSsmUiSpecific::FreeReservedPhoneMemorySpace(const TInt aSpaceToFree) |
|
253 { |
|
254 TInt errorCode(KErrGeneral); |
|
255 DEBUGPRINT3A("Reserved memory is = %d bytes, Request to free memory is = %d bytes", iReservedPhoneMemory, aSpaceToFree); |
|
256 if(0 < iReservedPhoneMemory) |
|
257 { |
|
258 if(0 == aSpaceToFree) |
|
259 { |
|
260 //Free complete reserved phone memory |
|
261 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), 0 ); |
|
262 DEBUGPRINT2A("Freeing memory completed with = %d", errorCode); |
|
263 iReservedPhoneMemory = 0; |
|
264 } |
|
265 else |
|
266 { |
|
267 TInt newReserveSize = iReservedPhoneMemory - aSpaceToFree; |
|
268 newReserveSize = newReserveSize >= 0 ? newReserveSize : 0; |
|
269 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), newReserveSize ); |
|
270 DEBUGPRINT2A("Freeing partial phone memory completed with = %d", errorCode); |
|
271 if(KErrNone == errorCode) |
|
272 { |
|
273 iReservedPhoneMemory = newReserveSize; |
|
274 } |
|
275 } |
|
276 } |
|
277 return errorCode; |
|
278 } |