|
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: CVtCtlCallControl class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #pragma CTC SKIP |
|
20 // INCLUDE FILES |
|
21 #include <cvtlogger.h> |
|
22 #include "CVtCtlCallControl.h" |
|
23 #include "MVtCtlEventObserver.h" |
|
24 #include "CVtCtlSessionContainer.h" |
|
25 #include "CVtCtlVideoCall.h" |
|
26 #include "VtCtlTypes.h" |
|
27 #include <cvtlogger.h> |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CVtCtlCallControl::NewL |
|
33 // two-phase constructor |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CVtCtlCallControl* CVtCtlCallControl::NewL( |
|
37 MVtCtlEventObserver& aEventObserver ) |
|
38 { |
|
39 __VTPRINTENTER( "CVtCtlCallControl.NewL" ) |
|
40 CVtCtlCallControl* self = new ( ELeave ) |
|
41 CVtCtlCallControl( aEventObserver ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(); |
|
45 __VTPRINTEXIT( "CVtCtlCallControl.NewL" ) |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CVtCtlCallControl::~CVtCtlCallControl |
|
51 // Destructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CVtCtlCallControl::~CVtCtlCallControl() |
|
55 { |
|
56 __VTPRINTENTER( "CVtCtlCallControl.~" ) |
|
57 delete iContainer; |
|
58 // uninitialize logging (if enabled) |
|
59 VTLOGUNINIT |
|
60 __VTPRINTEXIT( "CVtCtlCallControl.~" ) |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CVtCtlCallControl::CVtCtlCallControl |
|
65 // c++ constructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CVtCtlCallControl::CVtCtlCallControl( |
|
69 MVtCtlEventObserver& aEventObserver ) : |
|
70 iEventObserver( aEventObserver ) |
|
71 { |
|
72 __VTPRINTENTER( "CVtCtlCallControl.CVtCtlCallControl" ) |
|
73 __VTPRINTEXIT( "CVtCtlCallControl.CVtCtlCallControl" ) |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CVtCtlCallControl::ConstructL |
|
79 // |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CVtCtlCallControl::ConstructL() |
|
83 { |
|
84 __VTPRINTENTER( "CVtCtlCallControl.ConstructL" ) |
|
85 // initialize logging (if enabled) |
|
86 VTLOGINIT |
|
87 iContainer = CVtCtlSessionContainer::NewL( *this ); |
|
88 __VTPRINTEXIT( "CVtCtlCallControl.ConstructL" ) |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CVtCtlCallControl::GetDuration |
|
93 // |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CVtCtlCallControl::GetDuration( |
|
97 TVtCtlSessionId aId, |
|
98 TVtCtlDuration& aDuration ) |
|
99 { |
|
100 __VTPRINTENTER( "CVtCtlCallControl.GetDuration" ) |
|
101 CVtCtlVideoCall* call = iContainer->FindCall( aId ); |
|
102 TInt err( KErrNotFound ); |
|
103 if ( call ) |
|
104 { |
|
105 err = call->GetDuration( aDuration ); |
|
106 } |
|
107 __VTPRINTEXIT( "CVtCtlCallControl.GetDuration" ) |
|
108 return err; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CVtCtlCallControl::GetSessionInfoL |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 /***************************************************** |
|
117 * Series 60 Customer / ETel |
|
118 * Series 60 ETel API |
|
119 *****************************************************/ |
|
120 void CVtCtlCallControl::GetSessionInfoL( |
|
121 TVtCtlSessionId aId, |
|
122 TDes8& aInfo ) |
|
123 { |
|
124 __VTPRINTENTER( "CVtCtlCallControl.GetSessionInfoL" ) |
|
125 ValidateDataExtensionL( aInfo, EVtCtlCSSessionInfoExtensionId ); |
|
126 CVtCtlVideoCall* call = iContainer->FindCall( aId ); |
|
127 if ( call ) |
|
128 { |
|
129 TPckg<TVtCtlCSSessionInfoV1>& pckg = |
|
130 reinterpret_cast<TPckg<TVtCtlCSSessionInfoV1>&>( aInfo ); |
|
131 TVtCtlCSSessionInfoV1& info = pckg(); |
|
132 TInt err( call->UpdateCallInfo() ); |
|
133 if ( err == KErrNone ) |
|
134 { |
|
135 const RMobileCall::TMobileCallInfoV1& mobileInfo = call->MobileInfo(); |
|
136 info.iDuration = mobileInfo.iDuration; |
|
137 info.iTelNumber = mobileInfo.iRemoteParty.iRemoteNumber.iTelNumber; |
|
138 __VTPRINT2( DEBUG_SESSION, "VtCtl: mobile dir=%d", |
|
139 mobileInfo.iRemoteParty.iDirection ) |
|
140 switch ( mobileInfo.iRemoteParty.iDirection ) |
|
141 { |
|
142 case RMobileCall::EMobileOriginated: |
|
143 info.iDirection = EDirectionMobileOriginated; |
|
144 break; |
|
145 case RMobileCall::EMobileTerminated: |
|
146 info.iDirection = DirectionMobileTerminated; |
|
147 break; |
|
148 case RMobileCall::EDirectionUnknown: |
|
149 default: |
|
150 info.iDirection = EDirectionUnknown; |
|
151 break; |
|
152 } |
|
153 } |
|
154 } |
|
155 else |
|
156 { |
|
157 __VTPRINT( DEBUG_SESSION, "CallCtrl.GetSessionInfoL not found" ) |
|
158 User::Leave( KErrNotFound ); |
|
159 } |
|
160 __VTPRINTEXIT( "CVtCtlCallControl.GetSessionInfoL" ) |
|
161 } |
|
162 |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CVtCtlCallControl::GetState |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 MVtCtlCallControl::TVtCtlState CVtCtlCallControl::GetSessionState( |
|
170 TVtCtlSessionId aId ) const |
|
171 { |
|
172 __VTPRINTENTER( "CVtCtlCallControl.GetSessionState" ) |
|
173 __VTPRINT2( DEBUG_SESSION, "CallCtrl.GetSessionState for id:%d",aId ) |
|
174 MVtCtlCallControl::TVtCtlState state = EUnknown; |
|
175 CVtCtlVideoCall* call = iContainer->FindCall( aId ); |
|
176 if ( call ) |
|
177 { |
|
178 call->GetCallState( state ); |
|
179 } |
|
180 __VTPRINT3( DEBUG_SESSION, " callPtr=%d state=%d", (TInt) call, state ) |
|
181 __VTPRINTEXIT( "CVtCtlCallControl.GetSessionState" ) |
|
182 return state; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CVtCtlCallControl::GetPreviousState |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 MVtCtlCallControl::TVtCtlState CVtCtlCallControl::GetPreviousPreviousState( |
|
191 TVtCtlSessionId aId ) const |
|
192 { |
|
193 __VTPRINTENTER( "CVtCtlCallControl.GetPreviousPreviousState" ) |
|
194 MVtCtlCallControl::TVtCtlState state = EUnknown; |
|
195 const CVtCtlVideoCall* call = iContainer->FindCall( aId ); |
|
196 if ( call ) |
|
197 { |
|
198 state = call->CallInfo().iPreviousStatus; |
|
199 } |
|
200 __VTPRINTEXIT( "CVtCtlCallControl.GetPreviousPreviousState" ) |
|
201 return state; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CVtCtlCallControl::HandleCallStatusChangeL |
|
206 // Notifies observer about call status change. |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CVtCtlCallControl::HandleCallStatusChangeL( |
|
210 TVtCtlSessionId aId, |
|
211 MVtCtlCallControl::TVtCtlState aStatus, |
|
212 MVtCtlCallControl::TVtCtlState aPreviousStatus ) |
|
213 { |
|
214 __VTPRINTENTER( "CVtCtlCallControl.HandleCallStatusChangeL" ) |
|
215 __VTPRINT2( DEBUG_SESSION, " status=%d", (TInt) aStatus ) |
|
216 |
|
217 TVtCtlSessionStateEvent event; |
|
218 event.iPreviousState = aPreviousStatus; |
|
219 event.iState = aStatus; |
|
220 event.iSessionId = aId; |
|
221 |
|
222 TAny* parameter = &event; |
|
223 iEventObserver.HandleVtSessionEventL( |
|
224 KVtCtlEventSessionStatusChanged, |
|
225 parameter ); |
|
226 __VTPRINTEXIT( "CVtCtlCallControl.HandleCallStatusChangeL" ) |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CVtCtlCallControl::ValidateDataExtensionL |
|
231 // Validates extension id of descriptor representation of data type. |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CVtCtlCallControl::ValidateDataExtensionL( |
|
235 TDesC8& aData, |
|
236 TInt aExtension ) |
|
237 { |
|
238 __VTPRINTENTER( "CVtCtlCallControl.ValidateDataExtensionL" ) |
|
239 TVtCtlType type; |
|
240 TPckg<TVtCtlType> pckg(type); |
|
241 TPtrC8 ptr( aData.Ptr(), sizeof( TVtCtlType ) ); |
|
242 pckg.Copy( ptr ); |
|
243 if ( type.Extension() != aExtension ) |
|
244 { |
|
245 __VTPRINT( DEBUG_SESSION, "CallCtrl.Validate not supported" ) |
|
246 User::Leave( KErrNotSupported ); |
|
247 } |
|
248 __VTPRINTEXIT( "CVtCtlCallControl.ValidateDataExtensionL" ) |
|
249 } |
|
250 #pragma CTC ENDSKIP |
|
251 // End of File |
|
252 |