1 // Copyright (c) 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 // CUnsolicitedCommandCallControlHandler. The handler for handling the unsolicited command related to call control |
|
15 |
|
16 //system include |
|
17 |
|
18 //user include |
|
19 #include "unsolicitedcommandcallcontrolhandler.h" |
|
20 #include <ctsy/ltsy/cctsydispatchercallback.h> |
|
21 #include "ltsycommondefine.h" |
|
22 #include "globalphonemanager.h" |
|
23 #include "unsolicitedparams.h" |
|
24 #include "atclcc.h" |
|
25 #include "ltsycallinformationmanager.h" |
|
26 #include "mslogger.h" |
|
27 |
|
28 CUnsolicitedCommandCallControlHandler* CUnsolicitedCommandCallControlHandler::NewL(CGlobalPhonemanager& aGloblePhone, |
|
29 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
30 { |
|
31 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::NewL()")); |
|
32 |
|
33 CUnsolicitedCommandCallControlHandler* self = CUnsolicitedCommandCallControlHandler::NewLC(aGloblePhone, |
|
34 aCtsyDispatcherCallback); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CUnsolicitedCommandCallControlHandler* CUnsolicitedCommandCallControlHandler::NewLC(CGlobalPhonemanager& aGloblePhone, |
|
40 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
41 { |
|
42 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::NewLC()")); |
|
43 |
|
44 CUnsolicitedCommandCallControlHandler* self = new (ELeave) CUnsolicitedCommandCallControlHandler(aGloblePhone, |
|
45 aCtsyDispatcherCallback); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CUnsolicitedCommandCallControlHandler::~CUnsolicitedCommandCallControlHandler() |
|
52 { |
|
53 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::~CUnsolicitedCommandCallControlHandler()")); |
|
54 } |
|
55 |
|
56 CUnsolicitedCommandCallControlHandler::CUnsolicitedCommandCallControlHandler(CGlobalPhonemanager& aGloblePhone, |
|
57 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
58 :iGlobalPhone(aGloblePhone), |
|
59 iCtsyDispatcherCallback(aCtsyDispatcherCallback) |
|
60 { |
|
61 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::CUnsolicitedCommandCallControlHandler()")); |
|
62 } |
|
63 |
|
64 void CUnsolicitedCommandCallControlHandler::ConstructL() |
|
65 { |
|
66 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::ConstructL()")); |
|
67 |
|
68 iAtClcc = CATClcc::NewL(iGlobalPhone, iCtsyDispatcherCallback); |
|
69 |
|
70 iAtClcc->AddQueryCallInformationCompleteNotify(this); |
|
71 } |
|
72 |
|
73 void CUnsolicitedCommandCallControlHandler::QueryCallInformationComplete(TInt /*aError*/) |
|
74 { |
|
75 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::QueryCallInformationComplete()")); |
|
76 |
|
77 if (iAtClcc->GetProcessStates() == CATClcc::EProcessOK) |
|
78 { |
|
79 TInt nCallId = iGlobalPhone.GetCallInfoManager().FindWaitingCallId(); |
|
80 |
|
81 LOGTEXT2(_L8("[Ltsy CallControl] The Waiting Call Id = %d"), nCallId); |
|
82 if (KErrNotFound == nCallId) |
|
83 { |
|
84 iAtClcc->InitVariable(); |
|
85 return; |
|
86 } |
|
87 |
|
88 //Waiting call information |
|
89 TLtsyCallInformation& tWaitingCallInfo(iGlobalPhone.GetCallInfoManager().GetCallInformationByCallId(nCallId)); |
|
90 |
|
91 RMobileCall::TMobileCallInfoV1 tMobileCallInfo; |
|
92 |
|
93 //Call id |
|
94 tMobileCallInfo.iCallId = tWaitingCallInfo.GetCallId(); |
|
95 |
|
96 //Call service |
|
97 TLtsyCallInformation::TCallMode tCallService(tWaitingCallInfo.GetCallMode()); |
|
98 if (TLtsyCallInformation::EVoiceCall == tCallService) |
|
99 { |
|
100 tMobileCallInfo.iService = RMobilePhone::EVoiceService; |
|
101 } |
|
102 else if (TLtsyCallInformation::EDataCall == tCallService) |
|
103 { |
|
104 tMobileCallInfo.iService = RMobilePhone::ECircuitDataService; |
|
105 } |
|
106 else if (TLtsyCallInformation::EFaxCall == tCallService) |
|
107 { |
|
108 tMobileCallInfo.iService = RMobilePhone::EFaxService; |
|
109 } |
|
110 else |
|
111 { |
|
112 tMobileCallInfo.iService = RMobilePhone::EServiceUnspecified; |
|
113 } |
|
114 |
|
115 //Call back |
|
116 iCtsyDispatcherCallback.CallbackCallControlNotifyIncomingCallInd(KErrNone, tMobileCallInfo); |
|
117 |
|
118 //Waiting States |
|
119 tMobileCallInfo.iStatus = RMobileCall::EStatusRinging; |
|
120 |
|
121 //Telephone number |
|
122 tMobileCallInfo.iRemoteParty.iRemoteNumber.iTelNumber.Copy(tWaitingCallInfo.GetMobileTelNum()); |
|
123 |
|
124 //Callback |
|
125 iCtsyDispatcherCallback.CallbackCallControlNotifyCallInfoChangeInd(KErrNone, tMobileCallInfo); |
|
126 } |
|
127 |
|
128 //Init iAtCll for reusing it |
|
129 iAtClcc->InitVariable(); |
|
130 } |
|
131 |
|
132 void CUnsolicitedCommandCallControlHandler::HandleSimRemoveEvent() |
|
133 { |
|
134 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::HandleSimRemoveEvent()")); |
|
135 |
|
136 TInt nErr = KErrEtelNoCarrier; |
|
137 |
|
138 for (TInt nCallId = KLtsyMinCallId; nCallId <= KLtsyMaxCallId; nCallId++) |
|
139 { |
|
140 TLtsyCallInformation& tCallInfo(iGlobalPhone.GetCallInfoManager().GetCallInformationByCallId(nCallId)); |
|
141 if (TLtsyCallInformation::EUsed == tCallInfo.GetCallIdIsUsedInfo()) |
|
142 { |
|
143 //Notify disconnecting status |
|
144 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
145 nCallId, |
|
146 RMobileCall::EStatusDisconnecting); |
|
147 |
|
148 //Nofity idel status |
|
149 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
150 nCallId, |
|
151 RMobileCall::EStatusIdle); |
|
152 } |
|
153 } |
|
154 |
|
155 iGlobalPhone.GetCallInfoManager().ResetAllCalInformation(); |
|
156 } |
|
157 |
|
158 void CUnsolicitedCommandCallControlHandler::HandleProductInitEvent() |
|
159 { |
|
160 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::HandleProductInitEvent()")); |
|
161 |
|
162 TInt nErr = KErrEtelNoCarrier; |
|
163 |
|
164 for (TInt nCallId = KLtsyMinCallId; nCallId <= KLtsyMaxCallId; nCallId++) |
|
165 { |
|
166 TLtsyCallInformation& tCallInfo(iGlobalPhone.GetCallInfoManager().GetCallInformationByCallId(nCallId)); |
|
167 if (TLtsyCallInformation::EUsed == tCallInfo.GetCallIdIsUsedInfo()) |
|
168 { |
|
169 //Notify disconnecting status |
|
170 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
171 nCallId, |
|
172 RMobileCall::EStatusDisconnecting); |
|
173 //Notify idel status |
|
174 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
175 nCallId, |
|
176 RMobileCall::EStatusIdle); |
|
177 } |
|
178 } |
|
179 |
|
180 iGlobalPhone.GetCallInfoManager().ResetAllCalInformation(); |
|
181 } |
|
182 |
|
183 void CUnsolicitedCommandCallControlHandler::HandleNetworkLostEvent() |
|
184 { |
|
185 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::HandleNetworkLostEvent()")); |
|
186 |
|
187 TInt nErr = KErrEtelNoCarrier; |
|
188 |
|
189 for (TInt nCallId = KLtsyMinCallId; nCallId <= KLtsyMaxCallId; nCallId++) |
|
190 { |
|
191 TLtsyCallInformation& tCallInfo(iGlobalPhone.GetCallInfoManager().GetCallInformationByCallId(nCallId)); |
|
192 if (TLtsyCallInformation::EUsed == tCallInfo.GetCallIdIsUsedInfo()) |
|
193 { |
|
194 //Notify disconnecting status |
|
195 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
196 nCallId, |
|
197 RMobileCall::EStatusDisconnecting); |
|
198 //Notify idel status |
|
199 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(nErr, |
|
200 nCallId, |
|
201 RMobileCall::EStatusIdle); |
|
202 } |
|
203 } |
|
204 |
|
205 iGlobalPhone.GetCallInfoManager().ResetAllCalInformation(); |
|
206 } |
|
207 |
|
208 void CUnsolicitedCommandCallControlHandler::HandleCallCreatedEvent(const TDesC8& aWindPkg) |
|
209 { |
|
210 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::HandleCallCreatedEvent()")); |
|
211 |
|
212 TUnsolicitedParams::TUnsolicitedParamsPckgBuf* pPckg = (TUnsolicitedParams::TUnsolicitedParamsPckgBuf*)(&aWindPkg); |
|
213 TInt nCallId = (*pPckg)().iIdx; |
|
214 LOGTEXT2(_L8("[Ltsy CallControl] nCallId = %d"), nCallId); |
|
215 |
|
216 if (iAtClcc->GetProcessStates() == CATClcc::EProcessNotInProgress) |
|
217 { |
|
218 TInt nRet = iGlobalPhone.CheckGlobalPhoneStatus(); |
|
219 if (nRet == KErrNone) |
|
220 { |
|
221 iGlobalPhone.iEventSignalActive = ETrue; |
|
222 iAtClcc->StartRequest(); |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 void CUnsolicitedCommandCallControlHandler::HandleCallReleasedEvent(const TDesC8& aWindPkg) |
|
228 { |
|
229 //if call id is incoming call reset incoming call states |
|
230 iGlobalPhone.GetCallInfoManager().SetIncomingCallFlag(EFalse); |
|
231 |
|
232 //Notify CTSY incoming call release |
|
233 TUnsolicitedParams::TUnsolicitedParamsPckgBuf* pPckg = (TUnsolicitedParams::TUnsolicitedParamsPckgBuf*)(&aWindPkg); |
|
234 TInt nCallId = (*pPckg)().iIdx; |
|
235 LOGTEXT2(_L8("[Ltsy CallControl] nCallId = %d"), nCallId); |
|
236 |
|
237 if (nCallId >= KLtsyMinCallId && nCallId <= KLtsyMaxCallId) |
|
238 { |
|
239 TLtsyCallInformation& tCallInfo(iGlobalPhone.GetCallInfoManager().GetCallInformationByCallId(nCallId)); |
|
240 if (TLtsyCallInformation::EUsed == tCallInfo.GetCallIdIsUsedInfo()) |
|
241 { |
|
242 //Notify disconnecting status |
|
243 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(KErrGsmCCNormalCallClearing, |
|
244 nCallId, |
|
245 RMobileCall::EStatusDisconnecting); |
|
246 //Notify idel status |
|
247 iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(KErrGsmCCNormalCallClearing, |
|
248 nCallId, |
|
249 RMobileCall::EStatusIdle); |
|
250 |
|
251 iGlobalPhone.GetCallInfoManager().ResetCallInformationByCallId(nCallId); |
|
252 } |
|
253 } |
|
254 } |
|
255 |
|
256 void CUnsolicitedCommandCallControlHandler::UnsolicitedCommandArriving(TInt aEvent, |
|
257 const TDesC8& aWindPkg) |
|
258 { |
|
259 LOGTEXT(_L8("[Ltsy CallControl] Starting CUnsolicitedCommandCallControlHandler::UnsolicitedCommandArriving()")); |
|
260 LOGTEXT2(_L8("[Ltsy CallControl] nEvent = %d"), aEvent); |
|
261 |
|
262 switch (aEvent) |
|
263 { |
|
264 case KLtsyUnsolicitedEvent00: |
|
265 HandleSimRemoveEvent(); |
|
266 break; |
|
267 |
|
268 case KLtsyUnsolicitedEvent03: |
|
269 HandleProductInitEvent(); |
|
270 break; |
|
271 |
|
272 case KLtsyUnsolicitedEvent08: |
|
273 HandleNetworkLostEvent(); |
|
274 break; |
|
275 |
|
276 case KLtsyUnsolicitedEvent05: |
|
277 HandleCallCreatedEvent(aWindPkg); |
|
278 break; |
|
279 |
|
280 case KLtsyUnsolicitedEvent06: |
|
281 HandleCallReleasedEvent(aWindPkg); |
|
282 break; |
|
283 |
|
284 default: |
|
285 break; |
|
286 } |
|
287 |
|
288 LOGTEXT(_L8("[Ltsy CallControl] End CUnsolicitedCommandCallControlHandler::UnsolicitedCommandArriving()")); |
|
289 } |
|
290 |
|
291 //End of file |
|