|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Call active notifier: either for data or voice line, multi mode ETEL version. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <etel.h> |
|
23 #include <etelmm.h> |
|
24 #include <mmtsy_names.h> |
|
25 #include "CLogsMMECallStatus.h" |
|
26 #include "MLineStatusObserver.h" |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // Standard creation function. |
|
33 CLogsCallStatus* CLogsCallStatus::NewLC( const TLineStatus aLine ) |
|
34 { |
|
35 CLogsCallStatus* self = new ( ELeave ) CLogsCallStatus( aLine ); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CLogsCallStatus::~CLogsCallStatus() |
|
42 { |
|
43 Cancel(); |
|
44 iLine.Close(); |
|
45 CloseEtelConnection(); |
|
46 delete iDataLine; |
|
47 delete iSecondaryLine; |
|
48 } |
|
49 |
|
50 void CLogsCallStatus::ConstructL() |
|
51 { |
|
52 CActiveScheduler::Add(this); |
|
53 TInt ret = OpenEtelConnection(); |
|
54 User::LeaveIfError( ret ); |
|
55 |
|
56 switch( iSelectedLine ) |
|
57 { |
|
58 case ECallAndDataLines: // FALLTHROUGH |
|
59 { |
|
60 // Voice and Data lines should be monitored, but only check data lines if they are |
|
61 // supported by the TSY |
|
62 TBool dataSupported(EFalse); |
|
63 |
|
64 // ignore errors... on error, dataSupported should remain EFalse |
|
65 iServer.IsSupportedByModule( KMmTsyModuleName, KETelFuncMobileDataCall, dataSupported ); |
|
66 |
|
67 if ( dataSupported ) //For data we need another instance of this |
|
68 { |
|
69 CLogsCallStatus* tmp = CLogsCallStatus::NewLC( EDataLine ); |
|
70 CleanupStack::Pop(); // tmp |
|
71 iDataLine = tmp; |
|
72 } |
|
73 iSelectedLine = ECallLine; |
|
74 } |
|
75 case ECallLine: |
|
76 { |
|
77 TBool alsSupport(EFalse); //ALS alternate line service |
|
78 // ignore errors... on error, alsSupport should remain EFalse |
|
79 iServer.IsSupportedByModule( KMmTsyModuleName, KETelFuncMobileAlternateLineService, alsSupport ); |
|
80 if ( alsSupport ) //For secondary line, we need yet another instance of this |
|
81 { |
|
82 CLogsCallStatus* tmp = CLogsCallStatus::NewLC( ESecondaryLine ); |
|
83 CleanupStack::Pop(); // tmp |
|
84 iSecondaryLine = tmp; |
|
85 } |
|
86 |
|
87 |
|
88 ret = iLine.Open( iPhone, KMmTsyVoice1LineName ); |
|
89 break; |
|
90 } |
|
91 case ESecondaryLine: |
|
92 { |
|
93 ret = iLine.Open( iPhone, KMmTsyVoice2LineName ); |
|
94 break; |
|
95 } |
|
96 case EDataLine: |
|
97 { |
|
98 ret = iLine.Open( iPhone, KMmTsyDataLineName ); |
|
99 break; |
|
100 } |
|
101 default: |
|
102 { |
|
103 CloseEtelConnection(); |
|
104 User::Leave( KErrCorrupt ); |
|
105 break; |
|
106 } |
|
107 } |
|
108 if( ret != KErrNone ) |
|
109 { |
|
110 CloseEtelConnection(); |
|
111 User::LeaveIfError( ret ); |
|
112 } |
|
113 } |
|
114 |
|
115 // Default c++ constructor |
|
116 CLogsCallStatus::CLogsCallStatus( const TLineStatus aLine ): |
|
117 iSelectedLine( aLine ) |
|
118 { |
|
119 } |
|
120 |
|
121 void CLogsCallStatus::RunL() |
|
122 { |
|
123 if( iObserver ) |
|
124 { |
|
125 iObserver->LineStatusChangedL(); |
|
126 } |
|
127 if( !IsActive() ) |
|
128 { |
|
129 Cancel(); |
|
130 iLine.NotifyMobileLineStatusChange( iStatus, iLineStatus ); |
|
131 SetActive(); |
|
132 } |
|
133 } |
|
134 |
|
135 void CLogsCallStatus::DoCancel() |
|
136 { |
|
137 iLine.CancelAsyncRequest( EMobileLineNotifyMobileLineStatusChange ); |
|
138 } |
|
139 |
|
140 |
|
141 TInt CLogsCallStatus::CallIsActive( TBool& aCallIsActive ) |
|
142 { |
|
143 aCallIsActive = EFalse; |
|
144 TInt ret( KErrNone ); |
|
145 ret = iLine.GetMobileLineStatus( iLineStatus ); |
|
146 |
|
147 if( ret ) |
|
148 { |
|
149 return ret; |
|
150 } |
|
151 |
|
152 if( iLineStatus == RMobileCall::EStatusConnected ) |
|
153 { |
|
154 aCallIsActive = ETrue; |
|
155 } |
|
156 |
|
157 ////////////Fix for PNUN-666BDH |
|
158 //Let's also check do we have active data call going on (e.g video calls are data calls, not voice calls) |
|
159 TBool activeDataCall( EFalse ); |
|
160 if( iDataLine ) |
|
161 { |
|
162 iDataLine->CallIsActive( activeDataCall ); |
|
163 if ( activeDataCall ) |
|
164 { |
|
165 aCallIsActive = ETrue; |
|
166 } |
|
167 } |
|
168 ////////////// |
|
169 |
|
170 ////////////Fix for MVHA-6YUEXZ |
|
171 //Let's also check wether we have an active call on the secondary line (ALS) |
|
172 TBool secondaryLineActive( EFalse ); |
|
173 if( iSecondaryLine ) |
|
174 { |
|
175 iSecondaryLine->CallIsActive( secondaryLineActive ); |
|
176 if ( secondaryLineActive ) |
|
177 { |
|
178 aCallIsActive = ETrue; |
|
179 } |
|
180 } |
|
181 ////////////// |
|
182 |
|
183 return KErrNone; |
|
184 } |
|
185 |
|
186 |
|
187 //Called by observers wanting to receive line status change notifications |
|
188 //(e.g CCtControlContainer) |
|
189 void CLogsCallStatus::SetObserver( MLineStatusObserver* aObserver ) |
|
190 { |
|
191 /// composite objects //// |
|
192 if( iDataLine ) |
|
193 { |
|
194 iDataLine->SetObserver( aObserver ); |
|
195 } |
|
196 if( iSecondaryLine ) |
|
197 { |
|
198 iSecondaryLine->SetObserver( aObserver ); |
|
199 } |
|
200 //////////////////////// |
|
201 |
|
202 if( aObserver ) |
|
203 { |
|
204 Cancel(); |
|
205 iLine.NotifyMobileLineStatusChange( iStatus, iLineStatus ); |
|
206 SetActive(); |
|
207 iObserver = aObserver; |
|
208 } |
|
209 else |
|
210 { |
|
211 Cancel(); |
|
212 iObserver = aObserver; |
|
213 } |
|
214 } |
|
215 |
|
216 //Returns duration of an ongoing call (in seconds) |
|
217 TInt CLogsCallStatus::ActiveCallDuration(TTimeIntervalSeconds& aCallDuration) |
|
218 { |
|
219 TInt ret( KErrNone ); |
|
220 |
|
221 ret = iLine.GetMobileLineStatus( iLineStatus ); |
|
222 |
|
223 if( ret == KErrNone && iLineStatus == RMobileCall::EStatusConnected ) |
|
224 { |
|
225 switch( iSelectedLine ) |
|
226 { |
|
227 case ECallLine:// FALLTHROUGH |
|
228 case EDataLine: |
|
229 { |
|
230 |
|
231 TInt callCount; |
|
232 ret = iLine.EnumerateCall( callCount ); |
|
233 if( ret || callCount == 0) |
|
234 { |
|
235 break; |
|
236 } |
|
237 for(TInt i = 0; i < callCount; i++) |
|
238 { |
|
239 RLine::TCallInfo lineInfo; |
|
240 ret = iLine.GetCallInfo( i , lineInfo ); |
|
241 if( ret ) |
|
242 { |
|
243 break; |
|
244 } |
|
245 |
|
246 if( lineInfo.iStatus == RCall::EStatusConnected ) |
|
247 { |
|
248 RMobileCall call; |
|
249 ret = call.OpenExistingCall( iLine, lineInfo.iCallName ); |
|
250 if( ret ) |
|
251 { |
|
252 call.Close(); |
|
253 break; |
|
254 } |
|
255 |
|
256 RMobileCall::TMobileCallInfoV1 callInfo; |
|
257 RMobileCall::TMobileCallInfoV1Pckg callInfoPkg(callInfo); |
|
258 ret = call.GetMobileCallInfo( callInfoPkg ); |
|
259 call.Close(); |
|
260 aCallDuration = callInfo.iDuration; |
|
261 } |
|
262 } |
|
263 } |
|
264 break; |
|
265 |
|
266 default: |
|
267 ret = KErrCorrupt; |
|
268 break; |
|
269 } |
|
270 } |
|
271 return ret; |
|
272 } |
|
273 |
|
274 // End of file |