servicediscoveryandcontrol/pnp/test/upnp/upnpdescription/src/cpnpserviceparam.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 <upnp/cpnpserviceparam.h>
       
    17 #include "inetprottextutils.h"
       
    18 #include <upnpdescriptionschema.h>
       
    19 #include <e32cons.h>
       
    20 
       
    21 
       
    22 CUPnPArgument* CUPnPArgument::NewL()
       
    23     {
       
    24     CUPnPArgument* self = new (ELeave) CUPnPArgument();
       
    25     CleanupStack::PushL(self);
       
    26     self->ConstructL();
       
    27     CleanupStack::Pop();
       
    28     return self;
       
    29     }
       
    30 
       
    31 CUPnPArgument::CUPnPArgument()
       
    32     {
       
    33     }
       
    34 
       
    35 void CUPnPArgument::ConstructL()
       
    36     {
       
    37 	CUPnPProperty::ConstructL();
       
    38     }
       
    39 //Destructor
       
    40 CUPnPArgument::~CUPnPArgument()
       
    41     {
       
    42     }
       
    43 
       
    44  
       
    45 //Perform validation
       
    46 
       
    47 TBool CUPnPArgument::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) const
       
    48 	{
       
    49 	TBool result=EFalse;
       
    50 	if(	(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EName, aStringTable)).Length()!=0) &&
       
    51 			(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EArgumentDirection, aStringTable)).Length()!=0) &&	
       
    52 			(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::ERelatedStateVar, aStringTable)).Length()!=0))
       
    53 				result = ETrue;
       
    54 	
       
    55 	return result;
       
    56 	
       
    57 	}
       
    58 
       
    59 void CUPnPArgument::SetRetVal( TBool aValue)
       
    60 	{
       
    61 	iRetVal = aValue;
       
    62 	}
       
    63 
       
    64 TBool CUPnPArgument::RetVal()
       
    65 	{
       
    66 	return iRetVal;
       
    67 	}
       
    68 //--------------------------------------------------------------------
       
    69 
       
    70 EXPORT_C CUPnPValueRange* CUPnPValueRange::NewL()
       
    71 	{
       
    72 	CUPnPValueRange* self = new (ELeave) CUPnPValueRange();
       
    73 	CleanupStack::PushL(self);
       
    74 	self->ConstructL();
       
    75 	CleanupStack::Pop();
       
    76 	return self;
       
    77 	}
       
    78 
       
    79 CUPnPValueRange::CUPnPValueRange()
       
    80 	{
       
    81 	}
       
    82 
       
    83 void CUPnPValueRange::ConstructL()
       
    84 	{
       
    85 	CUPnPProperty::ConstructL();
       
    86 	}
       
    87  
       
    88 //Destructor
       
    89 
       
    90 EXPORT_C CUPnPValueRange::~CUPnPValueRange()
       
    91 	{
       
    92 	}
       
    93 
       
    94 
       
    95 //--------------------------------------------------------------------
       
    96 
       
    97 CUPnPArgValueList* CUPnPArgValueList::NewL()
       
    98 	{
       
    99 	CUPnPArgValueList* self = new (ELeave) CUPnPArgValueList();
       
   100 	CleanupStack::PushL(self);
       
   101 	self->ConstructL();
       
   102 	CleanupStack::Pop();
       
   103 	return self;
       
   104 	}
       
   105 
       
   106 CUPnPArgValueList::CUPnPArgValueList()
       
   107 {
       
   108 }
       
   109 
       
   110 void CUPnPArgValueList::ConstructL()
       
   111 	{
       
   112 	CUPnPProperty::ConstructL();
       
   113 	}
       
   114 
       
   115  
       
   116 //Destructor
       
   117 
       
   118 CUPnPArgValueList::~CUPnPArgValueList()
       
   119 {
       
   120 	for(TInt i =0;i< iAllowedValueList.Count();i++ )
       
   121     	{
       
   122     	iAllowedValueList[i].Close();
       
   123     	}
       
   124 	iAllowedValueList.Reset();
       
   125 }
       
   126 
       
   127 //------------------------------------------------------------------------
       
   128 
       
   129 CUPnPStateVariable* CUPnPStateVariable::NewL()
       
   130 	{
       
   131 	CUPnPStateVariable* self = new (ELeave) CUPnPStateVariable();
       
   132 	CleanupStack::PushL(self);
       
   133 	self->ConstructL();
       
   134 	CleanupStack::Pop();
       
   135 	return self;
       
   136 	}
       
   137 
       
   138 CUPnPStateVariable::CUPnPStateVariable()
       
   139 	{
       
   140 	}
       
   141 
       
   142 void CUPnPStateVariable::ConstructL()
       
   143 	{
       
   144 	CUPnPProperty::ConstructL();
       
   145 	}
       
   146 
       
   147 
       
   148 /** 
       
   149 Destructor
       
   150 */
       
   151 CUPnPStateVariable::~CUPnPStateVariable()
       
   152 	{
       
   153 	delete iAllowedValue;
       
   154 	}
       
   155 
       
   156 /** 
       
   157 validation
       
   158 */
       
   159 TBool CUPnPStateVariable::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) const
       
   160 	{
       
   161 	TBool result=ETrue;
       
   162 	// name cannot be of zero chars
       
   163 	
       
   164 	if(	(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EName, aStringTable)).Length()!=0) &&
       
   165 			(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EStateVariableDataType, aStringTable)).Length()!=0) &&
       
   166 			(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::ESendEvents, aStringTable)).Length()!=0)	)
       
   167 				result = ETrue;
       
   168 
       
   169 	
       
   170 	return result;
       
   171 
       
   172 	}
       
   173 
       
   174 //----------------------------------------------------------
       
   175 
       
   176 CUPnPAction* CUPnPAction::NewL()
       
   177 	{
       
   178 	CUPnPAction* self = new (ELeave) CUPnPAction();
       
   179 	CleanupStack::PushL(self);
       
   180 	self->ConstructL();
       
   181 	CleanupStack::Pop();
       
   182 	return self;
       
   183 	}
       
   184 
       
   185 CUPnPAction::CUPnPAction()
       
   186 	{
       
   187 	}
       
   188 
       
   189 void CUPnPAction::ConstructL()
       
   190 	{
       
   191 	CUPnPProperty::ConstructL();
       
   192 	}
       
   193 
       
   194 /** 
       
   195 Destructor
       
   196 */
       
   197 CUPnPAction::~CUPnPAction()
       
   198 	{
       
   199 	iArgumentList.ResetAndDestroy();
       
   200 	}
       
   201 
       
   202 /** 
       
   203 validation
       
   204 */
       
   205 TBool CUPnPAction::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) const
       
   206 	{
       
   207 	TBool result=ETrue;
       
   208 	// name cannot be of zero chars
       
   209 	if(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EName, aStringTable)).Length()==0)
       
   210 		result = EFalse;
       
   211 	
       
   212 	return result;
       
   213 
       
   214 	}
       
   215 
       
   216 //-------------------------------------------------------------
       
   217 
       
   218 EXPORT_C CUPnPServiceDescription* CUPnPServiceDescription::NewL()
       
   219 	{
       
   220 	CUPnPServiceDescription* self = new (ELeave) CUPnPServiceDescription();
       
   221 	CleanupStack::PushL(self);
       
   222 	self->ConstructL();
       
   223 	CleanupStack::Pop();
       
   224 	return self;
       
   225 	}
       
   226 
       
   227 CUPnPServiceDescription::CUPnPServiceDescription()
       
   228 	{
       
   229 	}
       
   230 
       
   231 void CUPnPServiceDescription::ConstructL()
       
   232 	{
       
   233 	CUPnPProperty::ConstructL();
       
   234 	}
       
   235 	
       
   236 
       
   237 /** 
       
   238 Destructor
       
   239 */
       
   240 EXPORT_C CUPnPServiceDescription::~CUPnPServiceDescription()
       
   241 	{
       
   242 	iActionList.ResetAndDestroy();
       
   243 	iServiceStateTable.ResetAndDestroy();
       
   244 	
       
   245 	}
       
   246 
       
   247 /** 
       
   248 validation
       
   249 */
       
   250 TBool CUPnPServiceDescription::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) const
       
   251 	{
       
   252 	
       
   253 	TBool result=ETrue;
       
   254 	if(iServiceStateTable.Count()<=0)
       
   255 		result = EFalse;
       
   256 	if(result)
       
   257 		{
       
   258 		for(TInt i =0;i< CountOfActionList();i++ )
       
   259 			{
       
   260 			result = iActionList[i]->Validate(aStringPool,aStringTable );
       
   261 			if(result==EFalse)
       
   262 				break;
       
   263 			}
       
   264 		}
       
   265 
       
   266 	if(result)
       
   267 		{
       
   268 		for(TInt i =0;i< CountOfServiceStateTable();i++ )
       
   269 			{
       
   270 			result = iServiceStateTable[i]->Validate(aStringPool, aStringTable );
       
   271 			if(result==EFalse) 
       
   272 				break;
       
   273 			}
       
   274 		}
       
   275 	return result;
       
   276 	}
       
   277