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