Symbian3/PDK/Source/GUID-7B5DBFBC-E67F-56F8-AFF8-DFF5019D707F.dita
changeset 1 25a17d01db0c
child 5 f345bda72bc4
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-7B5DBFBC-E67F-56F8-AFF8-DFF5019D707F" xml:lang="en"><title>Managing
       
    13 Files</title><shortdesc>Applications can use the <apiname>ContentAccess::CManager</apiname> class
       
    14 to manage files. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <section><title>Introduction</title> <p>Some agents may choose to store content
       
    16 files inside their server private directories. In the file system the private
       
    17 directories have the following format: </p> <p> <filepath>\private\&lt;process
       
    18 SID&gt;\protectedfile.ext</filepath>  </p> <p>If an agent want to publish the
       
    19 existence of its private directory, it specify the name of the private directory
       
    20 (the SecureID of the process) in the <codeph>opaque_data</codeph> section
       
    21 of the agent's ECom resource file. See <xref href="GUID-5BD60B1B-CEB7-557A-A9DC-1BB64575F3E2.dita">Content
       
    22 Access Agent ECOM Resource File</xref>. </p> <p>CAF maps the path to the agent
       
    23 name, so that it is human-readable. For example: </p> <p> <filepath>\private\&lt;agent_name&gt;\protectedfile.ext</filepath>  </p> <p>The
       
    24 agents can advertise the existence of files to applications through their
       
    25 implementation of the <xref href="GUID-D7457871-5361-3684-9A95-FBDB9C2689DD.dita#GUID-D7457871-5361-3684-9A95-FBDB9C2689DD/GUID-0306A1CE-9EAA-3008-A9D7-1AACA95A6081"><apiname>ContentAccess::CAgentManager::GetDir()</apiname></xref> function.
       
    26 When an application opens a file stored in the private directory, CAF selects
       
    27 the agent which handles that content based upon the name in the path. If the
       
    28 file is not stored in a private directory, CAF checks each of the agents whether
       
    29 they support the file. If no agent supports the file, it reads as plaintext
       
    30 using F32Agent. </p> </section>
       
    31 <section><title>Required background</title> <p>Before you start, you must
       
    32 understand: </p> <ul>
       
    33 <li id="GUID-E7B3F1D9-8642-5DC2-911F-C1AB89B02C46"><p><xref href="GUID-84B6389A-55CC-53EB-8725-65F753FD7217.dita">Content
       
    34 Access Framework for DRM</xref>  </p> </li>
       
    35 <li id="GUID-BDCB532C-22AB-5CF0-9499-363480AB8E4A"><p><xref href="GUID-B6912FE7-4C2A-5FC7-BDA8-702CA2C0214A.dita">Content
       
    36 Object Attributes</xref>  </p> </li>
       
    37 </ul> </section>
       
    38 <section><title>Procedure</title> <ol id="GUID-0E77D596-02DA-5024-A607-4DD96FDC9AD1">
       
    39 <li id="GUID-6AE6D7DF-B2A2-5B10-BE92-4A268FA7E74E"><p>Create a manager object
       
    40 using the <xref href="GUID-7F3D9E35-A8FC-35A6-8036-23396BAADFDC.dita#GUID-7F3D9E35-A8FC-35A6-8036-23396BAADFDC/GUID-2F4CB027-777F-3F16-AE9A-8902F4AE87E7"><apiname>CManager::NewL()</apiname></xref> function. </p> </li>
       
    41 <li id="GUID-CBBF33EB-EFB8-5996-9DE6-914F705C36E0"><p>Perform one or more
       
    42 of the following tasks as per your requirement: </p> <ul>
       
    43 <li id="GUID-A3827F88-086A-52F6-8053-BA4CD185D354"><p>Copy a file </p> </li>
       
    44 <li id="GUID-AE03CB29-84BE-59B6-8A0B-047DCC580C69"><p>Move or rename a file </p> </li>
       
    45 <li id="GUID-EC87FDE9-0DAF-5903-B303-24A863C348DE"><p>Delete a file </p> </li>
       
    46 <li id="GUID-8F1E1E88-546E-5F40-B039-510994E5A2D8"><p>Create a directory </p> </li>
       
    47 <li id="GUID-82C5252F-863D-5AF9-8922-C14F76D48642"><p>List the contents of
       
    48 a directory </p> </li>
       
    49 <li id="GUID-69695624-CE3A-5569-AD36-5413B11BBE55"><p>Find the real MIME type
       
    50 of the file </p> </li>
       
    51 <li id="GUID-B073B5BE-D492-5A07-A02F-E744B90303A2"><p>Get the attributes of
       
    52 the content object</p> </li>
       
    53 <li id="GUID-A643A08C-98F8-5BC4-BA0E-A5E6E946CE8C"><p>Remove a directory </p> </li>
       
    54 </ul> </li>
       
    55 </ol> </section>
       
    56 <section><title>Copy a file</title><p> <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-61AA708F-8EE5-3D54-AD7A-2E4E7A253877"><apiname>ContentAccess::CManager::CopyFile()</apiname></xref> allows
       
    57 a user to make a copy of the file. For example, the user may wish to make
       
    58 a copy of the file onto removable media. When copying content managed by a
       
    59 DRM agent, the agent only copies the content, it does not copy the rights.
       
    60  <codeblock id="GUID-63550964-EEDD-51A2-8316-4B33F794E060" xml:space="preserve">// create a manager object
       
    61 CManager *manager = CManager::NewL();
       
    62 
       
    63 // Use the manager to copy a file
       
    64 TInt result = manager-&gt;CopyFile(source, destination);</codeblock></p></section>
       
    65 <section><title>Move or rename a file</title><p><xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-234C24A5-5C9E-3575-9FF3-8BC6F1C09902"><apiname>ContentAccess::CManager::RenameFile()</apiname></xref> allows
       
    66 a user to move or rename a file. For example, the user may wish to move the
       
    67 file to removable media.  <codeblock id="GUID-25D923DF-CA66-5E8F-87D8-44AFCE75E04E" xml:space="preserve">TInt result = manager-&gt;RenameFile(oldFilename, newFilename);</codeblock></p></section>
       
    68 <section><title>Delete a file</title><p> <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-CCE97FF8-FE23-3A16-A093-B2C9388EABDC"><apiname>ContentAccess::CManager::DeleteFileL()</apiname></xref> allows
       
    69 a client to delete a specified file managed by a DRM agent. </p> <p>The agent
       
    70 responsible for the content can display a dialog to confirm that the user
       
    71 wants to delete the file. This is particularly important if the content still
       
    72 has valid rights. </p> <p>The agent implementation must decide whether to
       
    73 delete the rights or only the content. </p> <codeblock id="GUID-BBEBA78E-6BBD-5179-9C1E-7329BCCAED73" xml:space="preserve">TFileName filename;
       
    74 
       
    75 // Use the manager to delete a file
       
    76 // CAF asks the agent which actually owns the file to delete it.
       
    77 TInt result = manager-&gt;DeleteFile(filename);</codeblock></section>
       
    78 <section><title>Create a directory</title><p> <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-218ADCB8-25BA-31E0-83D2-8E2315CAD3C3"><apiname>ContentAccess::CManager::MkDir()</apiname></xref> allows
       
    79 a user to create a directory. </p> <codeblock id="GUID-886A4120-8A50-5740-98EA-B389C590F226" xml:space="preserve">TInt result = manager-&gt;MkDir(fullpath);</codeblock> <p>If one or more of the sub-directories do not exist they are created too using
       
    80 the <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-83D7D7A2-3046-381F-A856-04FA661F37CD"><apiname> ContentAccess::CManager::MkDirAll()</apiname></xref> function. </p> <codeblock id="GUID-E83DD3C2-6816-5834-8561-565EAC7FEE26" xml:space="preserve">TInt result = manager-&gt;MkDirAll(fullpath);</codeblock></section>
       
    81 <section><title>List the contents of a directory</title><p>There are three
       
    82 variations of the <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-BAA97FAB-5DEA-3FCB-93AD-8157D1AF6AC7"><apiname>ContentAccess::CManager::GetDir()</apiname></xref> function.
       
    83 They each allow a client to list the contents of an agent's private directory. </p> <p>As
       
    84 mentioned earlier, it is optional for agents to provide this information. </p> <codeblock id="GUID-5AB17FAF-83A1-518B-9D1D-B00C8818BFC2" xml:space="preserve">CDir *aDir;
       
    85 TInt result = manager-&gt;GetDir (aName, aEntryAttMask, aEntrySortKey, aDir);</codeblock></section>
       
    86 <section><title>Find the real MIME type of the file</title><p>The CAF Apparc
       
    87 recognizer provides a MIME type that is a combination of the file MIME type
       
    88 and the content within the file. In some cases, such as forwarding DRM content
       
    89 to another device, it is important to make sure the content is sent with the
       
    90 correct MIME type. </p> <p>Using the <codeph>""</codeph> empty string <codeph>UniqueId</codeph> allows
       
    91 an application to determine the MIME type of the file. </p> <codeblock id="GUID-CF389440-3AE5-5AC2-97E1-57E0D30901D6" xml:space="preserve">TBuf &lt;256&gt; mimeType;
       
    92 TInt result = manager-&gt;GetStringAttribute(EMimeType, mimeType, TVirtualPathPtr(aURI,KNullDesC16()));</codeblock></section>
       
    93 <section><title>Get the attributes of the content object</title><p>The <xref href="GUID-7F3D9E35-A8FC-35A6-8036-23396BAADFDC.dita"><apiname>CManager</apiname></xref> API
       
    94 allows applications to retrieve attributes or string attributes from a content
       
    95 object as described in <xref href="GUID-B6912FE7-4C2A-5FC7-BDA8-702CA2C0214A.dita">Content
       
    96 Object Attributes</xref>. </p></section>
       
    97 <section><title>Remove a directory</title><p> <xref href="GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8.dita#GUID-671191B1-B249-3DD3-A5E8-6F1A41A371C8/GUID-BB1AE25D-11DD-3599-902D-BE5B2D414C26"><apiname> ContentAccess::CManager::RmDir()</apiname></xref> allows
       
    98 a user to remove a directory. </p> <codeblock id="GUID-9350BEDB-5767-5CD2-9456-8AC1B9DF374F" xml:space="preserve">TInt result = manager-&gt;RmDir(fullpath);</codeblock></section>
       
    99 <section><title>See also</title> <p><xref href="GUID-E99E0092-5F1D-5715-945E-E83C307357C3.dita">Managing
       
   100 CAF Agents</xref>  </p> </section>
       
   101 </conbody></concept>