uifw/AknGlobalUI/CommonInc/aknmessagereaderlongpressdetector.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2008 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:  System soft notifications.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __AKNMESSAGEREADERLONGPRESSDETECTOR_H__
       
    20 #define __AKNMESSAGEREADERLONGPRESSDETECTOR_H__
       
    21 
       
    22 #include <coecntrl.h>
       
    23 
       
    24 class MEikButtonGroup;
       
    25 class CPeriodic;
       
    26 class CAknPhoneLockObserver;
       
    27 class CEikButtonGroupContainer;
       
    28 
       
    29 /**
       
    30 *  MAknMessageReaderLongPressDetector interface, used by CAknCapAppServerAppUi::HandleWsEventL. 
       
    31 *
       
    32 *  @lib   AknOldStyleNotif.lib
       
    33 *  @since 5.0
       
    34 */  
       
    35 class MAknMessageReaderLongPressDetector
       
    36     {
       
    37 public:    
       
    38 
       
    39     /**
       
    40     * Observe key and pointer events for long press detection
       
    41     * @param ws events received by the process
       
    42     * @param aDestionation control where wsevent is targeted at
       
    43     * @return whether ws event should be consumed or nto
       
    44     */
       
    45     virtual TBool HandleWsEventL( const TWsEvent& aEvent, 
       
    46                                   CCoeControl* aDestination ) = 0;
       
    47     };
       
    48 
       
    49 /**
       
    50 *  MAknMessageNotifierObserver interface, used by CAknSoftNotificationSubject. 
       
    51 *
       
    52 *  @lib   AknOldStyleNotif.lib
       
    53 *  @since 5.0
       
    54 */  
       
    55 class MAknMessageNotifierObserver
       
    56     {
       
    57 public:
       
    58     virtual TBool MessageNotifierShown() = 0;
       
    59     virtual CEikButtonGroupContainer* ButtonGroupContainer() = 0;
       
    60     };
       
    61         
       
    62 /**
       
    63 *  CAknMessageReaderLongPressDetector class. 
       
    64 *  Detects whether user has long pressed left soft key or not.
       
    65 *
       
    66 *  @lib   AknOldStyleNotif.lib
       
    67 *  @since 5.0
       
    68 */      
       
    69 NONSHARABLE_CLASS(CAknMessageReaderLongPressDetector): public CCoeControl, public MAknMessageReaderLongPressDetector
       
    70 {
       
    71     public: // Constructors and destructor
       
    72 
       
    73         /**
       
    74         * Two-phased constructor.
       
    75         * @param aButtonGroup soft notification dialog button group (cba)
       
    76         */
       
    77         static CAknMessageReaderLongPressDetector* NewL( CEikButtonGroupContainer* aGlobalNoteBGContainer, RWindow& aGlobalNoteWindow );
       
    78         
       
    79         /**
       
    80         * Destructor.
       
    81         */
       
    82         virtual ~CAknMessageReaderLongPressDetector();
       
    83 
       
    84         /**
       
    85         * Disable long press evaluation
       
    86         * @return ETrue if message reader has been installed on the device
       
    87         */    
       
    88         static TBool MessageReaderInstalled();
       
    89 
       
    90     
       
    91         /**
       
    92         * Soft notification is on the screen
       
    93         */
       
    94         void SoftNotifierVisible( TBool aVisible );
       
    95         
       
    96         /**
       
    97         * Phone keys are locked
       
    98         * @param aLocked ETrue if locked
       
    99         */
       
   100         void KeysLocked( TBool aLocked );
       
   101     
       
   102         /**
       
   103         * Give a access to the grouped note information
       
   104         */
       
   105         void SetMessageNotifierObserver( MAknMessageNotifierObserver* aMessageNotifierObserver );
       
   106         
       
   107    public: // from MAknMessageReaderLongPressDetector
       
   108    
       
   109         /**
       
   110         * Observe key and pointer events for long press detection
       
   111         * @param ws events received by the process
       
   112         * @param aDestionation control where wsevent is targeted at
       
   113         * @return whether ws event should be consumed or nto
       
   114         */
       
   115         TBool HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
       
   116         
       
   117     private:
       
   118 
       
   119         /**
       
   120         * C++ constructor
       
   121         * @param aButtonGroup soft notification dialog button group (cba)
       
   122         */
       
   123         CAknMessageReaderLongPressDetector( CEikButtonGroupContainer* aGlobalNoteBGContainer, RWindow& aGlobalNoteWindow );
       
   124         
       
   125         /**
       
   126         * Symbian OS 2nd phase constructor.
       
   127         */
       
   128         void ConstructL();
       
   129         
       
   130     private:
       
   131     
       
   132         /**
       
   133         * Enable long press evaluation
       
   134         */
       
   135         void Enable();
       
   136         
       
   137         /**
       
   138         * Disable long press evaluation
       
   139         */    
       
   140         void Disable();
       
   141         
       
   142     private:
       
   143     
       
   144         /**
       
   145         * Determine if left soft button has been long touched
       
   146         *
       
   147         * @param aPointerEvent received pointer event
       
   148         * @return if pointer event should be consumed
       
   149         * @param aDestionation the control where wsevent is targeted at
       
   150         */
       
   151         TBool HandleLongTouchL( const TPointerEvent& aPointerEvent, 
       
   152                                 CCoeControl* aDestination );
       
   153         
       
   154         TBool IsPointerInLeftSoftKeyRect(TPoint aPoint, CCoeControl* aDestination);
       
   155         
       
   156         /**
       
   157         * If left soft key was long pressed, launch message reader
       
   158         */
       
   159         void LaunchMessageReaderL();
       
   160         
       
   161         /**
       
   162         * Start long press timer
       
   163         */
       
   164         void StartLongPressTimerL();
       
   165         
       
   166         /**
       
   167         * Static function to be called when long press is detected
       
   168         * @param pointer to the class
       
   169         */
       
   170         static TInt ReportLongPressL( TAny* aThis );
       
   171 
       
   172         /**
       
   173         * Handle long press detection, called by ReportLongPressL
       
   174         */
       
   175         void DoReportLongPressL();    
       
   176                 
       
   177         /**
       
   178         * Stop long press timer
       
   179         */
       
   180         void StopLongPressTimer();
       
   181 
       
   182     private:
       
   183     
       
   184         // only detect long press if soft notifier is visible
       
   185         TBool iSoftNotifierVisible;
       
   186         
       
   187         // if detector has been enabled or not
       
   188         TBool iDetectorEnabled;
       
   189         
       
   190         // prevent pointer event leakage 
       
   191         TBool iIgnoreEventsUntilNextPointerUp;
       
   192         
       
   193         // for pointer presses we store pointer destination
       
   194         CCoeControl* iPointerDestination;
       
   195         
       
   196         // detects long pointer presses
       
   197         CPeriodic* iLongPressTimer;
       
   198         
       
   199         // left soft key control
       
   200         CCoeControl* iLeftSoftKeyControl;       
       
   201         
       
   202         // we create a separate phone lock observer as we do not want to 
       
   203         // couple our implementation with keylock notifier, keeps track of 
       
   204         // keyguard and devicelock status
       
   205         CAknPhoneLockObserver* iPhoneLockObserver;
       
   206 
       
   207         // Handle to the left soft key long capture        
       
   208         TInt32 iCaptureLongKeyHandle;
       
   209         
       
   210         // access to global note and grouped notes
       
   211         MAknMessageNotifierObserver* iMessageNotifierObserver;
       
   212         CEikButtonGroupContainer* iGlobalNoteBGContainer;
       
   213         RWindow& iGlobalNoteWindow;
       
   214         
       
   215         //Detect whether LSK has been keydowned
       
   216         TBool iLSKKeyDownDetect;
       
   217 };
       
   218 
       
   219 #endif  // __AKNMESSAGEREADERLONGPRESSDETECTOR_H__
       
   220 
       
   221 // End of file
       
   222 
       
   223