|
1 /* |
|
2 * Copyright (c) 2007 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: Contains the implementation of class CSPEtelCallWaitingRequester |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "cspetelcallwaitingrequester.h" |
|
21 |
|
22 #include <mmretrieve.h> |
|
23 #include <etelmm.h> |
|
24 |
|
25 #include "csplogger.h" |
|
26 #include "cspconsts.h" |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // Constructs the requester via two phased constructing. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CSPEtelCallWaitingRequester* CSPEtelCallWaitingRequester::NewL( |
|
34 RMobilePhone& aPhone ) |
|
35 { |
|
36 CSPLOGSTRING(CSPOBJECT, "CSPEtelCallWaitingRequester::NewL()" ); |
|
37 CSPEtelCallWaitingRequester* self = |
|
38 new ( ELeave ) CSPEtelCallWaitingRequester( aPhone ); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Destructor of the object. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CSPEtelCallWaitingRequester::~CSPEtelCallWaitingRequester( ) |
|
50 { |
|
51 CSPLOGSTRING(CSPOBJECT, "CSPEtelCallWaitingRequester::~CSPEtelCallWaitingRequester()" ); |
|
52 Cancel(); |
|
53 delete iList; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CSPEtelCallWaitingRequester::GetCallWaitingL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void CSPEtelCallWaitingRequester::GetCallWaitingL( const CCCECallParameters& |
|
61 aParams, |
|
62 TBool& aCallWaitingStatus ) |
|
63 { |
|
64 CSPLOGSTRING(CSPINT, "CSPEtelCallWaitingRequester::GetCallWaitingL()" ); |
|
65 |
|
66 if ( iMode == ECwRequesterInactive ) |
|
67 { |
|
68 iMode = ECwRequesterGetStarted; |
|
69 iList->Start( iStatus ); |
|
70 SetActive(); |
|
71 iWait.Start(); |
|
72 |
|
73 if ( iStatus == -5252 ) |
|
74 { |
|
75 aCallWaitingStatus = ETrue; |
|
76 } |
|
77 else |
|
78 { |
|
79 // Get the list of call waiting entries |
|
80 CMobilePhoneCWList* cwList = iList->RetrieveListL(); |
|
81 CleanupStack::PushL(cwList); |
|
82 |
|
83 TInt count = cwList->Enumerate(); |
|
84 RMobilePhone::TMobilePhoneCWInfoEntryV1 cwInfo; |
|
85 |
|
86 aCallWaitingStatus = EFalse; // Default false |
|
87 CSPLOGSTRING(CSPINT, "CSPEtelCallWaitingRequester::GetCallWaitingL() iterate" ); |
|
88 for( TInt i=0; i < count ; i++ ) |
|
89 { |
|
90 cwInfo = cwList->GetEntryL( i ); |
|
91 |
|
92 if ( cwInfo.iStatus == RMobilePhone::ECallWaitingStatusActive ) |
|
93 { |
|
94 if ( cwInfo.iServiceGroup == RMobilePhone::EAuxVoiceService ) |
|
95 { |
|
96 iAuxLineCwStatus = ETrue; |
|
97 } |
|
98 else |
|
99 { |
|
100 iPrimaryLineCwStatus = ETrue; |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 GetCallWaitingStatusByLineType( aParams, aCallWaitingStatus ); |
|
106 |
|
107 CSPLOGSTRING2(CSPINT, |
|
108 "CSPEtelCallWaitingRequester::GetCallWaitingL() res:%d", |
|
109 aCallWaitingStatus ); |
|
110 CleanupStack::PopAndDestroy( cwList ); |
|
111 |
|
112 // Initial value has been read from network, |
|
113 // now we must keep the setting value up to date. |
|
114 StartMonitoring(); |
|
115 } |
|
116 } |
|
117 |
|
118 else if ( iMode == ECwRequesterMonitoring ) |
|
119 { |
|
120 CSPLOGSTRING(CSPINT, "CSPEtelCallWaitingRequester::GetCallWaitingL() use cached value" ); |
|
121 GetCallWaitingStatusByLineType( aParams, aCallWaitingStatus ); |
|
122 } |
|
123 else if ( iMode == ECwRequesterGetStarted ) |
|
124 { |
|
125 CSPLOGSTRING(CSPINT, "CSPEtelCallWaitingRequester::GetCallWaitingL() KErrInUse" ); |
|
126 User::Leave( KErrInUse ); |
|
127 } |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // From CActive |
|
132 // CSPEtelCallWaitingRequester::RunL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CSPEtelCallWaitingRequester::RunL() |
|
136 { |
|
137 CSPLOGSTRING2( CSPREQEND, "CSPEtelCallWaitingRequester::RunL: status: %d", |
|
138 iStatus.Int() ); |
|
139 if ( iWait.IsStarted() ) |
|
140 { |
|
141 iWait.AsyncStop(); |
|
142 } |
|
143 else if ( KErrNone == iStatus.Int() ) |
|
144 { |
|
145 RMobilePhone::TMobilePhoneCWInfoEntryV1 cwInfo = iDesCwStatus(); |
|
146 switch (cwInfo.iStatus) |
|
147 { |
|
148 case RMobilePhone::ECallWaitingStatusActive: |
|
149 if ( cwInfo.iServiceGroup == RMobilePhone::EAuxVoiceService ) |
|
150 { |
|
151 iAuxLineCwStatus = ETrue; |
|
152 } |
|
153 else |
|
154 { |
|
155 iPrimaryLineCwStatus = ETrue; |
|
156 } |
|
157 break; |
|
158 case RMobilePhone::ECallWaitingStatusNotActive: |
|
159 if ( cwInfo.iServiceGroup == RMobilePhone::EAuxVoiceService ) |
|
160 { |
|
161 iAuxLineCwStatus = EFalse; |
|
162 } |
|
163 else |
|
164 { |
|
165 iPrimaryLineCwStatus = EFalse; |
|
166 } |
|
167 break; |
|
168 default: |
|
169 break; |
|
170 } |
|
171 |
|
172 CSPLOGSTRING3(CSPINT, |
|
173 "CSPEtelCallWaitingRequester::RunL: service:%d new cw status:%d", |
|
174 cwInfo.iServiceGroup, cwInfo.iStatus ); |
|
175 |
|
176 StartMonitoring(); |
|
177 } |
|
178 else |
|
179 { |
|
180 iMode = ECwRequesterInactive; |
|
181 } |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // From CActive |
|
186 // CSPEtelCallWaitingRequester::DoCancel |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CSPEtelCallWaitingRequester::DoCancel() |
|
190 { |
|
191 CSPLOGSTRING(CSPOBJECT, "CSPEtelCallWaitingRequester::DoCancel()" ); |
|
192 if ( iMode == ECwRequesterGetStarted ) |
|
193 { |
|
194 iList->Cancel(); |
|
195 iMode = ECwRequesterInactive; |
|
196 } |
|
197 else if ( iMode == ECwRequesterMonitoring ) |
|
198 { |
|
199 iPhone.CancelAsyncRequest( EMobilePhoneNotifyCallWaitingStatusChange ); |
|
200 iMode = ECwRequesterInactive; |
|
201 } |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Constructs the requester. |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 CSPEtelCallWaitingRequester::CSPEtelCallWaitingRequester(RMobilePhone& aPhone): |
|
209 CActive( EPriorityStandard ), |
|
210 iPhone( aPhone ) |
|
211 { |
|
212 CSPLOGSTRING(CSPOBJECT, "CSPEtelCallWaitingRequester::CSPEtelCallWaitingRequester()" ); |
|
213 CActiveScheduler::Add( this ); |
|
214 iPrimaryLineCwStatus = EFalse; |
|
215 iAuxLineCwStatus = EFalse; |
|
216 iMode = ECwRequesterInactive; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CSPEtelCallWaitingRequester::ConstructL |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 void CSPEtelCallWaitingRequester::ConstructL() |
|
224 { |
|
225 CSPLOGSTRING(CSPINT, "CSPEtelCallWaitingRequester::ConstructL()" ); |
|
226 iList = CRetrieveMobilePhoneCWList::NewL(iPhone); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // Start listening call waiting status change notifications. |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CSPEtelCallWaitingRequester::StartMonitoring() |
|
234 { |
|
235 iPhone.NotifyCallWaitingStatusChange( iStatus, iDesCwStatus ); |
|
236 SetActive(); |
|
237 iMode = ECwRequesterMonitoring; |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Returns the call waiting status from call waiting status list by linetype. |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CSPEtelCallWaitingRequester::GetCallWaitingStatusByLineType( const CCCECallParameters& |
|
245 aParams, |
|
246 TBool& aCallWaitingStatus ) |
|
247 { |
|
248 CSPLOGSTRING(CSPOBJECT, "CSPEtelCallWaitingRequester:GetCallWaitingStatusByLineType" ); |
|
249 |
|
250 if ( aParams.LineType() == CCCECallParameters::ECCELineTypePrimary ) |
|
251 { |
|
252 aCallWaitingStatus = iPrimaryLineCwStatus; |
|
253 } |
|
254 else |
|
255 { |
|
256 aCallWaitingStatus = iAuxLineCwStatus; |
|
257 } |
|
258 CSPLOGSTRING3(CSPINT, |
|
259 "CSPEtelCallWaitingRequester::GetCallWaitingStatusByLineType: line:%d res:%d", |
|
260 aParams.LineType(), aCallWaitingStatus ); |
|
261 } |
|
262 |
|
263 // End of file |