camerauis/cameraapp/generic/inc/camflashstatus.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 
       
     2 #ifndef CAMFLASHSTATUS_H
       
     3 #define CAMFLASHSTATUS_H/*
       
     4 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     5 * All rights reserved.
       
     6 * This component and the accompanying materials are made available
       
     7 * under the terms of "Eclipse Public License v1.0"
       
     8 * which accompanies this distribution, and is available
       
     9 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    10 *
       
    11 * Initial Contributors:
       
    12 * Nokia Corporation - initial contribution.
       
    13 *
       
    14 * Contributors:
       
    15 *
       
    16 * Description:  Header file for CCamFlashStatus class.
       
    17 *
       
    18 *  Copyright © 2007 Nokia.  All rights reserved.
       
    19 *  This material, including documentation and any related computer
       
    20 *  programs, is protected by copyright controlled by Nokia.  All
       
    21 *  rights are reserved.  Copying, including reproducing, storing,
       
    22 *  adapting or translating, any or all of this material requires the
       
    23 *  prior written consent of Nokia.  This material also contains
       
    24 *  confidential information which may not be disclosed to others
       
    25 *  without the prior written consent of Nokia.
       
    26 *
       
    27 *
       
    28 */
       
    29 
       
    30 
       
    31 
       
    32 // ===========================================================================
       
    33 // INCLUDES
       
    34 
       
    35 #include <e32base.h>
       
    36 #include "mcamcameraobserver.h"
       
    37 
       
    38 
       
    39 // ===========================================================================
       
    40 // CONSTANTS
       
    41 
       
    42 // Flash icon blinking delay (duration of icon on/off state)
       
    43 const TInt KFlashIconBlinkDelay = 300*1000; // [microseconds]
       
    44 
       
    45 // Enumerated flash charging states. Should probably be 
       
    46 // defined in the driver's headers and included from there.
       
    47 enum TFlashChargeStatus
       
    48     {
       
    49     EFlashCharged       = 0x1,
       
    50     EFlashRequired      = 0x2,
       
    51     EFlashChargeTimeout = 0x4  
       
    52     };
       
    53 
       
    54 /*
       
    55 // Flash P&S UID & key
       
    56 #ifndef  CAMERAAPP_SIMULATE_XENON_FLASH
       
    57 const TInt KFlashPSUid = 0xA0002371;
       
    58 #else
       
    59 // Use application UID to simulate the flash charging publish
       
    60 // and subscribe property. This way, no extra capabilities are needed
       
    61 // for creating the property.
       
    62 const TInt KFlashPSUid = 0x101FFA86;
       
    63 #endif // CAMERAAPP_SIMULATE_XENON_FLASH
       
    64 const TInt KFlashPSKey = 0;
       
    65 */
       
    66 
       
    67 
       
    68 // ===========================================================================
       
    69 // FORWARD DECLARATIONS
       
    70 
       
    71 // 
       
    72 //class CCamPropertyWatcher;
       
    73 class CCamAppController;
       
    74 
       
    75 
       
    76 // ===========================================================================
       
    77 // CLASS DECLARATION
       
    78 
       
    79 /**
       
    80 * Interface to notify observer of flash icon visibility.
       
    81 * This is used to create icon blinking effect when the flash
       
    82 * is being recharged.
       
    83 */
       
    84 class MFlashStatusObserver
       
    85     {
       
    86     public:        
       
    87         /*
       
    88         * Flash icon visibility has changed.
       
    89         * @param aVisible new visibility status
       
    90         */  
       
    91         virtual void FlashIconVisible( TBool aVisible ) = 0;      
       
    92         
       
    93         /**
       
    94         * Called every time when camera driver reports error in
       
    95         * flash recharging.                
       
    96         */
       
    97         virtual void FlashError() = 0;        
       
    98         
       
    99     };
       
   100 
       
   101 /**
       
   102 * Class to handle flash status and flash error status.
       
   103 *
       
   104 * - Keeps track of the flash recharge and flash error status
       
   105 * - Creates events for visibility of the battery icon and uses
       
   106 *   this to create blinking effect when the flash is being
       
   107 *   charged
       
   108 * - Gives an event when a charging error is received from
       
   109 *   the camera driver. In this case, the UI can display
       
   110 *   an error message.
       
   111 *
       
   112 */
       
   113 class CCamFlashStatus: public CBase,
       
   114                        public MCamCameraObserver
       
   115                      //public MPropertyObserver
       
   116     {
       
   117     public: // Construction and destruction
       
   118     
       
   119         /**
       
   120         * Two-phased constructor
       
   121         */
       
   122         static CCamFlashStatus* NewL( CCamAppController& aController );
       
   123         
       
   124         /**
       
   125         * Destructor
       
   126         */
       
   127         ~CCamFlashStatus();
       
   128         
       
   129     public: // New functions
       
   130     
       
   131         /**
       
   132         * Subscribes to flash icon blink events. At one time, only one 
       
   133         * observer can be listening for the events. An observer can
       
   134         * unregister itself by giving NULL as aObserver parameter
       
   135         * value.
       
   136         * 
       
   137         * @param aObserver pointer to observer or NULL
       
   138         */
       
   139         void Subscribe( MFlashStatusObserver* aObserver );   
       
   140         
       
   141         /**
       
   142         * Returns true, if flash is fully charged, otherwise false
       
   143         */
       
   144         TBool FlashReady() const;
       
   145         
       
   146         /**
       
   147         * Returns true if there has been an error recharging the flash
       
   148         */
       
   149         TBool FlashError() const;  
       
   150         
       
   151         /**
       
   152         * Set the value returned by FlashError. This may be needed
       
   153         * before application pretended exit.
       
   154         * @param aFlashError
       
   155         */                    
       
   156         void SetFlashError( TBool aFlashError );
       
   157                                 
       
   158         /**
       
   159         * Returns true, if flash recharge error has already been
       
   160         * reported to user. This eliminates the error displayed
       
   161         * multiple times (for example, when switching between
       
   162         * image and video modes)
       
   163         */
       
   164         TBool ErrorCallbacksEnabled() const;
       
   165         
       
   166         /**
       
   167         * Enable/disable flash error callbacks. Should be set to ETrue
       
   168         * when error message is displayed to user, and to EFalse
       
   169         * during pretended application exit.
       
   170         * @param aErrorReported
       
   171         */        
       
   172         void EnableErrorCallbacks( TBool aCallbacksEnabled );                        
       
   173                         
       
   174         /**
       
   175         * Returns true, if flash icon should be displayed, false
       
   176         * otherwise. This cannot be used to determine the charging
       
   177         * status of the flash.
       
   178         */
       
   179         TBool FlashIconVisible() const;
       
   180         
       
   181     //public: // From MPropertyObserver
       
   182         /**
       
   183         * The value of a watched property has changed
       
   184         * @param aCategory The category of the property
       
   185         * @param aKey the Identifier of the property
       
   186         */    
       
   187         //void HandlePropertyChangedL( const TUid& aCategory, const TUint aKey );   
       
   188 
       
   189     public: // From MCamCameraObserver
       
   190 
       
   191         /**
       
   192         * Handle camera event
       
   193         */
       
   194         virtual void HandleCameraEventL( TInt              aStatus, 
       
   195                                          TCamCameraEventId aEventId, 
       
   196                                          TAny*             aEventData = NULL );
       
   197         
       
   198     private: 
       
   199     
       
   200         /** 
       
   201         * C++ default constructor
       
   202         */
       
   203         CCamFlashStatus( CCamAppController& aController );
       
   204         
       
   205         /**
       
   206         * Second phase constructor
       
   207         */
       
   208         void ConstructL();
       
   209 
       
   210         /**
       
   211         * Check if blinking needs to be stopped or started.
       
   212         */
       
   213         void CheckBlinkingStatus();
       
   214         
       
   215         /**
       
   216         * Start flash icon blinking timer
       
   217         */
       
   218         void StartBlinking();
       
   219         
       
   220         /**
       
   221         * Stop flash icon blinking timer, return
       
   222         * the icon to invisible state.
       
   223         */
       
   224         void StopBlinking();
       
   225 
       
   226         /**
       
   227         * Check if flash setting is off.
       
   228         * Flash not ready events are ignored if flash setting is off.
       
   229         */
       
   230         TBool IsFlashOff() const;
       
   231         
       
   232         /**
       
   233         * Notifies observer about error, if necessary
       
   234         */
       
   235         void NotifyObserverAboutFlashError();
       
   236         
       
   237         /**
       
   238         * Updates blink status of the flash icon. 
       
   239         * @param aThis
       
   240         */
       
   241         static TInt BlinkTimerCallback( TAny* aSelf );     
       
   242         
       
   243     private:      
       
   244         
       
   245         // Flash readiness to take a picture        
       
   246         TBool iFlashReady;
       
   247         
       
   248         // Flash is required to take a photo under current
       
   249         // lighting conditions.
       
   250         TBool iFlashRequired;
       
   251         
       
   252         // Flash recharging error status.
       
   253         // If set to true, there has been an error in recharging
       
   254         // the flash, and flash functionality is no more functional.
       
   255         TBool iFlashError;      
       
   256           
       
   257         // Determines whether cllabacks
       
   258         TBool iErrorCallbacksEnabled;
       
   259                 
       
   260         // Flash status observer. Typically the container where
       
   261         // the flash icon resides.
       
   262         MFlashStatusObserver* iObserver;
       
   263     
       
   264         // Timer used to create blinking effect of the flash icon
       
   265         CPeriodic* iBlinkTimer;    
       
   266         
       
   267         TBool iBlinking;
       
   268         
       
   269         // Icon visibility 
       
   270         // true - visible, EFalse - not visible
       
   271         TBool iBlinkStatus;        
       
   272         
       
   273         // Used for watching the flash P&S key
       
   274         //CCamPropertyWatcher* iFlashPropertyWatcher;
       
   275         
       
   276         // Register for Camera events through controller.
       
   277         CCamAppController& iController;
       
   278     };
       
   279 
       
   280 #endif // CAMFLASHSTATUS_H