os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/testDRM.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 //
    15 
    16 #include "rightsdatabase.h"
    17 #include "TestDRM.h"
    18 #include <caf/caf.h>
    19 
    20 const TInt KDefaultRightsID = 1;
    21 const TInt KDefaultRightsCount = 2;
    22 
    23 const TInt KMaxMimeLength = 256;
    24 /**
    25  * Constructor
    26  */
    27 CTestMmfAclntDRMPlayerNoRights::CTestMmfAclntDRMPlayerNoRights()
    28 	{
    29 	// store the name of this test case
    30 	// this is the name that is used by the script file
    31 	// Each test step initialises it's own name
    32 	iTestStepName = _L("MM-MMF-ACLNT-I-9000-LP");
    33 
    34 	}
    35 
    36 CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewL()
    37 	{
    38 	CTestMmfAclntDRMPlayerNoRights* self = new (ELeave) CTestMmfAclntDRMPlayerNoRights();
    39 	return self;
    40 	}
    41 
    42 CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewLC()
    43 	{
    44 	CTestMmfAclntDRMPlayerNoRights* self = CTestMmfAclntDRMPlayerNoRights::NewL();
    45 	CleanupStack::PushL(self);
    46 	return self;
    47 	}
    48 
    49 void CTestMmfAclntDRMPlayerNoRights::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
    50 	{
    51 	iError = aError;
    52 	iDuration = aDuration;
    53 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
    54 	CActiveScheduler::Stop();
    55 	}
    56 
    57 void CTestMmfAclntDRMPlayerNoRights::MapcPlayComplete(TInt aError)
    58 	{
    59 	iError = aError;
    60 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
    61 	CActiveScheduler::Stop();
    62 	}
    63 
    64 
    65 
    66 /** Load and initialise an audio file.
    67  */
    68 TVerdict CTestMmfAclntDRMPlayerNoRights::DoTestStepL( void )
    69 	{
    70 	INFO_PRINTF1( _L("TestPlayerUtils : File"));
    71 	TVerdict ret = EFail;
    72 
    73 	iError = KErrTimedOut;
    74 
    75 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
    76 	delete rights; // the database will now be reset and have no entries in it
    77 
    78 	TBuf<KSizeBuf>	filename;
    79 	TPtrC			filename1; 
    80 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
    81 		return EInconclusive;
    82 	GetDriveName(filename);
    83 	filename.Append(filename1);
    84 
    85 	CMdaAudioPlayerUtility* player = NULL;
    86 	player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
    87 
    88 
    89 	// Wait for initialisation callback
    90 	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
    91 	CActiveScheduler::Start();
    92 
    93 	if (iError == KErrCANoRights)
    94 		ret = EPass;			
    95 	else
    96 		ret = EFail;
    97 	
    98 	delete player;
    99 	User::After(KOneSecond); // wait for deletion to shut down devsound
   100 	return	ret;
   101 	}
   102 //--------------------------------------------------------------------------------
   103 
   104 /**
   105  * Constructor
   106  */
   107 CTestMmfAclntDRMPlayerRightsCount::CTestMmfAclntDRMPlayerRightsCount()
   108 	{
   109 	// store the name of this test case
   110 	// this is the name that is used by the script file
   111 	// Each test step initialises it's own name
   112 	iTestStepName = _L("MM-MMF-ACLNT-I-9001-LP");
   113 
   114 	}
   115 
   116 CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewL()
   117 	{
   118 	CTestMmfAclntDRMPlayerRightsCount* self = new (ELeave) CTestMmfAclntDRMPlayerRightsCount();
   119 	return self;
   120 	}
   121 
   122 CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewLC()
   123 	{
   124 	CTestMmfAclntDRMPlayerRightsCount* self = CTestMmfAclntDRMPlayerRightsCount::NewL();
   125 	CleanupStack::PushL(self);
   126 	return self;
   127 	}
   128 
   129 void CTestMmfAclntDRMPlayerRightsCount::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
   130 	{
   131 	iError = aError;
   132 	iDuration = aDuration;
   133 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   134 	CActiveScheduler::Stop();
   135 	}
   136 
   137 void CTestMmfAclntDRMPlayerRightsCount::MapcPlayComplete(TInt aError)
   138 	{
   139 	iError = aError;
   140 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   141 	CActiveScheduler::Stop();
   142 	}
   143 
   144 
   145 
   146 /** Load and initialise an audio file.
   147  */
   148 TVerdict CTestMmfAclntDRMPlayerRightsCount::DoTestStepL( void )
   149 	{
   150 	INFO_PRINTF1( _L("TestPlayerUtils : File"));
   151 	TVerdict ret = EFail;
   152 
   153 	iError = KErrTimedOut;
   154 
   155 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   156 	CleanupStack::PushL(rights);
   157 	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count 
   158 	CleanupStack::PopAndDestroy(rights); // cleanup rights object
   159 
   160 	TBuf<KSizeBuf>	filename;
   161 	TPtrC			filename1; 
   162 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   163 		return EInconclusive;
   164 	GetDriveName(filename);
   165 	filename.Append(filename1);
   166 
   167 	CMdaAudioPlayerUtility* player = NULL;
   168 	player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
   169 
   170 
   171 	// Wait for initialisation callback
   172 	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   173 	CActiveScheduler::Start();
   174 
   175 	// Check for errors.
   176 	if (iError == KErrNone && player != NULL)
   177 		{
   178 		iError = KErrTimedOut;
   179 
   180 		for (TInt i=0;i<KDefaultRightsCount;i++)
   181 			{
   182 			player->Play();
   183 			
   184 			// Wait for play callback
   185 			INFO_PRINTF2( _L("Play CMdaAudioPlayerUtility: DRM play number %d"),i);
   186 			CActiveScheduler::Start();
   187 
   188 			if (iError != KErrNone)
   189 				{
   190 				INFO_PRINTF2(_L("Unexpected error %d"),iError);
   191 				break;
   192 				}
   193 			}
   194 
   195 		if (iError == KErrNone)
   196 			{
   197 			player->Play();
   198 			
   199 			// Wait for play callback
   200 			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility with expired rights"));
   201 			CActiveScheduler::Start();
   202 
   203 			if (iError != KErrCANoPermission)
   204 				{
   205 				INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
   206 				}
   207 			else
   208 				{
   209 				INFO_PRINTF1(_L("Expected failure: rights denied"));
   210 				ret = EPass;
   211 				}
   212 
   213 			}
   214 		}
   215 	
   216 	delete player;
   217 	User::After(KOneSecond); // wait for deletion to shut down devsound
   218 	return	ret;
   219 	}
   220 
   221 //----------------------------------------------------------------------------------------
   222 
   223 /**
   224  * Constructor
   225  */
   226 CTestMmfAclntDRMRecorderNoRights::CTestMmfAclntDRMRecorderNoRights()
   227 	{
   228 	// store the name of this test case
   229 	// this is the name that is used by the script file
   230 	// Each test step initialises it's own name
   231 	iTestStepName = _L("MM-MMF-ACLNT-I-9002-LP");
   232 
   233 	}
   234 
   235 CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewL()
   236 	{
   237 	CTestMmfAclntDRMRecorderNoRights* self = new (ELeave) CTestMmfAclntDRMRecorderNoRights();
   238 	return self;
   239 	}
   240 
   241 CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewLC()
   242 	{
   243 	CTestMmfAclntDRMRecorderNoRights* self = CTestMmfAclntDRMRecorderNoRights::NewL();
   244 	CleanupStack::PushL(self);
   245 	return self;
   246 	}
   247 
   248 
   249 /** Load and initialise an audio file.
   250  */
   251 TVerdict CTestMmfAclntDRMRecorderNoRights::DoTestStepL( void )
   252 	{
   253 	INFO_PRINTF1( _L("TestRecorderUtils : File"));
   254 	TVerdict ret = EFail;
   255 
   256 	iError = KErrTimedOut;
   257 
   258 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   259 	delete rights; // the database will now be reset and have no entries in it
   260 
   261 	TBuf<KSizeBuf>	filename;
   262 	TPtrC			filename1; 
   263 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   264 		return EInconclusive;
   265 	GetDriveName(filename);
   266 	filename.Append(filename1);
   267 
   268 	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
   269 	CleanupStack::PushL(recorder);
   270 
   271 	recorder->OpenFileL(filename);
   272 
   273 	// Wait for initialisation callback
   274 	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
   275 	CActiveScheduler::Start();
   276 
   277 	if (iError == KErrCANoRights)
   278 		ret = EPass;			
   279 	else
   280 		ret = EFail;
   281 	
   282 	CleanupStack::PopAndDestroy(recorder);
   283 	User::After(KOneSecond); // wait for deletion to shut down devsound
   284 	return	ret;
   285 	}
   286 
   287 
   288 void CTestMmfAclntDRMRecorderNoRights::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
   289 	{
   290 	iError = aErrorCode;
   291 	//iObject = aObject;
   292 	iPreviousState = aPreviousState;
   293 	iCurrentState = aCurrentState;
   294 
   295 	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
   296 	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
   297 	CActiveScheduler::Stop();
   298 	}
   299 
   300 //--------------------------------------------------------------------------------
   301 
   302 /**
   303  * Constructor
   304  */
   305 CTestMmfAclntDRMRecorderRightsCount::CTestMmfAclntDRMRecorderRightsCount()
   306 	{
   307 	// store the name of this test case
   308 	// this is the name that is used by the script file
   309 	// Each test step initialises it's own name
   310 	iTestStepName = _L("MM-MMF-ACLNT-I-9003-LP");
   311 
   312 	}
   313 
   314 CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewL()
   315 	{
   316 	CTestMmfAclntDRMRecorderRightsCount* self = new (ELeave) CTestMmfAclntDRMRecorderRightsCount();
   317 	return self;
   318 	}
   319 
   320 CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewLC()
   321 	{
   322 	CTestMmfAclntDRMRecorderRightsCount* self = CTestMmfAclntDRMRecorderRightsCount::NewL();
   323 	CleanupStack::PushL(self);
   324 	return self;
   325 	}
   326 
   327 /** Load and initialise an audio file.
   328  */
   329 TVerdict CTestMmfAclntDRMRecorderRightsCount::DoTestStepL( void )
   330 	{
   331 	INFO_PRINTF1( _L("TestRecorderUtils : File"));
   332 	TVerdict ret = EFail;
   333 
   334 	iError = KErrTimedOut;
   335 
   336 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   337 	CleanupStack::PushL(rights);
   338 	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count 
   339 	CleanupStack::PopAndDestroy(rights); // cleanup rights object
   340 
   341 	TBuf<KSizeBuf>	filename;
   342 	TPtrC			filename1; 
   343 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   344 		return EInconclusive;
   345 	GetDriveName(filename);
   346 	filename.Append(filename1);
   347 
   348 	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
   349 	CleanupStack::PushL(recorder);
   350 
   351 	recorder->OpenFileL(filename);
   352 
   353 	// Wait for initialisation callback
   354 	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
   355 	CActiveScheduler::Start();
   356 
   357 	// Check for errors.
   358 	if (iError == KErrNone && recorder != NULL)
   359 		{
   360 		iError = KErrTimedOut;
   361 
   362 		for (TInt i=0;i<KDefaultRightsCount;i++)
   363 			{
   364 			recorder->PlayL();
   365 			
   366 			// Wait for play callback
   367 			INFO_PRINTF2( _L("Play CMdaAudioRecorderUtility: DRM play number %d"),i);
   368 			CActiveScheduler::Start();
   369 
   370 			if (iError != KErrNone)
   371 				{
   372 				INFO_PRINTF2(_L("Unexpected error %d"),iError);
   373 				break;
   374 				}
   375 			}
   376 
   377 		if (iError == KErrNone)
   378 			{
   379 			recorder->PlayL();
   380 			
   381 			// Wait for play callback
   382 			INFO_PRINTF1( _L("Play CMdaAudioRecorderUtility with expired rights"));
   383 			CActiveScheduler::Start();
   384 
   385 			if (iError != KErrCANoPermission)
   386 				{
   387 				INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
   388 				}
   389 			else
   390 				{
   391 				INFO_PRINTF1(_L("Expected failure: rights denied"));
   392 				ret = EPass;
   393 				}
   394 
   395 			}
   396 		}
   397 	
   398 	CleanupStack::PopAndDestroy(recorder);
   399 	User::After(KOneSecond); // wait for deletion to shut down devsound
   400 	return	ret;
   401 	}
   402 
   403 
   404 
   405 
   406 void CTestMmfAclntDRMRecorderRightsCount::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
   407 	{
   408 	iError = aErrorCode;
   409 	//iObject = aObject;
   410 	iPreviousState = aPreviousState;
   411 	iCurrentState = aCurrentState;
   412 
   413 	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
   414 	if (!busy || iError!=KErrNone)
   415 		CActiveScheduler::Stop();
   416 	
   417 	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
   418 	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
   419 	
   420 	}
   421 
   422 //--------------------------------------------------------------------------------
   423 
   424 /**
   425  * Constructor
   426  */
   427 CTestMmfAclntDRMPlayerOpen::CTestMmfAclntDRMPlayerOpen()
   428 	{
   429 	// store the name of this test case
   430 	// this is the name that is used by the script file
   431 	// Each test step initialises it's own name
   432 	iTestStepName = _L("MM-MMF-ACLNT-I-9004-LP");
   433 
   434 	}
   435 
   436 CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewL()
   437 	{
   438 	CTestMmfAclntDRMPlayerOpen* self = new (ELeave) CTestMmfAclntDRMPlayerOpen();
   439 	return self;
   440 	}
   441 
   442 CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewLC()
   443 	{
   444 	CTestMmfAclntDRMPlayerOpen* self = CTestMmfAclntDRMPlayerOpen::NewL();
   445 	CleanupStack::PushL(self);
   446 	return self;
   447 	}
   448 
   449 void CTestMmfAclntDRMPlayerOpen::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
   450 	{
   451 	iError = aError;
   452 	iDuration = aDuration;
   453 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   454 	CActiveScheduler::Stop();
   455 	}
   456 
   457 void CTestMmfAclntDRMPlayerOpen::MapcPlayComplete(TInt aError)
   458 	{
   459 	iError = aError;
   460 	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   461 	CActiveScheduler::Stop();
   462 	}
   463 
   464 /** Load and initialise an audio file.
   465  */
   466 TVerdict CTestMmfAclntDRMPlayerOpen::DoTestStepL( void )
   467 	{
   468 	INFO_PRINTF1( _L("TestPlayerUtils : File"));
   469 	TVerdict ret = EFail;
   470 	TInt err=KErrNone;
   471 	iError = KErrTimedOut;
   472 	
   473 	//fectch MIME type from config file
   474 	TBuf8<KMaxMimeLength> mimeType;
   475 	TPtrC				  mimeTypePtr; 
   476 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
   477 		return EInconclusive;
   478 	mimeType.Copy(mimeTypePtr);
   479 
   480 
   481 	//setup file to open
   482 	TBuf<KSizeBuf>	filename;
   483 	TPtrC			filename1; 
   484 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   485 		return EInconclusive;
   486 	GetDriveName(filename);
   487 	filename.Append(filename1);
   488 
   489 	//setup DRM rights
   490 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   491 	CleanupStack::PushL(rights);
   492 	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
   493 	CleanupStack::PopAndDestroy(rights); // cleanup rights object
   494 
   495 	//create instance of Audio Player, which should try open the file as well
   496 	CMdaAudioPlayerUtility* player = NULL;
   497 	TRAP(err, player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this));
   498 	
   499 	if (iError == KErrNone)//call back OK
   500 	{
   501 		// Wait for initialisation callback
   502 		INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   503 		CActiveScheduler::Start();
   504 	}
   505 	else
   506 	{
   507 		INFO_PRINTF2(_L("Unexpected error %d"),iError);
   508 	}
   509 
   510 
   511 	if (err != KErrNone)
   512 		{
   513 			INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
   514 		}
   515 	else
   516 		{
   517 			INFO_PRINTF1(_L("Expected: PASS"));
   518 			ret = EPass;
   519 		}
   520 		
   521 	delete player;
   522 	User::After(KOneSecond); // wait for deletion to shut down devsound
   523 	return	ret;
   524 	}
   525 
   526 //--------------------------------------------------------------------------------
   527 
   528 /**
   529  * Constructor
   530  */
   531 CTestMmfAclntDRMRecorderPlay::CTestMmfAclntDRMRecorderPlay()
   532 	{
   533 	// store the name of this test case
   534 	// this is the name that is used by the script file
   535 	// Each test step initialises it's own name
   536 	iTestStepName = _L("MM-MMF-ACLNT-I-9005-LP");
   537 
   538 	}
   539 
   540 CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewL()
   541 	{
   542 	CTestMmfAclntDRMRecorderPlay* self = new (ELeave) CTestMmfAclntDRMRecorderPlay();
   543 	return self;
   544 	}
   545 
   546 CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewLC()
   547 	{
   548 	CTestMmfAclntDRMRecorderPlay* self = CTestMmfAclntDRMRecorderPlay::NewL();
   549 	CleanupStack::PushL(self);
   550 	return self;
   551 	}
   552 
   553 /** Load and initialise an audio file.
   554  */
   555 TVerdict CTestMmfAclntDRMRecorderPlay::DoTestStepL( void )
   556 	{
   557 	INFO_PRINTF1( _L("TestRecorderUtils : File"));
   558 	TVerdict ret = EFail;
   559 
   560 	iError = KErrTimedOut;
   561 
   562 	//fectch MIME type from config file
   563 	TBuf8<KMaxMimeLength> mimeType;
   564 	TPtrC				  mimeTypePtr; 
   565 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
   566 		return EInconclusive;
   567 	mimeType.Copy(mimeTypePtr);
   568 
   569 	//setup DRM rights
   570 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   571 	CleanupStack::PushL(rights);
   572 	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
   573 	CleanupStack::PopAndDestroy(rights); // cleanup rights object
   574 
   575 
   576 	TBuf<KSizeBuf>	filename;
   577 	TPtrC			filename1; 
   578 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   579 		return EInconclusive;
   580 	GetDriveName(filename);
   581 	filename.Append(filename1);
   582 
   583 	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
   584 	CleanupStack::PushL(recorder);
   585 
   586 	recorder->OpenFileL(filename);
   587 
   588 	// Wait for initialisation callback
   589 	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
   590 	CActiveScheduler::Start();
   591 
   592 	// Check for errors.
   593 	if (iError == KErrNone && recorder != NULL)
   594 		{
   595 		iError = KErrTimedOut;
   596 
   597 		recorder->PlayL();
   598 			
   599 		// Wait for play callback
   600 		INFO_PRINTF1( _L("Play DRM protected file with CMdaAudioRecorderUtility(with sufficient permission)"));
   601 		CActiveScheduler::Start();
   602 
   603 		if (iError != KErrNone)
   604 			{
   605 			INFO_PRINTF2(_L("Unexpected error trying to play protected file %d"),iError);
   606 			}
   607 		else
   608 			{
   609 			INFO_PRINTF1(_L("DRM Protected file played successfully"));
   610 			ret = EPass;
   611 			}
   612 		}
   613 	
   614 	CleanupStack::PopAndDestroy(recorder);
   615 	User::After(KOneSecond); // wait for deletion to shut down devsound
   616 	return	ret;
   617 	}
   618 
   619 
   620 
   621 
   622 void CTestMmfAclntDRMRecorderPlay::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
   623 	{
   624 	iError = aErrorCode;
   625 	//iObject = aObject;
   626 	iPreviousState = aPreviousState;
   627 	iCurrentState = aCurrentState;
   628 
   629 	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
   630 	if (!busy || iError!=KErrNone)
   631 		CActiveScheduler::Stop();
   632 	
   633 	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
   634 	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
   635 	
   636 	}
   637 
   638 
   639 //--------------------------------------------------------------------------------
   640 
   641 /**
   642  * Constructor
   643  */
   644 CTestMmfAclntDRMConverterFail::CTestMmfAclntDRMConverterFail()
   645 	{
   646 	// store the name of this test case
   647 	// this is the name that is used by the script file
   648 	// Each test step initialises it's own name
   649 	iTestStepName = _L("MM-MMF-ACLNT-I-9006-LP");
   650 
   651 	}
   652 
   653 CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewL()
   654 	{
   655 	CTestMmfAclntDRMConverterFail* self = new (ELeave) CTestMmfAclntDRMConverterFail();
   656 	return self;
   657 	}
   658 
   659 CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewLC()
   660 	{
   661 	CTestMmfAclntDRMConverterFail* self = CTestMmfAclntDRMConverterFail::NewL();
   662 	CleanupStack::PushL(self);
   663 	return self;
   664 	}
   665 
   666 /** Load and initialise an audio file.
   667  */
   668 TVerdict CTestMmfAclntDRMConverterFail::DoTestStepL( void )
   669 	{
   670 	INFO_PRINTF1( _L("TestconverterUtils : File"));
   671 	TVerdict ret = EFail;
   672 
   673 	iError = KErrTimedOut;
   674 
   675 	//fectch MIME type from config file
   676 	TBuf8<KMaxMimeLength> mimeType;
   677 	TPtrC				  mimeTypePtr; 
   678 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
   679 		return EInconclusive;
   680 	mimeType.Copy(mimeTypePtr);
   681 
   682 	//setup DRM rights
   683 	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
   684 	CleanupStack::PushL(rights);
   685 	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
   686 	CleanupStack::PopAndDestroy(rights); // cleanup rights object
   687 
   688 
   689 	TBuf<KSizeBuf>	filename;
   690 	TBuf<KSizeBuf>	destFilename;
   691 	TPtrC			filename1; 
   692 	TPtrC			filename2;
   693 	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
   694 		return EInconclusive;
   695 	if(!GetStringFromConfig(_L("SectionDRM"),_L("TestConvertFile"),filename2))
   696 		return EInconclusive;
   697 	GetDriveName(filename);
   698 	filename.Append(filename1);
   699 	GetDriveName(destFilename);
   700 	destFilename.Append(filename2);
   701 
   702 	RFs		theFs;
   703 	theFs.Connect();
   704 	theFs.Delete(destFilename);
   705 	theFs.Close();
   706 
   707 
   708 	iError = KErrTimedOut;
   709 	TMdaFileClipLocation location(destFilename);
   710 	TMdaWavClipFormat	format;
   711 	TMdaPcmWavCodec		codec;
   712 
   713 	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
   714 	CleanupStack::PushL(converter);
   715 
   716 	converter->OpenL(filename, &location, &format, &codec);
   717 
   718 	// Wait for initialisation callback
   719 	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
   720 	CActiveScheduler::Start();
   721 
   722 	// Check for errors.
   723 	if (iError == KErrNone && converter != NULL)
   724 		{
   725 		iError = KErrTimedOut;
   726 
   727 		converter->ConvertL();
   728 			
   729 		// Wait for convert callback
   730 		INFO_PRINTF1( _L("Convert CMdaAudioconverterUtility: DRM play number"));
   731 		CActiveScheduler::Start();
   732 
   733 		if (iError == KErrNotSupported)
   734 			{
   735 			INFO_PRINTF1(_L("Correctly received KErrNotSupported, for converting protected file"));
   736 			ret = EPass;
   737 			}
   738 		else
   739 			{
   740 			INFO_PRINTF3(_L("Unexpected error %d, expecting %d"),iError, KErrNotSupported);
   741 			}
   742 		}
   743 	
   744 	CleanupStack::PopAndDestroy(converter);
   745 	User::After(KOneSecond); // wait for deletion to shut down devsound
   746 	return	ret;
   747 	}
   748 
   749 
   750 
   751 
   752 void CTestMmfAclntDRMConverterFail::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
   753 	{
   754 	iError = aErrorCode;
   755 	//iObject = aObject;
   756 	iPreviousState = aPreviousState;
   757 	iCurrentState = aCurrentState;
   758 
   759 	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
   760 	if (!busy || iError!=KErrNone)
   761 		CActiveScheduler::Stop();
   762 
   763 	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioconverterUtility complete"));
   764 	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
   765 	
   766 	}
   767