os/security/contentmgmt/contentaccessfwfordrm/inc/virtualpathptr.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 
    20 /** 
    21 @file
    22 
    23 @publishedAll
    24 @released
    25 */
    26 
    27 
    28 #ifndef __CAFVIRTUALPATHPTR_H__
    29 #define __CAFVIRTUALPATHPTR_H__
    30 
    31 #include <e32base.h>
    32 
    33 namespace ContentAccess
    34 	{
    35 	class CVirtualPath;
    36 
    37 	/** 
    38 	The character used to separate the URI from the UniqueId 
    39 	when the two are concatenated into a single descriptor 
    40 	*/
    41 	_LIT(KCafVirtualPathSeparator, "|");
    42 
    43 	/**	Identifies the location of a file and a particular content object inside it.
    44 
    45 	TVirtualPathPtr points to the two descriptors (the URI and UniqueId) used 
    46 	to initialise it. These descriptors must not be modified or destroyed while 
    47 	the TVirtualPathPtr object is in use. 
    48 	
    49 	The URI must be in the format specified in RFC2396, found at http://www.ietf.org/.
    50 
    51 	The UniqueId will be created by the Agent. Content is only ever
    52 	accessed by one agent so it is the agents responsibility to ensure the 
    53 	UniqueId is truly unique within the file.
    54 
    55 	It is also possible to flatten a virtual path into a single descriptor. The
    56 	ContentAccess::CVirtualPath class concatenates the URI, a separator, the KCafVirtualPathSeparator
    57 	character, and the UniqueId to form a single URI. TVirtualPathPtr can be used to 
    58 	decode this virtual path into the URI and the content object UniqueId. The 
    59 	concatenated URI and UniqueId take the format:
    60 	@code
    61 		<URI><KCafVirtualPathSeparator><UniqueID>
    62 	@endcode
    63 	
    64 	An example of this format is shown below:		
    65 	@code
    66 	// Create a CVirtualPath object to point to OBJECT1 inside file.dcf
    67 	CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1"));
    68 
    69 	// convert the URI and unique ID into a single URI.
    70 	TVirtualPathPtr aPath = path->GetCombinedUriUniqueId();
    71 	@endcode
    72 	@note
    73 	If a URI is supplied which contains multiple KCafVirtualPathSeparator characters 
    74 	the rightmost KCafVirtualPathSeparator character will be taken as marking the end
    75 	of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator
    76 	characters are present, under certain situations this will result in an invalid 
    77 	URI and UniqueId being created for the virtual path and can lead to an undefined failure.
    78 
    79 	*/
    80 	class TVirtualPathPtr
    81 		{
    82 	public:
    83 		/** Constructor used when the URI and UniqueId fields are separate 
    84 		@param aUri The location of the file
    85 		@param aUniqueId The location of the content within the file
    86 		*/
    87 		IMPORT_C TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId);
    88 
    89 		/** Constructor used for a concatenated URI and UniqueId.
    90 		
    91 		Note that the descriptor here may be just a URI or it could be a URI
    92 		concatenated with the file's UniqueId. If it is a concatenated URI and 
    93 		UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator character.
    94 		For more information see above.
    95 		@param aCombinedUriUniqueId The location of the content object
    96 		*/
    97 		IMPORT_C TVirtualPathPtr(const TDesC& aCombinedUriUniqueId);
    98 
    99 		/** Copy constructor */
   100 		IMPORT_C TVirtualPathPtr(const TVirtualPathPtr& aPtr);
   101 
   102 		/** The location of the file containing the content object 
   103 		@return The location of the file
   104 		*/
   105 		IMPORT_C const TDesC& URI() const;
   106 
   107 		/** UniqueId supplied by a CAF Agent to identify the object within the 
   108 		file.  
   109 		@return The location of the content within the file
   110 		*/
   111 		IMPORT_C const TDesC& UniqueId() const;
   112 
   113 		/** Assignment operator */
   114 		IMPORT_C TVirtualPathPtr& operator = (const TVirtualPathPtr& aVirtualPath);
   115 	
   116 		/** Assignment operator converts a single descriptor to a TVirtualPathPtr.
   117 		If the descriptor is just a URI, the TVirtualPathPtr will point to the KDefaultContentObject within that file.
   118 		If it is a concatenated URI and UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator. 
   119 		character as detailed in the description above.   
   120 		*/
   121 		IMPORT_C TVirtualPathPtr& operator = (const TDesC& aCombinedUriUniqueId);
   122 
   123 
   124 	private:
   125 		// The Set() function is only used by CVirtualPath
   126 		friend class CVirtualPath;
   127 
   128 		/** Used to redirect the TVirtualPathPtr to point at a different set of descriptors */
   129 		void Set(const TDesC& aUri, const TDesC& aUniqueId);
   130 
   131 	private:
   132 		TPtrC iUri;
   133 		TPtrC iUniqueId;
   134 		};
   135 	}
   136 
   137 #endif