|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Global services for LBT server logic |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <lbterrors.h> |
|
21 #include "lbtglobal.h" |
|
22 #include "lbtlogger.h" |
|
23 |
|
24 // ================= LOCAL FUNCTIONS ======================= |
|
25 |
|
26 TInt DataSizeL( |
|
27 const RMessage2& aMessage, |
|
28 const TInt aClientBufferParam) |
|
29 { |
|
30 FUNC_ENTER("LbtGlobal::DataSizeL"); |
|
31 TInt dataSize = aMessage.GetDesLength(aClientBufferParam); |
|
32 if (dataSize < 0) |
|
33 { |
|
34 User::Leave(KErrBadDescriptor); |
|
35 } |
|
36 return dataSize; |
|
37 } |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // LbtGlobal::Write |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 TInt LbtGlobal::Write(const RMessage2& aMessage, |
|
47 const TInt aParam, |
|
48 const TDesC8& aDes, |
|
49 TInt aOffset) |
|
50 { |
|
51 FUNC_ENTER("LbtGlobal::Write"); |
|
52 TInt ret = aMessage.Write(aParam, aDes, aOffset); |
|
53 if (ret != KErrNone) |
|
54 { |
|
55 aMessage.Panic(KLbtClientPanicCategory, KErrBadDescriptor); |
|
56 } |
|
57 return ret; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // LbtGlobal::Read |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 TInt LbtGlobal::Read(const RMessage2& aMessage, |
|
65 const TInt aParam, |
|
66 TDes8& aDes, |
|
67 TInt aOffset) |
|
68 { |
|
69 FUNC_ENTER("LbtGlobal::Read"); |
|
70 TInt ret = aMessage.Read(aParam, aDes, aOffset); |
|
71 if (ret != KErrNone) |
|
72 { |
|
73 aMessage.Panic(KLbtClientPanicCategory, KErrBadDescriptor); |
|
74 } |
|
75 return ret; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // LbtGlobal::RequestComplete |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void LbtGlobal::RequestComplete(const RMessage2& aMessage, TInt aError) |
|
83 { |
|
84 FUNC_ENTER("LbtGlobal::RequestComplete"); |
|
85 if(!aMessage.IsNull()) |
|
86 { |
|
87 // Complete the IPC message only if it is a valid message. |
|
88 aMessage.Complete(aError); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // LbtGlobal::CopyClientBuffer8LC |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 HBufC8* LbtGlobal::CopyClientBuffer8LC( const RMessage2& aMessage, |
|
97 const TInt aClientBufferParam) |
|
98 { |
|
99 FUNC_ENTER("LbtGlobal::CopyClientBuffer8LC"); |
|
100 |
|
101 if( aMessage.IsNull() ) |
|
102 { |
|
103 return NULL; |
|
104 } |
|
105 |
|
106 // Create an empty server side buffer that will contain client data |
|
107 TInt dataSize = DataSizeL(aMessage, aClientBufferParam); |
|
108 HBufC8* buffer = HBufC8::NewLC(dataSize); |
|
109 |
|
110 // Populate server side buffer with client data |
|
111 TPtr8 ptrToBuf = buffer->Des(); |
|
112 TInt retVal = LbtGlobal::Read(aMessage, aClientBufferParam, ptrToBuf); |
|
113 if(retVal != KErrNone) |
|
114 { |
|
115 User::Leave(KErrBadDescriptor); |
|
116 } |
|
117 return buffer; |
|
118 } |
|
119 |
|
120 // end of file |