24
|
1 |
// Copyright (c) 1999-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 |
// Declares the CSmsProtocol, CSmsProtocolFamily, CSmsProvider and
|
|
15 |
// other classes used internally by them.
|
|
16 |
// Conditional includes
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
@internalAll
|
|
23 |
*/
|
|
24 |
|
|
25 |
#ifndef SMSPROT_H
|
|
26 |
#define SMSPROT_H
|
|
27 |
|
|
28 |
#include <es_sock.h>
|
|
29 |
#include <es_prot.h>
|
|
30 |
#include <etelmm.h>
|
|
31 |
#include <es_ini.h>
|
|
32 |
#include <mmlist.h>
|
|
33 |
#include <cdblen.h>
|
|
34 |
|
|
35 |
#include "smsuset.h"
|
|
36 |
#include "smsuaddr.H"
|
|
37 |
#include "smspcomm.h"
|
|
38 |
#include "smspproc.h"
|
|
39 |
#include "nbbackuprestoreint.h"
|
|
40 |
|
|
41 |
class CSmsProvider;
|
|
42 |
class CFacadeSmsReassemblyStore;
|
|
43 |
class CSmsSegmentationStore;
|
|
44 |
class CLogWrapper;
|
|
45 |
class CSmsModemNotification;
|
|
46 |
class CSmsPDURead;
|
|
47 |
class CSmsPhoneEnumeration;
|
|
48 |
class CSmsMessageWrite;
|
|
49 |
class CSmsPDUDelete;
|
|
50 |
class CSmsReadParams;
|
|
51 |
class CSmsWriteParams;
|
|
52 |
class CSmspWriteQueue;
|
|
53 |
class CQueuedSmsMessage;
|
|
54 |
class CSmspDeleteQueue;
|
|
55 |
class CSmspSendQueue;
|
|
56 |
class CSmsPhoneInitialization;
|
|
57 |
class CSmsProtocolBootTimer;
|
|
58 |
class CBackupAndRestore;
|
|
59 |
class CSmspSetBearer;
|
|
60 |
|
|
61 |
/**
|
|
62 |
* CProtocolFamilyBase derived class which identifies the protocols
|
|
63 |
* we can create, and provides an overidden factory method for
|
|
64 |
* creating them.
|
|
65 |
* @internalComponent
|
|
66 |
*/
|
|
67 |
class CSmsProtocolFamily : public CProtocolFamilyBase
|
|
68 |
{
|
|
69 |
public:
|
|
70 |
static CSmsProtocolFamily * NewL();
|
|
71 |
TInt Install();
|
|
72 |
TInt Remove();
|
|
73 |
CProtocolBase * NewProtocolL(TUint aSockType,TUint aProtocol);
|
|
74 |
TUint ProtocolList(TServerProtocolDesc *& aProtocolList);
|
|
75 |
private:
|
|
76 |
CSmsProtocolFamily();
|
|
77 |
};
|
|
78 |
|
|
79 |
/**
|
|
80 |
* @internalComponent
|
|
81 |
*/
|
|
82 |
IMPORT_C CProtocolFamilyBase* InstallSMS(); // Force export
|
|
83 |
|
|
84 |
/**
|
|
85 |
* The main class for this protocol which handles requests
|
|
86 |
* from clients contending for services from the phone.
|
|
87 |
* @internalComponent
|
|
88 |
*/
|
|
89 |
class CSmsProtocol : public CProtocolBase,
|
|
90 |
public MSmsComm,
|
|
91 |
public MNBBackupAndRestoreObserver
|
|
92 |
{
|
|
93 |
friend class CSmsProvider;
|
|
94 |
|
|
95 |
public:
|
|
96 |
static CSmsProtocol *NewL();
|
|
97 |
virtual ~CSmsProtocol();
|
|
98 |
|
|
99 |
// Calls from the socket server which we implement
|
|
100 |
CServProviderBase *NewSAPL(TUint aSocketType);
|
|
101 |
void InitL(TDesC& aTag);
|
|
102 |
void StartL(void);
|
|
103 |
void Identify(TServerProtocolDesc *)const;
|
|
104 |
|
|
105 |
// Calls from the socket server which we don't implement
|
|
106 |
virtual CHostResolvProvdBase *NewHostResolverL();
|
|
107 |
virtual CServiceResolvProvdBase *NewServiceResolverL();
|
|
108 |
virtual CNetDBProvdBase* NewNetDatabaseL();
|
|
109 |
|
|
110 |
// Calls from the socket server and other protocols which we just panic
|
|
111 |
void BindL(CProtocolBase *aProtocol, TUint aId);
|
|
112 |
virtual void BindToL(CProtocolBase *aProtocol);
|
|
113 |
TInt Send(TDes8& aDes, TSockAddr *aTo,TSockAddr *aFrom,CProtocolBase* aSourceProtocol);
|
|
114 |
void Process(TDes8& aDes,TSockAddr *aFrom,TSockAddr *to,CProtocolBase* aSourceProtocol);
|
|
115 |
TInt GetOption(TUint aLevel,TUint aName,TDes8 &aOption,CProtocolBase* aSourceProtocol);
|
|
116 |
TInt SetOption(TUint aLevel,TUint aName,const TDesC8& aOption,CProtocolBase* aSourceProtocol);
|
|
117 |
void Error(TInt aError,CProtocolBase* aSourceProtocol);
|
|
118 |
|
|
119 |
// Functions called for WAP binding or for SAP creation
|
|
120 |
virtual void AddSmsMessageObserverL(MSmsMessageObserver& aObserver);
|
|
121 |
virtual TInt BindSmsMessageObserver(MSmsMessageObserver& aObserver,const TSmsAddr& aSmsAddr);
|
|
122 |
virtual void RemoveSmsMessageObserver(const MSmsMessageObserver& aObserver);
|
|
123 |
virtual TBool SmsAddrIsAlreadyUsed(const MSmsMessageObserver* aObserver,const TSmsAddr& aSmsAddr)const;
|
|
124 |
|
|
125 |
// Functions called by SAPs (e.g. WAPPROT)
|
|
126 |
virtual void SendSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver,TUint aOptions);
|
|
127 |
virtual void CancelSendSmsMessage(MSmsMessageObserver& aObserver,TBool aCancelInternally=ETrue);
|
|
128 |
virtual void EnumeratePhone(MSmsMessageObserver& aObserver);
|
|
129 |
virtual void CancelEnumeratePhone(MSmsMessageObserver& aObserver);
|
|
130 |
|
|
131 |
void WriteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver);
|
|
132 |
void CancelWriteSmsMessage(MSmsMessageObserver& aObserver);
|
|
133 |
|
|
134 |
virtual void DeleteSmsMessage(CSmsMessage* aSmsMessage,MSmsMessageObserver& aObserver);
|
|
135 |
virtual void CancelDeleteSmsMessage(MSmsMessageObserver& aObserver);
|
|
136 |
virtual void ReadSmsParameters(MSmsMessageObserver& aObserver);
|
|
137 |
virtual void CancelReadSmsParams();
|
|
138 |
virtual void WriteSmsParameters(CMobilePhoneSmspList* aMobilePhoneSmspList, MSmsMessageObserver& aObserver);
|
|
139 |
virtual void CancelWriteSmsParams();
|
|
140 |
|
|
141 |
// MSmsComm Notifications used by active objects
|
|
142 |
TInt ProcessMessageL(const CSmsMessage& aSmsMessage,const TSmsAddr* aOriginalSmsAddr,const CSmsMessage* aOriginalSmsMessage,TDes& aDes);
|
|
143 |
void DeletePDUs(const CArrayFix<TGsmSmsSlotEntry>& aSlotArray, MSmsMessageObserver* aObserver);
|
|
144 |
void ModemNotificationCompleted(TInt aStatus,RPhone::TModemDetection aNewState);
|
|
145 |
void DiskSpaceMonitorStateChange(TSmsDiskSpaceMonitorStatus aStatus);
|
|
146 |
void MessageSendCompleted(TInt aStatus);
|
|
147 |
void PhoneEnumerationCompleted(TInt aStatus);
|
|
148 |
|
|
149 |
inline RFs& FileSession();
|
|
150 |
inline virtual TBool ObserverIsPresent(const MSmsMessageObserver& aObserver) const;
|
|
151 |
const RMobilePhone::TMobilePhoneNetworkInfoV1& NetworkInfo() const;
|
|
152 |
TBool NetworkInfoAvailable() const;
|
|
153 |
// new function which deletes msg from the reassemblystore
|
|
154 |
// by passing them the smsmessage class
|
|
155 |
void DeleteSMSFromReaStoreL(const CSmsMessage& aSmsMessage);
|
|
156 |
void MessageReadedSuccessfully();
|
|
157 |
TBool AllocateLocalAddress(TSmsAddr& aAddr);
|
|
158 |
TInt ExternalizeEnumeratedMessagesL(CSmsProvider& aProvider,TInt& aCount);
|
|
159 |
static TBool IsAppPortSMS(const CSmsMessage& aSmsMessage);
|
|
160 |
|
|
161 |
protected:
|
|
162 |
void CloseNow();
|
|
163 |
|
|
164 |
private:
|
|
165 |
CSmsProtocol();
|
|
166 |
|
|
167 |
TInt ObserverIndex(const MSmsMessageObserver& aObserver) const;
|
|
168 |
void OrderSmsMessageObserver(const MSmsMessageObserver& aObserver);
|
|
169 |
|
|
170 |
MSmsMessageObserver* MatchSmsAddressToObserver(const TSmsAddr& aAddr);
|
|
171 |
MSmsMessageObserver* MatchSmsMessageToObserver(const CSmsMessage& aSmsMessage);
|
|
172 |
static TBool IsMatch(const TSmsAddr& aSmsAddr, const CSmsMessage& aSmsMessage);
|
|
173 |
static TBool MatchInformationElement(const CSmsMessage& aSmsMessage, CSmsInformationElement::TSmsInformationElementIdentifier aIeVal);
|
|
174 |
void MatchCompleteSmsMessagesToObserverL(MSmsMessageObserver& aObserver,CArrayFix<TInt>& aIndexArray);
|
|
175 |
static TBool MatchApplicationPort(const CSmsMessage& aSmsMessage,TUint aPort,TBool a16Bit);
|
|
176 |
|
|
177 |
void NotifyMessageObservers(TInt aStatus);
|
|
178 |
|
|
179 |
TBool IsWapSMS(const CSmsMessage& smsmessage );
|
|
180 |
|
|
181 |
inline TBool ClosingDown() const;
|
|
182 |
inline void SetClosingDown(TBool aClosingDown);
|
|
183 |
void CloseNowWrap();
|
|
184 |
|
|
185 |
void PowerUp(); // Handles modem turning on or backup finishing
|
|
186 |
void DoPowerUpL();
|
|
187 |
void PowerDown(); // Handles modem turning off or backup starting
|
|
188 |
void ProcessCompleteSmsMessagesL();
|
|
189 |
TInt CheckPoweredUp() const;
|
|
190 |
virtual void HandleBackupOrRestoreStartingL();
|
|
191 |
virtual void HandleBackupOrRestoreCompleteL();
|
|
192 |
void ReadConfigurableSettingsL(); // from smswap.sms.esk -> [customTimeoutSettings]
|
|
193 |
|
|
194 |
private:
|
|
195 |
///< Enumerated flag values for states of the protocol
|
|
196 |
enum TSmsProtocolFlags
|
|
197 |
{
|
|
198 |
ESmsProtocolClosingDown=0x01 ///< In the process of shutting down
|
|
199 |
};
|
|
200 |
enum
|
|
201 |
{
|
|
202 |
KNumSARStoreAccessesBeforePurging=8 ///< Number of accesses to the segmentation & reassembly stores before purging
|
|
203 |
};
|
|
204 |
|
|
205 |
enum TSmsProtocolState
|
|
206 |
{
|
|
207 |
EPoweredDown, ///< SmsProt is not initialised and the phone is not swiched on
|
|
208 |
EPoweredUp ///< SmsProt is powered up, phone switched on, ready for action
|
|
209 |
} iState;
|
|
210 |
|
|
211 |
private:
|
|
212 |
CArrayPtrFlat<MSmsMessageObserver> iSmsMessageObserverList; ///< List of current observers
|
|
213 |
|
|
214 |
RTelServer iTelServer; ///< A session with the telephony server
|
|
215 |
TBuf<KCommsDbSvrMaxFieldLength> iGsmTsyName; ///< Name of the TSY
|
|
216 |
RMobilePhone iGsmPhone; ///< ETEL phone subsession for intialisation and detection events
|
|
217 |
RMobilePhone iEnumerationPhone; ///< ETEL phone subsession for enumerating the phone
|
|
218 |
RMobilePhone iWritePhone; ///< ETEL phone subsession for writing messages
|
|
219 |
RMobileSmsMessaging iSmsMessaging; ///< ETEL phone subsession for advanced messaging services
|
|
220 |
|
|
221 |
TSmsSettings iSmsSettings; ///< Global SMS Protocol settings
|
|
222 |
RMobileSmsMessaging::TMobileSmsCapsV1 iMobileSmsCaps; // SMS messaging capabilities of the phone
|
|
223 |
|
|
224 |
TInt iFlags; ///< Flags indicating current state of the protocol
|
|
225 |
|
|
226 |
RFs iFs; ///< A session with the file server
|
|
227 |
CFacadeSmsReassemblyStore* iReassemblyStore; ///< Pointer to the reassembly store
|
|
228 |
TInt iNumReassemblyStoreAccesses; ///< Counter for number of accesses to the reassembly store
|
|
229 |
CSmsSegmentationStore* iSegmentationStore; ///< Pointer to the segmentation store
|
|
230 |
TInt iNumSegmentationStoreAccesses; ///< Counter for number of accesses to the segmentation store
|
|
231 |
CSmsModemNotification* iSmsModemNotification; ///< Pointer to object for handling modem detection events
|
|
232 |
RPhone::TModemDetection iModemDetection; ///< The current modem detection state
|
|
233 |
|
|
234 |
|
|
235 |
CSmsPDURead* iSmsPDURead; ///< Pointer to object for receiving SMS PDUs from ETEL
|
|
236 |
|
|
237 |
CSmsMonitorDiskSpace* iSmsMonitorDiskSpace; ///< Pointer to object for monitoring of disk space
|
|
238 |
|
|
239 |
MSmsMessageObserver* iPhoneEnumerationObserver; ///< Pointer to the observer of any current enumeration
|
|
240 |
CSmsPhoneEnumeration* iSmsPhoneEnumeration; ///< Pointer to object for enumerating messages on the phone
|
|
241 |
|
|
242 |
CSmspSendQueue* iSendQueue; ///< Queue of messages to send
|
|
243 |
CSmspWriteQueue* iWriteQueue; ///< Pointer to object for writing messages to the phone
|
|
244 |
CSmspDeleteQueue* iDeleteQueue; ///< Queue of PDUs to delete
|
|
245 |
|
|
246 |
CSmsReadParams* iSmsReadParams; ///< Pointer to object for reading SMS parameters
|
|
247 |
CSmsWriteParams* iSmsWriteParams; ///< Pointer to object for writing SMS parameters
|
|
248 |
|
|
249 |
CSmsPhoneInitialization* iSmsPhoneInitialization;
|
|
250 |
CBackupAndRestore* iBackupRestoreSession;
|
|
251 |
CSmspSetBearer* iSetBearer; ///< Pointer to bearer object, used by message sender but cancelled from protocol
|
|
252 |
CSmspReceiveMode* iReceiveMode; ///< Pointer to receive mode object, used by PDU reader but cancelled from protocol
|
|
253 |
|
|
254 |
TInt iNext8BitPort;
|
|
255 |
TInt iNext16BitPort;
|
|
256 |
CSmsProtocolBootTimer* iBootTimer; ///< Pointer to the CSmsProtocolBootTimer object
|
|
257 |
};
|
|
258 |
|
|
259 |
/**
|
|
260 |
* A CServProviderBase derived class providing service access points to the
|
|
261 |
* SMS Protocol.
|
|
262 |
* @internalComponent
|
|
263 |
*/
|
|
264 |
class CSmsProvider : public CServProviderBase, public MSmsMessageObserver
|
|
265 |
{
|
|
266 |
public:
|
|
267 |
static CSmsProvider* NewL(CSmsProtocol& aProtocol);
|
|
268 |
virtual ~CSmsProvider();
|
|
269 |
public:
|
|
270 |
// pure virtuals from CServProviderBase
|
|
271 |
void Start();
|
|
272 |
void LocalName(TSockAddr& aAddr) const;
|
|
273 |
TInt SetLocalName(TSockAddr& aAddr);
|
|
274 |
void RemName(TSockAddr& aAddr) const;
|
|
275 |
TInt SetRemName(TSockAddr& aAddr);
|
|
276 |
TInt GetOption(TUint aLevel,TUint aName,TDes8& aOption) const;
|
|
277 |
void Ioctl(TUint aLevel,TUint aName,TDes8* aOption);
|
|
278 |
void CancelIoctl(TUint aLevel,TUint aName);
|
|
279 |
TInt SetOption(TUint aLevel,TUint aName,const TDesC8 &aOption);
|
|
280 |
TInt Write(RMBufChain& aBufChain, TUint aOptions, TSockAddr* aAddr=NULL);
|
|
281 |
TInt GetData(RMBufChain& aBufChain, TUint aLength, TUint aOptions, TSockAddr* aAddr=NULL);
|
|
282 |
void ActiveOpen();
|
|
283 |
void ActiveOpen(const TDesC8& aConnectionData);
|
|
284 |
TInt PassiveOpen(TUint aQueSize);
|
|
285 |
TInt PassiveOpen(TUint aQueSize,const TDesC8& aConnectionData);
|
|
286 |
void Shutdown(TCloseType aOption);
|
|
287 |
void Shutdown(TCloseType aOption,const TDesC8& aDisconnectionData);
|
|
288 |
void AutoBind();
|
|
289 |
|
|
290 |
// From MSmsMessageObserver
|
|
291 |
const TSmsAddr& GetLocalAddress() const;
|
|
292 |
void SetLocalAddress(const TSmsAddr& aSmsAddr);
|
|
293 |
void ModemNotificationCompleted(TInt aStatus);
|
|
294 |
void MessageSendCompleted(TInt aStatus); // aStatus is EPOC error or -(KFailureCauseOffset+failurecause)
|
|
295 |
TInt MessageReceived(const CSmsMessage& aSmsMessage,TDes& aDes); // must return EPOC error or -(KFailureCauseOffset+failurecause)
|
|
296 |
void EnumeratePhoneCompleted(TInt aStatus);
|
|
297 |
void MessageWriteCompleted(TInt aStatus, const CSmsMessage* aSmsMessage = NULL);
|
|
298 |
void MessageDeleteCompleted(TInt aStatus);
|
|
299 |
void ReadSmsParamsCompleted(TInt aStatus,CMobilePhoneSmspList* aSmspList);
|
|
300 |
void WriteSmsParamsCompleted(TInt aStatus);
|
|
301 |
virtual TBool ClientConfirmsMessage()const;
|
|
302 |
virtual TBool SmsAddrIsDuplicate(const MSmsMessageObserver* aObserver,const TSmsAddr& aAddr)const;
|
|
303 |
TInt ExternalizeEnumeratedMessagesL(TInt& aCount);
|
|
304 |
TInt ExternalizeMessageL(const CSmsMessage& aSmsMessage,TBool aAppend);
|
|
305 |
|
|
306 |
protected:
|
|
307 |
CSmsProvider(CSmsProtocol& aProtocol);
|
|
308 |
virtual TInt SecurityCheck(MProvdSecurityChecker* aSecurityChecker);
|
|
309 |
void ConstructL();
|
|
310 |
|
|
311 |
private:
|
|
312 |
TInt DoMessageReceivedL(const CSmsMessage& aSmsMessage);
|
|
313 |
inline static TInt NumSegments(TInt aSize);
|
|
314 |
void DoWriteL(const TDesC8& aData,TUint aOptions);
|
|
315 |
TInt ExternalizeEnumeratedMesagesL(TInt& aCount);
|
|
316 |
CSmsMessage* InternalizeMessageL();
|
|
317 |
TInt ExternalizeParametersL(const CMobilePhoneSmspList& aMobilePhoneSmspList);
|
|
318 |
CMobilePhoneSmspList* InternalizeParametersL();
|
|
319 |
|
|
320 |
inline TBool ObserverAddedToProtocol() const;
|
|
321 |
inline void SetObserverAddedToProtocol(TBool aAdded);
|
|
322 |
inline TBool IoctlOutstanding() const;
|
|
323 |
inline void SetIoctlOutstanding(TBool aOutstanding);
|
|
324 |
CSmsMessage* InternalizeMessageL( CBufSeg* aBufSeg);
|
|
325 |
void PopulateBufferWithPDUSlotsL(const CSmsMessage& aSmsMessage);
|
|
326 |
|
|
327 |
private:
|
|
328 |
///< Enumerated flag values for current of the provider
|
|
329 |
enum TSmsProviderFlags
|
|
330 |
{
|
|
331 |
ESmsProviderObserverAddedToProtocol=0x01, ///< Registered as observer of the protocol
|
|
332 |
ESmsProviderIoctlOutstanding=0x02 ///< Special SMS ioctl is outstanding
|
|
333 |
};
|
|
334 |
|
|
335 |
private:
|
|
336 |
CSmsProtocol& iProtocol; ///< Reference to the SMS Protocol object
|
|
337 |
TSmsAddr iLocalAddress; ///< The local address of the access point
|
|
338 |
TInt iFlags; ///< Flags indicating current state of the provider
|
|
339 |
CArrayPtr<CBufSeg>* iRecvBufSegArray; ///< Array of serialized SMS messages to be read from the socket
|
|
340 |
TInt iSegmentIndex; ///< Index of next segment of current SMS message to read
|
|
341 |
CBufSeg* iSendBufSeg; ///< SMS message segments written to the socket
|
|
342 |
TUint iName; ///< The integer "name" of the current ioctl request
|
|
343 |
TBool iEnumSocket; ///< this is enumeration client
|
|
344 |
TInt iNumOfEnumeratedMessages; ///< number of enumerated segments
|
|
345 |
MProvdSecurityChecker* iSecurityChecker; ///< ESOCK security checker object
|
|
346 |
};
|
|
347 |
|
|
348 |
#include "smsprot.inl"
|
|
349 |
|
|
350 |
/**
|
|
351 |
* @internalComponent
|
|
352 |
*/
|
|
353 |
class CSmsProtocolBootTimer : public CTimer
|
|
354 |
{
|
|
355 |
public:
|
|
356 |
static CSmsProtocolBootTimer* NewL(CSmsProtocol& aSmsProtocol);
|
|
357 |
virtual ~CSmsProtocolBootTimer();
|
|
358 |
|
|
359 |
void Start(const TTimeIntervalMicroSeconds32& aTimeIntervalMicroSeconds32);
|
|
360 |
|
|
361 |
private:
|
|
362 |
CSmsProtocolBootTimer(CSmsProtocol& aSmsProtocol);
|
|
363 |
virtual void RunL();
|
|
364 |
|
|
365 |
protected:
|
|
366 |
CSmsProtocol& iSmsProtocol; ///< reference to owner CSmsProtocol object
|
|
367 |
};
|
|
368 |
|
|
369 |
#endif // SMSPROT_H
|