os/security/contentmgmt/referencedrmagent/tcaf/source/SupplierStep.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <test/testexecutelog.h>
sl@0
    20
#include <s32mem.h>
sl@0
    21
#include "cafserver.h"
sl@0
    22
#include "SupplierStep.h"
sl@0
    23
#include "supplier.h"
sl@0
    24
#include "cafmimeheader.h"
sl@0
    25
#include "caferr.h"
sl@0
    26
#include "metadataarray.h"
sl@0
    27
#include "supplieroutputfile.h"
sl@0
    28
#include "attribute.h"
sl@0
    29
#include "bitset.h"
sl@0
    30
sl@0
    31
#include <uri8.h>
sl@0
    32
#ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
sl@0
    33
#include <http.h>
sl@0
    34
#include <http/rhttpsession.h>
sl@0
    35
#include <http/rhttptransaction.h>
sl@0
    36
#include <http/rhttpheaders.h>
sl@0
    37
#endif
sl@0
    38
sl@0
    39
using namespace ContentAccess;
sl@0
    40
sl@0
    41
sl@0
    42
/* 
sl@0
    43
 * This step imports a DCF file into CAF 
sl@0
    44
 *
sl@0
    45
 */
sl@0
    46
CCafSupplierStep::~CCafSupplierStep()
sl@0
    47
	{
sl@0
    48
	}
sl@0
    49
sl@0
    50
CCafSupplierStep::CCafSupplierStep(CCAFServer& aParent) : iParent(aParent)
sl@0
    51
	{
sl@0
    52
	SetTestStepName(KCAFSupplierStep);
sl@0
    53
	}
sl@0
    54
sl@0
    55
sl@0
    56
TVerdict CCafSupplierStep::doTestStepL()
sl@0
    57
	{
sl@0
    58
	SetTestStepResult(EInconclusive);
sl@0
    59
sl@0
    60
	RFs fs;
sl@0
    61
	RFile file;
sl@0
    62
	TBuf8 <128> readBuffer;
sl@0
    63
	
sl@0
    64
	INFO_PRINTF1(_L("Supplier Test - Agent provides output files"));
sl@0
    65
	
sl@0
    66
	TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType;
sl@0
    67
	TInt expectedLeave;
sl@0
    68
sl@0
    69
	// Get parameters from INI file
sl@0
    70
	GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
sl@0
    71
	GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
sl@0
    72
	GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
sl@0
    73
	GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
sl@0
    74
	GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
sl@0
    75
	
sl@0
    76
	StartApparcServerL();
sl@0
    77
sl@0
    78
	__UHEAP_MARK;
sl@0
    79
	
sl@0
    80
	HBufC8 *mime = ConvertDes16toHBufC8LC(mimeType);
sl@0
    81
sl@0
    82
	CCafMimeHeader *header = CCafMimeHeader::NewL(mime->Des());
sl@0
    83
	CleanupStack::PushL(header);
sl@0
    84
sl@0
    85
	CSupplier *mySupplier = CSupplier::NewLC();
sl@0
    86
	mySupplier->SetOutputDirectoryL(outputDirectory);
sl@0
    87
	
sl@0
    88
	// ignore return value, just exercises code for CCover
sl@0
    89
	mySupplier->IsImportSupported(header->StandardMimeData(EContentType));
sl@0
    90
sl@0
    91
	CImportFile *import = NULL;
sl@0
    92
	TRAPD(leaveResult, import = mySupplier->ImportFileL(*header, suggestedFileName));
sl@0
    93
	if(leaveResult != expectedLeave)
sl@0
    94
		{
sl@0
    95
		SetTestStepResult(EFail);
sl@0
    96
		}
sl@0
    97
	if(leaveResult == KErrNone)
sl@0
    98
		{
sl@0
    99
		CleanupStack::PushL(import);
sl@0
   100
sl@0
   101
		// read the input file and pass it to the CAF
sl@0
   102
		fs.Connect();
sl@0
   103
		CleanupClosePushL(fs);
sl@0
   104
	
sl@0
   105
		TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
sl@0
   106
		CleanupClosePushL(file);
sl@0
   107
		while(result == KErrNone)
sl@0
   108
			{
sl@0
   109
			result = file.Read(readBuffer);
sl@0
   110
			if(readBuffer.Length() == 0)
sl@0
   111
				break;
sl@0
   112
			User::LeaveIfError(import->WriteData(readBuffer));
sl@0
   113
			}
sl@0
   114
		CleanupStack::PopAndDestroy(&file); 
sl@0
   115
		User::LeaveIfError(import->WriteDataComplete());
sl@0
   116
sl@0
   117
		TInt n = import->OutputFileCountL();
sl@0
   118
		for(TInt i = 0; i < n; i++)
sl@0
   119
			{
sl@0
   120
			// get output file name
sl@0
   121
			TPtrC OutputFileName = import->OutputFileL(i).FileName();
sl@0
   122
			INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
sl@0
   123
sl@0
   124
			// get output file type (content or receipt)
sl@0
   125
			TOutputType outputType = import->OutputFileL(i).OutputType();
sl@0
   126
sl@0
   127
			if(outputType == EReceipt)
sl@0
   128
				{
sl@0
   129
				INFO_PRINTF1(_L("Output File is a receipt"));
sl@0
   130
				}
sl@0
   131
			else
sl@0
   132
				{
sl@0
   133
				INFO_PRINTF1(_L("Output File is content"));
sl@0
   134
				}
sl@0
   135
sl@0
   136
			// get output file mime type
sl@0
   137
			TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
sl@0
   138
			HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
sl@0
   139
			INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
sl@0
   140
			CleanupStack::PopAndDestroy(mime); 
sl@0
   141
			}
sl@0
   142
		CleanupStack::PopAndDestroy(&fs); 
sl@0
   143
		CleanupStack::PopAndDestroy(import); 
sl@0
   144
		}
sl@0
   145
	CleanupStack::PopAndDestroy(mySupplier); 
sl@0
   146
	CleanupStack::PopAndDestroy(header); 
sl@0
   147
	CleanupStack::PopAndDestroy(mime); 
sl@0
   148
	__UHEAP_MARKEND;
sl@0
   149
sl@0
   150
	if (TestStepResult() != EFail)
sl@0
   151
		{
sl@0
   152
		SetTestStepResult(EPass);
sl@0
   153
		}
sl@0
   154
sl@0
   155
	return TestStepResult();
sl@0
   156
	}
