|
1 // Copyright (c) 2004-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 // SD_BUF.CPP |
|
15 // HDbsBuf class - "DBMS security" related code only |
|
16 // |
|
17 // |
|
18 |
|
19 #include "SD_STD.H" |
|
20 |
|
21 /** |
|
22 Standard phase-one factory method for HDbsBuf instances. |
|
23 @param aDbSession RDbs session instance. |
|
24 @param aFunction DBMS server function code. EDbsDatabaseList DBMS function code is only used. |
|
25 @param aArgs EDbsDatabaseList related set of arguments. |
|
26 @return A pointer to the created HDbsBuf instance. |
|
27 @leave One of the system-wide error codes, including KErrNoMemory. |
|
28 */ |
|
29 HDbsBuf* HDbsBuf::NewLC(const RDbs& aDbSession, TDbsFunction aFunction, TIpcArgs& aArgs) |
|
30 { |
|
31 HDbsBuf* self = new (ELeave) HDbsBuf; |
|
32 self->PushL(); |
|
33 self->ConstructL(aDbSession, aFunction, aArgs); |
|
34 return self; |
|
35 } |
|
36 |
|
37 /** |
|
38 Standard phase-two construction method for HDbsBuf instances. |
|
39 @param aDbSession RDbs session instance. |
|
40 @param aFunction DBMS server function code. EDbsDatabaseList DBMS function code is only used. |
|
41 @param aArgs EDbsDatabaseList related set of arguments. |
|
42 @leave One of the system-wide error codes, including KErrNoMemory. |
|
43 */ |
|
44 void HDbsBuf::ConstructL(const RDbs& aDbSession, TDbsFunction aFunction, TIpcArgs& aArgs) |
|
45 { |
|
46 TPckg<TDbsStreamBuf> pckg(iBuf); |
|
47 aArgs.Set(3, &pckg); |
|
48 iIpc.OpenL(aDbSession, aFunction, aArgs); |
|
49 TUint8* base = iBuf.iData; |
|
50 // if reading we already have one buffer-full of data |
|
51 TInt avail = Max(0, Min(iBuf.iExt, KDbsStreamBufSize)); |
|
52 SetBuf(ERead, base, base + avail); |
|
53 SetPos(ERead, avail); |
|
54 SetBuf(EWrite, base, base); |
|
55 SetPos(EWrite, 0); |
|
56 } |