|
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: Contains the implementation of class CSPTransferProvider |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mccptransferprovider.h> |
|
20 #include <mccptransferobserver.h> |
|
21 #include <etelmm.h> |
|
22 #include <exterror.h> |
|
23 #include <mccpcall.h> |
|
24 |
|
25 #include "csptransferprovider.h" |
|
26 #include "csplogger.h" |
|
27 #include "mcspcallerrorobserver.h" |
|
28 #include "mcspcommoninfo.h" |
|
29 |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // Two phased construction |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CSPTransferProvider* CSPTransferProvider::NewL ( |
|
36 RMobileCall& aCall, |
|
37 MCSPCallErrorObserver& aErrorObserver, |
|
38 MCSPCommonInfo& aCommonInfo ) |
|
39 { |
|
40 CSPTransferProvider* self = |
|
41 new ( ELeave ) CSPTransferProvider( aCall, aErrorObserver, aCommonInfo ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( ); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Destructor of the object. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CSPTransferProvider::~CSPTransferProvider() |
|
53 { |
|
54 Cancel(); |
|
55 iObservers.Close(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Transfers the call. CCE maps CS Transfer() to this method. |
|
60 // (UnattendedTransfer and others are VoIP features) |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 TInt CSPTransferProvider::AttendedTransfer( MCCPCall& aTransferTargetCall ) |
|
64 { |
|
65 TInt err ( KErrNone ); |
|
66 |
|
67 if ( !IsActive() ) |
|
68 { |
|
69 if ( iCall.SubSessionHandle() != 0 ) |
|
70 { |
|
71 err = KErrNone; |
|
72 // send async request to Etel |
|
73 iCall.Transfer( iStatus ); |
|
74 SetActive(); |
|
75 if( aTransferTargetCall.State() == MCCPCallObserver::ECCPStateConnecting ) |
|
76 { |
|
77 iCommonInfo.DontReportTerminationError(); |
|
78 } |
|
79 } |
|
80 else |
|
81 { |
|
82 // transfer not allowed |
|
83 err = KErrNotSupported; |
|
84 } |
|
85 } |
|
86 else |
|
87 { |
|
88 err = KErrInUse; |
|
89 } |
|
90 CSPLOGSTRING2( CSPREQOUT, |
|
91 "CSPTransferProvider::AttendedTransfer: err: %d", err ); |
|
92 // return error value |
|
93 return err; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Transfers the call. CCE maps CS Transfer() to this method. |
|
98 // (UnattendedTransfer and others are VoIP features) |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CSPTransferProvider::AttendedTransfer( const TDesC& /*aTransferTarget*/ ) |
|
102 { |
|
103 TInt err ( KErrNone ); |
|
104 |
|
105 if ( !IsActive() ) |
|
106 { |
|
107 if ( iCall.SubSessionHandle() != 0 ) |
|
108 { |
|
109 err = KErrNone; |
|
110 // send async request to Etel |
|
111 iCall.Transfer( iStatus ); |
|
112 SetActive(); |
|
113 } |
|
114 else |
|
115 { |
|
116 // transfer not allowed |
|
117 err = KErrNotSupported; |
|
118 } |
|
119 } |
|
120 else |
|
121 { |
|
122 err = KErrInUse; |
|
123 } |
|
124 CSPLOGSTRING2( CSPREQOUT, |
|
125 "CSPTransferProvider::AttendedTransfer: err: %d", err ); |
|
126 // return error value |
|
127 return err; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Not supported by CS Plug-in. This is a VoIP feature |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CSPTransferProvider::UnattendedTransfer( const TDesC& /*aTransferTarget*/ ) |
|
135 { |
|
136 return KErrNotSupported; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // Not supported by CS Plug-in. This is a VoIP feature |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CSPTransferProvider::AcceptTransfer( const TBool /*aAccept*/ ) |
|
144 { |
|
145 return KErrNotSupported; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Not supported by CS Plug-in. This is a VoIP feature |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 const TDesC& CSPTransferProvider::TransferTarget() const |
|
153 { |
|
154 return KNullDesC; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Notify observers about an occurred transfer event |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CSPTransferProvider::TransferEventOccurred( |
|
162 const MCCPTransferObserver::TCCPTransferEvent aEvent ) |
|
163 { |
|
164 CSPLOGSTRING2( CSPREQOUT, |
|
165 "CSPTransferProvider::TransferEventOccurred: event: %d", aEvent ); |
|
166 |
|
167 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
168 { |
|
169 MCCPTransferObserver *obs = iObservers[i]; |
|
170 if ( obs ) |
|
171 { |
|
172 iObservers[i]->TransferEventOccurred( aEvent ); |
|
173 } |
|
174 } |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Adds observer to array |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CSPTransferProvider::AddObserverL( const MCCPTransferObserver& aObserver ) |
|
182 { |
|
183 if ( iObservers.Find( &aObserver ) == KErrNotFound ) |
|
184 { |
|
185 iObservers.Append( &aObserver ); |
|
186 } |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // Removes observer from array |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CSPTransferProvider::RemoveObserver( const MCCPTransferObserver& aObserver ) |
|
194 { |
|
195 TInt found = iObservers.Find( &aObserver ); |
|
196 if ( found != KErrNotFound ) |
|
197 { |
|
198 iObservers.Remove( found ); |
|
199 return KErrNone; |
|
200 } |
|
201 return found; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // From CActive. |
|
206 // Handles request completion. |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CSPTransferProvider::RunL() |
|
210 { |
|
211 CSPLOGSTRING2( CSPREQEND, |
|
212 "CSPTransferProvider::RunL: status: %d", iStatus.Int() ); |
|
213 |
|
214 if ( iStatus == KErrNone ) |
|
215 { |
|
216 MCCPTransferObserver::TCCPTransferEvent event = |
|
217 MCCPTransferObserver::ECCPLocalTransfer; |
|
218 TransferEventOccurred( event ); |
|
219 } |
|
220 else |
|
221 { |
|
222 CSPLOGSTRING2( CSPERROR, "CSPTransferProvider::RunL: Error \ |
|
223 %d", iStatus.Int() ); |
|
224 |
|
225 TInt error = iStatus.Int(); |
|
226 if ( error == KErrGsmCCFacilityRejected ) |
|
227 { |
|
228 iErrorObserver.NotifyErrorOccurred( ECCPErrorRejected ); |
|
229 } |
|
230 else if( error != KErrCancel ) |
|
231 { |
|
232 iErrorObserver.NotifyErrorOccurred( ECCPTransferFailed ); |
|
233 } |
|
234 } |
|
235 |
|
236 CSPLOGSTRING( CSPREQEND, "CSPTransferProvider::RunL End of RunL." ); |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // Cancels the pending async request |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CSPTransferProvider::DoCancel() |
|
244 { |
|
245 if ( iStatus == KRequestPending ) |
|
246 { |
|
247 CSPLOGSTRING( CSPINT, |
|
248 "CSPTransferProvider::DoCancel Canceling pending request.." ); |
|
249 // cancel request |
|
250 iCall.CancelAsyncRequest( EMobileCallTransfer ); |
|
251 } |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // Default C++ constructor |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 CSPTransferProvider::CSPTransferProvider( |
|
259 RMobileCall& aCall, |
|
260 MCSPCallErrorObserver& aErrorObserver, |
|
261 MCSPCommonInfo& aCommonInfo ) |
|
262 : CActive( EPriorityStandard ), |
|
263 iCall (aCall), |
|
264 iErrorObserver( aErrorObserver ), |
|
265 iCommonInfo( aCommonInfo ) |
|
266 { |
|
267 CSPLOGSTRING(CSPOBJECT, "CSPTransferProvider::CSPTransferProvider()" ); |
|
268 CActiveScheduler::Add( this ); |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // Constructing 2nd phase |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 void CSPTransferProvider::ConstructL() |
|
276 { |
|
277 CSPLOGSTRING(CSPOBJECT, "CSPTransferProvider::ConstructL()" ); |
|
278 } |
|
279 |
|
280 // End of File |
|
281 |