applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspUnknownCapabilities.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "CWspUnknownCapabilities.h"
       
    17 
       
    18 #include "CUnknownCapability.h"
       
    19 
       
    20 CWspUnknownCapabilities* CWspUnknownCapabilities::NewL()
       
    21 	{
       
    22 	return new (ELeave) CWspUnknownCapabilities();
       
    23 	}
       
    24 
       
    25 CWspUnknownCapabilities::~CWspUnknownCapabilities()
       
    26 	{
       
    27 	iUnknownCapabilities.ResetAndDestroy();
       
    28 	}
       
    29 
       
    30 CWspUnknownCapabilities::CWspUnknownCapabilities()
       
    31 : CBase(), iIndex(KErrNotFound)
       
    32 	{
       
    33 	}
       
    34 
       
    35 TInt CWspUnknownCapabilities::Start() const
       
    36 	{
       
    37 	// Have any unknown capabilities been added?
       
    38 	if( iUnknownCapabilities.Count() != 0 )
       
    39 		{
       
    40 		// There are unknown capabilities in array - set index to start
       
    41 		iIndex = 0;
       
    42 		}
       
    43 	// iIndex now is the error (return) value
       
    44 	return iIndex;
       
    45 	}
       
    46 
       
    47 TInt CWspUnknownCapabilities::GetNext(TPtrC8& aIdentifier, TPtrC8& aValue) const
       
    48 	{
       
    49 	// Check to see if array can be accessed
       
    50 	TInt error = KErrNone;
       
    51 	if( iIndex == KErrNotFound )
       
    52 		{
       
    53 		// Array is empty or have indexed to end of array
       
    54 		error = KErrNotFound;
       
    55 		}
       
    56 	else
       
    57 		{
       
    58 		// Have still got an unknown capability to access - get values
       
    59 		const CUnknownCapability& capability = *iUnknownCapabilities[iIndex];
       
    60 		aIdentifier.Set(capability.GetIdentifier());
       
    61 		aValue.Set(capability.GetValue());
       
    62 
       
    63 		// Increment index and check to see reached the end of the array
       
    64 		++iIndex;
       
    65 		if( iIndex == iUnknownCapabilities.Count() )
       
    66 			{
       
    67 			iIndex = KErrNotFound;
       
    68 			}
       
    69 		}
       
    70 	return error;
       
    71 	}
       
    72 
       
    73 void CWspUnknownCapabilities::Reset()
       
    74 	{
       
    75 	// Reset the array and index
       
    76 	iUnknownCapabilities.ResetAndDestroy();
       
    77 	iIndex = KErrNotFound;
       
    78 	}
       
    79 
       
    80 void CWspUnknownCapabilities::AddUnknownCapabilityL(const TDesC8& aIdentifier, const TDesC8& aValue)
       
    81 	{
       
    82 	// Create unknown capability object
       
    83 	CUnknownCapability* capability = CUnknownCapability::NewL(aIdentifier, aValue);
       
    84 	CleanupStack::PushL(capability);
       
    85 
       
    86 	// Append to array
       
    87 	User::LeaveIfError(iUnknownCapabilities.Append(capability));
       
    88 	CleanupStack::Pop(capability);
       
    89 	}
       
    90