upnp/upnpstack/serviceframework/src/upnpsoapmessage.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2005-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:  Represents SOAP message
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnpsoapmessage.h"
       
    21 #include "upnpstring.h"
       
    22 #include "upnplist.h"
       
    23 
       
    24 // CONSTANTS
       
    25 _LIT8(KCross, "#");
       
    26 _LIT8(KService, ":service:");
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CUpnpSoapMessage::CUpnpSoapMessage
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CUpnpSoapMessage::CUpnpSoapMessage():CUpnpHttpMessage()
       
    38 {
       
    39 
       
    40 }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CUpnpSoapMessage::NewL
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CUpnpSoapMessage* CUpnpSoapMessage::NewL( TDesC8& aBuffer, 
       
    48                                                    const TInetAddr& aAddr)
       
    49 {
       
    50     
       
    51     CUpnpSoapMessage* self = new (ELeave) CUpnpSoapMessage();
       
    52     CleanupStack::PushL(self);
       
    53     self->ConstructL(aAddr);
       
    54     self->ParseL(aBuffer);
       
    55     CleanupStack::Pop(self);
       
    56         
       
    57     return self;
       
    58 }
       
    59 
       
    60 // Destructor
       
    61 EXPORT_C CUpnpSoapMessage::~CUpnpSoapMessage()
       
    62 {
       
    63 
       
    64 }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CUpnpSoapMessage::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CUpnpSoapMessage::ConstructL( TInetAddr aSender) 
       
    72 {
       
    73     CUpnpHttpMessage::ConstructL(aSender, NewSessionIdL());
       
    74 }
       
    75     
       
    76 // -----------------------------------------------------------------------------
       
    77 // CUpnpSoapMessage::SoapAction
       
    78 //
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C const TPtrC8 CUpnpSoapMessage::SoapAction()
       
    83 {
       
    84     CUpnpHttpHeader* hdr = iHeaderList->First();
       
    85     
       
    86     while ( hdr )
       
    87     {
       
    88         if ( hdr->Name().CompareF( KSoapAction() ) == 0 )
       
    89         {
       
    90             return hdr->Value();
       
    91         }
       
    92         
       
    93         hdr = iHeaderList->Next( hdr );
       
    94     }
       
    95     
       
    96     return KNullDesC8();
       
    97 }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CUpnpSoapMessage::ActionName
       
   101 //
       
   102 // (other items were commented in a header).
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C const TPtrC8 CUpnpSoapMessage::ActionName()
       
   106 {
       
   107     const TPtrC8 soap = SoapAction();
       
   108     
       
   109     if (soap.Length() > 0)
       
   110     {
       
   111         TInt crossIndex = soap.Find( KCross() );
       
   112         
       
   113         if ( 0 <= crossIndex )
       
   114         {
       
   115             return soap.Mid(crossIndex + 1, soap.Length() - (crossIndex + 2));
       
   116         }
       
   117     }
       
   118     // If soap is zero or KCross is not found, return KNullDesC8
       
   119     return KNullDesC8();
       
   120 }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CUpnpSoapMessage::ServiceType
       
   124 //
       
   125 // (other items were commented in a header).
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 EXPORT_C const TPtrC8 CUpnpSoapMessage::ServiceType()
       
   129 {
       
   130     const TPtrC8 soap = SoapAction();
       
   131     
       
   132     if (soap.Length() > 0)
       
   133     {
       
   134         TInt servStart = soap.Find(KService());
       
   135         
       
   136         TInt servEnd = soap.Find(KCross());
       
   137         if( ( servStart < 0 ) ||
       
   138             ( servEnd   < 0 ) )
       
   139         {
       
   140             return KNullDesC8();
       
   141         }
       
   142 
       
   143         servStart += KService().Length();
       
   144         
       
   145         TInt length = (servEnd - servStart);
       
   146         
       
   147         return soap.Mid(servStart, length);
       
   148     }
       
   149     
       
   150     return KNullDesC8();
       
   151 }
       
   152 
       
   153 //  End of File