applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspExtendedMethods.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 "CWspExtendedMethods.h"
       
    17 
       
    18 #include "CExtendedMethod.h"
       
    19 
       
    20 CWspExtendedMethods* CWspExtendedMethods::NewL()
       
    21 	{
       
    22 	return new (ELeave) CWspExtendedMethods();
       
    23 	}
       
    24 
       
    25 CWspExtendedMethods::~CWspExtendedMethods()
       
    26 	{
       
    27 	iMethods.ResetAndDestroy();
       
    28 	}
       
    29 
       
    30 CWspExtendedMethods::CWspExtendedMethods()
       
    31 : CBase(), iIndex(KErrNotFound)
       
    32 	{
       
    33 	}
       
    34 
       
    35 TInt CWspExtendedMethods::Start() const
       
    36 	{
       
    37 	// Have any methods been added?
       
    38 	if( iMethods.Count() != 0 )
       
    39 		{
       
    40 		// There are methods 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 CWspExtendedMethods::GetNext(TUint8& aPDUType, TPtrC8& aMethodName) 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 a method to access - get values
       
    59 		const CExtendedMethod& method = *iMethods[iIndex];
       
    60 		aPDUType = method.GetPDUType();
       
    61 		aMethodName.Set(method.GetMethodName());
       
    62 
       
    63 		// Increment index and check to see reached the end of the array
       
    64 		++iIndex;
       
    65 		if( iIndex == iMethods.Count() )
       
    66 			{
       
    67 			iIndex = KErrNotFound;
       
    68 			}
       
    69 		}
       
    70 	return error;
       
    71 	}
       
    72 
       
    73 void CWspExtendedMethods::Reset()
       
    74 	{
       
    75 	// Reset the array and index
       
    76 	iMethods.ResetAndDestroy();
       
    77 	iIndex = KErrNotFound;
       
    78 	}
       
    79 
       
    80 void CWspExtendedMethods::AddExtendedMethodL(TUint8 aPDUType, const TDesC8& aMethodName)
       
    81 	{
       
    82 	// Create method object
       
    83 	CExtendedMethod* method = CExtendedMethod::NewL(aPDUType, aMethodName);
       
    84 	CleanupStack::PushL(method);
       
    85 
       
    86 	// Append to array
       
    87 	User::LeaveIfError(iMethods.Append(method));
       
    88 	CleanupStack::Pop(method);
       
    89 	}
       
    90