webservices/wsstar/wsstarmessagehandlers/src/wsstaraddressingheaderinbound.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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 #include "wsstaraddressingheaderinbound.h"
       
    26 #include "senlogger.h"
       
    27 
       
    28 using namespace WSStarAddressing;
       
    29 
       
    30 CWSStarAddressingHeaderInbound* CWSStarAddressingHeaderInbound::NewL(const TDesC8* aVersion)
       
    31     {
       
    32     CWSStarAddressingHeaderInbound* self = NewLC(aVersion);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35     }
       
    36 
       
    37 CWSStarAddressingHeaderInbound* CWSStarAddressingHeaderInbound::NewLC(const TDesC8* aVersion)
       
    38     {
       
    39     CWSStarAddressingHeaderInbound* self = new (ELeave) CWSStarAddressingHeaderInbound();
       
    40     CleanupStack::PushL (self);
       
    41     self->ConstructL(aVersion);
       
    42     return self;
       
    43     }
       
    44 
       
    45 
       
    46 void CWSStarAddressingHeaderInbound::StartElementL(const TDesC8& aNsUri,
       
    47                                const TDesC8& aLocalName,
       
    48                                const TDesC8& /*aQName*/,
       
    49                                const RAttributeArray& /*aAttributes*/)
       
    50     {
       
    51     switch (iState)
       
    52         {
       
    53         case KStateIgnore:
       
    54             {
       
    55             if (!iVersion && (aNsUri == KAddressingXmlns200408 ||
       
    56                 aNsUri == KAddressingXmlns200403 ||
       
    57                 aNsUri == KAddressingXmlns200412 ||
       
    58                 aNsUri == KAddressingXmlns200502 ||
       
    59                 aNsUri == KAddressingXmlns200503 ||
       
    60                 aNsUri == KAddressingXmlns200508))
       
    61                 {
       
    62                 delete iVersionBuf;
       
    63                 iVersionBuf = NULL;
       
    64                 iVersionBuf = aNsUri.AllocL();
       
    65                 iVersion = iVersionBuf;
       
    66                 }
       
    67             if (iVersion && (aNsUri == *iVersion))
       
    68                 {
       
    69                 iState = KStateSave;
       
    70                 if  (aLocalName == KReplyToName )
       
    71                     {
       
    72                     iState = KStateParsingReplyTo;
       
    73                     }
       
    74                 else if  (aLocalName == KFaultToName )
       
    75                     {
       
    76                     iState = KStateParsingFaultTo;
       
    77                     }
       
    78                 else if  (aLocalName == KFromName )
       
    79                     {
       
    80                     iState = KStateParsingFrom;
       
    81                     }
       
    82                 break;
       
    83                 }
       
    84             if (aLocalName == WSStarAddressingEPR::KDeviceAddressName)
       
    85                 {
       
    86                 iState = KStateSave;
       
    87                 }
       
    88             }
       
    89         default:
       
    90             break;
       
    91         }
       
    92     }                       
       
    93     
       
    94 void CWSStarAddressingHeaderInbound::EndElementL(const TDesC8& aNsUri,
       
    95                              const TDesC8& aLocalName,
       
    96                              const TDesC8& /*aQName*/)
       
    97     {
       
    98     TPtrC8 content = Content();
       
    99     TUriParser8 uriParser;
       
   100     TInt error = uriParser.Parse(content);
       
   101     if (error != KErrNone)
       
   102         {
       
   103         TLSLOG_FORMAT((KSenFaultsLogChannel, KSenFaultsLogLevel, 
       
   104                         WSStarAddressingFault::KInvalidHeaderFormatString8, 
       
   105                         &aLocalName,&WSStarAddressingFault::KInvalidUri()));   
       
   106         }
       
   107         
       
   108     switch (iState)
       
   109         {
       
   110         case KStateSave:
       
   111             {
       
   112             if (aNsUri == *iVersion)
       
   113                 {
       
   114                 if (aLocalName == KMessageIDName)
       
   115                     {
       
   116                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KMessageID, 
       
   117                                                             content);
       
   118                     }
       
   119                 else if (aLocalName == KRelatesToName)
       
   120                     {
       
   121                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KRelatesTo, 
       
   122                                                             content);
       
   123                     }
       
   124                 else if (aLocalName == KToName)
       
   125                     {
       
   126                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KTo, content);
       
   127                     }
       
   128                 else if (aLocalName == KActionName)
       
   129                     {
       
   130                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KAction, content);
       
   131                     }
       
   132                 }
       
   133             if (aLocalName == WSStarAddressingEPR::KDeviceAddressName)
       
   134                 {
       
   135                 ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KReplyToDeviceAddress,
       
   136                                                         content);
       
   137                 iDeviceAddress = ETrue;                                                            
       
   138                 }
       
   139             ResetContentL();
       
   140             iState = KStateIgnore;
       
   141             break;
       
   142             }
       
   143         case KStateParsingReplyTo:
       
   144             {
       
   145             if (aNsUri == *iVersion )
       
   146                 {
       
   147                 if (aLocalName == KAddressName)
       
   148                     {
       
   149                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KReplyTo,content);
       
   150                     }
       
   151                 ResetContentL();
       
   152                 break;
       
   153                 }
       
   154             if (aLocalName == WSStarAddressingEPR::KDeviceAddressName)
       
   155                 {
       
   156                 if (!iDeviceAddress)
       
   157                     {
       
   158                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KReplyToDeviceAddress,
       
   159                                                             content);
       
   160                     }
       
   161                 }
       
   162 
       
   163             ResetContentL();
       
   164             iState = KStateIgnore;
       
   165             break;
       
   166             }            
       
   167         case KStateParsingFaultTo:
       
   168             {
       
   169             if (aNsUri == *iVersion )
       
   170                 {
       
   171                 if (aLocalName == KAddressName)
       
   172                     {
       
   173                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KFaultTo,content);
       
   174                     ResetContentL();
       
   175                     iState = KStateIgnore;
       
   176                     }
       
   177                 }
       
   178             break;
       
   179             }            
       
   180         case KStateParsingFrom:
       
   181             {
       
   182             if (aNsUri == *iVersion )
       
   183                 {
       
   184                 if (aLocalName == KAddressName)
       
   185                     {
       
   186                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KFrom,content);
       
   187                     ResetContentL();
       
   188                     iState = KStateIgnore;
       
   189                     }
       
   190                 }
       
   191             break;
       
   192             }            
       
   193         default:
       
   194             break;
       
   195         }
       
   196     }
       
   197 
       
   198 
       
   199 // Constructor
       
   200 CWSStarAddressingHeaderInbound::CWSStarAddressingHeaderInbound()
       
   201     {
       
   202     }
       
   203 
       
   204 // Destructor
       
   205 CWSStarAddressingHeaderInbound::~CWSStarAddressingHeaderInbound()
       
   206     {
       
   207     delete iVersionBuf;
       
   208     }
       
   209 
       
   210 // Second phase construction.
       
   211 void CWSStarAddressingHeaderInbound::ConstructL(const TDesC8* aVersion)
       
   212     {
       
   213     if (aVersion)
       
   214         {
       
   215         CSenBaseFragment::BaseConstructL(*aVersion,
       
   216                 KSenSoapEnvelopeHeaderName);
       
   217         }
       
   218     else
       
   219         {
       
   220         CSenBaseFragment::BaseConstructL(TPtrC8(NULL,0),
       
   221                 KSenSoapEnvelopeHeaderName);
       
   222         }
       
   223     iVersion = aVersion;
       
   224     iDeviceAddress = EFalse;
       
   225     }
       
   226 
       
   227 
       
   228 TInt CWSStarAddressingHeaderInbound::SetMessageContext(MSenMessageContext& aCtx)
       
   229     {
       
   230     iMessageContext = &aCtx;
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 const TDesC8* CWSStarAddressingHeaderInbound::Version() const
       
   235     {
       
   236     return iVersion;
       
   237     }
       
   238 
       
   239 // END OF FILE
       
   240