applayerpluginsandutils/httpprotocolplugins/WspProtocolHandler/CWspCapabilityInfo.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 "CWspCapabilityInfo.h"
       
    17 
       
    18 #include <wsp/WspTypes.h>
       
    19 #include "CWspAliasAddresses.h"
       
    20 #include "CWspExtendedMethods.h"
       
    21 #include "CWspHeaderCodePages.h"
       
    22 #include "CWspUnknownCapabilities.h"
       
    23 
       
    24 const TUint32 KWspMethodMORDefault			= 1;
       
    25 const TUint32 KWspPushMORDefault			= 1;
       
    26 const TUint32 KWspClientSDUSizeDefault		= 1400;
       
    27 const TUint32 KWspServerSDUSizeDefault		= 1400;
       
    28 const TUint32 KWspClientMessageSizeDefault	= 1400;
       
    29 const TUint32 KWspServerMessageSizeDefault	= 1400;
       
    30 const TUint8  KWspProtocolOptionsDefault	= 0x00;
       
    31 
       
    32 
       
    33 CWspCapabilityInfo* CWspCapabilityInfo::NewL()
       
    34 	{
       
    35 	CWspCapabilityInfo* self = new (ELeave) CWspCapabilityInfo();
       
    36 	CleanupStack::PushL(self);
       
    37 	self->ConstructL();
       
    38 	CleanupStack::Pop(self);
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 CWspCapabilityInfo::~CWspCapabilityInfo()
       
    43 	{
       
    44 	delete iAliasAddresses;
       
    45 	delete iExtendedMethods;
       
    46 	delete iHeaderCodePages;
       
    47 	delete iUnknownCapabilities;
       
    48 	}
       
    49 
       
    50 CWspCapabilityInfo::CWspCapabilityInfo()
       
    51 : CBase(), iMethodMOR(KWspMethodMORDefault),
       
    52 		   iPushMOR(KWspPushMORDefault),
       
    53 		   iProtocolOptions(KWspProtocolOptionsDefault),
       
    54 		   iClientSDUSize(KWspClientSDUSizeDefault),
       
    55 		   iServerSDUSize(KWspServerSDUSizeDefault),
       
    56 		   iClientMessageSize(KWspClientMessageSizeDefault),
       
    57 		   iServerMessageSize(KWspServerMessageSizeDefault)
       
    58 	{
       
    59 	}
       
    60 
       
    61 void CWspCapabilityInfo::ConstructL()
       
    62 	{
       
    63 	iAliasAddresses = CWspAliasAddresses::NewL();
       
    64 	iExtendedMethods = CWspExtendedMethods::NewL();
       
    65 	iHeaderCodePages = CWspHeaderCodePages::NewL();
       
    66 	iUnknownCapabilities = CWspUnknownCapabilities::NewL();
       
    67 	}
       
    68 
       
    69 /*
       
    70  * Methods from MWspCapabilityViewer
       
    71  */
       
    72 
       
    73 const MWspAliasAddresses& CWspCapabilityInfo::GetAliasAddresses() const
       
    74 	{
       
    75 	return *iAliasAddresses;
       
    76 	}
       
    77 
       
    78 const MWspExtendedMethods& CWspCapabilityInfo::GetExtendedMethods() const
       
    79 	{
       
    80 	return *iExtendedMethods;
       
    81 	}
       
    82 
       
    83 const MWspHeaderCodePages& CWspCapabilityInfo::GetHeaderCodePages() const
       
    84 	{
       
    85 	return *iHeaderCodePages;
       
    86 	}
       
    87 
       
    88 TUint8 CWspCapabilityInfo::GetMethodMOR() const
       
    89 	{
       
    90 	return iMethodMOR;
       
    91 	}
       
    92 
       
    93 TUint8 CWspCapabilityInfo::GetPushMOR() const
       
    94 	{
       
    95 	return iPushMOR;
       
    96 	}
       
    97 
       
    98 TUint8 CWspCapabilityInfo::GetProtocolOptions() const
       
    99 	{
       
   100 	return iProtocolOptions;
       
   101 	}
       
   102 
       
   103 TUint32 CWspCapabilityInfo::GetClientSDUSize() const
       
   104 	{
       
   105 	return iClientSDUSize;
       
   106 	}
       
   107 
       
   108 TUint32 CWspCapabilityInfo::GetServerSDUSize() const
       
   109 	{
       
   110 	return iServerSDUSize;
       
   111 	}
       
   112 
       
   113 TUint32 CWspCapabilityInfo::GetClientMessageSize() const
       
   114 	{
       
   115 	return iClientMessageSize;
       
   116 	}
       
   117 
       
   118 TUint32 CWspCapabilityInfo::GetServerMessageSize() const
       
   119 	{
       
   120 	return iServerMessageSize;
       
   121 	}
       
   122 
       
   123 const MWspUnknownCapabilities& CWspCapabilityInfo::GetUnknownCapabilities() const
       
   124 	{
       
   125 	return *iUnknownCapabilities;
       
   126 	}
       
   127 
       
   128 /*
       
   129  * Methods from MWspCapabilitiesSetter
       
   130  */
       
   131 
       
   132 void CWspCapabilityInfo::Reset(TWspCapability aCapability)
       
   133 	{
       
   134 	switch(aCapability)
       
   135 		{
       
   136 	case EAliasAddresses:
       
   137 		{
       
   138 		iAliasAddresses->Reset();
       
   139 		} break;
       
   140 	case EExtendedMethods:
       
   141 		{
       
   142 		iExtendedMethods->Reset();
       
   143 		} break;
       
   144 	case EHeaderCodePages:
       
   145 		{
       
   146 		iHeaderCodePages->Reset();
       
   147 		} break;
       
   148 	case EMethodMOR:
       
   149 		{
       
   150 		iMethodMOR = KWspMethodMORDefault;
       
   151 		} break;
       
   152 	case EPushMOR:
       
   153 		{
       
   154 		iPushMOR = KWspPushMORDefault;
       
   155 		} break;
       
   156 	case EProtocolOptions:
       
   157 		{
       
   158 		iProtocolOptions = KWspProtocolOptionsDefault;
       
   159 		} break;
       
   160 	case EClientSDUSize:
       
   161 		{
       
   162 		iClientSDUSize = KWspClientSDUSizeDefault;
       
   163 		} break;
       
   164 	case EServerSDUSize:
       
   165 		{
       
   166 		iServerSDUSize = KWspServerSDUSizeDefault;
       
   167 		} break;
       
   168 	case EClientMessageSize:
       
   169 		{
       
   170 		iClientMessageSize = KWspClientMessageSizeDefault;
       
   171 		} break;
       
   172 	case EServerMessageSize:
       
   173 		{
       
   174 		iServerMessageSize = KWspServerMessageSizeDefault;
       
   175 		} break;
       
   176 	case EUnknownCapabilities:
       
   177 		{
       
   178 		iUnknownCapabilities->Reset();
       
   179 		} break;
       
   180 	case EAllCapabilities:
       
   181 		{
       
   182 		// Recurse into this function using a different value of TWspCapability
       
   183 		for(TInt capability = 0; capability<EAllCapabilities; ++capability)
       
   184 			{
       
   185 			// Reset the given capability
       
   186 			Reset(STATIC_CAST(TWspCapability, capability));
       
   187 			}
       
   188 		} break;
       
   189 	default:
       
   190 		// Ignore any unknown capability
       
   191 		break;
       
   192 		}
       
   193 	}
       
   194 
       
   195 void CWspCapabilityInfo::AddAliasAddressL(TWspBearer aBearer, TUint16 aPort, const TDesC8& aAddress)
       
   196 	{
       
   197 	iAliasAddresses->AddAddressL(aBearer, aPort, aAddress);
       
   198 	}
       
   199 
       
   200 void CWspCapabilityInfo::AddExtendedMethodL(TUint8 aPDUType, const TDesC8& aMethodName)
       
   201 	{
       
   202 	iExtendedMethods->AddExtendedMethodL(aPDUType, aMethodName);
       
   203 	}
       
   204 
       
   205 void CWspCapabilityInfo::AddHeaderCodePageL(TUint8 aPageCode, const TDesC8& aPageName)
       
   206 	{
       
   207 	iHeaderCodePages->AddHeaderCodePageL(aPageCode, aPageName);
       
   208 	}
       
   209 
       
   210 void CWspCapabilityInfo::SetMethodMOR(TUint8 aMOR)
       
   211 	{
       
   212 	iMethodMOR = aMOR;
       
   213 	}
       
   214 
       
   215 void CWspCapabilityInfo::SetPushMOR(TUint8 aMOR)
       
   216 	{
       
   217 	iPushMOR = aMOR;
       
   218 	}
       
   219 
       
   220 void CWspCapabilityInfo::SetProtocolOptions(TUint8 aProtocolOptions)
       
   221 	{
       
   222 	iProtocolOptions = aProtocolOptions;
       
   223 	}
       
   224 
       
   225 void CWspCapabilityInfo::SetClientSDUSize(TUint32 aSize)
       
   226 	{
       
   227 	iClientSDUSize = aSize;
       
   228 	}
       
   229 
       
   230 void CWspCapabilityInfo::SetServerSDUSize(TUint32 aSize)
       
   231 	{
       
   232 	iServerSDUSize = aSize;
       
   233 	}
       
   234 
       
   235 void CWspCapabilityInfo::SetClientMessageSize(TUint32 aSize)
       
   236 	{
       
   237 	iClientMessageSize = aSize;
       
   238 	}
       
   239 
       
   240 void CWspCapabilityInfo::SetServerMessageSize(TUint32 aSize)
       
   241 	{
       
   242 	iServerMessageSize = aSize;
       
   243 	}
       
   244 
       
   245 void CWspCapabilityInfo::AddUnknownCapabilityL(const TDesC8& aIdentifier, const TDesC8& aValue)
       
   246 	{
       
   247 	iUnknownCapabilities->AddUnknownCapabilityL(aIdentifier, aValue);
       
   248 	}