1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/caf/virtualpath.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,172 @@
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 +@publishedPartner
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 + @publishedPartner
1.80 + @released
1.81 + */
1.82 + class CVirtualPath : public CBase
1.83 + {
1.84 + public:
1.85 + /** Create a CVirtualPath object from a TVirtualPathPtr
1.86 + @param aPtr The location of the content object
1.87 + @return a new CVirtualPath object
1.88 + */
1.89 + IMPORT_C static CVirtualPath* NewL(const TVirtualPathPtr& aPtr);
1.90 +
1.91 + /** Create a virtual path object from a combined Uri and UniqueId
1.92 +
1.93 + This constructs a CVirtual path from a single descriptor.
1.94 +
1.95 + Note that the descriptor here may be just a URI or it could be a URI
1.96 + concatenated with the file's UniqueId. If it is a concatenated URI and
1.97 + UniqueId the URI and UniqueId will be seperated by the KCasfVirtualPathSeparator character.
1.98 + For more information see above.
1.99 + @param aCombinedUriUniqueId The location of the content object
1.100 + @return a new CVirtualPath object
1.101 + */
1.102 + IMPORT_C static CVirtualPath* NewL(const TDesC& aCombinedUriUniqueId);
1.103 +
1.104 + /** Create a virtual path object for a specific content object within a file
1.105 + @param aURI The location of the file
1.106 + @param aUniqueId The location of the content within the file
1.107 + @return a new CVirtualPath object
1.108 + */
1.109 + IMPORT_C static CVirtualPath* NewL(const TDesC& aURI, const TDesC& aUniqueId);
1.110 +
1.111 + /** Construct and read a CVirtualPath object from a stream
1.112 + @param aStream The stream to read frin
1.113 + */
1.114 + IMPORT_C static CVirtualPath* NewL(RReadStream& aStream);
1.115 +
1.116 +
1.117 + virtual ~CVirtualPath();
1.118 +
1.119 + /** The location of the file containing the content object
1.120 + @return The location of the file
1.121 + */
1.122 + IMPORT_C const TDesC& URI() const;
1.123 +
1.124 + /** UniqueId supplied by a CAF Agent to identify the object within the
1.125 + file.
1.126 + @return The uniqueId of the object within the file
1.127 + */
1.128 + IMPORT_C const TDesC& UniqueId() const;
1.129 +
1.130 + /** Allows the class to write itself to a stream
1.131 + @param aStream The stream to write to
1.132 + */
1.133 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.134 +
1.135 + /** Convert the CVirtualPath to a single URI representing a particular
1.136 + content object. The URI and UniqueId will be separated by a KCafVirtualPathSeparator()
1.137 + @return A descriptor contaning the URI and UniqueId concatenated together
1.138 + */
1.139 + IMPORT_C const TDesC& GetCombinedUriUniqueId();
1.140 +
1.141 + /** Cast operator allowing the CVirtualPath to be used as a TVirtualPathPtr
1.142 + @return a TVirtualPathPtr with the same value as this object
1.143 + */
1.144 + inline operator const TVirtualPathPtr& () const;
1.145 +
1.146 + private:
1.147 + CVirtualPath(const TVirtualPathPtr& aPtr);
1.148 +
1.149 + /** Allow derived classes to call 2nd phase constructor
1.150 + */
1.151 + void ConstructL();
1.152 +
1.153 + /** Used to continue initialisation and setup iCombinedPtr */
1.154 + void CreateCombinedUriUniqueIdL(const TDesC& aUri, const TDesC& aUniqueId);
1.155 +
1.156 + void InternalizeL(RReadStream& aStream);
1.157 +
1.158 + private:
1.159 +
1.160 + HBufC* iURI;
1.161 + HBufC* iUniqueId;
1.162 + HBufC* iCombinedUriUniqueId;
1.163 + TPtrC iCombinedUriUniqueIdPtr;
1.164 + TVirtualPathPtr iVirtualPathPtr;
1.165 + };
1.166 +
1.167 +
1.168 + // Cast operator for treating a CVirtualPath as a TVirtualPathPtr
1.169 + inline CVirtualPath::operator const TVirtualPathPtr& () const
1.170 + {
1.171 + return iVirtualPathPtr;
1.172 + }
1.173 + }
1.174 +
1.175 +#endif