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