upnp/upnpstack/upnpconnmanager/inc/upnpconninterfacewatcher.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2007-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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef UPNPCONNINTERFACEWATCHER_H_
       
    19 #define UPNPCONNINTERFACEWATCHER_H_
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <in_sock.h>
       
    24 #include "upnpipeventnotifier.h"
       
    25 
       
    26 const TInt KServiceTypeMaxLength = 128;
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CUpnpIPEventNotifier;
       
    30 
       
    31 /**
       
    32  * CUpnpConnInterfaceWatcher observer (callback interface).
       
    33  * @since S60 5.0
       
    34  */
       
    35 class MUpnpConnInterfaceWatcherObserver
       
    36     {
       
    37 public:
       
    38 
       
    39     /**
       
    40      * Invoked when network interface goes down
       
    41      */
       
    42     virtual void WlanNetworkLost() = 0;
       
    43     
       
    44     /**
       
    45      * Invoked when address changes
       
    46      */
       
    47     virtual void InterfaceAddressChange( TInetAddr& aAddr ) = 0;
       
    48     
       
    49     };
       
    50 
       
    51 /**
       
    52  * Class is responsible for network interface change handling.
       
    53  * @since S60 5.0
       
    54  */
       
    55 class CUpnpConnInterfaceWatcher : public CActive, public MUpnpIPEventObserver
       
    56     {
       
    57 public:
       
    58 
       
    59     /**
       
    60      * A two-phased constructor function
       
    61      */
       
    62     static CUpnpConnInterfaceWatcher* NewL( MUpnpConnInterfaceWatcherObserver& aIfObserver,
       
    63                                             RSocketServ& aSockServ, 
       
    64                                             RConnection& aConnection );
       
    65     /**
       
    66      * Destructor
       
    67      */
       
    68     virtual ~CUpnpConnInterfaceWatcher();
       
    69 
       
    70 	/**
       
    71      * Returns inet address
       
    72      */
       
    73     const TInetAddr& LocalAddress();
       
    74     
       
    75     /**
       
    76      * Creates and subscribes to CUpnpIPEventNotifier instance
       
    77      */
       
    78     void ListenAddressChangeL( TUint aIapId );
       
    79     
       
    80     /**
       
    81      * Get local ip address
       
    82      * @param aInterfaceIndex reference that will be set to interface index
       
    83      */ 
       
    84 
       
    85     TInetAddr LocalIpAddress(TInt& aInterfaceIndex);
       
    86 
       
    87     /**
       
    88      * Subscribes to Service Change Notification from RConnection.
       
    89      * This notification completes with KErrCancel when connection
       
    90      * is stopped (by WLan Lost or by calling RConnection::Stop())
       
    91      */
       
    92     void SubscribeForConnectionServiceChangeNotifications();
       
    93 
       
    94     /**
       
    95      * Cancels pending subscription
       
    96      */
       
    97     void CancelSubscriptionForConnectionServiceChangeNotifications();
       
    98 
       
    99 private:
       
   100 
       
   101     /**
       
   102      * Constructor.
       
   103      */
       
   104     CUpnpConnInterfaceWatcher( MUpnpConnInterfaceWatcherObserver& aIfObserver, 
       
   105                                RSocketServ& aSockServ, 
       
   106                                RConnection& aConnection );
       
   107 
       
   108     /**
       
   109      * Second phase constructors
       
   110      */
       
   111     void ConstructL();
       
   112 
       
   113 private:
       
   114 
       
   115     /**
       
   116      * This function will be invoke if IP Event occurs 
       
   117      * Checks if IP address from used interface was changed since last time    
       
   118      */
       
   119     virtual void IPEventOccursL();
       
   120     
       
   121     /**
       
   122      * Sets local address
       
   123      * @param aNew address
       
   124      */    
       
   125     void SetLocalAddress( const TInetAddr& aAddress );
       
   126     
       
   127 private:    // from CActive
       
   128 
       
   129     /**
       
   130      * RunL
       
   131      * Active object state machine.
       
   132      * @since Series60 5.0 HN
       
   133      */
       
   134     void RunL();
       
   135     
       
   136     /**
       
   137      * DoCancel
       
   138      * Cancel outstanding request(s) and reset the iActive flag.
       
   139      * @since Series60 5.0 HN
       
   140      */
       
   141     void DoCancel();
       
   142     
       
   143     /**
       
   144      * RunError
       
   145      * RunError in case RunL leaves.
       
   146      * @since Series60 5.0 HN
       
   147      */
       
   148     TInt RunError( TInt aError );
       
   149     
       
   150 private:
       
   151 
       
   152     /* @var iIfObserver Callback interface */
       
   153     MUpnpConnInterfaceWatcherObserver& iIfObserver;
       
   154 
       
   155     /* @var iSockServ Socket server session */
       
   156     RSocketServ& iSockServ;
       
   157        
       
   158     /* @var iIapId IAP identifier */
       
   159     TUint iIapId;
       
   160     
       
   161     /* @var iIPEvent IP events notifier */
       
   162     CUpnpIPEventNotifier* iIPEvent;
       
   163         
       
   164     /* @var iLocalIpAddress local IP address */
       
   165     TInetAddr iLocalIpAddress;
       
   166     
       
   167     /* @var iNewISPId variable used in Service Change Notification */
       
   168     TUint32 iNewISPId;
       
   169 
       
   170     /* @var iNewServiceType variable used in Service Change Notification */
       
   171     TBuf< KServiceTypeMaxLength > iNewServiceType;
       
   172     
       
   173     /* @var iConnection RConnection reference */
       
   174     RConnection& iConnection;
       
   175     
       
   176     };
       
   177 
       
   178 #endif /*UPNPCONNINTERFACEWATCHER_H_*/