sl@0
   157
sl@0
   158
sl@0
   159
sl@0
   160
/* 
sl@0
   161
 * This step imports a DCF file into CAF 
sl@0
   162
 *
sl@0
   163
 */
sl@0
   164
CCafSupplierAsyncStep::~CCafSupplierAsyncStep()
sl@0
   165
	{
sl@0
   166
	}
sl@0
   167
sl@0
   168
CCafSupplierAsyncStep::CCafSupplierAsyncStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   169
	{
sl@0
   170
	SetTestStepName(KCAFSupplierAsyncStep);
sl@0
   171
	}
sl@0
   172
sl@0
   173
sl@0
   174
TVerdict CCafSupplierAsyncStep::doTestStepL()
sl@0
   175
	{
sl@0
   176
	SetTestStepResult(EInconclusive);
sl@0
   177
sl@0
   178
	RFs fs;
sl@0
   179
	RFile file;
sl@0
   180
	TBuf8 <128> readBuffer;
sl@0
   181
	TRequestStatus status;
sl@0
   182
sl@0
   183
	INFO_PRINTF1(_L("Asynchronous Supplier Test - Agent provides output files"));
sl@0
   184
	
sl@0
   185
	TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType;
sl@0
   186
	TInt expectedLeave;
sl@0
   187
	
sl@0
   188
	// Get parameters from INI file
sl@0
   189
	GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
sl@0
   190
	GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
sl@0
   191
	GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
sl@0
   192
	GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
sl@0
   193
	GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
sl@0
   194
sl@0
   195
	StartApparcServerL();
sl@0
   196
sl@0
   197
sl@0
   198
	__UHEAP_MARK;
sl@0
   199
	
sl@0
   200
	HBufC8 *mime = ConvertDes16toHBufC8LC(mimeType);
sl@0
   201
sl@0
   202
	CCafMimeHeader *header = CCafMimeHeader::NewL(mime->Des());
sl@0
   203
	CleanupStack::PushL(header);
sl@0
   204
sl@0
   205
	CSupplier *mySupplier = CSupplier::NewLC();
sl@0
   206
	mySupplier->SetOutputDirectoryL(outputDirectory);
sl@0
   207
sl@0
   208
	// ignore return value, just exercises code for CCover
sl@0
   209
	mySupplier->IsImportSupported(header->StandardMimeData(EContentType));
sl@0
   210
sl@0
   211
	CImportFile *import = NULL;
sl@0
   212
	TRAPD(leaveResult, import = mySupplier->ImportFileL(*header, suggestedFileName));
sl@0
   213
	if(leaveResult != expectedLeave)
sl@0
   214
		{
sl@0
   215
		SetTestStepResult(EFail);
sl@0
   216
		}
sl@0
   217
	if(leaveResult == KErrNone)
sl@0
   218
		{
sl@0
   219
		CleanupStack::PushL(import);
sl@0
   220
sl@0
   221
		// read the input file and pass it to the CAF
sl@0
   222
		fs.Connect();
sl@0
   223
		CleanupClosePushL(fs);
sl@0
   224
	
sl@0
   225
		TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
sl@0
   226
		CleanupClosePushL(file);
sl@0
   227
		while(result == KErrNone)
sl@0
   228
			{
sl@0
   229
			result = file.Read(readBuffer);
sl@0
   230
			if(readBuffer.Length() == 0)
sl@0
   231
				break;
sl@0
   232
			status = KRequestPending;
sl@0
   233
			import->WriteData(readBuffer,status);
sl@0
   234
			User::WaitForRequest(status);
sl@0
   235
			}
sl@0
   236
		CleanupStack::PopAndDestroy(&file); 
sl@0
   237
		status = KRequestPending;
sl@0
   238
		import->WriteDataComplete(status);
sl@0
   239
		User::WaitForRequest(status);
sl@0
   240
sl@0
   241
		TInt n = import->OutputFileCountL();
sl@0
   242
		for(TInt i = 0; i < n; i++)
sl@0
   243
			{
sl@0
   244
			// get output file name
sl@0
   245
			TPtrC OutputFileName = import->OutputFileL(i).FileName();
sl@0
   246
			INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
sl@0
   247
sl@0
   248
			// get output file type (content or receipt)
sl@0
   249
			TOutputType outputType = import->OutputFileL(i).OutputType();
sl@0
   250
sl@0
   251
			if(outputType == EReceipt)
sl@0
   252
				{
sl@0
   253
				INFO_PRINTF1(_L("Output File is a receipt"));
sl@0
   254
				}
sl@0
   255
			else
sl@0
   256
				{
sl@0
   257
				INFO_PRINTF1(_L("Output File is content"));
sl@0
   258
				}
sl@0
   259
sl@0
   260
			// get output file mime type
sl@0
   261
			TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
sl@0
   262
			HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
sl@0
   263
			INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
sl@0
   264
			CleanupStack::PopAndDestroy(mime); 
sl@0
   265
			}
sl@0
   266
sl@0
   267
		CleanupStack::PopAndDestroy(&fs); 
sl@0
   268
		CleanupStack::PopAndDestroy(import); 
sl@0
   269
		}
sl@0
   270
	CleanupStack::PopAndDestroy(mySupplier); 
sl@0
   271
	CleanupStack::PopAndDestroy(header); 
sl@0
   272
	CleanupStack::PopAndDestroy(mime); 
sl@0
   273
	__UHEAP_MARKEND;
sl@0
   274
		
sl@0
   275
	if (TestStepResult() != EFail)
sl@0
   276
		{
sl@0
   277
		SetTestStepResult(EPass);
sl@0
   278
		}
sl@0
   279
sl@0
   280
	return TestStepResult();
sl@0
   281
	}
