|
1 /* |
|
2 * Copyright (c) 2005 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: Server global functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 //#ifdef _DEBUG |
|
23 #include "epos_csupltrace.h" |
|
24 //#endif |
|
25 #include "epos_suplterminalerrors.h" |
|
26 #include "epos_csuplglobal.h" |
|
27 |
|
28 // ================= LOCAL FUNCTIONS ======================= |
|
29 |
|
30 TInt DataSizeL( |
|
31 const RMessage2& aMessage, |
|
32 const TInt aClientBufferParam) |
|
33 { |
|
34 TInt dataSize = aMessage.GetDesLength(aClientBufferParam); |
|
35 if (dataSize < 0) |
|
36 { |
|
37 aMessage.Panic(KSuplClientFault, ESuplBadDescriptor); |
|
38 User::Leave(KErrBadDescriptor); |
|
39 } |
|
40 return dataSize; |
|
41 } |
|
42 |
|
43 // ================= MEMBER FUNCTIONS ======================= |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // SuplGlobal::Read |
|
47 // |
|
48 // (other items were commented in a header). |
|
49 // --------------------------------------------------------- |
|
50 // |
|
51 TInt SuplGlobal::Read(const RMessage2& aMessage, |
|
52 const TInt aParam, |
|
53 TDes8& aDes, |
|
54 TInt aOffset) |
|
55 { |
|
56 TInt ret = aMessage.Read(aParam, aDes, aOffset); |
|
57 if (ret != KErrNone) |
|
58 { |
|
59 aMessage.Panic(KSuplClientFault, ESuplBadDescriptor); |
|
60 } |
|
61 return ret; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // SuplGlobal::Read |
|
66 // |
|
67 // (other items were commented in a header). |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 TInt SuplGlobal::Read(const RMessage2& aMessage, |
|
71 const TInt aParam, |
|
72 TDes16& aDes, |
|
73 TInt aOffset) |
|
74 { |
|
75 TInt ret = aMessage.Read(aParam, aDes, aOffset); |
|
76 if (ret != KErrNone) |
|
77 { |
|
78 aMessage.Panic(KSuplClientFault, ESuplBadDescriptor); |
|
79 } |
|
80 return ret; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // SuplGlobal::Write |
|
85 // |
|
86 // (other items were commented in a header). |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 TInt SuplGlobal::Write(const RMessage2& aMessage, |
|
90 const TInt aParam, |
|
91 const TDesC8& aDes, |
|
92 TInt aOffset) |
|
93 { |
|
94 TInt ret = aMessage.Write(aParam, aDes, aOffset); |
|
95 if (ret != KErrNone) |
|
96 { |
|
97 aMessage.Panic(KSuplClientFault, ESuplBadDescriptor); |
|
98 } |
|
99 return ret; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // SuplGlobal::CopyClientBuffer8LC |
|
104 // |
|
105 // (other items were commented in a header). |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 HBufC8* SuplGlobal::CopyClientBuffer8LC( |
|
109 const RMessage2& aMessage, |
|
110 const TInt aClientBufferParam) |
|
111 { |
|
112 // Create an empty server side buffer that will contain client data |
|
113 TInt dataSize = DataSizeL(aMessage, aClientBufferParam); |
|
114 HBufC8* buffer = HBufC8::NewLC(dataSize); |
|
115 |
|
116 // Populate server side buffer with client data |
|
117 TPtr8 ptrToBuf = buffer->Des(); |
|
118 User::LeaveIfError(SuplGlobal::Read(aMessage, aClientBufferParam, ptrToBuf)); |
|
119 return buffer; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // SuplGlobal::CopyClientBufferLC |
|
124 // |
|
125 // (other items were commented in a header). |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 HBufC* SuplGlobal::CopyClientBufferLC( |
|
129 const RMessage2& aMessage, |
|
130 const TInt aClientBufferParam) |
|
131 { |
|
132 // Create an empty server side buffer that will contain client data |
|
133 TInt dataSize = DataSizeL(aMessage, aClientBufferParam); |
|
134 HBufC* buffer = HBufC::NewLC(dataSize); |
|
135 |
|
136 // Populate server side buffer with client data |
|
137 TPtr ptrToBuf = buffer->Des(); |
|
138 User::LeaveIfError(SuplGlobal::Read(aMessage, aClientBufferParam, ptrToBuf)); |
|
139 return buffer; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // SuplGlobal::RequestComplete |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void SuplGlobal::RequestComplete(const RMessage2& aMessage, TInt aError) |
|
147 { |
|
148 if(!aMessage.IsNull()) |
|
149 { |
|
150 // Complete the IPC message only if it is a valid message. |
|
151 aMessage.Complete(aError); |
|
152 } |
|
153 } |
|
154 |
|
155 //#ifdef _DEBUG |
|
156 CSuplTrace* traceLog = NULL; |
|
157 |
|
158 void SuplGlobal::SetupTraceL() |
|
159 { |
|
160 if (!traceLog) |
|
161 { |
|
162 traceLog = CSuplTrace::NewL(); |
|
163 } |
|
164 } |
|
165 |
|
166 void SuplGlobal::TearDownTrace() |
|
167 { |
|
168 delete traceLog; |
|
169 traceLog = NULL; |
|
170 } |
|
171 |
|
172 void SuplGlobal::Trace(const TDesC& aDescription, |
|
173 const TDesC& aFilename, |
|
174 const TInt aLineNumber) |
|
175 { |
|
176 if (traceLog) |
|
177 { |
|
178 // to epos log |
|
179 TInt err; |
|
180 TRAP(err, traceLog->TraceL(aDescription, aFilename, aLineNumber)); |
|
181 |
|
182 #ifdef _DEBUG |
|
183 // same to epocwind.out |
|
184 _LIT(KSuplTraceLogFormat , "SUPL::EPosSuplGateway: %S"); |
|
185 RDebug::Print(KSuplTraceLogFormat, &aDescription); |
|
186 #endif |
|
187 } |
|
188 |
|
189 } |
|
190 //#endif |
|
191 |
|
192 // End of File |