webservices/idwsfplugin/src/idwsfmessage.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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 FILES
       
    26 #include <SenDateUtils.h>
       
    27 
       
    28 #include "idwsfmessage.h"
       
    29 
       
    30 namespace
       
    31     {
       
    32     _LIT8(KSB11XmlNs,           "urn:liberty:sb:2004-04");
       
    33     _LIT8(KStatus,              "Status");
       
    34     _LIT8(KStatusCodeAttr,      "code");
       
    35     //_LIT8(KStatusOK,          "ok");
       
    36     _LIT8(KDetail,              "detail");
       
    37     }
       
    38 
       
    39 CIdWsfMessage* CIdWsfMessage::NewL(const TDesC8& aRefToMessageId)
       
    40     {
       
    41     CIdWsfMessage* pNew = new (ELeave) CIdWsfMessage;
       
    42     CleanupStack::PushL(pNew);
       
    43     pNew->BaseConstructL(aRefToMessageId);
       
    44     CleanupStack::Pop(); // pNew;
       
    45     return pNew;
       
    46     }
       
    47 
       
    48 CIdWsfMessage::~CIdWsfMessage()
       
    49     {
       
    50     TInt leaveCode(KErrNone);
       
    51     TRAP(leaveCode, delete CSenSoapEnvelope::HeaderL().RemoveElement(KSiuXmlns, KSiuName);)
       
    52     leaveCode=0; // not used
       
    53     if(ipSiuHeader)
       
    54         {
       
    55         // We do not own the element, so remove it from the fragment.
       
    56         ipSiuHeader->ExtractElement();
       
    57         delete ipSiuHeader;
       
    58         }
       
    59     }
       
    60 
       
    61 CIdWsfMessage::CIdWsfMessage()
       
    62     {
       
    63     }
       
    64 
       
    65 void CIdWsfMessage::BaseConstructL(const TDesC8& aRefToMessageId)
       
    66     {
       
    67     CIdWsfSoapMessage::BaseConstructL();
       
    68 
       
    69     // Add correlation header
       
    70     ipCorrelationHeader = CIdWsfCorrelationHeader::NewL(aRefToMessageId);
       
    71     AddHeaderL(*ipCorrelationHeader);
       
    72     }
       
    73 
       
    74 void CIdWsfMessage::ParseHeaderL(
       
    75     const TDesC8& aNsUri,
       
    76     const TDesC8& aLocalName,
       
    77     const TDesC8& aQName,
       
    78     const RAttributeArray& aAttributes
       
    79     )
       
    80     {
       
    81     if ((aNsUri == KSBXmlNs) && (aLocalName == KCorrelationName))
       
    82         {
       
    83         // Remove existing stuff
       
    84         delete HeaderL().RemoveElement(KSBXmlNs, KCorrelationName);
       
    85 
       
    86         // Add new correlation header
       
    87         ipCorrelationHeader = NULL;
       
    88         ipCorrelationHeader = CIdWsfCorrelationHeader::NewL(aAttributes);
       
    89         AddHeaderL(*ipCorrelationHeader);
       
    90         }
       
    91     else if ((aNsUri == KSB11XmlNs) && (aLocalName == KSiuName))
       
    92         {
       
    93         // Remove existing stuff
       
    94         delete HeaderL().RemoveElement(KSB11XmlNs, KSiuName);
       
    95         if (ipSiuHeader)
       
    96             {
       
    97             // We do not own the element, so remove it from the fragment.
       
    98             ipSiuHeader->ExtractElement();
       
    99             delete ipSiuHeader;
       
   100             }
       
   101         ipSiuHeader = NULL;
       
   102         ipSiuHeader = CIdWsfSiuHeader::NewL();
       
   103         DelegateParsingL(*ipSiuHeader);
       
   104         AddHeaderL(ipSiuHeader->AsElement());
       
   105         }
       
   106     else
       
   107         {
       
   108         CIdWsfSoapMessage::ParseHeaderL(aNsUri, aLocalName, aQName, aAttributes);
       
   109         }
       
   110     }
       
   111 
       
   112 void CIdWsfMessage::SetCorrelationL(const TDesC8& aRefToMessageId)
       
   113     {
       
   114     ipCorrelationHeader->SetCorrelationL(aRefToMessageId);
       
   115     }
       
   116 
       
   117 TPtrC8 CIdWsfMessage::MessageId()
       
   118     {
       
   119     return ipCorrelationHeader->MessageId();
       
   120     }
       
   121 
       
   122 
       
   123 TPtrC8 CIdWsfMessage::RefToMessageId()
       
   124     {
       
   125     return ipCorrelationHeader->RefToMessageId();
       
   126     }
       
   127 
       
   128 TPtrC8 CIdWsfMessage::Timestamp()
       
   129     {
       
   130     return ipCorrelationHeader->Timestamp();
       
   131     }
       
   132 
       
   133 CIdWsfSiuHeader* CIdWsfMessage::SiuHeader()
       
   134     {
       
   135     return ipSiuHeader;
       
   136     }
       
   137 
       
   138 const TDesC8* CIdWsfMessage::StatusCodeL()
       
   139     {
       
   140     const TDesC8* pCode = NULL;
       
   141     CSenElement* pStatus = NULL;
       
   142     // this fetched first child of Body,not yet the status
       
   143     CSenElement* pBodyChild = CIdWsfSoapMessage::BodyL().Child(0);
       
   144 
       
   145     if (pBodyChild)
       
   146         {
       
   147         //now we should have the S:Fault/detail element
       
   148         pStatus = pBodyChild->Element(KSBXmlNs,KStatus);
       
   149         }
       
   150 
       
   151     if (!pStatus && pBodyChild)
       
   152         {
       
   153         //now we should have the S:Fault/detail element
       
   154         pBodyChild = pBodyChild->Element(KNullDesC8, KDetail);
       
   155         if (pBodyChild)
       
   156             {
       
   157             //now we should have the S:Fault/detail element
       
   158             pStatus = pBodyChild->Element(KSBXmlNs,KStatus);
       
   159             }
       
   160         }
       
   161 
       
   162     if (pStatus)
       
   163         {
       
   164         pCode = pStatus->AttrValue(KStatusCodeAttr);
       
   165         }
       
   166 
       
   167     return pCode;
       
   168     }
       
   169 
       
   170 // End of File