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