os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/Virtualpathptr.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 
    20 #include <caf/virtualpathptr.h>
    21 
    22 #include <caf/caftypes.h>
    23 
    24 using namespace ContentAccess;
    25 
    26 EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aCombinedUriUniqueId) : iUri(KNullDesC16()), iUniqueId(KNullDesC16())
    27 	{
    28 	TInt pos = KErrNotFound;
    29 
    30 	//Search the URI looking for rightmost the separator character in case it is URI concatenated with UniqueId
    31 	pos = aCombinedUriUniqueId.LocateReverse(KCafVirtualPathSeparator()[0]);
    32 	
    33 	// if the length and position are valid seperate the URI and UniqueId
    34 	if(pos != KErrNotFound && aCombinedUriUniqueId.Length() - pos < KMaxCafUniqueId)
    35 		{
    36 		// Found the separator character
    37 		TInt uniqueIdLength = aCombinedUriUniqueId.Length() - pos - 1;
    38 
    39 		// Set the URI and UniqueId to point the corresponding parts of the supplied descriptor
    40 		Set(aCombinedUriUniqueId.Left(pos), aCombinedUriUniqueId.Right(uniqueIdLength));
    41 		}
    42 	else
    43 		{
    44 		// If its just a URI, make sure we point to the default content object
    45 		Set(aCombinedUriUniqueId, KDefaultContentObject());
    46 		}
    47 	}	
    48 
    49 EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TDesC& aUri, const TDesC& aUniqueId) : iUri(aUri), iUniqueId(aUniqueId)
    50 	{
    51 	}	
    52 
    53 EXPORT_C TVirtualPathPtr::TVirtualPathPtr(const TVirtualPathPtr& aPtr) : iUri(aPtr.URI()), iUniqueId(aPtr.UniqueId())
    54 	{
    55 	}	
    56 
    57 
    58 EXPORT_C const TDesC& TVirtualPathPtr::URI() const
    59 	{
    60 	return iUri;
    61 	}
    62 
    63 EXPORT_C const TDesC& TVirtualPathPtr::UniqueId() const
    64 	{
    65 	return iUniqueId;
    66 	}
    67 
    68 void TVirtualPathPtr::Set(const TDesC& aUri, const TDesC& aUniqueId)
    69 	{
    70 	iUri.Set(aUri);
    71 	iUniqueId.Set(aUniqueId);
    72 	}
    73 
    74 EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TVirtualPathPtr& aVirtualPath)
    75 	{
    76 	Set(aVirtualPath.URI(), aVirtualPath.UniqueId());
    77 	return *this;
    78 	}
    79 
    80 EXPORT_C TVirtualPathPtr& TVirtualPathPtr::operator = (const TDesC& aCombinedUriUniqueId)
    81 	{
    82 	TVirtualPathPtr temp(aCombinedUriUniqueId);
    83 	Set(temp.URI(), temp.UniqueId());
    84 	return *this;
    85 	}