1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements the class CSPCallAddedHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cspcalladdedhandler.h" |
|
20 |
|
21 #include <etelmm.h> |
|
22 #include <mccpcsobserver.h> |
|
23 |
|
24 #include "cspcallarray.h" |
|
25 #include "cspetellinestatusmonitor.h" |
|
26 #include "mcsplinestatusobserver.h" |
|
27 #include "rcsplinecontainer.h" |
|
28 #include "csplogger.h" |
|
29 #include "cspclientvoicecall.h" |
|
30 #include "cspclientvideocall.h" |
|
31 #include "rcsplinecontainer.h" |
|
32 #include "mcspcommoninfo.h" |
|
33 #include "cspconsts.h" |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CSPCallAddedHandler::NewL. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CSPCallAddedHandler* CSPCallAddedHandler::NewL( |
|
41 const MCCPCSObserver& aObserver, |
|
42 RCSPLineContainer& aLineContainer, |
|
43 CSPCallArray& aCallArray, |
|
44 MCSPCommonInfo& aCommonInfo, |
|
45 CSPAudioHandler& aAudioHandler ) |
|
46 { |
|
47 CSPLOGSTRING(CSPOBJECT, "CSPCallAddedHandler::NewL()" ); |
|
48 CSPCallAddedHandler* self = new ( ELeave ) CSPCallAddedHandler( |
|
49 aObserver, aLineContainer, |
|
50 aCallArray, aCommonInfo, |
|
51 aAudioHandler ); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Destructs the object by canceling first ongoing monitoring. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CSPCallAddedHandler::~CSPCallAddedHandler( ) |
|
63 { |
|
64 CSPLOGSTRING(CSPOBJECT, "CSPCallAddedHandler::~CSPCallAddedHandler" ); |
|
65 delete iAuxLineMonitor; |
|
66 delete iVoiceLineMonitor; |
|
67 delete iDataLineMonitor; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CSPCallAddedHandler::CallAdded |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CSPCallAddedHandler::CallAdded( RMobileLine& aLine, |
|
75 TName aCallName, |
|
76 RCSPLineContainer::TCSPLineId aLineId ) |
|
77 { |
|
78 CSPLOGSTRING2(CSPINT, |
|
79 "CSPCallAddedHandler::CallAdded line: %d", aLineId); |
|
80 CSPLOGSTRING2(CSPINT, |
|
81 "CSPCallAddedHandler::CallAdded call name: %S", &aCallName); |
|
82 |
|
83 // Find call by name |
|
84 if ( !iCallArray.FindCall( aCallName ) ) |
|
85 { |
|
86 TInt err( KErrNone ); |
|
87 |
|
88 // Resolve call type |
|
89 TUint32 serviceId( 0 ); |
|
90 CCPCall::TCallType callType; |
|
91 CCCECallParameters::TCCELineType lineType; |
|
92 |
|
93 iLineContainer.ResolveCallInfo( aLineId, serviceId, callType, lineType ); |
|
94 |
|
95 CSPCall* call = NULL; |
|
96 CCCECallParameters* callParameters = NULL; |
|
97 |
|
98 TRAP_IGNORE( callParameters = CCCECallParameters::NewL() ); |
|
99 if ( callParameters ) |
|
100 { |
|
101 callParameters->SetServiceId(serviceId); |
|
102 callParameters->SetCallType(callType); |
|
103 callParameters->SetLineType(lineType); |
|
104 |
|
105 CSPLOGSTRING2(CSPINT, |
|
106 "CSPCallAddedHandler::CallAdded call type: %d", callType ); |
|
107 |
|
108 if ( callType == CCPCall::ECallTypeCSVoice ) |
|
109 { |
|
110 TRAP( err, call = CSPClientVoiceCall::NewL( aCallName, |
|
111 aLine, *callParameters, |
|
112 iCommonInfo )); |
|
113 } |
|
114 else if ( callType == CCPCall::ECallTypeVideo ) |
|
115 { |
|
116 CSPLOGSTRING(CSPINT, |
|
117 "CSPCallAddedHandler::CallAdded creating video call"); |
|
118 TRAP( err, call = CSPClientVideoCall::NewL( aCallName, |
|
119 aLine, *callParameters, |
|
120 iCommonInfo )); |
|
121 } |
|
122 |
|
123 delete callParameters; |
|
124 callParameters = NULL; |
|
125 } |
|
126 |
|
127 CSPLOGSTRING2(CSPINT, |
|
128 "CSPCallAddedHandler::CallAdded Client call creation res %d", err ); |
|
129 |
|
130 if ( call ) |
|
131 { |
|
132 // Set audio handler for DevSound |
|
133 call->SetAudioHandler( &iAudioHandler ); |
|
134 |
|
135 MCCPCallObserver::TCCPCallState callState = call->State(); |
|
136 CSPLOGSTRING2(CSPINT, |
|
137 "CSPCallAddedHandler::CallAdded call state: %d", callState ); |
|
138 |
|
139 if ( callState == MCCPCallObserver::ECCPStateDialling ) |
|
140 { |
|
141 CSPLOGSTRING(CSPINT, |
|
142 "CSPCallAddedHandler::CallAdded add Dialling call" ); |
|
143 |
|
144 iCallArray.Add( call ); |
|
145 |
|
146 CSPLOGSTRING(CSPINT, |
|
147 "CSPCallAddedHandler::CallAdded notifying dialling state" ); |
|
148 |
|
149 call->NotifyCallStateChangedETel( RMobileCall::EStatusDialling ); |
|
150 } |
|
151 else if ( callState == MCCPCallObserver::ECCPStateConnecting || |
|
152 callState == MCCPCallObserver::ECCPStateConnected ) |
|
153 { |
|
154 CSPLOGSTRING(CSPINT, |
|
155 "CSPCallAddedHandler::CallAdded add Connecting/Connected call" ); |
|
156 iCallArray.Add( call ); |
|
157 iCommonInfo.IndicateClientCall( call ); |
|
158 } |
|
159 else |
|
160 { |
|
161 CSPLOGSTRING(CSPERROR, |
|
162 "CSPCallAddedHandler::CallAdded ignore call" ); |
|
163 delete call; |
|
164 } |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CSPCallAddedHandler::LineStatusChanged |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CSPCallAddedHandler::LineStatusChanged( RMobileLine& aLine, |
|
174 RCSPLineContainer::TCSPLineId aLineId, |
|
175 RMobileCall::TMobileCallStatus& aLineStatus ) |
|
176 { |
|
177 CSPLOGSTRING2(CSPINT, |
|
178 "CSPCallAddedHandler::LineStatusChanged line: %d", aLineId ); |
|
179 CSPLOGSTRING2(CSPINT, |
|
180 "CSPCallAddedHandler::LineStatusChanged line status: %d", |
|
181 aLineStatus ); |
|
182 |
|
183 if ( aLineStatus == RMobileCall::EStatusDialling ) |
|
184 { |
|
185 TInt err(KErrNone); |
|
186 RLine::TLineInfo lineInfo; |
|
187 err = aLine.GetInfo( lineInfo ); |
|
188 TName callName; |
|
189 |
|
190 if ( err == KErrNone ) |
|
191 { |
|
192 callName = lineInfo.iNameOfLastCallAdded; |
|
193 CallAdded( aLine, callName, aLineId); |
|
194 } |
|
195 else |
|
196 { |
|
197 CSPLOGSTRING2(CSPERROR, |
|
198 "CSPCallAddedHandler::LineStatusChanged get info err:%d", |
|
199 err); |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Constructs the monitor. |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 CSPCallAddedHandler::CSPCallAddedHandler( |
|
209 const MCCPCSObserver& aObserver, |
|
210 RCSPLineContainer& aLineContainer, |
|
211 CSPCallArray& aCallArray, |
|
212 MCSPCommonInfo& aCommonInfo, |
|
213 CSPAudioHandler& aAudioHandler ) : |
|
214 iLineContainer( aLineContainer ), |
|
215 iObserver( aObserver ), |
|
216 iCallArray( aCallArray ), |
|
217 iCommonInfo( aCommonInfo ), |
|
218 iAudioHandler( aAudioHandler ) |
|
219 { |
|
220 CSPLOGSTRING(CSPOBJECT, "CSPCallAddedHandler::CSPCallAddedHandler"); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // Second phase construction. |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CSPCallAddedHandler::ConstructL() |
|
228 { |
|
229 CSPLOGSTRING(CSPOBJECT, "CSPCallAddedHandler::ConstructL <"); |
|
230 |
|
231 if ( iLineContainer.LineIsOpen( RCSPLineContainer::ECSPLineSpeech ) ) |
|
232 { |
|
233 RMobileLine& line = iLineContainer.LineByType( |
|
234 RCSPLineContainer::ECSPLineSpeech ); |
|
235 iVoiceLineMonitor = CSPEtelLineStatusMonitor::NewL( *this, line, |
|
236 RCSPLineContainer::ECSPLineSpeech ); |
|
237 iVoiceLineMonitor->StartMonitoring(); |
|
238 } |
|
239 // This is for videocalls |
|
240 if ( iLineContainer.LineIsOpen( RCSPLineContainer::ECSPLineData ) ) |
|
241 { |
|
242 RMobileLine& line = iLineContainer.LineByType( |
|
243 RCSPLineContainer::ECSPLineData ); |
|
244 |
|
245 iDataLineMonitor = CSPEtelLineStatusMonitor::NewL( *this, line, |
|
246 RCSPLineContainer::ECSPLineData ); |
|
247 iDataLineMonitor->StartMonitoring(); |
|
248 } |
|
249 |
|
250 if ( iLineContainer.LineIsOpen( RCSPLineContainer::ECSPLineAuxSpeech ) ) |
|
251 { |
|
252 RMobileLine& line = iLineContainer.LineByType( |
|
253 RCSPLineContainer::ECSPLineAuxSpeech ); |
|
254 iAuxLineMonitor = CSPEtelLineStatusMonitor::NewL( *this, line, |
|
255 RCSPLineContainer::ECSPLineAuxSpeech ); |
|
256 iAuxLineMonitor->StartMonitoring(); |
|
257 } |
|
258 |
|
259 CSPLOGSTRING(CSPOBJECT, "CSPCallAddedHandler::ConstructL >"); |
|
260 } |
|
261 |
|
262 // End of File |
|