24
|
1 |
// Copyright (c) 2001-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 |
// Implements the CSmsProvider service access point (SAP) class.
|
|
15 |
// Includes
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "smsprot.h"
|
|
24 |
|
|
25 |
#include <es_ver.h>
|
|
26 |
#include <es_mbuf.h>
|
|
27 |
|
|
28 |
#include "Gsmuelem.h"
|
|
29 |
#include "gsmubuf.h"
|
|
30 |
#include "Gsmumsg.h"
|
|
31 |
|
|
32 |
#include "smsustrm.h"
|
|
33 |
#include "smspmain.h"
|
|
34 |
#include "smspfacadestor.h"
|
|
35 |
|
|
36 |
// CSmsProvider policies
|
|
37 |
//
|
|
38 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlDeleteSmsMessagePolicy,ECapabilityWriteUserData);
|
|
39 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlEnumerateSmsMessagesPolicy,ECapabilityReadUserData );
|
|
40 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlReadMessageSucceededPolicy,ECapabilityReadUserData );
|
|
41 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlReadMessageFailedPolicy,ECapabilityReadUserData );
|
|
42 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlSendSmsMessagePolicy,ECapabilityNetworkServices );
|
|
43 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlWriteSmsMessagePolicy,ECapabilityWriteUserData );
|
|
44 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlReadSmsParamsPolicy,ECapability_None );
|
|
45 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlCompleteReadSmsParamsPolicy,ECapability_None );
|
|
46 |
static _LIT_SECURITY_POLICY_C1(smsProviderIoctlWriteSmsParamsPolicy,ECapabilityWriteDeviceData );
|
|
47 |
|
|
48 |
// following not implemented as too paranoid
|
|
49 |
//static _LIT_SECURITY_POLICY_C1(smsProviderIoctlSelectModemPresentPolicy,ECapabilityWriteDeviceData );
|
|
50 |
//static _LIT_SECURITY_POLICY_C1(smsProviderIoctlSelectModemNotPresentPolicy,ECapabilityWriteDeviceData );
|
|
51 |
static _LIT_SECURITY_POLICY_C1(smsProviderSetLocalNamePolicy,ECapabilityNetworkServices);
|
|
52 |
static _LIT_SECURITY_POLICY_C1(smsProviderWritePolicy,ECapability_None);
|
|
53 |
|
|
54 |
/**
|
|
55 |
* 2 Phase constructor.
|
|
56 |
*
|
|
57 |
* @param aProtocol a reference to the SMS protocol object.
|
|
58 |
* @leave Leaves if ContructL() leaves, or not enough memory is available.
|
|
59 |
* @return a new CSmsProvider object.
|
|
60 |
*
|
|
61 |
*/
|
|
62 |
CSmsProvider* CSmsProvider::NewL(CSmsProtocol& aProtocol)
|
|
63 |
{
|
|
64 |
LOGSMSPROT1("CSmsProvider::NewL");
|
|
65 |
|
|
66 |
CSmsProvider* self =new(ELeave) CSmsProvider(aProtocol);
|
|
67 |
CleanupStack::PushL(self);
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop(self);
|
|
70 |
|
|
71 |
LOGSMSPROT1("-> CSmsProvider::NewL - done");
|
|
72 |
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* C'tor
|
|
78 |
*
|
|
79 |
* @param aProtocol a reference to the SMS protocol object.
|
|
80 |
*/
|
|
81 |
CSmsProvider::CSmsProvider(CSmsProtocol& aProtocol)
|
|
82 |
: iProtocol(aProtocol),iEnumSocket(EFalse),iNumOfEnumeratedMessages(0)
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* 2nd Phase of construction.
|
|
88 |
* Subscribes to the protocol as an observer, and creates our send and
|
|
89 |
* receive buffers.
|
|
90 |
*
|
|
91 |
*/
|
|
92 |
void CSmsProvider::ConstructL()
|
|
93 |
{
|
|
94 |
LOGSMSPROT1("CSmsProvider::ConstructL");
|
|
95 |
|
|
96 |
iProtocol.AddSmsMessageObserverL(*this);
|
|
97 |
SetObserverAddedToProtocol(ETrue);
|
|
98 |
iRecvBufSegArray=new(ELeave) CArrayPtrFlat<CBufSeg>(8);
|
|
99 |
iSendBufSeg = CBufSeg::NewL(KSmsMaxSegmentLength);
|
|
100 |
|
|
101 |
LOGSMSPROT1("-> CSmsProvider::ConstructL - done");
|
|
102 |
}
|
|
103 |
|
|
104 |
/**
|
|
105 |
* D'tor
|
|
106 |
*
|
|
107 |
* Removes this SAP as an observer of the SMS protocol, and
|
|
108 |
* frees the send and receive buffers.
|
|
109 |
*
|
|
110 |
*/
|
|
111 |
CSmsProvider::~CSmsProvider()
|
|
112 |
{
|
|
113 |
if( ObserverAddedToProtocol() )
|
|
114 |
{
|
|
115 |
iProtocol.RemoveSmsMessageObserver(*this);
|
|
116 |
}
|
|
117 |
if( iRecvBufSegArray )
|
|
118 |
{
|
|
119 |
iRecvBufSegArray->ResetAndDestroy();
|
|
120 |
delete iRecvBufSegArray;
|
|
121 |
}
|
|
122 |
delete iSendBufSeg;
|
|
123 |
}
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Does nothing. Implementation of pure virtual CServProviderBase::Start().
|
|
127 |
*
|
|
128 |
*/
|
|
129 |
void CSmsProvider::Start()
|
|
130 |
{
|
|
131 |
LOGSMSPROT1("CSmsProvider::Start");
|
|
132 |
}
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Returns the local address of this SAP. Implementation of
|
|
136 |
* pure virtual CServProviderBase::LocalName().
|
|
137 |
*
|
|
138 |
*/
|
|
139 |
void CSmsProvider::LocalName(TSockAddr& aAddr) const
|
|
140 |
{
|
|
141 |
LOGSMSPROT1("CSmsProvider::LocalName");
|
|
142 |
aAddr = iLocalAddress;
|
|
143 |
}
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Sets the local address of this SAP by binding it to the protocol.
|
|
147 |
* The protocol ensures that there are no duplicate observers, and
|
|
148 |
* then calls back on the CSmsProvider::SetLocalAddress() method
|
|
149 |
* to set the address.
|
|
150 |
*
|
|
151 |
* Implementation of the pure virtual CServProviderBase::SetLocalName().
|
|
152 |
*
|
|
153 |
* @capability NetworkServices
|
|
154 |
*/
|
|
155 |
TInt CSmsProvider::SetLocalName(TSockAddr& aAddr)
|
|
156 |
{
|
|
157 |
LOGSMSPROT1("CSmsProvider::SetLocalName");
|
|
158 |
|
|
159 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderSetLocalNamePolicy,"CSmsProvider SetLocal Name policy check") != KErrNone) )
|
|
160 |
{
|
|
161 |
return KErrPermissionDenied;
|
|
162 |
}
|
|
163 |
TSmsAddr& smsAddr=static_cast<TSmsAddr&>(aAddr);
|
|
164 |
if( ( smsAddr.SmsAddrFamily() == ESmsAddrApplication8BitPort || smsAddr.SmsAddrFamily() == ESmsAddrApplication16BitPort ) && smsAddr.Port() == 0 )
|
|
165 |
{
|
|
166 |
if( !iProtocol.AllocateLocalAddress(smsAddr) )
|
|
167 |
{
|
|
168 |
return KErrInUse;
|
|
169 |
}
|
|
170 |
}
|
|
171 |
return iProtocol.BindSmsMessageObserver(*this,smsAddr);
|
|
172 |
}
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Called by the protocol to retrieve the remote name of the connection.
|
|
176 |
* This protocol is not connection oriented so this is not supported.
|
|
177 |
*
|
|
178 |
* Implementation of the pure virtual CServProviderBase::RemName().
|
|
179 |
*
|
|
180 |
*/
|
|
181 |
void CSmsProvider::RemName(TSockAddr& /*aAddr*/) const
|
|
182 |
{
|
|
183 |
// Ignore in code coverage - not intended to be used
|
|
184 |
BULLSEYE_OFF
|
|
185 |
LOGSMSPROT1("CSmsProvider::RemName");
|
|
186 |
BULLSEYE_RESTORE
|
|
187 |
}
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Called by the protocol to set the remote name of the connection.
|
|
191 |
* This protocol is not connection oriented so this is not supported.
|
|
192 |
*
|
|
193 |
* Implementation of the pure virtual CServProviderBase::SetRemName().
|
|
194 |
*
|
|
195 |
*/
|
|
196 |
TInt CSmsProvider::SetRemName(TSockAddr& /*aAddr*/)
|
|
197 |
{
|
|
198 |
// Ignore in code coverage - not intended to be used
|
|
199 |
BULLSEYE_OFF
|
|
200 |
LOGSMSPROT1("CSmsProvider::SetRemName");
|
|
201 |
return KErrNotSupported;
|
|
202 |
BULLSEYE_RESTORE
|
|
203 |
}
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Returns the current value of an option setting for this SAP.
|
|
207 |
* No settings are currently defined.
|
|
208 |
* Implementation of pure virtual CServProviderBase::GetOption().
|
|
209 |
*
|
|
210 |
*/
|
|
211 |
TInt CSmsProvider::GetOption(TUint /*aLevel*/,TUint /*aName*/,TDes8& /*aOption*/) const
|
|
212 |
{
|
|
213 |
// Ignore in code coverage - not intended to be used
|
|
214 |
BULLSEYE_OFF
|
|
215 |
LOGSMSPROT1("CSmsProvider::GetOption");
|
|
216 |
return 0;
|
|
217 |
BULLSEYE_RESTORE
|
|
218 |
}
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Called to perform specific IO control by the client. All of the SMS protocol
|
|
222 |
* services are provided through this interface.
|
|
223 |
*
|
|
224 |
* The local address of this SAP must already be bound, and only one ioctl request
|
|
225 |
* may be outstanding at any one time.
|
|
226 |
*
|
|
227 |
* A resulting socket error of KErrEof can result from a KErrNoMemory during a
|
|
228 |
* preceding write to the socket.
|
|
229 |
*
|
|
230 |
* Implementation of pure virtual CServProviderBase::Ioctl().
|
|
231 |
*
|
|
232 |
* @param aLevel the IOCTL level. Only KSolSmsProv is supported.
|
|
233 |
* @param aName the IOCTL name.
|
|
234 |
* @param aOption the IOCTL option.
|
|
235 |
*
|
|
236 |
*/
|
|
237 |
void CSmsProvider::Ioctl(TUint aLevel,TUint aName,TDes8* aOption)
|
|
238 |
{
|
|
239 |
LOGSMSPROT3("CSmsProvider::Ioctl [aLevel=%d, aName=%d]", aLevel, aName);
|
|
240 |
LOGSMSPROT2("CSmsProvider::Ioctl [provider=0x%08x]",this);
|
|
241 |
|
|
242 |
// Panic in debug mode if this call is invalid in this SAPs current state
|
|
243 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrUnbound,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
244 |
__ASSERT_DEBUG(!IoctlOutstanding(),SmspPanic(KSmspPanicIoctlAlreadyOutstanding));
|
|
245 |
// Gracefully handle invalid calls in release build
|
|
246 |
if( iLocalAddress.SmsAddrFamily()==ESmsAddrUnbound )
|
|
247 |
{
|
|
248 |
iSocket->Error(KErrNotReady,MSocketNotify::EErrorIoctl);
|
|
249 |
return;
|
|
250 |
}
|
|
251 |
if( IoctlOutstanding() )
|
|
252 |
{
|
|
253 |
iSocket->Error(KErrInUse,MSocketNotify::EErrorIoctl);
|
|
254 |
return;
|
|
255 |
}
|
|
256 |
// General state is OK, now try to service the request
|
|
257 |
iName=aName;
|
|
258 |
switch( aLevel )
|
|
259 |
{
|
|
260 |
case KSolSmsProv:
|
|
261 |
{
|
|
262 |
switch( iName )
|
|
263 |
{
|
|
264 |
case KIoctlSupportOODClass0SmsMessages:
|
|
265 |
{
|
|
266 |
if( iProtocol.iReassemblyStore )
|
|
267 |
{
|
|
268 |
if( iProtocol.iReassemblyStore->IsSeparateClass0StoreSupported() )
|
|
269 |
{
|
|
270 |
iSocket->IoctlComplete(NULL);
|
|
271 |
}
|
|
272 |
else
|
|
273 |
{
|
|
274 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
275 |
}
|
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
280 |
}
|
|
281 |
} break;
|
|
282 |
case KIoctlSendSmsMessage:
|
|
283 |
{
|
|
284 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlSendSmsMessagePolicy,"CSmsProvider Ioctl SendSmsMessage policy check") != KErrNone) )
|
|
285 |
{
|
|
286 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
287 |
return;
|
|
288 |
}
|
|
289 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrLocalOperation,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
290 |
__ASSERT_DEBUG(aOption!=NULL,SmspPanic(KSmspPanicOptionBufferNull));
|
|
291 |
// Handle bad requests gracefully
|
|
292 |
if( iLocalAddress.SmsAddrFamily()==ESmsAddrLocalOperation )
|
|
293 |
{
|
|
294 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
295 |
return;
|
|
296 |
}
|
|
297 |
if( aOption == NULL )
|
|
298 |
{
|
|
299 |
iSocket->Error(KErrArgument,MSocketNotify::EErrorIoctl);
|
|
300 |
return;
|
|
301 |
}
|
|
302 |
// Read message from socket
|
|
303 |
CSmsMessage* smsmessage=NULL;
|
|
304 |
TRAPD(ret,(smsmessage=InternalizeMessageL()));
|
|
305 |
if( ret!=KErrNone )
|
|
306 |
{
|
|
307 |
iSendBufSeg->Reset();
|
|
308 |
iSocket->Error(ret,MSocketNotify::EErrorIoctl);
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
|
312 |
// Pass the message to the protocol for sending
|
|
313 |
TPckgBuf<TUint> buf;
|
|
314 |
buf.Copy(*aOption);
|
|
315 |
SetIoctlOutstanding(ETrue);
|
|
316 |
iProtocol.SendSmsMessage(smsmessage,*this, buf());
|
|
317 |
}
|
|
318 |
} break;
|
|
319 |
case KIoctlEnumerateSmsMessages:
|
|
320 |
{
|
|
321 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlEnumerateSmsMessagesPolicy, "CSmsProvider Ioctl EnumerateSmsMessages policy check") != KErrNone) )
|
|
322 |
{
|
|
323 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
324 |
return;
|
|
325 |
}
|
|
326 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
327 |
// Handle bad requests gracefully
|
|
328 |
if( iLocalAddress.SmsAddrFamily()==ESmsAddrSendOnly )
|
|
329 |
{
|
|
330 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
331 |
return;
|
|
332 |
}
|
|
333 |
|
|
334 |
SetIoctlOutstanding(ETrue);
|
|
335 |
iProtocol.EnumeratePhone(*this);
|
|
336 |
} break;
|
|
337 |
case KIoctlWriteSmsMessage:
|
|
338 |
{
|
|
339 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlWriteSmsMessagePolicy,"CSmsProvider IoctlWriteSmsMessage policy check") != KErrNone) )
|
|
340 |
{
|
|
341 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
342 |
return;
|
|
343 |
}
|
|
344 |
// Read message from the socket
|
|
345 |
CSmsMessage*smsmessage=NULL;
|
|
346 |
TRAPD(ret,(smsmessage=InternalizeMessageL()));
|
|
347 |
if( ret!=KErrNone )
|
|
348 |
{
|
|
349 |
iSendBufSeg->Reset();
|
|
350 |
iSocket->Error(ret,MSocketNotify::EErrorIoctl);
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
// Pass message to the protocol for writing
|
|
355 |
SetIoctlOutstanding(ETrue);
|
|
356 |
iProtocol.WriteSmsMessage(smsmessage,*this);
|
|
357 |
}
|
|
358 |
} break;
|
|
359 |
case KIoctlDeleteSmsMessage:
|
|
360 |
{
|
|
361 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlDeleteSmsMessagePolicy,"CSmsProvider Ioctl DeleteSmsMessage policy check") != KErrNone) )
|
|
362 |
{
|
|
363 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
364 |
return;
|
|
365 |
}
|
|
366 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
367 |
// Handle bad requests gracefully
|
|
368 |
if( iLocalAddress.SmsAddrFamily()==ESmsAddrSendOnly )
|
|
369 |
{
|
|
370 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
371 |
return;
|
|
372 |
}
|
|
373 |
// Read message from the socket
|
|
374 |
CSmsMessage*smsmessage=NULL;
|
|
375 |
TRAPD(ret,(smsmessage=InternalizeMessageL()));
|
|
376 |
if( ret!=KErrNone )
|
|
377 |
{
|
|
378 |
LOGSMSPROT2("-> CSmsProvider::Ioctl - CSmsProvider::InternalizeMessageL [ret=%d]", ret);
|
|
379 |
iSendBufSeg->Reset();
|
|
380 |
iSocket->Error(ret, MSocketNotify::EErrorIoctl);
|
|
381 |
}
|
|
382 |
else
|
|
383 |
{
|
|
384 |
// Pass request to protocol
|
|
385 |
SetIoctlOutstanding(ETrue);
|
|
386 |
iProtocol.DeleteSmsMessage(smsmessage,*this);
|
|
387 |
}
|
|
388 |
} break;
|
|
389 |
case KIoctlReadMessageSucceeded:
|
|
390 |
{
|
|
391 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlReadMessageSucceededPolicy,"CSmsProvider Ioctl ReadMessageSucceeded policy check") != KErrNone) )
|
|
392 |
{
|
|
393 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
394 |
return;
|
|
395 |
}
|
|
396 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
397 |
__ASSERT_DEBUG(NumSegments(iSegmentIndex==NumSegments(iRecvBufSegArray->At(0)->Size())),SmspPanic(KSmspPanicBadClientIoctlCall));
|
|
398 |
// Delete entry from reassemblystore
|
|
399 |
CSmsMessage*smsmessage=NULL;
|
|
400 |
TRAPD(ret,(smsmessage=InternalizeMessageL(iRecvBufSegArray->At(0))));
|
|
401 |
if( ret==KErrNone )
|
|
402 |
{
|
|
403 |
TRAP(ret,(iProtocol.DeleteSMSFromReaStoreL( *smsmessage )));
|
|
404 |
LOGSMSPROT2("-> CSmsProvider::Ioctl - CSmsProvider::DeleteSMSFromReaStoreL [ret=%d]", ret);
|
|
405 |
}
|
|
406 |
else
|
|
407 |
{
|
|
408 |
LOGSMSPROT2("-> CSmsProvider::Ioctl - CSmsProvider::InternalizeMessageL [ret=%d]", ret);
|
|
409 |
}
|
|
410 |
delete smsmessage;
|
|
411 |
// Looking for more sms left in the store
|
|
412 |
// This is now done after finishing the readprocess
|
|
413 |
iProtocol.MessageReadedSuccessfully();
|
|
414 |
if( iEnumSocket )
|
|
415 |
{
|
|
416 |
--iNumOfEnumeratedMessages;
|
|
417 |
LOGSMSPROT2("-> CSmsProvider::Ioctl - [iNumOfEnumeratedMessages=%d]", iNumOfEnumeratedMessages);
|
|
418 |
if( iNumOfEnumeratedMessages <= 0 )
|
|
419 |
{
|
|
420 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
421 |
iEnumSocket=EFalse;
|
|
422 |
iProtocol.MessageReadedSuccessfully();
|
|
423 |
LOGSMSPROT1("-> CSmsProvider::Ioctl - [iNumOfEnumeratedMessages=NULL]");
|
|
424 |
}
|
|
425 |
}
|
|
426 |
// Remove the message from the receive buffer & complete
|
|
427 |
delete iRecvBufSegArray->At(0);
|
|
428 |
iRecvBufSegArray->At(0) = NULL;
|
|
429 |
iRecvBufSegArray->Delete(0);
|
|
430 |
|
|
431 |
iSegmentIndex=0;
|
|
432 |
iSocket->IoctlComplete(NULL);
|
|
433 |
} break;
|
|
434 |
case KIoctlReadMessageFailed:
|
|
435 |
{
|
|
436 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlReadMessageFailedPolicy,"CSmsProvider Ioctl ReadMessageFailed policy check") != KErrNone) )
|
|
437 |
{
|
|
438 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
439 |
return;
|
|
440 |
}
|
|
441 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
442 |
__ASSERT_DEBUG(NumSegments(iSegmentIndex<=NumSegments(iRecvBufSegArray->At(0)->Size())),SmspPanic(KSmspPanicBadClientIoctlCall));
|
|
443 |
// Handle bad requests gracefully
|
|
444 |
if( iLocalAddress.SmsAddrFamily()==ESmsAddrSendOnly )
|
|
445 |
{
|
|
446 |
if( iEnumSocket )
|
|
447 |
{
|
|
448 |
--iNumOfEnumeratedMessages;
|
|
449 |
if( iNumOfEnumeratedMessages <= 0 )
|
|
450 |
{
|
|
451 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
452 |
LOGSMSPROT1("-> CSmsProvider::Ioctl - fail [iNumOfEnumeratedMessages=NULL]");
|
|
453 |
iEnumSocket=EFalse;
|
|
454 |
iProtocol.MessageReadedSuccessfully();
|
|
455 |
}
|
|
456 |
}
|
|
457 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
458 |
return;
|
|
459 |
}
|
|
460 |
// Re-notify the socket that data is available, reset the segment
|
|
461 |
// index of the current message back to the start & complete
|
|
462 |
iSocket->NewData(iSegmentIndex);
|
|
463 |
iSegmentIndex=0;
|
|
464 |
iSocket->IoctlComplete(NULL);
|
|
465 |
} break;
|
|
466 |
case KIoctlReadSmsParams:
|
|
467 |
{
|
|
468 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlReadSmsParamsPolicy,"CSmsProvider Ioctl ReadSmsParams policy check") != KErrNone) )
|
|
469 |
{
|
|
470 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
471 |
return;
|
|
472 |
}
|
|
473 |
// Handle bad requests gracefully
|
|
474 |
if( iLocalAddress.SmsAddrFamily()!=ESmsAddrLocalOperation )
|
|
475 |
{
|
|
476 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
477 |
return;
|
|
478 |
}
|
|
479 |
|
|
480 |
// Pass request on to the protocol
|
|
481 |
SetIoctlOutstanding(ETrue);
|
|
482 |
iProtocol.ReadSmsParameters(*this);
|
|
483 |
} break;
|
|
484 |
case KIoctlCompleteReadSmsParams:
|
|
485 |
{
|
|
486 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlCompleteReadSmsParamsPolicy,"CSmsProvider Ioctl CompleteReadSmsParams policy check") != KErrNone) )
|
|
487 |
{
|
|
488 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
489 |
return;
|
|
490 |
}
|
|
491 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
492 |
__ASSERT_DEBUG(NumSegments(iSegmentIndex==NumSegments(iRecvBufSegArray->At(0)->Size())),SmspPanic(KSmspPanicBadClientIoctlCall));
|
|
493 |
// Handle bad requests gracefully
|
|
494 |
if ( iLocalAddress.SmsAddrFamily()==ESmsAddrSendOnly )
|
|
495 |
{
|
|
496 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
497 |
return;
|
|
498 |
}
|
|
499 |
// Remove the parameter list from the receive buffer & complete
|
|
500 |
delete iRecvBufSegArray->At(0);
|
|
501 |
iRecvBufSegArray->At(0) = NULL;
|
|
502 |
iRecvBufSegArray->Delete(0);
|
|
503 |
iSegmentIndex=0;
|
|
504 |
iSocket->IoctlComplete(NULL);
|
|
505 |
} break;
|
|
506 |
case KIoctlWriteSmsParams:
|
|
507 |
{
|
|
508 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderIoctlWriteSmsParamsPolicy,"CSmsProvider Ioctl WriteSmsParams policy check") != KErrNone) )
|
|
509 |
{
|
|
510 |
iSocket->Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
|
|
511 |
return;
|
|
512 |
}
|
|
513 |
// Read parameters from the socket
|
|
514 |
CMobilePhoneSmspList*mobilePhoneSmspList=NULL;
|
|
515 |
TRAPD(ret,(mobilePhoneSmspList=InternalizeParametersL()));
|
|
516 |
if( ret!=KErrNone )
|
|
517 |
{
|
|
518 |
iSendBufSeg->Reset();
|
|
519 |
iSocket->Error(ret,MSocketNotify::EErrorIoctl);
|
|
520 |
}
|
|
521 |
else
|
|
522 |
{
|
|
523 |
// Pass parameters to the protocol for writing.
|
|
524 |
// CSmsWriteParams takes ownership of mobilePhoneSmspList.
|
|
525 |
SetIoctlOutstanding(ETrue);
|
|
526 |
iProtocol.WriteSmsParameters(mobilePhoneSmspList, *this);
|
|
527 |
}
|
|
528 |
} break;
|
|
529 |
default:
|
|
530 |
{
|
|
531 |
// Panic in debug build
|
|
532 |
__ASSERT_DEBUG(EFalse,SmspPanic(KSmspUndefinedName));
|
|
533 |
// Error gracefully in release build
|
|
534 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
535 |
} break;
|
|
536 |
}
|
|
537 |
} break;
|
|
538 |
default:
|
|
539 |
{
|
|
540 |
// Unsupported ioctl level, panic in debug build
|
|
541 |
__ASSERT_DEBUG(EFalse,SmspPanic(KSmspUndefinedLevel));
|
|
542 |
// Gracefully error in release build
|
|
543 |
iSocket->Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
|
|
544 |
} break;
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
/**
|
|
549 |
* Cancels an outstanding ioctl.
|
|
550 |
* Since there can only be a single ioctl request outstanding, the parameters
|
|
551 |
* must match those of the original request.
|
|
552 |
* Implementation of the pure virtual CServProviderBase::CancelIoctl().
|
|
553 |
*
|
|
554 |
* @param aLevel the level of the ioctl request to cancel.
|
|
555 |
* @param aName the name of the ioctl request to cancel.
|
|
556 |
*
|
|
557 |
*/
|
|
558 |
void CSmsProvider::CancelIoctl(TUint aLevel, TUint aName)
|
|
559 |
{
|
|
560 |
LOGSMSPROT3("CSmsProvider::CancelIoctl [aLevel=%d, aName=%d]", aLevel, aName);
|
|
561 |
|
|
562 |
// Panic in debug mode if this call is invalid in this SAPs current state
|
|
563 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrUnbound,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
564 |
__ASSERT_DEBUG(iName==aName,SmspPanic(ESmspBadIoctlName));
|
|
565 |
if( iName != aName )
|
|
566 |
{
|
|
567 |
return;
|
|
568 |
}
|
|
569 |
switch( aLevel )
|
|
570 |
{
|
|
571 |
case KSolSmsProv:
|
|
572 |
{
|
|
573 |
// Request cancel via protocol
|
|
574 |
switch( iName )
|
|
575 |
{
|
|
576 |
case KIoctlSendSmsMessage:
|
|
577 |
{
|
|
578 |
iProtocol.CancelSendSmsMessage(*this);
|
|
579 |
} break;
|
|
580 |
case KIoctlEnumerateSmsMessages:
|
|
581 |
{
|
|
582 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
583 |
iProtocol.CancelEnumeratePhone(*this);
|
|
584 |
iEnumSocket=EFalse;
|
|
585 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
586 |
LOGSMSPROT1("-> CSmsProvider::CancelIoctl - [iNumOfEnumeratedMessages=NULL]");
|
|
587 |
} break;
|
|
588 |
case KIoctlWriteSmsMessage:
|
|
589 |
{
|
|
590 |
iProtocol.CancelWriteSmsMessage(*this);
|
|
591 |
} break;
|
|
592 |
case KIoctlDeleteSmsMessage:
|
|
593 |
{
|
|
594 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
595 |
iProtocol.CancelDeleteSmsMessage(*this);
|
|
596 |
} break;
|
|
597 |
case KIoctlReadMessageSucceeded:
|
|
598 |
case KIoctlReadMessageFailed:
|
|
599 |
{
|
|
600 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
601 |
} break;
|
|
602 |
case KIoctlReadSmsParams:
|
|
603 |
{
|
|
604 |
iProtocol.CancelReadSmsParams();
|
|
605 |
} break;
|
|
606 |
case KIoctlWriteSmsParams:
|
|
607 |
{
|
|
608 |
iProtocol.CancelWriteSmsParams();
|
|
609 |
} break;
|
|
610 |
default:
|
|
611 |
{
|
|
612 |
__ASSERT_DEBUG(EFalse,SmspPanic(KSmspUndefinedName));
|
|
613 |
} break;
|
|
614 |
}
|
|
615 |
} break;
|
|
616 |
default:
|
|
617 |
{
|
|
618 |
__ASSERT_DEBUG(EFalse,SmspPanic(KSmspUndefinedLevel));
|
|
619 |
} break;
|
|
620 |
}
|
|
621 |
}
|
|
622 |
|
|
623 |
/**
|
|
624 |
* Sets an option on the SAP. No options are currently implemented.
|
|
625 |
*
|
|
626 |
* Implements the pure virtual CServProviderBase::SetOption().
|
|
627 |
*
|
|
628 |
*/
|
|
629 |
TInt CSmsProvider::SetOption(TUint /*aLevel*/,TUint /*aName*/,const TDesC8& /*aOption*/)
|
|
630 |
{
|
|
631 |
// Ignore in code coverage - not intended to be used
|
|
632 |
BULLSEYE_OFF
|
|
633 |
LOGSMSPROT1("CSmsProvider::SetOption()");
|
|
634 |
return 0;
|
|
635 |
BULLSEYE_RESTORE
|
|
636 |
}
|
|
637 |
|
|
638 |
/**
|
|
639 |
* Called by the socket server to write data into the send queue.
|
|
640 |
* The data is a single segment of a serialized SMS message.
|
|
641 |
*
|
|
642 |
* A KErrNoMemory condition arising in this write will not be reported directly (due to
|
|
643 |
* the ESOCK design), instead it will be reflected in a KErrEof from the subsequent Ioctl()
|
|
644 |
* call.
|
|
645 |
*
|
|
646 |
* Implementation of the pure virtual CServProviderBase::Write().
|
|
647 |
*
|
|
648 |
* @param aBufChain the data to write into the send buffer.
|
|
649 |
* @param aOptions not used.
|
|
650 |
* @param aAddr not used.
|
|
651 |
* @return 1 (datagram written) on success, otherwise an error.
|
|
652 |
*
|
|
653 |
* @capability None
|
|
654 |
*/
|
|
655 |
TInt CSmsProvider::Write(RMBufChain& aBufChain, TUint /*aOptions*/, TSockAddr* /*aAddr*/)
|
|
656 |
{
|
|
657 |
LOGSMSPROT1("CSmsProvider::Write");
|
|
658 |
|
|
659 |
if( !iSecurityChecker || (iSecurityChecker->CheckPolicy(smsProviderWritePolicy,"CSmsProvider Write policy check") != KErrNone) )
|
|
660 |
{
|
|
661 |
return KErrPermissionDenied;
|
|
662 |
}
|
|
663 |
__ASSERT_DEBUG(iLocalAddress.SmsAddrFamily()!=ESmsAddrUnbound,SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
664 |
|
|
665 |
/// @note: LOGIFH2A2 macro for logging esock write
|
|
666 |
LOGSMSPROT2("-> CSmsProvider::Write [%d bytes]", aBufChain.Length());
|
|
667 |
#ifdef SMSLOGGERIF
|
|
668 |
HBufC8* debugBuf = HBufC8::New(aBufChain.Length());
|
|
669 |
if(debugBuf)
|
|
670 |
{
|
|
671 |
TPtr8 debugData = debugBuf->Des();
|
|
672 |
aBufChain.CopyOut(debugData);
|
|
673 |
LOGIF2(_L8("ESOCK WRITE: %S"),&debugData);
|
|
674 |
LOGIFH2A2(_L8("ESOCK WRITE: "),debugData);
|
|
675 |
delete debugBuf;
|
|
676 |
}
|
|
677 |
#endif
|
|
678 |
|
|
679 |
TUint bytesCopied = 0;
|
|
680 |
// Append all of the mbufs to the send buffer
|
|
681 |
TInt ret = KErrNone;
|
|
682 |
TMBufIter iter(aBufChain);
|
|
683 |
while( iter.More() )
|
|
684 |
{
|
|
685 |
RMBuf* p = iter++;
|
|
686 |
TRAP(ret, iSendBufSeg->InsertL(iSendBufSeg->Size(), p->Ptr(), p->Length()));
|
|
687 |
if(ret != KErrNone)
|
|
688 |
break;
|
|
689 |
bytesCopied += p->Length();
|
|
690 |
}
|
|
691 |
if( ret != KErrNone )
|
|
692 |
{
|
|
693 |
iSendBufSeg->Reset(); // it has always done this, but won't innocent data get zapped?
|
|
694 |
}
|
|
695 |
else
|
|
696 |
{
|
|
697 |
aBufChain.Free(); // we accepted it all; flag these by consuming all buffers
|
|
698 |
}
|
|
699 |
return (ret == KErrNone)? 1: ret;
|
|
700 |
}
|
|
701 |
|
|
702 |
/**
|
|
703 |
* Called by the socket server to retrieve data that this SAP has indicated
|
|
704 |
* is waiting in its buffers.
|
|
705 |
*
|
|
706 |
* Implentation of the pure virtual CServProviderBase::GetData().
|
|
707 |
*
|
|
708 |
* Once the provider has indicated new data is available using
|
|
709 |
* MSocketNotify::NewData(), the socket server will call on this method
|
|
710 |
* to retrieve the serialized SMS message in segments.
|
|
711 |
* Once the sockets client has streamed out the entire message, it
|
|
712 |
* will call on ioctl with KIoctlReadMessageSucceeded which resets the internal
|
|
713 |
* counters.
|
|
714 |
*
|
|
715 |
* @param aBufChain the buffer to insert the data.
|
|
716 |
* @param aLength not used.
|
|
717 |
* @param aOptions not used.
|
|
718 |
* @param aAddr not used.
|
|
719 |
* @return 1 (datagram read) on success, otherwise an error.
|
|
720 |
*
|
|
721 |
*/
|
|
722 |
TInt CSmsProvider::GetData(RMBufChain& aBufChain, TUint /*aLength*/, TUint /*aOptions*/, TSockAddr* /*aAddr*/)
|
|
723 |
{
|
|
724 |
__ASSERT_DEBUG((iLocalAddress.SmsAddrFamily()!=ESmsAddrUnbound) && (iLocalAddress.SmsAddrFamily()!=ESmsAddrSendOnly),SmspPanic(KSmspPanicWrongSmsAddressFamily));
|
|
725 |
|
|
726 |
LOGSMSPROT2("CSmsProvider::GetData [provider=0x%08x]", this);
|
|
727 |
|
|
728 |
// Get the segmented buffer of first message
|
|
729 |
CBufSeg* recvbufseg=iRecvBufSegArray->At(0);
|
|
730 |
TInt size=recvbufseg->Size();
|
|
731 |
__ASSERT_DEBUG(iSegmentIndex<NumSegments(size),SmspPanic(KSmspPanicBadClientMessageRead));
|
|
732 |
|
|
733 |
// Caculate the position of the next segment of the serialized message,
|
|
734 |
// insert into the buffer parameter and update our segment counter
|
|
735 |
TInt pos=iSegmentIndex*KSmsMaxSegmentLength;
|
|
736 |
TInt length = pos+KSmsMaxSegmentLength>size? size-pos: KSmsMaxSegmentLength;
|
|
737 |
|
|
738 |
TRAPD(err, aBufChain.AllocL(length));
|
|
739 |
if( err == KErrNone )
|
|
740 |
{
|
|
741 |
// For want of a segmented buffer copy for Mbufs we have a little loop. Because we're
|
|
742 |
// reading consecutive data out of the CBufSeg there shouldn't be a bad performance hit
|
|
743 |
// (see CBufSeg::Ptr() doco; CBufBase::Read() uses this)
|
|
744 |
TInt segPos = 0;
|
|
745 |
TMBufIter iter(aBufChain);
|
|
746 |
while( segPos < length )
|
|
747 |
{
|
|
748 |
RMBuf* p = iter++;
|
|
749 |
TInt readSize = Min(p->Size(), length - segPos);
|
|
750 |
recvbufseg->Read(pos + segPos, p->Buffer(), readSize);
|
|
751 |
segPos += readSize;
|
|
752 |
}
|
|
753 |
}
|
|
754 |
else if( err == KErrNoMBufs )
|
|
755 |
{
|
|
756 |
return KErrNoMBufs; // ask ESock to call us back when some buffers are free
|
|
757 |
}
|
|
758 |
else
|
|
759 |
{
|
|
760 |
iSocket->Error(err, MSocketNotify::EErrorRecv);
|
|
761 |
}
|
|
762 |
++iSegmentIndex;
|
|
763 |
return 1; // datagrams are counted as atoms not bytes
|
|
764 |
}
|
|
765 |
|
|
766 |
/**
|
|
767 |
* Called by the socket server to indicate the provider should connect to
|
|
768 |
* a peer. Not a connection oriented protocol so this is not implemented.
|
|
769 |
*
|
|
770 |
* Implementation of the pure virtual CServProviderBase::ActiveOpen().
|
|
771 |
*
|
|
772 |
*/
|
|
773 |
void CSmsProvider::ActiveOpen()
|
|
774 |
{
|
|
775 |
// Ignore in code coverage - not intended to be used
|
|
776 |
BULLSEYE_OFF
|
|
777 |
LOGSMSPROT1("CSmsProvider::ActiveOpen [does nothing]");
|
|
778 |
BULLSEYE_RESTORE
|
|
779 |
}
|
|
780 |
|
|
781 |
/**
|
|
782 |
* Called by the socket server to indicate the provider should connect to
|
|
783 |
* a peer. Not a connection oriented protocol so this is not implemented.
|
|
784 |
*
|
|
785 |
* Implementation of the pure virtual CServProviderBase::ActiveOpen().
|
|
786 |
*
|
|
787 |
*/
|
|
788 |
void CSmsProvider::ActiveOpen(const TDesC8& /*aConnectionData*/)
|
|
789 |
{
|
|
790 |
// Ignore in code coverage - not intended to be used
|
|
791 |
BULLSEYE_OFF
|
|
792 |
LOGSMSPROT1("CSmsProvider::ActiveOpen [does nothing]");
|
|
793 |
BULLSEYE_RESTORE
|
|
794 |
}
|
|
795 |
|
|
796 |
/**
|
|
797 |
* Called by the socket server to indicate the provider should wait for an
|
|
798 |
* incoming client connection request. Not a connection oriented protocol
|
|
799 |
* so this is not implemented.
|
|
800 |
*
|
|
801 |
* Implementation of the pure virtual CServiceProviderBase::PassiveOpen().
|
|
802 |
*
|
|
803 |
*/
|
|
804 |
TInt CSmsProvider::PassiveOpen(TUint /*aQueSize*/)
|
|
805 |
{
|
|
806 |
// Ignore in code coverage - not intended to be used
|
|
807 |
BULLSEYE_OFF
|
|
808 |
LOGSMSPROT1("CSmsProvider::PassiveOpen [not supported]");
|
|
809 |
return KErrNotSupported;
|
|
810 |
BULLSEYE_RESTORE
|
|
811 |
}
|
|
812 |
|
|
813 |
/**
|
|
814 |
* Called by the socket server to indicate the provider should wait for an
|
|
815 |
* incoming client connection request. Not a connection oriented protocol
|
|
816 |
* so this is not implemented.
|
|
817 |
*
|
|
818 |
* Implementation of the pure virtual CServiceProviderBase::PassiveOpen().
|
|
819 |
*
|
|
820 |
*/
|
|
821 |
TInt CSmsProvider::PassiveOpen(TUint /*aQueSize*/,const TDesC8& /*aConnectionData*/)
|
|
822 |
{
|
|
823 |
// Ignore in code coverage - not intended to be used
|
|
824 |
BULLSEYE_OFF
|
|
825 |
LOGSMSPROT1("CSmsProvider::PassiveOpen [not supported]");
|
|
826 |
return KErrNotSupported;
|
|
827 |
BULLSEYE_RESTORE
|
|
828 |
}
|
|
829 |
|
|
830 |
/**
|
|
831 |
* Called by the socket server to shutdown a connection.
|
|
832 |
*
|
|
833 |
* Implementation of the pure virtual CServProviderBase::Shutdown().
|
|
834 |
*
|
|
835 |
*/
|
|
836 |
void CSmsProvider::Shutdown(TCloseType aOption)
|
|
837 |
{
|
|
838 |
LOGSMSPROT2("CSmsProvider::Shutdown [aOption=%d]", aOption);
|
|
839 |
|
|
840 |
TInt messagesInBuffer = iRecvBufSegArray->Count();
|
|
841 |
for( TInt index = 0; index < messagesInBuffer; ++index )
|
|
842 |
{
|
|
843 |
// Read message from the socket
|
|
844 |
CSmsMessage*smsmessage=NULL;
|
|
845 |
TRAPD(ret,(smsmessage=InternalizeMessageL(iRecvBufSegArray->At(index))));
|
|
846 |
if( ret == KErrNone )
|
|
847 |
{
|
|
848 |
TRAP(ret, (iProtocol.iReassemblyStore->SetMessagePassedToClientL(*smsmessage, EFalse)));
|
|
849 |
LOGSMSPROT2("-> CSmsProvider::Shutdown - SetMessagePassedToClientL [ret=%d]", ret);
|
|
850 |
}
|
|
851 |
else
|
|
852 |
{
|
|
853 |
LOGSMSPROT2("-> CSmsProvider::Shutdown - CSmsProvider::InternalizeMessageL leave [ret=%d]", ret);
|
|
854 |
}
|
|
855 |
delete smsmessage;
|
|
856 |
}
|
|
857 |
|
|
858 |
if( iEnumSocket && iProtocol.iPhoneEnumerationObserver == this )
|
|
859 |
{
|
|
860 |
iEnumSocket=EFalse;
|
|
861 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
862 |
}
|
|
863 |
if( ObserverAddedToProtocol() )
|
|
864 |
{
|
|
865 |
iProtocol.CancelSendSmsMessage(*this);
|
|
866 |
}
|
|
867 |
if( aOption!=CServProviderBase::EImmediate )
|
|
868 |
{
|
|
869 |
iSocket->CanClose();
|
|
870 |
}
|
|
871 |
}
|
|
872 |
|
|
873 |
/**
|
|
874 |
* Called by the socket server to shutdown a connection. Simply calls
|
|
875 |
* the single parameter version shutdown method.
|
|
876 |
*
|
|
877 |
* Implementation of the pure virtual CServProviderBase::Shutdown().
|
|
878 |
*
|
|
879 |
*/
|
|
880 |
void CSmsProvider::Shutdown(TCloseType aOption, const TDesC8& /*aDisconnectionData*/)
|
|
881 |
{
|
|
882 |
LOGSMSPROT1("CSmsProvider::Shutdown");
|
|
883 |
Shutdown(aOption);
|
|
884 |
}
|
|
885 |
|
|
886 |
/**
|
|
887 |
* Called by the socket server to indicate the provider should choose
|
|
888 |
* a local address and bind to it. Not supported by this protocol.
|
|
889 |
*
|
|
890 |
* Implementation of the pure virtual CServProviderBase::AutoBind().
|
|
891 |
*
|
|
892 |
*/
|
|
893 |
void CSmsProvider::AutoBind()
|
|
894 |
{
|
|
895 |
// Ignore in code coverage - not intended to be used
|
|
896 |
BULLSEYE_OFF
|
|
897 |
LOGSMSPROT1("CSmsProvider::AutoBind [does nothing]");
|
|
898 |
BULLSEYE_RESTORE
|
|
899 |
}
|
|
900 |
|
|
901 |
/**
|
|
902 |
* Called by the SMS protocol to obtain the local address of this SAP.
|
|
903 |
*
|
|
904 |
* @return the local address of this SAP.
|
|
905 |
*
|
|
906 |
*/
|
|
907 |
const TSmsAddr& CSmsProvider::GetLocalAddress() const
|
|
908 |
{
|
|
909 |
LOGSMSPROT1("CSmsProvider::GetLocalAddress");
|
|
910 |
return iLocalAddress;
|
|
911 |
}
|
|
912 |
|
|
913 |
/**
|
|
914 |
* Called by the SMS protocol to bind a local address to this SAP.
|
|
915 |
*
|
|
916 |
*/
|
|
917 |
void CSmsProvider::SetLocalAddress(const TSmsAddr& aSmsAddr)
|
|
918 |
{
|
|
919 |
LOGSMSPROT1("CSmsProvider::SetLocalAddress");
|
|
920 |
iLocalAddress = aSmsAddr;
|
|
921 |
}
|
|
922 |
|
|
923 |
/**
|
|
924 |
* Called by the protocol when the modem connection state has changed.
|
|
925 |
* Notifies any standard KIoctlSelect requests of this event.
|
|
926 |
*
|
|
927 |
* @param aStatus either KIoctlSelectModemPresent or KIoctlSelectModemNotPresent.
|
|
928 |
*
|
|
929 |
*/
|
|
930 |
void CSmsProvider::ModemNotificationCompleted(TInt aStatus)
|
|
931 |
{
|
|
932 |
LOGSMSPROT2("CSmsProvider::ModemNotificationCompleted [aStatus=%d]", aStatus);
|
|
933 |
|
|
934 |
if( !IoctlOutstanding() )
|
|
935 |
{
|
|
936 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
937 |
}
|
|
938 |
}
|
|
939 |
|
|
940 |
/**
|
|
941 |
* Called by the protocol when a message send request made by this
|
|
942 |
* SAP has completed.
|
|
943 |
*
|
|
944 |
* @param aStatus the result of the send.
|
|
945 |
*
|
|
946 |
*/
|
|
947 |
void CSmsProvider::MessageSendCompleted(TInt aStatus)
|
|
948 |
{
|
|
949 |
LOGSMSPROT2("CSmsProvider::MessageSendCompleted [aStatus=%d]", aStatus);
|
|
950 |
|
|
951 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
952 |
SetIoctlOutstanding(EFalse);
|
|
953 |
}
|
|
954 |
|
|
955 |
/**
|
|
956 |
* Called by the protocol when a message has been received for this SAP.
|
|
957 |
*
|
|
958 |
* @param aSmsMessage the received message.
|
|
959 |
* @return KErrNone if the message was serialized to the receive buffer successfully.
|
|
960 |
*
|
|
961 |
*/
|
|
962 |
TInt CSmsProvider::MessageReceived(const CSmsMessage& aSmsMessage,TDes& /*aDes*/)
|
|
963 |
{
|
|
964 |
LOGSMSPROT1("CSmsProvider::MessageReceived");
|
|
965 |
|
|
966 |
// Attempt to serial the message to the receive buffer & notify
|
|
967 |
// the socket of the new data
|
|
968 |
TInt numnewsegments=0;
|
|
969 |
TRAPD(ret,(numnewsegments=ExternalizeMessageL(aSmsMessage,ETrue)));
|
|
970 |
if( ret==KErrNone )
|
|
971 |
{
|
|
972 |
iSocket->NewData(numnewsegments);
|
|
973 |
}
|
|
974 |
return ret;
|
|
975 |
}
|
|
976 |
|
|
977 |
/**
|
|
978 |
* Informs protocol whether client confirms received message
|
|
979 |
*/
|
|
980 |
TBool CSmsProvider::ClientConfirmsMessage() const
|
|
981 |
{
|
|
982 |
LOGSMSPROT1("CSmsProvider::ClientConfirmsMessage");
|
|
983 |
|
|
984 |
return ETrue;
|
|
985 |
}
|
|
986 |
|
|
987 |
/**
|
|
988 |
* Informs protocol whether address is ued by the observer
|
|
989 |
*/
|
|
990 |
TInt CSmsProvider::SmsAddrIsDuplicate(const MSmsMessageObserver* aObserver, const TSmsAddr& aAddr) const
|
|
991 |
{
|
|
992 |
LOGSMSPROT1("CSmsProvider::SmsAddrIsDuplicate");
|
|
993 |
|
|
994 |
if( this == aObserver )
|
|
995 |
{
|
|
996 |
return EFalse;
|
|
997 |
}
|
|
998 |
return iLocalAddress==aAddr;
|
|
999 |
}
|
|
1000 |
|
|
1001 |
/**
|
|
1002 |
* Called by the protocol when an enumeration of the phone's message stores
|
|
1003 |
* requested by this SAP has completed.
|
|
1004 |
*
|
|
1005 |
* @param aStatus the result of the enumeration.
|
|
1006 |
*
|
|
1007 |
*/
|
|
1008 |
void CSmsProvider::EnumeratePhoneCompleted(TInt aStatus)
|
|
1009 |
{
|
|
1010 |
LOGSMSPROT2("CSmsProvider::EnumeratePhoneCompleted [aStatus=%d]", aStatus);
|
|
1011 |
|
|
1012 |
// Attempt to serialize all enumerated messages to the receive buffer
|
|
1013 |
TInt numnewsegments=0;
|
|
1014 |
TInt count=0;
|
|
1015 |
if( aStatus==KErrNone )
|
|
1016 |
{
|
|
1017 |
// Save current message count in case we need to rollback on error
|
|
1018 |
TInt nummessages=iRecvBufSegArray->Count();
|
|
1019 |
TRAP(aStatus, (numnewsegments=ExternalizeEnumeratedMessagesL(count)));
|
|
1020 |
if( aStatus==KErrNone )
|
|
1021 |
{
|
|
1022 |
// Success, obtain the message count and notify socket of the new data
|
|
1023 |
if( numnewsegments>0 )
|
|
1024 |
{
|
|
1025 |
iSocket->NewData(numnewsegments);
|
|
1026 |
}
|
|
1027 |
}
|
|
1028 |
else
|
|
1029 |
{
|
|
1030 |
// Error, rollback the messages we added
|
|
1031 |
for( TInt i=(iRecvBufSegArray->Count()-nummessages)-1; i>=0; i-- )
|
|
1032 |
{
|
|
1033 |
delete iRecvBufSegArray->At(i);
|
|
1034 |
iRecvBufSegArray->Delete(i);
|
|
1035 |
}
|
|
1036 |
}
|
|
1037 |
}
|
|
1038 |
// On success, complete with the count of messages enumerated
|
|
1039 |
if( aStatus==KErrNone )
|
|
1040 |
{
|
|
1041 |
TPckgBuf<TInt> buf;
|
|
1042 |
buf()=count;
|
|
1043 |
if( count>0 )
|
|
1044 |
{
|
|
1045 |
iEnumSocket=ETrue;
|
|
1046 |
}
|
|
1047 |
else
|
|
1048 |
{
|
|
1049 |
iEnumSocket=EFalse;
|
|
1050 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
1051 |
}
|
|
1052 |
iNumOfEnumeratedMessages=count;
|
|
1053 |
iSocket->IoctlComplete(&buf);
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
iEnumSocket=EFalse;
|
|
1058 |
if( iProtocol.iPhoneEnumerationObserver == this)
|
|
1059 |
{
|
|
1060 |
iProtocol.iPhoneEnumerationObserver=NULL;
|
|
1061 |
}
|
|
1062 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
1063 |
}
|
|
1064 |
SetIoctlOutstanding(EFalse);
|
|
1065 |
}
|
|
1066 |
|
|
1067 |
/**
|
|
1068 |
* Called by the protocol when a request to write a message to
|
|
1069 |
* a phone store by this SAP has completed.
|
|
1070 |
* Implements the pure virtual MSmsMessageObserver::MessageWriteCompleted().
|
|
1071 |
*
|
|
1072 |
* @param aStatus the result of the write operation.
|
|
1073 |
*
|
|
1074 |
*/
|
|
1075 |
void CSmsProvider::MessageWriteCompleted(TInt aStatus, const CSmsMessage* aSmsMessage)
|
|
1076 |
{
|
|
1077 |
LOGSMSPROT2("CSmsProvider::MessageWriteCompleted [aStatus=%d]", aStatus);
|
|
1078 |
|
|
1079 |
// If no errors at present populate the buffer
|
|
1080 |
if( aStatus == KErrNone )
|
|
1081 |
{
|
|
1082 |
TRAP(aStatus, (PopulateBufferWithPDUSlotsL(*aSmsMessage)));
|
|
1083 |
}
|
|
1084 |
if( aStatus != KErrNone )
|
|
1085 |
{
|
|
1086 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
1087 |
}
|
|
1088 |
SetIoctlOutstanding(EFalse);
|
|
1089 |
} // CSmsProvider::MessageWriteCompleted
|
|
1090 |
|
|
1091 |
|
|
1092 |
/**
|
|
1093 |
* Create and populate a buffer containing store type and PDU slot indexes
|
|
1094 |
*
|
|
1095 |
* @param aSmsMessage the message containing the slot information.
|
|
1096 |
*
|
|
1097 |
*/
|
|
1098 |
void CSmsProvider::PopulateBufferWithPDUSlotsL(const CSmsMessage& aSmsMessage)
|
|
1099 |
{
|
|
1100 |
LOGSMSPROT1("CSmsProvider::PopulateBufferWithPDUSlotsL");
|
|
1101 |
|
|
1102 |
// Create buffer for store id and PDU slot indexes based on size of slot array
|
|
1103 |
|
|
1104 |
HBufC8* buf = HBufC8::NewL(aSmsMessage.iSlotArray.Count()+1 * sizeof(TUint));
|
|
1105 |
buf->Des().Append(aSmsMessage.Storage());
|
|
1106 |
|
|
1107 |
TInt count = aSmsMessage.iSlotArray.Count();
|
|
1108 |
for( TInt index=0; index<count; ++index )
|
|
1109 |
{
|
|
1110 |
buf->Des().Append(aSmsMessage.iSlotArray[index].iIndex);
|
|
1111 |
}
|
|
1112 |
|
|
1113 |
TPtr8 textBufPtr(buf->Des());
|
|
1114 |
|
|
1115 |
iSocket->IoctlComplete(&textBufPtr);
|
|
1116 |
delete buf;
|
|
1117 |
|
|
1118 |
LOGSMSPROT1("-> CSmsProvider::PopulateBufferWithPDUSlotsL - done");
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
/**
|
|
1122 |
* Called by the protocol when a request to delete a message from
|
|
1123 |
* a phone store by this SAP has completed.
|
|
1124 |
* Implements the pure virtual MSmsMessageObserver::MessageDeleteCompleted().
|
|
1125 |
*
|
|
1126 |
* @param aStatus the result of the deletion.
|
|
1127 |
*
|
|
1128 |
*/
|
|
1129 |
void CSmsProvider::MessageDeleteCompleted(TInt aStatus)
|
|
1130 |
{
|
|
1131 |
LOGSMSPROT2("CSmsProvider::MessageDeleteCompleted [aStatus=%d]", aStatus);
|
|
1132 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
1133 |
SetIoctlOutstanding(EFalse);
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
/**
|
|
1137 |
* Called by the CSmsReadParams object when a read all SMS parameter sets
|
|
1138 |
* requested by this SAP has completed.
|
|
1139 |
*
|
|
1140 |
* @param aStatus the result of the read operation.
|
|
1141 |
* @param aSmspList SMS parameter list
|
|
1142 |
*
|
|
1143 |
*/
|
|
1144 |
void CSmsProvider::ReadSmsParamsCompleted(TInt aStatus, CMobilePhoneSmspList* aSmspList)
|
|
1145 |
{
|
|
1146 |
LOGSMSPROT2("CSmsProvider::ReadSmsParamsCompleted [aStatus=%d]", aStatus);
|
|
1147 |
|
|
1148 |
TInt numNewSegments=0;
|
|
1149 |
|
|
1150 |
if( aStatus == KErrNone )
|
|
1151 |
{
|
|
1152 |
// Attempt to serial the parameters to the receive buffer & notify
|
|
1153 |
// the socket of the new data
|
|
1154 |
__ASSERT_DEBUG(aSmspList != NULL,SmspPanic(KSmspPanicParameterBufferNull));
|
|
1155 |
TRAP(aStatus,(numNewSegments=ExternalizeParametersL(*aSmspList)));
|
|
1156 |
}
|
|
1157 |
if( aStatus == KErrNone )
|
|
1158 |
{
|
|
1159 |
iSocket->NewData(numNewSegments);
|
|
1160 |
TPckgBuf<TInt> buf;
|
|
1161 |
buf()=1;
|
|
1162 |
iSocket->IoctlComplete(&buf);
|
|
1163 |
}
|
|
1164 |
else
|
|
1165 |
{
|
|
1166 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
1167 |
}
|
|
1168 |
SetIoctlOutstanding(EFalse);
|
|
1169 |
}
|
|
1170 |
|
|
1171 |
/**
|
|
1172 |
* Called by the CSmsWriteParams object when a request to write SMS
|
|
1173 |
* parameters to a phone store by this SAP has completed.
|
|
1174 |
*
|
|
1175 |
* @param aStatus the result of the write operation.
|
|
1176 |
*
|
|
1177 |
*/
|
|
1178 |
void CSmsProvider::WriteSmsParamsCompleted(TInt aStatus)
|
|
1179 |
{
|
|
1180 |
LOGSMSPROT2("CSmsProvider::WriteSmsParamsCompleted [aStatus=%d]", aStatus);
|
|
1181 |
iSocket->Error(aStatus,MSocketNotify::EErrorIoctl);
|
|
1182 |
SetIoctlOutstanding(EFalse);
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
/**
|
|
1186 |
* Internal function called after a phone store enumeration request to
|
|
1187 |
* serialize the messages to the receive buffer.
|
|
1188 |
*
|
|
1189 |
* @leave Leaves if any individual ExternalizeMessageL() call leaves.
|
|
1190 |
* @return the total number of segments the messages were split into.
|
|
1191 |
*
|
|
1192 |
*/
|
|
1193 |
TInt CSmsProvider::ExternalizeEnumeratedMessagesL(TInt& aCount)
|
|
1194 |
{
|
|
1195 |
LOGSMSPROT1("CSmsProvider::ExternalizeEnumeratedMessagesL");
|
|
1196 |
|
|
1197 |
TInt numnewsegments(0);
|
|
1198 |
numnewsegments=iProtocol.ExternalizeEnumeratedMessagesL(*this,aCount);
|
|
1199 |
|
|
1200 |
LOGSMSPROT1("-> CSmsProvider::ExternalizeEnumeratedMessagesL - done");
|
|
1201 |
|
|
1202 |
return numnewsegments;
|
|
1203 |
}
|
|
1204 |
|
|
1205 |
/**
|
|
1206 |
* Internal function used to serialize a message into the receive buffer.
|
|
1207 |
* Each serialized message is split into smaller segments which form the
|
|
1208 |
* basic unit of data passed back to the socket server in the GetData() method.
|
|
1209 |
*
|
|
1210 |
* @param aSmsMessage the message to serialize.
|
|
1211 |
* @param aAppend specifies whether the message is inserted at the start or end of the buffer.
|
|
1212 |
* @leave Leaves if the message could not be serialized or inserted into the buffer.
|
|
1213 |
* @return the number of segments the message was split into.
|
|
1214 |
*
|
|
1215 |
*/
|
|
1216 |
TInt CSmsProvider::ExternalizeMessageL(const CSmsMessage& aSmsMessage,TBool aAppend)
|
|
1217 |
{
|
|
1218 |
LOGSMSPROT1("CSmsProvider::ExternalizeMessageL()");
|
|
1219 |
|
|
1220 |
// Create a new segmented buffer for the serialization of this message
|
|
1221 |
CBufSeg* recvbufseg = CBufSeg::NewL(KSmsMaxSegmentLength);
|
|
1222 |
CleanupStack::PushL(recvbufseg);
|
|
1223 |
|
|
1224 |
// Attempt to serialize this message into the buffer
|
|
1225 |
RBufWriteStream writestream(*recvbufseg);
|
|
1226 |
writestream.Open(*recvbufseg);
|
|
1227 |
CleanupClosePushL(writestream);
|
|
1228 |
writestream << aSmsMessage;
|
|
1229 |
|
|
1230 |
// Append / insert this buffer at the end / start of the other serialized message buffers
|
|
1231 |
if( aAppend )
|
|
1232 |
{
|
|
1233 |
iRecvBufSegArray->AppendL(recvbufseg);
|
|
1234 |
}
|
|
1235 |
else
|
|
1236 |
{
|
|
1237 |
iRecvBufSegArray->InsertL(0,recvbufseg);
|
|
1238 |
}
|
|
1239 |
CleanupStack::PopAndDestroy(); // writestream
|
|
1240 |
CleanupStack::Pop(); // recvbufseg
|
|
1241 |
|
|
1242 |
LOGSMSPROT1("-> CSmsProvider::ExternalizeMessageL - done");
|
|
1243 |
|
|
1244 |
return NumSegments(recvbufseg->Size());
|
|
1245 |
}
|
|
1246 |
|
|
1247 |
/**
|
|
1248 |
* Internal function to deserialize a message from the send buffer.
|
|
1249 |
* Each serialized message is split into smaller segments which form the basic
|
|
1250 |
* unit of data passed to this SAP from the socket server in the Write() method.
|
|
1251 |
*
|
|
1252 |
* @leave Leaves if the message could not be de-serialized.
|
|
1253 |
* @return the de-serialized CSmsMessage object.
|
|
1254 |
*
|
|
1255 |
*/
|
|
1256 |
CSmsMessage* CSmsProvider::InternalizeMessageL()
|
|
1257 |
{
|
|
1258 |
LOGSMSPROT1("CSmsProvider::InternalizeMessageL()");
|
|
1259 |
|
|
1260 |
// Initialize the read stream with the buffer
|
|
1261 |
RBufReadStream readstream(*iSendBufSeg);
|
|
1262 |
readstream.Open(*iSendBufSeg,0);
|
|
1263 |
CleanupClosePushL(readstream);
|
|
1264 |
|
|
1265 |
// Create a buffer and message to store the result
|
|
1266 |
CSmsBufferBase* buffer = CSmsBuffer::NewL();
|
|
1267 |
CSmsMessage* smsmessage= CSmsMessage::NewL(iProtocol.FileSession(), CSmsPDU::ESmsDeliver,buffer);
|
|
1268 |
CleanupStack::PushL(smsmessage);
|
|
1269 |
|
|
1270 |
// De-serialize the message from using the read stream
|
|
1271 |
readstream >> *smsmessage;
|
|
1272 |
|
|
1273 |
CleanupStack::Pop(); // smsmessage
|
|
1274 |
CleanupStack::PopAndDestroy(); // readstream
|
|
1275 |
iSendBufSeg->Reset();
|
|
1276 |
|
|
1277 |
LOGSMSPROT1("-> CSmsProvider::InternalizeMessageL - done");
|
|
1278 |
|
|
1279 |
return smsmessage;
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
/**
|
|
1283 |
* Internal function used to serialize SMS parameters into the receive buffer.
|
|
1284 |
* Each serialized parameter object is split into smaller segments which form the
|
|
1285 |
* basic unit of data passed back to the socket server in the GetData() method.
|
|
1286 |
*
|
|
1287 |
* @param aMobilePhoneSmspList the parameters to serialize.
|
|
1288 |
* @leave Leaves if the parameters could not be serialized or inserted into the buffer.
|
|
1289 |
* @return the number of segments the parameters was split into.
|
|
1290 |
*
|
|
1291 |
*/
|
|
1292 |
TInt CSmsProvider::ExternalizeParametersL(const CMobilePhoneSmspList& aMobilePhoneSmspList)
|
|
1293 |
{
|
|
1294 |
LOGSMSPROT1("CSmsProvider::ExternalizeParametersL");
|
|
1295 |
|
|
1296 |
// Create a new segmented buffer for the serialization of this message
|
|
1297 |
CBufSeg* recvBufSeg = CBufSeg::NewL(KSmsMaxSegmentLength);
|
|
1298 |
CleanupStack::PushL(recvBufSeg);
|
|
1299 |
|
|
1300 |
// Attempt to serialize this message into the buffer
|
|
1301 |
RBufWriteStream writeStream(*recvBufSeg);
|
|
1302 |
writeStream.Open(*recvBufSeg);
|
|
1303 |
CleanupClosePushL(writeStream);
|
|
1304 |
writeStream << aMobilePhoneSmspList;
|
|
1305 |
writeStream.CommitL();
|
|
1306 |
|
|
1307 |
// Append start of the other serialized message buffers
|
|
1308 |
CleanupStack::PopAndDestroy(); //writeStream
|
|
1309 |
iRecvBufSegArray->InsertL(0,recvBufSeg);
|
|
1310 |
CleanupStack::Pop(recvBufSeg);
|
|
1311 |
|
|
1312 |
LOGSMSPROT1("-> CSmsProvider::ExternalizeParametersL - done");
|
|
1313 |
|
|
1314 |
return NumSegments(recvBufSeg->Size());
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
/**
|
|
1318 |
* Internal function to retrieve a SMS parameters from the send buffer.
|
|
1319 |
* Each serialized object is split into smaller segments which form the basic
|
|
1320 |
* unit of data passed to this SAP from the socket server in the Write() method.
|
|
1321 |
*
|
|
1322 |
* @leave Leaves if the parameters could not retrieved.
|
|
1323 |
* @return the retrieved CMobilePhoneSmspList object.
|
|
1324 |
*
|
|
1325 |
*/
|
|
1326 |
CMobilePhoneSmspList* CSmsProvider::InternalizeParametersL()
|
|
1327 |
{
|
|
1328 |
LOGSMSPROT1("CSmsProvider::InternalizeParametersL");
|
|
1329 |
|
|
1330 |
// Initialize the read stream with the buffer
|
|
1331 |
RBufReadStream readStream(*iSendBufSeg);
|
|
1332 |
readStream.Open(*iSendBufSeg,0);
|
|
1333 |
CleanupClosePushL(readStream);
|
|
1334 |
|
|
1335 |
// Create a parameter object to store the result
|
|
1336 |
CMobilePhoneSmspList* mobilePhoneSmspList = CMobilePhoneSmspList::NewL();
|
|
1337 |
CleanupStack::PushL(mobilePhoneSmspList);
|
|
1338 |
|
|
1339 |
// De-serialize the message from using the read stream
|
|
1340 |
readStream >> *mobilePhoneSmspList;
|
|
1341 |
|
|
1342 |
CleanupStack::Pop(mobilePhoneSmspList);
|
|
1343 |
CleanupStack::PopAndDestroy(); //readStream
|
|
1344 |
iSendBufSeg->Reset();
|
|
1345 |
|
|
1346 |
LOGSMSPROT1("-> CSmsProvider::InternalizeParametersL - done");
|
|
1347 |
|
|
1348 |
return mobilePhoneSmspList;
|
|
1349 |
}
|
|
1350 |
|
|
1351 |
CSmsMessage* CSmsProvider::InternalizeMessageL( CBufSeg* aBufSeg)
|
|
1352 |
{
|
|
1353 |
LOGSMSPROT1("CSmsProvider::InternalizeMessageL");
|
|
1354 |
|
|
1355 |
RBufReadStream readstream(*aBufSeg);
|
|
1356 |
readstream.Open(*aBufSeg,0);
|
|
1357 |
CleanupClosePushL(readstream);
|
|
1358 |
CSmsBufferBase* buffer = CSmsBuffer::NewL();
|
|
1359 |
CSmsMessage* smsmessage= CSmsMessage::NewL(iProtocol.FileSession(),CSmsPDU::ESmsDeliver,buffer);
|
|
1360 |
|
|
1361 |
CleanupStack::PushL(smsmessage);
|
|
1362 |
readstream >> *smsmessage;
|
|
1363 |
|
|
1364 |
CleanupStack::Pop(); // smsmessage
|
|
1365 |
CleanupStack::PopAndDestroy(); // readsream
|
|
1366 |
|
|
1367 |
LOGSMSPROT1("-> CSmsProvider::InternalizeMessageL - done");
|
|
1368 |
|
|
1369 |
return smsmessage;
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
TInt CSmsProvider::SecurityCheck(MProvdSecurityChecker* aSecurityChecker)
|
|
1373 |
{
|
|
1374 |
LOGSMSPROT1("CSmsProvider::SecurityCheck");
|
|
1375 |
iSecurityChecker = aSecurityChecker;
|
|
1376 |
return KErrNone;
|
|
1377 |
}
|