author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 21 Jun 2010 17:12:14 +0300 | |
branch | RCL_3 |
changeset 39 | 2bb754abd467 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-2009 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 the License "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 |
// \e32\kernel\sproperty.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <kernel/kern_priv.h> |
|
19 |
#include "execs.h" |
|
20 |
||
21 |
#define __PS_ASSERT(aCond) \ |
|
22 |
__ASSERT_DEBUG( (aCond), ( \ |
|
23 |
Kern::Printf("Assertion '" #aCond "' failed;\nFile: '" \ |
|
24 |
__FILE__ "' Line: %d\n", __LINE__), \ |
|
25 |
Kern::Fault("Pub&Sub", 0)) ) |
|
26 |
||
27 |
inline DProcess* CurProcess() |
|
28 |
{ |
|
29 |
return TheCurrentThread->iOwningProcess; |
|
30 |
} |
|
31 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
// Used by a thread to schedule cancelation of Subscribe request in Supervisor thread. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
class TCancelQ: public SDblQueLink |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
{ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
public: |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
TPropertySubsRequest* iPropSubRequest;//The request to be cancelled, can be NULL |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
NFastSemaphore iFSemaphore;//Semafore to be signalled by Supervisor thread after the request is cancelled. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
}; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
|
0 | 40 |
class TProperty |
41 |
{ |
|
42 |
public: |
|
43 |
static TInt Init(); |
|
44 |
||
45 |
static TInt Attach(TUint aCategory, TUint aKey, TProperty** aProp); |
|
46 |
static TInt Open(TUint aCategory, TUint aKey, TProperty** aProp); |
|
47 |
void Close(); |
|
48 |
||
49 |
TInt Define(const TPropertyInfo*, DProcess*); |
|
50 |
TInt Delete(DProcess*); |
|
51 |
||
52 |
TInt Subscribe(TPropertySubsRequest* aSubs, DProcess*); |
|
53 |
void Cancel(TPropertySubsRequest* aSubs); |
|
54 |
||
55 |
TInt GetI(TInt* aValue, DProcess*); |
|
56 |
TInt GetB(TUint8* aBuf, TInt* aSize, DProcess*, TBool aUser); |
|
57 |
TInt SetI(TInt aValue, DProcess*); |
|
58 |
TInt SetB(const TUint8*, TInt aSize, DProcess*, TBool aUser); |
|
59 |
||
60 |
static TInt FindGetI(TUint aCategory, TUint aKey, TInt* aValue, DProcess*); |
|
61 |
static TInt FindSetI(TUint aCategory, TUint aKey, TInt aValue, DProcess*); |
|
62 |
||
63 |
// Called with system or feature locked |
|
64 |
TBool IsDefined() |
|
65 |
{ |
|
66 |
return iType != RProperty::ETypeLimit; |
|
67 |
} |
|
68 |
||
69 |
// Called with system or feature locked |
|
70 |
RProperty::TType Type() |
|
71 |
{ |
|
72 |
return (RProperty::TType) iType; |
|
73 |
} |
|
74 |
||
75 |
// Called with system or feature locked |
|
76 |
TInt BufSize() |
|
77 |
{ |
|
78 |
__PS_ASSERT(iType == RProperty::EByteArray || iType == RProperty::ELargeByteArray); |
|
79 |
return iBuf ? iBuf->iBufSize : 0; |
|
80 |
} |
|
81 |
||
82 |
||
83 |
// The property attributes. |
|
84 |
// Meaningful for defined properties only (ie. iType != RProperty::ETypeLimit) |
|
85 |
// Constant while the property is defined |
|
86 |
TUint32 Owner() |
|
87 |
{ return iOwner; } |
|
88 |
||
89 |
/// Ensure pages in the source buffer are paged in and lock them |
|
90 |
static TInt LockSourcePages(const TUint8* aBuf, TInt aSize); |
|
91 |
||
92 |
/// Unlock source pages again |
|
93 |
static void UnlockSourcePages(); |
|
94 |
||
95 |
#ifdef _DEBUG |
|
96 |
static TBool IsLocked() |
|
97 |
// used in assertions only |
|
98 |
{ return FeatureLock->iCleanup.iThread == TheCurrentThread; } |
|
99 |
#endif |
|
100 |
||
101 |
public: |
|
102 |
const TUint iCategory; |
|
103 |
const TUint iKey; |
|
104 |
||
105 |
private: |
|
106 |
// Acquire the feature lock |
|
107 |
// Called in CS |
|
108 |
static void Lock() |
|
109 |
{ |
|
110 |
Kern::MutexWait(*FeatureLock); |
|
111 |
} |
|
112 |
||
113 |
// Release the feature lock |
|
114 |
// Called in CS |
|
115 |
static void Unlock() |
|
116 |
{ |
|
117 |
Kern::MutexSignal(*FeatureLock); |
|
118 |
} |
|
119 |
||
120 |
static void CompleteRequest(TPropertySubsRequest*, TInt aReason); |
|
121 |
static void CompleteQue(SDblQue* aQue, TInt aReason); |
|
122 |
static void CompleteDfc(TAny* aQue); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
static void CompleteDfcByKErrPermissionDenied(TAny* aQue); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
static void CompleteDfcByKErrNotFound(TAny* aQue); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
static void CompleteCancellationQDfc(TAny* aQue); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
|
0 | 127 |
static TUint Hash(TUint aCategory, TUint aKey); |
128 |
static TProperty** Lookup(TUint aCategory, TUint aKey); |
|
129 |
static TInt LookupOrCreate(TUint aCategory, TUint aKey, TProperty**); |
|
130 |
||
131 |
TAny* operator new(TUint aSize) __NO_THROW |
|
132 |
{ return Kern::AllocZ(aSize); } |
|
133 |
||
134 |
TProperty(TUint aCategory, TUint aKey); |
|
135 |
||
136 |
void SetNotDefined() |
|
137 |
{ iType = RProperty::ETypeLimit; } |
|
138 |
||
139 |
inline void Use(); |
|
140 |
void Release(); |
|
141 |
||
142 |
void CompleteByDfc(); |
|
143 |
||
144 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
145 |
TBool DoCheckDeleteRights(DProcess* aProcess, const char* aDiagnostic); |
|
146 |
TBool DoCheckDefineRights(DProcess* aProcess, const char* aDiagnostic); |
|
147 |
TBool DoCheckGetRights(DProcess* aProcess, const char* aDiagnostic); |
|
148 |
TBool DoCheckSetRights(DProcess* aProcess, const char* aDiagnostic); |
|
149 |
#endif //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
150 |
TBool DoCheckDeleteRights(DProcess* aProcess); |
|
151 |
TBool DoCheckDefineRights(DProcess* aProcess); |
|
152 |
TBool DoCheckGetRights(DProcess* aProcess); |
|
153 |
TBool DoCheckSetRights(DProcess* aProcess); |
|
154 |
||
155 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
156 |
inline TBool CheckDeleteRights(DProcess* aProcess, const char* aDiagnostic=0) |
|
157 |
{ |
|
158 |
return DoCheckDeleteRights(aProcess, aDiagnostic); |
|
159 |
} |
|
160 |
||
161 |
inline TBool CheckDefineRights(DProcess* aProcess, const char* aDiagnostic=0) |
|
162 |
{ |
|
163 |
return DoCheckDefineRights(aProcess, aDiagnostic); |
|
164 |
} |
|
165 |
||
166 |
inline TBool CheckGetRights(DProcess* aProcess, const char* aDiagnostic=0) |
|
167 |
{ |
|
168 |
return DoCheckGetRights(aProcess, aDiagnostic); |
|
169 |
} |
|
170 |
||
171 |
inline TBool CheckSetRights(DProcess* aProcess, const char* aDiagnostic=0) |
|
172 |
{ |
|
173 |
return DoCheckSetRights(aProcess, aDiagnostic); |
|
174 |
} |
|
175 |
||
176 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
177 |
// Only available to NULL arguments |
|
178 |
inline TBool CheckDeleteRights(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/=NULL) |
|
179 |
{ |
|
180 |
return DoCheckDeleteRights(aProcess); |
|
181 |
} |
|
182 |
||
183 |
inline TBool CheckDefineRights(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/=NULL) |
|
184 |
{ |
|
185 |
return DoCheckDefineRights(aProcess); |
|
186 |
} |
|
187 |
||
188 |
inline TBool CheckGetRights(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/=NULL) |
|
189 |
{ |
|
190 |
return DoCheckGetRights(aProcess); |
|
191 |
} |
|
192 |
||
193 |
inline TBool CheckSetRights(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/=NULL) |
|
194 |
{ |
|
195 |
return DoCheckSetRights(aProcess); |
|
196 |
} |
|
197 |
||
198 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
199 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
enum { KCancellationDfcPriority = 1, KCompletionDfcPriority = 2 }; |
0 | 201 |
static TDfc CompletionDfc; |
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
static TDfc CompletionDfcPermissionDenied; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
static TDfc CompletionDfcNotFound; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
static TDfc CancellationDfc; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
// subscriptions to be completed by the DFCs, protected by system lock |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
static SDblQue CompletionQue; // to be completed by KerrNone |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
static SDblQue CompletionQuePermissionDenied; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
static SDblQue CompletionQueNotFound; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
static SDblQue CancellationQue; |
0 | 211 |
|
212 |
static DMutex* FeatureLock; ///< Order KMutexOrdPubSub |
|
213 |
||
214 |
// hash table collision lists |
|
215 |
enum { KHashTableLimit = 32 }; // must be power of 2 |
|
216 |
static TProperty* Table[KHashTableLimit]; // protected by the feature lock |
|
217 |
||
218 |
#ifdef __DEMAND_PAGING__ |
|
219 |
static DMutex* PagingLockMutex; ///< Mutex used to protect demand paging lock, order KMutexOrdPubSub2 |
|
220 |
static DDemandPagingLock* PagingLock; ///< Locks user memory when copying large properties |
|
221 |
#endif |
|
222 |
||
223 |
// iType == RProperty::ETypeLimit means not defined |
|
224 |
TUint8 iType; // updates require the system lock AND the feature lock |
|
225 |
// reads require only one of them |
|
226 |
// The property attributes. |
|
227 |
// Meaningful for defined properties only (ie. iType != RProperty::ETypeLimit) |
|
228 |
// Constant while the property is defined |
|
229 |
TUint8 iAttr; |
|
230 |
TCompiledSecurityPolicy iReadPolicy; |
|
231 |
TCompiledSecurityPolicy iWritePolicy; |
|
232 |
TUint32 iOwner; |
|
233 |
||
234 |
TUint iRefCount; // protected by the feature lock |
|
235 |
TProperty* iNext; // hash table collision list link - |
|
236 |
// protected by the feature lock |
|
237 |
||
238 |
class TBuf |
|
239 |
{ // Viraiable-size buffer for byte array property values |
|
240 |
public: |
|
241 |
static TBuf* New(TInt aSize); |
|
242 |
||
243 |
TUint16 iBufSize; // buffer size - constant |
|
244 |
TUint16 iSize; // actual property size - protected by the system lock |
|
245 |
TUint8 iBytes[1]; // byte array - protected by the system lock |
|
246 |
}; |
|
247 |
||
248 |
// The property value |
|
249 |
// Meaningful for defined properties only (ie. iType != RProperty::ETypeLimit) |
|
250 |
union // the value (ie. iValue or iBuf->iBytes) is protected by the system lock |
|
251 |
{ |
|
252 |
TBuf* iBuf; // pointer updates of a defined property (eg. buffer |
|
253 |
// reallocation) require the system AND the feature locks; |
|
254 |
// pointer reads (eg to get/set byte values) require any of them |
|
255 |
TInt iValue; |
|
256 |
}; |
|
257 |
||
258 |
// Called with system or feature locked |
|
259 |
TInt Size() |
|
260 |
{ |
|
261 |
__PS_ASSERT(iType == RProperty::EByteArray || iType == RProperty::ELargeByteArray); |
|
262 |
return iBuf ? iBuf->iSize : 0; |
|
263 |
} |
|
264 |
||
265 |
// Called with system or feature locked |
|
266 |
TUint8* Buf() |
|
267 |
{ |
|
268 |
__PS_ASSERT(iType == RProperty::EByteArray || iType == RProperty::ELargeByteArray); |
|
269 |
return iBuf ? iBuf->iBytes : NULL; |
|
270 |
} |
|
271 |
||
272 |
// Called with system or feature locked |
|
273 |
void SetSize(TInt aSize) |
|
274 |
{ |
|
275 |
__PS_ASSERT(TUint(aSize) <= TUint(BufSize())); |
|
276 |
if (iBuf) |
|
277 |
iBuf->iSize = TUint16(aSize); |
|
278 |
} |
|
279 |
||
280 |
TInt _GetB(TUint8* aBuf, TInt* aSize, DProcess* aProcess, TBool aUser); |
|
281 |
TInt _SetB(const TUint8*, TInt aSize, DProcess*, TBool aUser, TBuf** aNewBufHdr); |
|
282 |
||
283 |
SDblQue iPendingQue; // pending subscriptions - protected by the system lock |
|
284 |
}; |
|
285 |
||
286 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
// Completion/Cancelation DFCs and their corresponding queues. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
// All subscribe requests are completed in Supervisor thread. |
0 | 289 |
TDfc TProperty::CompletionDfc(TProperty::CompleteDfc, &TProperty::CompletionQue, KCompletionDfcPriority); |
290 |
SDblQue TProperty::CompletionQue; |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
TDfc TProperty::CompletionDfcPermissionDenied(TProperty::CompleteDfcByKErrPermissionDenied, &TProperty::CompletionQuePermissionDenied, KCompletionDfcPriority); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
SDblQue TProperty::CompletionQuePermissionDenied; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
TDfc TProperty::CompletionDfcNotFound(TProperty::CompleteDfcByKErrNotFound, &TProperty::CompletionQueNotFound, KCompletionDfcPriority); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
SDblQue TProperty::CompletionQueNotFound; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
TDfc TProperty::CancellationDfc(TProperty::CompleteCancellationQDfc, &TProperty::CancellationQue, KCancellationDfcPriority); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
SDblQue TProperty::CancellationQue; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
|
0 | 301 |
DMutex* TProperty::FeatureLock; |
302 |
TProperty* TProperty::Table[KHashTableLimit]; |
|
303 |
||
304 |
#ifdef __DEMAND_PAGING__ |
|
305 |
DMutex* TProperty::PagingLockMutex; |
|
306 |
DDemandPagingLock* TProperty::PagingLock; |
|
307 |
_LIT(KPubSubMutexName2, "PropertyPagingLockMutex"); |
|
308 |
#endif |
|
309 |
||
310 |
TInt PubSubPropertyInit() |
|
311 |
{ return TProperty::Init(); } |
|
312 |
||
313 |
_LIT(KPubSubMutexName, "PropertyLock"); |
|
314 |
||
315 |
TInt TProperty::Init() |
|
316 |
{ // static |
|
317 |
TInt r = Kern::MutexCreate(FeatureLock, KPubSubMutexName, KMutexOrdPubSub); |
|
318 |
if (r != KErrNone) |
|
319 |
return r; |
|
320 |
CompletionDfc.SetDfcQ(K::SvMsgQ); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
CompletionDfcPermissionDenied.SetDfcQ(K::SvMsgQ); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
CompletionDfcNotFound.SetDfcQ(K::SvMsgQ); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
CancellationDfc.SetDfcQ(K::SvMsgQ); |
0 | 324 |
|
325 |
#ifdef __DEMAND_PAGING__ |
|
326 |
r = Kern::MutexCreate(PagingLockMutex, KPubSubMutexName2, KMutexOrdPubSub2); |
|
327 |
if (r != KErrNone) |
|
328 |
return r; |
|
329 |
PagingLock = new DDemandPagingLock(); |
|
330 |
if (!PagingLock) |
|
331 |
return KErrNoMemory; |
|
332 |
r = PagingLock->Alloc(RProperty::KMaxLargePropertySize); |
|
333 |
if (r != KErrNone) |
|
334 |
return r; |
|
335 |
#endif |
|
336 |
||
337 |
return KErrNone; |
|
338 |
} |
|
339 |
||
340 |
TProperty::TProperty(TUint aCategory, TUint aKey) : iCategory(aCategory), iKey(aKey) |
|
341 |
{ SetNotDefined(); } |
|
342 |
||
343 |
TUint TProperty::Hash(TUint aCategory, TUint aKey) |
|
344 |
{ // a naive hash function |
|
345 |
TUint code = (aCategory ^ aKey) & (KHashTableLimit - 1); |
|
346 |
__PS_ASSERT(code < KHashTableLimit); // KHashTableLimit must be a power of 2 |
|
347 |
return code; |
|
348 |
} |
|
349 |
||
350 |
// Called feature locked. |
|
351 |
TProperty** TProperty::Lookup(TUint aCategory, TUint aKey) |
|
352 |
{ // static |
|
353 |
TProperty** propP = &Table[Hash(aCategory, aKey)]; |
|
354 |
for (;;) |
|
355 |
{ |
|
356 |
TProperty* prop = *propP; |
|
357 |
if (!prop) break; |
|
358 |
if ((prop->iCategory == aCategory) && (prop->iKey == aKey)) break; |
|
359 |
propP = &prop->iNext; |
|
360 |
} |
|
361 |
return propP; |
|
362 |
} |
|
363 |
||
364 |
// Called feature locked. |
|
365 |
TInt TProperty::LookupOrCreate(TUint aCategory, TUint aKey, TProperty** aProp) |
|
366 |
{ // static |
|
367 |
TProperty** propP = Lookup(aCategory, aKey); |
|
368 |
TProperty* prop = *propP; |
|
369 |
if (!prop) |
|
370 |
{ |
|
371 |
prop = new TProperty(aCategory, aKey); |
|
372 |
if (!prop) |
|
373 |
{ |
|
374 |
return KErrNoMemory; |
|
375 |
} |
|
376 |
*propP = prop; |
|
377 |
} |
|
378 |
*aProp = prop; |
|
379 |
return KErrNone; |
|
380 |
} |
|
381 |
||
382 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
383 |
TBool TProperty::DoCheckDefineRights(DProcess* aProcess, const char* aDiagnostic) |
|
384 |
{ |
|
385 |
TUint32 cat=iCategory; |
|
386 |
if(cat==aProcess->iS.iSecureId) |
|
387 |
return ETrue; |
|
388 |
if(cat<(TUint32)KUidSecurityThresholdCategoryValue) |
|
389 |
return aProcess->HasCapability(ECapabilityWriteDeviceData, aDiagnostic); |
|
390 |
PlatSec::SecureIdCheckFail(aProcess, cat, aDiagnostic); |
|
391 |
return EFalse; |
|
392 |
} |
|
393 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
394 |
||
395 |
TBool TProperty::DoCheckDefineRights(DProcess* aProcess) |
|
396 |
{ |
|
397 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
398 |
return DoCheckDefineRights(aProcess, NULL); |
|
399 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
400 |
TUint32 cat=iCategory; |
|
401 |
if(cat==aProcess->iS.iSecureId) |
|
402 |
return ETrue; |
|
403 |
if(cat<(TUint32)KUidSecurityThresholdCategoryValue) |
|
404 |
return aProcess->HasCapability(ECapabilityWriteDeviceData); |
|
405 |
return EFalse; |
|
406 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
407 |
} |
|
408 |
||
409 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
410 |
// Called feature locked |
|
411 |
TBool TProperty::DoCheckDeleteRights(DProcess* aProcess, const char* aDiagnostic) |
|
412 |
{ |
|
413 |
__ASSERT_MUTEX(FeatureLock); |
|
414 |
if(aProcess->iS.iSecureId == Owner()) |
|
415 |
{ |
|
416 |
return ETrue; |
|
417 |
} |
|
418 |
PlatSec::SecureIdCheckFail(aProcess, Owner(), aDiagnostic); |
|
419 |
return EFalse; |
|
420 |
} |
|
421 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
422 |
||
423 |
TBool TProperty::DoCheckDeleteRights(DProcess* aProcess) |
|
424 |
{ |
|
425 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
426 |
return DoCheckDeleteRights(aProcess, NULL); |
|
427 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
428 |
__ASSERT_MUTEX(FeatureLock); |
|
429 |
if(aProcess->iS.iSecureId == Owner()) |
|
430 |
{ |
|
431 |
return ETrue; |
|
432 |
} |
|
433 |
return EFalse; |
|
434 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
435 |
} |
|
436 |
||
437 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
438 |
// Called system locked |
|
439 |
TBool TProperty::DoCheckGetRights(DProcess* aProcess, const char* aDiagnostic) |
|
440 |
{ |
|
441 |
return iReadPolicy.CheckPolicy(aProcess, aDiagnostic); |
|
442 |
} |
|
443 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
444 |
||
445 |
TBool TProperty::DoCheckGetRights(DProcess* aProcess) |
|
446 |
{ |
|
447 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
448 |
return DoCheckGetRights(aProcess, NULL); |
|
449 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
450 |
return iReadPolicy.CheckPolicy(aProcess); |
|
451 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
452 |
} |
|
453 |
||
454 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
455 |
// Called system locked |
|
456 |
TBool TProperty::DoCheckSetRights(DProcess* aProcess, const char* aDiagnostic) |
|
457 |
{ |
|
458 |
return iWritePolicy.CheckPolicy(aProcess, aDiagnostic); |
|
459 |
} |
|
460 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
461 |
||
462 |
TBool TProperty::DoCheckSetRights(DProcess* aProcess) |
|
463 |
{ |
|
464 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
465 |
return DoCheckSetRights(aProcess, NULL); |
|
466 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
467 |
return iWritePolicy.CheckPolicy(aProcess); |
|
468 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
469 |
} |
|
470 |
||
471 |
// Called in CS |
|
472 |
TProperty::TBuf* TProperty::TBuf::New(TInt aSize) |
|
473 |
{ // static |
|
474 |
__ASSERT_CRITICAL; |
|
475 |
TBuf* buf = (TBuf*) Kern::Alloc(_FOFF(TBuf, iBytes) + aSize); |
|
476 |
if (!buf) |
|
477 |
{ |
|
478 |
return NULL; |
|
479 |
} |
|
480 |
buf->iBufSize = TUint16(aSize); |
|
481 |
buf->iSize = 0; |
|
482 |
return buf; |
|
483 |
} |
|
484 |
||
485 |
// Called in CS |
|
486 |
TInt TProperty::Define(const TPropertyInfo* aInfo, DProcess* aProcess) |
|
487 |
{ |
|
488 |
__ASSERT_CRITICAL; |
|
489 |
if (aProcess && !CheckDefineRights(aProcess,__PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Define a Publish and Subscribe Property"))) |
|
490 |
{ |
|
491 |
return KErrPermissionDenied; |
|
492 |
} |
|
493 |
TCompiledSecurityPolicy readPolicy; |
|
494 |
TInt r = readPolicy.Set((aInfo->iReadPolicy)); |
|
495 |
if(r != KErrNone) |
|
496 |
{ |
|
497 |
return r; |
|
498 |
} |
|
499 |
TCompiledSecurityPolicy writePolicy; |
|
500 |
r = writePolicy.Set((aInfo->iWritePolicy)); |
|
501 |
if(r != KErrNone) |
|
502 |
{ |
|
503 |
return r; |
|
504 |
} |
|
505 |
if ((aInfo->iType < 0) || (RProperty::ETypeLimit <= aInfo->iType) || |
|
506 |
((aInfo->iType == RProperty::EInt) && aInfo->iSize) || |
|
507 |
(aInfo->iAttr != 0)) |
|
508 |
{ |
|
509 |
return KErrArgument; |
|
510 |
} |
|
511 |
if ((aInfo->iType == RProperty::EByteArray && aInfo->iSize > RProperty::KMaxPropertySize)) |
|
512 |
{ |
|
513 |
return KErrTooBig; |
|
514 |
} |
|
515 |
Lock(); |
|
516 |
if (IsDefined()) |
|
517 |
{ |
|
518 |
Unlock(); |
|
519 |
return KErrAlreadyExists; |
|
520 |
} |
|
521 |
if (aInfo->iSize) |
|
522 |
{ |
|
523 |
__PS_ASSERT((aInfo->iType == RProperty::EByteArray) || (aInfo->iType == RProperty::ELargeByteArray)); |
|
524 |
__PS_ASSERT(iBuf == NULL); |
|
525 |
iBuf = TBuf::New(aInfo->iSize); |
|
526 |
} |
|
527 |
||
528 |
iReadPolicy = readPolicy; |
|
529 |
iWritePolicy = writePolicy; |
|
530 |
iOwner = CurProcess()->iS.iSecureId; |
|
531 |
iAttr = 0; |
|
532 |
||
533 |
// We need to check all pending requests for read access rights and |
|
534 |
// complete those that havn't. |
|
535 |
// We have the following constraints: |
|
536 |
// - we don't want to hold the system lock iterating through 'iPendingQue' list. |
|
537 |
// - as soon as the system lock is released new entries can be added by |
|
538 |
// 'Subscribe()' and existing entries can be removed by 'Cancel()'. |
|
539 |
// - we don't want to complete a request holding the feature lock |
|
540 |
// To deal with these issues we move all 'iPendingQue' entries to one of |
|
541 |
// two temporary queues: |
|
542 |
// 'localPendingQue' for entries that will remain pending |
|
543 |
// 'localCompletionQue' for entries that will be completed |
|
544 |
// We move entries one by one dropping and reacquiring the system lock on each |
|
545 |
// iteration; we get (move) always the first 'iPendingQue' entry until the |
|
546 |
// queue becomes empty. |
|
547 |
// |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
549 |
SDblQue localPendingQue; // Will hold requests with sufficient capabilities. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
550 |
TInt accessDeniedCounter = 0;// Will count requests with no sufficient capabilities. |
0 | 551 |
NKern::LockSystem(); |
552 |
while (!iPendingQue.IsEmpty()) |
|
553 |
{ |
|
554 |
TPropertySubsRequest* subs = (TPropertySubsRequest*) iPendingQue.GetFirst(); |
|
555 |
DProcess* process = subs->iProcess; |
|
556 |
subs->iProcess = NULL; |
|
557 |
if (process && !CheckGetRights(process, __PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Subscribe to a Publish and Subscribe Property"))) |
|
558 |
{ // Check fails - will complete the subscription with an error |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
CompletionQuePermissionDenied.Add(subs); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
accessDeniedCounter++; |
0 | 561 |
} |
562 |
else |
|
563 |
{ // Check OK - will leave in the pending queue |
|
564 |
localPendingQue.Add(subs); |
|
565 |
} |
|
566 |
NKern::FlashSystem(); // preemption point |
|
567 |
} |
|
568 |
iPendingQue.MoveFrom(&localPendingQue); |
|
569 |
iType = (TUint8) aInfo->iType; |
|
570 |
NKern::UnlockSystem(); |
|
571 |
// Now the property can be accessed by other threads. |
|
572 |
Use(); |
|
573 |
Unlock(); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
// Schedule DFC to complete requests of those with insufficient capabilities. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
if (accessDeniedCounter) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
CompletionDfcPermissionDenied.Enque(); |
0 | 578 |
return KErrNone; |
579 |
} |
|
580 |
||
581 |
// Called in CS |
|
582 |
TInt TProperty::Attach(TUint aCategory, TUint aKey, TProperty** aProp) |
|
583 |
{ //static |
|
584 |
Lock(); |
|
585 |
TProperty* prop; |
|
586 |
// Attach can create a non defined property. |
|
587 |
TInt r = LookupOrCreate(aCategory, aKey, &prop); |
|
588 |
if (r != KErrNone) |
|
589 |
{ |
|
590 |
Unlock(); |
|
591 |
return r; |
|
592 |
} |
|
593 |
prop->Use(); |
|
594 |
*aProp = prop; |
|
595 |
Unlock(); |
|
596 |
return KErrNone; |
|
597 |
} |
|
598 |
||
599 |
// Called in CS |
|
600 |
TInt TProperty::Open(TUint aCategory, TUint aKey, TProperty** aProp) |
|
601 |
{ //static |
|
602 |
Lock(); |
|
603 |
TProperty* prop = *Lookup(aCategory, aKey); |
|
604 |
if (!prop) |
|
605 |
{ |
|
606 |
Unlock(); |
|
607 |
return KErrNotFound; |
|
608 |
} |
|
609 |
prop->Use(); |
|
610 |
*aProp = prop; |
|
611 |
Unlock(); |
|
612 |
return KErrNone; |
|
613 |
} |
|
614 |
||
615 |
// Called in CS |
|
616 |
void TProperty::Close() |
|
617 |
{ |
|
618 |
Lock(); |
|
619 |
Release(); |
|
620 |
// '*this' may do not exist any more |
|
621 |
Unlock(); |
|
622 |
} |
|
623 |
||
624 |
// Called in CS |
|
625 |
TInt TProperty::Delete(DProcess* aProcess) |
|
626 |
{ |
|
627 |
Lock(); |
|
628 |
if (!IsDefined()) |
|
629 |
{ |
|
630 |
Unlock(); |
|
631 |
return KErrNotFound; |
|
632 |
} |
|
633 |
if (aProcess && !CheckDeleteRights(aProcess,__PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Delete a Publish and Subscribe Property"))) |
|
634 |
{ |
|
635 |
Unlock(); |
|
636 |
return KErrPermissionDenied; |
|
637 |
} |
|
638 |
NKern::LockSystem(); |
|
639 |
// Remember that iType is the tag of iBuf and iValue union |
|
640 |
TBuf* buf = (iType != RProperty::EInt) ? iBuf : NULL; |
|
641 |
SetNotDefined(); |
|
642 |
// Down from here nobody can access the property value |
|
643 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
644 |
// Move all pending requests to completion queue (to be completed by KErrNotFound). |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
645 |
TBool pendingQueEmpty = iPendingQue.IsEmpty(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
646 |
if(!pendingQueEmpty) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
647 |
CompletionQueNotFound.MoveFrom(&iPendingQue); |
0 | 648 |
|
649 |
NKern::UnlockSystem(); |
|
650 |
||
651 |
iBuf = NULL; |
|
652 |
iValue = 0; |
|
653 |
delete buf; |
|
654 |
Release(); |
|
655 |
// '*this' may do not exist any more |
|
656 |
Unlock(); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
657 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
658 |
// Schedule Svc Dfc to complete all requests from CompletionQueNotFound. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
659 |
if (!pendingQueEmpty) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
660 |
CompletionDfcNotFound.Enque(); |
0 | 661 |
return KErrNone; |
662 |
} |
|
663 |
||
664 |
// Enter feature locked. |
|
665 |
// Return feature locked. |
|
666 |
inline void TProperty::Use() |
|
667 |
{ |
|
668 |
__ASSERT_MUTEX(FeatureLock); |
|
669 |
++iRefCount; |
|
670 |
} |
|
671 |
||
672 |
// Enter feature locked. |
|
673 |
// Return feature locked. |
|
674 |
void TProperty::Release() |
|
675 |
{ |
|
676 |
__ASSERT_MUTEX(FeatureLock); |
|
677 |
__PS_ASSERT(iRefCount); |
|
678 |
if (--iRefCount == 0) |
|
679 |
{ |
|
680 |
__PS_ASSERT(!IsDefined()); // property must not be defined. |
|
681 |
// Lookup to find the previous element in the simply linked collision list. |
|
682 |
TProperty** propP = Lookup(iCategory, iKey); |
|
683 |
*propP = iNext; |
|
684 |
delete this; |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
// Enter system locked. |
|
689 |
// Return system unlocked. |
|
690 |
TInt TProperty::Subscribe(TPropertySubsRequest* aSubs, DProcess* aProcess) |
|
691 |
{ |
|
692 |
__ASSERT_SYSTEM_LOCK; |
|
693 |
if (aSubs->iNext) |
|
694 |
{ // already pending - will Panic |
|
695 |
NKern::UnlockSystem(); |
|
696 |
return KErrInUse; |
|
697 |
} |
|
698 |
TBool defined = IsDefined(); |
|
699 |
if (defined) |
|
700 |
{ // property is defined - check access now |
|
701 |
aSubs->iProcess = NULL; |
|
702 |
if (aProcess && !CheckGetRights(aProcess,__PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Subscribe to a Publish and Subscribe Property"))) |
|
703 |
{ |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
704 |
CompletionQuePermissionDenied.Add(aSubs); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
705 |
CompletionDfcPermissionDenied.Enque(SYSTEM_LOCK); |
0 | 706 |
return KErrNone; |
707 |
} |
|
708 |
} |
|
709 |
else |
|
710 |
{ // will check when defined |
|
711 |
aSubs->iProcess = aProcess; |
|
712 |
} |
|
713 |
iPendingQue.Add(aSubs); |
|
714 |
NKern::UnlockSystem(); |
|
715 |
return KErrNone; |
|
716 |
} |
|
717 |
||
718 |
// Enter system locked. |
|
719 |
// Return system unlocked. |
|
720 |
void TProperty::Cancel(TPropertySubsRequest* aSubs) |
|
721 |
{ |
|
722 |
__ASSERT_SYSTEM_LOCK; |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
723 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
// This is set if the request is about to be completed (in SVC thread). In that case, a 'dummy' CancelationDFC |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
725 |
// will be scheduled here. This will just ensure that we don't return from Cancel before ongoing completion has finished. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
726 |
TBool scheduledForCompletition = (TInt)(aSubs->iProcess) & TPropertySubsRequest::KScheduledForCompletion; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
728 |
if (!aSubs->iNext && !scheduledForCompletition) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
{ // Neither in any queue nor scheduled for completion. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
730 |
// The request is not active - silently return. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
NKern::UnlockSystem(); |
0 | 732 |
return; |
733 |
} |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
734 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
if (aSubs->iNext) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
{ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
// Take it out from the current queue. It is usually pending queue of a property but could |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
// also be one of the completion queues. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
739 |
aSubs->Deque(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
740 |
aSubs->iNext = NULL; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
742 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
743 |
// Set process to NULL (leave KScheduledForCompletion bit as it is) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
744 |
aSubs->iProcess = (DProcess*)((TInt)aSubs->iProcess & ~TPropertySubsRequest::KProcessPtrMask); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
745 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
746 |
if (&Kern::CurrentThread() == K::SvThread) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
747 |
{ // Complete the request immediatelly if already running in supervisor thread... |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
748 |
if (!scheduledForCompletition) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
749 |
CompleteRequest(aSubs, KErrCancel); //This will also release system lock. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
750 |
else |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
751 |
NKern::UnlockSystem(); // Nothing to be done here. Just release system lock. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
752 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
else |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
{ //... or schedule DFC in supervisor thread to complete the request. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
TCancelQ linkQ; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
756 |
if (!scheduledForCompletition) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
757 |
linkQ.iPropSubRequest = aSubs; // CancelationDFC will complete this request with KErrCancel. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
758 |
else |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
linkQ.iPropSubRequest = NULL; // Schedule 'dummy' CancelationDFC (no request will be completed). |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
760 |
linkQ.iFSemaphore.iOwningThread = NKern::CurrentThread(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
761 |
CancellationQue.Add(&linkQ); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
CancellationDfc.Enque(SYSTEM_LOCK); // This will also release system lock. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
763 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
764 |
NKern::FSWait(&linkQ.iFSemaphore); // Wait for CancellationDfc to finish. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
765 |
} |
0 | 766 |
} |
767 |
||
768 |
// Enter system locked. |
|
769 |
// Return system unlocked. |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
770 |
// Executed in supervisor thread. |
0 | 771 |
void TProperty::CompleteRequest(TPropertySubsRequest* aSubs, TInt aResult) |
772 |
{ // static |
|
773 |
__ASSERT_SYSTEM_LOCK; |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
774 |
__PS_ASSERT(&Kern::CurrentThread() == K::SvThread); |
0 | 775 |
TPropertyCompleteFn fn = aSubs->iCompleteFn; |
776 |
TAny* ptr = aSubs->iPtr; |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
// Mark that this request is about to be completed. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
778 |
aSubs->iProcess = (DProcess*)((TInt)aSubs->iProcess | TPropertySubsRequest::KScheduledForCompletion); |
0 | 779 |
NKern::UnlockSystem(); |
780 |
(*fn)(ptr, aResult); |
|
781 |
} |
|
782 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
783 |
// Executed in supervisor thread. |
0 | 784 |
void TProperty::CompleteQue(SDblQue* aQue, TInt aReason) |
785 |
{ // static |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
786 |
__PS_ASSERT(&Kern::CurrentThread() == K::SvThread); |
0 | 787 |
NKern::LockSystem(); |
788 |
while (!aQue->IsEmpty()) |
|
789 |
{ |
|
790 |
TPropertySubsRequest* subs = (TPropertySubsRequest*) aQue->First(); |
|
791 |
subs->Deque(); |
|
792 |
subs->iNext = NULL; |
|
793 |
CompleteRequest(subs, aReason); |
|
794 |
NKern::LockSystem(); |
|
795 |
} |
|
796 |
NKern::UnlockSystem(); |
|
797 |
} |
|
798 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
799 |
// Executed in supervisor thread. Completes requests with KErrNone. |
0 | 800 |
void TProperty::CompleteDfc(TAny* aQue) |
801 |
{ // static |
|
802 |
CompleteQue((SDblQue*) aQue, KErrNone); |
|
803 |
} |
|
804 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
// Executed in supervisor thread. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
806 |
void TProperty::CompleteDfcByKErrPermissionDenied(TAny* aQue) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
807 |
{ // static |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
808 |
CompleteQue((SDblQue*) aQue, KErrPermissionDenied); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
810 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
// Executed in supervisor thread. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
812 |
void TProperty::CompleteDfcByKErrNotFound(TAny* aQue) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
813 |
{ // static |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
814 |
CompleteQue((SDblQue*) aQue, KErrNotFound); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
815 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
816 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
817 |
// Executed in supervisor thread. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
818 |
void TProperty::CompleteCancellationQDfc(TAny* aAny) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
819 |
{ // static |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
820 |
SDblQue* aQue = (SDblQue*)aAny; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
821 |
NKern::LockSystem(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
822 |
while (!aQue->IsEmpty() ) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
823 |
{ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
TCancelQ* first = static_cast<TCancelQ*>(aQue->First()); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
first->Deque(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
826 |
first->iNext = NULL; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
827 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
828 |
if( first->iPropSubRequest) |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
829 |
{ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
830 |
CompleteRequest(first->iPropSubRequest, KErrCancel); // This will also release system lock. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
831 |
NKern::LockSystem(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
833 |
else |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
834 |
{ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
835 |
// Do not complete the request. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
836 |
// It was already just about to be completed when Cancel request was issued. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
837 |
// As all complitions (this method included) run is Svc thread, we can here be sure that |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
838 |
// the request is now completed. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
NKern::FlashSystem(); // Preemption point |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
840 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
NKern::FSSignal( &first->iFSemaphore ); // Issue the signal that the request is now completed. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
842 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
843 |
NKern::UnlockSystem(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
} |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
|
0 | 846 |
// Enter system locked. |
847 |
// Return system unlocked. |
|
848 |
void TProperty::CompleteByDfc() |
|
849 |
{ |
|
850 |
__ASSERT_SYSTEM_LOCK; |
|
851 |
// Append elements from the pending queue to the completion queue |
|
852 |
if (!iPendingQue.IsEmpty()) |
|
853 |
{ |
|
854 |
CompletionQue.MoveFrom(&iPendingQue); |
|
855 |
CompletionDfc.Enque(SYSTEM_LOCK); |
|
856 |
} |
|
857 |
else |
|
858 |
{ |
|
859 |
NKern::UnlockSystem(); |
|
860 |
} |
|
861 |
} |
|
862 |
||
863 |
// Enter system locked. |
|
864 |
// Return system unlocked. |
|
865 |
TInt TProperty::GetI(TInt* aValue, DProcess* aProcess) |
|
866 |
{ |
|
867 |
__ASSERT_SYSTEM_LOCK; |
|
868 |
if (!IsDefined()) |
|
869 |
{ |
|
870 |
NKern::UnlockSystem(); |
|
871 |
return KErrNotFound; |
|
872 |
} |
|
873 |
if (aProcess && !CheckGetRights(aProcess,__PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Get a Publish and Subscribe Property"))) |
|
874 |
{ |
|
875 |
NKern::UnlockSystem(); |
|
876 |
return KErrPermissionDenied; |
|
877 |
} |
|
878 |
if (iType != RProperty::EInt) |
|
879 |
{ |
|
880 |
NKern::UnlockSystem(); |
|
881 |
return KErrArgument; |
|
882 |
} |
|
883 |
*aValue = iValue; |
|
884 |
NKern::UnlockSystem(); |
|
885 |
return KErrNone; |
|
886 |
} |
|
887 |
||
888 |
TInt TProperty::FindGetI(TUint aCategory, TUint aKey, TInt* aValue, DProcess* aProcess) |
|
889 |
{ |
|
890 |
Lock(); |
|
891 |
TProperty* prop = *TProperty::Lookup(aCategory, aKey); |
|
892 |
TInt r; |
|
893 |
if (!prop) |
|
894 |
r = KErrNotFound; |
|
895 |
else |
|
896 |
{ |
|
897 |
NKern::LockSystem(); |
|
898 |
r = prop->GetI(aValue, aProcess); |
|
899 |
} |
|
900 |
Unlock(); |
|
901 |
return r; |
|
902 |
} |
|
903 |
||
904 |
TInt TProperty::FindSetI(TUint aCategory, TUint aKey, TInt aValue, DProcess* aProcess) |
|
905 |
{ |
|
906 |
Lock(); |
|
907 |
TProperty* prop = *TProperty::Lookup(aCategory, aKey); |
|
908 |
TInt r; |
|
909 |
if (!prop) |
|
910 |
r = KErrNotFound; |
|
911 |
else |
|
912 |
{ |
|
913 |
NKern::LockSystem(); |
|
914 |
r = prop->SetI(aValue, aProcess); |
|
915 |
} |
|
916 |
Unlock(); |
|
917 |
return r; |
|
918 |
} |
|
919 |
||
920 |
#ifdef __EPOC32__ |
|
921 |
extern "C" { extern void kumemput_no_paging_assert(TAny* /*aAddr*/, const TAny* /*aKernAddr*/, TInt /*aLength*/); } |
|
922 |
#else |
|
923 |
inline void kumemput_no_paging_assert(TAny* aAddr, const TAny* aKernAddr, TInt aLength) |
|
924 |
{kumemput(aAddr,aKernAddr,aLength);} |
|
925 |
#endif |
|
926 |
||
927 |
// Enter system locked. |
|
928 |
// Return system unlocked. |
|
929 |
TInt TProperty::_GetB(TUint8* aBuf, TInt* aSize, DProcess* aProcess, TBool aUser) |
|
930 |
{ |
|
931 |
if (!IsDefined()) |
|
932 |
{ |
|
933 |
NKern::UnlockSystem(); |
|
934 |
return KErrNotFound; |
|
935 |
} |
|
936 |
if (aProcess && !CheckGetRights(aProcess,__PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Get a Publish and Subscribe Property"))) |
|
937 |
{ |
|
938 |
NKern::UnlockSystem(); |
|
939 |
return KErrPermissionDenied; |
|
940 |
} |
|
941 |
if (iType == RProperty::EInt) |
|
942 |
{ |
|
943 |
NKern::UnlockSystem(); |
|
944 |
return KErrArgument; |
|
945 |
} |
|
946 |
if (iType == RProperty::ELargeByteArray) |
|
947 |
{ |
|
948 |
// copy with system lock released |
|
949 |
__ASSERT_MUTEX(FeatureLock); |
|
950 |
NKern::UnlockSystem(); |
|
951 |
} |
|
952 |
TInt bufSize = *aSize; |
|
953 |
TInt size = Size(); |
|
954 |
TInt r = KErrNone; |
|
955 |
if (bufSize < size) |
|
956 |
{ |
|
957 |
size = bufSize; |
|
958 |
r = KErrOverflow; |
|
959 |
} |
|
960 |
TUint8* buf = Buf(); |
|
961 |
if (aUser) |
|
962 |
{ // Don't use 'r' to preserve possible KErrOverflow condition |
|
963 |
XTRAPD(res, XT_DEFAULT, kumemput_no_paging_assert(aBuf, buf, size)); |
|
964 |
if (res != KErrNone) |
|
965 |
r = KErrBadDescriptor; |
|
966 |
} |
|
967 |
else |
|
968 |
{ |
|
969 |
memcpy(aBuf, buf, size); |
|
970 |
} |
|
971 |
*aSize = size; |
|
972 |
if (iType != RProperty::ELargeByteArray) |
|
973 |
{ |
|
974 |
NKern::UnlockSystem(); |
|
975 |
} |
|
976 |
return r; |
|
977 |
} |
|
978 |
||
979 |
// Enter system locked. |
|
980 |
// Return system unlocked. |
|
981 |
TInt TProperty::GetB(TUint8* aBuf, TInt* aSize, DProcess* aProcess, TBool aUser) |
|
982 |
{ |
|
983 |
__ASSERT_SYSTEM_LOCK; |
|
984 |
if (iType != RProperty::ELargeByteArray) |
|
985 |
return _GetB(aBuf,aSize,aProcess,aUser); |
|
986 |
||
987 |
// Acquire feature lock for accessing large properties |
|
988 |
NKern::ThreadEnterCS(); |
|
989 |
FeatureLock->Wait(); // returns with system lock still held |
|
990 |
TInt r = _GetB(aBuf,aSize,aProcess,aUser); |
|
991 |
Unlock(); |
|
992 |
NKern::ThreadLeaveCS(); |
|
993 |
return r; |
|
994 |
} |
|
995 |
||
996 |
// Enter system locked. |
|
997 |
// Return system unlocked. |
|
998 |
TInt TProperty::SetI(TInt aValue, DProcess* aProcess) |
|
999 |
{ |
|
1000 |
__ASSERT_SYSTEM_LOCK; |
|
1001 |
if (!IsDefined()) |
|
1002 |
{ |
|
1003 |
NKern::UnlockSystem(); |
|
1004 |
return KErrNotFound; |
|
1005 |
} |
|
1006 |
if (aProcess && !CheckSetRights(aProcess, __PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Set a Publish and Subscribe Property"))) |
|
1007 |
{ |
|
1008 |
NKern::UnlockSystem(); |
|
1009 |
return KErrPermissionDenied; |
|
1010 |
} |
|
1011 |
if (iType != RProperty::EInt) |
|
1012 |
{ |
|
1013 |
NKern::UnlockSystem(); |
|
1014 |
return KErrArgument; |
|
1015 |
} |
|
1016 |
iValue = aValue; |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1017 |
CompleteByDfc(); //This will also release system lock. |
0 | 1018 |
return KErrNone; |
1019 |
} |
|
1020 |
||
1021 |
||
1022 |
#ifdef __EPOC32__ |
|
1023 |
extern "C" { extern void kumemget_no_paging_assert(TAny* /*aKernAddr*/, const TAny* /*aAddr*/, TInt /*aLength*/); } |
|
1024 |
#else |
|
1025 |
inline void kumemget_no_paging_assert(TAny* aKernAddr, const TAny* aAddr, TInt aLength) |
|
1026 |
{kumemget(aKernAddr,aAddr,aLength);} |
|
1027 |
#endif |
|
1028 |
||
1029 |
// Enter with system locked. |
|
1030 |
// Return system unlocked. |
|
1031 |
TInt TProperty::_SetB(const TUint8* aBuf, TInt aSize, DProcess* aProcess, TBool aUser, TBuf** aNewBuf) |
|
1032 |
{ |
|
1033 |
if (!IsDefined()) |
|
1034 |
{ |
|
1035 |
NKern::UnlockSystem(); |
|
1036 |
return KErrNotFound; |
|
1037 |
} |
|
1038 |
if (aProcess && !CheckSetRights(aProcess, __PLATSEC_DIAGNOSTIC_STRING("Checked whilst trying to Set a Publish and Subscribe Property"))) |
|
1039 |
{ |
|
1040 |
NKern::UnlockSystem(); |
|
1041 |
return KErrPermissionDenied; |
|
1042 |
} |
|
1043 |
if (iType == RProperty::EInt) |
|
1044 |
{ |
|
1045 |
NKern::UnlockSystem(); |
|
1046 |
return KErrArgument; |
|
1047 |
} |
|
1048 |
else if (iType == RProperty::EByteArray) |
|
1049 |
{ |
|
1050 |
if (aSize > RProperty::KMaxPropertySize) |
|
1051 |
{ |
|
1052 |
NKern::UnlockSystem(); |
|
1053 |
return KErrTooBig; |
|
1054 |
} |
|
1055 |
} |
|
1056 |
else if (iType == RProperty::ELargeByteArray) |
|
1057 |
{ |
|
1058 |
__ASSERT_MUTEX(FeatureLock); |
|
1059 |
NKern::UnlockSystem(); |
|
1060 |
if (aSize > RProperty::KMaxLargePropertySize) |
|
1061 |
{ |
|
1062 |
return KErrTooBig; |
|
1063 |
} |
|
1064 |
} |
|
1065 |
if (aSize > BufSize()) |
|
1066 |
{ |
|
1067 |
if (aNewBuf == NULL || *aNewBuf == NULL) |
|
1068 |
{ |
|
1069 |
if (iType != RProperty::ELargeByteArray) |
|
1070 |
{ |
|
1071 |
NKern::UnlockSystem(); |
|
1072 |
} |
|
1073 |
return KErrOverflow; |
|
1074 |
} |
|
1075 |
// New buffer is provided by the caller - switch on it |
|
1076 |
TBuf* oldBuf = iBuf; |
|
1077 |
iBuf = *aNewBuf; |
|
1078 |
// Caller will deallocate the old buffer out of the system lock context |
|
1079 |
*aNewBuf = oldBuf; |
|
1080 |
} |
|
1081 |
if (aUser) |
|
1082 |
{ |
|
1083 |
__NK_ASSERT_DEBUG(iType==RProperty::ELargeByteArray); |
|
1084 |
XTRAPD(r, XT_DEFAULT, kumemget_no_paging_assert(Buf(), aBuf, aSize)); |
|
1085 |
if (r != KErrNone) |
|
1086 |
return KErrBadDescriptor; |
|
1087 |
} |
|
1088 |
else |
|
1089 |
{ |
|
1090 |
memcpy(Buf(), aBuf, aSize); |
|
1091 |
} |
|
1092 |
SetSize(aSize); |
|
1093 |
if (iType == RProperty::ELargeByteArray) |
|
1094 |
{ |
|
1095 |
NKern::LockSystem(); |
|
1096 |
} |
|
1097 |
CompleteByDfc(); |
|
1098 |
return KErrNone; |
|
1099 |
} |
|
1100 |
||
1101 |
// Enter system locked. |
|
1102 |
// Return system unlocked. |
|
1103 |
TInt TProperty::SetB(const TUint8* aBuf, TInt aSize, DProcess* aProcess, TBool aUser) |
|
1104 |
{ // static |
|
1105 |
__ASSERT_SYSTEM_LOCK; |
|
1106 |
TBuf* nBuf = 0; |
|
1107 |
if (iType != RProperty::ELargeByteArray) |
|
1108 |
{ |
|
1109 |
// Try to set without buffer reallocation (ie. "RT") first |
|
1110 |
TInt r = _SetB(aBuf, aSize, aProcess, aUser, NULL); |
|
1111 |
if (r != KErrOverflow) |
|
1112 |
return r; |
|
1113 |
||
1114 |
// Needs buffer reallocation |
|
1115 |
NKern::ThreadEnterCS(); |
|
1116 |
// Allocate a new buffer |
|
1117 |
nBuf = TBuf::New(aSize); |
|
1118 |
if (!nBuf) |
|
1119 |
{ |
|
1120 |
NKern::ThreadLeaveCS(); |
|
1121 |
return KErrNoMemory; |
|
1122 |
} |
|
1123 |
NKern::LockSystem(); |
|
1124 |
||
1125 |
r = _SetB(aBuf, aSize, aProcess, aUser, &nBuf); |
|
1126 |
// May be the old buffer (or NULL), may be the new one (if wasn't used) |
|
1127 |
delete nBuf; |
|
1128 |
NKern::ThreadLeaveCS(); |
|
1129 |
return r; |
|
1130 |
} |
|
1131 |
||
1132 |
NKern::ThreadEnterCS(); |
|
1133 |
||
1134 |
// Large property - need feature lock |
|
1135 |
FeatureLock->Wait(); |
|
1136 |
TInt r = _SetB(aBuf, aSize, aProcess, aUser, &nBuf); |
|
1137 |
if (r == KErrOverflow) |
|
1138 |
{ |
|
1139 |
// Allocate a new buffer |
|
1140 |
nBuf = TBuf::New(aSize); |
|
1141 |
if (!nBuf) |
|
1142 |
r = KErrNoMemory; |
|
1143 |
else |
|
1144 |
{ |
|
1145 |
NKern::LockSystem(); |
|
1146 |
r = _SetB(aBuf, aSize, aProcess, aUser, &nBuf); |
|
1147 |
} |
|
1148 |
} |
|
1149 |
Unlock(); |
|
1150 |
// May be the old buffer (or NULL), may be the new one (if wasn't used) |
|
1151 |
delete nBuf; |
|
1152 |
NKern::ThreadLeaveCS(); |
|
1153 |
return r; |
|
1154 |
} |
|
1155 |
||
1156 |
#ifdef __DEMAND_PAGING__ |
|
1157 |
||
1158 |
TInt TProperty::LockSourcePages(const TUint8* aBuf, TInt aSize) |
|
1159 |
{ |
|
1160 |
// When copying from user RAM we must lock the source data in case it is demand paged, otherwise |
|
1161 |
// we could get a mutex ordering voliation when waiting on the demand paging mutex |
|
1162 |
__ASSERT_CRITICAL; |
|
1163 |
Kern::MutexWait(*PagingLockMutex); |
|
1164 |
TInt r = PagingLock->Lock(TheCurrentThread, (TLinAddr)aBuf, aSize); |
|
1165 |
if(r>=0) |
|
1166 |
return KErrNone; |
|
1167 |
Kern::MutexSignal(*PagingLockMutex); |
|
1168 |
return r; |
|
1169 |
} |
|
1170 |
||
1171 |
void TProperty::UnlockSourcePages() |
|
1172 |
{ |
|
1173 |
__ASSERT_CRITICAL; |
|
1174 |
PagingLock->Unlock(); |
|
1175 |
Kern::MutexSignal(*PagingLockMutex); |
|
1176 |
} |
|
1177 |
||
1178 |
#else |
|
1179 |
||
1180 |
TInt TProperty::LockSourcePages(const TUint8*, TInt) |
|
1181 |
{ |
|
1182 |
return KErrNone; |
|
1183 |
} |
|
1184 |
||
1185 |
void TProperty::UnlockSourcePages() |
|
1186 |
{ |
|
1187 |
} |
|
1188 |
||
1189 |
#endif |
|
1190 |
||
1191 |
// |
|
1192 |
// User Interface |
|
1193 |
// |
|
1194 |
||
1195 |
class DPropertyRef : public DObject |
|
1196 |
{ |
|
1197 |
public: |
|
1198 |
||
1199 |
static TInt Define(TUint aCategory, TUint aKey, const TPropertyInfo*); |
|
1200 |
static TInt Delete(TUint aCategory, TUint aKey); |
|
1201 |
static TInt Attach(TUint aCategory, TUint aKey, TOwnerType aType); |
|
1202 |
||
1203 |
static TInt FindGetI(TUint aCategory, TUint aKey, TInt* aValue); |
|
1204 |
static TInt FindSetI(TUint aCategory, TUint aKey, TInt aValue); |
|
1205 |
||
1206 |
DPropertyRef(); |
|
1207 |
~DPropertyRef(); |
|
1208 |
||
1209 |
TInt Subscribe(TRequestStatus* aStatus); |
|
1210 |
inline void Cancel(); |
|
1211 |
||
1212 |
inline TInt GetI(TInt* aValue); |
|
1213 |
inline TInt GetB(TUint8* aBuf, TInt* aSize, TBool aUser); |
|
1214 |
inline TInt SetI(TInt aValue); |
|
1215 |
TInt SetB(const TUint8* aBuf, TInt aSize, TBool aUser); |
|
1216 |
||
1217 |
inline RProperty::TType Type() |
|
1218 |
{ return iProp->Type(); } |
|
1219 |
private: |
|
1220 |
||
1221 |
static void CompleteFn(TAny* aPtr, TInt aReason); |
|
1222 |
||
1223 |
TProperty* iProp; |
|
1224 |
TClientRequest* iRequest; |
|
1225 |
DThread* iClient; |
|
1226 |
TPropertySubsRequest iSubs; |
|
1227 |
}; |
|
1228 |
||
1229 |
DPropertyRef::DPropertyRef() : iSubs(CompleteFn, this) |
|
1230 |
{ |
|
1231 |
} |
|
1232 |
||
1233 |
// Called in CS |
|
1234 |
TInt DPropertyRef::Define(TUint aCategory, TUint aKey, const TPropertyInfo* aInfo) |
|
1235 |
{ // static |
|
1236 |
__ASSERT_CRITICAL; |
|
1237 |
TProperty* prop; |
|
1238 |
TInt r = TProperty::Attach(aCategory, aKey, &prop); |
|
1239 |
if (r != KErrNone) |
|
1240 |
{ |
|
1241 |
return r; |
|
1242 |
} |
|
1243 |
r = prop->Define(aInfo, CurProcess()); |
|
1244 |
prop->Close(); |
|
1245 |
return r; |
|
1246 |
} |
|
1247 |
||
1248 |
// Called in CS |
|
1249 |
TInt DPropertyRef::Delete(TUint aCategory, TUint aKey) |
|
1250 |
{ // static |
|
1251 |
__ASSERT_CRITICAL; |
|
1252 |
TProperty* prop; |
|
1253 |
TInt r = TProperty::Open(aCategory, aKey, &prop); |
|
1254 |
if (r != KErrNone) |
|
1255 |
{ |
|
1256 |
return r; |
|
1257 |
} |
|
1258 |
r = prop->Delete(CurProcess()); |
|
1259 |
prop->Close(); |
|
1260 |
return r; |
|
1261 |
} |
|
1262 |
||
1263 |
// Called in CS |
|
1264 |
TInt DPropertyRef::Attach(TUint aCategory, TUint aKey, TOwnerType aType) |
|
1265 |
{ // static |
|
1266 |
__ASSERT_CRITICAL; |
|
1267 |
DPropertyRef* ref = new DPropertyRef(); |
|
1268 |
if (ref == NULL) |
|
1269 |
{ |
|
1270 |
return KErrNoMemory; |
|
1271 |
} |
|
1272 |
TInt r = Kern::CreateClientRequest(ref->iRequest); |
|
1273 |
if (r != KErrNone) |
|
1274 |
{ |
|
1275 |
ref->Close(NULL); |
|
1276 |
return r; |
|
1277 |
} |
|
1278 |
r = TProperty::Attach(aCategory, aKey, &ref->iProp); |
|
1279 |
if (r != KErrNone) |
|
1280 |
{ |
|
1281 |
ref->Close(NULL); |
|
1282 |
return r; |
|
1283 |
} |
|
1284 |
r = K::AddObject(ref, EPropertyRef); |
|
1285 |
if (r != KErrNone) |
|
1286 |
{ |
|
1287 |
ref->Close(NULL); |
|
1288 |
return r; |
|
1289 |
} |
|
1290 |
r = K::MakeHandle(aType, ref); |
|
1291 |
if (r < 0) |
|
1292 |
{ // error |
|
1293 |
ref->Close(NULL); |
|
1294 |
} |
|
1295 |
return r; |
|
1296 |
} |
|
1297 |
||
1298 |
// Enter system locked. |
|
1299 |
// Return system unlocked. |
|
1300 |
TInt DPropertyRef::Subscribe(TRequestStatus* aStatus) |
|
1301 |
{ |
|
1302 |
__ASSERT_SYSTEM_LOCK; |
|
1303 |
if (iRequest->SetStatus(aStatus) != KErrNone) |
|
1304 |
{ // already pending - will Panic |
|
1305 |
NKern::UnlockSystem(); |
|
1306 |
return KErrInUse; |
|
1307 |
} |
|
1308 |
iClient = TheCurrentThread; |
|
1309 |
iClient->Open(); |
|
1310 |
return iProp->Subscribe(&iSubs, CurProcess()); |
|
1311 |
} |
|
1312 |
||
1313 |
// Called in CS or a DFC context |
|
1314 |
void DPropertyRef::CompleteFn(TAny* ptr, TInt aReason) |
|
1315 |
{ // static |
|
1316 |
__ASSERT_CRITICAL; |
|
1317 |
DPropertyRef* self = (DPropertyRef*) ptr; |
|
1318 |
// Local 'client' variable is necessary because after we call Kern::QueueRequestComplete the |
|
1319 |
// structure may be reused for another subscription |
|
1320 |
DThread* client = self->iClient; |
|
1321 |
__PS_ASSERT(client); |
|
1322 |
self->iClient = NULL; |
|
1323 |
Kern::QueueRequestComplete(client, self->iRequest, aReason); |
|
1324 |
client->Close(NULL); |
|
1325 |
} |
|
1326 |
||
1327 |
// Enter system locked. |
|
1328 |
// Return system unlocked. |
|
1329 |
inline void DPropertyRef::Cancel() |
|
1330 |
{ |
|
1331 |
__ASSERT_SYSTEM_LOCK; |
|
1332 |
iProp->Cancel(&iSubs); |
|
1333 |
} |
|
1334 |
||
1335 |
// Enter system locked. |
|
1336 |
// Return system unlocked. |
|
1337 |
inline TInt DPropertyRef::GetI(TInt* aValue) |
|
1338 |
{ |
|
1339 |
return iProp->GetI(aValue, CurProcess()); |
|
1340 |
} |
|
1341 |
||
1342 |
// Enter system locked. |
|
1343 |
// Return system unlocked. |
|
1344 |
inline TInt DPropertyRef::GetB(TUint8* aBuf, TInt* aSize, TBool aUser) |
|
1345 |
{ |
|
1346 |
return iProp->GetB(aBuf, aSize, CurProcess(), aUser); |
|
1347 |
} |
|
1348 |
||
1349 |
// Enter system locked. |
|
1350 |
// Return system unlocked. |
|
1351 |
inline TInt DPropertyRef::SetI(TInt aValue) |
|
1352 |
{ |
|
1353 |
return iProp->SetI(aValue, CurProcess()); |
|
1354 |
} |
|
1355 |
||
1356 |
// Called in CS |
|
1357 |
inline TInt DPropertyRef::FindGetI(TUint aCategory, TUint aKey, TInt* aValue) |
|
1358 |
{ |
|
1359 |
return TProperty::FindGetI(aCategory, aKey, aValue, CurProcess()); |
|
1360 |
} |
|
1361 |
||
1362 |
// Called in CS |
|
1363 |
inline TInt DPropertyRef::FindSetI(TUint aCategory, TUint aKey, TInt aValue) |
|
1364 |
{ |
|
1365 |
return TProperty::FindSetI(aCategory, aKey, aValue, CurProcess()); |
|
1366 |
} |
|
1367 |
||
1368 |
||
1369 |
// Enter system locked. |
|
1370 |
// Return system unlocked. |
|
1371 |
TInt DPropertyRef::SetB(const TUint8* aBuf, TInt aSize, TBool aUser) |
|
1372 |
{ |
|
1373 |
TBool open = |
|
1374 |
(iProp->Type() == RProperty::EByteArray) && (iProp->BufSize() < aSize); |
|
1375 |
if (open) |
|
1376 |
{ |
|
1377 |
// The buffer extension will release the system lock. |
|
1378 |
// We need to increment the DObject count to protect our-self against |
|
1379 |
// a concurrent DPropertyRef deletion by DObject::Close(). |
|
1380 |
if (Open() != KErrNone) |
|
1381 |
{ // Too late - destruction in progress .... |
|
1382 |
NKern::UnlockSystem(); |
|
1383 |
return KErrNotFound; |
|
1384 |
} |
|
1385 |
} |
|
1386 |
TInt r = iProp->SetB(aBuf, aSize, CurProcess(), aUser); |
|
1387 |
if (open) |
|
1388 |
{ |
|
1389 |
Close(NULL); |
|
1390 |
} |
|
1391 |
return r; |
|
1392 |
} |
|
1393 |
||
1394 |
// |
|
1395 |
// User interface entry points |
|
1396 |
// |
|
1397 |
||
1398 |
// Called in CS |
|
1399 |
DPropertyRef::~DPropertyRef() |
|
1400 |
{ |
|
1401 |
__ASSERT_CRITICAL; |
|
1402 |
if (iProp) |
|
1403 |
{ |
|
1404 |
NKern::LockSystem(); |
|
1405 |
Cancel(); |
|
1406 |
iProp->Close(); |
|
1407 |
iProp = NULL; |
|
1408 |
} |
|
1409 |
Kern::DestroyClientRequest(iRequest); |
|
1410 |
} |
|
1411 |
||
1412 |
TInt ExecHandler::PropertyDefine(TUint aCategory, TUint aKey, TPropertyInfo* aInfo) |
|
1413 |
{ |
|
1414 |
TPropertyInfo info; |
|
1415 |
kumemget(&info, aInfo, sizeof(info)); |
|
1416 |
if (aCategory == KMaxTUint) |
|
1417 |
aCategory = TUint(Kern::CurrentProcess().iS.iSecureId); |
|
1418 |
NKern::ThreadEnterCS(); |
|
1419 |
TInt r = DPropertyRef::Define(aCategory, aKey, &info); |
|
1420 |
NKern::ThreadLeaveCS(); |
|
1421 |
return r; |
|
1422 |
} |
|
1423 |
||
1424 |
TInt ExecHandler::PropertyDelete(TUint aCategory, TUint aKey) |
|
1425 |
{ |
|
1426 |
if (aCategory == KMaxTUint) |
|
1427 |
aCategory = TUint(Kern::CurrentProcess().iS.iSecureId); |
|
1428 |
NKern::ThreadEnterCS(); |
|
1429 |
TInt r = DPropertyRef::Delete(aCategory, aKey); |
|
1430 |
NKern::ThreadLeaveCS(); |
|
1431 |
return r; |
|
1432 |
} |
|
1433 |
||
1434 |
TInt ExecHandler::PropertyAttach(TUint aCategory, TUint aKey, TOwnerType aType) |
|
1435 |
{ |
|
1436 |
NKern::ThreadEnterCS(); |
|
1437 |
TInt r = DPropertyRef::Attach(aCategory, aKey, aType); |
|
1438 |
NKern::ThreadLeaveCS(); |
|
1439 |
return r; |
|
1440 |
} |
|
1441 |
||
1442 |
// Enter system locked. |
|
1443 |
// Return system unlocked. |
|
1444 |
void ExecHandler::PropertySubscribe(DPropertyRef* aRef, TRequestStatus* aStatus) |
|
1445 |
{ |
|
1446 |
TInt r = aRef->Subscribe(aStatus); |
|
1447 |
if (r != KErrNone) |
|
1448 |
{ |
|
1449 |
__PS_ASSERT(r == KErrInUse); |
|
1450 |
K::PanicKernExec(ERequestAlreadyPending); |
|
1451 |
} |
|
1452 |
} |
|
1453 |
||
1454 |
// Enter system locked. |
|
1455 |
// Return system unlocked. |
|
1456 |
void ExecHandler::PropertyCancel(DPropertyRef* aRef) |
|
1457 |
{ |
|
1458 |
aRef->Cancel(); |
|
1459 |
} |
|
1460 |
||
1461 |
// Enter system locked. |
|
1462 |
// Return system unlocked. |
|
1463 |
TInt ExecHandler::PropertyGetI(DPropertyRef* aRef, TInt* aValue) |
|
1464 |
{ |
|
1465 |
TInt value; |
|
1466 |
TInt r = aRef->GetI(&value); |
|
1467 |
if (r != KErrNone) |
|
1468 |
{ |
|
1469 |
return r; |
|
1470 |
} |
|
1471 |
kumemput32(aValue, &value, sizeof(value)); |
|
1472 |
return KErrNone; |
|
1473 |
} |
|
1474 |
||
1475 |
||
1476 |
// Enter system locked. |
|
1477 |
// Return system unlocked. |
|
1478 |
TInt ExecHandler::PropertyGetB(DPropertyRef* aRef, TUint8* aBuf, TInt aSize) |
|
1479 |
{ |
|
1480 |
TInt r; |
|
1481 |
||
1482 |
if(aRef->Type()!=RProperty::ELargeByteArray) |
|
1483 |
{ |
|
1484 |
// Use intermediate kernel buffer for small properties |
|
1485 |
TUint8 sbuf[RProperty::KMaxPropertySize]; |
|
1486 |
if(aSize > (TInt)sizeof(sbuf)) |
|
1487 |
aSize = sizeof(sbuf); |
|
1488 |
r = aRef->GetB(sbuf, &aSize, EFalse); |
|
1489 |
if(r==KErrNone || r==KErrOverflow) |
|
1490 |
kumemput(aBuf,sbuf,aSize); |
|
1491 |
} |
|
1492 |
else |
|
1493 |
{ |
|
1494 |
// For large properties we must pin user memory to prevent demand paging. |
|
1495 |
aRef->CheckedOpen(); |
|
1496 |
NKern::ThreadEnterCS(); |
|
1497 |
NKern::UnlockSystem(); |
|
1498 |
||
1499 |
if(aSize>RProperty::KMaxLargePropertySize) |
|
1500 |
aSize = RProperty::KMaxLargePropertySize; |
|
1501 |
r = TProperty::LockSourcePages(aBuf, aSize); |
|
1502 |
if(r>=0) |
|
1503 |
{ |
|
1504 |
NKern::LockSystem(); |
|
1505 |
r = aRef->GetB(aBuf, &aSize, ETrue); |
|
1506 |
TProperty::UnlockSourcePages(); |
|
1507 |
} |
|
1508 |
||
1509 |
aRef->Close(0); |
|
1510 |
NKern::ThreadLeaveCS(); |
|
1511 |
} |
|
1512 |
||
1513 |
if (r == KErrBadDescriptor) |
|
1514 |
{ |
|
1515 |
K::PanicKernExec(ECausedException); |
|
1516 |
} |
|
1517 |
else if (r != KErrNone) |
|
1518 |
{ |
|
1519 |
return r; |
|
1520 |
} |
|
1521 |
return aSize; |
|
1522 |
} |
|
1523 |
||
1524 |
// Enter system locked. |
|
1525 |
// Return system unlocked. |
|
1526 |
TInt ExecHandler::PropertySetI(DPropertyRef* aRef, TInt aValue) |
|
1527 |
{ |
|
1528 |
return aRef->SetI(aValue); |
|
1529 |
} |
|
1530 |
||
1531 |
// Enter and return system unlocked. |
|
1532 |
TInt ExecHandler::PropertySetB(TInt aPropertyRefHandle, const TUint8* aBuf, TInt aSize) |
|
1533 |
{ |
|
1534 |
// If property small enough then copy it to local buffer |
|
1535 |
TBool user = ETrue; |
|
1536 |
TUint8 sbuf[RProperty::KMaxPropertySize]; |
|
1537 |
if(aSize<=RProperty::KMaxPropertySize) |
|
1538 |
{ |
|
1539 |
kumemget(sbuf,aBuf,aSize); |
|
1540 |
aBuf = sbuf; |
|
1541 |
user = EFalse; |
|
1542 |
} |
|
1543 |
||
1544 |
NKern::ThreadEnterCS(); |
|
1545 |
||
1546 |
TInt r = KErrNone; |
|
1547 |
if (user) |
|
1548 |
r = TProperty::LockSourcePages(aBuf, aSize); |
|
1549 |
||
1550 |
// Set the property |
|
1551 |
if(r>=0) |
|
1552 |
{ |
|
1553 |
NKern::LockSystem(); |
|
1554 |
DPropertyRef* propertyRef = (DPropertyRef*)TheCurrentThread->ObjectFromHandle(aPropertyRefHandle,EPropertyRef); |
|
1555 |
if (propertyRef) |
|
1556 |
{ |
|
1557 |
r = propertyRef->SetB(aBuf, aSize, user); |
|
1558 |
// unlocks system lock |
|
1559 |
} |
|
1560 |
else |
|
1561 |
{ |
|
1562 |
r = KErrBadHandle; |
|
1563 |
NKern::UnlockSystem(); |
|
1564 |
} |
|
1565 |
||
1566 |
if (user) |
|
1567 |
TProperty::UnlockSourcePages(); |
|
1568 |
} |
|
1569 |
||
1570 |
NKern::ThreadLeaveCS(); |
|
1571 |
||
1572 |
if (r == KErrBadDescriptor) |
|
1573 |
K::PanicKernExec(ECausedException); |
|
1574 |
if (r == KErrBadHandle) |
|
1575 |
K::PanicKernExec(EBadHandle); |
|
1576 |
return r; |
|
1577 |
} |
|
1578 |
||
1579 |
TInt ExecHandler::PropertyFindGetI(TUint aCategory, TUint aKey, TInt* aValue) |
|
1580 |
{ |
|
1581 |
TInt value; |
|
1582 |
NKern::ThreadEnterCS(); |
|
1583 |
TInt r = DPropertyRef::FindGetI(aCategory, aKey, &value); |
|
1584 |
NKern::ThreadLeaveCS(); |
|
1585 |
if (r != KErrNone) |
|
1586 |
{ |
|
1587 |
return r; |
|
1588 |
} |
|
1589 |
kumemput32(aValue, &value, sizeof(value)); |
|
1590 |
return KErrNone; |
|
1591 |
} |
|
1592 |
||
1593 |
TInt ExecHandler::PropertyFindGetB(TUint aCategory, TUint aKey, TUint8* aBuf, |
|
1594 |
TInt aSize) |
|
1595 |
{ |
|
1596 |
NKern::ThreadEnterCS(); |
|
1597 |
||
1598 |
TProperty* prop; |
|
1599 |
TInt r = TProperty::Open(aCategory, aKey, &prop); |
|
1600 |
if (r == KErrNone) |
|
1601 |
{ |
|
1602 |
if(prop->Type()!=RProperty::ELargeByteArray) |
|
1603 |
{ |
|
1604 |
// Use intermediate kernel buffer for small properties |
|
1605 |
TUint8 sbuf[RProperty::KMaxPropertySize]; |
|
1606 |
if(aSize > (TInt)sizeof(sbuf)) |
|
1607 |
aSize = sizeof(sbuf); |
|
1608 |
NKern::LockSystem(); |
|
1609 |
r = prop->GetB(sbuf, &aSize, CurProcess(), EFalse); |
|
1610 |
if(r==KErrNone || r==KErrOverflow) |
|
1611 |
kumemput(aBuf,sbuf,aSize); |
|
1612 |
} |
|
1613 |
else |
|
1614 |
{ |
|
1615 |
// For large properties we must pin the use memory to prevent demand paging. |
|
1616 |
if(aSize>RProperty::KMaxLargePropertySize) |
|
1617 |
aSize = RProperty::KMaxLargePropertySize; |
|
1618 |
r = TProperty::LockSourcePages(aBuf, aSize); |
|
1619 |
if(r>=0) |
|
1620 |
{ |
|
1621 |
NKern::LockSystem(); |
|
1622 |
r = prop->GetB(aBuf, &aSize, CurProcess(), ETrue); |
|
1623 |
TProperty::UnlockSourcePages(); |
|
1624 |
} |
|
1625 |
} |
|
1626 |
prop->Close(); |
|
1627 |
} |
|
1628 |
||
1629 |
NKern::ThreadLeaveCS(); |
|
1630 |
||
1631 |
if (r == KErrBadDescriptor) |
|
1632 |
{ |
|
1633 |
K::PanicKernExec(ECausedException); |
|
1634 |
} |
|
1635 |
else if (r != KErrNone) |
|
1636 |
{ |
|
1637 |
return r; |
|
1638 |
} |
|
1639 |
return aSize; |
|
1640 |
} |
|
1641 |
||
1642 |
TInt ExecHandler::PropertyFindSetI(TUint aCategory, TUint aKey, TInt aValue) |
|
1643 |
{ |
|
1644 |
NKern::ThreadEnterCS(); |
|
1645 |
TInt r = DPropertyRef::FindSetI(aCategory, aKey, aValue); |
|
1646 |
NKern::ThreadLeaveCS(); |
|
1647 |
return r; |
|
1648 |
} |
|
1649 |
||
1650 |
TInt ExecHandler::PropertyFindSetB(TUint aCategory, TUint aKey, TUint8* aBuf, |
|
1651 |
TInt aSize) |
|
1652 |
{ |
|
1653 |
// If property small enough then copy it to local buffer |
|
1654 |
TBool user = ETrue; |
|
1655 |
TUint8 sbuf[RProperty::KMaxPropertySize]; |
|
1656 |
if(aSize<=RProperty::KMaxPropertySize) |
|
1657 |
{ |
|
1658 |
kumemget(sbuf,aBuf,aSize); |
|
1659 |
aBuf = sbuf; |
|
1660 |
user = EFalse; |
|
1661 |
} |
|
1662 |
||
1663 |
NKern::ThreadEnterCS(); |
|
1664 |
||
1665 |
TInt r = KErrNone; |
|
1666 |
if (user) |
|
1667 |
r = TProperty::LockSourcePages(aBuf, aSize); |
|
1668 |
||
1669 |
// Find and open property |
|
1670 |
if(r>=0) |
|
1671 |
{ |
|
1672 |
TProperty* prop; |
|
1673 |
r = TProperty::Open(aCategory, aKey, &prop); |
|
1674 |
if (r == KErrNone) |
|
1675 |
{ |
|
1676 |
// Set the property |
|
1677 |
NKern::LockSystem(); |
|
1678 |
r = prop->SetB(aBuf, aSize, CurProcess(), user); |
|
1679 |
prop->Close(); |
|
1680 |
} |
|
1681 |
||
1682 |
if (user) |
|
1683 |
TProperty::UnlockSourcePages(); |
|
1684 |
} |
|
1685 |
||
1686 |
NKern::ThreadLeaveCS(); |
|
1687 |
if (r == KErrBadDescriptor) |
|
1688 |
K::PanicKernExec(ECausedException); |
|
1689 |
return r; |
|
1690 |
} |
|
1691 |
||
1692 |
/** Attaches to a property. |
|
1693 |
||
1694 |
This performs the same action as RPropertyRef::Open(). However, if the property does |
|
1695 |
not exist then it is created first. |
|
1696 |
||
1697 |
@param aCategory The property category. |
|
1698 |
@param aKey The property sub-key. |
|
1699 |
||
1700 |
@return KErrNone, if successful; |
|
1701 |
KErrNoMemory, if insufficient memory. |
|
1702 |
||
1703 |
@pre Calling thread must be in a critical section. |
|
1704 |
@pre Property has not been opened. |
|
1705 |
@pre Call in a thread context. |
|
1706 |
@pre Kernel must be unlocked. |
|
1707 |
@pre interrupts enabled |
|
1708 |
@pre No fast mutex can be held |
|
1709 |
||
1710 |
@post Calling thread is in a critical section. |
|
1711 |
||
1712 |
@see RPropertyRef::Open() |
|
1713 |
*/ |
|
1714 |
EXPORT_C TInt RPropertyRef::Attach(TUid aCategory, TInt aKey) |
|
1715 |
{ |
|
1716 |
CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"RPropertyRef::Attach"); |
|
1717 |
__PS_ASSERT(iProp == NULL); |
|
1718 |
return TProperty::Attach(TUint(aCategory.iUid), aKey, &iProp); |
|
1719 |
} |
|
1720 |
||
1721 |
/** Opens a property. |
|
1722 |
||
1723 |
Once opened: |
|
1724 |
- the property can be defined, deleted, and subscribed to |
|
1725 |
- the property value can be retrieved (read) and published (written) |
|
1726 |
using the appropriate member-functions in the appropriate order. |
|
1727 |
||
1728 |
Note that the property must already exist. If it does not exist, |
|
1729 |
the function will not create it - it will return an error. |
|
1730 |
Use RPropertyRef::Attach() if you need to create the property. |
|
1731 |
||
1732 |
@param aCategory The property category. |
|
1733 |
@param aKey The property sub-key. |
|
1734 |
||
1735 |
@return KErrNotFound, if the property does not exist; |
|
1736 |
KErrNone, if successful; |
|
1737 |
Otherwise, one of the other system-wide error codes. |
|
1738 |
||
1739 |
@pre Calling thread must be in a critical section. |
|
1740 |
@pre Property has not been opened. |
|
1741 |
@pre Call in a thread context. |
|
1742 |
@pre Kernel must be unlocked. |
|
1743 |
@pre interrupts enabled |
|
1744 |
@pre No fast mutex can be held |
|
1745 |
||
1746 |
@post Calling thread is in a critical section. |
|
1747 |
*/ |
|
1748 |
EXPORT_C TInt RPropertyRef::Open(TUid aCategory, TInt aKey) |
|
1749 |
{ |
|
1750 |
CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"RPropertyRef::Open"); |
|
1751 |
__PS_ASSERT(iProp == NULL); |
|
1752 |
return TProperty::Open(TUint(aCategory.iUid), aKey, &iProp); |
|
1753 |
} |
|
1754 |
||
1755 |
/** Releases the property. |
|
1756 |
||
1757 |
@pre Calling thread must be in a critical section. |
|
1758 |
@pre Call in a thread context. |
|
1759 |
@pre Kernel must be unlocked. |
|
1760 |
@pre interrupts enabled |
|
1761 |
@pre No fast mutex can be held |
|
1762 |
||
1763 |
@post Calling thread is in a critical section. |
|
1764 |
*/ |
|
1765 |
EXPORT_C void RPropertyRef::Close() |
|
1766 |
{ |
|
1767 |
CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"RPropertyRef::Close"); |
|
1768 |
if (iProp) |
|
1769 |
{ |
|
1770 |
iProp->Close(); |
|
1771 |
iProp = NULL; |
|
1772 |
} |
|
1773 |
} |
|
1774 |
||
1775 |
/** Defines the attributes and access control for a property. |
|
1776 |
||
1777 |
This can only be done once for each property. |
|
1778 |
||
1779 |
Following defintion, the property has a default value: |
|
1780 |
- 0 for integer properties |
|
1781 |
- zero-length data for byte-array and text properties. |
|
1782 |
||
1783 |
Pending subscriptions for this property will not be completed |
|
1784 |
until a new value is published. |
|
1785 |
||
1786 |
@param aAttr Bits 0-7 define the property type. |
|
1787 |
Upper bits contain additional property attributes. |
|
1788 |
@param aReadPolicy Read policy. Defines the set capabilities that a process |
|
1789 |
will require before being allowed to retrieve (read) the |
|
1790 |
property value. |
|
1791 |
@param aWritePolicy Write policy. Defines the set capabilities that a process |
|
1792 |
will require before being allowed to publish (write) the |
|
1793 |
property value. |
|
1794 |
@param aPreallocate Pre-allocated buffer size for EByteArray or ELargeByteArray |
|
1795 |
property types. |
|
1796 |
@param aProcess If defining a property within the 'system services' category, |
|
1797 |
as defined by the KUidSystemCategoryValue UId, then this |
|
1798 |
is the process whose security attributes will be checked |
|
1799 |
to see whether it has sufficient authority to perform |
|
1800 |
this define operation. |
|
1801 |
If NULL, these security checks will NOT be performed. |
|
1802 |
||
1803 |
@return KErrPermissionDenied, if aProcess doesn't have rights to define this property; |
|
1804 |
KErrArgument, if aPreallocate is negative, |
|
1805 |
OR the property type passed to the aAttr argument |
|
1806 |
is greater than or equal to RProperty::ETypeLimit, |
|
1807 |
OR aPreallocate has a non-zero value when the property |
|
1808 |
type is an integer; |
|
1809 |
KErrTooBig, if aPreallocate is greater than RProperty::KMaxPropertySize |
|
1810 |
when the property type is RProperty::EByteArray, |
|
1811 |
OR if aPreallocate is greater than RProperty::KMaxLargePropertySize |
|
1812 |
when the property type is RProperty::ELargeByteArray; |
|
1813 |
KErrAlreadyExists, if the property has already been defined. |
|
1814 |
||
1815 |
@pre Calling thread must be in a critical section. |
|
1816 |
@pre Property has been opened. |
|
1817 |
@pre Call in a thread context. |
|
1818 |
@pre Kernel must be unlocked. |
|
1819 |
@pre interrupts enabled |
|
1820 |
@pre No fast mutex can be held |
|
1821 |
||
1822 |
@post Calling thread is in a critical section. |
|
1823 |
||
1824 |
@see RProperty::TType |
|
1825 |
*/ |
|
1826 |
EXPORT_C TInt RPropertyRef::Define(TInt aAttr, const TSecurityPolicy& aReadPolicy, const TSecurityPolicy& aWritePolicy, TInt aPreallocate, DProcess* aProcess) |
|
1827 |
{ |
|
1828 |
CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"RPropertyRef::Define"); |
|
1829 |
__PS_ASSERT(iProp); |
|
1830 |
||
1831 |
if(aPreallocate < 0) |
|
1832 |
return KErrArgument; |
|
1833 |
if(aPreallocate > RProperty::KMaxLargePropertySize) |
|
1834 |
return KErrTooBig; |
|
1835 |
||
1836 |
TPropertyInfo info; |
|
1837 |
info.iType = (RProperty::TType)(aAttr & RProperty::ETypeMask); |
|
1838 |
info.iAttr = (aAttr & ~RProperty::ETypeMask); |
|
1839 |
info.iSize = (TUint16) aPreallocate; |
|
1840 |
info.iReadPolicy = aReadPolicy; |
|
1841 |
info.iWritePolicy = aWritePolicy; |
|
1842 |
return iProp->Define(&info, aProcess); |
|
1843 |
} |
|
1844 |
||
1845 |
/** Deletes the property. |
|
1846 |
||
1847 |
Any pending subscriptions for this property will be completed with KErrNotFound. |
|
1848 |
Any new request will not complete until the property is defined and published again. |
|
1849 |
||
1850 |
@param aProcess The process whoes security attributes will be used for security checks. |
|
1851 |
If NULL the security checks will not be performed. |
|
1852 |
||
1853 |
@return KErrNone, if the delete succeeds; |
|
1854 |
KErrNotFound, if the property has not been defined; |
|
1855 |
KErrPermissionDenied, if aProcess is specified and is not the owner |
|
1856 |
of the process. |
|
1857 |
||
1858 |
@pre Calling thread must be in a critical section. |
|
1859 |
@pre Property has been opened. |
|
1860 |
@pre Call in a thread context. |
|
1861 |
@pre Kernel must be unlocked. |
|
1862 |
@pre interrupts enabled |
|
1863 |
@pre No fast mutex can be held |
|
1864 |
||
1865 |
@post Calling thread is in a critical section. |
|
1866 |
*/ |
|
1867 |
||
1868 |
EXPORT_C TInt RPropertyRef::Delete(DProcess* aProcess) |
|
1869 |
{ |
|
1870 |
CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"RPropertyRef::Delete"); |
|
1871 |
__PS_ASSERT(iProp); |
|
1872 |
return iProp->Delete(aProcess); |
|
1873 |
} |
|
1874 |
||
1875 |
/** Requests notification when the property is changed. |
|
1876 |
||
1877 |
If the property has not been defined, the request will not complete until the property |
|
1878 |
is defined and published. |
|
1879 |
||
1880 |
Only one subscription per TPropertySubsRequest object is allowed. |
|
1881 |
||
1882 |
@param aReq Specifies this request. |
|
1883 |
@param aProcess The process whoes security attributes will be used for security checks. |
|
1884 |
If NULL the security checks will not be performed. |
|
1885 |
||
1886 |
@return KErrNone, if the subcribe action succeeds. |
|
1887 |
||
1888 |
@pre Property has been opened. |
|
1889 |
*/ |
|
1890 |
EXPORT_C TInt RPropertyRef::Subscribe(TPropertySubsRequest& aReq, DProcess* aProcess) |
|
1891 |
{ |
|
1892 |
__PS_ASSERT(iProp); |
|
1893 |
NKern::LockSystem(); |
|
1894 |
TInt r = iProp->Subscribe(&aReq, aProcess); |
|
1895 |
__PS_ASSERT(r != KErrInUse); |
|
1896 |
return r; |
|
1897 |
} |
|
1898 |
||
1899 |
/** Cancels a subscription request originally made with RPropertyRef::Subscribe(). |
|
1900 |
||
1901 |
@param aReq The TPropertySubsRequest object used in the original subscribe request. |
|
1902 |
||
1903 |
@pre Property has been opened. |
|
1904 |
||
1905 |
@see RPropertyRef::Subscribe() |
|
1906 |
*/ |
|
1907 |
EXPORT_C void RPropertyRef::Cancel(TPropertySubsRequest& aReq) |
|
1908 |
{ |
|
1909 |
__PS_ASSERT(iProp); |
|
1910 |
NKern::LockSystem(); |
|
1911 |
iProp->Cancel(&aReq); |
|
1912 |
} |
|
1913 |
||
1914 |
/** Retrieves (reads) the value of an integer property. |
|
1915 |
||
1916 |
@param aValue An integer to hold the returned property value |
|
1917 |
@param aProcess The process whose security attributes will be used for security checks. |
|
1918 |
If NULL the security checks will not be performed. |
|
1919 |
||
1920 |
@return KErrNotFound, if the property has not been defined; |
|
1921 |
KErrPermissionDenied, if aProcess does not have the read capabilities; |
|
1922 |
KErrArgument, if the property is not of type EInt; |
|
1923 |
KErrNone, if the property was read succesfully. |
|
1924 |
||
1925 |
@pre Property has been opened. |
|
1926 |
||
1927 |
@realtime |
|
1928 |
*/ |
|
1929 |
EXPORT_C TInt RPropertyRef::Get(TInt& aValue, DProcess* aProcess) |
|
1930 |
{ |
|
1931 |
__PS_ASSERT(iProp); |
|
1932 |
NKern::LockSystem(); |
|
1933 |
return iProp->GetI(&aValue, aProcess); |
|
1934 |
} |
|
1935 |
||
1936 |
/** Publishes (writes) the value of an integer property. |
|
1937 |
||
1938 |
@param aValue The new value for the property. |
|
1939 |
@param aProcess The process whose security attributes will be used for security checks. |
|
1940 |
If NULL the security checks will not be performed. |
|
1941 |
||
1942 |
@return KErrNotFound, if the property has not been defined; |
|
1943 |
KErrPermissionDenied, if aProcess does not have the write capabilities; |
|
1944 |
KErrArgument, if the property is not of type EInt; |
|
1945 |
KErrNone, if the property was set succesfully. |
|
1946 |
||
1947 |
@pre Property has been opened. |
|
1948 |
||
1949 |
@realtime |
|
1950 |
*/ |
|
1951 |
EXPORT_C TInt RPropertyRef::Set(TInt aValue, DProcess* aProcess) |
|
1952 |
{ |
|
1953 |
__PS_ASSERT(iProp); |
|
1954 |
NKern::LockSystem(); |
|
1955 |
return iProp->SetI(aValue, aProcess); |
|
1956 |
} |
|
1957 |
||
1958 |
/** Retrieves (reads) the value of a binary property. |
|
1959 |
||
1960 |
@param aDes A descriptor to hold the returned property value. |
|
1961 |
@param aProcess The process whose security attributes will be used for security checks. |
|
1962 |
If NULL the security checks will not be performed. |
|
1963 |
||
1964 |
@return KErrNotFound, if the property has not been defined; |
|
1965 |
KErrPermissionDenied, if aProcess does not have the read capabilities; |
|
1966 |
KErrArgument, if the property is not of type EByteArray; |
|
1967 |
KErrOverflow, if the property is larger than the maximum size of aDes, |
|
1968 |
in which case aDes is filled with as much of the property value that will fit; |
|
1969 |
KErrNone, if the property was read succesfully. |
|
1970 |
||
1971 |
@pre Property has been opened. |
|
1972 |
||
1973 |
@realtime There are real time guarantees if the property is not large. |
|
1974 |
*/ |
|
1975 |
EXPORT_C TInt RPropertyRef::Get(TDes8& aDes, DProcess* aProcess) |
|
1976 |
{ |
|
1977 |
__PS_ASSERT(iProp); |
|
1978 |
TInt size = aDes.MaxSize(); |
|
1979 |
NKern::LockSystem(); |
|
1980 |
TInt r = iProp->GetB((TUint8*) aDes.Ptr(), &size, aProcess, EFalse); |
|
1981 |
if ((r == KErrNone) || (r == KErrOverflow)) |
|
1982 |
{ |
|
1983 |
aDes.SetLength(size); |
|
1984 |
} |
|
1985 |
return r; |
|
1986 |
} |
|
1987 |
||
1988 |
/** Publishes (writes) the value of a binary property. |
|
1989 |
||
1990 |
@param aDes The new value for the property. |
|
1991 |
@param aProcess The process whoes security attributes will be used for security checks. |
|
1992 |
If NULL the security checks will not be performed. |
|
1993 |
||
1994 |
@return KErrNotFound, if the property has not been defined; |
|
1995 |
KErrPermissionDenied, if aProcess does not have the write capabilities; |
|
1996 |
KErrArgument, if the property is not of type EByteArray; |
|
1997 |
KErrTooBig, if the property is larger than KMaxPropertySize; |
|
1998 |
KErrNone, if the property was set succesfully. |
|
1999 |
||
2000 |
@pre Property has been opened. |
|
2001 |
||
2002 |
@realtime There are realtime guarantees if the property is not large |
|
2003 |
and the size is not greater than the previously published value. |
|
2004 |
*/ |
|
2005 |
EXPORT_C TInt RPropertyRef::Set(const TDesC8& aDes, DProcess* aProcess) |
|
2006 |
{ |
|
2007 |
__PS_ASSERT(iProp); |
|
2008 |
NKern::LockSystem(); |
|
2009 |
return iProp->SetB((TUint8*) aDes.Ptr(), aDes.Size(), aProcess, EFalse); |
|
2010 |
} |
|
2011 |
||
2012 |
/** Gets property status information. |
|
2013 |
||
2014 |
@param aStatus property status output. |
|
2015 |
||
2016 |
@return ETrue if the property is defined; otherwise, EFalse. |
|
2017 |
||
2018 |
@pre System must be locked. |
|
2019 |
@pre Property has been opened. |
|
2020 |
||
2021 |
@post System is locked. |
|
2022 |
*/ |
|
2023 |
EXPORT_C TBool RPropertyRef::GetStatus(TPropertyStatus& aStatus) |
|
2024 |
{ |
|
2025 |
CHECK_PRECONDITIONS(MASK_SYSTEM_LOCKED,"RPropertyRef::GetStatus"); |
|
2026 |
__PS_ASSERT(iProp); |
|
2027 |
aStatus.iType = iProp->Type(); |
|
2028 |
aStatus.iAttr = 0; |
|
2029 |
aStatus.iOwner = iProp->Owner(); |
|
2030 |
return iProp->IsDefined(); |
|
2031 |
} |