servicediscoveryandcontrol/pnp/test/upnp/Client/upnpplugin/inc/pnputils.h
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 #ifndef __PNPUTILS_H_
       
    17 #define __PNPUTILS_H_
       
    18 #include <e32base.h>
       
    19 #include <es_sock.h>
       
    20 #include <e32des8.h>
       
    21 #include <e32def.h>
       
    22 #include <uri8.h>
       
    23 #include <es_sock.h>
       
    24 #include <in_sock.h>
       
    25 
       
    26 /* Utilities class
       
    27  @internalComponent
       
    28  */
       
    29 class CUPnPUtils : public CBase
       
    30 	{
       
    31 
       
    32 public:
       
    33 	/*
       
    34 	 * Converts a RSubConParameterBundle to CSubConParameterBundle and vice-versa
       
    35 	 */ 
       
    36 	template <class T1 , class T2>
       
    37 	static TUint ReplicateToReverseBundle (const T1& aSrcBundle,T2& aTargetBundle);
       
    38 	
       
    39 	enum TClientDllPanic
       
    40 		{
       
    41 		EPnpServiceDiscoveryHandleNotOpen
       
    42 		};
       
    43 	enum TUriType
       
    44 		{
       
    45 		EService,
       
    46 		EDevice,
       
    47 		EAny
       
    48 		};
       
    49 	TUriType iUriType;
       
    50 	static void ResolveHostAddressL ( RHostResolver& aResolver,const TDesC8& aUri, TInetAddr& aSockAddr );
       
    51 	static TInt GenericUriValidity ( const TDesC8& aUri ,TUriType aType);
       
    52 
       
    53 private:
       
    54 	static const TUint KOffset=3;
       
    55 	static const TUint KIpv4MaxAddrSize = 20;
       
    56 	};
       
    57 	
       
    58 template <class T1 , class T2>
       
    59 TUint CUPnPUtils::ReplicateToReverseBundle (const T1& aSrcBundle,T2& aTargetBundle)
       
    60 
       
    61 	{
       
    62 	TUint length = aSrcBundle.Length();
       
    63 	RBuf8 serializedBuffer;
       
    64 	TUint err;
       
    65 	if((err=serializedBuffer.Create(length))!=KErrNone)
       
    66 		return err;
       
    67 	//Create a serailized version of the cscparambundle and store it in tempdata
       
    68 	if((err=aSrcBundle.Store(serializedBuffer))!=KErrNone)
       
    69 		return err;
       
    70 	//Deserialize tempData to rsubconparambundle	
       
    71 	if((err=aTargetBundle.Load(serializedBuffer))!=KErrNone)
       
    72 		return err;
       
    73 	serializedBuffer.Close();
       
    74 	return KErrNone;
       
    75 	}
       
    76 	
       
    77 
       
    78 
       
    79 #endif /*PNPUTILS_H_*/