alarmui/inc/AlmAlarmControl.h
changeset 0 f979ecb2b13e
child 18 c198609911f9
child 30 d68a4b5d5885
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2006-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:   An alarm UI class, CAlmAlarmControl.
       
    15 *                This class takes care of displaying the alarm note and
       
    16 *                handling user input.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef ALMALARMCONTROL_H
       
    23 #define ALMALARMCONTROL_H
       
    24 
       
    25 
       
    26 // INCLUDES
       
    27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <uikon/eiknotifyalert.h>
       
    29 #endif
       
    30 #include "pim_trace.h"
       
    31 #include "PropertyObserver.h"
       
    32 #include "AlmAlertVariant.hrh"
       
    33 
       
    34 #include <akndialogcontroller.h>
       
    35 #include <AlarmObserver.h>
       
    36 
       
    37 #include <missedalarmstore.h>
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CAknAlarmService;
       
    41 class CAlarmUtils;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46 *  Alarm UI
       
    47 *  This class handles displaying the alarm note and playing alarm sound
       
    48 *
       
    49 *  @lib AknAlarmService.lib
       
    50 *  @since 1.0
       
    51 */
       
    52 NONSHARABLE_CLASS( CAlmAlarmControl ) : public CCoeControl,
       
    53                                         public MEikServAlarm,
       
    54                                         public MPropertyChangeHandler,
       
    55                                         public MNotifierDialogObserver
       
    56 {
       
    57  public: // Constructors and destructor
       
    58     /**
       
    59      * C++ default constructor.
       
    60      */
       
    61     CAlmAlarmControl();
       
    62 
       
    63     /**
       
    64      * Destructor.
       
    65      */
       
    66     ~CAlmAlarmControl();
       
    67 
       
    68     void ConstructL(CAknAlarmService* aSupervisor);
       
    69 
       
    70  public:  // New functions
       
    71     /**
       
    72     * Stops an active alarm.
       
    73     * Has the same effect as pressing the power key.
       
    74     * I.e. if the device was set off the startup query won't be shown.
       
    75     * @since S60 3.2
       
    76     **/
       
    77     void ExternalStopAlarm();
       
    78 
       
    79     /**
       
    80     * Snoozes an active alarm.
       
    81     * @since S60 3.2
       
    82     **/
       
    83     void ExternalSnoozeAlarm();
       
    84 
       
    85     /**
       
    86     * Handles auto-snooze operation.
       
    87     * @since S60 3.2
       
    88     */
       
    89     void DoAutoSnooze();
       
    90 
       
    91     /**
       
    92     * Query user whether power should be switched on.
       
    93     * @since S60 3.2
       
    94     */
       
    95     void AskWakeupPhoneL();
       
    96 
       
    97     /**
       
    98     * Show the snooze information note.
       
    99     * @since 3.1
       
   100     **/
       
   101     void ShowSnoozeInfoNoteL();
       
   102 
       
   103 	/**
       
   104     * Return if alarm can be snoozed.
       
   105     * @since 5.0
       
   106     **/
       
   107     TBool CanSnooze();
       
   108  private:  // New functions
       
   109     /**
       
   110      * Alarm UI Panic.
       
   111      * Only called after an irreversible error.
       
   112      * @param aReason One of the panic reasons defined in TAlarmUIPanicReason (combined with TAlarmUIFunctionInfo).
       
   113      **/
       
   114     void Panic(const TUint aReason) const;
       
   115 
       
   116     /**
       
   117      * Set internal state.
       
   118      * @since 2.0
       
   119      * @param aState New internal state
       
   120      */
       
   121     void SetState(TInt aState);
       
   122 
       
   123     /**
       
   124      * Handle custom state transitions.
       
   125      * @since 3.2
       
   126      */
       
   127     void HandleStateChange(TInt aOldState);
       
   128 
       
   129     /**
       
   130      * Get internal state.
       
   131      * @since 2.0
       
   132      * @param aState State to compare.
       
   133      * @return ETrue if aState matches the current internal state
       
   134      */
       
   135     TBool IsState(const TInt aState) const;
       
   136 
       
   137     /**
       
   138      * Cancel active dialog.
       
   139      * @since 1.0
       
   140      */
       
   141     void DoCancelDialog();
       
   142 
       
   143     /**
       
   144      * Handle interrupt request's.
       
   145      * @since 2.0
       
   146      * @param aReason One of the alarm interrupt reasons
       
   147      */
       
   148     void HandleInterruptAlarm(TInt aReason);
       
   149 
       
   150     /**
       
   151      * Stores the missed alarm data in the repository 
       
   152      * 
       
   153      */
       
   154     void StoreMissedAlarmDataL();
       
   155 
       
   156     /**
       
   157      * Checks for calendar type alarm needed to be stored as missed alarm 
       
   158      *  Stops the alarm and enters to missed alarm table. If the calendar type
       
   159      * is clock, then snoozes the alarm.
       
   160      */
       
   161 
       
   162     void StopOrSnoozeAlarm();
       
   163 
       
   164 public:  // from MEikServAlarm
       
   165     /**
       
   166      * From MEikServAlarm.
       
   167      * @since 1.0
       
   168      */
       
   169     void Release();
       
   170 
       
   171     /**
       
   172      * From MEikServAlarm.
       
   173      * @since 1.0
       
   174      */
       
   175     void ShowAlarm();
       
   176 
       
   177     /**
       
   178      * From MEikServAlarm.
       
   179      * @since 1.0
       
   180      */
       
   181     void HideAlarm();
       
   182 
       
   183     /**
       
   184      * From MEikServAlarm.
       
   185      * @since 1.0
       
   186      * Returns state of the alarm server.
       
   187      */
       
   188     TInt CurrentServerState() const;
       
   189 
       
   190     /**
       
   191      * From MEikServAlarm.
       
   192      * No implementation.
       
   193      * @since 1.0
       
   194      */
       
   195     void UpdateSoundPauseTimeInterval(TInt aMinutes);
       
   196 
       
   197     /**
       
   198      * From MEikServAlarm.
       
   199      * Updates the state of the alarm server.
       
   200      * @since 1.0
       
   201      * @param aNewAlarmServerState New state of the alarm server
       
   202      */
       
   203     void UpdateForAlarmServerState(TInt aNewAlarmServerState);
       
   204 
       
   205     /**
       
   206      * From MEikServAlarm.
       
   207      * Updates active alarm information.
       
   208      * @since 1.0
       
   209      * @param aAlarm Alarm info
       
   210      * @param aOwner Owner of the alarm. Ignored.
       
   211      */
       
   212     void UpdateAlarmInfo(const TASShdAlarm& aAlarm, const TFullName& aOwner);
       
   213 
       
   214     /**
       
   215      * From MEikServAlarm.
       
   216      * No implementation.
       
   217      * @since 1.0
       
   218      * @param aAlarmName Ignored
       
   219      */
       
   220     void StartPlayAlarmL(const TDesC& aAlarmName);
       
   221 
       
   222     /**
       
   223      * From MEikServAlarm.
       
   224      * No implementation.
       
   225      * @since 1.0
       
   226      */
       
   227     void StopPlayAlarm();
       
   228     
       
   229      /**
       
   230      * Handles the Missed Alarms Notifications from cenrep
       
   231      *
       
   232      * @since S60 5.0
       
   233      * @param aCount gets the missed alarm count
       
   234      */
       
   235     void HandleAlmInfoCRChangeL(TUint32 aCount);
       
   236     
       
   237      /**
       
   238      * Sets if StopAndExit to be sent to CFW/calendar
       
   239      * @since S60 5.0
       
   240      * @param aStopFromContext sets the missed alarm flag
       
   241      */
       
   242     void SetStopFromContext(TBool aStopFromContext);
       
   243     
       
   244     /**
       
   245      * Gets if StopAndExit to be sent to CFW/calendar
       
   246      * @since S60 5.0
       
   247      * @param None
       
   248      */
       
   249     TBool IsStopFromContext();
       
   250 
       
   251  private:  // From MPropertyChangeHandler
       
   252     /**
       
   253      * This is a callback function which is called when a property is changed.
       
   254      *
       
   255      * @param aCategory  UID of the category.
       
   256      * @param aKey       changed key
       
   257      * @param aValue     The new value.  See enumerations in PS/CR header files.
       
   258      *
       
   259      * Note! references aKey and aValue are only valid while executing
       
   260      * HandlePropertyChange(). After that the data in which they refer can change.
       
   261      **/
       
   262     void HandlePropertyChange(const TUid aCategory, const TUint aKey, const TInt aValue);
       
   263 
       
   264  private:  // from MNotifierDialogObserver
       
   265      /**
       
   266       * From MNotifierDialogObserver.
       
   267       * No implementation.
       
   268       * @since 1.0
       
   269       * @param aNoteId   Ignored
       
   270       * @param aCommand  Ignored
       
   271       */
       
   272      void NoteCompleted(TInt aNoteId, TInt aCommand);
       
   273 
       
   274      /**
       
   275       * From MNotifierDialogObserver
       
   276       * @since 1.0
       
   277       * @param aPriority
       
   278       * @return  ETrue, if we can process this request (based on the priority).
       
   279       */
       
   280      TBool DisplayDialogL(TInt aPriority);
       
   281 
       
   282      /**
       
   283       * From MNotifierDialogObserver
       
   284       * @since 1.0
       
   285       * @param aPriority
       
   286       * @return  ETrue, if we can process this request (based on the priority).
       
   287       */
       
   288      TBool CancelDialog(TInt aPriority);
       
   289 
       
   290  private:  // from CCoeControl
       
   291     /**
       
   292      * From CCoeControl.
       
   293      * Handles key events.
       
   294      * @since 1.0
       
   295      * @param aKeyEvent Key event information
       
   296      * @param aType Key event type
       
   297      * @return EKeyWasConsumed or EKeyWasNotConsumed.
       
   298      */
       
   299     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
   300 
       
   301  private:  // data
       
   302     /**
       
   303     * To observe "hide alarm" command (powerkey press) from SysAp.
       
   304     * Own.
       
   305     */
       
   306     CPropertyObserver* iPropertyHideAlarm;
       
   307 
       
   308     /**
       
   309     * To observe system state changes.
       
   310     * Own.
       
   311     */
       
   312     CPropertyObserver* iPropertySWStateValue;
       
   313 
       
   314     /**
       
   315     * To observe alarm ui stop command.
       
   316     * Own.
       
   317     */
       
   318     CPropertyObserver* iPropertyStopAlarm;
       
   319 
       
   320     /**
       
   321     * To observe alarm ui snooze command.
       
   322     * Own.
       
   323     */
       
   324     CPropertyObserver* iPropertySnoozeAlarm;
       
   325 
       
   326     /**
       
   327     * To observe the backlight setting PS Key.
       
   328     * Own.
       
   329     */
       
   330 	CPropertyObserver* iPropertyBacklight;
       
   331     // resource file
       
   332     TInt iResOffset;
       
   333 
       
   334     // Id of an active global note. KErrNotFound when not active.
       
   335     TInt iGlobalNoteId;
       
   336 
       
   337     // Current state of the alarm server. Not used in AlarmUI.
       
   338     TInt iCurrentServerState;
       
   339 
       
   340     TInt iState;  // Holds the current internal state
       
   341     enum  // AlmAlert internal states
       
   342     {
       
   343         EStateIdle = 1,               // no pending actions
       
   344         EStateWaitingShowRequest,     // alarm info accuired...waiting for request to show the alarm
       
   345         EStateWaitingDisplayRequest,  // alarm ready and pushed to global note queue...waiting for request to display the dialog
       
   346         EStateWaitingInput,           // waiting for user input...auto-snooze timer running
       
   347         EStateBeforeAskingWakeup,     // used to allow allow AskWakeupPhoneL() to cancel the dialog...see CancelDialog()...
       
   348         EStateAskingWakeup,           // only for clock alarms...when phone is off or in charging state...after user selects stop...asking to turn the phone on
       
   349         EStateAfterInput,             // Alarm already handled...Waiting for HideAlarm() or UpdateAlarmInfo()
       
   350         EStateShowingSnoozeInfo       // Showing (or about to show) the snooze info note.  This state maybe overridden with EStateWaitingShowRequest by an expiring alarm during the info note.  The new alarm is shown as soon as the info note has been handled.
       
   351     };
       
   352 
       
   353     enum  // Alarm interrupt reasons
       
   354     {
       
   355         EReasonKSysApHideAlarm = 1  // System request (power button)
       
   356     };
       
   357 
       
   358     // Set to ETrue only if device is in "alarm" or "charging" mode and an alarm was stopped.
       
   359     TBool iAskWakeup;
       
   360 
       
   361     // Only used to delay showing any alarms while showing the snooze info note.
       
   362     TBool iSnoozeInfoNoteActive;
       
   363 
       
   364     /**
       
   365     * An alarm utility class.
       
   366     * Own.
       
   367     */
       
   368     CAlarmUtils* iAlarmUtils;
       
   369 
       
   370     // To send Stop/StopAndExit to CFW to exit the opened calendar view.
       
   371     TBool iStopFromContextFw;
       
   372 };
       
   373 
       
   374 #endif  // ALMALARMCONTROL_H
       
   375 
       
   376 
       
   377 // End of File