contentmgmt/contentaccessfwfordrm/engineering/dox/CafCorruptData.dox
author savpatil@2INL09984
Thu, 08 Oct 2009 14:59:39 +0530
changeset 11 9d767430696e
parent 8 35751d3474b7
parent 6 50f2ff6984be
child 31 c0e7917aa107
permissions -rw-r--r--
Merged in changes from the tip of RCL_1 branch which includes fixes for Bug 284, Bug 383, Bug 287. These were wiped out from when the S^3 code drop came in.

// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// <hr>
// When supplying or consuming content it is possible that the content data has been 
// corrupted. This may be due to various reasons including file or disk corruption, 
// transmission errors, etc.
// If an agent detects corruption in a content object it will end the current 
// DRM operation and the <code>KErrCACorruptContent</code> or  <code>KErrCorrupt</code> error code will be sent back to the API clients, depending on the type of corruption detected and how the client chooses to handle it. It is recommended that clients be designed to handle such an error if received, as it can usually be considered a fatal error.
// An example of using this error code when importing content:
// CSupplier* supplier = CSupplier::NewLC();
// CImportFile* import = supplier->ImportFile( /*pass in specific MIME type and metadata
// 
//

/**
 @page CAFCorruptData Handling data corruption 
 - @ref CAFContentCorruption
 - @ref CAFRightsCorruption
 @section CAFContentCorruption Content data corruption
 @code
*/
TFileName fileName;
TBuf8<128> data;
TInt err = KErrNone;

// start importing content
while( (source still has data) && (err==KErrNone) )
	{
	source.read(data);
	err = import->WriteData(data);
	// need to supply new file to import to ?
	while (err == KErrCANewFileHandleRequired)		
		{
	    // supply new file in order to continue writing
		RFile newFile;
		import->GetSuggestedOutputFileName(fileName);
		newFile.Open(fileName, EFileWrite);
		err = import->ContinueWithNewOutputFile(newFile, fileName);
		newFile.Close();
		}
	}
	
if (err != KErrNone)
	{
	if (err == KErrCACorruptContent)
		{
		//Agent may have performed some error handling. 
		//Client may need to perform some client specific operations (e.g.cleanup).
		}
	else if (err == KErrCorrupt)
		{
		DisplayErrorMsg('Unable to import content because it is corrupt!');
		}
	else if (err == ...)
	...
	}	
...

@endcode


<hr>

@section CAFRightsCorruption Rights data corruption

When consuming content or when obtaining rights object information 
it is possible that the rights object data has been corrupted. This may be due 
to various reasons including file or disk corruption, transmission errors, etc.

If an agent detects corruption in a Rights object it will end the current 
DRM operation and the <code>KErrCACorruptRights</code> or <code>KErrCorrupt</code> error code will be sent back to 
API clients,depending on the type of corruption detected and how the client chooses to handle it. It is recommended that clients be designed to 
handle such an error if received, as it can usually be considered a fatal error.

An example of using this error code when accessing content:

@code
...
// Create a CContent object
CContent *content = ...

// Create a CData object to read the content
CData* data;
TRAP(err, data = content->OpenContentLC(EDisplay));

if (err != KErrNone)
	{
	if (err == KErrCACorruptRights)
		{
		//Agent may have performed some error handling. 
		//Client may need to perform some client specific operations(e.g. cleanup).
		}
	else if (err == KErrCorrupt)
		{
		DisplayErrorMsg('Unable to decode rights because it is corrupt!');
		}
	else if (err == ...)
	...
	}	
...

@endcode

<hr>
*/