upnp/upnpstack/serviceframework/src/upnpservicestatetablecontenthandler.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2007 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:  Implements the CUpnpActionListContentHandler class
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "upnpservicestatetablecontenthandler.h"
       
    20 #include "upnpcontenthandlerscontroller.h"
       
    21 #include "upnpignorecontenthandler.h"
       
    22 #include "upnpstatevariablecontenthandler.h"
       
    23 #include "upnpservice.h"
       
    24 #include "upnpstatevariable.h"
       
    25 #include "upnpserviceliterals.h"
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CUpnpServiceStateTableContentHandler::NewL
       
    29 // Two-phased constructor
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CUpnpServiceStateTableContentHandler* CUpnpServiceStateTableContentHandler::NewL(
       
    33     CUpnpContentHandlersController& aController, CUpnpService& aResultService )
       
    34     {
       
    35     CUpnpServiceStateTableContentHandler* actionListContentHandler = 
       
    36         CUpnpServiceStateTableContentHandler::NewLC( aController, aResultService );
       
    37     CleanupStack::Pop( actionListContentHandler );
       
    38     return actionListContentHandler;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CUpnpServiceStateTableContentHandler::NewLC
       
    43 // Two-phased constructor. Leaves teh object on the CleanupStack
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CUpnpServiceStateTableContentHandler* CUpnpServiceStateTableContentHandler::NewLC(
       
    47     CUpnpContentHandlersController& aController, CUpnpService& aResultService )
       
    48     {
       
    49     CUpnpServiceStateTableContentHandler* actionListContentHandler =
       
    50         new (ELeave) CUpnpServiceStateTableContentHandler(aController, 
       
    51             aResultService);
       
    52     CleanupStack::PushL( actionListContentHandler );
       
    53     return actionListContentHandler;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CUpnpServiceStateTableContentHandler::~CUpnpServiceStateTableContentHandler
       
    58 // Destructor of CUpnpServiceStateTableContentHandler class 
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CUpnpServiceStateTableContentHandler::~CUpnpServiceStateTableContentHandler()
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CUpnpServiceStateTableContentHandler::CUpnpServiceStateTableContentHandler
       
    67 // Constructor
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CUpnpServiceStateTableContentHandler::CUpnpServiceStateTableContentHandler(
       
    71     CUpnpContentHandlersController& aController, CUpnpService& aResultService ) :
       
    72     CUpnpContentHandler(aController), iResultService(aResultService)
       
    73     {
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CUpnpServiceStateTableContentHandler::OnStartElementL
       
    78 // This method is a callback to indicate an element has been parsed.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CUpnpServiceStateTableContentHandler::OnStartElementL(
       
    82     const RTagInfo& aElement, const RAttributeArray& aAttributes )
       
    83     {
       
    84     if ( aElement.LocalName().DesC().Compare(KUpnpStateVariable) == 0 )
       
    85         {
       
    86         iStateVariableFound = ETrue;
       
    87         CUpnpStateVariable* stateVariable = CUpnpStateVariable::NewL();
       
    88         CleanupStack::PushL( stateVariable );
       
    89         iResultService.AddStateVariableL( stateVariable );
       
    90         CleanupStack::Pop( stateVariable );
       
    91         ParseAttributesL( *stateVariable, aAttributes );
       
    92         iController.SetCurrentContentHandlerL( 
       
    93             CUpnpStateVariableContentHandler::NewL( iController, *stateVariable ) );
       
    94         }
       
    95     else
       
    96         {
       
    97         iController.SetCurrentContentHandlerL( 
       
    98             CUpnpIgnoreContentHandler::NewL( iController ) );
       
    99         }
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CUpnpServiceStateTableContentHandler::OnEndElementL
       
   104 // This method is a callback to indicate the end of the element has been reached.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CUpnpServiceStateTableContentHandler::OnEndElementL(
       
   108     const RTagInfo& aElement )
       
   109     {
       
   110     ASSERT( aElement.LocalName().DesC().Compare(KUpnpServiceStateTable) == 0 );
       
   111     //if ( iStateVariableFound )
       
   112         //{
       
   113         iController.SetPreviousContentHandler();
       
   114         //}
       
   115     //else
       
   116         //{
       
   117         //User::Leave( KErrArgument ) //required but not checked now 
       
   118         //}
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CUpnpServiceStateTableContentHandler::ParseAttributesL
       
   123 // Parse attributes, and set correct eventable values to aResultStateVariable.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CUpnpServiceStateTableContentHandler::ParseAttributesL(
       
   127     CUpnpStateVariable& aResultStateVariable,
       
   128     const RAttributeArray& aAttributes )
       
   129     {
       
   130     TBool sendEventsNotFound(ETrue);
       
   131     for ( TInt index=0; index<aAttributes.Count(); ++index )
       
   132         {
       
   133         if ( !aAttributes[index].Attribute().LocalName().DesC().Compare( KUpnpSendEvents ) )
       
   134             {
       
   135             aResultStateVariable.SetEventableL( aAttributes[index].Value().DesC() );
       
   136             sendEventsNotFound = EFalse;
       
   137             }
       
   138         }
       
   139     if ( sendEventsNotFound )
       
   140         {
       
   141         aResultStateVariable.SetEventableL( KYes );
       
   142         }
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CUpnpServiceStateTableContentHandler::OnContentL
       
   147 // This method is a callback that sends the content of the element.
       
   148 // aErrorCode must be KErrNone, and that aBytes should contains complete
       
   149 // content (one chunk).
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CUpnpServiceStateTableContentHandler::OnContentL( const TDesC8& /*aBytes*/ )
       
   153     {
       
   154     //User::Leave( KErrArgument ) 
       
   155     }
       
   156 
       
   157 //  End of File