os/security/contentmgmt/contentaccessfwfordrm/engineering/dox/HowToContentAPI.dox
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 // NOTE: For the purpose of clarity we have ommitted full error checking in the 
    15 // <hr>
    16 // An example content file is given below. It has a number of content objects
    17 // and a number of containers with other containers and content objects inside.
    18 // It is likely that each container will have information or meta-data related
    19 // to the collection of objects it holds. 
    20 // <hr>
    21 // The <code>ContentAccess::CContent</code> object encapsulates a single file. It allows an application to look
    22 // at the structure of the objects within the file and the attributes of those objects.
    23 // There a two ways to create a \c CContent object. The application can specify the URI of the 
    24 // content or it can supply an open file handle.
    25 // // Create a CContent with a URI
    26 // CContent* content = CContent::NewL(uri);
    27 // // Create a CContent with an existing file handle
    28 // CContent* content = CContent::NewL(aFs, aFile);
    29 // Upon creation, \c CContent selects the agent that will handle the file. For 
    30 // <hr>
    31 // <code>ContentAccess::CContent</code> acts like a cursor, only able to list the contents of one container 
    32 // object at any one time. When \c CContent is first opened it views the top level
    33 // container within the file. The top level container is actually the file itself. 
    34 // This top level container concept applies to all files, regardless of how many 
    35 // content or container objects are inside. 
    36 // Even a content file such as a JPEG image is a container, it's just that 
    37 // the file only has the <code>"DEFAULT"</code> object embedded inside.
    38 // So when the example file shown earlier is opened the following objects can be seen
    39 // by the \c CContent:
    40 // In this top level container there is only one embedded content object visible (the .jpg file) and two
    41 // embedded container objects.
    42 // // Create an array to store the results of CContent::GetEmbeddedObjectsL()
    43 // RStreamablePtrArray<CEmbeddedObject> myArray;
    44 // CleanupClosePushL(myArray);
    45 // // Get the embedded content objects in the current container
    46 // content->GetEmbeddedObjectsL(myArray, EContentObject); 
    47 // i = myArray.Count();  // One content object
    48 // // clear the contents of the array
    49 // myArray.ResetAndDestroy();
    50 // // Get the number of container objects in the current container
    51 // content->GetEmbeddedObjectsL(myArray, EContainerObject); 
    52 // i = myArray.Count(); // Two container objects
    53 // // clear the contents of the array
    54 // myArray->ResetAndDestroy();
    55 // <hr>
    56 // To investigate the objects inside a container \c CContent must first open the container. 
    57 // This changes <code>CContent</code>'s focus from the current container to the container specified in
    58 // the <code>ContentAccess::CContent::OpenContainer()</code> function.
    59 // <b> Opening Container 1 from the top level of the file </b>
    60 // // Get the container objects in the top level of the file
    61 // content->GetEmbeddedObjectsL(myArray, EContainerObject);
    62 // // Find the Unique Id of the first container
    63 // TPtrC UniqueId = myArray[0]->UniqueId();
    64 // // Open the first container
    65 // content->OpenContainer(UniqueId);
    66 // Now \c CContent can see the contents of Container 1:
    67 // At this point, listing the objects that \c CContent can see gives six MP3
    68 // files and one container object.
    69 // // Get the embedded content objects in the current container
    70 // content->GetEmbeddedObjectsL(myArray, EContentObject); 
    71 // i = myArray.Count();  // Six content objects
    72 // myArray.ResetAndDestroy();
    73 // // Get the number of container objects in the current container
    74 // content->GetEmbeddedObjectsL(myArray, EContainerObject); 
    75 // i = myArray.Count(); // One container object
    76 // myArray.ResetAndDestroy();
    77 // <b> Opening Container 1.1 from Container 1</b>
    78 // The same process can be followed again to see the contents of Container 1.1
    79 // // Get the array of container objects in the current container
    80 // content->GetEmbeddedObjectsL(myArray, EContainerObject);
    81 // // Find the Unique Id of the first container within Container 1
    82 // TPtrC UniqueId = myArray[0]->UniqueId();
    83 // // Open Container 1.1
    84 // content->OpenContainer(UniqueId);
    85 // myArray.ResetAndDestroy();
    86 // // Can now see two content objects (the MOV file and the TXT file)
    87 // content->GetEmbeddedObjectsL(myArray, EContentObject);
    88 // i = myArray.Count(); 
    89 // myArray.ResetAndDestroy();
    90 // // Zero container objects
    91 // content->GetEmbeddedObjectsL(myArray, EContentObject);
    92 // i = myArray.Count(); 
    93 // myArray.ResetAndDestroy();
    94 // <hr>
    95 // To look once more at the contents of the container that encloses the current container
    96 // the <code>ContentAccess::CContent::CloseContainer()</code> function should be used.
    97 // Continuing our example, if we close the Container 1.1 we are left viewing
    98 // Container 1 again.
    99 // // Close Container 1.1
   100 // Econtent->CloseContainer();
   101 // // Get the embedded content objects in the current container
   102 // content->GetEmbeddedObjectsL(myArray, EContentObject); 
   103 // i = myArray.Count();  // Six content objects
   104 // myArray.ResetAndDestroy();
   105 // // Get the number of container objects in the current container
   106 // content->GetEmbeddedObjectsL(myArray, EContainerObject); 
   107 // i = myArray.Count(); // One container object
   108 // myArray.ResetAndDestroy();
   109 // <hr>
   110 // If an application wants to find all the content with a particular MIME
   111 // type within a file it should use <code>ContentAccess::CContent::Search()</code>.
   112 // This function will produce a list of all content objects with the specified
   113 // MIME type that are stored under the current container.
   114 // // Create an array for storing the result of the search
   115 // RStreamablePtrArray<CEmbeddedObject> myArray;
   116 // CleanupClosePushL(myArray);
   117 // // Get all MP3 files in Container 1 
   118 // content->Search(myArray, _L("mpeg/audio"), EFalse);
   119 // // Do something with results
   120 // // Cleanup
   121 // CleanupStack::PopAndDestroy(1);
   122 // <hr>
   123 // The functions described earlier can be used to locate a particular content
   124 // object within a file. <code>ContentAccess::CContent::OpenContentL()</code> can be used to 
   125 // read the content object. The \c UniqueId parameter can be used to identify
   126 // a particular object within the file.
   127 // The call to <code>ContentAccess::CContent::OpenContentL()</code> will leave if the intent 
   128 // is not permitted. This could occur if the file is DRM protected but no 
   129 // rights are present. 
   130 // If the file is DRM protected and the call to <code>OpenContentL()</code> succeeds, the rights 
   131 // are not consumed at this point. CAF just checks that it is possible to use the 
   132 // content.
   133 // // Open the content object specified by uniqueId with the EPlay Intent
   134 // CData* data = content->OpenContentL(EPlay, uniqueId);
   135 // If the application already knows the URI and unique Id of the content object 
   136 // it wants to read from, it can create a \c CData object directly. 
   137 // CData* data = CData::NewL(TVirtualPathPtr(uri, uniqueId), EPlay, EContentShareReadOnly);
   138 // Once the \c CData object has been constructed, it allows the content object to be used
   139 // as if it were a standalone unprotected file. The client must call <code>ContentAccess::CData::ExecuteIntent()</code> 
   140 // when the rights should be consumed. If the file is not DRM protected, the call 
   141 // will be ignored by the agent handling the file.
   142 // TBuf8 <256> buf;
   143 // data->ExecuteIntent(EPlay);
   144 // data->Seek(SomePosition,ESEEK_START);
   145 // data->Read(buf);
   146 // There are several overloaded versions of the <code>ContentAccess::CData::Read()</code> function. Only one is illustrated
   147 // above for example purposes.
   148 // <hr>
   149 // The \c CContent interface supports notification requests for content objects within files. The
   150 // events for which an application can request notification are given by the enumeration <code>ContentAccess::TEventMask</code>.
   151 // The following example requests and cancels notification for rights becoming available:
   152 // // Request notification when rights become available for a particular content object 
   153 // content->NotifyStatusChange(ERightsAvailable, status, uniqueId);
   154 // // Cancel notification request 
   155 // content->CancelNotifyStatusChange(status, uniqueId);
   156 // <hr>
   157 // There are two functions available that give the application some control over the rights: 
   158 // - <b> Request Rights </b> 
   159 // \n\n
   160 // <code>ContentAccess::CContent::RequestRights()</code> allows the application to ask the agent to undertake
   161 // whatever steps are necessary to obtain rights for the given content object. Some agents
   162 // may not support this mechanism, in which case they will return <code>KErrCANotSupported</code>.
   163 // \n\n
   164 // The request rights call includes an \c TRequestStatus parameter, which allows the application to
   165 // be notified of the outcome of the rights request.
   166 // content->RequestRights(status, uniqueId);
   167 // \n\n
   168 // - <b> Display Info </b>
   169 // \n\n
   170 // <code>ContentAccess::CContent::DisplayInfoL()</code> allows the application to ask the agent to display
   171 // the file and/or rights information for the given content object. The call returns when
   172 // the display is dismissed.
   173 // \n\n
   174 // Some agents may not support this mechanism, in which case they will leave with <code>KErrCANotSupported</code>.
   175 // \n\n
   176 // content->DisplayInfoL(EFileProperties, uniqueId);
   177 // <hr>
   178 // <hr>
   179 // 
   180 //
   181 
   182 /**
   183  @page CContentAPI Consumer API (Browsing and reading from content files)
   184  - @ref ExampleFile
   185  - @ref CreatingCContent
   186  - @ref Listing
   187  - @ref OpeningContainer
   188  - @ref ClosingContainer
   189  - @ref Searching
   190  - @ref CAFCData
   191  - @ref ContentNotification
   192  - @ref ContentRights
   193  - @ref AgentResolution 
   194  code examples given below. For examples with error checking see @ref ExampleReadWithErrCheck.
   195  @section ExampleFile An Example Content File
   196  @image html DRMFile1.gif
   197  @section CreatingCContent Creating a CContent Object
   198  @code
   199  @endcode
   200  @code
   201  @endcode
   202  details on how this selection is done see @ref AgentResolution.
   203  @section Listing Listing objects within a container
   204  @image html DRMFile2.gif
   205  @code
   206  @endcode
   207  @section OpeningContainer Opening a container
   208  @code
   209  @endcode
   210  @image html DRMFile3.gif
   211  @code
   212  @endcode
   213  @code
   214  @endcode
   215  @image html DRMFile4.gif
   216  @section ClosingContainer Closing a Container
   217  @code
   218  @endcode
   219  @image html DRMFile3.gif
   220  @section Searching Searching for a MIME type within a file
   221  @code
   222  @endcode
   223  @section CAFCData Reading data from a content object
   224  @code
   225  @endcode
   226  @code
   227  @endcode
   228  @code
   229  @endcode
   230  @section ContentNotification Content Object Notifications
   231  @code
   232  @endcode
   233  @section ContentRights Handling Rights for DRM content
   234  @code
   235  @endcode
   236  @code
   237  @endcode
   238  @section AgentResolution Agent resolution during CContent object creation
   239  @li During the creation of a CContent object an instance of the internal object CAgentResolver is created.
   240  @li CAgentResolver uses ECOM to identifier all the Content Access Agents (CAAs) on the system. An instance of CAgentInfo is created for each CAA found. CAgentInfo contains supplier and consumer MIME types as well as the CAA plug-in details.
   241  @li When a URI is supplied to CContent::NewL() and it contains a path for the private directory of one of the agent's then that CAA is used. For RFile no private directory exists so this check cannot be performed.
   242  @li If a private directory cannot be obtained from the URI or an RFile was supplied to CContent::NewL() each CAA plug-in identified by CAgentResolver is loaded in turn. 
   243  @li CAgentResolver obtains a CAgentManager object from each CAA in turn and calls IsRecognized() allowing the agent implementation to determine if it can support the file.
   244  @li If no CAA responds the default F32 CAA is used in to open the file as it is assumed to be unprotected content.
   245  @li Note: The MIME types loaded into CAgentInfo are not used for Agent Resolution but are utilized in file type recognition under Application Architecture recognizer framework.
   246 */