|
1 /* |
|
2 * Component Name: Headset Simulator |
|
3 * Author: Comarch S.A. |
|
4 * Version: 1.0 |
|
5 * Copyright (c) 2010 Comarch S.A. |
|
6 * |
|
7 * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on |
|
8 * the basis of the Member Contribution Agreement entered between Comarch S.A. |
|
9 * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be |
|
10 * used only in accordance with the terms and conditions of the Agreement. |
|
11 * Any other usage, duplication or redistribution of this Software is not |
|
12 * allowed without written permission of Comarch S.A. |
|
13 * |
|
14 */ |
|
15 |
|
16 #include "hsprofilemanager.h" |
|
17 #include "debug.h" |
|
18 |
|
19 CHsProfileManager::CHsProfileManager() |
|
20 { |
|
21 } |
|
22 |
|
23 CHsProfileManager::~CHsProfileManager() |
|
24 { |
|
25 TRACE_FUNC_ENTRY |
|
26 DestroyProfile(); |
|
27 DestroyCodL(); |
|
28 DestroySdpL(); |
|
29 REComSession::FinalClose(); |
|
30 |
|
31 TRACE_FUNC_EXIT |
|
32 } |
|
33 |
|
34 CHsProfileManager* CHsProfileManager::NewLC() |
|
35 { |
|
36 CHsProfileManager* self = new ( ELeave ) CHsProfileManager(); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CHsProfileManager* CHsProfileManager::NewL() |
|
43 { |
|
44 CHsProfileManager* self = CHsProfileManager::NewLC(); |
|
45 CleanupStack::Pop( self ); // self; |
|
46 return self; |
|
47 } |
|
48 |
|
49 void CHsProfileManager::ConstructL() |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 void CHsProfileManager::LookupAndManageProfileL( const TUid aProfileUid ) |
|
55 { |
|
56 TRACE_FUNC_ENTRY |
|
57 |
|
58 DestroyProfile(); |
|
59 iProfilePlugin = CHsProfileBase::NewL( aProfileUid ); |
|
60 |
|
61 TRACE_FUNC_EXIT |
|
62 } |
|
63 |
|
64 void CHsProfileManager::LookupAndManageProfileL( const TDesC8 &aProfileName ) |
|
65 { |
|
66 TRACE_FUNC_ENTRY |
|
67 |
|
68 DestroyProfile(); |
|
69 iProfilePlugin = CHsProfileBase::NewL( aProfileName ); |
|
70 |
|
71 TRACE_FUNC_EXIT |
|
72 } |
|
73 |
|
74 void CHsProfileManager::UnloadProfile() |
|
75 { |
|
76 TRACE_FUNC_ENTRY |
|
77 |
|
78 if ( iProfilePlugin ) |
|
79 { |
|
80 delete iProfilePlugin; |
|
81 iProfilePlugin = NULL; |
|
82 } |
|
83 |
|
84 TRACE_FUNC_EXIT |
|
85 } |
|
86 |
|
87 void CHsProfileManager::LookupAndManageSdpL( const TUid aSdpUid ) |
|
88 { |
|
89 TRACE_FUNC_ENTRY |
|
90 |
|
91 DestroySdpL(); |
|
92 |
|
93 iSdpPlugin = CHsSdpBase::NewL( aSdpUid ); |
|
94 iSdpPlugin->SetServicePort( iSdpServicePort ); |
|
95 |
|
96 TRACE_FUNC_EXIT |
|
97 } |
|
98 |
|
99 void CHsProfileManager::LookupAndManageSdpL( const TDesC8 &aSdpName ) |
|
100 { |
|
101 TRACE_FUNC_ENTRY |
|
102 |
|
103 DestroySdpL(); |
|
104 |
|
105 iSdpPlugin = CHsSdpBase::NewL( aSdpName ); |
|
106 iSdpPlugin->SetServicePort( iSdpServicePort ); |
|
107 |
|
108 TRACE_FUNC_EXIT |
|
109 } |
|
110 |
|
111 void CHsProfileManager::LoadSdpL() |
|
112 { |
|
113 TRACE_FUNC_ENTRY |
|
114 |
|
115 User::LeaveIfNull( iSdpPlugin ); |
|
116 if ( iSdpSet ) |
|
117 { |
|
118 TRAP_IGNORE( iSdpPlugin->DeleteSdpRecordL() ); |
|
119 iSdpSet = EFalse; |
|
120 } |
|
121 iSdpPlugin->SetServicePort( iSdpServicePort ); |
|
122 iSdpPlugin->CreateSdpRecordL(); |
|
123 iSdpSet = ETrue; |
|
124 |
|
125 TRACE_FUNC_EXIT |
|
126 } |
|
127 |
|
128 void CHsProfileManager::UnloadSdpL() |
|
129 { |
|
130 TRACE_FUNC_ENTRY |
|
131 |
|
132 User::LeaveIfNull( iSdpPlugin ); |
|
133 if ( iSdpSet ) |
|
134 { |
|
135 iSdpPlugin->DeleteSdpRecordL(); |
|
136 iSdpSet = EFalse; |
|
137 } |
|
138 |
|
139 TRACE_FUNC_EXIT |
|
140 } |
|
141 |
|
142 void CHsProfileManager::SetSdpServicePort( TInt aPort ) |
|
143 { |
|
144 TRACE_FUNC_ENTRY |
|
145 if ( iSdpPlugin ) |
|
146 { |
|
147 iSdpPlugin->SetServicePort( aPort ); |
|
148 } |
|
149 iSdpServicePort = aPort; |
|
150 TRACE_FUNC_EXIT |
|
151 } |
|
152 |
|
153 void CHsProfileManager::RefreshSdp() |
|
154 { |
|
155 TRACE_FUNC_ENTRY |
|
156 if ( iSdpPlugin ) |
|
157 { |
|
158 TRAP_IGNORE( iSdpPlugin->DeleteSdpRecordL() ); |
|
159 iSdpSet = EFalse; |
|
160 TRAPD( err, iSdpPlugin->CreateSdpRecordL() ); |
|
161 if ( KErrNone == err ) |
|
162 { |
|
163 iSdpSet = ETrue; |
|
164 } |
|
165 } |
|
166 TRACE_FUNC_EXIT |
|
167 } |
|
168 |
|
169 void CHsProfileManager::LookupAndManageCodL( const TUid aCoDUid ) |
|
170 { |
|
171 TRACE_FUNC_ENTRY |
|
172 |
|
173 DestroyCodL(); |
|
174 iCoDPlugin = CHsCoDBase::NewL( aCoDUid ); |
|
175 User::LeaveIfError( iCoDPlugin->SaveOldCod() ); |
|
176 |
|
177 TRACE_FUNC_EXIT |
|
178 } |
|
179 |
|
180 void CHsProfileManager::LookupAndManageCodL( const TDesC8 &aCoDName ) |
|
181 { |
|
182 TRACE_FUNC_ENTRY |
|
183 |
|
184 DestroyCodL(); |
|
185 iCoDPlugin = CHsCoDBase::NewL( aCoDName ); |
|
186 User::LeaveIfError( iCoDPlugin->SaveOldCod() ); |
|
187 |
|
188 TRACE_FUNC_EXIT |
|
189 } |
|
190 |
|
191 void CHsProfileManager::LoadCodL() |
|
192 { |
|
193 TRACE_FUNC_ENTRY |
|
194 if ( iCoDPlugin ) |
|
195 { |
|
196 iCoDPlugin->SetNewCodL(); |
|
197 } |
|
198 TRACE_FUNC_EXIT |
|
199 } |
|
200 |
|
201 void CHsProfileManager::UnloadCodL() |
|
202 { |
|
203 TRACE_FUNC_ENTRY |
|
204 if ( iCoDPlugin ) |
|
205 { |
|
206 User::LeaveIfError( iCoDPlugin->RestoreOldCod() ); |
|
207 } |
|
208 TRACE_FUNC_EXIT |
|
209 } |
|
210 |
|
211 void CHsProfileManager::DestroyProfile() |
|
212 { |
|
213 TRACE_FUNC_ENTRY |
|
214 if ( iProfilePlugin ) |
|
215 { |
|
216 delete iProfilePlugin; |
|
217 iProfilePlugin = NULL; |
|
218 } |
|
219 TRACE_FUNC_EXIT |
|
220 } |
|
221 |
|
222 void CHsProfileManager::DestroySdpL() |
|
223 { |
|
224 TRACE_FUNC_ENTRY |
|
225 if ( iSdpPlugin ) |
|
226 { |
|
227 iSdpPlugin->DeleteSdpRecordL(); |
|
228 delete iSdpPlugin; |
|
229 iSdpPlugin = NULL; |
|
230 } |
|
231 TRACE_FUNC_EXIT |
|
232 } |
|
233 |
|
234 void CHsProfileManager::DestroyCodL() |
|
235 { |
|
236 TRACE_FUNC_ENTRY |
|
237 TInt err; |
|
238 if ( iCoDPlugin ) |
|
239 { |
|
240 err = iCoDPlugin->RestoreOldCod(); |
|
241 TRACE_INFO((_L("RestoreOldCoD method returned value %d"), err)) |
|
242 delete iCoDPlugin; |
|
243 iCoDPlugin = NULL; |
|
244 User::LeaveIfError( err ); |
|
245 } |
|
246 TRACE_FUNC_EXIT |
|
247 } |
|
248 |
|
249 TBool CHsProfileManager::IsSdpPluginLoaded() |
|
250 { |
|
251 return iSdpPlugin ? ETrue : EFalse; |
|
252 } |
|
253 |
|
254 TBool CHsProfileManager::IsProfilePluginLoaded() |
|
255 { |
|
256 return iProfilePlugin ? ETrue : EFalse; |
|
257 } |
|
258 |
|
259 TBool CHsProfileManager::IsCoDPluginLoaded() |
|
260 { |
|
261 return iCoDPlugin ? ETrue : EFalse; |
|
262 } |
|
263 |
|
264 void CHsProfileManager::HandleCommandL( const TDesC8 &aCommandsIn, |
|
265 TDes8 &aCommandOut, TBool aFromAG ) |
|
266 { |
|
267 TRACE_FUNC_ENTRY |
|
268 User::LeaveIfNull( iProfilePlugin ); |
|
269 |
|
270 iProfilePlugin->HandleCommandL( aCommandsIn, aCommandOut, aFromAG ); |
|
271 |
|
272 TRACE_FUNC_EXIT |
|
273 } |
|
274 |
|
275 void CHsProfileManager::HandleClientDisconnected( TInt aErr ) |
|
276 { |
|
277 TRACE_FUNC_ENTRY |
|
278 if ( iProfilePlugin ) |
|
279 { |
|
280 iProfilePlugin->HandleClientDisconnected( aErr ); |
|
281 } |
|
282 |
|
283 TRACE_FUNC_EXIT |
|
284 } |
|
285 |
|
286 void CHsProfileManager::HandleClientConnected( TDes8& aCommandOut ) |
|
287 { |
|
288 TRACE_FUNC_ENTRY |
|
289 if ( iProfilePlugin ) |
|
290 { |
|
291 iProfilePlugin->HandleClientConnected( aCommandOut ); |
|
292 } |
|
293 |
|
294 TRACE_FUNC_EXIT |
|
295 } |
|
296 |
|
297 void CHsProfileManager::AcceptIncomingCallL( TDes8& aProfileResponse ) |
|
298 { |
|
299 TRACE_FUNC_ENTRY |
|
300 if ( iProfilePlugin ) |
|
301 { |
|
302 iProfilePlugin->HandleAcceptCallL( aProfileResponse ); |
|
303 } |
|
304 |
|
305 TRACE_FUNC_EXIT |
|
306 } |
|
307 |
|
308 void CHsProfileManager::ReleaseOngoingCallL( TDes8& aProfileResponse ) |
|
309 { |
|
310 TRACE_FUNC_ENTRY |
|
311 if ( iProfilePlugin ) |
|
312 { |
|
313 iProfilePlugin->HandleReleaseCallL( aProfileResponse ); |
|
314 } |
|
315 TRACE_FUNC_EXIT |
|
316 } |
|
317 |