servicediscoveryandcontrol/pnp/test/upnp/codec/src/cupnpcodec.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 // upnpcodecmain.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <upnp/tupnptable.h>
       
    19 
       
    20 #include "cupnpcodec.h"
       
    21 #include "cupnpheaderreader.h"
       
    22 #include "cupnpheaderwriter.h"
       
    23 
       
    24 
       
    25 CUPnPCodec* CUPnPCodec::NewL(TAny* aStringPool)
       
    26 	{
       
    27 	RStringPool* strPool = static_cast<RStringPool*>(aStringPool);
       
    28 	CUPnPCodec* me = new (ELeave) CUPnPCodec(*strPool);
       
    29 	CleanupStack::PushL(me);
       
    30 	me->ConstructL();
       
    31 	CleanupStack::Pop(me);
       
    32 	return me;
       
    33 	}
       
    34 
       
    35 CUPnPCodec::~CUPnPCodec()
       
    36 	{
       
    37 	// do nothing.
       
    38 	}
       
    39 
       
    40 TBool CUPnPCodec::CanEncode(RStringF aHeaderField) const
       
    41 	{
       
    42 	TBool canEncode = EFalse;
       
    43 
       
    44 	RStringF st = iStringPool.StringF(UPnP::EST, TUPnPTable::Table());
       
    45 	RStringF usn = iStringPool.StringF(UPnP::EUSN, TUPnPTable::Table());
       
    46 	RStringF timeout = iStringPool.StringF(UPnP::ETimeout, TUPnPTable::Table());
       
    47 	RStringF ext = iStringPool.StringF(UPnP::EExt, TUPnPTable::Table());
       
    48 	RStringF sid = iStringPool.StringF(UPnP::ESID, TUPnPTable::Table());
       
    49 	RStringF nts = iStringPool.StringF(UPnP::ENTS, TUPnPTable::Table());
       
    50 	RStringF nt = iStringPool.StringF(UPnP::ENT, TUPnPTable::Table());
       
    51 	RStringF mx = iStringPool.StringF(UPnP::EMX, TUPnPTable::Table());
       
    52 	RStringF seq = iStringPool.StringF(UPnP::ESEQ, TUPnPTable::Table());
       
    53 	RStringF man = iStringPool.StringF(UPnP::EMAN, TUPnPTable::Table());
       
    54 	RStringF soapaction = iStringPool.StringF(UPnP::ESoapAction, TUPnPTable::Table());
       
    55 	RStringF callback = iStringPool.StringF(UPnP::ECallback, TUPnPTable::Table());
       
    56 
       
    57 	if(
       
    58 	  (aHeaderField == st)||(aHeaderField == usn)||(aHeaderField == timeout)||(aHeaderField == ext)||
       
    59 	  (aHeaderField == sid)||(aHeaderField == nts)||(aHeaderField == nt)||(aHeaderField == mx)||
       
    60 	  (aHeaderField == seq)||(aHeaderField == man)||(aHeaderField == soapaction)||(aHeaderField == callback)
       
    61 	  ) 
       
    62 		{
       
    63 		canEncode = ETrue; 
       
    64 		}
       
    65 
       
    66 	return canEncode;  
       
    67 	}
       
    68 
       
    69 TBool CUPnPCodec::CanDecode(RStringF aHeaderField) const
       
    70 	{
       
    71 	TBool canDecode = EFalse;
       
    72 
       
    73 	RStringF st = iStringPool.StringF(UPnP::EST, TUPnPTable::Table());
       
    74 	RStringF usn = iStringPool.StringF(UPnP::EUSN, TUPnPTable::Table());
       
    75 	RStringF timeout = iStringPool.StringF(UPnP::ETimeout, TUPnPTable::Table());
       
    76 	RStringF ext = iStringPool.StringF(UPnP::EExt, TUPnPTable::Table());
       
    77 	RStringF sid = iStringPool.StringF(UPnP::ESID, TUPnPTable::Table());
       
    78 	RStringF nts = iStringPool.StringF(UPnP::ENTS, TUPnPTable::Table());
       
    79 	RStringF nt = iStringPool.StringF(UPnP::ENT, TUPnPTable::Table());
       
    80 	RStringF mx = iStringPool.StringF(UPnP::EMX, TUPnPTable::Table());
       
    81 	RStringF seq = iStringPool.StringF(UPnP::ESEQ, TUPnPTable::Table());
       
    82 	RStringF man = iStringPool.StringF(UPnP::EMAN, TUPnPTable::Table());
       
    83 	RStringF soapaction = iStringPool.StringF(UPnP::ESoapAction, TUPnPTable::Table());
       
    84 	RStringF callback = iStringPool.StringF(UPnP::ECallback, TUPnPTable::Table());
       
    85 
       
    86 	if(
       
    87 	  (aHeaderField == st)||(aHeaderField == usn)||(aHeaderField == timeout)||(aHeaderField == ext)||
       
    88 	  (aHeaderField == sid)||(aHeaderField == nts)||(aHeaderField == nt)||(aHeaderField == mx)||
       
    89 	  (aHeaderField == seq)||(aHeaderField == man)||(aHeaderField == soapaction)||(aHeaderField == callback)
       
    90 	  ) 
       
    91 		{
       
    92 		canDecode = ETrue; 
       
    93 		}
       
    94 
       
    95 	return canDecode;
       
    96 	}
       
    97 
       
    98 CHeaderCodec* CUPnPCodec::FindDelegateCodecL(RStringF /*aHeaderField*/) const
       
    99 	{
       
   100 	return CHeaderCodecPlugin::CreateDelegateCodecL(iStringPool);
       
   101 	}
       
   102 
       
   103 CUPnPCodec::CUPnPCodec(RStringPool aStringPool)
       
   104 :CHeaderCodecPlugin(), iStringPool(aStringPool)
       
   105 	{
       
   106 	// do nothing.
       
   107 	}
       
   108 
       
   109 void CUPnPCodec::ConstructL()
       
   110 	{
       
   111 	CHeaderCodec::ConstructL();
       
   112 	
       
   113 	iWriter = CUPnPHeaderWriter::NewL(iStringPool);
       
   114 	iReader = CUPnPHeaderReader::NewL(iStringPool);
       
   115 	}