servicediscoveryandcontrol/pnp/test/upnp/upnpdescription/src/cpnpdeviceparam.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 <e32cons.h>
       
    17 
       
    18 #include "cpnpdeviceparam.h"
       
    19 #include <upnpdescriptionschema.h>
       
    20 #include "inetprottextutils.h"
       
    21 
       
    22 
       
    23 EXPORT_C CUPnPIconInfo* CUPnPIconInfo::NewL()
       
    24     {
       
    25     CUPnPIconInfo* self = new (ELeave) CUPnPIconInfo();
       
    26     CleanupStack::PushL(self);
       
    27     self->ConstructL();
       
    28     CleanupStack::Pop();
       
    29     return self;
       
    30     }
       
    31 
       
    32 CUPnPIconInfo::CUPnPIconInfo()
       
    33     {
       
    34 
       
    35     }
       
    36 
       
    37 void CUPnPIconInfo::ConstructL()
       
    38     {
       
    39     CUPnPProperty::ConstructL();
       
    40     }
       
    41 
       
    42 EXPORT_C CUPnPIconInfo::~CUPnPIconInfo()
       
    43     {
       
    44     }
       
    45 
       
    46 // Validation for icon
       
    47 TBool CUPnPIconInfo::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) 
       
    48 	{
       
    49 	TBool result=EFalse;
       
    50 
       
    51 	if(	(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EWidth, aStringTable)).Length()!=0) &&
       
    52 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EMimeType, aStringTable)).Length()!=0) &&
       
    53 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EHeight, aStringTable)).Length()!=0) &&
       
    54 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EDepth, aStringTable)).Length()!=0) &&
       
    55 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EUrl, aStringTable)).Length()!=0) )
       
    56 		{
       
    57 		result = ETrue;
       
    58 		}
       
    59 		
       
    60 	return result;
       
    61 	}
       
    62 
       
    63 //-------------------------------------------------------------------------
       
    64 
       
    65 EXPORT_C CUPnPServiceInfo* CUPnPServiceInfo::NewL()
       
    66 	{
       
    67 	CUPnPServiceInfo* self = new (ELeave) CUPnPServiceInfo();
       
    68 	CleanupStack::PushL(self);
       
    69 	self->ConstructL();
       
    70 	CleanupStack::Pop();
       
    71 	return self;
       
    72 	}
       
    73 
       
    74 CUPnPServiceInfo::CUPnPServiceInfo()
       
    75 	{
       
    76 	
       
    77 	}
       
    78 
       
    79 void CUPnPServiceInfo::ConstructL()
       
    80 	{
       
    81 	CUPnPProperty::ConstructL();
       
    82 	}
       
    83 
       
    84 
       
    85 EXPORT_C CUPnPServiceInfo::~CUPnPServiceInfo()
       
    86 	{
       
    87 	}
       
    88 
       
    89 // Validation for service
       
    90 
       
    91 TBool CUPnPServiceInfo::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) 
       
    92 	{
       
    93 	TBool result=EFalse;
       
    94 	if(	(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EServiceType, aStringTable)).Length()!=0) &&
       
    95 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EServiceId, aStringTable)).Length()!=0) &&
       
    96 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EScpdUrl, aStringTable)).Length()!=0) &&
       
    97 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EContorlUrl, aStringTable)).Length()!=0) )
       
    98 		{
       
    99 		result = ETrue;
       
   100 		}
       
   101 		
       
   102 	return result;
       
   103 
       
   104 	}
       
   105 
       
   106 // ------------------------------------------------------------------
       
   107 EXPORT_C CUPnPDevice* CUPnPDevice::NewL()
       
   108 	{
       
   109 	CUPnPDevice* self = new (ELeave) CUPnPDevice();
       
   110 	CleanupStack::PushL(self);
       
   111 	self->ConstructL();
       
   112 	CleanupStack::Pop();
       
   113 	return self;
       
   114 	}
       
   115 
       
   116 CUPnPDevice::CUPnPDevice()
       
   117 	{
       
   118 	}
       
   119 
       
   120 void CUPnPDevice::ConstructL()
       
   121 	{
       
   122 	CUPnPProperty::ConstructL();
       
   123 	}
       
   124 
       
   125 EXPORT_C CUPnPDevice::~CUPnPDevice()
       
   126 	{
       
   127 	iEmbeddedDeviceInfo.ResetAndDestroy();
       
   128 	iIconInfo.ResetAndDestroy();
       
   129 	iServiceInfo.ResetAndDestroy();
       
   130 	}
       
   131 
       
   132 // Validation for CUPnPDevice
       
   133 TBool CUPnPDevice::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) 
       
   134 	{
       
   135 	TBool result=ETrue;
       
   136 	TInt i;
       
   137 
       
   138 	if(	(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EDeviceType, aStringTable)).Length()!=0) &&
       
   139 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EFriendlyName, aStringTable)).Length()!=0) &&
       
   140 		(Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EUdn, aStringTable)).Length()!=0)  )
       
   141 		{
       
   142 		result = ETrue;
       
   143 		}
       
   144 	else
       
   145 		result = EFalse;
       
   146 	
       
   147 	// Validate manufacturer attribute
       
   148 	if (result & (Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EManufacturer, aStringTable)).Length()!=0) )
       
   149 		result = ETrue;
       
   150 	else
       
   151 		result = EFalse;
       
   152 	
       
   153 	// Validate the model attribute
       
   154 	if (result & (Property(aStringPool.String(UPNPDESCRIPTIONXMLTAGS::EModelName, aStringTable)).Length()!=0) )
       
   155 		result = ETrue;
       
   156 	else
       
   157 		result = EFalse;
       
   158 	
       
   159 	if(result)
       
   160 		{
       
   161 		for(i=0;i<CountOfEmbeddedDeviceInfoTable();i++)
       
   162 			{
       
   163 			result = iEmbeddedDeviceInfo[i]->Validate(aStringPool,aStringTable);
       
   164 			if(EFalse==result)
       
   165 				break;
       
   166 			}
       
   167 		}
       
   168 
       
   169 	if(result)
       
   170 		{
       
   171 		for(i=0;i<CountOfServiceInfoTable();i++)
       
   172 			{
       
   173 			result = iServiceInfo[i]->Validate(aStringPool,aStringTable);
       
   174 			if(EFalse==result)
       
   175 				break;
       
   176 			}
       
   177 		
       
   178 		}
       
   179 	if(result)
       
   180 		{
       
   181 		for(i=0;i<CountOfIconInfoTable();i++)
       
   182 			{
       
   183 			result = iIconInfo[i]->Validate(aStringPool,aStringTable);
       
   184 			if(EFalse==result)
       
   185 				break;
       
   186 			}
       
   187 		}
       
   188 	return result;
       
   189 	}
       
   190 
       
   191 //-------------------------------------------------------------------
       
   192 EXPORT_C CUPnPDeviceDescription* CUPnPDeviceDescription::NewL()
       
   193 	{
       
   194 	CUPnPDeviceDescription* self = new (ELeave) CUPnPDeviceDescription();
       
   195 	CleanupStack::PushL(self);
       
   196 	self->ConstructL();
       
   197 	CleanupStack::Pop();
       
   198 	return self;
       
   199 	}
       
   200 
       
   201 CUPnPDeviceDescription::CUPnPDeviceDescription()
       
   202 	{
       
   203 	}
       
   204 
       
   205 void CUPnPDeviceDescription::ConstructL()
       
   206 	{
       
   207 	CUPnPProperty::ConstructL();
       
   208 	}
       
   209 
       
   210 EXPORT_C CUPnPDeviceDescription::~CUPnPDeviceDescription()
       
   211 	{
       
   212 	if(iDeviceObj!=NULL)
       
   213 		delete iDeviceObj;
       
   214 	}
       
   215 
       
   216 // Validation for device description. It delegates the validation to the root device
       
   217 TBool CUPnPDeviceDescription::Validate(const RStringPool& aStringPool, const TStringTable& aStringTable ) const
       
   218 	{
       
   219 	
       
   220 	if(iDeviceObj!=NULL)
       
   221 		return iDeviceObj->Validate(aStringPool,aStringTable);
       
   222 	else
       
   223 		return EFalse;	
       
   224 	
       
   225 	}