sl@0: /* sl@0: * Copyright (c) 2003-2006 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: * sl@0: */ sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __CAFVIRTUALPATHPTR_H__ sl@0: #define __CAFVIRTUALPATHPTR_H__ sl@0: sl@0: #include sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: class CVirtualPath; sl@0: sl@0: /** sl@0: The character used to separate the URI from the UniqueId sl@0: when the two are concatenated into a single descriptor sl@0: */ sl@0: _LIT(KCafVirtualPathSeparator, "|"); sl@0: sl@0: /** Identifies the location of a file and a particular content object inside it. sl@0: sl@0: TVirtualPathPtr points to the two descriptors (the URI and UniqueId) used sl@0: to initialise it. These descriptors must not be modified or destroyed while sl@0: the TVirtualPathPtr object is in use. sl@0: sl@0: The URI must be in the format specified in RFC2396, found at http://www.ietf.org/. sl@0: sl@0: The UniqueId will be created by the Agent. Content is only ever sl@0: accessed by one agent so it is the agents responsibility to ensure the sl@0: UniqueId is truly unique within the file. sl@0: sl@0: It is also possible to flatten a virtual path into a single descriptor. The sl@0: ContentAccess::CVirtualPath class concatenates the URI, a separator, the KCafVirtualPathSeparator sl@0: character, and the UniqueId to form a single URI. TVirtualPathPtr can be used to sl@0: decode this virtual path into the URI and the content object UniqueId. The sl@0: concatenated URI and UniqueId take the format: sl@0: @code sl@0: sl@0: @endcode sl@0: sl@0: An example of this format is shown below: sl@0: @code sl@0: // Create a CVirtualPath object to point to OBJECT1 inside file.dcf sl@0: CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1")); sl@0: sl@0: // convert the URI and unique ID into a single URI. sl@0: TVirtualPathPtr aPath = path->GetCombinedUriUniqueId(); sl@0: @endcode sl@0: @note sl@0: If a URI is supplied which contains multiple KCafVirtualPathSeparator characters sl@0: the rightmost KCafVirtualPathSeparator character will be taken as marking the end sl@0: of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator sl@0: characters are present, under certain situations this will result in an invalid sl@0: URI and UniqueId being created for the virtual path and can lead to an undefined failure. sl@0: sl@0: */ sl@0: class TVirtualPathPtr sl@0: { sl@0: public: sl@0: /** Constructor used when the URI and UniqueId fields are separate sl@0: @param aUri The location of the file sl@0: @param aUniqueId The location of the content within the file sl@0: */ sl@0: IMPORT_C TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId); sl@0: sl@0: /** Constructor used for a concatenated URI and UniqueId. sl@0: sl@0: Note that the descriptor here may be just a URI or it could be a URI sl@0: concatenated with the file's UniqueId. If it is a concatenated URI and sl@0: UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator character. sl@0: For more information see above. sl@0: @param aCombinedUriUniqueId The location of the content object sl@0: */ sl@0: IMPORT_C TVirtualPathPtr(const TDesC& aCombinedUriUniqueId); sl@0: sl@0: /** Copy constructor */ sl@0: IMPORT_C TVirtualPathPtr(const TVirtualPathPtr& aPtr); sl@0: sl@0: /** The location of the file containing the content object sl@0: @return The location of the file sl@0: */ sl@0: IMPORT_C const TDesC& URI() const; sl@0: sl@0: /** UniqueId supplied by a CAF Agent to identify the object within the sl@0: file. sl@0: @return The location of the content within the file sl@0: */ sl@0: IMPORT_C const TDesC& UniqueId() const; sl@0: sl@0: /** Assignment operator */ sl@0: IMPORT_C TVirtualPathPtr& operator = (const TVirtualPathPtr& aVirtualPath); sl@0: sl@0: /** Assignment operator converts a single descriptor to a TVirtualPathPtr. sl@0: If the descriptor is just a URI, the TVirtualPathPtr will point to the KDefaultContentObject within that file. sl@0: If it is a concatenated URI and UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator. sl@0: character as detailed in the description above. sl@0: */ sl@0: IMPORT_C TVirtualPathPtr& operator = (const TDesC& aCombinedUriUniqueId); sl@0: sl@0: sl@0: private: sl@0: // The Set() function is only used by CVirtualPath sl@0: friend class CVirtualPath; sl@0: sl@0: /** Used to redirect the TVirtualPathPtr to point at a different set of descriptors */ sl@0: void Set(const TDesC& aUri, const TDesC& aUniqueId); sl@0: sl@0: private: sl@0: TPtrC iUri; sl@0: TPtrC iUniqueId; sl@0: }; sl@0: } sl@0: sl@0: #endif