idlefw/plugins/devicestatus/inc/ainetworkinfolistener.h
changeset 0 79c6a41cd166
child 9 d0529222e3f0
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     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:  Network info listener.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AINETWORKINFOLISTENER_H
       
    20 #define C_AINETWORKINFOLISTENER_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <NWHandlingEngine.h>
       
    25 
       
    26 
       
    27 class MAiNetworkInfoObserver;
       
    28 class CNWSession;
       
    29 
       
    30 /**
       
    31  *  @ingroup group_devicestatusplugin
       
    32  *
       
    33  *  Network info listener.
       
    34  *
       
    35  *  Client can use this object to listen network info changes. Client must implement
       
    36  *  MAiNetworkInfoObserver interface to retrieve network info change events.
       
    37  *
       
    38  *  @since S60 3.2
       
    39  */
       
    40 class CAiNetworkInfoListener : public CBase, public MNWMessageObserver
       
    41     {
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Get pointer to network info listener.
       
    46      * When this is called first time, object is created, later calls
       
    47      * gets pointer to previously created object.
       
    48      *
       
    49      * @since S60 3.2
       
    50      * @return pointer to network info listener.
       
    51      */
       
    52     static CAiNetworkInfoListener* InstanceL();
       
    53 
       
    54     /**
       
    55      * Release network info listener.
       
    56      * This must be called when client doesn't listen network info
       
    57      * changes anymore. When all of the listener instances are released,
       
    58      * the object is destroyed. After client calls this method, the pointer
       
    59      * returned by InstanceL must not be used anymore.
       
    60      *
       
    61      * @since S60 3.2
       
    62      * @param ?arg1
       
    63      * @param ?arg2
       
    64      * @return
       
    65      */
       
    66     void Release();
       
    67 
       
    68     /**
       
    69      * Add network info observer.
       
    70      *
       
    71      * @since S60 3.2
       
    72      * @param aObserver is interface which is used to inform network info changes.
       
    73      */
       
    74     void AddObserverL( MAiNetworkInfoObserver& aObserver );
       
    75 
       
    76     /**
       
    77      * Remove network info observer.
       
    78      *
       
    79      * @since S60 3.2
       
    80      * @param aObserver must be exactly same object as was given to AddObserverL call.
       
    81      */
       
    82     void RemoveObserver( MAiNetworkInfoObserver& aObserver );
       
    83 
       
    84     /**
       
    85      * Get cached network info structure.
       
    86      * When network info changes, it is stored in this listener, client can use this
       
    87      * method to receive the latest network info.
       
    88      *
       
    89      * @since S60 3.2
       
    90      * @return latest network info structure.
       
    91      */
       
    92     const TNWInfo& NetworkInfo() const;
       
    93 
       
    94     /**
       
    95      * Is the operator indicator allowed to be shown.
       
    96      * 
       
    97      * @since S60 v3.2
       
    98      * @return ETrue if the indicator can be shown.
       
    99      */
       
   100     TBool IsOperatorIndicatorAllowed() const;
       
   101     
       
   102     /**
       
   103      * Client can use this method to check if certain network message has been already
       
   104      * received.
       
   105      *
       
   106      * @since S60 3.2
       
   107      * @param aMessage is type of the message.
       
   108      * @return ETrue if the message has been received.
       
   109      */
       
   110     TBool MessageReceived( MNWMessageObserver::TNWMessages aMessage );
       
   111 
       
   112     /**
       
   113      * Check if it's allowed to show operator indicator.
       
   114      * Number of rules control operator indicator visibility. 
       
   115      * Parameter aMessage is used for fulfilling these rules - it can have
       
   116      * various values so this method is called many times. The sum of the
       
   117      * calls (and thus sum of different aMessage values) defines whether
       
   118      * rules are fulfilled and indicator is shown.
       
   119      * @param aMessage Network message 
       
   120      * @return ETrue if rules are not fulfilled and indicator should 
       
   121      *                  not be shown.
       
   122      */
       
   123 	TBool NotAllowedToDisplayOperatorIndicator( const TNWMessages aMessage );
       
   124 	
       
   125 	/**
       
   126 	 * Check if network info has been changed.
       
   127 	 * @param aMessage Network message
       
   128 	 * @return ETrue if network info has changed since last check.
       
   129 	 */
       
   130 	TBool HasNetworkInfoChanged( const TNWMessages aMessage );
       
   131 	
       
   132 
       
   133 // from base class MNWMessageObserver
       
   134 
       
   135     /**
       
   136      * From MNWMessageObserver.
       
   137      * Called by network handling engine when network info changes.
       
   138      *
       
   139      * @since S60 3.2
       
   140      * @param aMessage is type of the change.
       
   141      */
       
   142     void HandleNetworkMessage( const TNWMessages aMessage );
       
   143 
       
   144     /**
       
   145      * From MNWMessageObserver.
       
   146      * Called fi network handling engine fails.
       
   147      *
       
   148      * @since S60 3.2
       
   149      * @param aOperation is failed operation.
       
   150      * @param aErrorCode is fail reason.
       
   151      */
       
   152     void HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode );
       
   153 
       
   154 private:
       
   155 
       
   156     CAiNetworkInfoListener();
       
   157 
       
   158     void ConstructL();
       
   159 
       
   160     ~CAiNetworkInfoListener();
       
   161 
       
   162     /**
       
   163      * Increase access count.
       
   164      */
       
   165     TInt IncAccessCount();
       
   166 
       
   167     /**
       
   168      * Decrease access count, when this goes to zero, object is deleted.
       
   169      */
       
   170     TInt DecAccessCount();
       
   171 
       
   172 private: // data
       
   173 
       
   174     /**
       
   175      * Array of observers.
       
   176      * Not own.
       
   177      */
       
   178     RArray<MAiNetworkInfoObserver*> iObservers;
       
   179 
       
   180     /**
       
   181      * Session to network handling engine.
       
   182      * Own.
       
   183      */
       
   184     CNWSession* iSession;
       
   185 
       
   186     /**
       
   187      * Cached network info structure.
       
   188      */
       
   189     TNWInfo iInfo;
       
   190 	
       
   191 	/**
       
   192 	 * Previous network information.
       
   193 	 */
       
   194     TNWInfo iOldInfo;
       
   195     
       
   196     /**
       
   197      * Message cache. There is only one instance of one type of message.
       
   198      * Own.
       
   199      */
       
   200     CArrayFixFlat<MNWMessageObserver::TNWMessages>* iMessageCache;
       
   201 
       
   202     /**
       
   203      * Sorting rule.
       
   204      */
       
   205     TKeyArrayFix iKeyProperties;
       
   206 
       
   207     /**
       
   208      * Access count.
       
   209      */
       
   210     TInt iAccessCount;
       
   211     
       
   212     /**
       
   213      * Network related message flags
       
   214      */
       
   215     enum TNetInfoFlags 
       
   216     	{
       
   217         ENetworkProviderNameReceived      = 0x00000001,
       
   218         ENetworkProviderNameOk            = 0x00000002,
       
   219         EServiceProviderNameReceived      = 0x00000004,
       
   220         EServiceProviderNameOk            = 0x00000008,
       
   221         ERegistrationStatusReceived       = 0x00000010,
       
   222         ENetworkInfoChangeReceived        = 0x00000020,
       
   223         EProgrammableOperatorInfoReceived = 0x00000040,
       
   224         EProgrammableOperatorInfoReceivedOk = 0x00000080
       
   225         };
       
   226         
       
   227 	/**
       
   228      * Subset of sum of TNetInfoFlags.
       
   229      */    
       
   230     TUint iReceivedMessageFlags;
       
   231     
       
   232     /**
       
   233      * Subset of sum of old TNetInfoFlags.
       
   234      */    
       
   235     TUint iOldReceivedMessageFlags;
       
   236     
       
   237     /**
       
   238      * Is the operator indicator allowed to show
       
   239      */
       
   240     TBool iShowOpInd;
       
   241     };
       
   242     
       
   243 
       
   244 
       
   245 #endif // C_AINETWORKINFOLISTENER_H