os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/Virtualpathptr.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/Virtualpathptr.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 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 +#include <caf/virtualpathptr.h>
    1.24 +
    1.25 +#include <caf/caftypes.h>
    1.26 +
    1.27 +using namespace ContentAccess;
    1.28 +
    1.29 +EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aCombinedUriUniqueId) : iUri(KNullDesC16()), iUniqueId(KNullDesC16())
    1.30 +	{
    1.31 +	TInt pos = KErrNotFound;
    1.32 +
    1.33 +	//Search the URI looking for rightmost the separator character in case it is URI concatenated with UniqueId
    1.34 +	pos = aCombinedUriUniqueId.LocateReverse(KCafVirtualPathSeparator()[0]);
    1.35 +	
    1.36 +	// if the length and position are valid seperate the URI and UniqueId
    1.37 +	if(pos != KErrNotFound && aCombinedUriUniqueId.Length() - pos < KMaxCafUniqueId)
    1.38 +		{
    1.39 +		// Found the separator character
    1.40 +		TInt uniqueIdLength = aCombinedUriUniqueId.Length() - pos - 1;
    1.41 +
    1.42 +		// Set the URI and UniqueId to point the corresponding parts of the supplied descriptor
    1.43 +		Set(aCombinedUriUniqueId.Left(pos), aCombinedUriUniqueId.Right(uniqueIdLength));
    1.44 +		}
    1.45 +	else
    1.46 +		{
    1.47 +		// If its just a URI, make sure we point to the default content object
    1.48 +		Set(aCombinedUriUniqueId, KDefaultContentObject());
    1.49 +		}
    1.50 +	}	
    1.51 +
    1.52 +EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId) : iUri(aUri), iUniqueId(aUniqueId)
    1.53 +	{
    1.54 +	}	
    1.55 +
    1.56 +EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TVirtualPathPtr& aPtr) : iUri(aPtr.URI()), iUniqueId(aPtr.UniqueId())
    1.57 +	{
    1.58 +	}	
    1.59 +
    1.60 +
    1.61 +EXPORT_C const TDesC& TVirtualPathPtr::URI() const
    1.62 +	{
    1.63 +	return iUri;
    1.64 +	}
    1.65 +
    1.66 +EXPORT_C const TDesC& TVirtualPathPtr::UniqueId() const
    1.67 +	{
    1.68 +	return iUniqueId;
    1.69 +	}
    1.70 +
    1.71 +void TVirtualPathPtr::Set(const TDesC& aUri, const TDesC& aUniqueId)
    1.72 +	{
    1.73 +	iUri.Set(aUri);
    1.74 +	iUniqueId.Set(aUniqueId);
    1.75 +	}
    1.76 +
    1.77 +EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TVirtualPathPtr& aVirtualPath)
    1.78 +	{
    1.79 +	Set(aVirtualPath.URI(), aVirtualPath.UniqueId());
    1.80 +	return *this;
    1.81 +	}
    1.82 +
    1.83 +EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TDesC& aCombinedUriUniqueId)
    1.84 +	{
    1.85 +	TVirtualPathPtr temp(aCombinedUriUniqueId);
    1.86 +	Set(temp.URI(), temp.UniqueId());
    1.87 +	return *this;
    1.88 +	}