Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Handling data corruption

[Top]


Content data corruption

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 KErrCACorruptContent or KErrCorrupt 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*/ );
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 == ...)
        ...
        }
...

[Top]


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 KErrCACorruptRights or KErrCorrupt 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:

...
// 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 == ...)
        ...
        }       
...