applayerprotocols/httpservice/src/httpclientutils.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-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 "httpclientutils.h"
       
    17 #include <stringpool.h>
       
    18 
       
    19 TInt HttpClientUtils::OpenStringF(const TDesC8& aDesc, RStringPool& aPool, RStringF& aStringF)
       
    20 	{
       
    21 	// Usage of TRAP here is not correct. Currently we do not have any non-leaving variant in
       
    22 	// the stringpool implementation. Need to be requested to provide.
       
    23 	TRAPD(err, aStringF = aPool.OpenFStringL(aDesc));
       
    24 	return err;
       
    25 	}
       
    26 
       
    27 THttpHeaderValueVariant HttpClientUtils::CopyHttpHdrVal(const THTTPHdrVal& aVal)
       
    28   {
       
    29   switch(aVal.Type())
       
    30       {
       
    31       case THTTPHdrVal::KTIntVal:
       
    32           {
       
    33           return THttpHeaderValueVariant(aVal.Int());
       
    34           }
       
    35       
       
    36       
       
    37       case  THTTPHdrVal::KStrVal:
       
    38           {
       
    39           return THttpHeaderValueVariant(aVal.Str().DesC());
       
    40           }
       
    41       
       
    42       
       
    43       case THTTPHdrVal::KStrFVal:
       
    44           {
       
    45           return THttpHeaderValueVariant(aVal.StrF().DesC());
       
    46           }
       
    47       
       
    48       
       
    49       case THTTPHdrVal::KDateVal:
       
    50           {
       
    51           return THttpHeaderValueVariant(aVal.DateTime());
       
    52           }
       
    53       
       
    54       }
       
    55   return THttpHeaderValueVariant();
       
    56   }
       
    57 
       
    58 THTTPHdrVal HttpClientUtils::CopyHttpHdrVal(const THttpHeaderValueVariant& aVal, RStringPool& aStrPool)
       
    59   {
       
    60   switch(aVal.Type())
       
    61       {
       
    62       case THttpHeaderValueVariant::EIntType:
       
    63           {
       
    64           return THTTPHdrVal(aVal.Int());
       
    65           }
       
    66       
       
    67       
       
    68       case THttpHeaderValueVariant::EStrType:
       
    69           {
       
    70           RStringF str;
       
    71           TRAP_IGNORE(str = aStrPool.OpenFStringL(aVal.Str()));
       
    72           if(!((RStringTokenBase)str).IsNull())
       
    73               {
       
    74               return THTTPHdrVal(str);
       
    75               }
       
    76           break;
       
    77           }
       
    78       
       
    79       case THttpHeaderValueVariant::EDateTimeType:
       
    80           {
       
    81           return THTTPHdrVal(aVal.DateTime());
       
    82           }
       
    83       
       
    84     
       
    85       }
       
    86   return THTTPHdrVal();     
       
    87 	}
       
    88 
       
    89 void HttpClientUtils::CloseString(const THTTPHdrVal& aVal)
       
    90   {
       
    91   if(aVal.Type() == THTTPHdrVal::KStrVal)
       
    92       {
       
    93       aVal.Str().Close();
       
    94       return;
       
    95       }
       
    96   
       
    97   if(aVal.Type() == THTTPHdrVal::KStrFVal)
       
    98       {
       
    99       aVal.StrF().Close();
       
   100       return;
       
   101       }                
       
   102   }