contentmgmt/contentaccessfwfordrm/engineering/dox/CafCorruptData.dox
changeset 108 ca9a0fc2f082
parent 102 deec7e509f66
equal deleted inserted replaced
102:deec7e509f66 108:ca9a0fc2f082
     1 // Copyright (c) 2006-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 the License "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 // <hr>
       
    15 // When supplying or consuming content it is possible that the content data has been 
       
    16 // corrupted. This may be due to various reasons including file or disk corruption, 
       
    17 // transmission errors, etc.
       
    18 // If an agent detects corruption in a content object it will end the current 
       
    19 // 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.
       
    20 // An example of using this error code when importing content:
       
    21 // CSupplier* supplier = CSupplier::NewLC();
       
    22 // CImportFile* import = supplier->ImportFile( /*pass in specific MIME type and metadata
       
    23 // 
       
    24 //
       
    25 
       
    26 /**
       
    27  @page CAFCorruptData Handling data corruption 
       
    28  - @ref CAFContentCorruption
       
    29  - @ref CAFRightsCorruption
       
    30  @section CAFContentCorruption Content data corruption
       
    31  @code
       
    32 */
       
    33 TFileName fileName;
       
    34 TBuf8<128> data;
       
    35 TInt err = KErrNone;
       
    36 
       
    37 // start importing content
       
    38 while( (source still has data) && (err==KErrNone) )
       
    39 	{
       
    40 	source.read(data);
       
    41 	err = import->WriteData(data);
       
    42 	// need to supply new file to import to ?
       
    43 	while (err == KErrCANewFileHandleRequired)		
       
    44 		{
       
    45 	    // supply new file in order to continue writing
       
    46 		RFile newFile;
       
    47 		import->GetSuggestedOutputFileName(fileName);
       
    48 		newFile.Open(fileName, EFileWrite);
       
    49 		err = import->ContinueWithNewOutputFile(newFile, fileName);
       
    50 		newFile.Close();
       
    51 		}
       
    52 	}
       
    53 	
       
    54 if (err != KErrNone)
       
    55 	{
       
    56 	if (err == KErrCACorruptContent)
       
    57 		{
       
    58 		//Agent may have performed some error handling. 
       
    59 		//Client may need to perform some client specific operations (e.g.cleanup).
       
    60 		}
       
    61 	else if (err == KErrCorrupt)
       
    62 		{
       
    63 		DisplayErrorMsg('Unable to import content because it is corrupt!');
       
    64 		}
       
    65 	else if (err == ...)
       
    66 	...
       
    67 	}	
       
    68 ...
       
    69 
       
    70 @endcode
       
    71 
       
    72 
       
    73 <hr>
       
    74 
       
    75 @section CAFRightsCorruption Rights data corruption
       
    76 
       
    77 When consuming content or when obtaining rights object information 
       
    78 it is possible that the rights object data has been corrupted. This may be due 
       
    79 to various reasons including file or disk corruption, transmission errors, etc.
       
    80 
       
    81 If an agent detects corruption in a Rights object it will end the current 
       
    82 DRM operation and the <code>KErrCACorruptRights</code> or <code>KErrCorrupt</code> error code will be sent back to 
       
    83 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 
       
    84 handle such an error if received, as it can usually be considered a fatal error.
       
    85 
       
    86 An example of using this error code when accessing content:
       
    87 
       
    88 @code
       
    89 ...
       
    90 // Create a CContent object
       
    91 CContent *content = ...
       
    92 
       
    93 // Create a CData object to read the content
       
    94 CData* data;
       
    95 TRAP(err, data = content->OpenContentLC(EDisplay));
       
    96 
       
    97 if (err != KErrNone)
       
    98 	{
       
    99 	if (err == KErrCACorruptRights)
       
   100 		{
       
   101 		//Agent may have performed some error handling. 
       
   102 		//Client may need to perform some client specific operations(e.g. cleanup).
       
   103 		}
       
   104 	else if (err == KErrCorrupt)
       
   105 		{
       
   106 		DisplayErrorMsg('Unable to decode rights because it is corrupt!');
       
   107 		}
       
   108 	else if (err == ...)
       
   109 	...
       
   110 	}	
       
   111 ...
       
   112 
       
   113 @endcode
       
   114 
       
   115 <hr>
       
   116 */