uifw/AvKon/inc/aknstatuspanedatasubscriber.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Avkon internal subscriber for the system controlled and 
       
    15 *                published status pane data.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_AKNSTATUSPANEDATASUBSCRIBER_H
       
    21 #define C_AKNSTATUSPANEDATASUBSCRIBER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <e32property.h>
       
    27 #include <coecntrl.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CActive;
       
    31 class CAknStatusPaneSubscriberData;
       
    32 class MAknStatusPaneDataObserver;
       
    33 
       
    34 /**
       
    35  *
       
    36  * This class is subscriber for the system controlled
       
    37  * and published status pane data.
       
    38  *
       
    39  * @since S60 3.2
       
    40  *
       
    41  * @internal
       
    42  */
       
    43 NONSHARABLE_CLASS( CAknStatusPaneDataSubscriber ) : public CActive
       
    44 	{
       
    45 public: 
       
    46 
       
    47     DECLARE_TYPE_ID(0x102823DA) 
       
    48 
       
    49 	/**
       
    50      * Two-phased constructor.
       
    51      */
       
    52     IMPORT_C static CAknStatusPaneDataSubscriber* NewL();
       
    53      
       
    54     /**
       
    55      * Destructor.
       
    56      */
       
    57     ~CAknStatusPaneDataSubscriber();        
       
    58 
       
    59     /**
       
    60      * Sets a flag to indicate that when this subscriber is in foreground it
       
    61      * does not indicate itself as foreground subscriber, thus allowing the
       
    62      * previous foreground subscriber still to be updated normally.
       
    63      * If this flag is set, then @c iForceBackgroundRefresh should be set to
       
    64      * @c ETrue to allow this subscriber to receive updates in the background.
       
    65      * 
       
    66      * @param  aAlwaysBackground  @c ETrue if this subscriber
       
    67      *                            remains always in the background.
       
    68      */
       
    69     IMPORT_C void SetAlwaysBackground( TBool aAlwaysBackground ); 
       
    70 
       
    71     /**
       
    72      * Refreshes status pane data.
       
    73      */
       
    74     IMPORT_C void RefreshDataL();
       
    75 
       
    76 	enum
       
    77 		{
       
    78 		ERefreshLevelNone   = 0x10,			
       
    79 		ERefreshLevelMedium = 0x20,
       
    80 		ERefreshLevelHigh   = 0x30
       
    81 		};
       
    82 		
       
    83     /**
       
    84      * Sets the refresh level.
       
    85      *
       
    86   	 * @param  aLevel   Refresh level to be set.
       
    87   	 * @param  aForced  @c ETrue to force the level to be set or
       
    88   	 *                  to override a level that has been forced.
       
    89      */
       
    90     IMPORT_C void SetRefreshLevel( TInt aLevel, TBool aForced ); 
       
    91 
       
    92     /**
       
    93      * Gets the refresh level.
       
    94      *
       
    95   	 * @return  Refresh level
       
    96      */
       
    97 	IMPORT_C TInt RefreshLevel();
       
    98 
       
    99     /**
       
   100      * Gets the id of the subscriber in the foreground currently.
       
   101      *
       
   102   	 * @return  Id of the foreground status pane.
       
   103      */
       
   104     TInt ForegroundSubscriberId() const; 
       
   105 
       
   106     /**
       
   107      * Sets the id of the subscriber in the foreground currently.
       
   108      *
       
   109 	 * @param  aId  Id of the foreground status pane sync service subscriber.
       
   110      */
       
   111     void SetForegroundSubscriberId( TInt aId ); 
       
   112 
       
   113     /**
       
   114      * Gets the id of this subscriber.
       
   115      *
       
   116      * @return  Id of the status pane sync service subscriber.
       
   117      */
       
   118     TInt SubscriberId() const; 
       
   119 
       
   120     /**
       
   121      * Returns @c ETrue if this subscriber is in the foreground. 
       
   122      *
       
   123 	 * @return @c ETrue if this is in the foreground, otherwise @c EFalse.
       
   124      */
       
   125     TBool IsBackground() const; 
       
   126 
       
   127     /**
       
   128      * Adds observer which will be notified when status pane data has changed.
       
   129      *
       
   130      * @param  aObserver  An observer that is to be added.
       
   131      */
       
   132 	void AddObserver( MAknStatusPaneDataObserver* aObserver );
       
   133 
       
   134     /**
       
   135      * Removes observer.
       
   136      *
       
   137      * @param  aObserver  An observer that is to be added.
       
   138      */
       
   139 	void RemoveObserver( MAknStatusPaneDataObserver* aObserver );
       
   140     
       
   141     /**
       
   142      * Handles the the situation where status pane comes
       
   143      * to foreground.
       
   144      */
       
   145     IMPORT_C void HandleGainingForeground();
       
   146 
       
   147     /**
       
   148      * Handles the the situation where status pane loses foreground.
       
   149      */       
       
   150     IMPORT_C void HandleLosingForeground();
       
   151 
       
   152 private: // From @c CActive
       
   153     
       
   154     /**
       
   155      * Executes when serverside publishes data update.
       
   156      */
       
   157     void RunL();
       
   158 
       
   159     /**
       
   160    	 * Cancels subscription to data update notifications.
       
   161      */
       
   162     void DoCancel();
       
   163 
       
   164     /**
       
   165 	 * Handles error situation of the property subscribtions.
       
   166      */
       
   167     TInt RunError( TInt aError );
       
   168 
       
   169 private:
       
   170 
       
   171 	/**
       
   172      * Private 2nd phase constructor.
       
   173      */
       
   174     void ConstructL();
       
   175 
       
   176     /**
       
   177      * Standard constructor
       
   178      */
       
   179     CAknStatusPaneDataSubscriber();
       
   180  
       
   181     /**
       
   182      * Subscribes to the property that contains the serverside data.
       
   183      */
       
   184     void DoSubscribe();   
       
   185         
       
   186 private:
       
   187 
       
   188 	/** Property for status pane state data. */
       
   189     RProperty iProperty;
       
   190 			
       
   191 	/**
       
   192 	 * Flag to indicate that when this subscriber is in foreground it does not
       
   193 	 * indicate itself as foreground subscriber, thus allowing the previous
       
   194 	 * foreground subscriber still to be updated. If this flag is set, then
       
   195 	 * @c iForceBackgroundRefresh should be set to @c ETrue to allow this
       
   196 	 * subscriber to receive updates in the background.
       
   197 	 */
       
   198 	TBool iAlwaysBackground;	
       
   199 
       
   200 	/** Describes the level of the status pane controls are updates. */
       
   201 	TInt  iRefreshLevel;
       
   202 
       
   203 	/** A flag to tell if refresh level has been forced or not. */	
       
   204 	TBool iForcedRefreshLevel;
       
   205 	
       
   206 	/** Unique id of this subscriber. */
       
   207 	TInt iSubscriberId;
       
   208 	
       
   209 	/** Data structure to hold status pane state data. */
       
   210 	CAknStatusPaneSubscriberData* iStatusPaneStateData;
       
   211 	
       
   212 	/** Array of subscriber observers. */
       
   213 	RPointerArray<MAknStatusPaneDataObserver> iObservers; 
       
   214 		
       
   215 	class TWsEventObserver;
       
   216 	friend class TWsEventObserver;
       
   217 	
       
   218 	/** Owned window server event observer */
       
   219 	TWsEventObserver* iObserver;	
       
   220 	
       
   221 	/**
       
   222 	 * A flag determining whether or not this subscriber is the
       
   223 	 * foreground subscriber.
       
   224 	 */
       
   225 	TBool iIsForeground;
       
   226 		
       
   227   };
       
   228 
       
   229 #endif // C_AKNSTATUSPANEDATASUBSCRIBER_H