|
1 // Copyright (c) 1998-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 "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 inline TInt DbsMessage(TInt aFunction,TInt aHandle) |
|
18 { |
|
19 return (aFunction<<KDbsHandleBits)|aHandle; |
|
20 } |
|
21 |
|
22 inline TDbsFunction DbsFunction(TInt aMessage) |
|
23 { |
|
24 return TDbsFunction(aMessage>>KDbsHandleBits); |
|
25 } |
|
26 |
|
27 inline TInt DbsHandle(TInt aMessage) |
|
28 { |
|
29 return aMessage&KDbsHandleMask; |
|
30 } |
|
31 |
|
32 inline TDbsType DbsType(TInt aHandle) |
|
33 { |
|
34 return TDbsType(aHandle&KDbsTypeMask); |
|
35 } |
|
36 |
|
37 inline TInt DbsMagic(TInt aHandle) |
|
38 { |
|
39 return (aHandle>>KDbsTypeBits)&KDbsMagicMask; |
|
40 } |
|
41 |
|
42 inline TInt DbsObjectIndex(TInt aHandle) |
|
43 { |
|
44 return aHandle>>(KDbsTypeBits+KDbsMagicBits); |
|
45 } |
|
46 |
|
47 inline TInt DbsMakeHandle(TInt aIndex,TInt aMagic,TDbsType aType) |
|
48 { |
|
49 return (((aIndex<<KDbsMagicBits)|aMagic)<<KDbsTypeBits)|aType; |
|
50 } |
|
51 |
|
52 inline TInt DbsSessionHandle() |
|
53 { |
|
54 return DbsMakeHandle(1<<(KDbsIndexBits-1),0,EDbsSession); |
|
55 } |
|
56 |
|
57 // streaming functions |
|
58 inline RWriteStream& operator<<(RWriteStream& aStream,const TDbCol& aCol) |
|
59 { |
|
60 ExternalizeL(aCol,aStream); |
|
61 return aStream; |
|
62 } |
|
63 |
|
64 inline RWriteStream& operator<<(RWriteStream& aStream,const CDbColSet& aColSet) |
|
65 { |
|
66 ExternalizeL(aColSet,aStream); |
|
67 return aStream; |
|
68 } |
|
69 |
|
70 inline RReadStream& operator>>(RReadStream& aStream,CDbColSet& aColSet) |
|
71 { |
|
72 InternalizeL(aColSet,aStream); |
|
73 return aStream; |
|
74 } |
|
75 |
|
76 inline RWriteStream& operator<<(RWriteStream& aStream,const CDbKey& aKey) |
|
77 { |
|
78 ExternalizeL(aKey,aStream); |
|
79 return aStream; |
|
80 } |
|
81 |
|
82 inline RReadStream& operator>>(RReadStream& aStream,CDbKey& aKey) |
|
83 { |
|
84 InternalizeL(aKey,aStream); |
|
85 return aStream; |
|
86 } |
|
87 |
|
88 inline RWriteStream& operator<<(RWriteStream& aStream,const CDbNames& aNames) |
|
89 { |
|
90 ExternalizeL(aNames,aStream); |
|
91 return aStream; |
|
92 } |
|
93 |
|
94 inline RReadStream& operator>>(RReadStream& aStream,CDbNames& aNames) |
|
95 { |
|
96 InternalizeL(aNames,aStream); |
|
97 return aStream; |
|
98 } |
|
99 |
|
100 /** |
|
101 This operator is used for externalizing CDbStrings array to a stream. |
|
102 @internalComponent |
|
103 */ |
|
104 inline RWriteStream& operator<<(RWriteStream& aStream,const CDbStrings& aStrings) |
|
105 { |
|
106 ExternalizeL(aStrings,aStream); |
|
107 return aStream; |
|
108 } |
|
109 |
|
110 /** |
|
111 This operator is used for internalizing CDbStrings array from a stream. |
|
112 @internalComponent |
|
113 */ |
|
114 inline RReadStream& operator>>(RReadStream& aStream,CDbStrings& aStrings) |
|
115 { |
|
116 InternalizeL(aStrings,aStream); |
|
117 return aStream; |
|
118 } |
|
119 |
|
120 template <class T> |
|
121 inline TExternalizeFunction Externalizer(const T*) |
|
122 { |
|
123 return TExternalizer<T>::Function(); |
|
124 } |
|
125 |
|
126 // Class TDbsParam |
|
127 inline void TDbsParam::operator=(const TDesC8& aDes) |
|
128 { |
|
129 iPtr=&aDes; |
|
130 } |
|
131 |
|
132 inline void TDbsParam::operator=(const TDesC16& aDes) |
|
133 { |
|
134 iPtr=&aDes; |
|
135 } |
|
136 |
|
137 inline void TDbsParam::operator=(TInt aVal) |
|
138 { |
|
139 iInt=aVal; |
|
140 } |
|
141 |
|
142 // Class RDbsObject |
|
143 inline RDbsObject::RDbsObject(): |
|
144 iHandle(0) |
|
145 { |
|
146 } |
|
147 |
|
148 inline RDbsObject::RDbsObject(const RDbs& aDbs): |
|
149 RDbs(aDbs), |
|
150 iHandle(KDbsSessionHandle) |
|
151 { |
|
152 } |
|
153 |
|
154 inline TInt RDbsObject::Handle() const |
|
155 { |
|
156 return iHandle; |
|
157 } |
|
158 |
|
159 inline void RDbsObject::OpenL(const RDbsObject& aDbs,TDbsFunction aFunction) |
|
160 { |
|
161 OpenL(aDbs,aFunction,0); |
|
162 } |
|
163 |
|
164 inline void RDbsObject::OpenL(const RDbsObject& aDbs,TDbsFunction aFunction,const TIpcArgs& aArgs) |
|
165 { |
|
166 OpenL(aDbs,aFunction,&aArgs); |
|
167 } |
|
168 |
|
169 inline void RDbsObject::OpenL(const RDbs& aDbs,TDbsFunction aFunction,const TIpcArgs& aArgs) |
|
170 { |
|
171 OpenL(RDbsObject(aDbs),aFunction,&aArgs); |
|
172 } |
|
173 |
|
174 inline void RDbsObject::SendReceive(TDbsFunction aFunction,TRequestStatus& aStatus) const |
|
175 { |
|
176 SendReceive(aFunction,0,aStatus); |
|
177 } |
|
178 |
|
179 inline TInt RDbsObject::SendReceive(TDbsFunction aFunction,const TIpcArgs& aArgs) const |
|
180 { |
|
181 return SendReceive(aFunction,&aArgs); |
|
182 } |
|
183 |
|
184 inline TInt RDbsObject::SendReceiveL(TDbsFunction aFunction,const TIpcArgs& aArgs) const |
|
185 { |
|
186 return SendReceiveL(aFunction,&aArgs); |
|
187 } |
|
188 |
|
189 inline void RDbsObject::SendReceive(TDbsFunction aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const |
|
190 { |
|
191 SendReceive(aFunction,&aArgs,aStatus); |
|
192 } |
|
193 |
|
194 // Class CDbsDatabase |
|
195 inline CDbsDatabase::CDbsDatabase() |
|
196 { |
|
197 } |
|
198 |
|
199 // Class CDbsNotifier |
|
200 inline CDbsNotifier::CDbsNotifier() |
|
201 { |
|
202 } |
|
203 |
|
204 // Class CDbsIncrmental |
|
205 inline CDbsIncremental::CDbsIncremental() |
|
206 { |
|
207 } |
|
208 |
|
209 // Class CDbsConstraint |
|
210 inline CDbsConstraint::CDbsConstraint() |
|
211 { |
|
212 } |
|
213 |
|
214 // Class HDbsBuf |
|
215 inline HDbsBuf::HDbsBuf() |
|
216 { |
|
217 iBuf.iExt=-1; |
|
218 } |
|
219 |
|
220 inline HDbsBuf::~HDbsBuf() |
|
221 { |
|
222 iIpc.Close(); |
|
223 } |
|
224 |
|
225 inline void HDbsBuf::SetPos(TRead,TInt aPos) |
|
226 { |
|
227 iRPos=aPos; |
|
228 } |
|
229 |
|
230 inline void HDbsBuf::SetPos(TWrite,TInt aPos) |
|
231 { |
|
232 iWPos=aPos; |
|
233 } |
|
234 |
|
235 inline TInt HDbsBuf::Pos(TRead) const |
|
236 { |
|
237 return iRPos; |
|
238 } |
|
239 |
|
240 inline TInt HDbsBuf::Pos(TWrite) const |
|
241 { |
|
242 return iWPos; |
|
243 } |
|
244 |
|
245 inline TInt HDbsBuf::MovePos(TRead,TInt anOffset) |
|
246 { |
|
247 return iRPos+=anOffset; |
|
248 } |
|
249 |
|
250 inline TInt HDbsBuf::MovePos(TWrite,TInt anOffset) |
|
251 { |
|
252 return iWPos+=anOffset; |
|
253 } |
|
254 |
|
255 inline TInt HDbsBuf::Lag(TRead) const |
|
256 { |
|
257 return Ptr(ERead)-End(ERead); |
|
258 } |
|
259 |
|
260 inline TInt HDbsBuf::Lag(TWrite) const |
|
261 { |
|
262 return Ptr(EWrite)-iBuf.iData; |
|
263 } |
|
264 |
|
265 inline TInt HDbsBuf::Mark(TRead) const |
|
266 { |
|
267 return Pos(ERead)+Lag(ERead); |
|
268 } |
|
269 |
|
270 inline TInt HDbsBuf::Mark(TWrite) const |
|
271 { |
|
272 return Pos(EWrite)+Lag(EWrite); |
|
273 } |
|
274 |
|
275 // Class CDbsSource |
|
276 inline TInt CDbsSource::LinkOffset() |
|
277 { |
|
278 return _FOFF(CDbsSource,iLink); |
|
279 } |
|
280 |
|
281 inline CDbsSource::CDbsSource(const TDbFormat& aFormat): |
|
282 iFormat(aFormat) |
|
283 { |
|
284 } |
|
285 |
|
286 inline void CDbsSource::Open() |
|
287 { |
|
288 ++iConnections; |
|
289 } |
|
290 |
|
291 inline CDbSource& CDbsSource::Source() |
|
292 { |
|
293 __ASSERT(iSource); |
|
294 return *iSource; |
|
295 } |
|
296 |
|
297 // Class CDbsDatabaseStub |
|
298 inline CDbsDatabaseStub::CDbsDatabaseStub() |
|
299 { |
|
300 } |
|
301 |
|
302 // Class CDbsConnection |
|
303 inline void CDbsConnection::Set(CDbsSource& aSource) |
|
304 { |
|
305 __ASSERT(!iSource); |
|
306 iSource=&aSource; |
|
307 aSource.Open(); |
|
308 } |
|
309 |
|
310 inline CDbsSource& CDbsConnection::Source() const |
|
311 { |
|
312 __ASSERT(iSource); |
|
313 return *iSource; |
|
314 } |
|
315 |
|
316 inline const CDbsConnection& CDbsConnection::Connection(const CDbObject& aObject) |
|
317 { |
|
318 __ASSERT(aObject.Context()); |
|
319 return *STATIC_CAST(const CDbsConnection*,aObject.Context()); |
|
320 } |
|
321 |
|
322 inline CDbsSource& CDbsConnection::Source(const CDbObject& aObject) |
|
323 { |
|
324 return Connection(aObject).Source(); |
|
325 } |
|
326 |
|
327 // Class RDbsSources |
|
328 inline RDbsSources::RDbsSources(RDbCache& aCache): |
|
329 iSources(CDbsSource::LinkOffset()), |
|
330 iDrivers(aCache) |
|
331 { |
|
332 } |
|
333 |
|
334 inline void RDbsSources::Close() |
|
335 { |
|
336 __ASSERT(iSources.IsEmpty()); |
|
337 iDrivers.Close(); |
|
338 } |
|
339 |
|
340 // Class CDbsServer |
|
341 inline TDes& CDbsServer::Name0() |
|
342 { |
|
343 return iName0; |
|
344 } |
|
345 |
|
346 inline TDes& CDbsServer::Name1() |
|
347 { |
|
348 return iName1; |
|
349 } |
|
350 |
|
351 inline TDes& CDbsServer::FileName() |
|
352 { |
|
353 return iFileName; |
|
354 } |
|
355 |
|
356 inline RDbsSources& CDbsServer::Sources() |
|
357 { |
|
358 return iSources; |
|
359 } |
|
360 |
|
361 inline RFs& CDbsServer::Fs() |
|
362 { |
|
363 return iFs; |
|
364 } |
|
365 |
|
366 inline RDriveSpaceCol& CDbsServer::DriveSpaceCol() |
|
367 { |
|
368 return iDriveSpaceCol; |
|
369 } |
|
370 |
|
371 inline void CDbsServer::Panic(const TDesC& aCategory,TInt aPanic) |
|
372 { |
|
373 Message().Panic(aCategory,aPanic); |
|
374 } |
|
375 |
|
376 inline CPolicyProxy& CDbsServer::PolicyProxy() const |
|
377 { |
|
378 __ASSERT(iPolicyProxy); |
|
379 return *iPolicyProxy; |
|
380 } |
|
381 |
|
382 inline RDbPropsFactory& CDbsServer::DbPropsFactory() |
|
383 { |
|
384 return iDbPropsFactory; |
|
385 } |
|
386 |
|
387 // Class CDbsSession::TEntry |
|
388 inline TDbsType CDbsSession::TEntry::Type() const |
|
389 { |
|
390 return TDbsType(iType); |
|
391 } |
|
392 |
|
393 inline CDbsDatabaseStub& CDbsSession::TEntry::DatabaseStub() |
|
394 { |
|
395 __ASSERT(Type()==EDbsDatabase); |
|
396 return *STATIC_CAST(CDbsDatabaseStub*,iObject); |
|
397 } |
|
398 |
|
399 inline CDbDatabase& CDbsSession::TEntry::Database() |
|
400 { |
|
401 __ASSERT(Type()==EDbsDatabase); |
|
402 return *STATIC_CAST(CDbDatabase*,iObject); |
|
403 } |
|
404 |
|
405 inline CDbIncremental& CDbsSession::TEntry::Incremental() |
|
406 { |
|
407 __ASSERT(Type()==EDbsIncremental); |
|
408 return *STATIC_CAST(CDbIncremental*,iObject); |
|
409 } |
|
410 |
|
411 inline CDbCursor& CDbsSession::TEntry::Cursor() |
|
412 { |
|
413 __ASSERT(Type()==EDbsCursor); |
|
414 return *STATIC_CAST(CDbCursor*,iObject); |
|
415 } |
|
416 |
|
417 inline CDbRowConstraint& CDbsSession::TEntry::Constraint() |
|
418 { |
|
419 __ASSERT(Type()==EDbsConstraint); |
|
420 return *STATIC_CAST(CDbRowConstraint*,iObject); |
|
421 } |
|
422 |
|
423 inline HDbsStream& CDbsSession::TEntry::Stream() |
|
424 { |
|
425 __ASSERT(Type()==EDbsStream); |
|
426 return *STATIC_CAST(HDbsStream*,iObject); |
|
427 } |
|
428 |
|
429 inline CDbsObserver::HObserver& CDbsSession::TEntry::Observer() |
|
430 { |
|
431 __ASSERT(Type()==EDbsObserver); |
|
432 return *STATIC_CAST(CDbsObserver::HObserver*,iObject); |
|
433 } |
|
434 |
|
435 // Class CDbsSession |
|
436 inline TInt CDbsSession::Add(CDbIncremental* aIncremental, const MPolicy* aPolicy) |
|
437 { |
|
438 return DoAdd(aIncremental,EDbsIncremental, aPolicy); |
|
439 } |
|
440 |
|
441 inline TInt CDbsSession::Add(CDbCursor* aCursor, const MPolicy* aPolicy) |
|
442 { |
|
443 return DoAdd(aCursor,EDbsCursor, aPolicy); |
|
444 } |
|
445 |
|
446 inline TInt CDbsSession::Add(CDbRowConstraint* aConstraint, const MPolicy* aPolicy) |
|
447 { |
|
448 return DoAdd(aConstraint,EDbsConstraint, aPolicy); |
|
449 } |
|
450 |
|
451 inline TInt CDbsSession::Add(HDbsStream* aStream, const MPolicy* aPolicy) |
|
452 { |
|
453 return DoAdd(aStream,EDbsStream, aPolicy); |
|
454 } |
|
455 |
|
456 inline TInt CDbsSession::Add(CDbsObserver::HObserver* aObserver, const MPolicy* aPolicy) |
|
457 { |
|
458 return DoAdd(aObserver,EDbsObserver, aPolicy); |
|
459 } |
|
460 |
|
461 inline CDbsServer& CDbsSession::Server() const |
|
462 { |
|
463 return *static_cast<CDbsServer*>(const_cast<CServer2*>(CSession2::Server())); |
|
464 } |
|
465 |
|
466 inline RDbsSources& CDbsSession::Sources() |
|
467 { |
|
468 return Server().Sources(); |
|
469 } |
|
470 |
|
471 // Class HDbsStream |
|
472 inline HDbsStream::HDbsStream(MStreamBuf* aHost,TInt aReadPos): |
|
473 iHost(*aHost), |
|
474 iRPos(aReadPos), |
|
475 iWPos(0) |
|
476 { |
|
477 __ASSERT(aHost); |
|
478 } |
|
479 |
|
480 inline HDbsStream::~HDbsStream() |
|
481 { |
|
482 iHost.Release(); |
|
483 } |
|
484 |
|
485 inline TInt HDbsStream::SizeL() |
|
486 { |
|
487 return iHost.SizeL(); |
|
488 } |
|
489 |
|
490 inline void HDbsStream::SynchL() |
|
491 { |
|
492 iHost.SynchL(); |
|
493 } |
|
494 |
|
495 // Class HBufBuf |
|
496 inline HBufBuf::HBufBuf(): |
|
497 iBuf(0) |
|
498 { |
|
499 } |
|
500 |
|
501 inline HBufBuf::~HBufBuf() |
|
502 { |
|
503 delete iBuf; |
|
504 } |
|
505 |
|
506 // Class CDbsSecureDatabase |
|
507 inline CDbsSecureDatabase::CDbsSecureDatabase() |
|
508 { |
|
509 } |
|
510 |