sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 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 |
#include <caf/virtualpathptr.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <caf/caftypes.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
using namespace ContentAccess;
|
sl@0
|
25 |
|
sl@0
|
26 |
EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aCombinedUriUniqueId) : iUri(KNullDesC16()), iUniqueId(KNullDesC16())
|
sl@0
|
27 |
{
|
sl@0
|
28 |
TInt pos = KErrNotFound;
|
sl@0
|
29 |
|
sl@0
|
30 |
//Search the URI looking for rightmost the separator character in case it is URI concatenated with UniqueId
|
sl@0
|
31 |
pos = aCombinedUriUniqueId.LocateReverse(KCafVirtualPathSeparator()[0]);
|
sl@0
|
32 |
|
sl@0
|
33 |
// if the length and position are valid seperate the URI and UniqueId
|
sl@0
|
34 |
if(pos != KErrNotFound && aCombinedUriUniqueId.Length() - pos < KMaxCafUniqueId)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
// Found the separator character
|
sl@0
|
37 |
TInt uniqueIdLength = aCombinedUriUniqueId.Length() - pos - 1;
|
sl@0
|
38 |
|
sl@0
|
39 |
// Set the URI and UniqueId to point the corresponding parts of the supplied descriptor
|
sl@0
|
40 |
Set(aCombinedUriUniqueId.Left(pos), aCombinedUriUniqueId.Right(uniqueIdLength));
|
sl@0
|
41 |
}
|
sl@0
|
42 |
else
|
sl@0
|
43 |
{
|
sl@0
|
44 |
// If its just a URI, make sure we point to the default content object
|
sl@0
|
45 |
Set(aCombinedUriUniqueId, KDefaultContentObject());
|
sl@0
|
46 |
}
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId) : iUri(aUri), iUniqueId(aUniqueId)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TVirtualPathPtr& aPtr) : iUri(aPtr.URI()), iUniqueId(aPtr.UniqueId())
|
sl@0
|
54 |
{
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
EXPORT_C const TDesC& TVirtualPathPtr::URI() const
|
sl@0
|
59 |
{
|
sl@0
|
60 |
return iUri;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
EXPORT_C const TDesC& TVirtualPathPtr::UniqueId() const
|
sl@0
|
64 |
{
|
sl@0
|
65 |
return iUniqueId;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
void TVirtualPathPtr::Set(const TDesC& aUri, const TDesC& aUniqueId)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
iUri.Set(aUri);
|
sl@0
|
71 |
iUniqueId.Set(aUniqueId);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
Set(aVirtualPath.URI(), aVirtualPath.UniqueId());
|
sl@0
|
77 |
return *this;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TDesC& aCombinedUriUniqueId)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
TVirtualPathPtr temp(aCombinedUriUniqueId);
|
sl@0
|
83 |
Set(temp.URI(), temp.UniqueId());
|
sl@0
|
84 |
return *this;
|
sl@0
|
85 |
}
|