wvuing/IMPSConnectionUI/NotifySrc/CIMPSConnUiConnectionModeNotifierImp.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Connection mode notifier implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CIMPSCONNUICONNECTIONMODENOTIFIERIMP_H
       
    19 #define __CIMPSCONNUICONNECTIONMODENOTIFIERIMP_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Base.h>
       
    23 #include <impspresenceconnectionuiconstsng.h>
       
    24 #include <PEngPresenceEngineConsts2.h>
       
    25 #include "MCnUiConnModeHandler.h"
       
    26 #include "RGenericObserverArray.h"
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MIMPSConnUiConnectionModeObserver;
       
    31 class CIMPSConnUiConnectionModeNotifier;
       
    32 class CIMPSConnUiConnectionModeNotifierImp;
       
    33 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 /**
       
    37  * CIMPSConnUiConnectionModeNotifierImp.
       
    38  * Implements the event notifier features.
       
    39  *
       
    40  * @since 3.0
       
    41  */
       
    42 NONSHARABLE_CLASS( CIMPSConnUiConnectionModeNotifierImp ) :
       
    43         public CBase,
       
    44         public MCnUiConnModeObserver,
       
    45         public MGenObserverNotifyMediator < MIMPSConnUiConnectionModeObserver,
       
    46         TIMPSConnectionModeEvent >
       
    47     {
       
    48 public:  // Two-phased constructor and destructor
       
    49 
       
    50     /**
       
    51      * Two-phased constructor.
       
    52      * Constructs client filtered version of
       
    53      * event notifier implementation.
       
    54      */
       
    55     static CIMPSConnUiConnectionModeNotifierImp* NewL(
       
    56         CIMPSConnUiConnectionModeNotifier& aInterface,
       
    57         TIMPSConnectionClient aClient );
       
    58 
       
    59 
       
    60     /**
       
    61      * Destructor.
       
    62      */
       
    63     ~CIMPSConnUiConnectionModeNotifierImp();
       
    64 
       
    65 
       
    66 private:
       
    67 
       
    68     /**
       
    69      * C++ constructor.
       
    70      */
       
    71     CIMPSConnUiConnectionModeNotifierImp( CIMPSConnUiConnectionModeNotifier& aInterface,
       
    72                                           TIMPSConnectionClient aClient );
       
    73 
       
    74 
       
    75     /**
       
    76      * Symbian OS constructor.
       
    77      */
       
    78     void ConstructL();
       
    79 
       
    80 
       
    81 public:  //Implementation methods for public APIs
       
    82 
       
    83     /**
       
    84      * Implements notify start.
       
    85      *
       
    86      * @since 3.0
       
    87      */
       
    88     void StartL();
       
    89 
       
    90 
       
    91     /**
       
    92      * Implements notify stop.
       
    93      *
       
    94      * @since 3.0
       
    95      */
       
    96     void Stop();
       
    97 
       
    98 
       
    99     /**
       
   100      * Implements add observer.
       
   101      *
       
   102      * @since 3.0
       
   103      * @param aObserver The observer to add.
       
   104      */
       
   105     void AddObserverL( MIMPSConnUiConnectionModeObserver* aObserver );
       
   106 
       
   107 
       
   108     /**
       
   109      * Implements remove observer.
       
   110      *
       
   111      * @since 3.0
       
   112      * @param aObserver The observer to remove.
       
   113      * @return KErrNone if observer was found, else KErrNotFound.
       
   114      */
       
   115     TInt RemoveObserver( MIMPSConnUiConnectionModeObserver* aObserver );
       
   116 
       
   117 
       
   118     /**
       
   119      * Implements connection mode get.
       
   120      *
       
   121      * @since 3.0
       
   122      * @param aModeEventCateqory event category
       
   123      * @return Current connection mode.
       
   124      */
       
   125     TIMPSConnectionModeEvent ConnectionModeByCategoryL(
       
   126         TIMPSConnectionModeEvent aModeEventCateqory );
       
   127 
       
   128 
       
   129 public: //Observation method from MCnUiConnModeObserver
       
   130 
       
   131 
       
   132     /**
       
   133      * Observation method to get events from client
       
   134      * specific connection mode changes.
       
   135      *
       
   136      * Forwards events to reqistered
       
   137      * MIMPSConnUiConnectionModeObserver observers.
       
   138      *
       
   139      * @since 3.0
       
   140      */
       
   141     void HandleConnModeChange( TIMPSConnectionClient aRequestedClient,
       
   142                                TIMPSConnectionModeEvent aConnMode );
       
   143 
       
   144 
       
   145 private:  // Helper methods
       
   146 
       
   147     /**
       
   148      * Helper method implementing
       
   149      * real notify start.
       
   150      *
       
   151      * @since 3.0
       
   152      */
       
   153     void DoStartL();
       
   154 
       
   155 
       
   156     /**
       
   157      * Helper method to implementing
       
   158      * real notify stop.
       
   159      *
       
   160      * @since 3.0
       
   161      */
       
   162     void DoStop();
       
   163 
       
   164 
       
   165     /**
       
   166      * Called in notifier destructor.
       
   167      *
       
   168      * Sets the dying flag on (prevents further starting the
       
   169      * notifier and error and event notifying) Stops the notifier
       
   170      * if running.
       
   171      *
       
   172      * @since 3.0
       
   173      */
       
   174     void Dying();
       
   175 
       
   176 
       
   177     /**
       
   178      * Notifies registered observers from given presence event.
       
   179      * If notifier isn't running,
       
   180      * ignores given presence event.
       
   181      *
       
   182      * @since 3.0
       
   183      * @param aEvent The event to notify.
       
   184      */
       
   185     void NotifyObserversFromEvent( TIMPSConnectionModeEvent aEvent );
       
   186 
       
   187 
       
   188     /**
       
   189      * Notifies registered observers from given error.
       
   190      *
       
   191      * If notifier isn't running, ignores given error.
       
   192      *
       
   193      * Before notifying the error,
       
   194      * the notifier is stopped. (Client can restart
       
   195      * the notifier in the error callback.)
       
   196      *
       
   197      * @since 3.0
       
   198      * @param aError The error to report.
       
   199      */
       
   200     void StopAndNotifyObserversFromError( TInt aError );
       
   201 
       
   202 
       
   203 private: //Notify mediators from MGenObserverNotifyMediator
       
   204 
       
   205     /**
       
   206      * Implements the observer notification.
       
   207      *
       
   208      * @since 3.0
       
   209      * @param aObserverToNotify The observer to notify.
       
   210      * @param aNotifyData The notify data.
       
   211      */
       
   212     void MediateNotifyL( MIMPSConnUiConnectionModeObserver& aObserverToNotify,
       
   213                          TIMPSConnectionModeEvent& aNotifyData );
       
   214 
       
   215 
       
   216     /**
       
   217      * Observer notification from error.
       
   218      *
       
   219      * @since 3.0
       
   220      * @param aObserverToNotify The notified observer which leaved.
       
   221      * @param aLeaveError The propagated leave code.
       
   222      */
       
   223     void MediateNotifyError( MIMPSConnUiConnectionModeObserver& aObserverToNotify,
       
   224                              TInt aLeaveError );
       
   225 
       
   226 
       
   227     /**
       
   228      * Observer notification from error.
       
   229      *
       
   230      * @since 3.0
       
   231      * @param aObserverToNotify The observer to notify.
       
   232      * @param aError The error.
       
   233      */
       
   234     void MediateError( MIMPSConnUiConnectionModeObserver& aObserverToNotify,
       
   235                        TInt aError );
       
   236 
       
   237 
       
   238 
       
   239 private: //Data
       
   240 
       
   241     ///< Reference to owning interface, interface not owned
       
   242     CIMPSConnUiConnectionModeNotifier&  iInterface;
       
   243 
       
   244     /// Client for which to deliver mode events, owned
       
   245     const TIMPSConnectionClient         iClient;
       
   246 
       
   247     /// Connection mode handler to get notifications, owned
       
   248     MCnUiConnModeHandler*               iConnModeHandler;
       
   249 
       
   250     ///< Observer array, array owned, observers not
       
   251     RGenericObserverArray < MIMPSConnUiConnectionModeObserver,
       
   252     TIMPSConnectionModeEvent > iObserverArray;
       
   253 
       
   254     ///< Flags describing the notifier state, owned
       
   255     ///< Flag contents are either EFalse or ETrue
       
   256     TInt8   iStarted;
       
   257     TInt8   iDying;
       
   258     TInt8   iReserved1;
       
   259     TInt8   iReserved2;
       
   260     };
       
   261 
       
   262 #endif      //__CIMPSCONNUICONNECTIONMODENOTIFIERIMP_H
       
   263 //  End of File
       
   264 
       
   265