|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalAll |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef __SIMSMSMESS_H_ |
|
23 #define __SIMSMSMESS_H_ |
|
24 |
|
25 #include <etelmm.h> |
|
26 #include <et_phone.h> |
|
27 |
|
28 #include "CSimPhone.h" |
|
29 #include "csimtimer.h" |
|
30 |
|
31 #include "CSimSmsStore.h" |
|
32 #include "utils.h" |
|
33 |
|
34 const TUint KMaxSmsPduLength=168; |
|
35 typedef TBuf8<KMaxSmsPduLength> TSmsPdu; |
|
36 |
|
37 const TUint KMaxSmsScaLength=100; |
|
38 typedef TBuf8<KMaxSmsScaLength> TSmsSca; |
|
39 |
|
40 const TUint KMaxSmsDestinationLength=50; |
|
41 typedef TBuf8<KMaxSmsDestinationLength> TSmsDestination; |
|
42 |
|
43 const TUint KMaxSmsExpectedErrorLength=10; |
|
44 typedef TBuf8<KMaxSmsExpectedErrorLength> TSmsExpectedError; |
|
45 |
|
46 |
|
47 struct TSmsTxParametersGsm |
|
48 { |
|
49 TInt iFlags; |
|
50 RMobileSmsMessaging::TMobileSmsGsmTpdu iPdu; |
|
51 TSmsSca iSca; |
|
52 TInt iRef; |
|
53 RMobileSmsMessaging::TMobileSmsGsmTpdu iSubmitReport; |
|
54 TInt iExpectedError; |
|
55 }; |
|
56 |
|
57 |
|
58 struct TSmsRxParametersGsm |
|
59 { |
|
60 RMobileSmsMessaging::TMobileSmsGsmTpdu iPdu; |
|
61 RMobileSmsMessaging::TMobileSmsGsmTpdu iDeliveryReport; |
|
62 TSmsSca iSca; |
|
63 }; |
|
64 |
|
65 |
|
66 struct TConstraintEntry |
|
67 { |
|
68 TInt iIpcCnt; // <The Number of times an IPC(now only sendMessage suported)before incoming messages are simulated |
|
69 TInt iRxCnt; // <The number of times sms messages are going to be simulated |
|
70 }; |
|
71 |
|
72 |
|
73 class CSimSmsStore; |
|
74 class CSimPhone; |
|
75 class CSimSmsMessaging : public CSubSessionExtBase, public MTimerCallBack |
|
76 { |
|
77 friend class CSimSmsStore; |
|
78 |
|
79 public: |
|
80 static CSimSmsMessaging* NewL(CSimPhone* aPhone); |
|
81 CSimSmsMessaging(CSimPhone* aPhone); |
|
82 ~CSimSmsMessaging(); |
|
83 |
|
84 static void CloseSmsObj(TAny* aObj); |
|
85 const CTestConfigSection* CfgFileSection(); |
|
86 |
|
87 virtual CTelObject::TReqMode ReqModeL(const TInt aIpc); |
|
88 // MTelObjectTSY pure virtual |
|
89 virtual TInt RegisterNotification(const TInt aIpc); |
|
90 virtual TInt DeregisterNotification(const TInt aIpc); |
|
91 virtual void Init(); |
|
92 virtual CTelObject* OpenNewObjectByNameL(const TDesC& aName); |
|
93 virtual CTelObject* OpenNewObjectL(TDes& aNewName); |
|
94 virtual TInt NumberOfSlotsL(const TInt aIpc); |
|
95 virtual TInt CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle); |
|
96 |
|
97 // MSubSessionExtBaseTSY pure virtual |
|
98 virtual TInt ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage); |
|
99 |
|
100 protected: |
|
101 void ConstructL(); |
|
102 |
|
103 private: |
|
104 enum TSmsRxEvent |
|
105 { |
|
106 ESmsEventPostedRxReq, |
|
107 ESmsEventRxTimer, |
|
108 ESmsEventRxAckNack, |
|
109 ESmsEventResume |
|
110 }; |
|
111 |
|
112 enum TSmsRxState |
|
113 { |
|
114 ESmsRxStateIdle, |
|
115 ESmsRxStateWaitingForSmsRx, |
|
116 ESmsRxStateWaitingForNetworkAckNackResponse, |
|
117 ESmsRxStateWaitingForAckNack, |
|
118 ESmsRxStateSuspend, |
|
119 ESmsRxStateWaitingForNetworkResumeResponse, |
|
120 ESmsRxStateWaitingToStart |
|
121 } iRxState; |
|
122 |
|
123 TSmsRxState iRxStatePrevious; |
|
124 |
|
125 enum TSmsTxEvent |
|
126 { |
|
127 ESmsEventSendReq, |
|
128 ESmsEventSubmitReportReceived |
|
129 }; |
|
130 |
|
131 enum TSmsTxState |
|
132 { |
|
133 ESmsTxStateIdle, |
|
134 ESmsTxStateWaitingForSubmitReport |
|
135 } iTxState; |
|
136 |
|
137 TInt HandleExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage); |
|
138 |
|
139 void FindAndCreateSmsStoresL(CSimPhone* aPhone); |
|
140 void FindAndCreateRxAttributesL(); |
|
141 void FindAndCreateTxAttributesL(); |
|
142 void FindAndCreateConstraints(); |
|
143 void FindAndCreateSmsParamsL(); |
|
144 |
|
145 TInt ReceiveMessageL(const TTsyReqHandle aTsyReqHandle,TDes8* aSmsPdu,TDes8* aSmsAttrib); |
|
146 void ReceiveMessageCancel(); |
|
147 void SendMessageCancel(); |
|
148 TInt GetCaps(const TTsyReqHandle aReqHandle,TDes8* aPckg1); |
|
149 TInt EnumerateMessagingStores(TTsyReqHandle aReqHandle,TDes8* aPckg); |
|
150 TInt GetMessageStoreInfo(TTsyReqHandle aReqHandle,TDes8* aPckg1, TDes8* aPckg2); |
|
151 TInt GetReceiveMode(const TTsyReqHandle aReqHandle,TDes8* aPckg); |
|
152 TInt SetReceiveMode(const TTsyReqHandle aReqHandle,TDes8* aPckg); |
|
153 TInt AckSmsStored(const TTsyReqHandle aReqHandle,TDes8* aMsg,TDes8* aFullFlag); |
|
154 TInt NackSmsStored(const TTsyReqHandle aReqHandle,TDes8* aMsg,TDes8* aRpCausePckg); |
|
155 void AckNackCancel(); |
|
156 TInt ResumeSmsReception(const TTsyReqHandle aReqHandle); |
|
157 void ResumeSmsReceptionCancel(); |
|
158 TInt SendMessageL(const TTsyReqHandle aTsyReqHandle,TDes8* aPckg1, TDes8* aPckg2); |
|
159 TInt GetSmspListPhase1(const TTsyReqHandle aTsyReqHandle, |
|
160 TDes8* aParam1,TDes8* aParam2); |
|
161 void GetSmspListPhase1L(TTsyReqHandle aTsyReqHandle,RMobilePhone::TClientId& aClientId,TInt& aBufSize); |
|
162 TInt GetSmspListPhase2(const TTsyReqHandle aTsyReqHandle, |
|
163 TDes8* aParam1,TDes8* aParam2); |
|
164 void GetSmspListCancel(); |
|
165 TInt StoreSmspList(const TTsyReqHandle aTsyReqHandle,TDes8* aPckg); |
|
166 void StoreSmspListCancel(); |
|
167 void CompletePendingReq(); |
|
168 void CompleteTxPendingReq(TInt aError); |
|
169 TInt AttemptSmsRxComplete(); |
|
170 void StartSmsMtTimer(); |
|
171 void TimerCallBack(TInt aId); |
|
172 void PopulateSmsRxAttrib(const TDesC8& aAsciiScaAddr,RMobileSmsMessaging::TMobileSmsReceiveAttributesV1* aAttrib); |
|
173 |
|
174 void PopulateSmsTxAttrib(RMobileSmsMessaging::TMobileSmsSendAttributesV1* aAttrib); |
|
175 |
|
176 void PopulateSmsTxAttrib(RMobileSmsMessaging::TMobileSmsAttributesV1* aAttrib); |
|
177 |
|
178 void RecordSca(const TDesC8& aAsciiScaAddr, RMobileSmsMessaging::TMobileSmspEntryV1& aEntry); |
|
179 void RecordDestination(const TDesC8& aAsciiScaAddr, RMobileSmsMessaging::TMobileSmspEntryV1& aEntry); |
|
180 void PopulateSmspListFromConfigFile(); |
|
181 TBool IpcMatch(); |
|
182 TInt ActionRxEventUnstoredClientAck(TSmsRxEvent aRxEvent); |
|
183 TInt ActionRxEventUnstoredPhoneAck(TSmsRxEvent aRxEvent); |
|
184 TInt ActionRxEventStored(TSmsRxEvent aRxEvent); |
|
185 TInt ActionTxEvent(TSmsTxEvent aTxEvent); |
|
186 |
|
187 TBool CanStartRxEvent() const; |
|
188 TBool ConstraintEllapsed() const; |
|
189 |
|
190 void LogRequest(const TBool aEntering, TInt aIpc, TInt aError); |
|
191 |
|
192 #ifdef _DEBUG |
|
193 void LogTMobileSmsAttributesV1(const RMobileSmsMessaging::TMobileSmsAttributesV1& aSmsAttributesV1); |
|
194 void AppendTonToBuffer(TDes8& aBuffer, const RMobilePhone::TMobileTON& aTon); |
|
195 void AppendNpiToBuffer(TDes8& aBuffer, const RMobilePhone::TMobileNPI& aNpi); |
|
196 #endif |
|
197 |
|
198 TInt ReloadConfigL(const TTsyReqHandle aReqHandle); |
|
199 HBufC8* PduToAscii(TDesC8& aSmsPdu); |
|
200 void DumpPdu(const TDesC8& aText, TDesC8& aSmsPdu, HBufC8* aPduInAscii = 0); |
|
201 |
|
202 private: |
|
203 |
|
204 CSimTimer* iRxTimer; |
|
205 CSimTimer* iTxTimer; |
|
206 CSimTimer* iSmspTimer; |
|
207 TTsyReqHandle iSmsRxReqHandle; |
|
208 TTsyReqHandle iSmsTxReqHandle; |
|
209 TTsyReqHandle iSmspReqHandle; |
|
210 TTsyReqHandle iPendingReqHandle; // < Request handle for pending Ack, Nack or Resume Completion. |
|
211 |
|
212 CSimPhone* iPhone; |
|
213 CArrayFixFlat<CSimSmsStore*>* iSmsStores; |
|
214 |
|
215 CArrayFixFlat<TSmsRxParametersGsm>* iSmsRxParameterListGsm; // < Contains the values associated with the SmsRx tag for GSM |
|
216 |
|
217 TInt iSmsRxPeriod; // < The period between simulating received SMS messages. |
|
218 TInt iAckNackCompletePause; // < The pause before Ack/Nack requests are completed. |
|
219 TInt iResumeCompletePause; // < The pause before Resume requests are completed. |
|
220 TBool iSmsStoreFull; // < Flag to indicate that last Ack/NAck received stated that the store was full. |
|
221 TInt iSmsRxCnt; // < Count of the number of SMS messages received. |
|
222 TBool iSmsRxReqOutstanding; // < Flags if ReceiveMessage has been posted by the client |
|
223 TDes8* iSmsRxPdu; |
|
224 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1* iSmsRxAttrib; // <Attributes to be return to the client On ReceiveMessage completion |
|
225 |
|
226 CArrayFixFlat<TSmsTxParametersGsm>* iSmsTxParametersListGsm; // < Contains the values associated with the Smstx tag |
|
227 |
|
228 RMobileSmsMessaging::TMobileSmsSendAttributesV1* iSmsTxAttrib; // <Attributes to be return to the client On SendMessage completion |
|
229 |
|
230 TInt iSmsTxCnt; // < Count the number times RSmsMessaging::SendMessage. completes |
|
231 TInt iSmsTxPause; // < The period between the layer 3 send request and the submit report reception |
|
232 RMobileSmsMessaging::TMobileSmsControlCaps iSmsControlCaps; // < The control capabilities of messaging(TMobileSmsControlCaps) |
|
233 |
|
234 RMobileSmsMessaging::TMobileSmsReceiveMode iSmsReceiveMode; // < The control capabilities of messaging(TMobileSmsControlCaps) |
|
235 |
|
236 //constraint |
|
237 TInt iCurrentConstraint; // < The index in the iConstraints Array currently in use |
|
238 TInt iConstraintRxCnt; // < The number of SmsMessages received under 1 constraint |
|
239 RArray<TConstraintEntry> iConstraints; // < An array of constraints |
|
240 |
|
241 //smsp |
|
242 CArrayPtrFlat<CListReadAllAttempt>* iSmspReadAll; // < A list of the oustanding two phase batch read requests. |
|
243 CMobilePhoneSmspList* iSmspEntries; // < A pointer to the SMSpList array. |
|
244 TInt iSmspBatchPause; // < The pause value used to delay the completion of a batch SMS Store manipulation request. |
|
245 TBool iSmspBusy; // < Used as a semaphore to avoid store/get at the same time. |
|
246 |
|
247 RMobileSmsMessaging::TMobileSmsModeCaps iSmsModeCaps; // < The mode capabilities of messaging(TMobileSmsControlCaps) |
|
248 TInt iSmsRxStartDelay; |
|
249 TBool iSmsReceiveModeSet; |
|
250 TUint8 iLastTxMsgId[2]; |
|
251 }; |
|
252 |
|
253 #endif // __SIMSMSMESS_H_ |