controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.h
changeset 25 19394c261aa5
parent 24 f5dfdd5e4a1b
child 27 848a3adde87f
child 31 e79ce701c376
equal deleted inserted replaced
24:f5dfdd5e4a1b 25:19394c261aa5
     1 /*
       
     2  * Copyright (c) 2009 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:
       
    15  *     The header file for tone previewing.
       
    16  *     
       
    17  */
       
    18 
       
    19 #ifndef TONEPREVIEWPRIVATE_H
       
    20 #define TONEPREVIEWPRIVATE_H
       
    21 #include <e32base.h>
       
    22 #include <DrmAudioSamplePlayer.h>
       
    23 #include <mdaaudiotoneplayer.h>
       
    24 #include <videoplayer.h>
       
    25 #include <centralrepository.h>
       
    26 #include <apgcli.h>  // for RApaLsSession
       
    27 #include <e32property.h>
       
    28 #include <QObject>
       
    29 #include "tonefetcherengine.h"
       
    30 #include <coemain.h>
       
    31 
       
    32 class C3DRingingToneInterface;
       
    33 class RWindow;
       
    34 
       
    35 /**
       
    36 * CMFPreviewHandlerBase
       
    37 *
       
    38 * Base class for CMFAudioPreviewHandler.
       
    39  */
       
    40 class CMFPreviewHandlerBase : public QObject, public CBase
       
    41                         
       
    42 {
       
    43 Q_OBJECT
       
    44 public: 
       
    45 
       
    46    enum TMediaFileType
       
    47        {
       
    48        EMediaFileTypeAudio = 0,
       
    49        EMediaFileTypeVideo
       
    50        };
       
    51     enum TPlayerStatus
       
    52         {
       
    53         EPlayerNotCreated,
       
    54         EPlayerInitializing,
       
    55         EPlayerReady,
       
    56         EPlayerPlaying,
       
    57         EPlayerInitialized,
       
    58         EPlayerPlayingWith3DEffect
       
    59         };
       
    60 
       
    61     // these must match with the ones in Profile Engine
       
    62     enum TRingingTypes
       
    63         {
       
    64         ERingingTypeRinging = 0,
       
    65         ERingingTypeAscending,
       
    66         ERingingTypeRingOnce,
       
    67         ERingingTypeBeepOnce,
       
    68         ERingingTypeSilent
       
    69         };
       
    70 
       
    71     enum TFLAllowScreenSaver
       
    72         {
       
    73         EFLScreenSaverAllowed = 0, EFLScreenSaverNotAllowed
       
    74         };
       
    75 
       
    76 protected:
       
    77 
       
    78     virtual ~CMFPreviewHandlerBase();
       
    79 
       
    80 protected:
       
    81 
       
    82     /**
       
    83      * C++ default constructor.
       
    84      */
       
    85     CMFPreviewHandlerBase( QObject *parent );
       
    86 
       
    87     /**
       
    88      * By default Symbian OS constructor is private.
       
    89      */
       
    90     void ConstructL();
       
    91 
       
    92 public:    
       
    93     void SetAttr(const QString &file);    
       
    94     TInt Attr(TInt aAttr);    
       
    95     virtual void Play() = 0;
       
    96     virtual void Stop() = 0;
       
    97     virtual TBool IsPlaying() = 0;
       
    98 
       
    99 protected:
       
   100     TInt ConvertVolume(TInt aVolume);
       
   101     void ReadActiveProfileL();
       
   102     TInt GetDataType(const TDesC& aFileName, TDataType& aDataType);
       
   103     void ReadDefaultToneL();   
       
   104     
       
   105 
       
   106     void DisableBackLight();
       
   107 
       
   108     static TInt DoResetInactivityTimer(TAny* aObject);
       
   109 protected:
       
   110     TInt RingingVolume();
       
   111     TInt RingingType();
       
   112     TInt Vibra();
       
   113     TInt Echo3D();
       
   114     TInt Effect3D();
       
   115 
       
   116 protected:
       
   117     static TInt ConvertVolume(TInt aVolume, TInt aMaxVolume);    
       
   118 
       
   119 protected:
       
   120     TInt iRingingVolume;
       
   121     TInt iRingingType;
       
   122     TInt iVibra;
       
   123     TInt i3DEffect;
       
   124     TInt i3DEcho;
       
   125     TInt iMediaType;
       
   126     TInt iFileSize;
       
   127     HBufC* iFullName;
       
   128 
       
   129     TBool iActiveProfileRead;
       
   130     TInt iActiveProfileRingingVolume;
       
   131     TInt iActiveProfileRingingType;
       
   132     TInt iActiveProfileVibra;
       
   133     TInt iActiveProfile3DEffect;
       
   134     TInt iActiveProfile3DEcho;
       
   135    
       
   136 
       
   137     TInt iPlayerStatus;
       
   138 
       
   139     // handle to window
       
   140     RWindow* iWindow; // does not own
       
   141 
       
   142     // for getting file MIME types
       
   143     RApaLsSession iApaSession;
       
   144 
       
   145     // for setting screensaver on/off
       
   146     RProperty iProperty;
       
   147 
       
   148     // default ringing tone
       
   149     TFileName iDefaultTone;
       
   150 
       
   151     // file server session
       
   152     //RFs iFsSession;
       
   153 
       
   154     /**
       
   155      * Timer for resetting the user inactivity timeout
       
   156      */
       
   157     CPeriodic* iBacklightTimer;
       
   158 };
       
   159 
       
   160 // CLASS DECLARATION
       
   161 /**
       
   162  *  This class is used for previewing the tones.
       
   163  *
       
   164  */
       
   165 
       
   166 class TonePreviewPrivate : public CMFPreviewHandlerBase,
       
   167                            public MDrmAudioPlayerCallback,
       
   168                            public MMdaAudioToneObserver,
       
   169                            public MCoeForegroundObserver
       
   170 
       
   171 {
       
   172 Q_OBJECT
       
   173 public:
       
   174     TonePreviewPrivate( QObject *parent );
       
   175     virtual ~TonePreviewPrivate();   
       
   176 signals:
       
   177     void notifyPreviewEvent( ToneFetcherEngine::TPreviewEvent event, int errorId );
       
   178     
       
   179 public:
       
   180     void Play();
       
   181     void Stop();
       
   182     TBool IsPlaying();
       
   183 
       
   184 private:
       
   185     void Cancel();
       
   186     void SetAudioRingingType( TInt aRingingType );
       
   187     void SetToneRingingType( TInt aRingingType );
       
   188     TInt ConvertVolume( TInt aVolume );
       
   189         
       
   190         
       
   191 private:
       
   192     // from MMdaAudioToneObserver
       
   193     virtual void MatoPrepareComplete( TInt aError );
       
   194     virtual void MatoPlayComplete(TInt aError);
       
   195 
       
   196 private:
       
   197     // from MDrmAudioPlayerCallback
       
   198     void MdapcInitComplete(TInt aError,
       
   199             const TTimeIntervalMicroSeconds& aDuration);
       
   200     void MdapcPlayComplete(TInt aError);
       
   201     // from MCoeForegroundObserver
       
   202     void HandleLosingForeground();
       
   203     void HandleGainingForeground();
       
   204 
       
   205 private:
       
   206     // audio player
       
   207     CDrmPlayerUtility* iAudioPlayer;
       
   208 
       
   209     /// Audioplayer status
       
   210     TPlayerStatus iAudioPlayerStatus;
       
   211 
       
   212     /// toneplayer
       
   213     CMdaAudioToneUtility* iTonePlayer;
       
   214 
       
   215     /// Toneplayer status
       
   216     TPlayerStatus iTonePlayerStatus;
       
   217     
       
   218     // plugin for playing 3D effects
       
   219     C3DRingingToneInterface* i3dRingingTonePlugin;
       
   220 
       
   221 };
       
   222     
       
   223 #endif /* TONEPREVIEWPRIVATE_H_ */