startupservices/startupanimation/sanimctrl/inc/sanimstartupctrl.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2007,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:  Declaration of CSAnimStartupCtrl class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SANIMSTARTUPCTRL_H
       
    20 #define SANIMSTARTUPCTRL_H
       
    21 
       
    22 #include "sanimctrl.h"
       
    23 #include <MediatorCommandInitiator.h>
       
    24 #include <MediatorCommandResponder.h>
       
    25 
       
    26 class CRepository;
       
    27 
       
    28 /**
       
    29 *  Start-up Animation UI control class with support for reading animation
       
    30 *  properties from Central Repository and synchronising wilt Secondary Display.
       
    31 *
       
    32 *  @lib sanimctrl.lib
       
    33 *  @since S60 3.2
       
    34 */
       
    35 class CSAnimStartupCtrl
       
    36   : public CSAnimCtrl,
       
    37     public MMediatorCommandObserver,
       
    38     public MMediatorCommandResponseObserver
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /**
       
    44     * Contains Central Repository keys which can be used to find out parameters
       
    45     * for the animation.
       
    46     *
       
    47     * @since S60 3.2
       
    48     */
       
    49     NONSHARABLE_CLASS( TAnimationParams )
       
    50         {
       
    51     public:
       
    52         /** Identifies the repository to use for fetching the following values. */
       
    53         TUid iRepositoryUid;
       
    54         /** Value of the key identifies the filename and path of the animation file. */
       
    55         TInt iAnimationPathKey;
       
    56         /**
       
    57         * Value of the key gives a frame delay to use unless the animation file
       
    58         * contains that information.
       
    59         */
       
    60         TInt iFrameDelayKey;
       
    61         /**
       
    62         * Value of the key indicates whether to try to scale the image to fit
       
    63         * the screen if possible.
       
    64         */
       
    65         TInt iEnableScalingKey;
       
    66         /** Value of the key identifies the filename and path of the tone file. */
       
    67         TInt iTonePathKey;
       
    68         /** Value of the key gives the volume to use for playing the tone. */
       
    69         TInt iVolumeKey;
       
    70         };
       
    71 
       
    72 public:
       
    73 
       
    74     /**
       
    75     * Constructs a CSAnimStartupCtrl object.
       
    76     *
       
    77     * @since S60 3.2
       
    78     *
       
    79     * @param aRect Rectangle designated for the control.
       
    80     * @param aContainer The compound control that is the container for this control.
       
    81     * start-up sync command (only required if secondary display is supported).
       
    82     * @return The new object
       
    83     */
       
    84     IMPORT_C static CSAnimStartupCtrl* NewL(
       
    85         const TRect& aRect,
       
    86         const CCoeControl& aContainer );
       
    87     /**
       
    88     * Destructor.
       
    89     *
       
    90     * @since S60 3.2
       
    91     */
       
    92     virtual ~CSAnimStartupCtrl();
       
    93 
       
    94     /**
       
    95     * Return ETrue if the animation has any content (image or tone).
       
    96     *
       
    97     * @since S60 3.2
       
    98     *
       
    99     * @return ETrue if the animation has any content (image or tone).
       
   100     */
       
   101     virtual TBool HasContent() const;
       
   102 
       
   103     /**
       
   104     * Load the parts of the show (image/animation and/or tone) from file(s).
       
   105     * Completes immediately with KErrNone if the show has no parts.
       
   106     * From CSAnimCtrl.
       
   107     *
       
   108     * @since S60 3.2
       
   109     *
       
   110     * @param aParams Central Repository keys for finding out details of the
       
   111     * animation.
       
   112     * @param aPlayDefaultBeep Indicates whether the default 'beep' tone should
       
   113     * be played during the animation, if the parameters do not specify a valid
       
   114     * tone file.
       
   115     * @param aSyncCommand Identifies the parameters for secondary display
       
   116     * @param aStatus Request to complete when loading is complete.
       
   117     */
       
   118     virtual void Load(
       
   119         const TAnimationParams& aParams,
       
   120         const TBool aPlayDefaultBeep,
       
   121         const TInt aSyncCommand,
       
   122         TRequestStatus& aStatus );
       
   123 
       
   124     /**
       
   125     * Send synchronization command to Secondary Display (if required) and start
       
   126     * the show (image/animation and/or tone).
       
   127     * Completes immediately with KErrNone if the show has no parts.
       
   128     * From CSAnimCtrl.
       
   129     *
       
   130     * @since S60 3.2
       
   131     *
       
   132     * @param aStatus Request to complete when all parts of the show have
       
   133     * finished.
       
   134     */
       
   135     virtual void Start( TRequestStatus& aStatus );
       
   136 
       
   137 protected:
       
   138 
       
   139     /**
       
   140     * From CCoeControl.
       
   141     * Handles pointer events.
       
   142     *
       
   143     * @since S60 5.0
       
   144     *
       
   145     * @param aPointerEvent The pointer event.
       
   146     */
       
   147     virtual void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   148 
       
   149     /**
       
   150     * MMediatorCommandObserver
       
   151     * A Mediator Service command.
       
   152     *
       
   153     * @since S60 5.0
       
   154     *
       
   155     * @param aDomain    The identifier of the domain.
       
   156     * @param aCategory  The identifier of the category.
       
   157     * @param aCommandId The identifier of the command.
       
   158     * @param aVersion   The version information of the command. Not used.
       
   159     * @param aData      The parameters of the command. Not used.
       
   160     */
       
   161     void MediatorCommandL(
       
   162         TUid aDomain,
       
   163         TUid aCategory,
       
   164         TInt aCommandId,
       
   165         TVersion aVersion,
       
   166         const TDesC8& aData );
       
   167 
       
   168     /**
       
   169     * MMediatorCommandObserver
       
   170     * Cancel a Mediator Service command.
       
   171     * Does nothing.
       
   172     *
       
   173     * @since S60 5.0
       
   174     *
       
   175     * @param aDomain    The identifier of the domain. Not used.
       
   176     * @param aCategory  The identifier of the category. Not used.
       
   177     * @param aCommandId The identifier of the command. Not used.
       
   178     */
       
   179     void CancelMediatorCommand(
       
   180         TUid aDomain,
       
   181         TUid aCategory,
       
   182         TInt aCommandId );
       
   183 
       
   184     /**
       
   185     * A response to a Mediator Service command.
       
   186     * From MMediatorCommandResponseObserver.
       
   187     *
       
   188     * @since S60 3.2
       
   189     *
       
   190     * @param aDomain The identifier of the domain
       
   191     * @param aCategory The identifier of the category.
       
   192     * @param aCommandId The identifier of the command.
       
   193     * @param aStatus Standard Symbian error code indicating the success of the command.
       
   194     * @param aData The parameters of the response.
       
   195     */
       
   196     virtual void CommandResponseL(
       
   197         TUid aDomain,
       
   198         TUid aCategory,
       
   199         TInt aCommandId,
       
   200         TInt aStatus,
       
   201         const TDesC8& aData );
       
   202 
       
   203 protected:
       
   204 
       
   205     /**
       
   206     * First phase constructor.
       
   207     *
       
   208     * @since S60 3.2
       
   209     */
       
   210     IMPORT_C CSAnimStartupCtrl();
       
   211 
       
   212     /**
       
   213     * Second phase constructor.
       
   214     *
       
   215     * @since S60 3.2
       
   216     *
       
   217     * @param aRect Rectangle designated for the control.
       
   218     * @param aContainer The compound control that is the container for this control.
       
   219     */
       
   220     IMPORT_C void ConstructL(
       
   221         const TRect& aRect,
       
   222         const CCoeControl& aContainer );
       
   223 
       
   224     /**
       
   225     * Leavable version of Load. Leaves if there is an error reading animation
       
   226     * properties.
       
   227     *
       
   228     * @since S60 3.2
       
   229     *
       
   230     * @param aParams Central Repository keys for finding out details of the
       
   231     * animation.
       
   232     * @param aStatus Request to complete when loading is complete.
       
   233     */
       
   234     virtual void LoadL(
       
   235         const TAnimationParams& aParams,
       
   236         TRequestStatus& aStatus );
       
   237 
       
   238     /**
       
   239     * Read a file name value from Central Repository key identified by parameter.
       
   240     * Return empty value if the file does not exist or can not be opened.
       
   241     *
       
   242     * @since S60 3.2
       
   243     *
       
   244     * @param aFs File server session for checking the existence of the file.
       
   245     * @param aRepository Central repository to read the file name from.
       
   246     * @param aKey Identifies the key to read.
       
   247     * @param aBuf On return, contains a file name.
       
   248     */
       
   249     virtual void ReadFileNameL(
       
   250         RFs& aFs,
       
   251         CRepository& aRepository,
       
   252         const TUint32 aKey,
       
   253         TDes& aBuf );
       
   254 
       
   255     /**
       
   256     * Read a volume level value from Central Repository key identified by
       
   257     * parameter.
       
   258     * If device ringing tone is silent in profile settings, return 0.
       
   259     * If the volume level is lower than the minimum allowed, return the minimum
       
   260     * allowed value.
       
   261     * If the volume level is higher than the maximum allowed, return the maximum
       
   262     * allowed value.
       
   263     * Otherwise return the volume level read from Central Repository.
       
   264     *
       
   265     * @since S60 3.2
       
   266     *
       
   267     * @param aRepository Central repository to read the file name from.
       
   268     * @param aKey Identifies the key to read.
       
   269     * @return Volume level for playing a welcome show tone.
       
   270     */
       
   271     virtual TInt ReadVolume( CRepository& aRepository, const TUint32 aKey );
       
   272 
       
   273     /**
       
   274     * Read an integer value from Central Repository key identified by parameter.
       
   275     * Return 0 on failure.
       
   276     *
       
   277     * @since S60 3.2
       
   278     *
       
   279     * @param aRepository Central repository to read the file name from.
       
   280     * @param aKey Identifies the key to read.
       
   281     * @return The value from CentralRepository.
       
   282     */
       
   283     virtual TInt ReadIntValue( CRepository& aRepository, const TUint32 aKey );
       
   284 
       
   285     /**
       
   286     * Start playing the animation.
       
   287     *
       
   288     * @since S60 3.2
       
   289     */
       
   290     virtual void StartAnimation();
       
   291 
       
   292 private:
       
   293 
       
   294     /** Copy constructor. */
       
   295     CSAnimStartupCtrl( const CSAnimStartupCtrl& );
       
   296     /** Assignment operator. */
       
   297     CSAnimStartupCtrl& operator=( const CSAnimStartupCtrl& );
       
   298 
       
   299 protected: // data
       
   300 
       
   301     /**
       
   302     * For sending commands to Secondary Display using Mediator.
       
   303     * Owned. May be NULL.
       
   304     */
       
   305     CMediatorCommandInitiator* iCommandInitiator;
       
   306 
       
   307     /**
       
   308     * For responding to commands from Secondary Display using Mediator.
       
   309     * Owned. May be NULL.
       
   310     */
       
   311     CMediatorCommandResponder* iCommandResponder;
       
   312 
       
   313     /** ETrue if default 'beep' tone should be played. */
       
   314     TBool iPlayDefaultBeep;
       
   315 
       
   316     /**
       
   317     * Identifies the message to send to secondary display (if supported) to
       
   318     * synchronise the animation.
       
   319     */
       
   320     TInt iSyncCommand;
       
   321 
       
   322     /** ETrue if the animation has any content (image or tone). */
       
   323     TBool iHasContent;
       
   324 
       
   325     /**
       
   326     * Request status stored here until secondary display sync command completes
       
   327     * and animation can be started. Not owned. May be NULL.
       
   328     */
       
   329     TRequestStatus* iClientStatus;
       
   330 
       
   331 private: // data
       
   332 
       
   333     TAny* iReserved1; /** Reserved for future use. */
       
   334     TAny* iReserved2; /** Reserved for future use. */
       
   335 
       
   336     /**
       
   337     * Set to ETrue when sending a sync command to secondary display, and EFalse
       
   338     * when a response is received.
       
   339     * Responses arriving while the value is EFalse are not handled.
       
   340     */
       
   341     TBool iWaitingForSyncResponse;
       
   342 
       
   343     TInt iReserved4; /** Reserved for future use. */
       
   344 
       
   345     };
       
   346 
       
   347 #endif // SANIMSTARTUPCTRL_H