MIME Content Policy

MIME Content Policy API is used for checking the MIME types and file extensions against the Closed Content List (apfmimecontentpolicy.rss). It also provides the functionality for checking if a given file is a DRM envelope, and a function to check if a file is considered closed content for any reason.

Description

MIME Content Policy utility uses File Server to access the resource files and Application Architecture Server (apparc) for recognizing and checking the MIME type using Symbian recognizers.

This utility uses Content Access Framework to check whether a file is forward locked, superdistributable or a DRM envelope.

All functionality can be accessed via a CApfMimeContentPolicy instance.

The functionality of this utility can be accessed through the apfmimecontentpolicy.h interface header. The binaries are linked to Apfile.DLL.

The diagram below illustrates the key relationships between the MIME Content Policy utility and the other subsystems:

Figure 1. Class diagram of the MIME Content Policy

Class

Description

CApfMimeContentPolicy

An interface class for the MIME Content Policy component. All the calls are routed to the CApfMimeContentPolicyImpl class without further processing here.

CApfMimeContentPolicyImpl

Implements the MIME Content Policy functionality.

CContent

A Symbian class for browsing the content objects contained within a single file.

RResourceFile

A Symbian class for accessing the resource file.

RFs

A Symbian class for a file system session.

RApaLsSession

A Symbian class for an Application Architecture Server session. Needed for recognizing the MIME type of a file.

Usage

A CApfMimeContentPolicy instance is created using one of its exported factory methods, NewL() or NewLC(). The exported interface can then be used in the usual way via the created instance. After the usage, the instance must be cleaned up using either PopAndDestroy() or delete.

This utility uses the common Symbian platform error handling mechanisms and has no specific errors defined.

Example

An example of code explaining the usage of MIME Content Policy API is given below:

#include <apfmimecontentpolicy.h>
#include <apgcli.h> // RApaLsSession

RApaLsSession   aLs; 
TFileName fileName = <name of the file to be checked>
TUid            uid;
TDataType       recData;

CApfMimeContentPolicy *ccp = CApfMimeContentPolicy::NewLC();

if (ccp->IsDRMEnvelope( fileName ))    
    {
    // Whatever needs to be done if file is DRM envelope. 
    }

// Check file extension.    
TParse parser;
parser.Set(fileName, NULL, NULL);
if (ccp->IsClosedExtension(parser.Ext()))
    {
    // Do what needs to be done if closed content.
    }

aLs.Connect(); // Open session with Application Architecture Server
aLs.AppForDocument(fileName, uid, recData);  // Get MIME type for file.

// Check if this MIME type is closed.
if (ccp->IsClosedType(recData.Des())   
    {  
    // Whatever needs to be done if type is closed.
    }

// Check if file is closed for any reason:
if (ccp->IsClosedFileL( fileName );
    {
    // Do whatever has to be done if file is closed.    
    }

// Don't forget to clean up.
CleanupStack::PopAndDestroy();  // ccp

For more information on individual methods, see the reference API for CApfMimeContentPolicy.