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 |
#ifndef __CAFVIRTUALPATHPTR_H__
|
sl@0
|
29 |
#define __CAFVIRTUALPATHPTR_H__
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <e32base.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
namespace ContentAccess
|
sl@0
|
34 |
{
|
sl@0
|
35 |
class CVirtualPath;
|
sl@0
|
36 |
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
The character used to separate the URI from the UniqueId
|
sl@0
|
39 |
when the two are concatenated into a single descriptor
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
_LIT(KCafVirtualPathSeparator, "|");
|
sl@0
|
42 |
|
sl@0
|
43 |
/** Identifies the location of a file and a particular content object inside it.
|
sl@0
|
44 |
|
sl@0
|
45 |
TVirtualPathPtr points to the two descriptors (the URI and UniqueId) used
|
sl@0
|
46 |
to initialise it. These descriptors must not be modified or destroyed while
|
sl@0
|
47 |
the TVirtualPathPtr object is in use.
|
sl@0
|
48 |
|
sl@0
|
49 |
The URI must be in the format specified in RFC2396, found at http://www.ietf.org/.
|
sl@0
|
50 |
|
sl@0
|
51 |
The UniqueId will be created by the Agent. Content is only ever
|
sl@0
|
52 |
accessed by one agent so it is the agents responsibility to ensure the
|
sl@0
|
53 |
UniqueId is truly unique within the file.
|
sl@0
|
54 |
|
sl@0
|
55 |
It is also possible to flatten a virtual path into a single descriptor. The
|
sl@0
|
56 |
ContentAccess::CVirtualPath class concatenates the URI, a separator, the KCafVirtualPathSeparator
|
sl@0
|
57 |
character, and the UniqueId to form a single URI. TVirtualPathPtr can be used to
|
sl@0
|
58 |
decode this virtual path into the URI and the content object UniqueId. The
|
sl@0
|
59 |
concatenated URI and UniqueId take the format:
|
sl@0
|
60 |
@code
|
sl@0
|
61 |
<URI><KCafVirtualPathSeparator><UniqueID>
|
sl@0
|
62 |
@endcode
|
sl@0
|
63 |
|
sl@0
|
64 |
An example of this format is shown below:
|
sl@0
|
65 |
@code
|
sl@0
|
66 |
// Create a CVirtualPath object to point to OBJECT1 inside file.dcf
|
sl@0
|
67 |
CVirtualPath *path = CVirtualPath::NewL(_L("C:\\directory\file.dcf"), _L("OBJECT1"));
|
sl@0
|
68 |
|
sl@0
|
69 |
// convert the URI and unique ID into a single URI.
|
sl@0
|
70 |
TVirtualPathPtr aPath = path->GetCombinedUriUniqueId();
|
sl@0
|
71 |
@endcode
|
sl@0
|
72 |
@note
|
sl@0
|
73 |
If a URI is supplied which contains multiple KCafVirtualPathSeparator characters
|
sl@0
|
74 |
the rightmost KCafVirtualPathSeparator character will be taken as marking the end
|
sl@0
|
75 |
of the URI and the start of the UniqueId. When multiple KCafVirtualPathSeparator
|
sl@0
|
76 |
characters are present, under certain situations this will result in an invalid
|
sl@0
|
77 |
URI and UniqueId being created for the virtual path and can lead to an undefined failure.
|
sl@0
|
78 |
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
class TVirtualPathPtr
|
sl@0
|
81 |
{
|
sl@0
|
82 |
public:
|
sl@0
|
83 |
/** Constructor used when the URI and UniqueId fields are separate
|
sl@0
|
84 |
@param aUri The location of the file
|
sl@0
|
85 |
@param aUniqueId The location of the content within the file
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
IMPORT_C TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId);
|
sl@0
|
88 |
|
sl@0
|
89 |
/** Constructor used for a concatenated URI and UniqueId.
|
sl@0
|
90 |
|
sl@0
|
91 |
Note that the descriptor here may be just a URI or it could be a URI
|
sl@0
|
92 |
concatenated with the file's UniqueId. If it is a concatenated URI and
|
sl@0
|
93 |
UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator character.
|
sl@0
|
94 |
For more information see above.
|
sl@0
|
95 |
@param aCombinedUriUniqueId The location of the content object
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
IMPORT_C TVirtualPathPtr(const TDesC& aCombinedUriUniqueId);
|
sl@0
|
98 |
|
sl@0
|
99 |
/** Copy constructor */
|
sl@0
|
100 |
IMPORT_C TVirtualPathPtr(const TVirtualPathPtr& aPtr);
|
sl@0
|
101 |
|
sl@0
|
102 |
/** The location of the file containing the content object
|
sl@0
|
103 |
@return The location of the file
|
sl@0
|
104 |
*/
|
sl@0
|
105 |
IMPORT_C const TDesC& URI() const;
|
sl@0
|
106 |
|
sl@0
|
107 |
/** UniqueId supplied by a CAF Agent to identify the object within the
|
sl@0
|
108 |
file.
|
sl@0
|
109 |
@return The location of the content within the file
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
IMPORT_C const TDesC& UniqueId() const;
|
sl@0
|
112 |
|
sl@0
|
113 |
/** Assignment operator */
|
sl@0
|
114 |
IMPORT_C TVirtualPathPtr& operator = (const TVirtualPathPtr& aVirtualPath);
|
sl@0
|
115 |
|
sl@0
|
116 |
/** Assignment operator converts a single descriptor to a TVirtualPathPtr.
|
sl@0
|
117 |
If the descriptor is just a URI, the TVirtualPathPtr will point to the KDefaultContentObject within that file.
|
sl@0
|
118 |
If it is a concatenated URI and UniqueId the URI and UniqueId will be seperated by the KCafVirtualPathSeparator.
|
sl@0
|
119 |
character as detailed in the description above.
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
IMPORT_C TVirtualPathPtr& operator = (const TDesC& aCombinedUriUniqueId);
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
private:
|
sl@0
|
125 |
// The Set() function is only used by CVirtualPath
|
sl@0
|
126 |
friend class CVirtualPath;
|
sl@0
|
127 |
|
sl@0
|
128 |
/** Used to redirect the TVirtualPathPtr to point at a different set of descriptors */
|
sl@0
|
129 |
void Set(const TDesC& aUri, const TDesC& aUniqueId);
|
sl@0
|
130 |
|
sl@0
|
131 |
private:
|
sl@0
|
132 |
TPtrC iUri;
|
sl@0
|
133 |
TPtrC iUniqueId;
|
sl@0
|
134 |
};
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
#endif
|