sl@0
   282
sl@0
   283
sl@0
   284
sl@0
   285
/* 
sl@0
   286
 * This step imports a DCF file into CAF 
sl@0
   287
 *
sl@0
   288
 */
sl@0
   289
CCafClientOutputSupplierStep::~CCafClientOutputSupplierStep()
sl@0
   290
	{
sl@0
   291
	}
sl@0
   292
sl@0
   293
CCafClientOutputSupplierStep::CCafClientOutputSupplierStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   294
	{
sl@0
   295
	SetTestStepName(KCAFClientOutputSupplierStep);
sl@0
   296
	}
sl@0
   297
sl@0
   298
void CCafClientOutputSupplierStep::CheckContentMimeL(CImportFile* aImport, TDes8& aContentMime, TDesC8& aExpectedContentMime)
sl@0
   299
	{
sl@0
   300
	if(!aImport->ContentMimeTypeL(aContentMime))
sl@0
   301
		{
sl@0
   302
		//Agent can't determine the content MIME type with available data at the moment
sl@0
   303
						
sl@0
   304
		INFO_PRINTF1(_L("Content MIME Type can't be determined"));
sl@0
   305
		SetTestStepResult(EFail);
sl@0
   306
		return;
sl@0
   307
		}
sl@0
   308
	
sl@0
   309
									    
sl@0
   310
	//If we reach here, we are expecting a correct Content MIME type 
sl@0
   311
	HBufC *mime = ConvertDes8toHBufC16LC(aContentMime);
sl@0
   312
	INFO_PRINTF2(_L("Content MIME Type: %S"), mime);
sl@0
   313
	CleanupStack::PopAndDestroy(mime);
sl@0
   314
										    					    				    					    	
sl@0
   315
	if(aContentMime.CompareF(aExpectedContentMime) == 0)
sl@0
   316
		{
sl@0
   317
		SetTestStepResult(EPass);
sl@0
   318
		}
sl@0
   319
	else
sl@0
   320
		{
sl@0
   321
		ERR_PRINTF1(_L("Content MIME Type doesn't match expected"));
sl@0
   322
		SetTestStepResult(EFail);
sl@0
   323
		}
sl@0
   324
			
sl@0
   325
	}
