66 * |
66 * |
67 * |
67 * |
68 * If there are no constraints any SMS specified in the configuration file and the "incoming SMS event" timer will |
68 * If there are no constraints any SMS specified in the configuration file and the "incoming SMS event" timer will |
69 * be started. |
69 * be started. |
70 */ |
70 */ |
|
71 { |
|
72 InitializeL(); |
|
73 } |
|
74 |
|
75 void CSimSmsMessaging::InitializeL() |
71 { |
76 { |
72 LOGSMS1("Starting to Load and Parse Sms Messaging Config "); |
77 LOGSMS1("Starting to Load and Parse Sms Messaging Config "); |
73 iRxTimer=CSimTimer::NewL(iPhone); |
78 iRxTimer=CSimTimer::NewL(iPhone); |
74 iTxTimer=CSimTimer::NewL(iPhone); |
79 iTxTimer=CSimTimer::NewL(iPhone); |
75 iSmspTimer=CSimTimer::NewL(iPhone); |
80 iSmspTimer=CSimTimer::NewL(iPhone); |
93 |
98 |
94 LOGSMS1("Finished parsing SMS Messaging config parameters"); |
99 LOGSMS1("Finished parsing SMS Messaging config parameters"); |
95 } |
100 } |
96 |
101 |
97 |
102 |
98 CSimSmsMessaging::~CSimSmsMessaging() |
103 void CSimSmsMessaging::Reset() |
99 /** |
104 { |
100 * Standard destructor. Any objects created by the ::ConstructL() function should be destroyed here. |
105 if(iSmsRxParameterListGsm) |
101 */ |
|
102 { |
|
103 if(iSmsRxParameterListGsm) |
|
104 { |
106 { |
105 iSmsRxParameterListGsm->Delete(0,iSmsRxParameterListGsm->Count()); |
107 iSmsRxParameterListGsm->Delete(0,iSmsRxParameterListGsm->Count()); |
106 delete iSmsRxParameterListGsm; |
108 delete iSmsRxParameterListGsm; |
|
109 iSmsRxParameterListGsm = NULL; |
107 } |
110 } |
108 |
111 |
109 if(iSmsTxParametersListGsm) |
112 if(iSmsTxParametersListGsm) |
110 { |
113 { |
111 iSmsTxParametersListGsm->Delete(0,iSmsTxParametersListGsm->Count()); |
114 iSmsTxParametersListGsm->Delete(0,iSmsTxParametersListGsm->Count()); |
112 delete iSmsTxParametersListGsm; |
115 delete iSmsTxParametersListGsm; |
|
116 iSmsTxParametersListGsm = NULL; |
113 } |
117 } |
114 |
118 |
115 delete iSmspEntries; |
119 delete iSmspEntries; |
116 |
120 iSmspEntries = NULL; |
117 if (iSmsStores) |
121 |
118 { |
122 if (iSmsStores) |
119 TInt storeCount=iSmsStores->Count(); |
123 { |
120 for(TInt i=0;i<storeCount;i++) |
124 TInt storeCount=iSmsStores->Count(); |
121 { |
125 for(TInt i=0;i<storeCount;i++) |
122 iSmsStores->At(i)->Close(); |
126 { |
123 } |
127 iSmsStores->At(i)->Close(); |
124 delete iSmsStores; |
128 } |
125 } |
129 delete iSmsStores; |
126 |
130 iSmsStores = NULL; |
127 if (iSmspReadAll) |
131 } |
128 { |
132 |
129 iSmspReadAll->ResetAndDestroy(); |
133 if (iSmspReadAll) |
130 delete iSmspReadAll; |
134 { |
131 } |
135 iSmspReadAll->ResetAndDestroy(); |
132 |
136 delete iSmspReadAll; |
133 iConstraints.Close(); |
137 iSmspReadAll = NULL; |
134 if(iRxTimer) |
138 } |
135 delete iRxTimer; |
139 |
136 if(iTxTimer) |
140 iConstraints.Reset(); |
137 delete iTxTimer; |
141 |
138 if(iSmspTimer) |
142 iSmsTxCnt = 0; |
139 delete iSmspTimer; |
143 iSmsRxCnt = 0; |
|
144 iCurrentConstraint = 0; |
|
145 iConstraintRxCnt = 0; |
|
146 |
|
147 iSmspBusy = EFalse; |
|
148 iRxState = ESmsRxStateIdle; |
|
149 iTxState = ESmsTxStateIdle; |
|
150 |
|
151 delete iRxTimer; |
|
152 iRxTimer = NULL; |
|
153 |
|
154 delete iTxTimer; |
|
155 iTxTimer = NULL; |
|
156 |
|
157 delete iSmspTimer; |
|
158 iSmspTimer = NULL; |
|
159 } |
|
160 |
|
161 CSimSmsMessaging::~CSimSmsMessaging() |
|
162 /** |
|
163 * Standard destructor. Any objects created by the ::ConstructL() function should be destroyed here. |
|
164 */ |
|
165 { |
|
166 Reset(); |
140 } |
167 } |
141 |
168 |
142 void CSimSmsMessaging::FindAndCreateRxAttributesL() |
169 void CSimSmsMessaging::FindAndCreateRxAttributesL() |
143 /** |
170 /** |
144 * Extract values from the tags |
171 * Extract values from the tags |
814 TBool constraintEllapsed=ConstraintEllapsed(); |
841 TBool constraintEllapsed=ConstraintEllapsed(); |
815 |
842 |
816 // NOTE - call ConstraintEllapsed() before doing loop below as iCurrentConstraint |
843 // NOTE - call ConstraintEllapsed() before doing loop below as iCurrentConstraint |
817 // is updated in the loop and so can result in ConstraintEllapsed() giving a |
844 // is updated in the loop and so can result in ConstraintEllapsed() giving a |
818 // different result |
845 // different result |
819 |
846 TInt count = iConstraints.Count(); |
820 for(i=0;i<iConstraints.Count();i++) |
847 for(i=0;i<count;++i) |
821 { |
848 { |
822 if(iSmsTxCnt==(iConstraints[i].iIpcCnt)) |
849 if(iSmsTxCnt==(iConstraints[i].iIpcCnt)) |
823 { |
850 { |
824 iCurrentConstraint=i; |
851 iCurrentConstraint=i; |
825 LOGSMS2("New Constraint : %d", iCurrentConstraint); |
852 LOGSMS2("New Constraint : %d", iCurrentConstraint); |
1245 * Cancel an outstanding Receive Message request. |
1272 * Cancel an outstanding Receive Message request. |
1246 */ |
1273 */ |
1247 { |
1274 { |
1248 if(iSmsRxReqOutstanding) |
1275 if(iSmsRxReqOutstanding) |
1249 { |
1276 { |
|
1277 iRxTimer->Cancel(); |
1250 iSmsRxReqOutstanding=EFalse; |
1278 iSmsRxReqOutstanding=EFalse; |
1251 iRxState=ESmsRxStateIdle; |
1279 iRxState=ESmsRxStateIdle; |
1252 ReqCompleted(iSmsRxReqHandle,KErrCancel); |
1280 ReqCompleted(iSmsRxReqHandle,KErrCancel); |
1253 } |
1281 } |
1254 } |
1282 } |
1568 LOGSMS1(">>CompleteTxPendingReq "); |
1596 LOGSMS1(">>CompleteTxPendingReq "); |
1569 iSmsTxCnt++; |
1597 iSmsTxCnt++; |
1570 if(IpcMatch()) |
1598 if(IpcMatch()) |
1571 { |
1599 { |
1572 iConstraintRxCnt=0; |
1600 iConstraintRxCnt=0; |
|
1601 if( iRxState == ESmsRxStateSuspend ) |
|
1602 { |
|
1603 // A previous rx message was NACKed due memory full and |
|
1604 // SIM TSY is waiting for resume event from client - as |
|
1605 // a new message needs to be received, change states |
|
1606 // to allow receipt of the message. |
|
1607 if( iSmsRxReqOutstanding ) |
|
1608 { |
|
1609 iRxState = ESmsRxStateWaitingForSmsRx; |
|
1610 } |
|
1611 else |
|
1612 { |
|
1613 iRxState = ESmsRxStateIdle; |
|
1614 } |
|
1615 } |
1573 if( iSmsRxReqOutstanding ) |
1616 if( iSmsRxReqOutstanding ) |
1574 { |
1617 { |
1575 // Client has a pending receive request - safe to start Rx timer |
1618 // Client has a pending receive request - safe to start Rx timer |
1576 // to simulate received SMS from network. |
1619 // to simulate received SMS from network. |
1577 StartSmsMtTimer(); |
1620 StartSmsMtTimer(); |
2101 LOGSMS1(">>CSimSmsMessaging::CfgFileSection"); |
2144 LOGSMS1(">>CSimSmsMessaging::CfgFileSection"); |
2102 return iPhone->CfgFile(); |
2145 return iPhone->CfgFile(); |
2103 } |
2146 } |
2104 |
2147 |
2105 |
2148 |
2106 TInt CSimSmsMessaging::ReloadConfigL(const TTsyReqHandle aReqHandle) |
2149 void CSimSmsMessaging::ReloadConfigurationSettingsL() |
2107 /** |
2150 /** |
2108 * This function reloads the Rx, Tx and constraint parameters from the config file |
2151 * This function reloads settings from the config file |
2109 * @param aReqHandle Handle to notify when operation completed |
2152 */ |
2110 * @return KErrNone |
2153 { |
2111 */ |
2154 Reset(); |
2112 { |
2155 InitializeL(); |
2113 LOGSMS1("Reloading configuration"); |
2156 } |
2114 //Tell SimPhone to reread the test number property |
2157 |
2115 iPhone->ResetTestNumber(); |
|
2116 //Delete current configuration |
|
2117 iSmsRxParameterListGsm->Reset(); |
|
2118 iSmsTxParametersListGsm->Reset(); |
|
2119 |
|
2120 iSmsTxCnt = 0; |
|
2121 iSmsRxCnt = 0; |
|
2122 iConstraints.Reset(); |
|
2123 iCurrentConstraint = 0; |
|
2124 iConstraintRxCnt = 0; |
|
2125 //Reread the configuration |
|
2126 TInt err; |
|
2127 TRAP(err, FindAndCreateRxAttributesL()); |
|
2128 if (err != KErrNone) return err; |
|
2129 TRAP(err, FindAndCreateTxAttributesL()); |
|
2130 if (err != KErrNone) return err; |
|
2131 FindAndCreateConstraints(); |
|
2132 |
|
2133 TInt count; |
|
2134 count = iSmsRxParameterListGsm->Count(); |
|
2135 |
|
2136 if((count>0)&&(iConstraints.Count()==0)) // If there are messages to receive & no constraints, then |
|
2137 { |
|
2138 if (iRxTimer->Running()) |
|
2139 { |
|
2140 iRxTimer->Cancel(); |
|
2141 } |
|
2142 LOGSMS1("Starting Rx Timer"); |
|
2143 iRxStatePrevious = iRxState; |
|
2144 iRxState = ESmsRxStateWaitingToStart; |
|
2145 iRxTimer->Start(iSmsRxStartDelay,this, ETimerIdSmsMessRx); |
|
2146 } |
|
2147 else if (iRxTimer->Running()) |
|
2148 { |
|
2149 LOGSMS1("Stopping Rx Timer"); |
|
2150 iRxTimer->Cancel(); |
|
2151 } |
|
2152 |
|
2153 LOGSMS1("Finished reloading configuration"); |
|
2154 ReqCompleted(aReqHandle,KErrNone); |
|
2155 return KErrNone; |
|
2156 } |
|
2157 |
|
2158 HBufC8* CSimSmsMessaging::PduToAscii(TDesC8& aSmsPdu) |
2158 HBufC8* CSimSmsMessaging::PduToAscii(TDesC8& aSmsPdu) |
2159 /** |
2159 /** |
2160 * Converts the contents of a TDes8 to their Hex representation |
2160 * Converts the contents of a TDes8 to their Hex representation |
2161 * @param aSmsPdu Reference to the descriptor to convert |
2161 * @param aSmsPdu Reference to the descriptor to convert |
2162 * @return A pointer to an HBufC8 containing the Hex representation of aSmsPdu. The caller is responsible for freeing the object. |
2162 * @return A pointer to an HBufC8 containing the Hex representation of aSmsPdu. The caller is responsible for freeing the object. |