upnp/upnpstack/serviceframework/src/upnpinitialeventqueuemanager.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2008-2008 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 algoritms for initial events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "upnpinitialeventqueuemanager.h"
       
    20 #include "upnpgenamessagefactory.h"
       
    21 #include "upnphttpinitialeventtransaction.h"
       
    22 #include "upnpcommonupnplits.h"
       
    23 #include "upnpcommonstructs.h"
       
    24 
       
    25 
       
    26 #define KLogFile _L("UPnPStack.txt")
       
    27 #include "upnpcustomlog.h"
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CUpnpInitialEventQueueManager::CUpnpInitialEventQueueManager
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CUpnpInitialEventQueueManager::CUpnpInitialEventQueueManager( 
       
    35                                             CUpnpServiceImplementation& aServiceImpl,
       
    36                                             CUpnpEventController& aEventController,
       
    37                                             CUpnpSubscriberLibrary* aSubscriberLibrary
       
    38                                                              )
       
    39     :CUpnpEventQueueManagerBase( aServiceImpl, aEventController, aSubscriberLibrary )
       
    40     {
       
    41     // No implementation required
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CUpnpInitialEventQueueManager::~CUpnpInitialEventQueueManager
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CUpnpInitialEventQueueManager::~CUpnpInitialEventQueueManager()
       
    49     {
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CUpnpInitialEventQueueManager::NewLC
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CUpnpInitialEventQueueManager* CUpnpInitialEventQueueManager::NewLC( 
       
    57                                            CUpnpServiceImplementation& aServiceImpl,
       
    58                                            CUpnpEventController& aEventController,
       
    59                                            CUpnpSubscriberLibrary* aSubscriberLibrary 
       
    60                                                                     )
       
    61     {
       
    62     CUpnpInitialEventQueueManager* self = 
       
    63         new (ELeave) CUpnpInitialEventQueueManager( aServiceImpl, 
       
    64                                                     aEventController, 
       
    65                                                     aSubscriberLibrary );
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     return self;
       
    69     }
       
    70     
       
    71 // -----------------------------------------------------------------------------
       
    72 // CUpnpInitialEventQueueManager::NewL
       
    73 // -----------------------------------------------------------------------------
       
    74 //    
       
    75 CUpnpInitialEventQueueManager* CUpnpInitialEventQueueManager::NewL( 
       
    76                                           CUpnpServiceImplementation& aServiceImpl,
       
    77                                           CUpnpEventController& aEventController,
       
    78                                           CUpnpSubscriberLibrary* aSubscriberLibrary 
       
    79                                                                    )
       
    80     {
       
    81     CUpnpInitialEventQueueManager* self= CUpnpInitialEventQueueManager::NewLC( 
       
    82                                                             aServiceImpl, 
       
    83                                                             aEventController, 
       
    84                                                             aSubscriberLibrary 
       
    85                                                                               );
       
    86     CleanupStack::Pop( self );
       
    87     return self;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CUpnpInitialEventQueueManager::ConstructL
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CUpnpInitialEventQueueManager::ConstructL()
       
    95     {
       
    96     BaseConstructL();
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CUpnpInitialEventQueueManager::SendEvent
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CUpnpInitialEventQueueManager::SendEvent()
       
   104     {
       
   105     TRAP_IGNORE( SendEventL() );
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CUpnpInitialEventQueueManager::SendEventL
       
   110 // -----------------------------------------------------------------------------
       
   111 //   
       
   112 void CUpnpInitialEventQueueManager::SendEventL()
       
   113     {
       
   114     // Initial event is sent to subscriber which is last on the list
       
   115     // it has been just added into it
       
   116     //
       
   117     TInt lastSubscriberIndex( iSubscriberLibrary->SubscriberLibrary().Count() - 1 );
       
   118     
       
   119     if ( iBody )
       
   120         {
       
   121         delete iBody;
       
   122         iBody =NULL;
       
   123         }
       
   124          
       
   125     iBody = CreateEventL( iServiceImpl.StateVariableList() );
       
   126     
       
   127     PrepareTransactionAndStartSendingL( lastSubscriberIndex );   
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CUpnpInitialEventQueueManager::CreateTransactionL
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 CUpnpHttpTransaction* CUpnpInitialEventQueueManager::CreateTransactionL( CUpnpHttpMessage* aMessage )
       
   135     {
       
   136     return CUpnpHttpInitialEventTransaction::NewL( aMessage );
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CUpnpInitialEventQueueManager::FillEventBody
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TInt CUpnpInitialEventQueueManager::FillEventBodyL( TDes8& aEvent, 
       
   144                                               const RPointerArray<CUpnpStateVariable>& aVariableList 
       
   145                                                    )
       
   146     {
       
   147     TInt eventableVariableCount(0);        
       
   148     for ( TInt i = 0; i < aVariableList.Count(); i++ )
       
   149         {
       
   150         if (   aVariableList[i]->Eventable().CompareF( KYes() ) == 0 
       
   151             && aVariableList[i]->ReadyForEventing() )
       
   152             {                            
       
   153             AddVariableToEventBody( aEvent , aVariableList[i] );
       
   154         
       
   155             eventableVariableCount++;
       
   156             }  
       
   157         }
       
   158     return eventableVariableCount;
       
   159     }
       
   160 //end if file