Applications can use the ContentAccess::CManager class to manage files.
Some agents may choose to store content files inside their server private directories. In the file system the private directories have the following format:
\private\<process SID>\protectedfile.ext
If an agent want to publish the existence of its private directory, it specify the name of the private directory (the SecureID of the process) in the opaque_data section of the agent's ECom resource file. See Content Access Agent ECOM Resource File.
CAF maps the path to the agent name, so that it is human-readable. For example:
\private\<agent_name>\protectedfile.ext
The agents can advertise the existence of files to applications through their implementation of the ContentAccess::CAgentManager::GetDir() function. When an application opens a file stored in the private directory, CAF selects the agent which handles that content based upon the name in the path. If the file is not stored in a private directory, CAF checks each of the agents whether they support the file. If no agent supports the file, it reads as plaintext using F32Agent.
Create a manager object using the CManager::NewL() function.
Perform one or more of the following tasks as per your requirement:
// create a manager object CManager *manager = CManager::NewL(); // Use the manager to copy a file TInt result = manager->CopyFile(source, destination);
TInt result = manager->RenameFile(oldFilename, newFilename);
ContentAccess::CManager::DeleteFileL() allows a client to delete a specified file managed by a DRM agent.
The agent responsible for the content can display a dialog to confirm that the user wants to delete the file. This is particularly important if the content still has valid rights.
The agent implementation must decide whether to delete the rights or only the content.
TFileName filename; // Use the manager to delete a file // CAF asks the agent which actually owns the file to delete it. TInt result = manager->DeleteFile(filename);
ContentAccess::CManager::MkDir() allows a user to create a directory.
TInt result = manager->MkDir(fullpath);
If one or more of the sub-directories do not exist they are created too using the ContentAccess::CManager::MkDirAll() function.
TInt result = manager->MkDirAll(fullpath);
There are three variations of the ContentAccess::CManager::GetDir() function. They each allow a client to list the contents of an agent's private directory.
As mentioned earlier, it is optional for agents to provide this information.
CDir *aDir; TInt result = manager->GetDir (aName, aEntryAttMask, aEntrySortKey, aDir);
The CAF Apparc recognizer provides a MIME type that is a combination of the file MIME type and the content within the file. In some cases, such as forwarding DRM content to another device, it is important to make sure the content is sent with the correct MIME type.
Using the "" empty string UniqueId allows an application to determine the MIME type of the file.
TBuf <256> mimeType; TInt result = manager->GetStringAttribute(EMimeType, mimeType, TVirtualPathPtr(aURI,KNullDesC16()));
The CManager API allows applications to retrieve attributes or string attributes from a content object as described in Content Object Attributes.
ContentAccess::CManager::RmDir() allows a user to remove a directory.
TInt result = manager->RmDir(fullpath);
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.