webservices/wsoviplugin/src/wsoviencoderhandler.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:       
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 #include "wsoviencoderhandler.h"
       
    28 #include "senlogger.h"
       
    29 #include "wsoviutils.h"
       
    30 #include <SenHttpTransportProperties.h>
       
    31 using namespace OAuth;
       
    32 using namespace WSOviResponse;
       
    33 // Create instance of concrete ECOM interface implementation
       
    34 CWSOviEncoderHandler* CWSOviEncoderHandler::NewL(TAny* aHandlerCtx)
       
    35     {
       
    36     
       
    37     MSenHandlerContext* handlerCtx =
       
    38         reinterpret_cast<MSenHandlerContext*>(aHandlerCtx);
       
    39     CWSOviEncoderHandler* self = 
       
    40             new(ELeave)CWSOviEncoderHandler(*handlerCtx);
       
    41     CleanupStack::PushL (self);
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop(self);
       
    44     return self;
       
    45     }
       
    46 
       
    47 // Constructor
       
    48 CWSOviEncoderHandler::CWSOviEncoderHandler(MSenHandlerContext& aCtx)
       
    49 :CSenMessageHandler(aCtx)
       
    50     {
       
    51     }
       
    52 
       
    53 // Destructor
       
    54 CWSOviEncoderHandler::~CWSOviEncoderHandler()
       
    55     {
       
    56         TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::\
       
    57                          ~CWSOviEncoderHandler()")));
       
    58     }
       
    59 
       
    60 // Second phase construction.
       
    61 void CWSOviEncoderHandler::ConstructL()
       
    62     {
       
    63     }
       
    64     
       
    65 TInt CWSOviEncoderHandler::InvokeL(MSenMessageContext& aCtx)
       
    66     {
       
    67     TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::InvokeL(MSenMessageContext& aCtx)")));
       
    68     
       
    69     const TDesC8* bodyMessage = ((CWSOviMessageContext&)aCtx).GetDesC8L(WSOviContextKeys::KMessageBody);
       
    70 
       
    71     if (bodyMessage)
       
    72         {
       
    73         CSenTransportProperties* transProp = ((CWSOviMessageContext&)aCtx).TP();
       
    74         CSenHttpTransportProperties::TSenHttpMethod httpMethod = CSenHttpTransportProperties::ESenHttpPost;
       
    75         TInt retVal = ((CSenHttpTransportProperties*)transProp)->HttpMethodL(httpMethod);
       
    76         if (httpMethod == CSenHttpTransportProperties::ESenHttpGet)
       
    77             {
       
    78             TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::InvokeL\
       
    79                                     (MSenMessageContext& aCtx) -  \
       
    80                                     body is not encoding with GET method for http")));
       
    81             return KErrNone;
       
    82             }
       
    83 
       
    84         HBufC8* bodyEncodedUrl = CWSOviUtils::FormEncodeCharsLC(*bodyMessage);
       
    85         HBufC8* allBody = HBufC8::NewL(KXmlContentEqual().Length()+bodyEncodedUrl->Length());
       
    86         allBody->Des().Append(KXmlContentEqual());
       
    87         allBody->Des().Append(*bodyEncodedUrl);
       
    88         CleanupStack::PushL(allBody);
       
    89         
       
    90         ((CWSOviMessageContext&)aCtx).Update(WSOviContextKeys::KMessageBody, *allBody);
       
    91         
       
    92         CleanupStack::PopAndDestroy(allBody);
       
    93         CleanupStack::PopAndDestroy(bodyEncodedUrl);
       
    94         return KErrNone;
       
    95         }
       
    96     else
       
    97         {
       
    98         TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::InvokeL\
       
    99                                 (MSenMessageContext& aCtx) -  \
       
   100                                 body message context not exists")));
       
   101         return KErrNotFound;
       
   102         }
       
   103     }
       
   104 
       
   105 TInt CWSOviEncoderHandler::InitL(MSenHandlerContext& aCtx)
       
   106     {
       
   107     iHandlerContext = aCtx;
       
   108     return KErrNone;
       
   109     }
       
   110     
       
   111 SenHandler::THandlerDirection CWSOviEncoderHandler::Direction() const
       
   112     {
       
   113     TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::Direction()")));
       
   114     return SenHandler::EOutgoing;
       
   115     };
       
   116 SenHandler::THandlerPhase CWSOviEncoderHandler::Phase()
       
   117     {
       
   118     TLSLOG(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,(_L("CWSOviEncoderHandler::Phase()")));
       
   119     return SenHandler::EMessage;
       
   120     };    
       
   121 
       
   122 // END OF FILE
       
   123