contentmgmt/contentaccessfwfordrm/source/cafutils/Virtualpathptr.cpp
author Santosh Patil <santosh.v.patil@nokia.com>
Wed, 08 Jul 2009 11:25:26 +0100
changeset 0 2c201484c85f
child 8 35751d3474b7
permissions -rw-r--r--
Move the Security package to EPL, and add the implementations of the cryptographic algorithms

/*
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/



#include "virtualpathptr.h"

#include "caftypes.h"

using namespace ContentAccess;

EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aCombinedUriUniqueId) : iUri(KNullDesC16()), iUniqueId(KNullDesC16())
	{
	TInt pos = KErrNotFound;

	//Search the URI looking for rightmost the separator character in case it is URI concatenated with UniqueId
	pos = aCombinedUriUniqueId.LocateReverse(KCafVirtualPathSeparator()[0]);
	
	// if the length and position are valid seperate the URI and UniqueId
	if(pos != KErrNotFound && aCombinedUriUniqueId.Length() - pos < KMaxCafUniqueId)
		{
		// Found the separator character
		TInt uniqueIdLength = aCombinedUriUniqueId.Length() - pos - 1;

		// Set the URI and UniqueId to point the corresponding parts of the supplied descriptor
		Set(aCombinedUriUniqueId.Left(pos), aCombinedUriUniqueId.Right(uniqueIdLength));
		}
	else
		{
		// If its just a URI, make sure we point to the default content object
		Set(aCombinedUriUniqueId, KDefaultContentObject());
		}
	}	

EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId) : iUri(aUri), iUniqueId(aUniqueId)
	{
	}	

EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TVirtualPathPtr& aPtr) : iUri(aPtr.URI()), iUniqueId(aPtr.UniqueId())
	{
	}	


EXPORT_C const TDesC& TVirtualPathPtr::URI() const
	{
	return iUri;
	}

EXPORT_C const TDesC& TVirtualPathPtr::UniqueId() const
	{
	return iUniqueId;
	}

void TVirtualPathPtr::Set(const TDesC& aUri, const TDesC& aUniqueId)
	{
	iUri.Set(aUri);
	iUniqueId.Set(aUniqueId);
	}

EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TVirtualPathPtr& aVirtualPath)
	{
	Set(aVirtualPath.URI(), aVirtualPath.UniqueId());
	return *this;
	}

EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TDesC& aCombinedUriUniqueId)
	{
	TVirtualPathPtr temp(aCombinedUriUniqueId);
	Set(temp.URI(), temp.UniqueId());
	return *this;
	}