sl@0
   326
sl@0
   327
sl@0
   328
TVerdict CCafClientOutputSupplierStep::doTestStepL()
sl@0
   329
	{
sl@0
   330
	SetTestStepResult(EInconclusive);
sl@0
   331
sl@0
   332
	RFs fs;
sl@0
   333
	RFile file;
sl@0
   334
	TBuf8 <128> readBuffer;
sl@0
   335
	TBuf8 <255> mimetype8;
sl@0
   336
	TFileName outputFileName;
sl@0
   337
	RFile outputFile;
sl@0
   338
	CImportFile *import = NULL;
sl@0
   339
	
sl@0
   340
	// first output file will be a.txt
sl@0
   341
	_LIT(KOutputFileName, "C:\\something.drm");
sl@0
   342
	outputFileName.Copy(KOutputFileName);
sl@0
   343
	
sl@0
   344
	INFO_PRINTF1(_L("Supplier Test - Client provides output files"));
sl@0
   345
	
sl@0
   346
	TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType, expectedContentMime;
sl@0
   347
	TInt expectedLeave;
sl@0
   348
	TBool checkContentMime = EFalse;
sl@0
   349
	TBuf8<KMaxDataTypeLength> contentMimeType;	
sl@0
   350
	
sl@0
   351
	// Get parameters from INI file
sl@0
   352
	GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
sl@0
   353
	GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
sl@0
   354
	GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
sl@0
   355
	GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
sl@0
   356
	GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
sl@0
   357
	GetStringFromConfig(ConfigSection(),_L("ExpectedContentMime"),expectedContentMime);
sl@0
   358
	GetBoolFromConfig(ConfigSection(),_L("CheckContentMime"),checkContentMime);
sl@0
   359
	
sl@0
   360
	
sl@0
   361
	StartApparcServerL();
sl@0
   362
sl@0
   363
	__UHEAP_MARK;
sl@0
   364
	
sl@0
   365
	mimetype8.Copy(mimeType);
sl@0
   366
sl@0
   367
	// fill in meta data - just the mime type really
sl@0
   368
	CMetaDataArray *array = CMetaDataArray::NewL();
sl@0
   369
	CleanupStack::PushL(array);
sl@0
   370
	_LIT8(KContentType,"content-type");
sl@0
   371
	array->AddL(KContentType(), mimetype8);
sl@0
   372
sl@0
   373
	// create a supplier session
sl@0
   374
	CSupplier *mySupplier = CSupplier::NewL();
sl@0
   375
	CleanupStack::PushL(mySupplier);
sl@0
   376
	
sl@0
   377
	// check import is supported, ignore return value, just exercises code for CCover
sl@0
   378
	mySupplier->IsImportSupported(array->SearchL(KContentType()));
sl@0
   379
sl@0
   380
	// create import session
sl@0
   381
	TRAPD(leaveResult, import = mySupplier->ImportFileL(mimetype8, *array));
sl@0
   382
	if(leaveResult != expectedLeave)
sl@0
   383
		{
sl@0
   384
		SetTestStepResult(EFail);
sl@0
   385
		}
sl@0
   386
	if(leaveResult == KErrNone)
sl@0
   387
		{
sl@0
   388
		CleanupStack::PushL(import);
sl@0
   389
sl@0
   390
		// read the input file and pass it to the CAF
sl@0
   391
		fs.Connect();
sl@0
   392
		CleanupClosePushL(fs);
sl@0
   393
		TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
sl@0
   394
		CleanupClosePushL(file);
sl@0
   395
		
sl@0
   396
		TParsePtrC parse(suggestedFileName);
sl@0
   397
		TPtrC desiredOutFileName( parse.Name() );
sl@0
   398
		
sl@0
   399
		while(result == KErrNone)
sl@0
   400
			{
sl@0
   401
			result = file.Read(readBuffer);
sl@0
   402
			if(readBuffer.Length() == 0)
sl@0
   403
				break;
sl@0
   404
			result = import->WriteData(readBuffer);
sl@0
   405
			while(result == KErrCANewFileHandleRequired)
sl@0
   406
				{
sl@0
   407
				
sl@0
   408
				if(checkContentMime)
sl@0
   409
					{
sl@0
   410
					
sl@0
   411
					//If CheckContentMimeL failed, Client code should assume content MIME type wouldn't
sl@0
   412
					//be available until after the supply session has finished. The imported data could be
sl@0
   413
					//output to default location
sl@0
   414
					//In this test step, data are always output to default location regardless of content MIME
sl@0
   415
					//type
sl@0
   416
					TBuf8<KMaxDataTypeLength> expectedContentMime8bit;
sl@0
   417
					expectedContentMime8bit.Copy(expectedContentMime);
sl@0
   418
					CheckContentMimeL(import, contentMimeType, expectedContentMime8bit);
sl@0
   419
					//no more check needed in following iterations
sl@0
   420
					checkContentMime = EFalse;
sl@0
   421
						
sl@0
   422
					//At this point client should decide where to save the file based on content mime
sl@0
   423
					
sl@0
   424
					}
sl@0
   425
				
sl@0
   426
				const TInt KMaxExtLen = 28;
sl@0
   427
				TBuf<KMaxExtLen> suggestedExt;
sl@0
   428
				User::LeaveIfError(import->GetSuggestedOutputFileExtension(suggestedExt));
sl@0
   429
				outputFileName.Copy(outputDirectory);
sl@0
   430
				outputFileName.Append(desiredOutFileName);
sl@0
   431
				outputFileName.Append(suggestedExt);
sl@0
   432
				// create a new outputfile
sl@0
   433
				fs.Delete(outputFileName);
sl@0
   434
				User::LeaveIfError(outputFile.Create(fs,outputFileName, EFileShareAny  | EFileStream | EFileWrite));
sl@0
   435
				result = import->ContinueWithNewOutputFile(outputFile,outputFileName);
sl@0
   436
				outputFile.Close();
sl@0
   437
				}
sl@0
   438
			User::LeaveIfError(result);
sl@0
   439
			}
sl@0
   440
		CleanupStack::PopAndDestroy(&file); 
sl@0
   441
		result = import->WriteDataComplete();
sl@0
   442
		while(result == KErrCANewFileHandleRequired)
sl@0
   443
				{
sl@0
   444
				TFileName suggestedName;
sl@0
   445
				User::LeaveIfError(import->GetSuggestedOutputFileName(suggestedName));
sl@0
   446
				outputFileName.Copy(outputDirectory);
sl@0
   447
				outputFileName.Append(suggestedName);
sl@0
   448
sl@0
   449
				// create a new outputfile
sl@0
   450
				fs.Delete(outputFileName);
sl@0
   451
				User::LeaveIfError(outputFile.Create(fs,outputFileName, EFileShareAny  | EFileStream | EFileWrite));
sl@0
   452
				result = import->ContinueWithNewOutputFile(outputFile,outputFileName);
sl@0
   453
				outputFile.Close();
sl@0
   454
				}
sl@0
   455
	
sl@0
   456
sl@0
   457
		TInt n = import->OutputFileCountL();
sl@0
   458
		for(TInt i = 0; i < n; i++)
sl@0
   459
			{
sl@0
   460
			// get output file name
sl@0
   461
			TPtrC OutputFileName = import->OutputFileL(i).FileName();
sl@0
   462
			INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
sl@0
   463
sl@0
   464
			// get output file type (content or receipt)
sl@0
   465
			TOutputType outputType = import->OutputFileL(i).OutputType();
sl@0
   466
sl@0
   467
			if(outputType == EReceipt)
sl@0
   468
				{
sl@0
   469
				INFO_PRINTF1(_L("Output File is a receipt"));
sl@0
   470
				}
sl@0
   471
			else
sl@0
   472
				{
sl@0
   473
				INFO_PRINTF1(_L("Output File is content"));
sl@0
   474
				}
sl@0
   475
sl@0
   476
			// get output file mime type
sl@0
   477
			TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
sl@0
   478
			HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
sl@0
   479
			INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
sl@0
   480
			CleanupStack::PopAndDestroy(mime); 
sl@0
   481
			}
sl@0
   482
		CleanupStack::PopAndDestroy(&fs); 
sl@0
   483
		CleanupStack::PopAndDestroy(import); 
sl@0
   484
		}
sl@0
   485
	CleanupStack::PopAndDestroy(mySupplier); 
sl@0
   486
	CleanupStack::PopAndDestroy(array); 
sl@0
   487
	__UHEAP_MARKEND;
sl@0
   488
sl@0
   489
	if (TestStepResult() != EFail)
sl@0
   490
		{
sl@0
   491
		SetTestStepResult(EPass);
sl@0
   492
		}
sl@0
   493
sl@0
   494
	return TestStepResult();
sl@0
   495
	}
