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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // USER |
|
20 #include "mustestdirector.h" |
|
21 #include <musmanagercommon.h> |
|
22 #include "mussessionproperties.h" |
|
23 #include "musresourceproperties.h" |
|
24 #include "mussesseioninformationapi.h" |
|
25 #include "mussettingskeys.h" |
|
26 #include "mussettings.inl" |
|
27 |
|
28 #include <e32property.h> |
|
29 #include <e32base.h> |
|
30 #include <e32err.h> |
|
31 #include <QDebug> |
|
32 |
|
33 _LIT(KTestTelNumber,"+358504869612"); |
|
34 _LIT( KTestCallProvider,"MultimediaSharing" ); |
|
35 _LIT( KTestRemoteSipAddress,"sip:siva@musworld.com" ); |
|
36 _LIT( KTestRemoteSipAddressProposal,"sip:wondering@nokia.com,sip:package@gone.com" ); |
|
37 _LIT( KTestContactName,"Michel Jackson" ); |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMusTestDirector::CMusTestDirector() |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 |
|
53 CMusTestDirector* CMusTestDirector::NewL() |
|
54 { |
|
55 CMusTestDirector* self = new( ELeave )CMusTestDirector(); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 |
|
66 void CMusTestDirector::ConstructL() |
|
67 { |
|
68 DefinePropertiesL(); |
|
69 } |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 |
|
75 CMusTestDirector::~CMusTestDirector() |
|
76 { |
|
77 DeleteProperties(); |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 |
|
86 void CMusTestDirector::ConfigureLiveSharing( ) |
|
87 { |
|
88 SetUseCase( MultimediaSharing::EMusLiveVideo ); |
|
89 |
|
90 TInt error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMusTelNumber, KTestTelNumber); |
|
91 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
92 |
|
93 error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMusCallDirection, NMusSessionInformationApi::ECallOrginated); |
|
94 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
95 |
|
96 error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMUSCallProvider, KTestCallProvider); |
|
97 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 |
|
105 void CMusTestDirector::ConfigureReceiveSharing( ) |
|
106 { |
|
107 SetUseCase( MultimediaSharing::EMusReceive ); |
|
108 |
|
109 TInt error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMusTelNumber, KTestTelNumber); |
|
110 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
111 |
|
112 error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMusCallDirection, NMusSessionInformationApi::ECallOrginated); |
|
113 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
114 |
|
115 error = RProperty::Set( NMusResourceApi::KCategoryUid, NMusSessionInformationApi::KMUSCallProvider, KTestCallProvider); |
|
116 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
117 } |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 |
|
123 void CMusTestDirector::SetUseCase( MultimediaSharing::TMusUseCase aUseCase ) |
|
124 { |
|
125 TInt err = RProperty::Set( NMusSessionApi::KCategoryUid, NMusSessionApi::KUseCase, ( TInt )aUseCase); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMusAoPlugin::DefineResourcePropertiesL() |
|
130 // Note : Ignore Define Errors . Because if define fails for sure Set |
|
131 // will fail too . But there are some cases in Define Error should |
|
132 // be ignored like KErrAlreadyExists , KErrPersmissionDenied.So It |
|
133 // could be better if we dont care Define Error but care about Set Err. |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMusTestDirector::DefinePropertiesL() |
|
137 { |
|
138 MUS_LOG( "mus: [TEST] -> CMusAoPlugin::DefineResourceProperties") ; |
|
139 // define resource properties |
|
140 // they need to be defined here to make them exist always |
|
141 // Read from cenrep key about the availability of camera and keypad |
|
142 // if the availability is dynamic then define a key else no. |
|
143 MusSettingsKeys::TAvailability camera = MusSettingsKeys::EAvailabilityStatic; |
|
144 MusSettingsKeys::TAvailability keypad = MusSettingsKeys::EAvailabilityStatic ; |
|
145 MultimediaSharingSettings::ResourceAvailability(camera,keypad); |
|
146 if( camera == MusSettingsKeys::EAvailabilityDynamic ) |
|
147 { |
|
148 DefinePropertyL(NMusResourceApi::KCameraAvailability, |
|
149 RProperty::EInt,( TInt ) NMusResourceApi::ENotAvailable); |
|
150 } |
|
151 if( keypad == MusSettingsKeys::EAvailabilityDynamic ) |
|
152 { |
|
153 DefinePropertyL(NMusResourceApi::KKeypadAvailability, |
|
154 RProperty::EInt,( TInt ) NMusResourceApi::ENotAvailable); |
|
155 } |
|
156 DefinePropertyL(NMusResourceApi::KCameraInformation, |
|
157 RProperty::EInt,( TInt ) NMusResourceApi::EUsePrimaryCamera); |
|
158 DefinePropertyL(NMusSessionInformationApi::KMusCallEvent, |
|
159 RProperty::EInt,( TInt ) NMusSessionInformationApi::ENoCall); |
|
160 DefinePropertyL(NMusSessionInformationApi::KMusCallCount,RProperty::EInt,0); |
|
161 |
|
162 DefinePropertyL(NMusSessionInformationApi::KMusTelNumber, |
|
163 RProperty::EText,KTestTelNumber); |
|
164 DefinePropertyL(NMusSessionInformationApi::KMUSForbidden, |
|
165 RProperty::EInt,( TInt ) NMusSessionInformationApi::EMUSAllowed); |
|
166 DefinePropertyL(NMusSessionInformationApi::KMusCallDirection, |
|
167 RProperty::EInt,( TInt ) NMusSessionInformationApi::ENoDirection); |
|
168 |
|
169 DefinePropertyL(NMusSessionInformationApi::KMUSCallProvider, |
|
170 RProperty::EText,KTestCallProvider); |
|
171 |
|
172 DefineSessionPropertyL(NMusSessionApi::KUseCase, |
|
173 RProperty::EInt,MultimediaSharing::EMusLiveVideo); |
|
174 |
|
175 DefineSessionPropertyL(NMusSessionApi::KStatus, |
|
176 RProperty::EInt,MultimediaSharing::EMultimediaSharingAvailable); |
|
177 |
|
178 DefineSessionPropertyL(NMusSessionApi::KTelNumber, |
|
179 RProperty::EText,KTestTelNumber); |
|
180 |
|
181 DefineSessionPropertyL(NMusSessionApi::KRemoteSipAddress, |
|
182 RProperty::EText,KTestRemoteSipAddress); |
|
183 |
|
184 DefineSessionPropertyL(NMusSessionApi::KRemoteSipAddressProposal, |
|
185 RProperty::EText,KTestRemoteSipAddressProposal); |
|
186 |
|
187 DefineSessionPropertyL(NMusSessionApi::KContactId, |
|
188 RProperty::EInt,1); |
|
189 |
|
190 DefineSessionPropertyL(NMusSessionApi::KContactName, |
|
191 RProperty::EText,KTestContactName); |
|
192 |
|
193 DefineSessionPropertyL(NMusSessionApi::KSipProfileId, |
|
194 RProperty::EInt,1); |
|
195 |
|
196 CRepository* repository = CRepository::NewL(MusSettingsKeys::KRepositoryUid); |
|
197 TInt uid = 0; |
|
198 TBool exist = (repository->Get(MusSettingsKeys::KEncodingDevice,uid) == KErrNone); |
|
199 if( !exist ) |
|
200 { |
|
201 TInt uid = 1234; |
|
202 repository->Create(MusSettingsKeys::KEncodingDevice,uid); |
|
203 TUint32 modifiedKeyCount(0); |
|
204 User::LeaveIfError(repository->CommitTransaction(modifiedKeyCount)); |
|
205 } |
|
206 delete repository; |
|
207 |
|
208 MUS_LOG( "mus: [TEST] <- CMusAoPlugin::DefineResourceProperties" ) |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMusAoPlugin::DefineProperty() |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CMusTestDirector::DefineSessionPropertyL(TInt aKey,RProperty::TType aType,TInt aVal) |
|
216 { |
|
217 MUS_LOG( "mus: [TEST] -> CMusTestDirector::DefineSessionPropertyL( intValue )" ) |
|
218 |
|
219 TInt error = RProperty::Define( NMusSessionApi::KCategoryUid, |
|
220 aKey, |
|
221 aType ); |
|
222 MUS_LOG2( "mus: [TEST] Key=%d defining tried, return=%d", aKey, error ) |
|
223 |
|
224 if ( error == KErrNone ) |
|
225 { |
|
226 error = RProperty::Set( NMusSessionApi::KCategoryUid, aKey, aVal ); |
|
227 MUS_LOG2( "mus: [TEST] RProperty value %d set, return = %d", |
|
228 aVal, error ) |
|
229 User::LeaveIfError( error ); |
|
230 } |
|
231 else |
|
232 { |
|
233 MUS_LOG( "mus: [TEST] Defining failed, do not set value" ) |
|
234 } |
|
235 |
|
236 MUS_LOG( "mus: [TEST] <- CMusTestDirector::DefineSessionPropertyL( intValue )" ) |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CTESTPlugin::DefineProperty() |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CMusTestDirector::DefineSessionPropertyL( TInt aKey, |
|
244 RProperty::TType aType, |
|
245 const TDesC& aVal ) |
|
246 { |
|
247 MUS_LOG( "mus: [TEST] -> CTESTPlugin::DefineSessionPropertyL( DesCValue )" ) |
|
248 |
|
249 TInt error = RProperty::Define( NMusSessionApi::KCategoryUid, |
|
250 aKey, |
|
251 aType ); |
|
252 MUS_LOG2( "mus: [TEST] Key=%d defining tried, return=%d", aKey, error ) |
|
253 |
|
254 if ( error == KErrNone ) |
|
255 { |
|
256 error = RProperty::Set( NMusSessionApi::KCategoryUid, aKey, aVal); |
|
257 MUS_LOG_TDESC( "mus: [TEST] Tried to set RProperty value: ", aVal ) |
|
258 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
259 User::LeaveIfError( error ); |
|
260 } |
|
261 else |
|
262 { |
|
263 MUS_LOG( "mus: [TEST] Defining failed, do not set value" ) |
|
264 } |
|
265 |
|
266 MUS_LOG( "mus: [TEST] <- CTESTPlugin::DefineSessionPropertyL( DesCValue )" ) |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CMusAoPlugin::DefineProperty() |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CMusTestDirector::DefinePropertyL(TInt aKey,RProperty::TType aType,TInt aVal) |
|
274 { |
|
275 MUS_LOG( "mus: [TEST] -> CMusAoPlugin::DefinePropertyL( intValue )" ) |
|
276 |
|
277 TInt error = RProperty::Define( NMusResourceApi::KCategoryUid, |
|
278 aKey, |
|
279 aType ); |
|
280 MUS_LOG2( "mus: [TEST] Key=%d defining tried, return=%d", aKey, error ) |
|
281 |
|
282 if ( error == KErrNone ) |
|
283 { |
|
284 error = RProperty::Set( NMusResourceApi::KCategoryUid, aKey, aVal ); |
|
285 MUS_LOG2( "mus: [TEST] RProperty value %d set, return = %d", |
|
286 aVal, error ) |
|
287 User::LeaveIfError( error ); |
|
288 } |
|
289 else |
|
290 { |
|
291 MUS_LOG( "mus: [TEST] Defining failed, do not set value" ) |
|
292 } |
|
293 |
|
294 MUS_LOG( "mus: [TEST] <- CTESTPlugin::DefinePropertyL( intValue )" ) |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CTESTPlugin::DefineProperty() |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 void CMusTestDirector::DefinePropertyL( TInt aKey, |
|
302 RProperty::TType aType, |
|
303 const TDesC& aVal ) |
|
304 { |
|
305 MUS_LOG( "mus: [TEST] -> CTESTPlugin::DefinePropertyL( DesCValue )" ) |
|
306 |
|
307 TInt error = RProperty::Define( NMusResourceApi::KCategoryUid, |
|
308 aKey, |
|
309 aType ); |
|
310 MUS_LOG2( "mus: [TEST] Key=%d defining tried, return=%d", aKey, error ) |
|
311 |
|
312 if ( error == KErrNone ) |
|
313 { |
|
314 error = RProperty::Set( NMusResourceApi::KCategoryUid, aKey, aVal); |
|
315 MUS_LOG_TDESC( "mus: [TEST] Tried to set RProperty value: ", aVal ) |
|
316 MUS_LOG1("mus: [TEST] return value = %d",error ) |
|
317 User::LeaveIfError( error ); |
|
318 } |
|
319 else |
|
320 { |
|
321 MUS_LOG( "mus: [TEST] Defining failed, do not set value" ) |
|
322 } |
|
323 |
|
324 MUS_LOG( "mus: [TEST] <- CTESTPlugin::DefinePropertyL( DesCValue )" ) |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CTESTPlugin::DeleteSessionProperties() |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CMusTestDirector::DeleteSessionProperties() |
|
332 { |
|
333 TInt retVal = RProperty::Delete( NMusSessionApi::KCategoryUid,NMusSessionApi::KStatus); |
|
334 retVal = RProperty::Delete( NMusSessionApi::KCategoryUid,NMusSessionApi::KRemoteSipAddress); |
|
335 retVal = RProperty::Delete( NMusSessionApi::KCategoryUid,NMusSessionApi::KRemoteSipAddressProposal); |
|
336 retVal = RProperty::Delete( NMusSessionApi::KCategoryUid,NMusSessionApi::KContactId); |
|
337 retVal = RProperty::Delete( NMusSessionApi::KCategoryUid,NMusSessionApi::KContactName); |
|
338 } |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CTESTPlugin::DeleteResourceProperties() |
|
341 // Note : There is no need of caring the return value in deleting |
|
342 // This will be called when AO Plugin destroyed which is rare to happen |
|
343 // Any unwanted deletion of AO Plugin should leave some PS Keys open. |
|
344 // But this is OK if we ignore KErrAlreadyExists while defining next time. |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CMusTestDirector::DeleteProperties() |
|
348 { |
|
349 MUS_LOG( "mus: [TEST] -> CTESTPlugin::DeleteResourcePropertiesL" ) |
|
350 // Delete resource properties |
|
351 // they need to be defined here to make them exist always |
|
352 DeleteProperty(NMusResourceApi::KCameraAvailability); |
|
353 DeleteProperty(NMusResourceApi::KKeypadAvailability); |
|
354 DeleteProperty(NMusResourceApi::KCameraInformation); |
|
355 DeleteProperty(NMusSessionInformationApi::KMusCallEvent); |
|
356 DeleteProperty(NMusSessionInformationApi::KMusCallCount); |
|
357 DeleteProperty(NMusSessionInformationApi::KMusTelNumber); |
|
358 DeleteProperty(NMusSessionInformationApi::KMUSCallProvider); |
|
359 DeleteProperty(NMusSessionInformationApi::KMUSForbidden); |
|
360 DeleteProperty(NMusSessionInformationApi::KMusCallDirection); |
|
361 MUS_LOG( "mus: [TEST] <- CTESTPlugin::DeleteResourcePropertiesL" ) |
|
362 } |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CTESTPlugin::DeleteProperty() |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void CMusTestDirector::DeleteProperty(TInt aKey) |
|
369 { |
|
370 TInt retVal = RProperty::Delete( NMusResourceApi::KCategoryUid,aKey); |
|
371 MUS_LOG2( "mus: [TEST] RProperty::Delete Type=%d return=%d",\ |
|
372 aKey, retVal ) |
|
373 } |
|