|
1 /* |
|
2 * Copyright (c) 2005 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: call status handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "BTMonoMobileLine.h" |
|
22 #include "BTMonoCdmaIncomingFlash.h" |
|
23 #include "BTMonoEventObserver.h" |
|
24 #include "BTMonoCmdHandlerDefs.h" |
|
25 #include "Debug.h" |
|
26 |
|
27 const TInt KMobileLineActiveService = 1; |
|
28 const TInt KMobileCallActiveService = 2; |
|
29 const TInt KMobileCdmaActiveService = 3; |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CBTMonoMobileLine::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 CBTMonoMobileLine* CBTMonoMobileLine::NewL( |
|
35 MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) |
|
36 { |
|
37 CBTMonoMobileLine* self = CBTMonoMobileLine::NewLC(aObserver, aPhone, aLineName); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CBTMonoMobileLine::NewLC |
|
44 // ----------------------------------------------------------------------------- |
|
45 CBTMonoMobileLine* CBTMonoMobileLine::NewLC( |
|
46 MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) |
|
47 { |
|
48 CBTMonoMobileLine* self = new(ELeave) CBTMonoMobileLine(aObserver, aPhone, aLineName); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CBTMonoMobileLine::~CBTMonoMobileLine |
|
56 // ----------------------------------------------------------------------------- |
|
57 CBTMonoMobileLine::~CBTMonoMobileLine() |
|
58 { |
|
59 TRACE_FUNC_ENTRY_THIS |
|
60 iCallActives.ResetAndDestroy(); |
|
61 iCallActives.Close(); |
|
62 iCdmaActives.ResetAndDestroy(); |
|
63 iCdmaActives.Close(); |
|
64 delete iLineActive; |
|
65 iLine.Close(); |
|
66 } |
|
67 |
|
68 TInt CBTMonoMobileLine::ActiveCallCount() const |
|
69 { |
|
70 TInt count = iCallActives.Count(); |
|
71 TInt activecount = 0; |
|
72 RMobileCall::TMobileCallStatus sta; |
|
73 for (TInt i = 0; i < count; i++) |
|
74 { |
|
75 sta = iCallActives[i]->CallStatus(); |
|
76 if (sta == RMobileCall::EStatusConnected || sta == RMobileCall::EStatusHold) |
|
77 { |
|
78 activecount++; |
|
79 } |
|
80 } |
|
81 return activecount; |
|
82 } |
|
83 |
|
84 RMobileCall::TMobileCallStatus CBTMonoMobileLine::CallStatus(const TName& aCallName) const |
|
85 { |
|
86 TInt count = iCallActives.Count(); |
|
87 for (TInt i = 0; i < count; i++) |
|
88 { |
|
89 if (iCallActives[i]->CallName().Compare(aCallName) == 0) |
|
90 { |
|
91 return iCallActives[i]->CallStatus(); |
|
92 } |
|
93 } |
|
94 return RMobileCall::EStatusUnknown; |
|
95 } |
|
96 |
|
97 |
|
98 void CBTMonoMobileLine::RequestCompletedL(CBTMonoActive& aActive, TInt aErr) |
|
99 { |
|
100 switch (aActive.ServiceId()) |
|
101 { |
|
102 case KMobileLineActiveService: |
|
103 { |
|
104 if (aErr == KErrNone) |
|
105 { |
|
106 CBTMonoCallActive* callActive = CBTMonoCallActive::NewLC( |
|
107 *this, CActive::EPriorityStandard, KMobileCallActiveService, |
|
108 iLine, iName); |
|
109 iCallActives.AppendL(callActive); |
|
110 |
|
111 CBTMonoCdmaIncomingFlash* cdmaActive = CBTMonoCdmaIncomingFlash::NewLC( |
|
112 *this, CActive::EPriorityStandard, KMobileCdmaActiveService, |
|
113 iLine, iName); |
|
114 iCdmaActives.AppendL(cdmaActive); |
|
115 iObserver.HandleMobileCallEventL(iName, callActive->CallStatus()); |
|
116 callActive->GoActive(); |
|
117 cdmaActive->GoActive(); |
|
118 CleanupStack::Pop(callActive); |
|
119 CleanupStack::Pop(cdmaActive); |
|
120 } |
|
121 iLine.NotifyCallAdded(aActive.iStatus, iName); |
|
122 aActive.GoActive(); |
|
123 break; |
|
124 } |
|
125 case KMobileCallActiveService: |
|
126 { |
|
127 CBTMonoCallActive& calla = reinterpret_cast<CBTMonoCallActive&>(aActive); |
|
128 iObserver.HandleMobileCallEventL(calla.CallName(), calla.CallStatus()); |
|
129 RMobileCall::TMobileCallStatus status = calla.CallStatus(); |
|
130 if (status == RMobileCall::EStatusIdle) |
|
131 { |
|
132 TInt idx = iCallActives.Find(&calla); |
|
133 if (idx >= 0) |
|
134 { |
|
135 delete iCallActives[idx]; |
|
136 iCallActives.Remove(idx); |
|
137 delete iCdmaActives[idx]; |
|
138 iCdmaActives.Remove(idx); |
|
139 } |
|
140 } |
|
141 else |
|
142 { |
|
143 aActive.GoActive(); |
|
144 } |
|
145 break; |
|
146 } |
|
147 case KMobileCdmaActiveService: |
|
148 { |
|
149 iObserver.HandleCdmaIncomingFlashEventL(); |
|
150 aActive.GoActive(); |
|
151 break; |
|
152 } |
|
153 default: |
|
154 break; |
|
155 } |
|
156 } |
|
157 |
|
158 void CBTMonoMobileLine::CancelRequest(TInt aServiceId) |
|
159 { |
|
160 if (aServiceId == KMobileLineActiveService) |
|
161 { |
|
162 iLine.NotifyCallAddedCancel(); |
|
163 } |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CBTMonoMobileLine::CBTMonoMobileLine |
|
168 // ----------------------------------------------------------------------------- |
|
169 CBTMonoMobileLine::CBTMonoMobileLine( |
|
170 MBTMonoEventObserver& aObserver, RMobilePhone& aPhone, const TDesC& aLineName) |
|
171 : iObserver(aObserver), iPhone(aPhone), iLineName(aLineName) |
|
172 { |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CBTMonoMobileLine::ConstructL |
|
177 // ----------------------------------------------------------------------------- |
|
178 void CBTMonoMobileLine::ConstructL() |
|
179 { |
|
180 LEAVE_IF_ERROR(iLine.Open(iPhone, iLineName)) |
|
181 |
|
182 TInt count = 0; |
|
183 LEAVE_IF_ERROR(iLine.EnumerateCall(count)) |
|
184 |
|
185 for (TInt i = 0; i < count; i++) |
|
186 { |
|
187 RLine::TCallInfo info; |
|
188 LEAVE_IF_ERROR(iLine.GetCallInfo(i, info)) |
|
189 CBTMonoCallActive* callActive = CBTMonoCallActive::NewLC( |
|
190 *this, CActive::EPriorityStandard, KMobileCallActiveService, |
|
191 iLine, info.iCallName); |
|
192 iCallActives.AppendL(callActive); |
|
193 |
|
194 CBTMonoCdmaIncomingFlash* cdmaActive = CBTMonoCdmaIncomingFlash::NewLC( |
|
195 *this, CActive::EPriorityStandard, KMobileCdmaActiveService, |
|
196 iLine, info.iCallName); |
|
197 iCdmaActives.AppendL(cdmaActive); |
|
198 |
|
199 callActive->GoActive(); |
|
200 cdmaActive->GoActive(); |
|
201 CleanupStack::Pop(callActive); |
|
202 CleanupStack::Pop(cdmaActive); |
|
203 } |
|
204 |
|
205 iLineActive = CBTMonoActive::NewL(*this, CActive::EPriorityStandard, KMobileLineActiveService); |
|
206 iLine.NotifyCallAdded(iLineActive->iStatus, iName); |
|
207 iLineActive->GoActive(); |
|
208 TRACE_FUNC_THIS |
|
209 } |
|
210 |
|
211 // End of file |