os/security/contentmgmt/contentaccessfwfordrm/inc/virtualpath.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 
    29 #ifndef __CAFVIRTUALPATH_H__
    30 #define __CAFVIRTUALPATH_H__
    31 
    32 #include <e32base.h>
    33 
    34 #include <caf/virtualpathptr.h>
    35 
    36 class RReadStream;
    37 class RWriteStream;
    38 
    39 namespace ContentAccess
    40 	{
    41 	class TVirtualPathPtr;
    42 
    43 	/**  A virtual path describes the location of the file (URI) and the location of
    44 	a content object within that file (Unique Id). 
    45 	
    46 	The URI must conform to the standard defined in RFC2396, found at http://www.ietf.org/.
    47 	
    48 	CVirtualPath makes a copy of the URI and UniqueId used to identify a particular content
    49 	object within a file.
    50 
    51 	The TVirtualPathPtr cast operator allows the CVirtualPath object to be used with 
    52 	CAF functions requiring a TVirtualPathPtr.
    53 
    54 	The GetCombinedUriUniqueId() function allows it to "flatten" a virtual 
    55 	path into a single URI. The combined virtual path will be the URI concatenated with the UniqueId
    56 	seperated by the KCafVirtualPathSeparator character taking the format. 
    57 	@code
    58 		<URI><KCafVirtualPathSeparator><UniqueID>
    59 	@endcode
    60 	
    61 	An example of this format is shown below:		
    62 	@code
    63 	// Create a CVirtualPath object to point to OBJECT1 inside file.dcf
    64 	CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1"));
    65 
    66 	// convert the URI and unique ID into a single URI.
    67 	TVirtualPathPtr aPath = path->GetCombinedUriUniqueId();
    68 	@endcode
    69 	@note
    70 	If a URI is supplied which contains multiple KCafVirtualPathSeparator characters 
    71 	the rightmost KCafVirtualPathSeparator character will be taken as marking the end
    72 	of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator
    73 	characters are present, under certain situations this will result in an invalid 
    74 	URI and UniqueId being created for the virtual path and can lead to an undefined failure.
    75 
    76 	*/
    77 	class CVirtualPath : public CBase
    78 		{
    79 	public:
    80 		/** Create a CVirtualPath object from a TVirtualPathPtr 
    81 		@param aPtr The location of the content object
    82 		@return a new CVirtualPath object
    83 		*/
    84 		IMPORT_C static CVirtualPath* NewL(const TVirtualPathPtr& aPtr);
    85 
    86 		/** Create a virtual path object from a combined Uri and UniqueId 
    87 		
    88 		This constructs a CVirtual path from a single descriptor. 
    89 		
    90 		Note that the descriptor here may be just a URI or it could be a URI
    91 		concatenated with the file's UniqueId. If it is a concatenated URI and 
    92 		UniqueId the URI and UniqueId will be seperated by the KCasfVirtualPathSeparator character.
    93 		For more information see above.
    94 		@param aCombinedUriUniqueId The location of the content object
    95 		@return a new CVirtualPath object
    96 		*/
    97 		IMPORT_C static CVirtualPath* NewL(const TDesC& aCombinedUriUniqueId);
    98 
    99 		/** Create a virtual path object for a specific content object within a file 
   100 		@param aURI The location of the file
   101 		@param aUniqueId The location of the content within the file
   102 		@return a new CVirtualPath object
   103 		*/
   104 		IMPORT_C static CVirtualPath* NewL(const TDesC& aURI, const TDesC& aUniqueId);
   105 		
   106 		/** Construct and read a CVirtualPath object from a stream 
   107 		@param aStream The stream to read frin
   108 		*/
   109 		IMPORT_C static CVirtualPath* NewL(RReadStream& aStream);
   110 
   111 
   112 		virtual ~CVirtualPath();
   113 
   114 		/** The location of the file containing the content object 
   115 		@return The location of the file
   116 		*/
   117 		IMPORT_C const TDesC& URI() const;
   118 
   119 		/** UniqueId supplied by a CAF Agent to identify the object within the 
   120 		file.  
   121 		@return The uniqueId of the object within the file
   122 		*/
   123 		IMPORT_C const TDesC& UniqueId() const;
   124 		
   125 		/** Allows the class to write itself to a stream 
   126 		@param aStream	The stream to write to
   127 		*/
   128 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   129 		
   130 		/** Convert the CVirtualPath to a single URI representing a particular 
   131 		content object. The URI and UniqueId will be separated by a KCafVirtualPathSeparator()
   132 		@return A descriptor contaning the URI and UniqueId concatenated together
   133 		*/
   134 		IMPORT_C const TDesC& GetCombinedUriUniqueId();
   135 
   136 		/** Cast operator allowing the CVirtualPath to be used as a TVirtualPathPtr 
   137 		@return a TVirtualPathPtr with the same value as this object
   138 		*/
   139 		inline operator const TVirtualPathPtr& () const;
   140 
   141 	private:
   142 		CVirtualPath(const TVirtualPathPtr& aPtr);	
   143 
   144 		/** Allow derived classes to call 2nd phase constructor
   145 		*/
   146 		void ConstructL();
   147 
   148 		/** Used to continue initialisation and setup iCombinedPtr */
   149 		void CreateCombinedUriUniqueIdL(const TDesC& aUri, const TDesC& aUniqueId);
   150 
   151 		void InternalizeL(RReadStream& aStream);
   152 
   153 	private:
   154 				
   155 		HBufC* iURI;
   156 		HBufC* iUniqueId;
   157 		HBufC* iCombinedUriUniqueId;
   158 		TPtrC iCombinedUriUniqueIdPtr;
   159 		TVirtualPathPtr iVirtualPathPtr;
   160 		};
   161 		
   162 
   163 	// Cast operator for treating a CVirtualPath as a TVirtualPathPtr
   164 	inline CVirtualPath::operator const TVirtualPathPtr& () const
   165 			{
   166 			return iVirtualPathPtr;
   167 			}
   168 	}
   169 
   170 #endif