IMPSengine/ImpsIpCirWatcher/ImpsUdpIpCirWatcher/inc/UdpCirWatcher.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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: CirWatcher for UDP
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __UDPCIRWATCHER__
       
    21 #define __UDPCIRWATCHER__
       
    22 
       
    23 // INCLUDES
       
    24 #include <in_sock.h>
       
    25 #include <es_sock.h>
       
    26 #include "ImpsIpCirWatcherAPI.h"
       
    27 
       
    28 
       
    29 
       
    30 //FORWARD DECLARATIONS
       
    31 class CUdpSocketListener;
       
    32 class MImpsConnectionManager;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 class CUdpCirWatcher : public CImpsUdpCirWatcher
       
    36 
       
    37     {
       
    38     public:  // Constructors and destructor
       
    39 
       
    40         /**
       
    41         * Symbian OS default constructor.
       
    42         * @param aPingInterval Interval of the ping requests
       
    43         * @param aConnManager Reference to the active connection manager
       
    44         */
       
    45         static CUdpCirWatcher* NewL();
       
    46 
       
    47         /**
       
    48         * Symbian OS default constructor.
       
    49         * @param aPingInterval Interval of the ping requests
       
    50         * @param aConnManager Reference to the active connection manager
       
    51         */
       
    52         void RegisterCirReceiverL( const MImpsCirReceiver& aCirReceiver,
       
    53                                    const TInt aServicePort = KDefaultUDPPortNumber );
       
    54 
       
    55         /**
       
    56         * Symbian OS default constructor.
       
    57         * @param aPingInterval Interval of the ping requests
       
    58         * @param aConnManager Reference to the active connection manager
       
    59         */
       
    60         void UnregisterCirReceiverL( const MImpsCirReceiver& aCirReceiver );
       
    61 
       
    62         /**
       
    63         * Reset all watchers on a specified port. By default resets
       
    64         * all watchers on all ports!
       
    65         * @param TInt The port to reset; by default all ports
       
    66         * @return void
       
    67         */
       
    68         void Reset( const TInt aServicePort = KErrArgument );
       
    69 
       
    70         /**
       
    71         * Symbian OS default constructor.
       
    72         * @param aPingInterval Interval of the ping requests
       
    73         * @param aConnManager Reference to the active connection manager
       
    74         */
       
    75         virtual void DeleteSingleton();
       
    76 
       
    77         /**
       
    78         * Symbian OS default constructor.
       
    79         * @param aPingInterval Interval of the ping requests
       
    80         * @param aConnManager Reference to the active connection manager
       
    81         */
       
    82         virtual void Destroy();
       
    83 
       
    84         /**
       
    85         * Destructor.
       
    86         */
       
    87         virtual ~CUdpCirWatcher();
       
    88 
       
    89     public:   //New functions
       
    90 
       
    91         /**
       
    92         * Symbian OS default constructor.
       
    93         * @param aPingInterval Interval of the ping requests
       
    94         * @param aConnManager Reference to the active connection manager
       
    95         */
       
    96         static void WriteToLog( TRefByValue<const TDesC8> aFmt, ... );
       
    97 
       
    98     private:
       
    99 
       
   100         /**
       
   101         * Symbian OS second-phase constructor.
       
   102         */
       
   103         void ConstructL();
       
   104 
       
   105         /**
       
   106         * C++ default constructor is private
       
   107         */
       
   108         CUdpCirWatcher();
       
   109 
       
   110         /**
       
   111         * C++ default constructor is private
       
   112         */
       
   113         void DeleteLogFileL();
       
   114 
       
   115         /**
       
   116         * Increase the number of clients for this singleton
       
   117         * @return void
       
   118         */
       
   119         void IncreaseReferenceCount();
       
   120 
       
   121         /**
       
   122         * Return the current reference count for the singleton object.
       
   123         * Comes in handy at least in testing.
       
   124         * @return TInt Current reference count
       
   125         */
       
   126         void DecreaseReferenceCount();
       
   127 
       
   128         /**
       
   129         * Return the current reference count for the singleton object.
       
   130         * Comes in handy at least in testing.
       
   131         * @return TInt Current reference count
       
   132         */
       
   133         const TInt ReferenceCount() const;
       
   134 
       
   135         /**
       
   136         * Return the current reference count for the singleton object.
       
   137         * Comes in handy at least in testing.
       
   138         * @return TInt Current reference count
       
   139         */
       
   140         void StoreDestructorKeyL( const TUid aDestructorKey );
       
   141 
       
   142         /**
       
   143         * Symbian OS default constructor.
       
   144         * @param aPingInterval Interval of the ping requests
       
   145         * @param aConnManager Reference to the active connection manager
       
   146         */
       
   147         TBool FindListenerL( const TInt aServicePort,
       
   148                              const MImpsCirReceiver& aCirReceiver );
       
   149 
       
   150         /**
       
   151         * Symbian OS default constructor.
       
   152         * @param aPingInterval Interval of the ping requests
       
   153         * @param aConnManager Reference to the active connection manager
       
   154         */
       
   155         CUdpSocketListener* FindListener( TInt& aIndex,
       
   156                                           const TInt aServicePort ) const;
       
   157 
       
   158         /**
       
   159         * Symbian OS default constructor.
       
   160         * @param aPingInterval Interval of the ping requests
       
   161         * @param aConnManager Reference to the active connection manager
       
   162         */
       
   163         TInt CreateListenerL( const TInt aServicePort,
       
   164                               const MImpsCirReceiver& aCirReceiver );
       
   165 
       
   166     private: //Data
       
   167 
       
   168         TInt                                        iReferenceCount;
       
   169         RSocketServ                                 iSocketSession;
       
   170         RPointerArray<CUdpSocketListener>           iListenerQueue;
       
   171     };
       
   172 
       
   173 #endif
       
   174 
       
   175 // End of File