idlehomescreen/xmluicontroller/inc/onlineofflinehelper.h
changeset 0 f72a12da539e
child 9 f966699dea19
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Helper for online/offline state handling
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef ONLINEOFFLINEHELPER_H
       
    19 #define ONLINEOFFLINEHELPER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <NWHandlingEngine.h>
       
    23 #include <MProfileChangeObserver.h>
       
    24 #include <babitflags.h>
       
    25 
       
    26 // Forward declrations
       
    27 class CNWSession;
       
    28 class CProfileChangeNotifyHandler;
       
    29 class CXnNodeAppIf;
       
    30 
       
    31 namespace AiXmlUiController
       
    32 {
       
    33 // Forward declrations
       
    34 class CXmlUiController;
       
    35 
       
    36 // Classe declaration
       
    37 
       
    38 
       
    39 /**
       
    40  * Online/offline state helper
       
    41  *
       
    42  * @ingroup group_aixmluimain
       
    43  * @lib ai3xmluimain.lib
       
    44  * @since S60 5.0
       
    45  */
       
    46 
       
    47 class COnlineOfflineHelper : public CBase, 
       
    48     public MNWMessageObserver, public MProfileChangeObserver
       
    49     {    
       
    50 public:
       
    51     // Constructors
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      */
       
    56     static COnlineOfflineHelper* NewL( CXmlUiController& aUiCtl );
       
    57     
       
    58 public:
       
    59     // Destructor
       
    60     
       
    61     ~COnlineOfflineHelper();
       
    62         
       
    63 private:
       
    64     /*
       
    65      * C++ default constructor
       
    66      */
       
    67     COnlineOfflineHelper( CXmlUiController& aUiCtl );
       
    68     
       
    69     /**
       
    70      *  2nd phase constructor
       
    71      */
       
    72     void ConstructL();    
       
    73 
       
    74 public:
       
    75     // New functions
       
    76     
       
    77     /*
       
    78      * Determines if online menuitem can be shown
       
    79      * 
       
    80      * @since S60 5.0
       
    81      * @return ETrue if item can be shown, EFalse otherwise
       
    82      */
       
    83     TBool ShowOnlineItem() const;
       
    84 
       
    85     /*
       
    86      * Determines if offline menuitem can be shown
       
    87      * 
       
    88      * @since S60 5.0
       
    89      * @return ETrue if item can be shown, EFalse otherwise
       
    90      */    
       
    91     TBool ShowOfflineItem() const;
       
    92     
       
    93     /*
       
    94      * Check and set whether online/offline state is needed by plugins
       
    95      * 
       
    96      * @since S60 5.0
       
    97      * @param aList List of plugins 
       
    98      */
       
    99     void ProcessOnlineStateL( RPointerArray< CXnNodeAppIf >& aList );
       
   100 
       
   101     /*
       
   102      * Set online or offline state based on user selection
       
   103      * 
       
   104      * @since S60 5.0
       
   105      * @param aOnline ETrue to set online, EFalse to offline 
       
   106      */    
       
   107     void ProcessOnlineStateL( TBool aOnline );
       
   108     
       
   109 private:    
       
   110     // from MNWMessageObserver
       
   111 
       
   112     /**
       
   113      * From MNWMessageObserver.
       
   114      * Called by network handling engine when network info changes.
       
   115      *
       
   116      * @since S60 5.0
       
   117      * @param aMessage is type of the change.
       
   118      */
       
   119     void HandleNetworkMessage( const TNWMessages aMessage );
       
   120 
       
   121     /**
       
   122      * From MNWMessageObserver.
       
   123      * Called if network handling engine fails.
       
   124      *
       
   125      * @since S60 5.0
       
   126      * @param aOperation is failed operation.
       
   127      * @param aErrorCode is fail reason.
       
   128      */
       
   129     void HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode );
       
   130 
       
   131 private:
       
   132     // from MProfileChangeObserver
       
   133 
       
   134     /**
       
   135      * Called when active profile changes.
       
   136      *
       
   137      * @since S60 5.0
       
   138      * @param aProfileEvent Profile event.
       
   139      * @param aProfileId New profile id.
       
   140      */
       
   141     void HandleActiveProfileEventL( TProfileEvent aProfileEvent, TInt aProfileId );
       
   142     
       
   143 private:
       
   144     // New functions
       
   145     
       
   146     TBool HasNetworkInfoChanged( const TNWMessages aMsg );
       
   147     void InterpretNWMessageL( const TNWMessages aMessage, const TNWInfo );
       
   148     
       
   149     void SetOnlineL( TBool aOnline );
       
   150 private:
       
   151     // Data types
       
   152     
       
   153     /**
       
   154      * Network related message flags
       
   155      */    
       
   156     enum TNetInfoFlags 
       
   157         {
       
   158         ENetworkProviderNameReceived        = 0x00000001,
       
   159         ENetworkProviderNameOk              = 0x00000002,
       
   160         EServiceProviderNameReceived        = 0x00000004,
       
   161         EServiceProviderNameOk              = 0x00000008,
       
   162         ERegistrationStatusReceived         = 0x00000010,
       
   163         ENetworkInfoChangeReceived          = 0x00000020,
       
   164         EProgrammableOperatorInfoReceived   = 0x00000040,
       
   165         EProgrammableOperatorInfoReceivedOk = 0x00000080
       
   166         };
       
   167     
       
   168     enum
       
   169         {
       
   170         EOnline,
       
   171         EUtilizeOnline,
       
   172         ERoamingShown,
       
   173         EOfflineProfile
       
   174         };
       
   175 private: 
       
   176     // data
       
   177     
       
   178     /**
       
   179      * UI controller
       
   180      * Not own
       
   181      */    
       
   182     CXmlUiController& iUiCtl;
       
   183     
       
   184     /**
       
   185     * Session to network handling engine.
       
   186     * Own.
       
   187     */
       
   188    CNWSession* iSession;
       
   189 
       
   190    /**
       
   191    * Profile change handler.
       
   192    * Own.
       
   193    */   
       
   194    CProfileChangeNotifyHandler* iHandler;
       
   195 
       
   196    /**
       
   197     * Cached network info structure.
       
   198     */
       
   199    TNWInfo iInfo;
       
   200    
       
   201    /**
       
   202     * Previous network information.
       
   203     */
       
   204    TNWInfo iOldInfo;
       
   205 
       
   206    /**
       
   207     * Subset of sum of TNetInfoFlags.
       
   208     */    
       
   209    TUint iReceivedMessageFlags;
       
   210    
       
   211    /**
       
   212     * Subset of sum of old TNetInfoFlags.
       
   213     */    
       
   214    TUint iOldReceivedMessageFlags;
       
   215    
       
   216    /**
       
   217     * current state of network
       
   218     */    
       
   219    TNWRegistrationStatus iCurrentNwStatus;
       
   220 
       
   221    /**
       
   222     * Flags
       
   223     */
       
   224    TBitFlags32 iFlags;
       
   225    };
       
   226 
       
   227 }// namespace AiXmlUiController
       
   228 #endif //ONLINEOFFLINEHELPER_H
       
   229 
       
   230 
       
   231 
       
   232 
       
   233