1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/inc/virtualpath.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,170 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 +@file
1.25 +
1.26 +@publishedAll
1.27 +@released
1.28 +*/
1.29 +
1.30 +
1.31 +
1.32 +#ifndef __CAFVIRTUALPATH_H__
1.33 +#define __CAFVIRTUALPATH_H__
1.34 +
1.35 +#include <e32base.h>
1.36 +
1.37 +#include <caf/virtualpathptr.h>
1.38 +
1.39 +class RReadStream;
1.40 +class RWriteStream;
1.41 +
1.42 +namespace ContentAccess
1.43 + {
1.44 + class TVirtualPathPtr;
1.45 +
1.46 + /** A virtual path describes the location of the file (URI) and the location of
1.47 + a content object within that file (Unique Id).
1.48 +
1.49 + The URI must conform to the standard defined in RFC2396, found at http://www.ietf.org/.
1.50 +
1.51 + CVirtualPath makes a copy of the URI and UniqueId used to identify a particular content
1.52 + object within a file.
1.53 +
1.54 + The TVirtualPathPtr cast operator allows the CVirtualPath object to be used with
1.55 + CAF functions requiring a TVirtualPathPtr.
1.56 +
1.57 + The GetCombinedUriUniqueId() function allows it to "flatten" a virtual
1.58 + path into a single URI. The combined virtual path will be the URI concatenated with the UniqueId
1.59 + seperated by the KCafVirtualPathSeparator character taking the format.
1.60 + @code
1.61 + <URI><KCafVirtualPathSeparator><UniqueID>
1.62 + @endcode
1.63 +
1.64 + An example of this format is shown below:
1.65 + @code
1.66 + // Create a CVirtualPath object to point to OBJECT1 inside file.dcf
1.67 + CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1"));
1.68 +
1.69 + // convert the URI and unique ID into a single URI.
1.70 + TVirtualPathPtr aPath = path->GetCombinedUriUniqueId();
1.71 + @endcode
1.72 + @note
1.73 + If a URI is supplied which contains multiple KCafVirtualPathSeparator characters
1.74 + the rightmost KCafVirtualPathSeparator character will be taken as marking the end
1.75 + of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator
1.76 + characters are present, under certain situations this will result in an invalid
1.77 + URI and UniqueId being created for the virtual path and can lead to an undefined failure.
1.78 +
1.79 + */
1.80 + class CVirtualPath : public CBase
1.81 + {
1.82 + public:
1.83 + /** Create a CVirtualPath object from a TVirtualPathPtr
1.84 + @param aPtr The location of the content object
1.85 + @return a new CVirtualPath object
1.86 + */
1.87 + IMPORT_C static CVirtualPath* NewL(const TVirtualPathPtr& aPtr);
1.88 +
1.89 + /** Create a virtual path object from a combined Uri and UniqueId
1.90 +
1.91 + This constructs a CVirtual path from a single descriptor.
1.92 +
1.93 + Note that the descriptor here may be just a URI or it could be a URI
1.94 + concatenated with the file's UniqueId. If it is a concatenated URI and
1.95 + UniqueId the URI and UniqueId will be seperated by the KCasfVirtualPathSeparator character.
1.96 + For more information see above.
1.97 + @param aCombinedUriUniqueId The location of the content object
1.98 + @return a new CVirtualPath object
1.99 + */
1.100 + IMPORT_C static CVirtualPath* NewL(const TDesC& aCombinedUriUniqueId);
1.101 +
1.102 + /** Create a virtual path object for a specific content object within a file
1.103 + @param aURI The location of the file
1.104 + @param aUniqueId The location of the content within the file
1.105 + @return a new CVirtualPath object
1.106 + */
1.107 + IMPORT_C static CVirtualPath* NewL(const TDesC& aURI, const TDesC& aUniqueId);
1.108 +
1.109 + /** Construct and read a CVirtualPath object from a stream
1.110 + @param aStream The stream to read frin
1.111 + */
1.112 + IMPORT_C static CVirtualPath* NewL(RReadStream& aStream);
1.113 +
1.114 +
1.115 + virtual ~CVirtualPath();
1.116 +
1.117 + /** The location of the file containing the content object
1.118 + @return The location of the file
1.119 + */
1.120 + IMPORT_C const TDesC& URI() const;
1.121 +
1.122 + /** UniqueId supplied by a CAF Agent to identify the object within the
1.123 + file.
1.124 + @return The uniqueId of the object within the file
1.125 + */
1.126 + IMPORT_C const TDesC& UniqueId() const;
1.127 +
1.128 + /** Allows the class to write itself to a stream
1.129 + @param aStream The stream to write to
1.130 + */
1.131 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.132 +
1.133 + /** Convert the CVirtualPath to a single URI representing a particular
1.134 + content object. The URI and UniqueId will be separated by a KCafVirtualPathSeparator()
1.135 + @return A descriptor contaning the URI and UniqueId concatenated together
1.136 + */
1.137 + IMPORT_C const TDesC& GetCombinedUriUniqueId();
1.138 +
1.139 + /** Cast operator allowing the CVirtualPath to be used as a TVirtualPathPtr
1.140 + @return a TVirtualPathPtr with the same value as this object
1.141 + */
1.142 + inline operator const TVirtualPathPtr& () const;
1.143 +
1.144 + private:
1.145 + CVirtualPath(const TVirtualPathPtr& aPtr);
1.146 +
1.147 + /** Allow derived classes to call 2nd phase constructor
1.148 + */
1.149 + void ConstructL();
1.150 +
1.151 + /** Used to continue initialisation and setup iCombinedPtr */
1.152 + void CreateCombinedUriUniqueIdL(const TDesC& aUri, const TDesC& aUniqueId);
1.153 +
1.154 + void InternalizeL(RReadStream& aStream);
1.155 +
1.156 + private:
1.157 +
1.158 + HBufC* iURI;
1.159 + HBufC* iUniqueId;
1.160 + HBufC* iCombinedUriUniqueId;
1.161 + TPtrC iCombinedUriUniqueIdPtr;
1.162 + TVirtualPathPtr iVirtualPathPtr;
1.163 + };
1.164 +
1.165 +
1.166 + // Cast operator for treating a CVirtualPath as a TVirtualPathPtr
1.167 + inline CVirtualPath::operator const TVirtualPathPtr& () const
1.168 + {
1.169 + return iVirtualPathPtr;
1.170 + }
1.171 + }
1.172 +
1.173 +#endif