sl@0
   496
sl@0
   497
sl@0
   498
/* 
sl@0
   499
 * This step tests the ExternalizeL() and InternalizeL() functions for
sl@0
   500
 * CCafMimeHeader
sl@0
   501
 */
sl@0
   502
CCAFSupplierSerializeStep::~CCAFSupplierSerializeStep()
sl@0
   503
	{
sl@0
   504
	}
sl@0
   505
sl@0
   506
CCAFSupplierSerializeStep::CCAFSupplierSerializeStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   507
	{
sl@0
   508
	SetTestStepName(KCAFSupplierSerializeStep);
sl@0
   509
	}
sl@0
   510
sl@0
   511
sl@0
   512
TVerdict CCAFSupplierSerializeStep::doTestStepL()
sl@0
   513
	{	
sl@0
   514
	_LIT8(KDrmMime,"application/testagent.drm");
sl@0
   515
	_LIT8(KBinaryEncoding,"Binary");
sl@0
   516
	_LIT8(KOmaRightsPending, "X-Oma-Drm-Separate-Delivery");
sl@0
   517
	_LIT8(KOmaRightsPendingValue, "12");
sl@0
   518
	
sl@0
   519
	SetTestStepResult(EInconclusive); // Default result to EInconclusive
sl@0
   520
sl@0
   521
	__UHEAP_MARK;
sl@0
   522
	
sl@0
   523
	// create a CafMimeHeader with "content type:" application/testagent.drm
sl@0
   524
	CCafMimeHeader *header = CCafMimeHeader::NewL(KDrmMime());
sl@0
   525
	CleanupStack::PushL(header);
sl@0
   526
	
sl@0
   527
	// Add some information to the header
sl@0
   528
	header->SetStandardMimeDataL(EContentTransferEncoding, KBinaryEncoding());
sl@0
   529
	header->AddNonStandardMimeL(KOmaRightsPending(), KOmaRightsPendingValue());
sl@0
   530
sl@0
   531
	// Create a buffer stream
sl@0
   532
	CBufFlat* buf = CBufFlat::NewL(50);
sl@0
   533
	CleanupStack::PushL(buf);
sl@0
   534
	RBufWriteStream stream(*buf);
sl@0
   535
	CleanupClosePushL(stream);
sl@0
   536
sl@0
   537
	// call the stream function
sl@0
   538
	stream << *header;
sl@0
   539
	CleanupStack::PopAndDestroy(&stream);
sl@0
   540
sl@0
   541
	// Now, create an HBufC8 from the stream buf's length, and copy 
sl@0
   542
	// the stream buffer into this descriptor
sl@0
   543
	HBufC8* des = HBufC8::NewL(buf->Size());
sl@0
   544
	TPtr8 ptr(des->Des());
sl@0
   545
	buf->Read(0, ptr, buf->Size());
sl@0
   546
sl@0
   547
	// destroy the buffer
sl@0
   548
	CleanupStack::PopAndDestroy(buf);
sl@0
   549
	CleanupStack::PushL(des);
sl@0
   550
sl@0
   551
	// Now, stream a new CCafMimeHeader from the descriptor
sl@0
   552
	CCafMimeHeader* newHeader = CCafMimeHeader::NewL(KNullDesC8());
sl@0
   553
	CleanupStack::PushL(newHeader);
sl@0
   554
	RDesReadStream readstream(*des);
sl@0
   555
	CleanupClosePushL(readstream);
sl@0
   556
	readstream >> *newHeader;
sl@0
   557
	CleanupStack::PopAndDestroy(&readstream);
sl@0
   558
sl@0
   559
	// Now check that the new bitset equals the old one
sl@0
   560
	TInt result = newHeader->StandardMimeData(EContentType).Compare(KDrmMime());
sl@0
   561
	if (result != 0)
sl@0
   562
		{
sl@0
   563
		INFO_PRINTF1(_L("Content type was not copied properly during seriaization"));
sl@0
   564
		SetTestStepResult(EFail);
sl@0
   565
		}
sl@0
   566
	result = newHeader->StandardMimeData(EContentTransferEncoding).Compare(KBinaryEncoding());
sl@0
   567
	if (result != 0)
sl@0
   568
		{
sl@0
   569
		INFO_PRINTF1(_L("Content Length was not copied properly during seriaization"));
sl@0
   570
		SetTestStepResult(EFail);
sl@0
   571
		}
sl@0
   572
	
sl@0
   573
	if (newHeader->NonStandardMimeCount() != 1)
sl@0
   574
		{
sl@0
   575
		INFO_PRINTF1(_L("Non standard field array not copied properly during seriaization"));
sl@0
   576
		SetTestStepResult(EFail);
sl@0
   577
		}
sl@0
   578
sl@0
   579
	result = newHeader->NonStandardMimeField(0).Compare(KOmaRightsPending());
sl@0
   580
	if (result != 0)
sl@0
   581
		{
sl@0
   582
		INFO_PRINTF1(_L("Non standard field not copied properly during seriaization"));
sl@0
   583
		SetTestStepResult(EFail);
sl@0
   584
		}
sl@0
   585
sl@0
   586
	result = newHeader->NonStandardMimeData(0).Compare(KOmaRightsPendingValue());
sl@0
   587
	if (result != 0)
sl@0
   588
		{
sl@0
   589
		INFO_PRINTF1(_L("Non standard field data was not copied properly during seriaization"));
sl@0
   590
		SetTestStepResult(EFail);
sl@0
   591
		}
sl@0
   592
sl@0
   593
	CleanupStack::PopAndDestroy(3, header);
sl@0
   594
sl@0
   595
	__UHEAP_MARKEND;
sl@0
   596
	
sl@0
   597
	if (TestStepResult() != EFail)
sl@0
   598
		{
sl@0
   599
		SetTestStepResult(EPass);
sl@0
   600
		}
sl@0
   601
sl@0
   602
	return TestStepResult();
sl@0
   603
	}
