|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implementation for the VCC Init state |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "tvccstateinit.h" |
|
19 #include "cvccperformer.h" |
|
20 #include "vccsettingsreader.h" |
|
21 #include "rubydebug.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // c'tor |
|
25 // ----------------------------------------------------------------------------- |
|
26 // |
|
27 |
|
28 TVccStateInit::TVccStateInit() |
|
29 { |
|
30 RUBY_DEBUG_BLOCK( "TVccStateInit::TVccStateInit" ); |
|
31 } |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // Name |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 TUint TVccStateInit::Name() const |
|
38 { |
|
39 RUBY_DEBUG_BLOCK( "TVccStateInit::Name" ); |
|
40 return KVccStateInit; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // LinkState |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void TVccStateInit::LinkState(TVccState& aCalling) |
|
48 { |
|
49 RUBY_DEBUG_BLOCK( "TVccStateInit::LinkState" ); |
|
50 iCalling = &aCalling; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // Swap() |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 TInt TVccStateInit::Swap(MCCPCall& aCall) |
|
58 { |
|
59 RUBY_DEBUG_BLOCK( "TVccStateInit::Swap()" ); |
|
60 return aCall.Swap(); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // From MCCPCallObserver |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void TVccStateInit::ErrorOccurred( CVccPerformer& aContext, |
|
68 const TCCPError aError, |
|
69 MCCPCall* /*aCall*/ ) |
|
70 { |
|
71 RUBY_DEBUG_BLOCK( "TVccStateInit::ErrorOccurred" ); |
|
72 __ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant()); |
|
73 aContext.CallObserver()->ErrorOccurred( aError, |
|
74 aContext.PrimaryCall() ); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // From MCCPCallObserver |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void TVccStateInit::CallStateChanged( CVccPerformer& aContext, |
|
82 const MCCPCallObserver::TCCPCallState aState, |
|
83 MCCPCall* /*aCall*/ ) |
|
84 { |
|
85 RUBY_DEBUG_BLOCK( "TVccStateInit::CallStateChanged" ); |
|
86 __ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant()); |
|
87 //start trigger if call is connected, stop if not. |
|
88 if( aState == MCCPCallObserver::ECCPStateConnected ) |
|
89 { |
|
90 aContext.SetRemoteParties(); |
|
91 aContext.ActivateTrigger( ETrue ); |
|
92 |
|
93 } |
|
94 else |
|
95 { |
|
96 aContext.ActivateTrigger( EFalse ); |
|
97 } |
|
98 aContext.CallObserver()->CallStateChanged( aState, |
|
99 aContext.PrimaryCall()); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // From MCCPCallObserver |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void TVccStateInit::CallStateChangedWithInband( CVccPerformer& aContext, |
|
107 const MCCPCallObserver::TCCPCallState aState, |
|
108 MCCPCall* /*aCall*/ ) |
|
109 { |
|
110 RUBY_DEBUG_BLOCK( "TVccStateInit::CallStateChangedWithInband" ); |
|
111 __ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant()); |
|
112 aContext.CallObserver()->CallStateChangedWithInband( aState, |
|
113 aContext.PrimaryCall()); |
|
114 |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // From MCCPCallObserver |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void TVccStateInit::CallEventOccurred( CVccPerformer& aContext, |
|
122 const MCCPCallObserver::TCCPCallEvent aEvent, |
|
123 MCCPCall* aCall ) |
|
124 { |
|
125 RUBY_DEBUG_BLOCK( "TVccStateInit::CallEventOccurred" ); |
|
126 RUBY_DEBUG1( "TVccStateInit::CallEventOccurred, event: %d", aEvent ); |
|
127 __ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant()); |
|
128 |
|
129 if( aContext.PrimaryCall() == aCall ) |
|
130 { |
|
131 //if remote end holds the call HO is not allowed at this end either |
|
132 if( aEvent == MCCPCallObserver::ECCPRemoteHold ) |
|
133 { |
|
134 //Trigger is informed that automatic HO is not allowed. |
|
135 aContext.ActivateTrigger( EFalse ); |
|
136 //for manual HO PS key needs to be updated |
|
137 aContext.AllowHo( EFalse ); |
|
138 } |
|
139 |
|
140 else if( aEvent == MCCPCallObserver::ECCPRemoteResume ) |
|
141 { |
|
142 //HO is allowed again |
|
143 aContext.ActivateTrigger( ETrue ); |
|
144 //for manual HO PS key needs to be updated |
|
145 aContext.AllowHo( ETrue ); |
|
146 } |
|
147 else if( aEvent == MCCPCallObserver::ECCPNotifyRemotePartyInfoChange ) |
|
148 { |
|
149 aContext.SetRemoteParties(); |
|
150 } |
|
151 |
|
152 RUBY_DEBUG0("primary call event, forward it"); |
|
153 aContext.CallObserver()->CallEventOccurred( aEvent, |
|
154 aContext.PrimaryCall()); |
|
155 } |
|
156 |
|
157 } |
|
158 // ----------------------------------------------------------------------------- |
|
159 // From MCCPCallObserver |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void TVccStateInit::CallCapsChanged( CVccPerformer& aContext, |
|
163 const TUint32 aCapsFlags ) |
|
164 { |
|
165 RUBY_DEBUG_BLOCK( "TVccStateInit::CallCapsChanged" ); |
|
166 __ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant()); |
|
167 aContext.CallObserver()->CallCapsChanged( aCapsFlags, |
|
168 aContext.PrimaryCall() ); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // SwitchL() |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void TVccStateInit::SwitchL(CVccPerformer& aContext) |
|
176 { |
|
177 RUBY_DEBUG_BLOCKL( "TVccStateInit::SwitchL" ); |
|
178 |
|
179 __ASSERT_DEBUG(aContext.PrimaryCall()!=NULL, User::Invariant()); |
|
180 __ASSERT_ALWAYS(aContext.PrimaryCall()->State() == |
|
181 MCCPCallObserver::ECCPStateConnected,User::Leave(KErrAccessDenied)); |
|
182 |
|
183 if ( aContext.PrimaryCall()->Parameters().CallType() == |
|
184 CCPCall::ECallTypeCSVoice ) |
|
185 { |
|
186 RUBY_DEBUG0( "- make VoIP call" ); |
|
187 aContext.Notifier().NotifySubscriberL(EVccCsToPsHoStarted, KErrNone); |
|
188 CCCECallParameters* params = CCCECallParameters::NewL(); |
|
189 params->SetCallType( CCPCall::ECallTypePS ); |
|
190 params->SetServiceId( KErrNone ); |
|
191 TInt id = KErrNotFound; |
|
192 id = VccSettingsReader::VoIPServiceIdL(); |
|
193 __ASSERT_ALWAYS(id >= 0, User::Leave(KErrArgument)); |
|
194 params->SetServiceId( id ); |
|
195 HBufC* uri = NULL; |
|
196 uri = VccSettingsReader::DomainTransferUriL(); |
|
197 CleanupStack::PushL(uri); |
|
198 __ASSERT_ALWAYS (uri->Length() > 0, User::Leave(KErrArgument)); |
|
199 aContext.CreateSecondaryCallL(*params, *uri, aContext); |
|
200 CleanupStack::PopAndDestroy( uri ); //uri |
|
201 __ASSERT_DEBUG(aContext.SecondaryCall()!=NULL, User::Invariant()); |
|
202 //-> Set Next State (work around, VoIP should call CallStateChanged |
|
203 // only after Dial has returned) |
|
204 aContext.SetState(*iCalling); |
|
205 User::LeaveIfError(aContext.SecondaryCall()->Dial()); |
|
206 delete params; |
|
207 } |
|
208 else |
|
209 { |
|
210 RUBY_DEBUG0( "- make CS call" ); |
|
211 aContext.Notifier().NotifySubscriberL(EVccPsToCsHoStarted, KErrNone); |
|
212 |
|
213 CCCECallParameters* params = CCCECallParameters::NewL(); |
|
214 params->SetCallType( CCPCall::ECallTypeCSVoice ); |
|
215 params->SetServiceId( KErrNone ); |
|
216 |
|
217 TInt id = KErrNotFound; |
|
218 id = VccSettingsReader::CSServiceIdL(); |
|
219 __ASSERT_ALWAYS(id >= 0, User::Leave(KErrArgument)); |
|
220 params->SetServiceId( id ); |
|
221 HBufC* number = NULL; |
|
222 number = VccSettingsReader::DomainTransferNumberL(); |
|
223 CleanupStack::PushL( number ); |
|
224 __ASSERT_ALWAYS (number->Length() > 0, User::Leave(KErrArgument)); |
|
225 // the events will come to the context |
|
226 aContext.CreateSecondaryCallL(*params, *number, aContext); |
|
227 CleanupStack::PopAndDestroy( number ); //number |
|
228 __ASSERT_DEBUG(aContext.SecondaryCall()!=NULL, User::Invariant()); |
|
229 //-> Set Next State (work around, VoIP should call CallStateChanged |
|
230 // only after Dial has returned) |
|
231 aContext.SetState(*iCalling); |
|
232 |
|
233 //not used by cs-plugin |
|
234 User::LeaveIfError(static_cast<MCCPCSCall*> |
|
235 (aContext.SecondaryCall())->Dial(KNullDesC8)); |
|
236 delete params; |
|
237 } |
|
238 } |