devicediagnostics/diagplugins/diagloudspeakerplugin/inc/diagspeakerplugin.h
changeset 0 3ce708148e4d
child 54 9360ca28b668
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 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: Implementation of diagnostics components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DIAGSPEAKERPLUGIN_H
       
    20 #define DIAGSPEAKERPLUGIN_H
       
    21 
       
    22 #include <AknProgressDialog.h>       // MProgressDialogCallback
       
    23 #include <DiagTestPluginBase.h>      // CDiagTestPluginBase
       
    24 #include <DiagResultsDatabaseItem.h> // CDiagResultsDatabaseItem::TResult
       
    25 #include <mdaaudiosampleplayer.h>    // MMdaAudioPlayerCallback
       
    26 #include <AudioOutput.h>             // TAudioOutputPreference
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CPeriodic;
       
    30 class CDiagResultsDbItemBuilder;
       
    31 class CEikDialog;
       
    32 class CAknNoteDialog;
       
    33 class CAknProgressDialog;
       
    34 class CEikProgressInfo;
       
    35 
       
    36 // CLASS DEFINITION
       
    37 class CDiagSpeakerPlugin : public CDiagTestPluginBase,
       
    38                            public MProgressDialogCallback,
       
    39                            public MMdaObjectStateChangeObserver,
       
    40                            public MMdaAudioPlayerCallback
       
    41 {
       
    42 public: // Constructors and destructor
       
    43     /**
       
    44     * Symbian OS two-phased constructor
       
    45     *
       
    46     * @return Timer Test Plugin
       
    47     */
       
    48     static MDiagPlugin* NewL( TAny* aInitParams );
       
    49 
       
    50     /**
       
    51     * Destructor
       
    52     */
       
    53     virtual ~CDiagSpeakerPlugin();
       
    54 
       
    55 
       
    56 private: // private functions
       
    57     /**
       
    58     * C++ default constructor.
       
    59     */
       
    60     CDiagSpeakerPlugin( CDiagPluginConstructionParam* aInitParams  );
       
    61 
       
    62     /**
       
    63     * Symbian OS default constructor.
       
    64     *
       
    65     */
       
    66     void ConstructL();
       
    67 
       
    68     /**
       
    69     * Start Audio Recording with Dialogs
       
    70     *
       
    71     */
       
    72     void StartRecordL();
       
    73 
       
    74     /**
       
    75     * Start Audio Playing with Dialogs
       
    76     *
       
    77     */
       
    78     void StartPlayL();
       
    79 
       
    80     /**
       
    81     * Audio Recording
       
    82     *
       
    83     */
       
    84     void RecordingL();
       
    85 
       
    86     /**
       
    87     * Audio Playing
       
    88     *
       
    89     */
       
    90     void PlayingL();
       
    91 
       
    92     /**
       
    93     * Actions after Recording has finished
       
    94     *
       
    95     */
       
    96     void AfterRecordL();
       
    97 
       
    98     /**
       
    99     * Actions after Playing has finished
       
   100     *
       
   101     */
       
   102     void AfterPlayL();
       
   103 
       
   104     /**
       
   105     * Invoke CMdaAudioRecorderUtility::RecordL to start record
       
   106     *
       
   107     */
       
   108     void RecordL();
       
   109 
       
   110     /**
       
   111     * Invoke CMdaAudioRecorderUtility::PlayL to start play
       
   112     *
       
   113     */
       
   114     void PlayL();
       
   115 
       
   116     /**
       
   117     * Set Audio to Current Output
       
   118     *
       
   119     */
       
   120     void SaveAudioOutput();
       
   121 
       
   122     /**
       
   123     * Set Audio to previous Output
       
   124     *
       
   125     */
       
   126     void RestoreAudioOutputL();
       
   127 
       
   128     /**
       
   129     * Clean up instance of CPeriodic
       
   130     *
       
   131     */
       
   132     void ClosePeriodic();
       
   133 
       
   134     /**
       
   135     * Check whether Recorded file exist
       
   136     */
       
   137     TBool CheckRecordFile();
       
   138 
       
   139     /**
       
   140     * Delete Recorded file
       
   141     */
       
   142     void DeleteRecordFile();
       
   143 
       
   144     /**
       
   145     * Check whether there are enough space to record
       
   146     *
       
   147     * @return ETure when there is enough free space
       
   148     */
       
   149     TBool EnoughFreeSpace();
       
   150 
       
   151     /**
       
   152     * Set Dialog has dismissed
       
   153     *
       
   154     * @param aDismissed - ETrue  for Dialog dismissed
       
   155     *                   - EFalse for Dialog has not dismissed
       
   156     */
       
   157     void SetProgressDismissed( TBool aDismissed );
       
   158 
       
   159     /**
       
   160     * Check whether Dialog has dismissed
       
   161     *
       
   162     * @return ETure when Dialog has dismissed
       
   163     */
       
   164     TBool ProgressDismissed() const;
       
   165 
       
   166     /**
       
   167     * Ask Cancel all Test
       
   168     *
       
   169     * @param  aButtonId - reference of button id pressed
       
   170     * @return ETure when current state is valid
       
   171     */
       
   172     TBool AskCancelExecutionL( TInt& aButtonId );
       
   173 
       
   174     /**
       
   175     * Display Confirmation Query
       
   176     *
       
   177     * @param aResourceId - Resource ID of Confimation Query
       
   178     *
       
   179     */
       
   180     TBool ShowConfQueryL( TInt aResourceId, TInt &aButtonId );
       
   181 
       
   182     /**
       
   183     * Display Message Query
       
   184     *
       
   185     * @param aResourceId - Resource ID of Message Query
       
   186     * @param aButtonId   - Reference of button id to exit
       
   187     */
       
   188     TBool ShowMessageQueryL( TInt aResourceId, TInt &aButtonId );
       
   189 
       
   190     /**
       
   191     * Display Progress Dialog
       
   192     *
       
   193     * @param aResourceId - Resource ID of Progress
       
   194     * @param aFinalValue - Final value of Progress Note to display
       
   195     */
       
   196     void ShowProgressNoteL( TInt aResourceId, TInt aFinalValue );
       
   197 
       
   198     /**
       
   199     * Callback function to update Progress Dialog
       
   200     *
       
   201     * @param aThis - Object to receive call back
       
   202     * @return 0 on finish
       
   203     */
       
   204     static TInt CallbackIncrementProgressNoteL( TAny* aThis );
       
   205 
       
   206     /**
       
   207     * Called from CallbackIncrementProgressNoteL
       
   208     *  Actual Function to update Progress Dialog
       
   209     *
       
   210     * @return 0 on finish
       
   211     */
       
   212     TInt UpdateProgressNoteL();
       
   213 
       
   214 
       
   215 private: // From CDiagTestPluginBase
       
   216 
       
   217     /**
       
   218     * @see CDiagTestPluginBase::Visible()
       
   219     */
       
   220     virtual TBool IsVisible() const;
       
   221 
       
   222     /**
       
   223     * @see CDiagTestPluginBase::RunMode()
       
   224     */
       
   225     virtual TRunMode RunMode() const;
       
   226 
       
   227     /**
       
   228     * @see CDiagTestPluginBase::TotalSteps()
       
   229     */
       
   230     virtual TUint TotalSteps() const;
       
   231 
       
   232     /**
       
   233     * @see CDiagTestPluginBase::GetPluginNameL
       
   234     */
       
   235     virtual HBufC* GetPluginNameL( TNameLayoutType aLayoutType ) const;
       
   236 
       
   237     /**
       
   238     * @see CDiagTestPluginBase::Uid
       
   239     */
       
   240     virtual TUid Uid() const;
       
   241 
       
   242     /**
       
   243     * @see CDiagTestPluginBase::TestSessionBeginL
       
   244     */
       
   245     virtual void TestSessionBeginL( MDiagEngineCommon& aEngine,
       
   246                                     TBool aSkipDependencyCheck,
       
   247                                     TAny* aCustomParams );
       
   248 
       
   249     /**
       
   250     * @see CDiagTestPluginBase::TestSessionEndL
       
   251     */
       
   252     virtual void TestSessionEndL( MDiagEngineCommon& aEngine,
       
   253                                   TBool aSkipDependencyCheck,
       
   254                                   TAny* aCustomParams );
       
   255 
       
   256     /**
       
   257     * Handle plug-in execution.
       
   258     *   @see CDiagTestPluginBase::DoRunTestL()
       
   259     */
       
   260     virtual void DoRunTestL();
       
   261 
       
   262     /**
       
   263     * Handle plug-in execution stop and clean up
       
   264     *   @see CDiagTestPluginBase::DoStopAndCleanupL()
       
   265     */
       
   266     void DoStopAndCleanupL();
       
   267 
       
   268 
       
   269 private: // from CActive
       
   270     /**
       
   271     * Handle active object completion event
       
   272     */
       
   273     virtual void RunL();
       
   274 
       
   275     /**
       
   276     * Handle cancel
       
   277     */
       
   278     virtual void DoCancel();
       
   279     
       
   280     enum TState
       
   281     {
       
   282     EStateUnknown = 0,
       
   283     EStateFailed,
       
   284     EStateCancelled,
       
   285     EStateSkipped,
       
   286     EStateIdle,
       
   287     EStateRecorded,
       
   288     EStatePlayed,
       
   289     EStateUserQuery
       
   290     };
       
   291 
       
   292 
       
   293 private: // from MProgressDialogCallback
       
   294     /**
       
   295     * Callback method Get's called when a dialog is dismissed
       
   296     *
       
   297     * @param aButtonId - indicate which button made dialog to dismiss
       
   298     */
       
   299     virtual void DialogDismissedL( TInt aButtonId );
       
   300 
       
   301 
       
   302 private: // from MMdaObjectStateChangeObserver
       
   303     /**
       
   304     * Handling the change of state of an audio data sample object
       
   305     *
       
   306     * @param aObject        - indicate which button made dialog to dismiss
       
   307     * @param aPreviousState - previous state
       
   308     * @param aCurrentState  - current state
       
   309     * @param aErrorCode     - error code
       
   310     */
       
   311     virtual void MoscoStateChangeEvent(
       
   312         CBase *aObject,
       
   313         TInt aPreviousState,
       
   314         TInt aCurrentState,
       
   315         TInt aErrorCode);
       
   316 
       
   317 private: // MMdaAudioPlayerCallback
       
   318      /**
       
   319      * Defines required client behaviour when an attempt to open and initialise an audio sample has completed
       
   320      *
       
   321      * @param aError     - The status of the audio sample after initialisation
       
   322      * @param aDuration  - Duration of the audio sample
       
   323      */
       
   324     virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
       
   325 
       
   326     /**
       
   327      * Defines required client behaviour when an attempt to playback an audio sample has completed
       
   328      *
       
   329      * @param aError  - The status of playback
       
   330      */
       
   331     virtual void MapcPlayComplete(TInt aError);
       
   332     
       
   333     void SetAudioEvent(TState aState);
       
   334 
       
   335 private: // Data
       
   336     /**
       
   337      * Tells session is Valid
       
   338      */
       
   339     TBool iSessionValid;
       
   340 
       
   341     /**
       
   342      * Indicate Progress has dismissed
       
   343      */
       
   344     TBool iProgressDismissed;
       
   345 
       
   346     /**
       
   347      * AudioState for Recording/Playing
       
   348      */
       
   349     TInt iAudioState;
       
   350 
       
   351     /**
       
   352      * Recorder for Recording Audio
       
   353      * OWN
       
   354      */
       
   355     CMdaAudioRecorderUtility* iRecorder;
       
   356 
       
   357     /**
       
   358      * Player for Playing Audio
       
   359      * OWN
       
   360      */
       
   361     CMdaAudioPlayerUtility* iAudioPlayer;
       
   362 
       
   363     /**
       
   364      * Maxmium Size of Record File
       
   365      */
       
   366     TInt iRecordFileSize;
       
   367 
       
   368     /**
       
   369      * Path of Record File
       
   370      */
       
   371     TFileName iRecordFilePath;
       
   372 
       
   373     /**
       
   374      * Progress Dialog
       
   375      * OWN
       
   376      */
       
   377     CAknProgressDialog* iProgressDialog;
       
   378 
       
   379     /**
       
   380      * Info for Progress Dialog
       
   381      * OWN
       
   382      */
       
   383     CEikProgressInfo* iProgressInfo;
       
   384 
       
   385     /**
       
   386      * Timer for Update Progress
       
   387      * OWN
       
   388      */
       
   389     CPeriodic* iPeriodic;
       
   390 
       
   391     /**
       
   392      * Duration of Audio in usec
       
   393      */
       
   394     TTimeIntervalMicroSeconds iMaxDurationMicroSec;
       
   395 
       
   396     /**
       
   397      * Position of Audio in usec
       
   398      */
       
   399     TTimeIntervalMicroSeconds iPositionMicroSec;
       
   400 
       
   401     /**
       
   402      * Maximum time(sec) to record
       
   403      */
       
   404     TInt iFinalValue;
       
   405 
       
   406     /**
       
   407      * Previous Audio Output
       
   408      */
       
   409     CAudioOutput::TAudioOutputPreference iPrevAudioOutput;
       
   410 
       
   411     /**
       
   412      * Current Audio Output
       
   413      */
       
   414     CAudioOutput::TAudioOutputPreference iOutput;
       
   415 
       
   416     /**
       
   417      * Audio Output to route
       
   418      * OWN
       
   419      */
       
   420     CAudioOutput* iAudioOutput;
       
   421     
       
   422     /*
       
   423     * State of the Audio Plugin.
       
   424     */
       
   425     TState iState;
       
   426     };
       
   427 
       
   428 #endif //DIAGSPEAKERPLUGIN_H
       
   429 
       
   430 // End of File