|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Contains implementation of CTestUPnPManager class |
|
15 // Contains implemenatation of CTestUPnPManager, CUPnPObserver, CUPnPTimer, |
|
16 // and CAction classes |
|
17 // |
|
18 // |
|
19 |
|
20 #include "testupnpmanager.h" |
|
21 |
|
22 |
|
23 /* |
|
24 Constructor: |
|
25 @internalTechnology |
|
26 @test |
|
27 */ |
|
28 CTestUPnPManager::CTestUPnPManager() |
|
29 : CTestStep() |
|
30 { |
|
31 iCancelDiscovery = EFalse; |
|
32 iExpectedData = EFalse; |
|
33 iDiscoverySuccess = EFalse; |
|
34 iNotifyCount = 0; |
|
35 iPublishCount = 0; |
|
36 iDescribeResponseCount = 0; |
|
37 iRenewCount = 0; |
|
38 iFailedNumUris = 0; |
|
39 } |
|
40 |
|
41 /* |
|
42 Initializes all member vaiables. |
|
43 @param None. |
|
44 @return None. |
|
45 */ |
|
46 void CTestUPnPManager::InitializeL() |
|
47 { |
|
48 iScheduler = new (ELeave) CActiveScheduler; |
|
49 CActiveScheduler::Install(iScheduler); |
|
50 |
|
51 _LIT(KInfoLogFile, "SequenceOperationsL().... \n"); |
|
52 INFO_PRINTF1(KInfoLogFile); |
|
53 TPtrC listOfSequences; |
|
54 _LIT(KListOfSequences, "listofsequences"); |
|
55 GetStringFromConfig(ConfigSection(), KListOfSequences, listOfSequences); |
|
56 |
|
57 TokenizeStringL(listOfSequences, iSequenceList); |
|
58 iNumOperations = iSequenceList.Count(); |
|
59 |
|
60 } |
|
61 |
|
62 /* |
|
63 Destructor |
|
64 @internalTechnology |
|
65 @test |
|
66 */ |
|
67 CTestUPnPManager::~CTestUPnPManager() |
|
68 { |
|
69 } |
|
70 |
|
71 void CTestUPnPManager::ClosePublisher() |
|
72 { |
|
73 _LIT(KInfoLogFile, "ClosePublisher....\n"); |
|
74 INFO_PRINTF1(KInfoLogFile); |
|
75 CancelPublish(); |
|
76 } |
|
77 |
|
78 void CTestUPnPManager::CloseDiscoverer() |
|
79 { |
|
80 iControlPoint.Close(); |
|
81 } |
|
82 |
|
83 void CTestUPnPManager::CleanUpObserverArray() |
|
84 { |
|
85 _LIT(KInfoLogFile, "CleanUpObserverArray....\n"); |
|
86 INFO_PRINTF1(KInfoLogFile); |
|
87 if (iObserverArray.Count() > 0 ) |
|
88 { |
|
89 iObserverArray.ResetAndDestroy(); |
|
90 } |
|
91 else |
|
92 { |
|
93 iObserverArray.Close(); |
|
94 } |
|
95 _LIT(KInfoLogFile1, "CleanUpObserverArray End....\n"); |
|
96 INFO_PRINTF1(KInfoLogFile1); |
|
97 } |
|
98 |
|
99 void CTestUPnPManager::CleanUpResultsArray() |
|
100 { |
|
101 _LIT(KInfoLogFile, "CleanUpResultsArray....\n"); |
|
102 INFO_PRINTF1(KInfoLogFile); |
|
103 TInt count = iResultsArray.Count(); |
|
104 for (TInt index(0); index < count ; index++ ) |
|
105 { |
|
106 iResultsArray[index]->Close(); |
|
107 } |
|
108 iResultsArray.Close(); |
|
109 _LIT(KInfoLogFile1, "CleanUpResultsArray End....\n"); |
|
110 INFO_PRINTF1(KInfoLogFile1); |
|
111 } |
|
112 |
|
113 void CTestUPnPManager::DescriptionSuiteCleanUp() |
|
114 { |
|
115 _LIT(KInfoLogFile, "DescriptionSuiteCleanUp....\n"); |
|
116 INFO_PRINTF1(KInfoLogFile); |
|
117 TInt count = iDescriptionSuiteArray.Count(); |
|
118 for (TInt index(0); index < count ; index++ ) |
|
119 { |
|
120 iDescriptionSuiteArray[index].iBaseUrl.Close(); |
|
121 iDescriptionSuiteArray[index].iDescription.Close(); |
|
122 DeleteSeriveUrlsList(index); |
|
123 } |
|
124 iDescriptionSuiteArray.Close(); |
|
125 _LIT(KInfoLogFile1, "DescriptionSuiteCleanUp End...\n"); |
|
126 INFO_PRINTF1(KInfoLogFile1); |
|
127 } |
|
128 |
|
129 void CTestUPnPManager::ScpdUriArrayCleanUp() |
|
130 { |
|
131 _LIT(KInfoLogFile, "ScpdUriArrayCleanUp....\n"); |
|
132 INFO_PRINTF1(KInfoLogFile); |
|
133 TInt count = iScpdUriArray.Count(); |
|
134 for (TInt index(0); index < count ; index++ ) |
|
135 { |
|
136 iScpdUriArray[index].Close(); |
|
137 } |
|
138 iScpdUriArray.Close(); |
|
139 _LIT(KInfoLogFile1, "ScpdUriArrayCleanUp End....\n"); |
|
140 INFO_PRINTF1(KInfoLogFile1); |
|
141 } |
|
142 |
|
143 void CTestUPnPManager::EventUriArrayCleanUp() |
|
144 { |
|
145 _LIT(KInfoLogFile, "EventUriArrayCleanUp....\n"); |
|
146 INFO_PRINTF1(KInfoLogFile); |
|
147 TInt count = iEventUriArray.Count(); |
|
148 for (TInt index(0); index < count ; index++ ) |
|
149 { |
|
150 iEventUriArray[index].Close(); |
|
151 } |
|
152 iEventUriArray.Close(); |
|
153 _LIT(KInfoLogFile1, "EventUriArrayCleanUp End....\n"); |
|
154 INFO_PRINTF1(KInfoLogFile1); |
|
155 } |
|
156 |
|
157 void CTestUPnPManager::ControlUriArrayCleanUp() |
|
158 { |
|
159 _LIT(KInfoLogFile, "ControlUriArrayCleanUp....\n"); |
|
160 INFO_PRINTF1(KInfoLogFile); |
|
161 TInt count = iControlUriArray.Count(); |
|
162 for (TInt index(0); index < count ; index++ ) |
|
163 { |
|
164 iControlUriArray[index].Close(); |
|
165 } |
|
166 iControlUriArray.Close(); |
|
167 _LIT(KInfoLogFile1, "ControlUriArrayCleanUp End....\n"); |
|
168 INFO_PRINTF1(KInfoLogFile1); |
|
169 } |
|
170 |
|
171 /* |
|
172 Implementation of CTestStep base class virtual and this is used for doing all |
|
173 initialisation common |
|
174 to derived classes here. |
|
175 @param None |
|
176 @return TVerdict |
|
177 */ |
|
178 TVerdict CTestUPnPManager::doTestStepPreambleL() |
|
179 { |
|
180 InitializeL(); |
|
181 SavePreviousLogFileL(); |
|
182 return CTestStep::doTestStepPreambleL(); |
|
183 } |
|
184 |
|
185 /* |
|
186 Save the previous log file...if any |
|
187 */ |
|
188 void CTestUPnPManager::SavePreviousLogFileL() |
|
189 { |
|
190 _LIT(KInfoLogFile, "Saving Previous logs If any.... \n"); |
|
191 INFO_PRINTF1(KInfoLogFile); |
|
192 RFs fileserv; |
|
193 TInt error = fileserv.Connect(); |
|
194 if(!error) |
|
195 { |
|
196 _LIT(KlogFile, "C:\\logs\\log.txt"); |
|
197 _LIT(KPrefixLog, "C:\\upnplogs\\"); |
|
198 _LIT(KSuffix, "_UDEB"); |
|
199 _LIT(KExtn, ".txt"); |
|
200 |
|
201 CFileMan* fMan = NULL; |
|
202 TRAP_IGNORE(fMan = CFileMan::NewL(fileserv)); |
|
203 if(fMan != NULL) |
|
204 { |
|
205 CleanupStack::PushL(fMan); |
|
206 RBuf newFileName; |
|
207 const TInt KTwentyFour = 24; |
|
208 newFileName.Create(ConfigSection().Length() + KTwentyFour ); |
|
209 newFileName.Copy(KPrefixLog); |
|
210 //Script file name |
|
211 iScriptName.Copy(ConfigSection()); |
|
212 newFileName.Append(iScriptName); |
|
213 newFileName.Append(KSuffix); |
|
214 newFileName.Append(KExtn); |
|
215 |
|
216 TInt error = fMan->Rename(KlogFile, newFileName); |
|
217 if (error != KErrNone) |
|
218 { |
|
219 _LIT(KErrInfo, "Unable to Save Previous logs...May be NO Previous logs exist \n"); |
|
220 ERR_PRINTF1(KErrInfo); |
|
221 } |
|
222 else |
|
223 { |
|
224 _LIT(KSavingInfo, "<font color=0000ff><b>Saved Previous logs with File Name: <u>%S</u> </b></font> \n"); |
|
225 INFO_PRINTF2(KSavingInfo, &newFileName); |
|
226 } |
|
227 CleanupStack::PopAndDestroy(fMan); |
|
228 newFileName.Close(); |
|
229 } |
|
230 } |
|
231 fileserv.Close(); |
|
232 _LIT(KInfoLogFile1, "Saving Previous logs End.... \n"); |
|
233 INFO_PRINTF1(KInfoLogFile1); |
|
234 } |
|
235 |
|
236 /* |
|
237 return Script File name..if any |
|
238 */ |
|
239 const TDesC& CTestUPnPManager::ScriptFileName() |
|
240 { |
|
241 return iScriptName; |
|
242 } |
|
243 |
|
244 /* |
|
245 Implementation of CTestStep base class virtual and it is used for doing all |
|
246 after test treatment common to derived classes in here. |
|
247 @return TVerdict |
|
248 */ |
|
249 TVerdict CTestUPnPManager::doTestStepPostambleL() |
|
250 { |
|
251 _LIT(KInfoDesctructorBegin, "Begin: In Destructor CTestUpnPanager....\n"); |
|
252 INFO_PRINTF1(KInfoDesctructorBegin); |
|
253 if(iStringPoolMgr) |
|
254 { |
|
255 iStringPoolMgr->Release(); |
|
256 //this will tkae care of clean up of iStringPool |
|
257 } |
|
258 _LIT(KInfoDesctructorBegin2, "Releasing String Pool Manager....\n"); |
|
259 INFO_PRINTF1(KInfoDesctructorBegin2); |
|
260 |
|
261 CleanUpObserverArray(); |
|
262 iDeviceLocationArray.Close(); |
|
263 CleanUpResultsArray(); |
|
264 DescriptionSuiteCleanUp(); |
|
265 ScpdUriArrayCleanUp(); |
|
266 ControlUriArrayCleanUp(); |
|
267 EventUriArrayCleanUp(); |
|
268 CloseDiscoverer(); |
|
269 //#ifdef _DEBUG |
|
270 ClosePublisher(); |
|
271 CActiveScheduler::Install(NULL); //Testing for ONB hangs |
|
272 _LIT(KInfoDesctructorBegin1, "Deleting the Active Schedulers....\n"); |
|
273 INFO_PRINTF1(KInfoDesctructorBegin1); |
|
274 delete iScheduler; |
|
275 iScheduler = NULL; |
|
276 //#endif //_Debug |
|
277 |
|
278 iPublisherObserverMap.Close(); |
|
279 _LIT(KInfoDesctructorEnd, "End: ....In Destructor CTestUpnPanager\n"); |
|
280 INFO_PRINTF1(KInfoDesctructorEnd); |
|
281 |
|
282 return CTestStep::doTestStepPostambleL(); |
|
283 } |
|
284 |
|
285 |
|
286 TVerdict CTestUPnPManager::doTestStepL() |
|
287 { |
|
288 SequenceOperationsL(); |
|
289 return TestStepResult(); |
|
290 } |
|
291 |
|
292 /* |
|
293 This function performs operations based on sequence specified in the ini file |
|
294 @param None |
|
295 @return None |
|
296 */ |
|
297 void CTestUPnPManager::SequenceOperationsL() |
|
298 { |
|
299 for(TInt i(0); i < iNumOperations; i++) |
|
300 { |
|
301 SetCurrentSection(iSequenceList[i]); |
|
302 TPtrC operationType; |
|
303 _LIT(KOperationType, "operationtype"); |
|
304 GetStringFromConfig(iSequenceList[i], KOperationType, operationType); |
|
305 PerformDesiredOperationsL(iSequenceList[i], operationType); |
|
306 } |
|
307 } |
|
308 |
|
309 /* |
|
310 This function performs desired operations specified as a parameter |
|
311 @param aOperation string representing operation to be performed |
|
312 @return None |
|
313 */ |
|
314 void CTestUPnPManager::PerformDesiredOperationsL(const TDesC& aOperation, const TDesC& operationType) |
|
315 { |
|
316 const TInt KMatch = 0; |
|
317 // TPtrC operationType; |
|
318 // _LIT(KOperationType, "operationtype"); |
|
319 // GetStringFromConfig(aOperation, KOperationType, operationType); |
|
320 |
|
321 if(operationType.Compare(KOpenDiscoverer) == KMatch) |
|
322 { |
|
323 DoTestOOML(EOpenDiscover); |
|
324 } |
|
325 else if(operationType.Compare(KDiscovery) == KMatch) |
|
326 { |
|
327 TPtrC listOfServiceTypes; |
|
328 TPtrC listOfMxTimes; |
|
329 _LIT(KListOfServiceTypes, "listofservicetypes"); |
|
330 _LIT(KListOfMxTimes, "listofmxtimes"); |
|
331 if(!GetStringFromConfig(GetCurrentSection(), KListOfServiceTypes, listOfServiceTypes) |
|
332 || !GetStringFromConfig(GetCurrentSection(), KListOfMxTimes, listOfMxTimes)) |
|
333 { |
|
334 _LIT(KErrInfo, "Problem in reading values from ini. \n Expected fields are: \n%S, \n%S \n"); |
|
335 ERR_PRINTF3( KErrInfo, &KListOfServiceTypes, &KListOfMxTimes ); |
|
336 //SetTestStepResult(EFail); |
|
337 return; |
|
338 } |
|
339 TokenizeStringL(listOfServiceTypes, iServiceTypeList); |
|
340 TokenizeStringL(listOfMxTimes, iMxTimeList); |
|
341 |
|
342 DoTestOOML(EDiscover); |
|
343 } |
|
344 else if(operationType.Compare(KCancelDiscover) == KMatch) |
|
345 { |
|
346 CancelDiscoverL(aOperation); |
|
347 } |
|
348 else if(operationType.Compare(KCancelDescribe) == KMatch) |
|
349 { |
|
350 CancelDescribeL(aOperation); |
|
351 } |
|
352 else if(operationType.Compare(KPublishService) == KMatch) |
|
353 { |
|
354 TPtrC iServiceType; |
|
355 GetStringFromConfig(aOperation, KServiceType, iServiceType); |
|
356 |
|
357 TPtrC iUsn; |
|
358 GetStringFromConfig(aOperation, KUSN, iUsn); |
|
359 |
|
360 TInt iDuration; |
|
361 GetIntFromConfig(aOperation, KCacheControl, iDuration); |
|
362 |
|
363 TPtrC iDescription; |
|
364 GetStringFromConfig(aOperation, KDescription, iDescription); |
|
365 |
|
366 TPtrC descriptionPath; |
|
367 _LIT(KDescriptionPath, "Description_Path"); |
|
368 GetStringFromConfig(aOperation, KDescriptionPath, iDescriptionPath); |
|
369 |
|
370 DoTestOOML(EPublishService); |
|
371 // PublishServiceL(aOperation); |
|
372 } |
|
373 else if(operationType.Compare(KPublishDevice) == KMatch) |
|
374 { |
|
375 GetStringFromConfig(aOperation, KParentDeviceUid, iParentdeviceuid); |
|
376 GetStringFromConfig(aOperation, KDeviceType, iDevicetype); |
|
377 GetStringFromConfig(aOperation, KFriendlyName, iFriendlyname); |
|
378 GetStringFromConfig(aOperation, KManufacturer, iManufacturer); |
|
379 GetStringFromConfig(aOperation, KManufacturerURL, iManufacturerurl); |
|
380 GetStringFromConfig(aOperation, KModelDescription, iModeldescription); |
|
381 GetStringFromConfig(aOperation, KModelName, iModelname); |
|
382 GetStringFromConfig(aOperation, KModelNumber, iModelnumber); |
|
383 GetStringFromConfig(aOperation, KModelURL, iModelurl); |
|
384 GetStringFromConfig(aOperation, KPresentationURL, iPresentationurl); |
|
385 GetStringFromConfig(aOperation, KSerialNumber, iSerialnumber); |
|
386 GetStringFromConfig(aOperation, KUDN, iUdn); |
|
387 GetStringFromConfig(aOperation, KUPC, iUpc); |
|
388 GetIntFromConfig(aOperation, KCacheControl, iDuration); |
|
389 DoTestOOML(EPublishDevice); |
|
390 } |
|
391 else if(operationType.Compare(KDescribe) == 0) |
|
392 { |
|
393 DescribeL(); |
|
394 } |
|
395 else if(operationType.Compare(KDescribeService) == 0) |
|
396 { |
|
397 DescribeServiceL(); |
|
398 } |
|
399 else if(operationType.Compare(KSubscribe) == 0) |
|
400 { |
|
401 SubscribeForStateChangeNotificationsL(); |
|
402 } |
|
403 else if(operationType.Compare(KUnsubscribe) == 0) |
|
404 { |
|
405 UnsubscribeForStateChangeNotificationsL(aOperation); |
|
406 } |
|
407 else if(operationType.Compare(KRegisterAnnouncement) == KMatch) |
|
408 { |
|
409 RegisterForAnnouncementsL(aOperation); |
|
410 } |
|
411 else if(operationType.Compare(KCancelNotify) == KMatch) |
|
412 { |
|
413 CancelNotifyAnnouncementL(aOperation); |
|
414 } |
|
415 else if(operationType.Compare(KInitiateControl) == KMatch) |
|
416 { |
|
417 InitiateActionL(aOperation); |
|
418 } |
|
419 else if(operationType.Compare(KStartScheduler) == KMatch) |
|
420 { |
|
421 CActiveScheduler::Start(); |
|
422 } |
|
423 else if(operationType.Compare(KStopScheduler) == KMatch) |
|
424 { |
|
425 CActiveScheduler::Stop(); |
|
426 } |
|
427 else if(operationType.Compare(KStartTimer) == KMatch) |
|
428 { |
|
429 StartTimerL(aOperation); |
|
430 } |
|
431 else if(operationType.Compare(KPrintResults) == 0) |
|
432 { |
|
433 PrintAndValidateResultsL(aOperation); |
|
434 } |
|
435 } |
|
436 |
|
437 /* |
|
438 Parses a comma separated string and constructs a list out of the values |
|
439 @param aString a reference to a string to be tokenized |
|
440 @param aList is an out parameter to store a list of tokens in an arry |
|
441 @param aSeparator is a character used to delimit the tokens |
|
442 */ |
|
443 void CTestUPnPManager::TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator) |
|
444 { |
|
445 TLex lexer(aString); |
|
446 |
|
447 while(!lexer.Eos()) |
|
448 { |
|
449 lexer.SkipSpaceAndMark(); |
|
450 |
|
451 while(!lexer.Eos() && lexer.Get() != aSeparator) |
|
452 { |
|
453 } |
|
454 |
|
455 if(!lexer.Eos()) |
|
456 { |
|
457 lexer.UnGet(); |
|
458 } |
|
459 aList.AppendL(lexer.MarkedToken()); |
|
460 lexer.Inc(); |
|
461 } |
|
462 } |
|
463 |
|
464 /* |
|
465 Starts a timer for a wait time and triggers CallBack function as timer expires. |
|
466 @param None |
|
467 @return None |
|
468 */ |
|
469 void CTestUPnPManager::StartTimerL(const TDesC& aOperationType) |
|
470 { |
|
471 _LIT(KInfoLogFile, "StartTimerL.... \n"); |
|
472 INFO_PRINTF1(KInfoLogFile); |
|
473 _LIT(KWaitTime,"waittime"); |
|
474 TInt waitTime = 0; |
|
475 GetIntFromConfig(aOperationType, KWaitTime, waitTime); |
|
476 // TTimeIntervalMicroSeconds32 interval(waitTime); |
|
477 CUPnPTimer* timer = CUPnPTimer::NewL(this); |
|
478 CleanupStack::PushL(timer); |
|
479 timer->IssueRequestL(waitTime); |
|
480 CActiveScheduler::Start(); |
|
481 CleanupStack::PopAndDestroy(timer); |
|
482 _LIT(KInfoLogFile1, "StartTimerL End.... \n"); |
|
483 INFO_PRINTF1(KInfoLogFile1); |
|
484 } |
|
485 |
|
486 /* |
|
487 Sets the current config section. |
|
488 @param aCurrentSection - a reference string that represent current config section |
|
489 @return None |
|
490 */ |
|
491 void CTestUPnPManager::SetCurrentSection(const TDesC& aCurrentSection) |
|
492 { |
|
493 iCurrentSection = aCurrentSection; |
|
494 } |
|
495 |
|
496 /* |
|
497 Retrieve the current config section. |
|
498 @param |
|
499 @return Reference to current config section |
|
500 */ |
|
501 TDesC& CTestUPnPManager::GetCurrentSection() |
|
502 { |
|
503 return iCurrentSection; |
|
504 } |
|
505 |
|
506 /* |
|
507 Tests whether discovering services/devices is performing as specified in UPnP specifications. |
|
508 @param aOperationType is reference to a section name in ini file where required parameters |
|
509 needs to be referred for this operation. |
|
510 @return None. |
|
511 */ |
|
512 void CTestUPnPManager::DiscoverL() |
|
513 { |
|
514 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
515 iObserverArray.AppendL(upnpObserver); |
|
516 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
517 CleanupClosePushL( *pnpBundle ); |
|
518 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
519 |
|
520 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPDiscoverRequestParamSet ); |
|
521 TInt numUris = iServiceTypeList.Count(); |
|
522 iFailedNumUris = iServiceTypeList.Count(); //This should be of Unique Uri's count |
|
523 TInt numMxs = iMxTimeList.Count(); |
|
524 TLex responseTimeObj; |
|
525 RBuf8 buf; |
|
526 buf.CreateL(KMaxUriSize); |
|
527 for(TInt i(0); i < numUris; i++) |
|
528 { |
|
529 CUPnPDiscoverRequestParamSet* discoverParamSet = CUPnPDiscoverRequestParamSet::NewL(pnpFamily ); |
|
530 buf.Copy(iServiceTypeList[i]); |
|
531 discoverParamSet->SetUriL( buf ); |
|
532 //response time |
|
533 responseTimeObj.Assign(iMxTimeList[i]); |
|
534 TInt responseTime(0); |
|
535 responseTimeObj.Val(responseTime); |
|
536 discoverParamSet->SetResponseTime(responseTime); |
|
537 } |
|
538 iControlPoint.Discover(*pnpBundle); |
|
539 CActiveScheduler::Start(); |
|
540 |
|
541 buf.Close(); |
|
542 iMxTimeList.Close(); |
|
543 iServiceTypeList.Close(); |
|
544 CleanupStack::PopAndDestroy( pnpBundle ); |
|
545 } |
|
546 |
|
547 TBool CTestUPnPManager::IsDiscoverySuccess() |
|
548 { |
|
549 return iDiscoverySuccess; |
|
550 } |
|
551 |
|
552 void CTestUPnPManager::SetDiscoveryStatus(TBool aSuccess) |
|
553 { |
|
554 _LIT(KInfoDiscoverSetStatus, "Setting iDiscoverySuccesss Flag to %d \n"); |
|
555 INFO_PRINTF2(KInfoDiscoverSetStatus, aSuccess ); |
|
556 iDiscoverySuccess = aSuccess; |
|
557 } |
|
558 |
|
559 /* |
|
560 Tests whether Publishing a Service/Device is performing as specified in UPnP specifications. |
|
561 @param aOperationType is reference to a section name in ini file where required parameters |
|
562 needs to be referred for this operation. |
|
563 @return None. |
|
564 */ |
|
565 void CTestUPnPManager::PublishServiceL () |
|
566 { |
|
567 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
568 iObserverArray.Append(upnpObserver); |
|
569 //To keep track of mapping between Observer and Publisher |
|
570 TInt observerIndex = iObserverArray.Count() - 1; |
|
571 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
572 CleanupClosePushL( *pnpBundle ); |
|
573 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
574 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPServiceRegisterParamSet ); |
|
575 CUPnPServiceRegisterParamSet* registerServiceParamSet = CUPnPServiceRegisterParamSet::NewL(pnpFamily ); |
|
576 RBuf8 serviceTypeBuf; |
|
577 serviceTypeBuf.Create(iServiceType.Length()); |
|
578 serviceTypeBuf.Copy(iServiceType); |
|
579 |
|
580 RBuf8 usnBuf; |
|
581 usnBuf.Create(iUsn.Length()); |
|
582 usnBuf.Copy(iUsn); |
|
583 |
|
584 RBuf8 descriptionBuf; |
|
585 descriptionBuf.Create(iDescription.Length()); |
|
586 descriptionBuf.Copy(iDescription); |
|
587 |
|
588 registerServiceParamSet->SetUriL ( serviceTypeBuf ); |
|
589 registerServiceParamSet->SetDeviceUidL ( usnBuf ); |
|
590 registerServiceParamSet->SetCacheControlData ( iDuration ); |
|
591 registerServiceParamSet->SetSubscriptionDuration(300); |
|
592 |
|
593 ExtractServiceDescriptionL (*registerServiceParamSet); |
|
594 |
|
595 _LIT8(KInitialMessage, "Initial Service Message"); |
|
596 registerServiceParamSet->SetInitialMessageL(KInitialMessage); |
|
597 |
|
598 //To keep track of mapping between Observer and Publisher |
|
599 TInt publisherIndex = OpenPublisherL(); |
|
600 //Create mapping of Publsiher and observer |
|
601 TPublisherObserverMap publisherObserverMapElement; |
|
602 publisherObserverMapElement.iPublisherIndex = publisherIndex; |
|
603 publisherObserverMapElement.iObserverIndex = observerIndex; |
|
604 publisherObserverMapElement.iPublisherControl = KService; |
|
605 iPublisherObserverMap.Append(publisherObserverMapElement); |
|
606 |
|
607 //Publish service nad update publish count |
|
608 iPublishCount++; |
|
609 iPublisherArray[publisherIndex].Publish(*pnpBundle); |
|
610 |
|
611 descriptionBuf.Close(); |
|
612 usnBuf.Close(); |
|
613 serviceTypeBuf.Close(); |
|
614 CleanupStack::PopAndDestroy( pnpBundle ); |
|
615 } |
|
616 |
|
617 /* |
|
618 * Get publisher mapping index for the given observer index |
|
619 */ |
|
620 TInt CTestUPnPManager::GetPublisherIndex (TInt aObserverIndex) |
|
621 { |
|
622 _LIT(KInfoLogFile, "GetPublisherIndex.... \n"); |
|
623 INFO_PRINTF1(KInfoLogFile); |
|
624 |
|
625 TInt count = iPublisherObserverMap.Count(); |
|
626 for (TInt index(0); index < count ; index++ ) |
|
627 { |
|
628 if (iPublisherObserverMap[index].iObserverIndex == aObserverIndex) |
|
629 { |
|
630 return iPublisherObserverMap[index].iPublisherIndex; |
|
631 } |
|
632 } |
|
633 return KErrNotFound; |
|
634 } |
|
635 |
|
636 /* |
|
637 * Gets publisher control i.e, Device/Service for the given observer index |
|
638 */ |
|
639 TPublisherControl CTestUPnPManager::GetPublisherControl (TInt aObserverIndex) |
|
640 { |
|
641 _LIT(KInfoLogFile, "GetPublisherControl.... \n"); |
|
642 INFO_PRINTF1(KInfoLogFile); |
|
643 |
|
644 TInt count = iPublisherObserverMap.Count(); |
|
645 for (TInt index(0); index < count ; index++ ) |
|
646 { |
|
647 if (iPublisherObserverMap[index].iObserverIndex == aObserverIndex) |
|
648 { |
|
649 return iPublisherObserverMap[index].iPublisherControl; |
|
650 } |
|
651 } |
|
652 return KErrNoControl; |
|
653 } |
|
654 |
|
655 /* |
|
656 * Gets publisher control i.e, Device/Service for the given observer index |
|
657 */ |
|
658 TPublisherControl CTestUPnPManager::PublisherType (TInt aPublisherIndex) |
|
659 { |
|
660 _LIT(KInfoLogFile, "PublisherType.... \n"); |
|
661 INFO_PRINTF1(KInfoLogFile); |
|
662 TInt count = iPublisherObserverMap.Count(); |
|
663 TPublisherControl publisherControl = KErrNoControl; |
|
664 for (TInt index(0); index < count ; index++ ) |
|
665 { |
|
666 if (iPublisherObserverMap[index].iPublisherIndex == aPublisherIndex) |
|
667 { |
|
668 switch (iPublisherObserverMap[index].iPublisherControl) |
|
669 { |
|
670 case KService: |
|
671 { |
|
672 publisherControl = KService; |
|
673 break; |
|
674 } |
|
675 case KDevice: |
|
676 { |
|
677 publisherControl = KDevice; |
|
678 break; |
|
679 } |
|
680 default : |
|
681 { |
|
682 publisherControl = KErrNoControl; |
|
683 break; |
|
684 } |
|
685 } |
|
686 } |
|
687 } |
|
688 _LIT(KInfoLogFile2, "PublisherType....End \n"); |
|
689 INFO_PRINTF1(KInfoLogFile2); |
|
690 return publisherControl; |
|
691 } |
|
692 |
|
693 TInt CTestUPnPManager::NotifyCount() |
|
694 { |
|
695 return iNotifyCount; |
|
696 } |
|
697 |
|
698 TBool CTestUPnPManager::SendNotificationsL (CUPnPObserver* aObserver) |
|
699 { |
|
700 _LIT(KInfoLogFile, "SendNotificationsL.... \n"); |
|
701 INFO_PRINTF1(KInfoLogFile); |
|
702 |
|
703 TInt observerIndex = iObserverArray.Find(aObserver); |
|
704 TInt publisherIndex = GetPublisherIndex(observerIndex); |
|
705 TPublisherControl publisherControl = GetPublisherControl(observerIndex); |
|
706 |
|
707 if(publisherControl != KService) |
|
708 { |
|
709 _LIT(KSendNotifyErr,"SEND NOTIFY NOT EXECUTED -- Can be Executed only ON Services...\n"); |
|
710 ERR_PRINTF1(KSendNotifyErr); |
|
711 return EFalse; |
|
712 } |
|
713 |
|
714 CPnPParameterBundle* pnpBundle = CPnPParameterBundle ::NewL( ); |
|
715 CleanupClosePushL( *pnpBundle ); |
|
716 pnpBundle->SetPnPObserver((MPnPObserver*)this); |
|
717 |
|
718 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPServiceNotificationParamSet); |
|
719 CUPnPServiceNotificationParamSet* ServiceNotifyParamSet = CUPnPServiceNotificationParamSet::NewL (pnpFamily ); |
|
720 |
|
721 RBuf8 notificationDataBuf; |
|
722 notificationDataBuf.CreateL(_L8("notification")); |
|
723 |
|
724 ServiceNotifyParamSet->SetNotificationL (notificationDataBuf ); |
|
725 iNotifyCount++; |
|
726 if(publisherIndex >= 0) |
|
727 { |
|
728 iPublisherArray[publisherIndex].SendNotify(*pnpBundle ); |
|
729 _LIT(KSendNotify,"Info: SEND NOTIFY SUCCESSFUL...\n"); |
|
730 INFO_PRINTF1(KSendNotify); |
|
731 } |
|
732 else |
|
733 { |
|
734 _LIT(KSendNotifyFailed,"Err: SEND NOTIFY UNSUCCESSFUL...\n"); |
|
735 ERR_PRINTF1(KSendNotifyFailed); |
|
736 } |
|
737 |
|
738 CleanupStack::PopAndDestroy( pnpBundle ); |
|
739 notificationDataBuf.Close(); |
|
740 _LIT(KInfoLogFile1, "SendNotificationsL End.... \n"); |
|
741 INFO_PRINTF1(KInfoLogFile1); |
|
742 |
|
743 return ETrue; |
|
744 } |
|
745 |
|
746 /* |
|
747 Extract service description available in a file, copy it to the buffer and append the same to service register paramset. |
|
748 @param aConfigSection - reference to a section name in ini file where required parameters that needs to be referred for this operation. |
|
749 aServiceRegisterParamSet - Storage for the description buffer |
|
750 @return None. |
|
751 */ |
|
752 |
|
753 void CTestUPnPManager::ExtractServiceDescriptionL (CUPnPServiceRegisterParamSet& aServiceRegisterParamSet) |
|
754 { |
|
755 if((iDescriptionPath == KNullDesC) && (iDescription == KNullDesC)) |
|
756 { |
|
757 _LIT8(KDefaultServiceDescription, "defaultservicedescription"); |
|
758 TBuf8<KMaxBufLength> descBuf; |
|
759 descBuf.Copy(KDefaultServiceDescription); |
|
760 aServiceRegisterParamSet.SetServiceDescriptionL (descBuf); |
|
761 return; |
|
762 } |
|
763 else |
|
764 { |
|
765 RFs fs; |
|
766 RFile file; |
|
767 TInt err; |
|
768 RBuf8 buf; |
|
769 User::LeaveIfError(fs.Connect()); |
|
770 CleanupClosePushL(fs); |
|
771 if(iDescriptionPath != KNullDesC) |
|
772 { |
|
773 err = file.Open(fs, iDescriptionPath, EFileShareReadersOnly); |
|
774 } |
|
775 else |
|
776 { |
|
777 err = file.Open(fs, iDescription, EFileShareReadersOnly); |
|
778 } |
|
779 |
|
780 if (err != KErrNone) |
|
781 { |
|
782 User::LeaveIfError(err); |
|
783 } |
|
784 CleanupClosePushL(file); |
|
785 TInt fileSize = 0; |
|
786 file.Size(fileSize); |
|
787 buf.Create(fileSize); |
|
788 err = file.Read(buf, fileSize); |
|
789 aServiceRegisterParamSet.SetServiceDescriptionL ( buf ); |
|
790 _LIT(KServiceDescription, "ServiceDescription is.... %S \n"); |
|
791 INFO_PRINTF2(KServiceDescription, &buf); |
|
792 CleanupStack::PopAndDestroy(2); |
|
793 buf.Close(); |
|
794 } |
|
795 _LIT(KInfoLogFile1, "ExtractServiceDescriptionL() End.... \n"); |
|
796 INFO_PRINTF1(KInfoLogFile1); |
|
797 } |
|
798 |
|
799 void CTestUPnPManager::ResolveScpdUrisL(TInt aIndex) |
|
800 { |
|
801 _LIT(KInfoLogFile, "ResolveScpdUrisL .... \n"); |
|
802 INFO_PRINTF1(KInfoLogFile); |
|
803 if ( aIndex < 0 ) |
|
804 { |
|
805 _LIT(KBadIndex, "BadIndex...ResolveScpdUrisL Cannot be executed \n"); |
|
806 ERR_PRINTF1(KBadIndex); |
|
807 return; |
|
808 } |
|
809 const TInt KSlashLenghth = 1; |
|
810 TUriParser8 uri; |
|
811 uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl); |
|
812 TBuf8<KMaxUriSize> buf; |
|
813 buf.Copy(uri.Extract(EUriScheme)); |
|
814 |
|
815 buf.Append(KColonSlashSlash); |
|
816 buf.Append(uri.Extract(EUriHost)); |
|
817 |
|
818 buf.Append(KColon); |
|
819 buf.Append(uri.Extract(EUriPort)); |
|
820 |
|
821 TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count(); |
|
822 for (TInt scpdIndex(0); scpdIndex < count; scpdIndex++ ) |
|
823 { |
|
824 RBuf8 scpdUri; |
|
825 scpdUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl.Length()); |
|
826 scpdUri.Copy(buf); |
|
827 if (iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl.Find(KSlash)!=0) |
|
828 { |
|
829 scpdUri.Append(KSlash); |
|
830 } |
|
831 scpdUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[scpdIndex].scpdUrl); |
|
832 AppendScpdUriL(scpdUri); |
|
833 } |
|
834 _LIT(KInfoLogFile1, "ResolveScpdUrisL End .... \n"); |
|
835 INFO_PRINTF1(KInfoLogFile1); |
|
836 } |
|
837 |
|
838 void CTestUPnPManager::ResolveEventUrisL(TInt aIndex) |
|
839 { |
|
840 _LIT(KInfoLogFile, "ResolveEventUrisL.... \n"); |
|
841 INFO_PRINTF1(KInfoLogFile); |
|
842 if ( aIndex < 0 ) |
|
843 { |
|
844 _LIT(KBadIndex, "BadIndex...ResolveEventUrisL Cannot be executed \n"); |
|
845 ERR_PRINTF1(KBadIndex); |
|
846 return; |
|
847 } |
|
848 const TInt KSlashLenghth = 1; |
|
849 TUriParser8 uri; |
|
850 uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl); |
|
851 TBuf8<KMaxUriSize> buf; |
|
852 buf.Copy(uri.Extract(EUriScheme)); |
|
853 |
|
854 buf.Append(KColonSlashSlash); |
|
855 buf.Append(uri.Extract(EUriHost)); |
|
856 |
|
857 buf.Append(KColon); |
|
858 buf.Append(uri.Extract(EUriPort)); |
|
859 |
|
860 TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count(); |
|
861 for (TInt eventIndex(0); eventIndex < count; eventIndex++ ) |
|
862 { |
|
863 RBuf8 eventUri; |
|
864 eventUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl.Length()); |
|
865 eventUri.Copy(buf); |
|
866 if (iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl.Find(KSlash)!=0) |
|
867 { |
|
868 eventUri.Append(KSlash); |
|
869 } |
|
870 eventUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[eventIndex].eventSubUrl); |
|
871 AppendEventUriL(eventUri); |
|
872 } |
|
873 _LIT(KInfoLogFile1, "ResolveEventUrisL End.... \n"); |
|
874 INFO_PRINTF1(KInfoLogFile1); |
|
875 |
|
876 } |
|
877 |
|
878 void CTestUPnPManager::ResolveControlUrisL(TInt aIndex) |
|
879 { |
|
880 _LIT(KInfoLogFile, "ResolveControlUrisL().... \n"); |
|
881 INFO_PRINTF1(KInfoLogFile); |
|
882 if ( aIndex < 0 ) |
|
883 { |
|
884 _LIT(KBadIndex, "BadIndex...ResolveControlUrisL Cannot be executed \n"); |
|
885 ERR_PRINTF1(KBadIndex); |
|
886 return; |
|
887 } |
|
888 const TInt KSlashLenghth = 1; |
|
889 TUriParser8 uri; |
|
890 uri.Parse(iDescriptionSuiteArray[aIndex].iBaseUrl); |
|
891 TBuf8<KMaxUriSize> buf; |
|
892 buf.Copy(uri.Extract(EUriScheme)); |
|
893 |
|
894 buf.Append(KColonSlashSlash); |
|
895 buf.Append(uri.Extract(EUriHost)); |
|
896 |
|
897 buf.Append(KColon); |
|
898 buf.Append(uri.Extract(EUriPort)); |
|
899 |
|
900 TInt count = iDescriptionSuiteArray[aIndex].iServiceUrls.Count(); |
|
901 for (TInt ControlIndex(0); ControlIndex < count; ControlIndex++ ) |
|
902 { |
|
903 RBuf8 controlUri; |
|
904 controlUri.Create(buf.Length() + KSlashLenghth + iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl.Length()); |
|
905 controlUri.Copy(buf); |
|
906 if (iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl.Find(KSlash)!=0) |
|
907 { |
|
908 controlUri.Append(KSlash); |
|
909 } |
|
910 controlUri.Append(iDescriptionSuiteArray[aIndex].iServiceUrls[ControlIndex].controlUrl); |
|
911 AppendControlUriL(controlUri); |
|
912 } |
|
913 _LIT(KInfoLogFile1, "ResolveControlUrisL() End.... \n"); |
|
914 INFO_PRINTF1(KInfoLogFile1); |
|
915 } |
|
916 |
|
917 /* |
|
918 Opens a handle to a RPnPServiceDiscovery object |
|
919 @param None. |
|
920 @return None. |
|
921 */ |
|
922 void CTestUPnPManager::OpenDiscovererL() |
|
923 { |
|
924 User::LeaveIfError(iControlPoint.Open(KTierId)); |
|
925 } |
|
926 |
|
927 /* |
|
928 Opens a handle to a RPnPServicePublisher object and append the same to Publisher array |
|
929 @param None. |
|
930 @return TBool representing success or failure of the operation. |
|
931 */ |
|
932 TInt CTestUPnPManager::OpenPublisherL() |
|
933 { |
|
934 RPnPServicePublisher publisher; |
|
935 TInt openStatus = 0; |
|
936 User::LeaveIfError(publisher.Open(KTierId)); |
|
937 iPublisherArray.AppendL(publisher); |
|
938 TInt index = iPublisherArray.Count() - 1; |
|
939 return index; |
|
940 } |
|
941 |
|
942 /* |
|
943 Publishing of device as per UPnP specifications. |
|
944 @param aOperationType is reference to a section name in ini file where required parameters |
|
945 needs to be referred for this operation. |
|
946 @return None. |
|
947 */ |
|
948 |
|
949 void CTestUPnPManager::PublishDeviceL () |
|
950 { |
|
951 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
952 iObserverArray.AppendL(upnpObserver); |
|
953 |
|
954 //To keep track of mapping between Observer and Publisher |
|
955 TInt observerIndex = iObserverArray.Count() - 1; |
|
956 |
|
957 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
958 CleanupClosePushL( *pnpBundle ); |
|
959 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
960 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPDeviceRegisterParamSet ); |
|
961 CUPnPDeviceRegisterParamSet* registerDeviceParamSet = CUPnPDeviceRegisterParamSet::NewL(pnpFamily ); |
|
962 |
|
963 RBuf8 parentdeviceuidBuf; |
|
964 parentdeviceuidBuf.CreateL(iParentdeviceuid.Length()); |
|
965 parentdeviceuidBuf.Copy(iParentdeviceuid); |
|
966 |
|
967 RBuf8 devicetypeBuf; |
|
968 devicetypeBuf.CreateL(iDevicetype.Length()); |
|
969 devicetypeBuf.Copy(iDevicetype); |
|
970 |
|
971 RBuf8 friendlynameBuf; |
|
972 friendlynameBuf.CreateL(iFriendlyname.Length()); |
|
973 friendlynameBuf.Copy(iFriendlyname); |
|
974 |
|
975 RBuf8 manufacturerBuf; |
|
976 manufacturerBuf.CreateL(iManufacturer.Length()); |
|
977 manufacturerBuf.Copy(iManufacturer); |
|
978 |
|
979 RBuf8 manufacturerurlBuf; |
|
980 manufacturerurlBuf.CreateL(iManufacturerurl.Length()); |
|
981 manufacturerurlBuf.Copy(iManufacturerurl); |
|
982 |
|
983 RBuf8 modeldescriptionBuf; |
|
984 modeldescriptionBuf.CreateL(iModeldescription.Length()); |
|
985 modeldescriptionBuf.Copy(iModeldescription); |
|
986 |
|
987 RBuf8 modelnameBuf; |
|
988 modelnameBuf.CreateL(iModelname.Length()); |
|
989 modelnameBuf.Copy(iModelname); |
|
990 |
|
991 RBuf8 modelnumberBuf; |
|
992 modelnumberBuf.CreateL(iModelnumber.Length()); |
|
993 modelnumberBuf.Copy(iModelnumber); |
|
994 |
|
995 |
|
996 RBuf8 modelurlBuf; |
|
997 modelurlBuf.CreateL(iModelurl.Length()); |
|
998 modelurlBuf.Copy(iModelurl); |
|
999 |
|
1000 RBuf8 presentationurlBuf; |
|
1001 presentationurlBuf.CreateL(iPresentationurl.Length()); |
|
1002 presentationurlBuf.Copy(iPresentationurl); |
|
1003 |
|
1004 RBuf8 serialnumberBuf; |
|
1005 serialnumberBuf.CreateL(iSerialnumber.Length()); |
|
1006 serialnumberBuf.Copy(iSerialnumber); |
|
1007 |
|
1008 RBuf8 udnBuf; |
|
1009 udnBuf.CreateL(iUdn.Length()); |
|
1010 udnBuf.Copy(iUdn); |
|
1011 |
|
1012 RBuf8 upcBuf; |
|
1013 upcBuf.CreateL(iUpc.Length()); |
|
1014 upcBuf.Copy(iUpc); |
|
1015 |
|
1016 |
|
1017 TInt publisherIndex = OpenPublisherL(); |
|
1018 registerDeviceParamSet-> SetParentDeviceUidL(parentdeviceuidBuf); |
|
1019 registerDeviceParamSet-> SetUriL (devicetypeBuf); |
|
1020 registerDeviceParamSet-> SetFriendlyNameL (friendlynameBuf); |
|
1021 registerDeviceParamSet-> SetManufacturerL (manufacturerBuf ); |
|
1022 registerDeviceParamSet-> SetManufactureUrlL (manufacturerurlBuf); |
|
1023 registerDeviceParamSet-> SetModelDescL (modeldescriptionBuf); |
|
1024 registerDeviceParamSet-> SetModelNameL (modelnameBuf); |
|
1025 registerDeviceParamSet-> SetModelNumberL (modelnumberBuf); |
|
1026 registerDeviceParamSet-> SetModelUriL (modelurlBuf); |
|
1027 registerDeviceParamSet-> SetPresentationL (presentationurlBuf); |
|
1028 registerDeviceParamSet-> SetUDNL (udnBuf); |
|
1029 registerDeviceParamSet-> SetUPCL (upcBuf); |
|
1030 registerDeviceParamSet-> SetCacheControlData (iDuration); |
|
1031 registerDeviceParamSet-> SetSerialNumberL (serialnumberBuf); |
|
1032 |
|
1033 //To keep track of mapping between Observer and Publisher |
|
1034 //Create mapping of Publsiher and observer |
|
1035 TPublisherObserverMap publisherObserverMapElement; |
|
1036 publisherObserverMapElement.iPublisherIndex = publisherIndex; |
|
1037 publisherObserverMapElement.iObserverIndex = observerIndex; |
|
1038 publisherObserverMapElement.iPublisherControl = KDevice; |
|
1039 iPublisherObserverMap.AppendL(publisherObserverMapElement); |
|
1040 |
|
1041 //Publish Device and update publish count |
|
1042 iPublishCount++; |
|
1043 iPublisherArray[publisherIndex].Publish(*pnpBundle); |
|
1044 |
|
1045 CleanUpObserverArray(); |
|
1046 upcBuf.Close(); |
|
1047 udnBuf.Close(); |
|
1048 serialnumberBuf.Close(); |
|
1049 presentationurlBuf.Close(); |
|
1050 modelurlBuf.Close(); |
|
1051 modelnumberBuf.Close(); |
|
1052 modelnameBuf.Close(); |
|
1053 manufacturerurlBuf.Close(); |
|
1054 manufacturerBuf.Close(); |
|
1055 friendlynameBuf.Close(); |
|
1056 devicetypeBuf.Close(); |
|
1057 parentdeviceuidBuf.Close(); |
|
1058 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1059 _LIT(KInfoLogFile1, "PublishDeviceL End.... \n"); |
|
1060 INFO_PRINTF1(KInfoLogFile1); |
|
1061 } |
|
1062 |
|
1063 /* |
|
1064 Test for Register announcements ssdp:alive and ssdp:byebye messages |
|
1065 @param aOperationType is reference to a section name in ini file where required parameters |
|
1066 needs to be referred for this operation. |
|
1067 @return None. |
|
1068 */ |
|
1069 void CTestUPnPManager::RegisterForAnnouncementsL (const TDesC& aOperationType) |
|
1070 { |
|
1071 _LIT(KInfoLogFile, "RegisterForAnnouncementsL().... \n"); |
|
1072 INFO_PRINTF1(KInfoLogFile); |
|
1073 RArray<TPtrC> uriTypeList; |
|
1074 TPtrC listOfUriTypes; |
|
1075 _LIT(KListOfUriTypes, "listofuritypes"); |
|
1076 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1077 iObserverArray.Append(upnpObserver); |
|
1078 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1079 CleanupClosePushL( *pnpBundle ); |
|
1080 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1081 |
|
1082 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPRegisterAnnouncementParamSet ); |
|
1083 if(!GetStringFromConfig(GetCurrentSection(), KListOfUriTypes, listOfUriTypes)) |
|
1084 { |
|
1085 _LIT(KErrInfo, "Problem in reading values from ini. \n Expected fields are: \n%S, \n%S \n"); |
|
1086 ERR_PRINTF2( KErrInfo, &KListOfUriTypes); |
|
1087 return; |
|
1088 } |
|
1089 |
|
1090 TokenizeStringL(listOfUriTypes, uriTypeList); |
|
1091 TInt numUris = uriTypeList.Count(); |
|
1092 RBuf8 buf; |
|
1093 buf.Create(KMaxUriSize); |
|
1094 for(TInt i(0); i < numUris; i++) |
|
1095 { |
|
1096 CUPnPRegisterAnnouncementParamSet* announcementParamSet = CUPnPRegisterAnnouncementParamSet::NewL(pnpFamily ); |
|
1097 buf.Copy(uriTypeList[i]); |
|
1098 announcementParamSet->SetUriL( buf ); |
|
1099 } |
|
1100 buf.Close(); |
|
1101 uriTypeList.Close(); |
|
1102 iControlPoint.RegisterNotify(*pnpBundle ); |
|
1103 TBool schedulerStart = EFalse; |
|
1104 _LIT(KSchedulerStart, "schedulerstart"); |
|
1105 GetBoolFromConfig(aOperationType, KSchedulerStart, schedulerStart); |
|
1106 if(schedulerStart) |
|
1107 { |
|
1108 CActiveScheduler::Start(); |
|
1109 } |
|
1110 CleanupStack::PopAndDestroy(pnpBundle); |
|
1111 _LIT(KInfoLogFile1, "RegisterForAnnouncementsL() End.... \n"); |
|
1112 INFO_PRINTF1(KInfoLogFile1); |
|
1113 |
|
1114 |
|
1115 } |
|
1116 |
|
1117 /* |
|
1118 Tests whether subscribtion to event change notifications is performing as specified in UPnP specifications. |
|
1119 @param None. |
|
1120 @return None. |
|
1121 */ |
|
1122 void CTestUPnPManager::SubscribeForStateChangeNotificationsL() |
|
1123 { |
|
1124 _LIT(KInfoLogFile, "SubscribeForStateChangeNotificationsL() start.... \n"); |
|
1125 INFO_PRINTF1(KInfoLogFile); |
|
1126 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1127 CleanupStack::PushL( upnpObserver ); |
|
1128 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1129 CleanupClosePushL( *pnpBundle ); |
|
1130 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1131 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPSubscribeRequestParamSet); |
|
1132 TInt subscriptionDuration; |
|
1133 _LIT(KSubscriptionDuration, "subscriptionduration"); |
|
1134 GetIntFromConfig(GetCurrentSection(), KSubscriptionDuration, subscriptionDuration); |
|
1135 TBool readIni = EFalse; |
|
1136 GetBoolFromConfig(GetCurrentSection(), KReadIni, readIni); |
|
1137 if(readIni) |
|
1138 { |
|
1139 CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily ); |
|
1140 TPtrC subscriptionUri; |
|
1141 GetStringFromConfig(GetCurrentSection(), KSubscriptionUri, subscriptionUri); |
|
1142 RBuf8 subscriptionUriBuf; |
|
1143 subscriptionUriBuf.Create(subscriptionUri.Length()); |
|
1144 subscriptionUriBuf.Copy(subscriptionUri); |
|
1145 subscribeParamSet->SetDuration(subscriptionDuration); |
|
1146 subscribeParamSet->SetUriL(subscriptionUriBuf); |
|
1147 subscriptionUriBuf.Close(); |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 //Multiple uri's can be submitted for description |
|
1152 ResolveAllUrisL(); |
|
1153 TInt eventUriCount = iEventUriArray.Count(); |
|
1154 if ( eventUriCount==0 ) |
|
1155 { |
|
1156 _LIT(KEventSubscription,"Event Subscription Cannot be performed \n"); |
|
1157 INFO_PRINTF1(KEventSubscription); |
|
1158 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1159 CleanupStack::PopAndDestroy( upnpObserver ); |
|
1160 //SetTestStepResult(EFail); |
|
1161 return; |
|
1162 } |
|
1163 for(TInt index(0); index < eventUriCount ; index++) |
|
1164 { |
|
1165 //for (TInt j(0); j < 10 ; j++) |
|
1166 //{//Pass Duplicate subscritption reuqest multiple times in single bundle |
|
1167 CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily ); |
|
1168 subscribeParamSet->SetUriL(iEventUriArray[index]); |
|
1169 subscribeParamSet->SetDuration(subscriptionDuration); |
|
1170 RBuf eventUri16; |
|
1171 eventUri16.Create(iEventUriArray[index].Length()); |
|
1172 eventUri16.Copy(iEventUriArray[index]); |
|
1173 _LIT(KEventSubUriInfo,"Event Uri Submitted for Subscription Request is: %S \n"); |
|
1174 INFO_PRINTF2(KEventSubUriInfo, &eventUri16); |
|
1175 eventUri16.Close(); |
|
1176 // } |
|
1177 } |
|
1178 } |
|
1179 iControlPoint.Subscribe( *pnpBundle ); |
|
1180 CActiveScheduler::Start(); |
|
1181 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1182 CleanupStack::PopAndDestroy( upnpObserver ); |
|
1183 _LIT(KInfoLogFile1, "SubscribeForStateChangeNotificationsL() End.... \n"); |
|
1184 INFO_PRINTF1(KInfoLogFile1); |
|
1185 } |
|
1186 |
|
1187 void CTestUPnPManager::ReSubscribeForStateChangeNotificationsL() |
|
1188 { |
|
1189 _LIT(KInfoLogFile, "Re-SubscribeForStateChangeNotificationsL() start.... \n"); |
|
1190 INFO_PRINTF1(KInfoLogFile); |
|
1191 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1192 CleanupStack::PushL( upnpObserver ); |
|
1193 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1194 CleanupClosePushL( *pnpBundle ); |
|
1195 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1196 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPSubscribeRequestParamSet); |
|
1197 TInt subscriptionDuration; |
|
1198 _LIT(KSubscriptionDuration, "subscriptionduration"); |
|
1199 GetIntFromConfig(GetCurrentSection(), KSubscriptionDuration, subscriptionDuration); |
|
1200 |
|
1201 TInt eventUriCount = iEventUriArray.Count(); |
|
1202 if ( eventUriCount==0 ) |
|
1203 { |
|
1204 _LIT(KEventSubscription,"Event Subscription Cannot be performed \n"); |
|
1205 INFO_PRINTF1(KEventSubscription); |
|
1206 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1207 CleanupStack::PopAndDestroy( upnpObserver ); |
|
1208 //SetTestStepResult(EFail); |
|
1209 return; |
|
1210 } |
|
1211 for(TInt index(0); index < eventUriCount ; index++) |
|
1212 { |
|
1213 CUPnPSubscribeRequestParamSet * subscribeParamSet = CUPnPSubscribeRequestParamSet::NewL (pnpFamily ); |
|
1214 subscribeParamSet->SetUriL(iEventUriArray[index]); |
|
1215 subscribeParamSet->SetDuration(20); |
|
1216 RBuf eventUri16; |
|
1217 eventUri16.Create(iEventUriArray[index].Length()); |
|
1218 eventUri16.Copy(iEventUriArray[index]); |
|
1219 _LIT(KEventSubUriInfo,"Event Uri Submitted for Re-Subscription is: %S \n"); |
|
1220 INFO_PRINTF2(KEventSubUriInfo, &eventUri16); |
|
1221 eventUri16.Close(); |
|
1222 } |
|
1223 iControlPoint.Subscribe( *pnpBundle ); |
|
1224 CActiveScheduler::Start(); |
|
1225 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1226 CleanupStack::PopAndDestroy( upnpObserver ); |
|
1227 _LIT(KInfoLogFile1, "Re-SubscribeForStateChangeNotificationsL() End.... \n"); |
|
1228 INFO_PRINTF1(KInfoLogFile1); |
|
1229 } |
|
1230 /* |
|
1231 Tests whether unsubscribtion to subscribed events is performing as specified in UPnP specifications. |
|
1232 @param None |
|
1233 @return None. |
|
1234 */ |
|
1235 void CTestUPnPManager::UnsubscribeForStateChangeNotificationsL(const TDesC& aOperationType) |
|
1236 { |
|
1237 _LIT(KInfoLogFile, "UnsubscribeForStateChangeNotificationsL().... \n"); |
|
1238 INFO_PRINTF1(KInfoLogFile); |
|
1239 |
|
1240 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1241 iObserverArray.Append(upnpObserver); |
|
1242 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL(); |
|
1243 CleanupClosePushL( *pnpBundle ); |
|
1244 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1245 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPCancelSubscribeParamSet); |
|
1246 TBool readIni = EFalse; |
|
1247 GetBoolFromConfig(aOperationType, KReadIni, readIni); |
|
1248 if(readIni) |
|
1249 { |
|
1250 CUPnPCancelSubscribeParamSet * unsubscribeParamSet = CUPnPCancelSubscribeParamSet::NewL(pnpFamily); |
|
1251 TPtrC unsubscribepath; |
|
1252 _LIT(KUnsubscribePath, "unsubscribepath"); |
|
1253 GetStringFromConfig(aOperationType, KUnsubscribePath, unsubscribepath); |
|
1254 RBuf8 unsubscribepathBuf; |
|
1255 unsubscribepathBuf.Create(unsubscribepath.Length()); |
|
1256 unsubscribepathBuf.Copy(unsubscribepath); |
|
1257 unsubscribeParamSet->SetUriL(unsubscribepathBuf); |
|
1258 _LIT(KCanCelSubscribeInfo,"Executing Cancel Subscribe for URI: %S \n"); |
|
1259 INFO_PRINTF2(KCanCelSubscribeInfo, &unsubscribepath); |
|
1260 iControlPoint.Cancel(*pnpBundle ); |
|
1261 unsubscribepathBuf.Close(); |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 TInt eventUriCount = iEventUriArray.Count(); |
|
1266 if ( eventUriCount==0 ) |
|
1267 { |
|
1268 _LIT(KEventUnSubscription,"Event UnSubscription Cannot be performed \n"); |
|
1269 INFO_PRINTF1(KEventUnSubscription); |
|
1270 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1271 return; |
|
1272 } |
|
1273 for(TInt index(0); index < eventUriCount ; index++)//eventUriCount |
|
1274 { |
|
1275 CUPnPCancelSubscribeParamSet * unsubscribeParamSet = CUPnPCancelSubscribeParamSet::NewL(pnpFamily); |
|
1276 unsubscribeParamSet ->SetUriL(iEventUriArray[index]); |
|
1277 RBuf eventUri16; |
|
1278 eventUri16.Create(iEventUriArray[index].Length()); |
|
1279 eventUri16.Copy(iEventUriArray[index]); |
|
1280 _LIT(KEventSubUriInfo,"Event Uri Submitted for UnSubscription Request is: %S \n"); |
|
1281 INFO_PRINTF2(KEventSubUriInfo, &eventUri16); |
|
1282 eventUri16.Close(); |
|
1283 } |
|
1284 iControlPoint.Cancel(*pnpBundle ); |
|
1285 } |
|
1286 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1287 _LIT(KInfoLogFile1, "UnsubscribeForStateChangeNotificationsL() End.... \n"); |
|
1288 INFO_PRINTF1(KInfoLogFile1); |
|
1289 } |
|
1290 |
|
1291 /* |
|
1292 Test for Intiatting a Control Action from Control Point side |
|
1293 @param aOperationType is reference to a section name in ini file where required parameters |
|
1294 needs to be referred for this operation. |
|
1295 @return None. |
|
1296 */ |
|
1297 void CTestUPnPManager::InitiateActionL(const TDesC& /* aOperationType */) |
|
1298 { |
|
1299 _LIT(KInfoLogFile, "InitiateActionL().... \n"); |
|
1300 INFO_PRINTF1(KInfoLogFile); |
|
1301 ResolveAllUrisL(); |
|
1302 if(!iAction) |
|
1303 { |
|
1304 iAction= CAction::NewL(this); |
|
1305 } |
|
1306 for(TInt i(0); i < iControlUriArray.Count(); i++) |
|
1307 { |
|
1308 RBuf controlUri16; |
|
1309 controlUri16.Create(iControlUriArray[i].Length()); |
|
1310 controlUri16.Copy(iControlUriArray[i]); |
|
1311 _LIT(KContolUri, "<font color=00ff00><b><u>Control Uri Submitted is: %S </b></u></font>"); |
|
1312 INFO_PRINTF2(KContolUri, &controlUri16); |
|
1313 iAction->InitiateActionControlL(iControlUriArray[i],iControlPoint); |
|
1314 controlUri16.Close(); |
|
1315 } |
|
1316 _LIT(KInfoLogFile1, "InitiateActionL() End.... \n"); |
|
1317 INFO_PRINTF1(KInfoLogFile1); |
|
1318 } |
|
1319 |
|
1320 /* |
|
1321 Test for Cancelling Discovery Operation |
|
1322 @param aOperationType is reference to a section name in ini file where required parameters |
|
1323 needs to be referred for this operation. |
|
1324 @return None. |
|
1325 */ |
|
1326 void CTestUPnPManager::CancelDiscoverL(const TDesC& aOperationType) |
|
1327 { |
|
1328 iCancelDiscovery = ETrue; |
|
1329 const TInt KBufLength = 1000; |
|
1330 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1331 iObserverArray.Append(upnpObserver); |
|
1332 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1333 CleanupClosePushL( *pnpBundle ); |
|
1334 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1335 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPCancelDiscoverParamSet ); |
|
1336 CUPnPCancelDiscoverParamSet* cancelDiscoverParamSet = CUPnPCancelDiscoverParamSet::NewL(pnpFamily ); |
|
1337 TPtrC serviceType; |
|
1338 GetStringFromConfig(aOperationType, KServiceType, serviceType); |
|
1339 RBuf8 buf; |
|
1340 buf.Create(KBufLength); |
|
1341 buf.Copy(serviceType); |
|
1342 cancelDiscoverParamSet->SetUriL( buf ); |
|
1343 iControlPoint.Cancel (*pnpBundle ); |
|
1344 buf.Close(); |
|
1345 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1346 |
|
1347 TBool flag=ETrue; |
|
1348 _LIT(KStopScheduler,"stopscheduler"); |
|
1349 GetBoolFromConfig(aOperationType,KStopScheduler,flag); |
|
1350 if(flag) |
|
1351 { |
|
1352 CActiveScheduler::Stop(); |
|
1353 } |
|
1354 _LIT(KInfoLogFile1, "CancelDiscoverL() End.... \n"); |
|
1355 INFO_PRINTF1(KInfoLogFile1); |
|
1356 } |
|
1357 |
|
1358 void CTestUPnPManager::CancelDescribeL(const TDesC& aOperationType) |
|
1359 { |
|
1360 //Modify this later |
|
1361 const TInt KBufLength = 1000; |
|
1362 _LIT(KInfoLogFile, "CancelDescribeL().... \n"); |
|
1363 INFO_PRINTF1(KInfoLogFile); |
|
1364 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1365 iObserverArray.Append(upnpObserver); |
|
1366 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1367 CleanupClosePushL( *pnpBundle ); |
|
1368 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1369 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPCancelDescribeParamSet ); |
|
1370 CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL(pnpFamily ); |
|
1371 TPtrC serviceType; |
|
1372 GetStringFromConfig(aOperationType, KServiceType, serviceType); |
|
1373 _LIT(KCanCelDiscoveryInfo,"Executing Cancel Describe for URI: %S \n"); |
|
1374 INFO_PRINTF2(KCanCelDiscoveryInfo, &serviceType); |
|
1375 RBuf8 buf; |
|
1376 buf.Create(KBufLength); |
|
1377 buf.Copy(serviceType); |
|
1378 cancelDescribeParamSet->SetUriL( buf ); |
|
1379 iControlPoint.Cancel (*pnpBundle ); |
|
1380 buf.Close(); |
|
1381 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1382 _LIT(KInfoLogFile1, "CancelDescribeL() End.... \n"); |
|
1383 INFO_PRINTF1(KInfoLogFile1); |
|
1384 } |
|
1385 |
|
1386 /* |
|
1387 Cancells all persistent Device Description Requests. |
|
1388 */ |
|
1389 void CTestUPnPManager::CancelAllDeviceDescribeL() |
|
1390 { |
|
1391 _LIT(KInfoLogFile, "CancelAllDeviceDescribeL().... \n"); |
|
1392 INFO_PRINTF1(KInfoLogFile); |
|
1393 |
|
1394 //this perofrms only Cancellation of all Device descriptions only |
|
1395 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1396 iObserverArray.Append(upnpObserver); |
|
1397 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1398 CleanupClosePushL( *pnpBundle ); |
|
1399 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1400 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPCancelDescribeParamSet ); |
|
1401 TInt DevLocCount = iDeviceLocationArray.Count(); |
|
1402 for(TInt index(0); index < DevLocCount ; index++) |
|
1403 { |
|
1404 TBuf8<256> url; |
|
1405 TUriParser8 uri; |
|
1406 uri.Parse(iDeviceLocationArray[index]); |
|
1407 url.Copy(_L8("http://")); |
|
1408 const TDesC8& scheme = uri.Extract(EUriScheme); |
|
1409 _LIT8(KScheme, "http"); |
|
1410 //Uri must be of scheme "http" only |
|
1411 if (scheme.CompareF(KScheme) == 0) |
|
1412 { |
|
1413 const TDesC8& host = uri.Extract(EUriHost); |
|
1414 url.Append(host); |
|
1415 url.Append(_L8(":")); |
|
1416 const TDesC8& portStr = uri.Extract ( EUriPort ); |
|
1417 url.Append(portStr); |
|
1418 url.Append(_L8("/")) ; |
|
1419 CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL(pnpFamily ); |
|
1420 cancelDescribeParamSet->SetUriL(url); |
|
1421 RBuf uri16; |
|
1422 uri16.Create(url.Length()); |
|
1423 uri16.Copy(url); |
|
1424 _LIT(KCanCelDescribeInfo,"Executing Cancel Describe for URI: %S \n"); |
|
1425 INFO_PRINTF2(KCanCelDescribeInfo, &uri16); |
|
1426 uri16.Close(); |
|
1427 } |
|
1428 } |
|
1429 iControlPoint.Cancel (*pnpBundle ); |
|
1430 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1431 CActiveScheduler::Stop(); |
|
1432 _LIT(KInfoLogFile1, "CancelAllDeviceDescribeL() End.... \n"); |
|
1433 INFO_PRINTF1(KInfoLogFile1); |
|
1434 |
|
1435 } |
|
1436 |
|
1437 /* |
|
1438 * this perofrms only Cancellation of all Service descriptions only |
|
1439 */ |
|
1440 void CTestUPnPManager::CancelAllServiceDescribeL() |
|
1441 { |
|
1442 _LIT(KInfoLogFile, "CancelAllServiceDescribeL().... \n"); |
|
1443 INFO_PRINTF1(KInfoLogFile); |
|
1444 |
|
1445 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1446 iObserverArray.Append(upnpObserver); |
|
1447 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1448 CleanupClosePushL( *pnpBundle ); |
|
1449 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1450 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL ( *pnpBundle , EUPnPCancelDescribeParamSet ); |
|
1451 TInt scpdCount = iScpdUriArray.Count(); |
|
1452 for(TInt index(0); index < scpdCount ; index++) |
|
1453 { |
|
1454 RBuf uri16; |
|
1455 uri16.Create(iScpdUriArray[index].Length()); |
|
1456 uri16.Copy(iScpdUriArray[index]); |
|
1457 _LIT(KCanCelDescribeServiceInfo,"Executing Cancel DescribeService for URI: %S \n"); |
|
1458 INFO_PRINTF2(KCanCelDescribeServiceInfo, &uri16); |
|
1459 uri16.Close(); |
|
1460 CUPnPCancelDescribeParamSet* cancelDescribeParamSet = CUPnPCancelDescribeParamSet::NewL(pnpFamily ); |
|
1461 cancelDescribeParamSet->SetUriL(iScpdUriArray[index]); |
|
1462 } |
|
1463 iControlPoint.Cancel (*pnpBundle ); |
|
1464 CleanupStack::PopAndDestroy( pnpBundle ); |
|
1465 CActiveScheduler::Stop(); |
|
1466 _LIT(KInfoLogFile1, "CancelAllServiceDescribeL() End.... \n"); |
|
1467 INFO_PRINTF1(KInfoLogFile1); |
|
1468 |
|
1469 } |
|
1470 |
|
1471 /* |
|
1472 Test for Cancelling Register Announcement |
|
1473 @param aOperationType is reference to a section name in ini file where required parameters |
|
1474 needs to be referred for this operation. |
|
1475 @return None. |
|
1476 */ |
|
1477 void CTestUPnPManager::CancelNotifyAnnouncementL(const TDesC& aOperationType) |
|
1478 { |
|
1479 _LIT(KInfoLogFile, "CancelNotifyAnnouncementL().... \n"); |
|
1480 INFO_PRINTF1(KInfoLogFile); |
|
1481 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
1482 iObserverArray.Append(upnpObserver); |
|
1483 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
1484 CleanupClosePushL( *pnpBundle ); |
|
1485 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
1486 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPCancelRegisterNotifyParamSet); |
|
1487 CUPnPCancelRegisterNotifyParamSet * cancelNotifyParamSet = CUPnPCancelRegisterNotifyParamSet::NewL(pnpFamily); |
|
1488 TPtrC uri; |
|
1489 GetStringFromConfig(aOperationType, KUri, uri); |
|
1490 RBuf8 buf; |
|
1491 buf.Create(uri.Length()); |
|
1492 buf.Copy(uri); |
|
1493 cancelNotifyParamSet->SetUriL(buf); |
|
1494 iControlPoint.Cancel (*pnpBundle); |
|
1495 buf.Close(); |
|
1496 CleanupStack::PopAndDestroy(pnpBundle); |
|
1497 _LIT(KInfoLogFile1, "CancelNotifyAnnouncementL() End.... \n"); |
|
1498 INFO_PRINTF1(KInfoLogFile1); |
|
1499 } |
|
1500 |
|
1501 void CTestUPnPManager::AppendBundlesL(CPnPParameterBundleBase* aPnPBundle) |
|
1502 { |
|
1503 iResultsArray.AppendL(aPnPBundle); |
|
1504 } |
|
1505 |
|
1506 /* |
|
1507 Validates the discovery response received from the callback against the expected discovery response. |
|
1508 @param aIndex is an integer refers to an index in the ResultsArray of CResults object. |
|
1509 @param aResultsList is an array for section names for expected results section. |
|
1510 @param aExpctedResults is an array of Bools and each of the element indicates whether the expected results |
|
1511 in each section are matched against actual results. |
|
1512 @return None |
|
1513 */ |
|
1514 |
|
1515 void CTestUPnPManager::PrintAndValidateResultsL(const TDesC& aOperationType) |
|
1516 { |
|
1517 _LIT(KInfoLogFile, "PrintAndValidateResultsL().... \n"); |
|
1518 INFO_PRINTF1(KInfoLogFile); |
|
1519 TInt resultsCount = 0; |
|
1520 const TInt bundleCount = iResultsArray.Count(); |
|
1521 _LIT(KPrintStatement, "printing results \n"); |
|
1522 _LIT(KPrintDesign," \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n"); |
|
1523 INFO_PRINTF1(KPrintStatement); |
|
1524 INFO_PRINTF1(KPrintDesign); |
|
1525 for(TInt i(0); i < bundleCount; i++) |
|
1526 { |
|
1527 CUPnPParameterFamily* paramFamily = static_cast<CUPnPParameterFamily*> ( iResultsArray[i]->GetFamilyByIndex() ); |
|
1528 if( paramFamily ) |
|
1529 { |
|
1530 switch ( paramFamily->Id() ) |
|
1531 { |
|
1532 case EUPnPDiscoverResponseParamSet: |
|
1533 { |
|
1534 PrintDiscoveryResultsL(paramFamily); |
|
1535 ValidateDiscoveryResultsL(aOperationType); |
|
1536 } |
|
1537 break; |
|
1538 |
|
1539 case EUPnPPresenceAnnouncementParamSet: |
|
1540 { |
|
1541 TParamSetIter<CUPnPPresenceAnnouncementParamSet> iter; |
|
1542 CUPnPPresenceAnnouncementParamSet* paramSet = NULL; |
|
1543 paramFamily->InitializeIter(iter); |
|
1544 while ( !iter.AtEnd() ) |
|
1545 { |
|
1546 //Paramset at current position |
|
1547 paramSet = iter(); |
|
1548 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1549 { |
|
1550 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1551 _LIT(KRegisterAliveFailed,"Failed to Send Register Alive Notifications with...Error Code = %d \n"); |
|
1552 ERR_PRINTF2(KRegisterAliveFailed, error); |
|
1553 //SetTestStepResult(EFail); |
|
1554 ++iter; |
|
1555 continue; |
|
1556 } |
|
1557 TPtrC8 serviceLocation(paramSet->ServiceLocation()); |
|
1558 HBufC* devloc = HBufC::NewLC(serviceLocation.Length()); //1 |
|
1559 devloc->Des().Copy(serviceLocation); |
|
1560 TPtrC devLocPointer (devloc->Des()); |
|
1561 _LIT(KInfoUri,"The URI found is %S \n"); |
|
1562 INFO_PRINTF2(KInfoUri, &devLocPointer); |
|
1563 |
|
1564 TInt availabilityDuration = 0; |
|
1565 availabilityDuration = paramSet->Duration(); |
|
1566 _LIT(KInfoDuration,"The service availability duration is %d \n"); |
|
1567 INFO_PRINTF2(KInfoDuration, &availabilityDuration); |
|
1568 |
|
1569 _LIT(KInfoAlive,"ssdp:alive notification got from %S AND Duration is %d\n"); |
|
1570 INFO_PRINTF3(KInfoAlive, &devLocPointer, &availabilityDuration); |
|
1571 |
|
1572 TPtrC8 usn(paramSet->USN()); |
|
1573 HBufC* usnVal = HBufC::NewLC(usn.Length()); //2 |
|
1574 usnVal->Des().Copy(usn); |
|
1575 TPtrC usnValPointer (usnVal->Des()); |
|
1576 _LIT(KInfoUSN,"The USN found is %S \n"); |
|
1577 INFO_PRINTF2(KInfoUSN, &usnValPointer); |
|
1578 |
|
1579 TPtrC8 uri(paramSet->Uri()); |
|
1580 HBufC* uriVal = HBufC::NewLC(uri.Length()); //3 |
|
1581 uriVal->Des().Copy(uri); |
|
1582 TPtrC uriValPointer (uriVal->Des()); |
|
1583 _LIT(KInfoURI,"The Uri found is %S \n"); |
|
1584 INFO_PRINTF2(KInfoURI, &uriValPointer); |
|
1585 resultsCount++; |
|
1586 CleanupStack::PopAndDestroy(uriVal); |
|
1587 CleanupStack::PopAndDestroy(usnVal); |
|
1588 CleanupStack::PopAndDestroy(devloc); |
|
1589 ++iter; |
|
1590 } |
|
1591 } |
|
1592 break; |
|
1593 case EUPnPDescribeResponseParamSet: |
|
1594 { |
|
1595 TParamSetIter<CUPnPDescribeResponseParamSet> iter; |
|
1596 CUPnPDescribeResponseParamSet* paramSet = NULL; |
|
1597 paramFamily->InitializeIter(iter); |
|
1598 while ( !iter.AtEnd() ) |
|
1599 { |
|
1600 paramSet = iter(); |
|
1601 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1602 { |
|
1603 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1604 _LIT(KDescribeFailed,"Failed to Describe with...Error Code = %d \n"); |
|
1605 ERR_PRINTF2(KDescribeFailed, error); |
|
1606 //SetTestStepResult(EFail); |
|
1607 return; |
|
1608 } |
|
1609 TPtrC8 description(paramSet->Description()); |
|
1610 HBufC* descriptionValue = HBufC::NewLC(description.Length()); |
|
1611 descriptionValue->Des().Copy(description); |
|
1612 TPtrC descriptionPointer (descriptionValue->Des()); |
|
1613 _LIT(KInfoDescribe,"content is %S \n"); |
|
1614 INFO_PRINTF2(KInfoDescribe, &descriptionPointer); |
|
1615 CleanupStack::PopAndDestroy(descriptionValue); |
|
1616 ++iter; |
|
1617 resultsCount++; |
|
1618 } |
|
1619 //Reached Eof the Bundles |
|
1620 } |
|
1621 break; |
|
1622 case EUPnPAbsenceAnnouncementParamSet: |
|
1623 { |
|
1624 TParamSetIter<CUPnPAbsenceAnnouncementParamSet> iter; |
|
1625 CUPnPAbsenceAnnouncementParamSet* paramSet = NULL; |
|
1626 paramFamily->InitializeIter(iter); |
|
1627 |
|
1628 while ( !iter.AtEnd() ) |
|
1629 { |
|
1630 //Paramset at current position |
|
1631 paramSet = iter(); |
|
1632 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1633 { |
|
1634 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1635 _LIT(KRegisterByeByeFailed,"Failed to Send Register ByeBye Notifications with...Error Code = %d \n"); |
|
1636 ERR_PRINTF2(KRegisterByeByeFailed, error); |
|
1637 //SetTestStepResult(EFail); |
|
1638 ++iter; |
|
1639 continue; |
|
1640 } |
|
1641 TPtrC8 usn(paramSet->USN()); |
|
1642 HBufC* usnVal = HBufC::NewLC(usn.Length()); |
|
1643 usnVal->Des().Copy(usn); |
|
1644 TPtrC usnValPointer (usnVal->Des()); |
|
1645 |
|
1646 _LIT(KInfoBye,"ssdp:byebye notification received from %S \n"); |
|
1647 INFO_PRINTF2(KInfoBye, &usnValPointer); |
|
1648 resultsCount++; |
|
1649 CleanupStack::PopAndDestroy(usnVal); |
|
1650 ++iter; |
|
1651 } |
|
1652 } |
|
1653 break; |
|
1654 case EUPnPSubscribeResponseParamSet: |
|
1655 { |
|
1656 TParamSetIter<CUPnPSubscribeResponseParamSet> iter; |
|
1657 CUPnPSubscribeResponseParamSet* paramSet = NULL; |
|
1658 paramFamily->InitializeIter(iter); |
|
1659 while ( !iter.AtEnd() ) |
|
1660 { |
|
1661 //Paramset at current position |
|
1662 paramSet = iter(); |
|
1663 RBuf subscriptionUri16; |
|
1664 subscriptionUri16.Create(paramSet->Uri().Length()); |
|
1665 subscriptionUri16.Copy(paramSet->Uri()); |
|
1666 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1667 { |
|
1668 _LIT(KInfoSubscribeFailed, "Err: Failed to Subscribe.\n %S \n"); |
|
1669 INFO_PRINTF2(KInfoSubscribeFailed,&subscriptionUri16); |
|
1670 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1671 _LIT(KErrSubscribe,"Failed to Subscribe with...Error Code = %d \n"); |
|
1672 ERR_PRINTF2(KErrSubscribe, error); |
|
1673 //SetTestStepResult(EFail); |
|
1674 } |
|
1675 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESubscriptionTimeout) |
|
1676 { |
|
1677 _LIT(KInfoSubscribeTimedOut, "Info: SubscribeTimed out \n %S \n"); |
|
1678 INFO_PRINTF2(KInfoSubscribeTimedOut,&subscriptionUri16); |
|
1679 } |
|
1680 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess) |
|
1681 { |
|
1682 _LIT(KInfoSubscribeSuccess, "<font color=00ff00><b><u>Info: Subscribtion SUCCESS</u></b></font>\n %S \n"); |
|
1683 INFO_PRINTF2(KInfoSubscribeSuccess,&subscriptionUri16); |
|
1684 } |
|
1685 subscriptionUri16.Close(); |
|
1686 ++iter; |
|
1687 } |
|
1688 } |
|
1689 break; |
|
1690 case EUPnPNotifyEventParamSet: |
|
1691 {//receives event notifications sent at client |
|
1692 TParamSetIter<CUPnPNotifyEventParamSet> iter; |
|
1693 CUPnPNotifyEventParamSet* paramSet = NULL; |
|
1694 paramFamily->InitializeIter(iter); |
|
1695 while ( !iter.AtEnd() ) |
|
1696 { |
|
1697 //Paramset at current position |
|
1698 paramSet = iter(); |
|
1699 RBuf subscriptionUri16; |
|
1700 subscriptionUri16.Create(paramSet->Uri().Length()); |
|
1701 subscriptionUri16.Copy(paramSet->Uri()); |
|
1702 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1703 { |
|
1704 ++iter; |
|
1705 _LIT(KInfoNotificationsFailed, "Err: Failed to Get Event notifications \n %S \n"); |
|
1706 INFO_PRINTF2(KInfoNotificationsFailed,&subscriptionUri16); |
|
1707 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1708 _LIT(KNotificationsFailed,"Failed to Receive Notifications with...Error Code = %d \n"); |
|
1709 ERR_PRINTF2(KNotificationsFailed, error); |
|
1710 //SetTestStepResult(EFail); |
|
1711 } |
|
1712 else if (paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess) |
|
1713 { |
|
1714 _LIT(KInfoNotifications, "Notifications for subscribed Uri: %S \t is received \n"); |
|
1715 INFO_PRINTF2(KInfoNotifications, &subscriptionUri16); |
|
1716 ++iter; |
|
1717 } |
|
1718 subscriptionUri16.Close(); |
|
1719 } |
|
1720 } |
|
1721 break; |
|
1722 default: |
|
1723 { |
|
1724 //Do Nothing |
|
1725 } |
|
1726 break; |
|
1727 } |
|
1728 } |
|
1729 } |
|
1730 _LIT(KEndPrintStatement,"Done with printing results \n"); |
|
1731 INFO_PRINTF1(KEndPrintStatement); |
|
1732 INFO_PRINTF1(KPrintDesign); |
|
1733 } |
|
1734 |
|
1735 /* |
|
1736 Constructor: |
|
1737 */ |
|
1738 CUPnPObserver::CUPnPObserver() |
|
1739 :iSequence(0),iResultsCount(0) |
|
1740 { |
|
1741 } |
|
1742 |
|
1743 /* |
|
1744 Destructor |
|
1745 */ |
|
1746 CUPnPObserver::~CUPnPObserver() |
|
1747 { |
|
1748 iFileServ.Close(); |
|
1749 } |
|
1750 |
|
1751 |
|
1752 /* |
|
1753 Static factory constructor. Uses two phase construction and leaves nothing on the |
|
1754 CleanupStack. Creates a CTestControlPointService object. |
|
1755 @param aManager A pointer to a CTestUPnPManager object. |
|
1756 @return A pointer to the newly created CPnPObserver object. |
|
1757 @post A fully constructed and initialized CPnPObserver object. |
|
1758 */ |
|
1759 CUPnPObserver* CUPnPObserver::NewL(CTestUPnPManager* aManager) |
|
1760 { |
|
1761 CUPnPObserver* self = new(ELeave) CUPnPObserver; |
|
1762 CleanupStack::PushL(self); |
|
1763 self->ConstructL(aManager); |
|
1764 CleanupStack::Pop(self); |
|
1765 return self; |
|
1766 } |
|
1767 |
|
1768 /* |
|
1769 Second phase of two-phase construction method. Does any allocations required to fully construct |
|
1770 the object. |
|
1771 @pre First phase of construction is complete. |
|
1772 @param aManager A pointer to a CTestUPnPManager object. |
|
1773 @post The object is fully constructed and initialized. |
|
1774 */ |
|
1775 void CUPnPObserver::ConstructL(CTestUPnPManager* aManager) |
|
1776 { |
|
1777 iManager = aManager; |
|
1778 User::LeaveIfError(iFileServ.Connect()); |
|
1779 } |
|
1780 |
|
1781 |
|
1782 |
|
1783 /* |
|
1784 This method returns a reference to the CTestUPnPManager object. |
|
1785 @param None |
|
1786 return a reference to the CTestUPnPManager object |
|
1787 */ |
|
1788 CTestUPnPManager& CUPnPObserver::Manager() |
|
1789 { |
|
1790 return *iManager; |
|
1791 } |
|
1792 |
|
1793 void CTestUPnPManager::DoTestOOML (TInt aTestType) |
|
1794 { |
|
1795 TInt iTryCount = 1; |
|
1796 TInt err=0; |
|
1797 // __UHEAP_MARK; |
|
1798 for ( ;; ) |
|
1799 { |
|
1800 __UHEAP_SETFAIL(RHeap::EFailNext, iTryCount); |
|
1801 |
|
1802 switch(aTestType) |
|
1803 { |
|
1804 case EPublishDevice: |
|
1805 TRAP( err, PublishDeviceL()); |
|
1806 break; |
|
1807 case EOpenDiscover: |
|
1808 TRAP(err,OpenDiscovererL()); |
|
1809 break; |
|
1810 case EDiscover: |
|
1811 TRAP(err, DiscoverL()); |
|
1812 break; |
|
1813 case EPublishService: |
|
1814 TRAP(err,PublishServiceL()); |
|
1815 break; |
|
1816 default: |
|
1817 break; |
|
1818 } |
|
1819 |
|
1820 if ( err == KErrNone ) |
|
1821 { |
|
1822 __UHEAP_RESET; |
|
1823 INFO_PRINTF1(_L("Memory allocation testing completed. No of allocations ")); |
|
1824 break; |
|
1825 } |
|
1826 if ( err != KErrNoMemory ) |
|
1827 { |
|
1828 SetTestStepResult(EFail); |
|
1829 User::Leave(err); |
|
1830 } |
|
1831 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
1832 if(aTestType == EPublishDevice && iTryCount == 25) |
|
1833 { |
|
1834 iTryCount = 30; |
|
1835 } |
|
1836 iTryCount++; |
|
1837 } |
|
1838 // __UHEAP_MARKEND; |
|
1839 INFO_PRINTF2(_L("TRYCOUNT %d"), iTryCount); |
|
1840 } |
|
1841 |
|
1842 /* |
|
1843 This is called when callback hits. And this method stores the bundle results |
|
1844 and meta information related to that results into results array maintained by manager |
|
1845 for later verification. |
|
1846 @param aParameterBundle a reference to CPnPParameterBundleBase |
|
1847 @return None |
|
1848 */ |
|
1849 void CUPnPObserver::OnPnPEventL ( CPnPParameterBundleBase& aParameterBundle) |
|
1850 { |
|
1851 _LIT(KInfoLogFile, "OnPnPEventL ().... \n"); |
|
1852 Manager().INFO_PRINTF1(KInfoLogFile); |
|
1853 |
|
1854 CopyResultBundlesL(aParameterBundle); |
|
1855 CUPnPParameterFamily* paramFamily = static_cast<CUPnPParameterFamily*> ( aParameterBundle.GetFamilyByIndex() ); |
|
1856 if( paramFamily ) |
|
1857 { |
|
1858 switch ( paramFamily->Id() ) |
|
1859 { |
|
1860 case EUPnPDiscoverResponseParamSet: |
|
1861 { |
|
1862 TParamSetIter<CUPnPDiscoverResponseParamSet> iter; |
|
1863 CUPnPDiscoverResponseParamSet* paramSet = NULL; |
|
1864 paramFamily->InitializeIter(iter); |
|
1865 while (!iter.AtEnd()) |
|
1866 { |
|
1867 paramSet = iter(); |
|
1868 //Printig of Search target |
|
1869 TPtrC8 uriST(paramSet->Uri()); |
|
1870 HBufC* stUri = HBufC::NewLC(uriST.Length()); |
|
1871 stUri->Des().Copy(uriST); |
|
1872 TPtrC uriStPtr (stUri->Des()); |
|
1873 CleanupStack::PopAndDestroy(stUri); |
|
1874 |
|
1875 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EDiscoveryTimeout) |
|
1876 { |
|
1877 CActiveScheduler::Stop(); |
|
1878 return; |
|
1879 } |
|
1880 } |
|
1881 } |
|
1882 break; |
|
1883 case EUPnPPresenceAnnouncementParamSet: |
|
1884 { |
|
1885 TParamSetIter<CUPnPPresenceAnnouncementParamSet> iter; |
|
1886 CUPnPPresenceAnnouncementParamSet* paramSet = NULL; |
|
1887 paramFamily->InitializeIter(iter); |
|
1888 |
|
1889 while ( !iter.AtEnd() ) |
|
1890 { |
|
1891 paramSet = iter(); |
|
1892 //Printig of Search target |
|
1893 TPtrC8 uriST(paramSet->Uri()); |
|
1894 HBufC* stUri = HBufC::NewLC(uriST.Length()); |
|
1895 stUri->Des().Copy(uriST); |
|
1896 TPtrC uriStPtr (stUri->Des()); |
|
1897 _LIT(KInfoST,"<b>The RegisterNotify URI was: <u>%S</u> </b>\n"); |
|
1898 Manager().INFO_PRINTF2(KInfoST, &uriStPtr); |
|
1899 CleanupStack::PopAndDestroy(stUri); |
|
1900 |
|
1901 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1902 { |
|
1903 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1904 _LIT(KRegisterNotifyFail,"Resgitser Notify Failed: TUPnPEvent::EFail Error Code is = %d \n"); |
|
1905 Manager().ERR_PRINTF2(KRegisterNotifyFail,error); |
|
1906 CActiveScheduler::Stop(); |
|
1907 //Manager().SetTestStepResult(EFail); |
|
1908 return; |
|
1909 } |
|
1910 TPtrC8 serviceLocation(paramSet->ServiceLocation()); |
|
1911 HBufC* servloc = HBufC::NewLC(serviceLocation.Length()); //1 |
|
1912 servloc->Des().Copy(serviceLocation); |
|
1913 TPtrC servlocPointer (servloc->Des()); |
|
1914 TInt duration = paramSet->Duration(); |
|
1915 _LIT(KInfoAlive,"<font color=1f6633><b>ssdp:alive notification got from %S AND Duration is %d </b></font>\n"); |
|
1916 iManager->INFO_PRINTF3(KInfoAlive, &servlocPointer, &duration); |
|
1917 CleanupStack::PopAndDestroy(servloc); |
|
1918 ++iter; |
|
1919 iResultsCount++; |
|
1920 } |
|
1921 _LIT(KInfoLogFile, "EUPnPPresenceAnnouncementParamSet.... \n"); |
|
1922 Manager().INFO_PRINTF1(KInfoLogFile); |
|
1923 } |
|
1924 break; |
|
1925 |
|
1926 case EUPnPAbsenceAnnouncementParamSet: |
|
1927 { |
|
1928 TParamSetIter<CUPnPAbsenceAnnouncementParamSet> iter; |
|
1929 CUPnPAbsenceAnnouncementParamSet* paramSet = NULL; |
|
1930 paramFamily->InitializeIter(iter); |
|
1931 |
|
1932 while ( !iter.AtEnd() ) |
|
1933 { |
|
1934 paramSet = iter(); |
|
1935 //Printig of Search target |
|
1936 TPtrC8 uriST(paramSet->Uri()); |
|
1937 HBufC* stUri = HBufC::NewLC(uriST.Length()); |
|
1938 stUri->Des().Copy(uriST); |
|
1939 TPtrC uriStPtr (stUri->Des()); |
|
1940 _LIT(KInfoST,"<b>The RegisterNotify URI was: <u>%S</u> </b>\n"); |
|
1941 Manager().INFO_PRINTF2(KInfoST, &uriStPtr); |
|
1942 CleanupStack::PopAndDestroy(stUri); |
|
1943 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
1944 { |
|
1945 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
1946 _LIT(KRegisterNotifyByeByeFail,"Resgitser Notify ByeBye Failed: TUPnPEvent::EFail Error Code is = %d \n"); |
|
1947 Manager().ERR_PRINTF2(KRegisterNotifyByeByeFail, error); |
|
1948 CActiveScheduler::Stop(); |
|
1949 //Manager().SetTestStepResult(EFail); |
|
1950 return; |
|
1951 } |
|
1952 TPtrC8 usn(paramSet->USN()); |
|
1953 HBufC* usnvalue = HBufC::NewLC(usn.Length()); //1 |
|
1954 usnvalue->Des().Copy(usn); |
|
1955 TPtrC usnPointer (usnvalue->Des()); |
|
1956 _LIT(KInfoBye,"<font color=33121f><b>ssdp:byebye notification received from %S </b></font>\n"); |
|
1957 iManager->INFO_PRINTF2(KInfoBye, &usnPointer); |
|
1958 CleanupStack::PopAndDestroy(usnvalue); |
|
1959 ++iter; |
|
1960 } |
|
1961 _LIT(KInfoLogFile, "EUPnPAbsenceAnnouncementParamSet.... \n"); |
|
1962 Manager().INFO_PRINTF1(KInfoLogFile); |
|
1963 } |
|
1964 break; |
|
1965 |
|
1966 case EUPnPPublishResponseParamSet: |
|
1967 { |
|
1968 TBool flag=EFalse; |
|
1969 _LIT(KStopScheduler,"stopscheduler"); |
|
1970 TInt responseCount = 0; |
|
1971 CUPnPPublishResponseParamSet* paramSet = NULL; |
|
1972 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KStopScheduler,flag); |
|
1973 _LIT(KExpectedPublishEesponseCount,"expectedpublishresponsecount"); |
|
1974 Manager().GetIntFromConfig(Manager().GetCurrentSection(),KExpectedPublishEesponseCount,responseCount); |
|
1975 TParamSetIter<CUPnPPublishResponseParamSet> iter; |
|
1976 paramFamily->InitializeIter(iter); |
|
1977 while ( !iter.AtEnd() ) |
|
1978 { |
|
1979 paramSet = iter(); |
|
1980 Manager().iPublishCount--; |
|
1981 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess) |
|
1982 { |
|
1983 TBool sendNotify= EFalse; |
|
1984 TInt notifyCount(0); |
|
1985 _LIT(KInfoPublish, "Info: Succesfully Published a Device/Service."); |
|
1986 Manager().INFO_PRINTF1(KInfoPublish); |
|
1987 _LIT(KSendNotify,"sendnotifications"); |
|
1988 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KSendNotify,sendNotify); |
|
1989 |
|
1990 if(sendNotify) |
|
1991 { |
|
1992 RBuf16 descriptionBaseUri; |
|
1993 descriptionBaseUri.Create(paramSet->Uri().Length()); |
|
1994 descriptionBaseUri.Copy(paramSet->Uri()); |
|
1995 _LIT(KInfoSendNotify, "Info: Calling Send Notify on Uri %S \n"); |
|
1996 Manager().INFO_PRINTF2(KInfoSendNotify, &descriptionBaseUri); |
|
1997 descriptionBaseUri.Close(); |
|
1998 Manager().SendNotificationsL(this); |
|
1999 } |
|
2000 _LIT(KExpctedNotifications,"expectednotifications"); |
|
2001 Manager().GetIntFromConfig(Manager().GetCurrentSection(),KExpctedNotifications,notifyCount); |
|
2002 TInt publishCount = Manager().iPublishCount; |
|
2003 if(flag && notifyCount == Manager().NotifyCount()&& publishCount <= 0 ) |
|
2004 { |
|
2005 _LIT(KInfoLogFile, "EUPnPPublishResponseParamSet Success....And Stopping Active Scheduler after %d Publishes \n"); |
|
2006 Manager().INFO_PRINTF2(KInfoLogFile, publishCount ); |
|
2007 CActiveScheduler::Stop(); |
|
2008 } |
|
2009 } |
|
2010 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2011 { |
|
2012 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2013 _LIT(KErrPublish,"Failed to Published a Device/Service...Error Code is = %d \n"); |
|
2014 Manager().ERR_PRINTF2(KErrPublish, error); |
|
2015 CActiveScheduler::Stop(); |
|
2016 _LIT(KInfoLogFile, "EUPnPPublishResponseParamSet Fail.... \n"); |
|
2017 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2018 //Manager().SetTestStepResult(EFail); |
|
2019 return; |
|
2020 } |
|
2021 ++iter; |
|
2022 } |
|
2023 } |
|
2024 break; |
|
2025 |
|
2026 case EUPnPDescribeResponseParamSet: |
|
2027 { |
|
2028 //abruptdescribeclosecp |
|
2029 //opt for Abrupt close of CP |
|
2030 TBool abruptDiscribeCloseCP = EFalse; |
|
2031 _LIT(KAbruptDiscribeCloseCP,"abruptdescribeclosecp"); |
|
2032 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KAbruptDiscribeCloseCP,abruptDiscribeCloseCP ); |
|
2033 if(abruptDiscribeCloseCP) |
|
2034 { |
|
2035 //Closing Control point Abruptly |
|
2036 _LIT(KInfoSubScribe, "In Describe Response \n"); |
|
2037 _LIT(KInfoCloseCP, "Closing Control point Abruptly.... \n"); |
|
2038 Manager().INFO_PRINTF1(KInfoSubScribe); |
|
2039 Manager().INFO_PRINTF1(KInfoCloseCP); |
|
2040 CActiveScheduler::Stop(); |
|
2041 Manager().CloseDiscoverer(); |
|
2042 return; |
|
2043 } |
|
2044 |
|
2045 TParamSetIter<CUPnPDescribeResponseParamSet> iter; |
|
2046 CUPnPDescribeResponseParamSet* paramSet = NULL; |
|
2047 paramFamily->InitializeIter(iter); |
|
2048 |
|
2049 while ( !iter.AtEnd() ) |
|
2050 { |
|
2051 //Only one response expected for Describe and no iter increment is required |
|
2052 //Paramset at current position |
|
2053 paramSet = iter(); |
|
2054 |
|
2055 RBuf8 descriptionBuf; |
|
2056 RBuf8 descriptionBaseUri; |
|
2057 descriptionBaseUri.Create(paramSet->Uri()); |
|
2058 descriptionBuf.Create(paramSet->Description()); |
|
2059 |
|
2060 RBuf description16; |
|
2061 description16.Create(descriptionBuf.Length()); |
|
2062 description16.Copy(descriptionBuf); |
|
2063 |
|
2064 RBuf descriptionUri16; |
|
2065 descriptionUri16.Create(descriptionBaseUri.Length()); |
|
2066 descriptionUri16.Copy(descriptionBaseUri); |
|
2067 |
|
2068 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2069 { |
|
2070 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2071 _LIT(KDescribeFail,"Describe Response Fail: TUPnPEvent::EFail...Error Code is = %d \n"); |
|
2072 Manager().ERR_PRINTF2(KDescribeFail, error); |
|
2073 _LIT(KDescriptionUri,"Description Uri is %S \n"); |
|
2074 Manager().ERR_PRINTF1(KDescribeFail); |
|
2075 Manager().INFO_PRINTF2(KDescriptionUri, &descriptionUri16 ); |
|
2076 _LIT(KInfoLogFile, "EUPnPDescribeResponseParamSet Fail.... \n"); |
|
2077 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2078 CActiveScheduler::Stop(); |
|
2079 descriptionBuf.Close(); |
|
2080 descriptionBaseUri.Close(); |
|
2081 description16.Close(); |
|
2082 descriptionUri16.Close(); |
|
2083 //Manager().SetTestStepResult(EFail); |
|
2084 return; |
|
2085 } |
|
2086 Manager().AppendDescriptionL(descriptionBaseUri, descriptionBuf); |
|
2087 TFileName filename; |
|
2088 filename.Format(KDefaultFileFormat, 'C'); |
|
2089 TBuf<KMaxBufLength> filenameBuffer(filename); |
|
2090 //get scriptName |
|
2091 filenameBuffer.Append(Manager().ScriptFileName()); |
|
2092 _LIT(KUnderScore, "_"); |
|
2093 filenameBuffer.Append(KUnderScore); |
|
2094 filenameBuffer.AppendNumFixedWidth(iSequence,EDecimal, 4); |
|
2095 iSequence++; |
|
2096 filenameBuffer.Append(KDefaultExtension); |
|
2097 RFile file; |
|
2098 TInt err=file.Replace(iFileServ,filenameBuffer,EFileRead|EFileWrite|EFileShareAny); |
|
2099 if (err == KErrNone) |
|
2100 { |
|
2101 TInt writeErr= file.Write(descriptionBuf); |
|
2102 if(writeErr != KErrNone ) |
|
2103 { |
|
2104 _LIT(KErrWrite,"Unable to Write the description to the File \n"); |
|
2105 Manager().ERR_PRINTF1(KErrWrite); |
|
2106 } |
|
2107 _LIT(KDescriptionUri,"Description Uri is %S \n"); |
|
2108 _LIT(KInfoDescribe,"content is %S \n"); |
|
2109 Manager().INFO_PRINTF2(KDescriptionUri, &descriptionUri16 ); |
|
2110 Manager().INFO_PRINTF2(KInfoDescribe, &description16); |
|
2111 Manager().iDescribeResponseCount++; |
|
2112 } |
|
2113 descriptionBuf.Close(); |
|
2114 descriptionBaseUri.Close(); |
|
2115 description16.Close(); |
|
2116 descriptionUri16.Close(); |
|
2117 file.Close(); |
|
2118 ++iter; |
|
2119 iResultsCount++; |
|
2120 } |
|
2121 TBool cancelAll = EFalse; |
|
2122 Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KCancelAll, cancelAll ); |
|
2123 TBool cancelAllService = EFalse; |
|
2124 Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KCancelAllService, cancelAllService ); |
|
2125 TInt descCount = 1; |
|
2126 Manager().GetIntFromConfig(Manager().GetCurrentSection(), KExpctedDescriptions, descCount ); |
|
2127 |
|
2128 if(Manager().iDescribeResponseCount >= descCount )// Modify this later |
|
2129 { |
|
2130 if(cancelAll) |
|
2131 { |
|
2132 Manager().CancelAllDeviceDescribeL(); |
|
2133 return; |
|
2134 } |
|
2135 else if(cancelAllService) |
|
2136 { |
|
2137 Manager().CancelAllServiceDescribeL(); |
|
2138 return; |
|
2139 } |
|
2140 else |
|
2141 { |
|
2142 CActiveScheduler::Stop(); |
|
2143 _LIT(KInfoLogFile, "EUPnPDescribeResponseParamSet.... \n"); |
|
2144 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2145 return; |
|
2146 } |
|
2147 } |
|
2148 } |
|
2149 break; |
|
2150 case EUPnPSubscribeResponseParamSet: |
|
2151 { |
|
2152 TParamSetIter<CUPnPSubscribeResponseParamSet> iter; |
|
2153 CUPnPSubscribeResponseParamSet* paramSet = NULL; |
|
2154 paramFamily->InitializeIter(iter); |
|
2155 |
|
2156 while ( !iter.AtEnd() ) |
|
2157 { |
|
2158 //Paramset at current position |
|
2159 paramSet = iter(); |
|
2160 RBuf subscriptionUri16; |
|
2161 subscriptionUri16.Create(paramSet->Uri().Length()); |
|
2162 subscriptionUri16.Copy(paramSet->Uri()); |
|
2163 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2164 { |
|
2165 _LIT(KInfoSubscribeFailed, "Info: Failed to Subscribe.\n %S \n"); |
|
2166 Manager().INFO_PRINTF2(KInfoSubscribeFailed,&subscriptionUri16); |
|
2167 subscriptionUri16.Close(); |
|
2168 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2169 _LIT(KSubscribeFailed,"Failed to Subscribe with...Error Code = %d \n"); |
|
2170 Manager().ERR_PRINTF2(KSubscribeFailed, error); |
|
2171 CActiveScheduler::Stop(); |
|
2172 _LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Fail.... \n"); |
|
2173 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2174 //Manager().SetTestStepResult(EFail); |
|
2175 return; |
|
2176 } |
|
2177 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESubscriptionTimeout) |
|
2178 { |
|
2179 _LIT(KInfoSubscribeTimeOut, "Info: Subscription about to expire\n %S \n"); |
|
2180 Manager().INFO_PRINTF2(KInfoSubscribeTimeOut, &subscriptionUri16); |
|
2181 subscriptionUri16.Close(); |
|
2182 _LIT(KInfoSubscribeTimeOut3, "subscription uri deleted\n"); |
|
2183 Manager().INFO_PRINTF1(KInfoSubscribeTimeOut3); |
|
2184 |
|
2185 //Implementation of Resubscribe is here |
|
2186 TBool renewFlag = EFalse; |
|
2187 _LIT(KRenewFlag,"renewflag"); |
|
2188 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KRenewFlag,renewFlag ); |
|
2189 |
|
2190 _LIT(KInfoSubscribeTimeOut1, "renew flag value %d renew count %d \n"); |
|
2191 Manager().INFO_PRINTF3(KInfoSubscribeTimeOut1, renewFlag,Manager().iRenewCount); |
|
2192 |
|
2193 if( renewFlag && Manager().iRenewCount == 0) |
|
2194 {//go to renew here only once |
|
2195 subscriptionUri16.Close();//cleanup activity |
|
2196 CActiveScheduler::Stop();//this is for start made in prev subscribe |
|
2197 _LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Timeout1.... \n"); |
|
2198 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2199 Manager().iRenewCount++; |
|
2200 //renew subscriptions |
|
2201 _LIT(KInfoSubscribeTimeOut2, "renew count %d \n"); |
|
2202 Manager().INFO_PRINTF2(KInfoSubscribeTimeOut2,Manager().iRenewCount); |
|
2203 _LIT(KInfoReSubscribe, "Request to RESUBSCRIPTION is Executed\n %S \n"); |
|
2204 Manager().INFO_PRINTF1(KInfoReSubscribe); |
|
2205 Manager().SubscribeForStateChangeNotificationsL(); |
|
2206 return; |
|
2207 } |
|
2208 else |
|
2209 { |
|
2210 //Unsubscribe before closing |
|
2211 _LIT(KInfoUnSubscribe, "Request to UNSUBSCRIPTION is Executed As Subscription TIMED OUT \n %S \n"); |
|
2212 Manager().INFO_PRINTF1(KInfoUnSubscribe); |
|
2213 TPtrC referSection; |
|
2214 _LIT(KReferSection,"refersection"); |
|
2215 Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection ); |
|
2216 Manager().UnsubscribeForStateChangeNotificationsL(referSection); |
|
2217 subscriptionUri16.Close();//cleanup activity |
|
2218 CActiveScheduler::Stop(); |
|
2219 _LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Timeout2.... \n"); |
|
2220 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2221 return; |
|
2222 } |
|
2223 } |
|
2224 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess) |
|
2225 { |
|
2226 _LIT(KInfoSubscribeSuccess, "Info: SUBSCRIPTION REQUEST IS ACCEPTED FOR SUBSCRIPTION\n %S \n"); |
|
2227 Manager().INFO_PRINTF2(KInfoSubscribeSuccess, &subscriptionUri16); |
|
2228 |
|
2229 //opt for Abrupt close of CP |
|
2230 TBool abruptCloseCP = EFalse; |
|
2231 _LIT(KAbruptCloseCP,"abruptclosecp"); |
|
2232 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KAbruptCloseCP,abruptCloseCP ); |
|
2233 if(abruptCloseCP) |
|
2234 { |
|
2235 //Closing Control point Abruptly |
|
2236 _LIT(KInfoSubScribe, "In Subscribe Response \n"); |
|
2237 _LIT(KInfoCloseCP, "Closing Control point Abruptly.... \n"); |
|
2238 Manager().INFO_PRINTF1(KInfoSubScribe); |
|
2239 Manager().INFO_PRINTF1(KInfoCloseCP); |
|
2240 CActiveScheduler::Stop(); |
|
2241 Manager().CloseDiscoverer(); |
|
2242 return; |
|
2243 } |
|
2244 //Opt for Unsubscribe |
|
2245 TBool unSubscribeFlag = EFalse; |
|
2246 _LIT(KUnsubscribeFlag,"unsubscribeflag"); |
|
2247 Manager().GetBoolFromConfig(Manager().GetCurrentSection(),KUnsubscribeFlag,unSubscribeFlag ); |
|
2248 if(unSubscribeFlag) |
|
2249 {//go to unsubscribe here |
|
2250 _LIT(KInfoUnSubscribe, "Request to UNSUBSCRIPTION is Executed Before Subscription Expiry\n \n"); |
|
2251 Manager().INFO_PRINTF1(KInfoUnSubscribe); |
|
2252 TPtrC referSection; |
|
2253 _LIT(KReferSection,"refersection"); |
|
2254 Manager().GetStringFromConfig(Manager().GetCurrentSection(),KReferSection,referSection ); |
|
2255 //Unsubscribe |
|
2256 Manager().UnsubscribeForStateChangeNotificationsL(referSection); |
|
2257 subscriptionUri16.Close();//cleanup activity |
|
2258 CActiveScheduler::Stop();//this is for start made in prev subscribe |
|
2259 _LIT(KInfoLogFile, "EUPnPSubscribeResponseParamSet Success.... \n"); |
|
2260 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2261 return; |
|
2262 } |
|
2263 } |
|
2264 ++iter; |
|
2265 } |
|
2266 } |
|
2267 break; |
|
2268 case EUPnPNotifyEventParamSet: |
|
2269 {//receives event notifications sent at client |
|
2270 _LIT(KInfoLogFile, "EUPnPNotifyEventParamSet.... \n"); |
|
2271 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2272 |
|
2273 TParamSetIter<CUPnPNotifyEventParamSet> iter; |
|
2274 CUPnPNotifyEventParamSet* paramSet = NULL; |
|
2275 paramFamily->InitializeIter(iter); |
|
2276 |
|
2277 while ( !iter.AtEnd() ) |
|
2278 { |
|
2279 //Paramset at current position |
|
2280 paramSet = iter(); |
|
2281 RBuf subscriptionUri16; |
|
2282 subscriptionUri16.Create(paramSet->Uri().Length()); |
|
2283 subscriptionUri16.Copy(paramSet->Uri()); |
|
2284 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2285 { |
|
2286 ++iter; |
|
2287 _LIT(KInfoNotificationsFailed, "Info: Failed to Get Event notifications\n %S \n"); |
|
2288 Manager().INFO_PRINTF2(KInfoNotificationsFailed,&subscriptionUri16); |
|
2289 subscriptionUri16.Close(); |
|
2290 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2291 _LIT(KNotificationsFailed,"Failed to Receive Notifications with...Error Code = %d \n"); |
|
2292 Manager().ERR_PRINTF2(KNotificationsFailed, error); |
|
2293 //Manager().SetTestStepResult(EFail); |
|
2294 return; |
|
2295 } |
|
2296 else if (paramSet->UPnPEvent().iStatus == TUPnPEvent::ESuccess) |
|
2297 { |
|
2298 _LIT(KInfoNotifications, "Notifications for subscribed Uri: %S \t is received \n"); |
|
2299 Manager().INFO_PRINTF2(KInfoNotifications, &subscriptionUri16); |
|
2300 subscriptionUri16.Close();//cleanup activity |
|
2301 ++iter; |
|
2302 } |
|
2303 } |
|
2304 _LIT(KInfoLogFile1, "EUPnPNotifyEventParamSet End.... \n"); |
|
2305 Manager().INFO_PRINTF1(KInfoLogFile1); |
|
2306 } |
|
2307 break; |
|
2308 default: |
|
2309 { |
|
2310 //Do Nothing |
|
2311 } |
|
2312 break; |
|
2313 } |
|
2314 } |
|
2315 } |
|
2316 |
|
2317 /* |
|
2318 Error handling,asynchronous one. |
|
2319 @param aError Error Code |
|
2320 @return None |
|
2321 */ |
|
2322 void CUPnPObserver::OnPnPError(TInt aError) |
|
2323 { |
|
2324 if(aError == KErrNoMemory) |
|
2325 { |
|
2326 //User::Leave(KErrNoMemory); |
|
2327 } |
|
2328 _LIT(KPositiveCase,"positivecase"); |
|
2329 TBool positiveCase = ETrue; |
|
2330 Manager().GetBoolFromConfig(Manager().GetCurrentSection(), KPositiveCase, positiveCase); |
|
2331 // Note down the error and stop scheduler |
|
2332 //If not postive case, client.dll will come back before active scheduler start |
|
2333 //so, don't execute activescheduler::stop |
|
2334 if (positiveCase) |
|
2335 { |
|
2336 CActiveScheduler::Stop(); |
|
2337 } |
|
2338 _LIT(KErrorMessage, "Error occurred in the UPnP Observer : %d \n"); |
|
2339 Manager().ERR_PRINTF2(KErrorMessage, aError); |
|
2340 //Manager().SetTestStepResult(EFail); |
|
2341 } |
|
2342 |
|
2343 /* |
|
2344 This function copies result bundles into results array, which inturn is used in printing results |
|
2345 @param aPnpBundle a reference to CPnPParameterBundleBase |
|
2346 @return None |
|
2347 */ |
|
2348 void CUPnPObserver::CopyResultBundlesL(const RPnPParameterBundle& aPnpBundle) |
|
2349 { |
|
2350 _LIT(KInfoLogFile, "CUPnPObserver::CopyResultBundlesL().... \n"); |
|
2351 Manager().INFO_PRINTF1(KInfoLogFile); |
|
2352 |
|
2353 HBufC8* holdBundle = HBufC8::NewLC(aPnpBundle.Length()); |
|
2354 |
|
2355 if (!holdBundle) |
|
2356 { |
|
2357 User::Leave(KErrNoMemory); |
|
2358 } |
|
2359 |
|
2360 TPtr8 storePtr(holdBundle->Des()); |
|
2361 TInt retOnStore = aPnpBundle.Store(storePtr); |
|
2362 User::LeaveIfError(retOnStore); |
|
2363 |
|
2364 TPtrC8 loadPtr(holdBundle->Des()); |
|
2365 CPnPParameterBundleBase* newPnpBundle = CPnPParameterBundleBase::NewL(); |
|
2366 TInt retOnLoad = newPnpBundle->Load(loadPtr); |
|
2367 User::LeaveIfError(retOnLoad); |
|
2368 CleanupStack::PushL(newPnpBundle); |
|
2369 Manager().AppendBundlesL(newPnpBundle); |
|
2370 CleanupStack::Pop(newPnpBundle); |
|
2371 CleanupStack::PopAndDestroy(holdBundle); |
|
2372 _LIT(KInfoLogFile1, "CUPnPObserver::CopyResultBundlesL() End.... \n"); |
|
2373 Manager().INFO_PRINTF1(KInfoLogFile1); |
|
2374 } |
|
2375 |
|
2376 /* |
|
2377 This function Prints Discovery results by getting it from Results bundle |
|
2378 @param aParamFamily a pointer to CUPnPParameterFamily |
|
2379 @return None |
|
2380 */ |
|
2381 void CTestUPnPManager::PrintDiscoveryResultsL(CUPnPParameterFamily* aParamFamily) |
|
2382 { |
|
2383 _LIT(KInfoLogFile, "CTestUPnPManager::PrintDiscoveryResultsL().... \n"); |
|
2384 INFO_PRINTF1(KInfoLogFile); |
|
2385 |
|
2386 _LIT(KPrintStatement, "printing results \n"); |
|
2387 _LIT(KPrintDesign," \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n"); |
|
2388 |
|
2389 INFO_PRINTF1(KPrintStatement); |
|
2390 INFO_PRINTF1(KPrintDesign); |
|
2391 |
|
2392 TParamSetIter<CUPnPDiscoverResponseParamSet> iter; |
|
2393 CUPnPDiscoverResponseParamSet* paramSet = NULL; |
|
2394 aParamFamily->InitializeIter(iter); |
|
2395 |
|
2396 while ( !iter.AtEnd() ) |
|
2397 { |
|
2398 paramSet = iter(); |
|
2399 |
|
2400 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2401 { |
|
2402 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2403 _LIT(KDiscoverFailed,"Failed to Discover with...Error Code = %d \n"); |
|
2404 ERR_PRINTF2(KDiscoverFailed, error); |
|
2405 ++iter; |
|
2406 continue; |
|
2407 } |
|
2408 else if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EDiscoveryTimeout) |
|
2409 { |
|
2410 _LIT(KDiscoverTimeOut,"Discover Response TimeOut: TUPnPEvent::EDiscoveryTimeout \n"); |
|
2411 INFO_PRINTF1(KDiscoverTimeOut); |
|
2412 ++iter; |
|
2413 continue; |
|
2414 } |
|
2415 TPtrC8 deviceLocation(paramSet->DeviceLocation()); |
|
2416 HBufC* devloc = HBufC::NewLC(deviceLocation.Length()); //1 |
|
2417 devloc->Des().Copy(deviceLocation); |
|
2418 TPtrC devLocPointer (devloc->Des()); |
|
2419 _LIT(KInfoUri,"The Location: %S \n"); |
|
2420 INFO_PRINTF2(KInfoUri, &devLocPointer); |
|
2421 |
|
2422 TPtrC8 usn(paramSet->USN()); |
|
2423 HBufC* usnVal = HBufC::NewLC(usn.Length()); //2 |
|
2424 usnVal->Des().Copy(usn); |
|
2425 TPtrC usnValPointer (usnVal->Des()); |
|
2426 _LIT(KInfoUSN,"The USN found is %S \n"); |
|
2427 INFO_PRINTF2(KInfoUSN, &usnValPointer); |
|
2428 |
|
2429 TInt expiryTime = paramSet->ExpiryTime(); |
|
2430 _LIT(KInfoexpiryTime,"The Expiry Time or CACHE-CONTROL: max-age = %d \n"); |
|
2431 INFO_PRINTF2(KInfoexpiryTime, expiryTime); |
|
2432 |
|
2433 CleanupStack::PopAndDestroy(usnVal); |
|
2434 CleanupStack::PopAndDestroy(devloc); |
|
2435 ++iter; |
|
2436 continue; |
|
2437 } |
|
2438 _LIT(KEndPrintStatement,"Done with printing results \n"); |
|
2439 INFO_PRINTF1(KEndPrintStatement); |
|
2440 INFO_PRINTF1(KPrintDesign); |
|
2441 } |
|
2442 |
|
2443 void CTestUPnPManager::ValidateDiscoveryResultsL(const TDesC& aOperationType) |
|
2444 { |
|
2445 _LIT(KInfoLogFile, "CTestUPnPManager::ValidateDiscoveryResultsL().... \n"); |
|
2446 INFO_PRINTF1(KInfoLogFile); |
|
2447 |
|
2448 TInt DeviceLocationCount = NULL; |
|
2449 TPtrC ExpectedURL; |
|
2450 GetStringFromConfig(aOperationType, KExpectedURL, ExpectedURL); |
|
2451 |
|
2452 TInt totalCount(0); |
|
2453 GetIntFromConfig(aOperationType, KExpectedCount, totalCount); |
|
2454 const TInt bundleCount = iResultsArray.Count(); |
|
2455 |
|
2456 for(TInt i(0); i < bundleCount; i++) |
|
2457 { |
|
2458 CUPnPParameterFamily* paramFamily = static_cast<CUPnPParameterFamily*> ( iResultsArray[i]->GetFamilyByIndex() ); |
|
2459 if( paramFamily ) |
|
2460 { |
|
2461 if(paramFamily->Id() ==EUPnPDiscoverResponseParamSet) |
|
2462 { |
|
2463 TParamSetIter<CUPnPDiscoverResponseParamSet> iter; |
|
2464 CUPnPDiscoverResponseParamSet* paramSet = NULL; |
|
2465 paramFamily->InitializeIter(iter); |
|
2466 |
|
2467 while ( !iter.AtEnd() ) |
|
2468 { |
|
2469 paramSet = iter(); |
|
2470 if(paramSet->UPnPEvent().iStatus == TUPnPEvent::EFail) |
|
2471 { |
|
2472 TInt error = paramSet->UPnPEvent().iErrorCode; |
|
2473 _LIT(KDiscoverFailed,"Failed to Discover with...Error Code = %d \n"); |
|
2474 ERR_PRINTF2(KDiscoverFailed, error); |
|
2475 ++iter; |
|
2476 continue; |
|
2477 } |
|
2478 TPtrC8 deviceLocation(paramSet->DeviceLocation()); |
|
2479 HBufC* devloc = HBufC::NewLC(deviceLocation.Length()); |
|
2480 devloc->Des().Copy(deviceLocation); |
|
2481 TPtrC devLocPointer (devloc->Des()); |
|
2482 DeviceLocationCount++; |
|
2483 if((ExpectedURL!=KNullDesC) && (ExpectedURL.Compare(devLocPointer) == KErrNone)) |
|
2484 { |
|
2485 SetTestStepResult(EPass); |
|
2486 } |
|
2487 CleanupStack::PopAndDestroy(devloc); |
|
2488 ++iter; |
|
2489 continue; |
|
2490 } |
|
2491 } |
|
2492 } |
|
2493 } |
|
2494 if((DeviceLocationCount != NULL) &&(DeviceLocationCount == totalCount)) |
|
2495 { |
|
2496 SetTestStepResult(EPass); |
|
2497 } |
|
2498 _LIT(KInfoLogFile1, "CTestUPnPManager::ValidateDiscoveryResultsL() End.... \n"); |
|
2499 INFO_PRINTF1(KInfoLogFile1); |
|
2500 } |
|
2501 |
|
2502 void CTestUPnPManager::CancelPublish() |
|
2503 { |
|
2504 _LIT(KInfoLogFile, "CTestUPnPManager::CancelPublish() Begin.... \n"); |
|
2505 INFO_PRINTF1(KInfoLogFile); |
|
2506 TInt count = iPublisherArray.Count(); |
|
2507 for(TInt i(count - 1); i >= 0 ; i--) |
|
2508 { |
|
2509 TPublisherControl publisherType = PublisherType(i); |
|
2510 _LIT(KInfoCancelLog, "CTestUPnPManager::CancelPublish()...Closing Publisher.... %d\n"); |
|
2511 INFO_PRINTF2(KInfoCancelLog,i); |
|
2512 switch(publisherType) |
|
2513 { |
|
2514 case KService: |
|
2515 { |
|
2516 _LIT(KInfoService, "Closing Publisher.... of Type---->SERVICE\n"); |
|
2517 INFO_PRINTF1(KInfoService); |
|
2518 break; |
|
2519 } |
|
2520 case KDevice: |
|
2521 { |
|
2522 _LIT(KInfoDevice, "Closing Publisher.... of Type---->DEVICE\n"); |
|
2523 INFO_PRINTF1(KInfoDevice); |
|
2524 break; |
|
2525 } |
|
2526 default : |
|
2527 { |
|
2528 _LIT(KInfoErr, "Closing Publisher.... of Type---->InValid\n"); |
|
2529 ERR_PRINTF1(KInfoErr); |
|
2530 break; |
|
2531 } |
|
2532 } |
|
2533 iPublisherArray[i].Close(); |
|
2534 } |
|
2535 _LIT(KInfoLogFile2, "CancelPublish() Array Closed.... \n"); |
|
2536 INFO_PRINTF1(KInfoLogFile2); |
|
2537 iPublisherArray.Close(); |
|
2538 _LIT(KInfoLogFile3, "CTestUPnPManager::CancelPublish() End.... \n"); |
|
2539 INFO_PRINTF1(KInfoLogFile3); |
|
2540 } |
|
2541 |
|
2542 void CTestUPnPManager::DescribeServiceL() |
|
2543 { |
|
2544 _LIT(KInfoLogFile, "CTestUPnPManager::DescribeServiceL().... \n"); |
|
2545 INFO_PRINTF1(KInfoLogFile); |
|
2546 |
|
2547 ResolveAllUrisL(); |
|
2548 TInt scpdUriCount = iScpdUriArray.Count(); |
|
2549 //__ASSERT_DEBUG ( scpdUriCount > 0, User::Panic (KDescribeTestPanicCategory,KErrNoDescriptionPath ) ); |
|
2550 if ( scpdUriCount==0 ) |
|
2551 { |
|
2552 _LIT(KDescription,"Description Cannot be performed \n"); |
|
2553 INFO_PRINTF1(KDescription); |
|
2554 //SetTestStepResult(EFail); |
|
2555 return; |
|
2556 } |
|
2557 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
2558 CleanupStack::PushL( upnpObserver ); |
|
2559 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
2560 CleanupClosePushL( *pnpBundle ); |
|
2561 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
2562 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPDescribeRequestParamSet); |
|
2563 |
|
2564 // Read the ScpdUrl from ScpdUri Array |
|
2565 //Make sure that Before this Describe Device, and Discovery is executes Succesfully. |
|
2566 for(TInt index(0); index < scpdUriCount ; index++)//scpdUriCount |
|
2567 { |
|
2568 CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily ); |
|
2569 describeParamSet->SetUriL(iScpdUriArray[index]); |
|
2570 RBuf scpdUri16; |
|
2571 scpdUri16.Create(iScpdUriArray[index].Length()); |
|
2572 scpdUri16.Copy(iScpdUriArray[index]); |
|
2573 _LIT(KScpdUriInfo,"SCPD Uri Submitted for Description Request is: %S \n"); |
|
2574 INFO_PRINTF2(KScpdUriInfo, &scpdUri16); |
|
2575 scpdUri16.Close(); |
|
2576 } |
|
2577 iControlPoint.Describe(*pnpBundle ); |
|
2578 CActiveScheduler::Start(); |
|
2579 _LIT(KInfoLogFile1, "CTestUPnPManager::DescribeServiceL() End.... \n"); |
|
2580 INFO_PRINTF1(KInfoLogFile1); |
|
2581 |
|
2582 CleanupStack::PopAndDestroy( pnpBundle ); |
|
2583 CleanupStack::PopAndDestroy( upnpObserver ); |
|
2584 } |
|
2585 |
|
2586 void CTestUPnPManager::DescribeL() |
|
2587 { |
|
2588 _LIT(KInfoLogFile, "CTestUPnPManager::DescribeL().... \n"); |
|
2589 INFO_PRINTF1(KInfoLogFile); |
|
2590 |
|
2591 CUPnPObserver* upnpObserver = CUPnPObserver::NewL(this); |
|
2592 CleanupStack::PushL( upnpObserver ); |
|
2593 CPnPParameterBundle* pnpBundle = CPnPParameterBundle::NewL( ); |
|
2594 CleanupClosePushL( *pnpBundle ); |
|
2595 pnpBundle->SetPnPObserver((MPnPObserver*)upnpObserver); |
|
2596 CUPnPParameterFamily* pnpFamily = CUPnPParameterFamily::NewL (*pnpBundle , EUPnPDescribeRequestParamSet); |
|
2597 RBuf8 descriptionPathBuf; |
|
2598 |
|
2599 TBool readIni = ETrue; |
|
2600 GetBoolFromConfig(GetCurrentSection(), KReadIni, readIni); |
|
2601 if(readIni) |
|
2602 { |
|
2603 // Get the Description path from .ini File |
|
2604 TPtrC descriptionPath; |
|
2605 GetStringFromConfig(GetCurrentSection(), KDescriptionPath, descriptionPath); |
|
2606 CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily ); |
|
2607 descriptionPathBuf.Create(descriptionPath.Length()); |
|
2608 descriptionPathBuf.Copy(descriptionPath); |
|
2609 describeParamSet->SetUriL(descriptionPathBuf); |
|
2610 descriptionPathBuf.Close(); |
|
2611 iControlPoint.Describe(*pnpBundle ); |
|
2612 TBool SchedulerStatus = ETrue; |
|
2613 _LIT(KSchedulerStatus, "schedulerstart"); |
|
2614 GetBoolFromConfig(GetCurrentSection(), KSchedulerStatus, SchedulerStatus); |
|
2615 if(SchedulerStatus) |
|
2616 { |
|
2617 CActiveScheduler::Start(); |
|
2618 } |
|
2619 } |
|
2620 else |
|
2621 { |
|
2622 // Read the Description path from DevLoaction array |
|
2623 //Make sure that Before this Describe, Successful Discovery is happend. |
|
2624 TInt DevLocCount = iDeviceLocationArray.Count(); |
|
2625 if ( DevLocCount==0 ) |
|
2626 { |
|
2627 _LIT(KDescription,"Description Cannot be performed as NO Uri available to Describe\n"); |
|
2628 INFO_PRINTF1(KDescription); |
|
2629 CleanupStack::PopAndDestroy( pnpBundle ); |
|
2630 CleanupStack::PopAndDestroy( upnpObserver ); |
|
2631 //SetTestStepResult(EFail); |
|
2632 return; |
|
2633 } |
|
2634 |
|
2635 //__ASSERT_DEBUG ( DevLocCount > 0, User::Panic (KDescribeTestPanicCategory,KErrNoDescriptionPath ) ); |
|
2636 |
|
2637 for(TInt iter(0); iter < DevLocCount ; iter++) |
|
2638 { |
|
2639 TBuf8<256> url; |
|
2640 TUriParser8 uri; |
|
2641 uri.Parse(iDeviceLocationArray[iter]); |
|
2642 const TDesC8& scheme = uri.Extract(EUriScheme); |
|
2643 _LIT8(KScheme, "http"); |
|
2644 //Uri must be of scheme "http" only |
|
2645 if (scheme.CompareF(KScheme) == 0) |
|
2646 { |
|
2647 url.Copy(iDeviceLocationArray[iter]); |
|
2648 CUPnPDescribeRequestParamSet* describeParamSet = CUPnPDescribeRequestParamSet::NewL (pnpFamily ); |
|
2649 describeParamSet->SetUriL(url); |
|
2650 } |
|
2651 else |
|
2652 { |
|
2653 _LIT(KInavlidUri, "Describe Request for InvalidURi"); |
|
2654 INFO_PRINTF1(KInavlidUri); |
|
2655 return; |
|
2656 } |
|
2657 } |
|
2658 |
|
2659 iControlPoint.Describe(*pnpBundle ); |
|
2660 TBool SchedulerStatus = ETrue; |
|
2661 _LIT(KSchedulerStatus, "schedulerstart"); |
|
2662 GetBoolFromConfig(GetCurrentSection(), KSchedulerStatus, SchedulerStatus); |
|
2663 if(SchedulerStatus) |
|
2664 { |
|
2665 CActiveScheduler::Start(); |
|
2666 } |
|
2667 } |
|
2668 _LIT(KInfoLogFile1, "CTestUPnPManager::DescribeL() End.... \n"); |
|
2669 INFO_PRINTF1(KInfoLogFile1); |
|
2670 CleanupStack::PopAndDestroy( pnpBundle ); |
|
2671 CleanupStack::PopAndDestroy( upnpObserver ); |
|
2672 } |
|
2673 |
|
2674 void CTestUPnPManager::ResolveAllUrisL() |
|
2675 { |
|
2676 _LIT(KInfoLogFile, "CTestUPnPManager::ResolveAllUrisL().... \n"); |
|
2677 INFO_PRINTF1(KInfoLogFile); |
|
2678 |
|
2679 TInt count = iDescriptionSuiteArray.Count(); |
|
2680 //__ASSERT_DEBUG ( count > 0, User::Panic (KDescribeTestPanicCategory, KErrNoServiceUris ) ); |
|
2681 if( count <=0 ) |
|
2682 { |
|
2683 _LIT(KErrResolve, "No Description is exist to Resolve URIs"); |
|
2684 ERR_PRINTF1(KErrResolve); |
|
2685 return; |
|
2686 } |
|
2687 //Fill the all types of Uris for each base Uri |
|
2688 for (TInt index(0); index < count ; index++ ) |
|
2689 { |
|
2690 GetServiceUrlsListL(index); |
|
2691 ResolveScpdUrisL(index); |
|
2692 ResolveEventUrisL(index); |
|
2693 ResolveControlUrisL(index); |
|
2694 } |
|
2695 } |
|
2696 |
|
2697 void CTestUPnPManager::GetServiceUrlsListL(TInt aIndex) |
|
2698 { |
|
2699 _LIT(KInfoLogFile, "CTestUPnPManager::GetServiceUrlsListL().... \n"); |
|
2700 INFO_PRINTF1(KInfoLogFile); |
|
2701 |
|
2702 CUPnPDeviceDescription* rootDeviceDescription = NULL; |
|
2703 //Release the content of StringPool if any |
|
2704 if(iStringPoolMgr) |
|
2705 iStringPoolMgr->Release(); |
|
2706 DeleteSeriveUrlsList(aIndex); |
|
2707 |
|
2708 iStringPoolMgr = CStringPoolManager::NewL(); |
|
2709 //Store the Parsed node info |
|
2710 iStringPool = iStringPoolMgr->StringPool(); |
|
2711 _LIT(KInfoLogFile4, "Creating Stringpool and its manager.... \n"); |
|
2712 INFO_PRINTF1(KInfoLogFile4); |
|
2713 |
|
2714 //Parse the device description |
|
2715 CUPnPDescriptionParser* app = CUPnPDescriptionParser::NewL( iStringPool, CUPnPDescriptionParser::EDevice); |
|
2716 _LIT(KInfoLogFile2, "CTestUPnPManager::CUpnpDeviceXmlParser::NewL().... \n"); |
|
2717 INFO_PRINTF1(KInfoLogFile2); |
|
2718 TRAPD(error,(rootDeviceDescription = static_cast<CUPnPDeviceDescription*>(app->ParseDescriptionBufL(iDescriptionSuiteArray[aIndex].iDescription)))); |
|
2719 if (error != KErrNone) |
|
2720 { |
|
2721 _LIT(KErrLogFile1, "CTestUPnPManager::GetServiceUrlsListL() is Terminating.... And Error is %d \n"); |
|
2722 ERR_PRINTF2(KErrLogFile1, error); |
|
2723 return; |
|
2724 } |
|
2725 _LIT(KInfoLogFile3, "rootDeviceDescription.... \n"); |
|
2726 INFO_PRINTF1(KInfoLogFile3); |
|
2727 |
|
2728 |
|
2729 |
|
2730 delete app; |
|
2731 app = NULL; |
|
2732 _LIT(KInfoLogFile5, "Deleting CUpnpDeviceXmlParser().... \n"); |
|
2733 INFO_PRINTF1(KInfoLogFile5); |
|
2734 |
|
2735 //Retrieve the Tag for Base |
|
2736 RString string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EUrlBase,iStringPoolMgr->GetUPnPTable()); |
|
2737 //Get the node info for the Base i.e., value between the start and end Base tags |
|
2738 //If BaseUri exist in Description replace already existing BaseUri |
|
2739 if(rootDeviceDescription->Property(string).Compare(KNullDesC8)>0) |
|
2740 { |
|
2741 //Delete already stored Base uri |
|
2742 iDescriptionSuiteArray[aIndex].iBaseUrl.Close(); |
|
2743 iDescriptionSuiteArray[aIndex].iBaseUrl.Create(rootDeviceDescription->Property(string).Length()); |
|
2744 iDescriptionSuiteArray[aIndex].iBaseUrl.Copy(rootDeviceDescription->Property(string)); |
|
2745 } |
|
2746 |
|
2747 //Catch hold of first level of Device |
|
2748 CUPnPDevice* device = rootDeviceDescription->DeviceObject(); |
|
2749 |
|
2750 TInt count =device->CountOfEmbeddedDeviceInfoTable(); |
|
2751 if(count>0) |
|
2752 { |
|
2753 for(TInt i=0;i<count;i++) |
|
2754 { |
|
2755 GetEmbeddedDeviceServicesL(aIndex,device->AtEmbeddedDeviceInfoTable(i)); |
|
2756 } |
|
2757 } |
|
2758 GetServiceValuesL(aIndex, device); |
|
2759 _LIT(KInfoLogFile6, "Finished GetServiceValuesL.... \n"); |
|
2760 INFO_PRINTF1(KInfoLogFile6); |
|
2761 delete rootDeviceDescription; |
|
2762 rootDeviceDescription = NULL; |
|
2763 _LIT(KInfoLogFile1, "CTestUPnPManager::GetServiceUrlsListL() End.... \n"); |
|
2764 INFO_PRINTF1(KInfoLogFile1); |
|
2765 } |
|
2766 |
|
2767 void CTestUPnPManager::DeleteSeriveUrlsList(TInt aIndex) |
|
2768 { |
|
2769 _LIT(KInfoLogFile, "CTestUPnPManager::DeleteSeriveUrlsList().... \n"); |
|
2770 INFO_PRINTF1(KInfoLogFile); |
|
2771 |
|
2772 for(TInt i=0;i<iDescriptionSuiteArray[aIndex].iServiceUrls.Count();i++) |
|
2773 { |
|
2774 iDescriptionSuiteArray[aIndex].iServiceUrls[i].serviceType.Close(); |
|
2775 iDescriptionSuiteArray[aIndex].iServiceUrls[i].scpdUrl.Close(); |
|
2776 iDescriptionSuiteArray[aIndex].iServiceUrls[i].controlUrl.Close(); |
|
2777 iDescriptionSuiteArray[aIndex].iServiceUrls[i].eventSubUrl.Close(); |
|
2778 } |
|
2779 iDescriptionSuiteArray[aIndex].iServiceUrls.Close(); |
|
2780 _LIT(KInfoLogFile1, "CTestUPnPManager::DeleteSeriveUrlsList() End.... \n"); |
|
2781 INFO_PRINTF1(KInfoLogFile1); |
|
2782 } |
|
2783 |
|
2784 void CTestUPnPManager::GetEmbeddedDeviceServicesL(TInt aIndex, CUPnPDevice* aDevice) |
|
2785 { |
|
2786 _LIT(KInfoLogFile, "CTestUPnPManager::GetEmbeddedDeviceServicesL().... \n"); |
|
2787 INFO_PRINTF1(KInfoLogFile); |
|
2788 |
|
2789 if(aDevice->CountOfEmbeddedDeviceInfoTable() > 0) |
|
2790 { |
|
2791 for(TInt i=0;i<aDevice->CountOfEmbeddedDeviceInfoTable();i++) |
|
2792 { |
|
2793 GetEmbeddedDeviceServicesL(aIndex, aDevice->AtEmbeddedDeviceInfoTable(i)); |
|
2794 GetServiceValuesL(aIndex, aDevice); |
|
2795 } |
|
2796 } |
|
2797 else |
|
2798 { |
|
2799 GetServiceValuesL(aIndex, aDevice); |
|
2800 } |
|
2801 } |
|
2802 |
|
2803 |
|
2804 void CTestUPnPManager::AppendDeviceLocationL(TDesC8& aDevLocPointer) |
|
2805 { |
|
2806 User::LeaveIfError( iDeviceLocationArray.Append(aDevLocPointer) ); |
|
2807 } |
|
2808 |
|
2809 void CTestUPnPManager::AppendScpdUriL(RBuf8& aScpdUri) |
|
2810 { |
|
2811 User::LeaveIfError( iScpdUriArray.Append(aScpdUri) ); |
|
2812 } |
|
2813 |
|
2814 void CTestUPnPManager::AppendEventUriL(RBuf8& aEventUri) |
|
2815 { |
|
2816 User::LeaveIfError( iEventUriArray.Append(aEventUri) ); |
|
2817 } |
|
2818 |
|
2819 void CTestUPnPManager::AppendControlUriL(RBuf8& aControlUri) |
|
2820 { |
|
2821 User::LeaveIfError( iControlUriArray.Append(aControlUri) ); |
|
2822 } |
|
2823 |
|
2824 void CTestUPnPManager::AppendDescriptionL(RBuf8& aBaseUri,RBuf8& aDescription) |
|
2825 { |
|
2826 TDescriptionSuite buf; |
|
2827 buf.iDescription.CreateL(aDescription); |
|
2828 buf.iBaseUrl.CreateL(aBaseUri); |
|
2829 iDescriptionSuiteArray.Append(buf); |
|
2830 } |
|
2831 |
|
2832 void CTestUPnPManager::GetServiceValuesL(TInt aIndex, CUPnPDevice* aDevice) |
|
2833 { |
|
2834 _LIT(KInfoLogFile, "CTestUPnPManager::GetServiceValuesL().... \n"); |
|
2835 INFO_PRINTF1(KInfoLogFile); |
|
2836 |
|
2837 TUint count; |
|
2838 const CUPnPServiceInfo* servInfo = NULL; |
|
2839 TServiceUrl serviceurl; |
|
2840 count = aDevice->CountOfServiceInfoTable(); |
|
2841 if(count > 0) |
|
2842 { |
|
2843 for(TInt i = 0; i< aDevice->CountOfServiceInfoTable(); i++) |
|
2844 { |
|
2845 servInfo = aDevice->AtServiceInfoTable(i); |
|
2846 |
|
2847 RString string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EServiceType, iStringPoolMgr->GetUPnPTable()); |
|
2848 serviceurl.serviceType.Create(servInfo->Property(string).Length()); |
|
2849 serviceurl.serviceType.Copy(servInfo->Property(string)); |
|
2850 |
|
2851 string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EScpdUrl, iStringPoolMgr->GetUPnPTable()); |
|
2852 serviceurl.scpdUrl.Create(servInfo->Property(string).Length()); |
|
2853 serviceurl.scpdUrl.Copy(servInfo->Property(string)); |
|
2854 |
|
2855 string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EContorlUrl, iStringPoolMgr->GetUPnPTable()); |
|
2856 serviceurl.controlUrl.Create(servInfo->Property(string).Length()); |
|
2857 serviceurl.controlUrl.Copy(servInfo->Property(string)); |
|
2858 |
|
2859 string = iStringPool.String(UPNPDESCRIPTIONXMLTAGS::EEventSubUrl, iStringPoolMgr->GetUPnPTable()); |
|
2860 serviceurl.eventSubUrl.Create(servInfo->Property(string).Length()); |
|
2861 serviceurl.eventSubUrl.Copy(servInfo->Property(string)); |
|
2862 |
|
2863 iDescriptionSuiteArray[aIndex].iServiceUrls.AppendL(serviceurl); |
|
2864 } |
|
2865 } |
|
2866 _LIT(KInfoLogFile1, "CTestUPnPManager::GetServiceValuesL() End.... \n"); |
|
2867 INFO_PRINTF1(KInfoLogFile1); |
|
2868 } |
|
2869 |
|
2870 |
|
2871 CUPnPTimer::CUPnPTimer(CTestUPnPManager* aManager) |
|
2872 : CActive(EPriorityHigh),iManager(aManager) |
|
2873 { |
|
2874 CActiveScheduler::Add(this); |
|
2875 } |
|
2876 |
|
2877 |
|
2878 CUPnPTimer::~CUPnPTimer() |
|
2879 { |
|
2880 Cancel(); |
|
2881 } |
|
2882 |
|
2883 |
|
2884 CUPnPTimer* CUPnPTimer::NewL(CTestUPnPManager* aManager) |
|
2885 { |
|
2886 CUPnPTimer* self = new (ELeave) CUPnPTimer(aManager); |
|
2887 CleanupStack::PushL(self); |
|
2888 self->ConstructL(); |
|
2889 CleanupStack::Pop(); |
|
2890 return self; |
|
2891 } |
|
2892 |
|
2893 void CUPnPTimer::ConstructL() |
|
2894 { |
|
2895 } |
|
2896 |
|
2897 |
|
2898 void CUPnPTimer::IssueRequestL(TTimeIntervalMicroSeconds32 anInterval) |
|
2899 { |
|
2900 iTimer.CreateLocal(); |
|
2901 iTimer.After(iStatus, anInterval); |
|
2902 SetActive(); |
|
2903 _LIT(KInfoLogFile, "CUPnPTimer::IssueRequestL() End.... \n"); |
|
2904 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2905 } |
|
2906 |
|
2907 |
|
2908 void CUPnPTimer::RunL() |
|
2909 { |
|
2910 CActiveScheduler::Stop(); |
|
2911 _LIT(KInfoLogFile, "CUPnPTimer::RunL() End.... \n"); |
|
2912 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2913 |
|
2914 } |
|
2915 |
|
2916 void CUPnPTimer::DoCancel() |
|
2917 { |
|
2918 iTimer.Cancel(); |
|
2919 } |
|
2920 |
|
2921 CAction* CAction::NewL(CTestUPnPManager* aManager) |
|
2922 { |
|
2923 CAction* self = new (ELeave) CAction(aManager); |
|
2924 CleanupStack::PushL(self); |
|
2925 self->ConstructL(); |
|
2926 CleanupStack::Pop(); |
|
2927 return self; |
|
2928 |
|
2929 } |
|
2930 |
|
2931 CAction::CAction(CTestUPnPManager* aManager) |
|
2932 : CActive(CActive::EPriorityStandard),iManager(aManager) |
|
2933 { |
|
2934 |
|
2935 } |
|
2936 |
|
2937 CAction::~CAction() |
|
2938 { |
|
2939 Cancel(); |
|
2940 iFile.Close ( ); |
|
2941 iFs.Close ( ); |
|
2942 } |
|
2943 |
|
2944 void CAction::ConstructL() |
|
2945 { |
|
2946 _LIT(KInfoLogFile, "CAction::ConstructL() .... \n"); |
|
2947 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2948 CActiveScheduler::Add(this); |
|
2949 _LIT(KPath, "c:\\upnp\\testupnp\\client\\testdata\\"); |
|
2950 _LIT(KFile, "c:\\upnp\\testupnp\\client\\testdata\\actionresponse.xml"); |
|
2951 User::LeaveIfError ( iFs.Connect ( ) ); |
|
2952 TInt err = iFile.Open ( iFs, KFile, EFileWrite ); |
|
2953 if(err == KErrNotFound) |
|
2954 { |
|
2955 err = iFile.Create(iFs,KFile,EFileWrite); |
|
2956 } |
|
2957 else if(err == KErrPathNotFound) |
|
2958 { |
|
2959 err= iFs.MkDirAll(KPath); |
|
2960 if(err==KErrNone || err== KErrAlreadyExists) |
|
2961 { |
|
2962 iFile.Create(iFs,KFile,EFileWrite); |
|
2963 } |
|
2964 } |
|
2965 else |
|
2966 { |
|
2967 User::LeaveIfError(err); |
|
2968 } |
|
2969 } |
|
2970 |
|
2971 void CAction::RunL() |
|
2972 { |
|
2973 switch(iActionState) |
|
2974 { |
|
2975 case ESendData: |
|
2976 iActionState = EReceiveData; |
|
2977 iControlChannel.Recv ( iCtrlMsg, iStatus ); |
|
2978 SetActive(); |
|
2979 _LIT(KInfoLogFile, "CAction::RunL Send Data.... \n"); |
|
2980 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2981 break; |
|
2982 case EReceiveData: |
|
2983 TInt err = iFile.Write(iCtrlMsg.MessageDes ()); |
|
2984 if ( !iCtrlMsg.IsLast () ) |
|
2985 { |
|
2986 iCtrlMsg.ClearFlags(); |
|
2987 iControlChannel.Recv ( iCtrlMsg, iStatus ); |
|
2988 SetActive(); |
|
2989 _LIT(KInfoLogFile, "CAction::RunL Receive Data... \n"); |
|
2990 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2991 } |
|
2992 else |
|
2993 { |
|
2994 iControlChannel.Close( ); |
|
2995 CActiveScheduler::Stop(); |
|
2996 _LIT(KInfoLogFile, "CAction::RunL End.... \n"); |
|
2997 iManager->INFO_PRINTF1(KInfoLogFile); |
|
2998 } |
|
2999 break; |
|
3000 } |
|
3001 } |
|
3002 |
|
3003 void CAction::DoCancel() |
|
3004 { |
|
3005 } |
|
3006 |
|
3007 void CAction::InitiateActionControlL(TDesC8& aUri,RPnPServiceDiscovery& aControlPoint) |
|
3008 { |
|
3009 RFs fs; |
|
3010 RFile file; |
|
3011 TInt err; |
|
3012 RBuf8 buf; |
|
3013 _LIT(KInfoLogFile2, "InitiateActionControlL .... \n"); |
|
3014 iManager->INFO_PRINTF1(KInfoLogFile2); |
|
3015 |
|
3016 User::LeaveIfError(fs.Connect()); |
|
3017 CleanupClosePushL(fs); |
|
3018 err = file.Open(fs,_L("z:\\upnp\\testupnp\\client\\testdata\\action.xml"),EFileRead); |
|
3019 if (err != KErrNone) |
|
3020 { |
|
3021 User::LeaveIfError(err); |
|
3022 } |
|
3023 CleanupClosePushL(file); |
|
3024 TInt fileSize = 0; |
|
3025 file.Size(fileSize); |
|
3026 buf.Create(fileSize); |
|
3027 err = file.Read(buf, fileSize); |
|
3028 err= -1; |
|
3029 err = aControlPoint.InitiateControl ( iControlChannel, aUri ); |
|
3030 _LIT(KInfoLogFile, "InitiateControl() on Control Point Done with %d.... \n"); |
|
3031 iManager->INFO_PRINTF2(KInfoLogFile,err); |
|
3032 iCtrlMsg.SetMessageDes ( buf ); |
|
3033 iCtrlMsg.SetLast (); |
|
3034 TInt newLen = buf.Length(); |
|
3035 iCtrlMsg.SetMaxLength (newLen); |
|
3036 iControlChannel.Send ( iCtrlMsg, iStatus ); |
|
3037 SetActive(); |
|
3038 CActiveScheduler::Start(); |
|
3039 _LIT(KInfoLogFile1, "InitiateActionControlL End.... \n"); |
|
3040 iManager->INFO_PRINTF1(KInfoLogFile1); |
|
3041 CleanupStack::PopAndDestroy(2 ); |
|
3042 } |
|
3043 |
|
3044 |