114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System include files
|
|
19 |
#include <s32strm.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
|
|
22 |
// User include files
|
|
23 |
#include "ccsrvapi.h"
|
|
24 |
|
|
25 |
// Local constants
|
|
26 |
|
|
27 |
// ======== MEMBER FUNCTIONS ========
|
|
28 |
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
// CCcSrvMsg::NewL()
|
|
31 |
// Two-phased constructor.
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
EXPORT_C CCcSrvMsg* CCcSrvMsg::NewL()
|
|
34 |
{
|
|
35 |
CCcSrvMsg* self = new ( ELeave ) CCcSrvMsg();
|
|
36 |
CleanupStack::PushL( self );
|
|
37 |
self->ConstructL();
|
|
38 |
CleanupStack::Pop( self );
|
|
39 |
return( self ) ;
|
|
40 |
}
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------
|
|
43 |
// CCcSrvMsg::ConstructL()
|
|
44 |
// -----------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
void CCcSrvMsg::ConstructL()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------
|
|
51 |
// CCcSrvMsg::CCcSrvMsg()
|
|
52 |
// -----------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CCcSrvMsg::CCcSrvMsg()
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------
|
|
59 |
// CCcSrvMsg::~CCcSrvMsg()
|
|
60 |
// -----------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
CCcSrvMsg::~CCcSrvMsg()
|
|
63 |
{
|
|
64 |
delete iData;
|
|
65 |
iData = NULL;
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CCcSrvMsg::MsgId()
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
EXPORT_C RMessage2 CCcSrvMsg::Message()
|
|
72 |
{
|
|
73 |
return( iMessage ) ;
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CCcSrvMsg::SetMsgId()
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
EXPORT_C void CCcSrvMsg::SetMessage( RMessage2& aMessage )
|
|
80 |
{
|
|
81 |
iMessage = aMessage;
|
|
82 |
SetFunction( aMessage.Function() );
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// CCcSrvMsg::Sender()
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
EXPORT_C TInt CCcSrvMsg::Function()
|
|
89 |
{
|
|
90 |
return( iFunction ) ;
|
|
91 |
}
|
|
92 |
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
// CCcSrvMsg::SetSender()
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
EXPORT_C void CCcSrvMsg::SetFunction( TInt aFunction )
|
|
97 |
{
|
|
98 |
iFunction = aFunction;
|
|
99 |
}
|
|
100 |
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
// CCcSrvMsg::Sender()
|
|
103 |
// -----------------------------------------------------------------------------
|
|
104 |
EXPORT_C TUint32 CCcSrvMsg::Sender()
|
|
105 |
{
|
|
106 |
return( iSender ) ;
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CCcSrvMsg::SetSender()
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
EXPORT_C void CCcSrvMsg::SetSender( TUint32 aSender )
|
|
113 |
{
|
|
114 |
iSender = aSender;
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// CCcSrvMsg::Receiver()
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
EXPORT_C TUint32 CCcSrvMsg::Receiver()
|
|
121 |
{
|
|
122 |
return( iReceiver ) ;
|
|
123 |
}
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// CCcSrvMsg::SetReceiver()
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
EXPORT_C void CCcSrvMsg::SetReceiver( TUint32 aReceiver )
|
|
129 |
{
|
|
130 |
iReceiver = aReceiver;
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// CCcSrvMsg::MsgId()
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
EXPORT_C TUint32 CCcSrvMsg::MsgId()
|
|
137 |
{
|
|
138 |
return( iMsgId ) ;
|
|
139 |
}
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
// CCcSrvMsg::SetMsgId()
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
EXPORT_C void CCcSrvMsg::SetMsgId( TUint32 aMsgId )
|
|
145 |
{
|
|
146 |
iMsgId = aMsgId;
|
|
147 |
}
|
|
148 |
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
// CCcSrvMsg::TrId()
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
EXPORT_C TUint32 CCcSrvMsg::TrId()
|
|
153 |
{
|
|
154 |
return( iTrId ) ;
|
|
155 |
}
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CCcSrvMsg::SetTrId()
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
EXPORT_C void CCcSrvMsg::SetTrId( TUint32 aTrId )
|
|
161 |
{
|
|
162 |
iTrId = aTrId;
|
|
163 |
}
|
|
164 |
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
// CCcSrvMsg::Status()
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
EXPORT_C TInt CCcSrvMsg::Status()
|
|
169 |
{
|
|
170 |
return( iStatus ) ;
|
|
171 |
}
|
|
172 |
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
// CCcSrvMsg::SetStatus()
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
EXPORT_C void CCcSrvMsg::SetStatus( TInt aStatus )
|
|
177 |
{
|
|
178 |
iStatus = aStatus;
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
// CCcSrvMsg::Data()
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
EXPORT_C TPtrC8 CCcSrvMsg::Data()
|
|
185 |
{
|
|
186 |
if ( iData )
|
|
187 |
{
|
|
188 |
return iData->Des();
|
|
189 |
}
|
|
190 |
else
|
|
191 |
{
|
|
192 |
return KNullDesC8();
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
// CCcSrvMsg::SetData()
|
|
198 |
// -----------------------------------------------------------------------------
|
|
199 |
EXPORT_C void CCcSrvMsg::SetData( const TDesC8& aData )
|
|
200 |
{
|
|
201 |
if ( iData )
|
|
202 |
{
|
|
203 |
delete iData;
|
|
204 |
}
|
|
205 |
iData = aData.Alloc();
|
|
206 |
iDataSize = iData->Des().Length();
|
|
207 |
}
|
|
208 |
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
// CCcSrvMsg::DataSize()
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
EXPORT_C TInt CCcSrvMsg::DataSize()
|
|
213 |
{
|
|
214 |
return iDataSize;
|
|
215 |
}
|
|
216 |
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
// CCcSrvMsg::ExternalizeL()
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
EXPORT_C void CCcSrvMsg::ExternalizeL( RWriteStream& aStream )
|
|
221 |
{
|
|
222 |
ExternalizeHeaderL( aStream );
|
|
223 |
if ( iData )
|
|
224 |
{
|
|
225 |
aStream << *iData;
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// CCcSrvMsg::ExternalizeHeaderL()
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
EXPORT_C void CCcSrvMsg::ExternalizeHeaderL( RWriteStream& aStream )
|
|
233 |
{
|
|
234 |
aStream.WriteUint32L( iMsgId );
|
|
235 |
aStream.WriteUint32L( iTrId );
|
|
236 |
aStream.WriteInt32L( iStatus );
|
|
237 |
aStream.WriteInt32L( iDataSize );
|
|
238 |
}
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
// CCcSrvMsg::InternalizeL()
|
|
242 |
// -----------------------------------------------------------------------------
|
|
243 |
EXPORT_C void CCcSrvMsg::InternalizeL( RReadStream& aStream )
|
|
244 |
{
|
|
245 |
InternalizeHeaderL( aStream );
|
|
246 |
if ( iData )
|
|
247 |
{
|
|
248 |
delete iData;
|
|
249 |
iData = NULL;
|
|
250 |
}
|
|
251 |
if ( iDataSize )
|
|
252 |
{
|
|
253 |
iData = HBufC8::NewL( aStream, iDataSize );
|
|
254 |
}
|
|
255 |
}
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// CCcSrvMsg::InternalizeHeaderL()
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
EXPORT_C void CCcSrvMsg::InternalizeHeaderL( RReadStream& aStream )
|
|
261 |
{
|
|
262 |
iMsgId = aStream.ReadUint32L();
|
|
263 |
iTrId = aStream.ReadUint32L();
|
|
264 |
iStatus = aStream.ReadInt32L();
|
|
265 |
iDataSize = aStream.ReadInt32L();
|
|
266 |
}
|
|
267 |
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
// CCcSrvMsg::MarshalL()
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
EXPORT_C HBufC8* CCcSrvMsg::MarshalL()
|
|
272 |
{
|
|
273 |
// Externalize message
|
|
274 |
CBufFlat* reqBuf = CBufFlat::NewL( KCcHeaderSize + iDataSize );
|
|
275 |
CleanupStack::PushL( reqBuf );
|
|
276 |
RBufWriteStream reqStream( *reqBuf );
|
|
277 |
CleanupClosePushL( reqStream );
|
|
278 |
ExternalizeL( reqStream );
|
|
279 |
CleanupStack::PopAndDestroy( &reqStream );
|
|
280 |
|
|
281 |
// Append externalized messgae to a descriptor
|
|
282 |
HBufC8* msgDesc = HBufC8::NewL( reqBuf->Size() );
|
|
283 |
TPtr8 msgPtr( NULL, 0 );
|
|
284 |
msgPtr.Set( msgDesc->Des() );
|
|
285 |
reqBuf->Read( 0, msgPtr, reqBuf->Size() );
|
|
286 |
CleanupStack::PopAndDestroy( reqBuf );
|
|
287 |
|
|
288 |
return msgDesc;
|
|
289 |
}
|
|
290 |
|
|
291 |
// End of file
|