upnp/upnpstack/upnpconnmanager/src/upnpipeventnotifier.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:  Monitoring of IP Event Notification from ipeventnotifier module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "upnpipeventnotifier.h"
       
    20 #include <networking/ipeventtypesids.h>
       
    21 
       
    22 #ifdef _DEBUG
       
    23 #define KLogFile _L("UPnPStack.txt")
       
    24 #endif
       
    25 #include "upnpcustomlog.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CUpnpIPEventNotifier::NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CUpnpIPEventNotifier* CUpnpIPEventNotifier::NewL( TInt aInterfaceIndex )
       
    35     {
       
    36     CUpnpIPEventNotifier* self = new (ELeave) CUpnpIPEventNotifier;
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL( aInterfaceIndex );
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CUpnpIPEventNotifier::CUpnpIPEventNotifier
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CUpnpIPEventNotifier::CUpnpIPEventNotifier() : CActive( EPriorityStandard )
       
    48     {
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CUpnpIPEventNotifier::ConstructL
       
    53 // ---------------------------------------------------------------------------
       
    54 //    
       
    55 void CUpnpIPEventNotifier::ConstructL( TInt aInterfaceIndex )
       
    56     {
       
    57     User::LeaveIfError( iProperty.Attach( TUid::Uid( IPEvent::EIPReady ), 
       
    58                                           aInterfaceIndex ) );
       
    59     CActiveScheduler::Add( this );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CUpnpIPEventNotifier::~CUpnpIPEventNotifier
       
    64 // ---------------------------------------------------------------------------
       
    65 //    
       
    66 CUpnpIPEventNotifier::~CUpnpIPEventNotifier()
       
    67     {
       
    68     Cancel();
       
    69     iProperty.Close();
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CUpnpIPEventNotifier::DoCancel
       
    74 // ---------------------------------------------------------------------------
       
    75 //    
       
    76 void CUpnpIPEventNotifier::DoCancel()
       
    77     {
       
    78     iProperty.Cancel();
       
    79     }
       
    80     
       
    81 // ---------------------------------------------------------------------------
       
    82 // CUpnpIPEventNotifier::Subscribe
       
    83 // ---------------------------------------------------------------------------
       
    84 //    
       
    85 void CUpnpIPEventNotifier::Subscribe( MUpnpIPEventObserver* aObserver )
       
    86     {
       
    87     iObserver = aObserver; 
       
    88 	if(!IsActive())
       
    89 		{
       
    90 		iProperty.Subscribe( iStatus );
       
    91 	    SetActive();        
       
    92 		}
       
    93     }
       
    94     
       
    95 // ---------------------------------------------------------------------------
       
    96 // CUpnpIPEventNotifier::RunL
       
    97 // ---------------------------------------------------------------------------
       
    98 //    
       
    99 void CUpnpIPEventNotifier::RunL()
       
   100     {
       
   101     if ( iStatus.Int() == KErrNone ) 
       
   102         {
       
   103         iProperty.Subscribe( iStatus );
       
   104         SetActive();        
       
   105         iObserver->IPEventOccursL();        
       
   106         }    
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CUpnpIPEventNotifier::RunError
       
   111 // ---------------------------------------------------------------------------
       
   112 //  
       
   113 TInt CUpnpIPEventNotifier::RunError( TInt /*aErr*/ )
       
   114     {
       
   115     LOG_FUNC_NAME;
       
   116     return KErrNone;
       
   117     }
       
   118