radioapp/radioenginewrapper/inc/radioenginehandler.h
author hgs
Thu, 08 Jul 2010 12:44:18 +0300
changeset 36 ba22309243a1
parent 34 bc10a61bd7d3
child 54 a8ba0c289b44
permissions -rw-r--r--
201027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#ifndef _RADIOENGINEHANDLER_H_
hgs
parents:
diff changeset
    19
#define _RADIOENGINEHANDLER_H_
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
// System includes
hgs
parents:
diff changeset
    22
#include <QScopedPointer>
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
// User includes
hgs
parents:
diff changeset
    25
#include "radio_global.h"
hgs
parents:
diff changeset
    26
#include "mradioengineinitializer.h"
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
// Forward declarations
hgs
parents:
diff changeset
    29
class CRadioEngine;
hgs
parents:
diff changeset
    30
class MRadioRdsDataObserver;
hgs
parents:
diff changeset
    31
class MRadioEngineHandlerObserver;
hgs
parents:
diff changeset
    32
class MRadioApplicationSettings;
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// Class declaration
hgs
parents:
diff changeset
    35
class RadioEngineHandler : public MRadioEngineInitializer
hgs
parents:
diff changeset
    36
{
hgs
parents:
diff changeset
    37
public:
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
    RadioEngineHandler( MRadioEngineHandlerObserver& observer );
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
    ~RadioEngineHandler();
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
    /*!
hgs
parents:
diff changeset
    44
     * Attempts to construct the radio engine
hgs
parents:
diff changeset
    45
     */
hgs
parents:
diff changeset
    46
    bool constructEngine();
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
    /*!
hgs
parents:
diff changeset
    49
     * Sets the rds data observer
hgs
parents:
diff changeset
    50
     */
hgs
parents:
diff changeset
    51
    void setRdsObserver( MRadioRdsDataObserver* observer );
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
    /*!
hgs
parents:
diff changeset
    54
     * Starts or stops receiving RDS data
hgs
parents:
diff changeset
    55
     */
hgs
parents:
diff changeset
    56
    void setRdsEnabled( bool rdsEnabled );
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
    /*!
hgs
parents:
diff changeset
    59
     * Returns the radio status
hgs
parents:
diff changeset
    60
     * @return ETrue = radio is on, EFalse = radio is off
hgs
parents:
diff changeset
    61
     */
hgs
parents:
diff changeset
    62
    bool isRadioOn();
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
    /*!
hgs
parents:
diff changeset
    65
     * Sets the manual seek status
hgs
parents:
diff changeset
    66
     */
hgs
parents:
diff changeset
    67
    void setManualSeekMode( bool manualSeek );
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
    /*!
hgs
parents:
diff changeset
    70
     * Returns the manual seek status
hgs
parents:
diff changeset
    71
     */
hgs
parents:
diff changeset
    72
    bool isInManualSeekMode() const;
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
    /*!
hgs
parents:
diff changeset
    75
     * Tune to the specified frequency
hgs
parents:
diff changeset
    76
     * @param aFrequency - frequency to lock onto.
hgs
parents:
diff changeset
    77
     */
hgs
parents:
diff changeset
    78
    void setFrequency( uint frequency );
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
    /*!
hgs
parents:
diff changeset
    81
     * Sets the audio mute state
hgs
parents:
diff changeset
    82
     * @param aMuted - flag to determine whether mute should be turned on or off
hgs
parents:
diff changeset
    83
     */
hgs
parents:
diff changeset
    84
    void setMute( const bool muted, const bool updateSettings = true );
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
    /*!
hgs
parents:
diff changeset
    87
     * Gets the audio mute state
hgs
parents:
diff changeset
    88
     * @return ETrue or EFalse to indicate whether mute is currently on.
hgs
parents:
diff changeset
    89
     */
hgs
parents:
diff changeset
    90
    bool isMuted() const;
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
    /*!
hgs
parents:
diff changeset
    93
     * Sets the volume level of the FM radio
hgs
parents:
diff changeset
    94
     * @param aVolume - the volume to be used.
hgs
parents:
diff changeset
    95
     */
hgs
parents:
diff changeset
    96
    void setVolume( int newVolume );
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
    /*!
hgs
parents:
diff changeset
    99
     * Gets the volumelevel.
hgs
parents:
diff changeset
   100
     * @return the current volume
hgs
parents:
diff changeset
   101
     */
hgs
parents:
diff changeset
   102
    int volume() const;
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
    /*!
hgs
parents:
diff changeset
   105
     * Gets the max volumelevel.
hgs
parents:
diff changeset
   106
     * @return the max volume
hgs
parents:
diff changeset
   107
     */
hgs
parents:
diff changeset
   108
    int maxVolume() const;
hgs
parents:
diff changeset
   109
hgs
parents:
diff changeset
   110
    /*!
hgs
parents:
diff changeset
   111
     * Increases the volume by one increment
hgs
parents:
diff changeset
   112
     */
hgs
parents:
diff changeset
   113
    void increaseVolume();
hgs
parents:
diff changeset
   114
hgs
parents:
diff changeset
   115
    /*!
hgs
parents:
diff changeset
   116
     * Decreases the volume by one increment
hgs
parents:
diff changeset
   117
     */
hgs
parents:
diff changeset
   118
    void decreaseVolume();
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
    /*!
hgs
parents:
diff changeset
   121
     * Checks if the antenna is attached
hgs
parents:
diff changeset
   122
     * @return ETrue or EFalse to indicate whether antenna is currently attached.
hgs
parents:
diff changeset
   123
     */
hgs
parents:
diff changeset
   124
    bool isAntennaAttached() const;
hgs
parents:
diff changeset
   125
hgs
parents:
diff changeset
   126
    /*!
hgs
parents:
diff changeset
   127
     * Retrieves the current frequency.
hgs
parents:
diff changeset
   128
     * @return the frequency in hertz
hgs
parents:
diff changeset
   129
     */
hgs
parents:
diff changeset
   130
    uint currentFrequency() const;
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
    /*!
hgs
parents:
diff changeset
   133
     * Returns the minimum allowed frequency in the current region
hgs
parents:
diff changeset
   134
     */
hgs
parents:
diff changeset
   135
    uint minFrequency() const;
hgs
parents:
diff changeset
   136
hgs
parents:
diff changeset
   137
    /*!
hgs
parents:
diff changeset
   138
     * Returns the maximum allowed frequency in the current region
hgs
parents:
diff changeset
   139
     */
hgs
parents:
diff changeset
   140
    uint maxFrequency() const;
hgs
parents:
diff changeset
   141
hgs
parents:
diff changeset
   142
    /*!
hgs
parents:
diff changeset
   143
     * Checks if the given frequency is valid in the current region
hgs
parents:
diff changeset
   144
     */
hgs
parents:
diff changeset
   145
    bool isFrequencyValid( uint frequency ) const;
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
    /*!
hgs
parents:
diff changeset
   148
     * Scan up to the next available frequency.
hgs
parents:
diff changeset
   149
     */
hgs
parents:
diff changeset
   150
    void seek( Seek::Direction direction );
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
    /*!
hgs
parents:
diff changeset
   153
     * Cancel previously requested scan.
hgs
parents:
diff changeset
   154
     */
hgs
parents:
diff changeset
   155
    void cancelSeek();
hgs
parents:
diff changeset
   156
hgs
parents:
diff changeset
   157
    /*!
hgs
parents:
diff changeset
   158
     * Returns the engine seeking state
hgs
parents:
diff changeset
   159
     */
hgs
parents:
diff changeset
   160
    Seek::State seekingState() const;
hgs
parents:
diff changeset
   161
hgs
parents:
diff changeset
   162
    /*!
hgs
parents:
diff changeset
   163
     * Rreturn step size for tuning.
hgs
parents:
diff changeset
   164
     * @return step size
hgs
parents:
diff changeset
   165
     */
hgs
parents:
diff changeset
   166
    uint frequencyStepSize() const;
hgs
parents:
diff changeset
   167
hgs
parents:
diff changeset
   168
    /*!
hgs
parents:
diff changeset
   169
     * Determine current region
hgs
parents:
diff changeset
   170
     * @return fmradio region. In case of error, returns EFMRadioRegionNone.
hgs
parents:
diff changeset
   171
     */
hgs
parents:
diff changeset
   172
    RadioRegion::Region region() const;
hgs
parents:
diff changeset
   173
hgs
parents:
diff changeset
   174
    /*!
hgs
parents:
diff changeset
   175
     * Sets whether or not audio should be routed to loudspeaker
hgs
parents:
diff changeset
   176
     * @param aLoudspeaker ETrue if loudspeaker should be used, EFalse if not
hgs
parents:
diff changeset
   177
     */
hgs
parents:
diff changeset
   178
    void setAudioRouteToLoudspeaker( bool loudspeaker );
hgs
parents:
diff changeset
   179
hgs
parents:
diff changeset
   180
    /*!
hgs
parents:
diff changeset
   181
     * Checks if audio is routed to loudspeaker
hgs
parents:
diff changeset
   182
     * @return ETrue if loudspeaker is used, EFalse if headset is used
hgs
parents:
diff changeset
   183
     */
hgs
parents:
diff changeset
   184
    bool isAudioRoutedToLoudspeaker() const;
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
    /*!
hgs
parents:
diff changeset
   187
     * Returns a reference to the application settings
hgs
parents:
diff changeset
   188
     */
hgs
parents:
diff changeset
   189
    MRadioApplicationSettings& applicationSettings() const;
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
private:
hgs
parents:
diff changeset
   192
hgs
parents:
diff changeset
   193
// from base class MRadioEngineInitializer
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
    CRadioAudioRouter* InitAudioRouterL();
hgs
parents:
diff changeset
   196
    CRadioSystemEventCollector* InitSystemEventCollectorL();
hgs
parents:
diff changeset
   197
    CRadioSettings* InitSettingsL();
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
private: // data
hgs
parents:
diff changeset
   200
hgs
parents:
diff changeset
   201
    /*!
hgs
parents:
diff changeset
   202
     * Radio engine holder
hgs
parents:
diff changeset
   203
     * Own.
hgs
parents:
diff changeset
   204
     */
hgs
parents:
diff changeset
   205
    QScopedPointer<CRadioEngine>    mEngine;
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
    /*!
hgs
parents:
diff changeset
   208
     * Radio handler observer
hgs
parents:
diff changeset
   209
     * Not own.
hgs
parents:
diff changeset
   210
     */
hgs
parents:
diff changeset
   211
    MRadioEngineHandlerObserver&    mObserver;
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
    /*!
hgs
parents:
diff changeset
   214
     * Selected radio region
hgs
parents:
diff changeset
   215
     */
hgs
parents:
diff changeset
   216
    RadioRegion::Region             mRegion;
hgs
parents:
diff changeset
   217
hgs
parents:
diff changeset
   218
};
hgs
parents:
diff changeset
   219
hgs
parents:
diff changeset
   220
#endif //_RADIOENGINEHANDLER_H_