sl@0
   604
sl@0
   605
#ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
sl@0
   606
sl@0
   607
/* 
sl@0
   608
 * Check that applications can retrieve the HTTP request headers
sl@0
   609
 */
sl@0
   610
CCAFHTTPRequestHeadersStep::~CCAFHTTPRequestHeadersStep()
sl@0
   611
	{
sl@0
   612
	}
sl@0
   613
sl@0
   614
CCAFHTTPRequestHeadersStep::CCAFHTTPRequestHeadersStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   615
	{
sl@0
   616
	SetTestStepName(KCAFHTTPRequestHeadersStep);
sl@0
   617
	}
sl@0
   618
sl@0
   619
sl@0
   620
void CCAFHTTPRequestHeadersStep::MHFRunL(RHTTPTransaction, const THTTPEvent&)
sl@0
   621
	{
sl@0
   622
	
sl@0
   623
	}
sl@0
   624
	
sl@0
   625
TInt CCAFHTTPRequestHeadersStep::MHFRunError(TInt, RHTTPTransaction, const THTTPEvent&)
sl@0
   626
	{
sl@0
   627
	return 0;
sl@0
   628
	}
sl@0
   629
sl@0
   630
sl@0
   631
TVerdict CCAFHTTPRequestHeadersStep::doTestStepL()
sl@0
   632
	{	
sl@0
   633
	_LIT8(Kuri, "http://www.symbian.com/");
sl@0
   634
	TPtrC8 acceptHeader;
sl@0
   635
	TInt i = 0;
sl@0
   636
	TInt result = 0;
sl@0
   637
	
sl@0
   638
	SetTestStepResult(EInconclusive); // Default result to EInconclusive
sl@0
   639
	THTTPHdrVal aValue;
sl@0
   640
	
sl@0
   641
	__UHEAP_MARK;
sl@0
   642
sl@0
   643
	CSupplier* supplier = CSupplier::NewLC();
sl@0
   644
	
sl@0
   645
	// Create an HTTP session 
sl@0
   646
	RHTTPSession session;
sl@0
   647
	session.OpenL();
sl@0
   648
	RStringPool pool = session.StringPool();
sl@0
   649
	
sl@0
   650
	
sl@0
   651
	// Convert the URI string into a TUri8
sl@0
   652
	TUriParser8 parser;
sl@0
   653
	parser.Parse(Kuri());
sl@0
   654
	
sl@0
   655
	// create an HTTP transaction
sl@0
   656
	RHTTPTransaction transaction = session.OpenTransactionL(parser, *this, pool.StringF(HTTP::EGET,RHTTPSession::GetTable()));
sl@0
   657
	RHTTPHeaders hdr = transaction.Request().GetHeaderCollection();
sl@0
   658
sl@0
   659
	// Get the request headers from the agent
sl@0
   660
	supplier->PrepareHTTPRequestHeaders(pool, hdr);
sl@0
   661
	
sl@0
   662
	TInt fieldParts = hdr.FieldPartsL(pool.StringF(HTTP::EAccept, RHTTPSession::GetTable()));
sl@0
   663
	if(fieldParts == 3)
sl@0
   664
		{
sl@0
   665
		for(i = 0; i < fieldParts; i++)
sl@0
   666
			{
sl@0
   667
			// loop over all accept headers make sure we find the three we expect
sl@0
   668
			User::LeaveIfError(hdr.GetField(pool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), i, aValue));
sl@0
   669
	
sl@0
   670
			RStringF header = (RStringF) aValue;
sl@0
   671
			acceptHeader.Set(header.DesC()); 
sl@0
   672
		
sl@0
   673
			// Reference Test Agent - content MIME type
sl@0
   674
			if(acceptHeader.Compare(_L8("application/x-rta.drm.content")) == 0)
sl@0
   675
				{
sl@0
   676
				result |= 1;
sl@0
   677
				}
sl@0
   678
			// Reference Test Agent - content + rights MIME type
sl@0
   679
			else if(acceptHeader.Compare(_L8("application/x-rta.drm.contentrights")) == 0)
sl@0
   680
				{
sl@0
   681
				result |= 2;
sl@0
   682
				}
sl@0
   683
			// Test Agent - MIME type
sl@0
   684
			else if(acceptHeader.Compare(_L8("APPLICATION/TESTAGENT.DRM")) == 0)
sl@0
   685
				{
sl@0
   686
				result |= 4;
sl@0
   687
				}
sl@0
   688
			}
sl@0
   689
		if(result != 7)
sl@0
   690
			{
sl@0
   691
			// not all three headers were found
sl@0
   692
			INFO_PRINTF1(_L("Not all expected HTTP Accept headers were present"));
sl@0
   693
			SetTestStepResult(EFail);		
sl@0
   694
			}
sl@0
   695
		}
sl@0
   696
	else
sl@0
   697
		{
sl@0
   698
		// We were expecting three accept headers to be set
sl@0
   699
		// two from the Reference Test Agent and one from Test Agent
sl@0
   700
		INFO_PRINTF2(_L("ERROR: Only %d HTTP Accept headers were returned, expected 3"), fieldParts);
sl@0
   701
		SetTestStepResult(EFail);	
sl@0
   702
		}
sl@0
   703
		
sl@0
   704
	transaction.Close();
sl@0
   705
	session.Close();
sl@0
   706
	CleanupStack::PopAndDestroy(supplier);
sl@0
   707
	__UHEAP_MARKEND;
sl@0
   708
	
sl@0
   709
	if (TestStepResult() != EFail)
sl@0
   710
		{
sl@0
   711
		SetTestStepResult(EPass);
sl@0
   712
		}
sl@0
   713
sl@0
   714
	return TestStepResult();
sl@0
   715
	}
sl@0
   716
sl@0
   717
#endif
sl@0
   718
sl@0
   719