webservices/wsstar/wsstarmessagehandlers/src/wsstarpassportheaderinbound.cpp
changeset 0 62f9d29f7211
child 1 272b002df977
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 //Co-Branding CR
       
    22 #include "wsstarpassportheaderinbound.h"
       
    23 #include "senlogger.h"
       
    24 #include "SenXmlUtils.h"
       
    25 #include "SenBaseElement.h"
       
    26 
       
    27 
       
    28 CWSStarPassportHeaderInbound* CWSStarPassportHeaderInbound::NewL()
       
    29     {
       
    30     CWSStarPassportHeaderInbound* self = NewLC();
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33     }
       
    34 
       
    35 CWSStarPassportHeaderInbound* CWSStarPassportHeaderInbound::NewLC()
       
    36     {
       
    37     CWSStarPassportHeaderInbound* self = new (ELeave) CWSStarPassportHeaderInbound();
       
    38     CleanupStack::PushL (self);
       
    39     self->ConstructL();
       
    40     return self;
       
    41     }
       
    42 
       
    43 
       
    44 void CWSStarPassportHeaderInbound::StartElementL(const TDesC8& aNsUri,
       
    45                                const TDesC8& aLocalName,
       
    46                                const TDesC8& aQName,
       
    47                                const RAttributeArray& aAttributes)
       
    48     {
       
    49     switch (iState)
       
    50         {
       
    51         case KStateIgnore:
       
    52             {
       
    53             if (aNsUri == WSPassport32::KPassportFaultNamespaceXmlns)
       
    54                 {
       
    55                 iState = KStateSave;
       
    56                 if  (aLocalName == WSPassport32::KCredProperty )
       
    57                     {
       
    58                     TPtrC8 value =
       
    59                         SenXmlUtils::AttrValue(aAttributes, WSPassport32::KName);
       
    60                     if(value == WSPassport32::KMainBrandID)
       
    61                         {
       
    62                             iState = KStateParsingMainBrandID;
       
    63                         }
       
    64                     
       
    65                     }
       
    66                  else if  (aLocalName == WSPassport32::KCredProperties )
       
    67                     {
       
    68                     iState = KStateParsingBrandIDList;
       
    69                     if(ipBrandIdListElem)
       
    70                         {
       
    71                             delete ipBrandIdListElem;
       
    72                             ipBrandIdListElem = NULL;
       
    73                         }  
       
    74                     ipBrandIdListElem = CSenBaseElement::NewL(aNsUri,aLocalName,aQName,aAttributes);
       
    75                   	}
       
    76                 break;
       
    77                 }
       
    78             }
       
    79         default:
       
    80             break;
       
    81         }
       
    82     }                       
       
    83     
       
    84 void CWSStarPassportHeaderInbound::EndElementL(const TDesC8& aNsUri,
       
    85                              const TDesC8& aLocalName,
       
    86                              const TDesC8& aQName)
       
    87     {
       
    88     TPtrC8 content = Content();
       
    89     switch (iState)
       
    90         {
       
    91         case KStateSave:
       
    92             {
       
    93             ResetContentL();
       
    94             iState = KStateIgnore;
       
    95             break;
       
    96             }
       
    97         case KStateParsingMainBrandID:
       
    98             {
       
    99             if (aNsUri == WSPassport32::KPassportFaultNamespaceXmlns)
       
   100                 {
       
   101                 if (aLocalName == WSPassport32::KCredProperty)
       
   102                     {
       
   103                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KMainBrandID,content);
       
   104                     ResetContentL();
       
   105                     iState = KStateParsingBrandIDList;
       
   106                     }
       
   107                 }
       
   108             break;
       
   109             }            
       
   110         case KStateParsingBrandIDList:
       
   111             {
       
   112             if (aNsUri == WSPassport32::KPassportFaultNamespaceXmlns)
       
   113                 {
       
   114                 if (aLocalName == WSPassport32::KCredProperties)
       
   115                     {
       
   116                     ipBrandIdListElem->SetContentL(content);
       
   117                     HBufC8* xmlSnippet = ipBrandIdListElem->AsXmlL();
       
   118                     CleanupStack::PushL(xmlSnippet);
       
   119                     ((MSenContext*)iMessageContext)->Update(WSStarContextKeys::KBrandIDList,xmlSnippet);
       
   120                     CleanupStack::PopAndDestroy(xmlSnippet);
       
   121                     
       
   122                     ResetContentL();
       
   123                     iState = KStateIgnore;
       
   124                     }
       
   125                 }
       
   126             break;
       
   127             }            
       
   128         default:
       
   129             break;
       
   130         }
       
   131     }
       
   132 
       
   133 
       
   134 // Constructor
       
   135 CWSStarPassportHeaderInbound::CWSStarPassportHeaderInbound()
       
   136     {
       
   137     }
       
   138 
       
   139 // Destructor
       
   140 CWSStarPassportHeaderInbound::~CWSStarPassportHeaderInbound()
       
   141     {
       
   142     if(ipBrandIdListElem)
       
   143         {
       
   144             delete ipBrandIdListElem;
       
   145             ipBrandIdListElem = NULL;
       
   146         }      
       
   147     }
       
   148 
       
   149 // Second phase construction.
       
   150 void CWSStarPassportHeaderInbound::ConstructL()
       
   151     {
       
   152     CSenBaseFragment::BaseConstructL(TPtrC8(NULL,0),
       
   153             KSenSoapEnvelopeHeaderName);
       
   154     }
       
   155 
       
   156 
       
   157 TInt CWSStarPassportHeaderInbound::SetMessageContext(MSenMessageContext& aCtx)
       
   158     {
       
   159     iMessageContext = &aCtx;
       
   160     return KErrNone;
       
   161     }
       
   162 
       
   163 // END OF FILE
       
   164