sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // NOTE: For the purpose of clarity we have ommitted full error checking in the sl@0: //
ContentAccess::CContent
object encapsulates a single file. It allows an application to look
sl@0: // at the structure of the objects within the file and the attributes of those objects.
sl@0: // There a two ways to create a \c CContent object. The application can specify the URI of the
sl@0: // content or it can supply an open file handle.
sl@0: // // Create a CContent with a URI
sl@0: // CContent* content = CContent::NewL(uri);
sl@0: // // Create a CContent with an existing file handle
sl@0: // CContent* content = CContent::NewL(aFs, aFile);
sl@0: // Upon creation, \c CContent selects the agent that will handle the file. For
sl@0: // ContentAccess::CContent
acts like a cursor, only able to list the contents of one container
sl@0: // object at any one time. When \c CContent is first opened it views the top level
sl@0: // container within the file. The top level container is actually the file itself.
sl@0: // This top level container concept applies to all files, regardless of how many
sl@0: // content or container objects are inside.
sl@0: // Even a content file such as a JPEG image is a container, it's just that
sl@0: // the file only has the "DEFAULT"
object embedded inside.
sl@0: // So when the example file shown earlier is opened the following objects can be seen
sl@0: // by the \c CContent:
sl@0: // In this top level container there is only one embedded content object visible (the .jpg file) and two
sl@0: // embedded container objects.
sl@0: // // Create an array to store the results of CContent::GetEmbeddedObjectsL()
sl@0: // RStreamablePtrArrayCContent
's focus from the current container to the container specified in
sl@0: // the ContentAccess::CContent::OpenContainer()
function.
sl@0: // Opening Container 1 from the top level of the file
sl@0: // // Get the container objects in the top level of the file
sl@0: // content->GetEmbeddedObjectsL(myArray, EContainerObject);
sl@0: // // Find the Unique Id of the first container
sl@0: // TPtrC UniqueId = myArray[0]->UniqueId();
sl@0: // // Open the first container
sl@0: // content->OpenContainer(UniqueId);
sl@0: // Now \c CContent can see the contents of Container 1:
sl@0: // At this point, listing the objects that \c CContent can see gives six MP3
sl@0: // files and one container object.
sl@0: // // Get the embedded content objects in the current container
sl@0: // content->GetEmbeddedObjectsL(myArray, EContentObject);
sl@0: // i = myArray.Count(); // Six content objects
sl@0: // myArray.ResetAndDestroy();
sl@0: // // Get the number of container objects in the current container
sl@0: // content->GetEmbeddedObjectsL(myArray, EContainerObject);
sl@0: // i = myArray.Count(); // One container object
sl@0: // myArray.ResetAndDestroy();
sl@0: // Opening Container 1.1 from Container 1
sl@0: // The same process can be followed again to see the contents of Container 1.1
sl@0: // // Get the array of container objects in the current container
sl@0: // content->GetEmbeddedObjectsL(myArray, EContainerObject);
sl@0: // // Find the Unique Id of the first container within Container 1
sl@0: // TPtrC UniqueId = myArray[0]->UniqueId();
sl@0: // // Open Container 1.1
sl@0: // content->OpenContainer(UniqueId);
sl@0: // myArray.ResetAndDestroy();
sl@0: // // Can now see two content objects (the MOV file and the TXT file)
sl@0: // content->GetEmbeddedObjectsL(myArray, EContentObject);
sl@0: // i = myArray.Count();
sl@0: // myArray.ResetAndDestroy();
sl@0: // // Zero container objects
sl@0: // content->GetEmbeddedObjectsL(myArray, EContentObject);
sl@0: // i = myArray.Count();
sl@0: // myArray.ResetAndDestroy();
sl@0: // ContentAccess::CContent::CloseContainer()
function should be used.
sl@0: // Continuing our example, if we close the Container 1.1 we are left viewing
sl@0: // Container 1 again.
sl@0: // // Close Container 1.1
sl@0: // Econtent->CloseContainer();
sl@0: // // Get the embedded content objects in the current container
sl@0: // content->GetEmbeddedObjectsL(myArray, EContentObject);
sl@0: // i = myArray.Count(); // Six content objects
sl@0: // myArray.ResetAndDestroy();
sl@0: // // Get the number of container objects in the current container
sl@0: // content->GetEmbeddedObjectsL(myArray, EContainerObject);
sl@0: // i = myArray.Count(); // One container object
sl@0: // myArray.ResetAndDestroy();
sl@0: // ContentAccess::CContent::Search()
.
sl@0: // This function will produce a list of all content objects with the specified
sl@0: // MIME type that are stored under the current container.
sl@0: // // Create an array for storing the result of the search
sl@0: // RStreamablePtrArrayContentAccess::CContent::OpenContentL()
can be used to
sl@0: // read the content object. The \c UniqueId parameter can be used to identify
sl@0: // a particular object within the file.
sl@0: // The call to ContentAccess::CContent::OpenContentL()
will leave if the intent
sl@0: // is not permitted. This could occur if the file is DRM protected but no
sl@0: // rights are present.
sl@0: // If the file is DRM protected and the call to OpenContentL()
succeeds, the rights
sl@0: // are not consumed at this point. CAF just checks that it is possible to use the
sl@0: // content.
sl@0: // // Open the content object specified by uniqueId with the EPlay Intent
sl@0: // CData* data = content->OpenContentL(EPlay, uniqueId);
sl@0: // If the application already knows the URI and unique Id of the content object
sl@0: // it wants to read from, it can create a \c CData object directly.
sl@0: // CData* data = CData::NewL(TVirtualPathPtr(uri, uniqueId), EPlay, EContentShareReadOnly);
sl@0: // Once the \c CData object has been constructed, it allows the content object to be used
sl@0: // as if it were a standalone unprotected file. The client must call ContentAccess::CData::ExecuteIntent()
sl@0: // when the rights should be consumed. If the file is not DRM protected, the call
sl@0: // will be ignored by the agent handling the file.
sl@0: // TBuf8 <256> buf;
sl@0: // data->ExecuteIntent(EPlay);
sl@0: // data->Seek(SomePosition,ESEEK_START);
sl@0: // data->Read(buf);
sl@0: // There are several overloaded versions of the ContentAccess::CData::Read()
function. Only one is illustrated
sl@0: // above for example purposes.
sl@0: // ContentAccess::TEventMask
.
sl@0: // The following example requests and cancels notification for rights becoming available:
sl@0: // // Request notification when rights become available for a particular content object
sl@0: // content->NotifyStatusChange(ERightsAvailable, status, uniqueId);
sl@0: // // Cancel notification request
sl@0: // content->CancelNotifyStatusChange(status, uniqueId);
sl@0: // ContentAccess::CContent::RequestRights()
allows the application to ask the agent to undertake
sl@0: // whatever steps are necessary to obtain rights for the given content object. Some agents
sl@0: // may not support this mechanism, in which case they will return KErrCANotSupported
.
sl@0: // \n\n
sl@0: // The request rights call includes an \c TRequestStatus parameter, which allows the application to
sl@0: // be notified of the outcome of the rights request.
sl@0: // content->RequestRights(status, uniqueId);
sl@0: // \n\n
sl@0: // - Display Info
sl@0: // \n\n
sl@0: // ContentAccess::CContent::DisplayInfoL()
allows the application to ask the agent to display
sl@0: // the file and/or rights information for the given content object. The call returns when
sl@0: // the display is dismissed.
sl@0: // \n\n
sl@0: // Some agents may not support this mechanism, in which case they will leave with KErrCANotSupported
.
sl@0: // \n\n
sl@0: // content->DisplayInfoL(EFileProperties, uniqueId);
sl@0: //