radioapp/radiouiengine/inc/radiouiengine.h
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 33 11b6825f0862
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    20 #define RADIOUIENGINE_H_
    20 #define RADIOUIENGINE_H_
    21 
    21 
    22 // System includes
    22 // System includes
    23 #include <QObject>
    23 #include <QObject>
    24 #include <QString>
    24 #include <QString>
       
    25 #include <QScopedPointer>
       
    26 #include <QSharedPointer>
    25 
    27 
    26 // User includes
    28 // User includes
    27 #include "radiouiengineexport.h"
    29 #include "radiouiengineexport.h"
    28 #include "radio_global.h"
    30 #include "radio_global.h"
    29 
    31 
    32 class RadioStationModel;
    34 class RadioStationModel;
    33 class RadioSettingsIf;
    35 class RadioSettingsIf;
    34 class RadioStation;
    36 class RadioStation;
    35 class RadioHistoryModel;
    37 class RadioHistoryModel;
    36 class RadioHistoryItem;
    38 class RadioHistoryItem;
    37 class RadioCarouselModel;
       
    38 class RadioStationFilterModel;
       
    39 class RadioScannerEngine;
    39 class RadioScannerEngine;
    40 class RadioMonitorService;
    40 class RadioMonitorService;
    41 
    41 
    42 namespace GenreTarget
    42 typedef QSharedPointer<RadioScannerEngine> RadioScannerEnginePtr;
    43 {
       
    44     enum Target{
       
    45         Carousel,
       
    46         StationsList,
       
    47         HomeScreen
       
    48     };
       
    49 }
       
    50 
    43 
       
    44 // Constants
       
    45 const uint DEFAULT_MIN_FREQUENCY = 87500000;
    51 
    46 
    52 class UI_ENGINE_DLL_EXPORT RadioUiEngine : public QObject
    47 class UI_ENGINE_DLL_EXPORT RadioUiEngine : public QObject
    53 {
    48 {
    54     Q_OBJECT
    49     Q_OBJECT
    55     Q_DECLARE_PRIVATE_D( d_ptr, RadioUiEngine )
    50     Q_DECLARE_PRIVATE_D( d_ptr.data(), RadioUiEngine )
    56     Q_DISABLE_COPY( RadioUiEngine )
    51     Q_DISABLE_COPY( RadioUiEngine )
    57 
    52 
    58     friend class RadioScannerEngine;
    53     friend class RadioScannerEngine;
    59 
    54 
       
    55 public: // Static functions that are used before the ui engine is created
       
    56 
       
    57     /*!
       
    58      * Gets the last tuned frequency from central repository
       
    59      */
       
    60     static uint lastTunedFrequency( uint defaultFrequency = DEFAULT_MIN_FREQUENCY );
       
    61 
       
    62     /*!
       
    63      * Gets the last used volume level
       
    64      */
       
    65     static int lastVolume();
       
    66 
       
    67     /*!
       
    68      * Launches the radio server process
       
    69      */
       
    70     static void launchRadioServer();
       
    71 
    60 public:
    72 public:
    61 
       
    62     /**
       
    63      * Static functions that are used before the ui engine is created
       
    64      */
       
    65     static bool isOfflineProfile();
       
    66     static uint lastTunedFrequency();
       
    67 
    73 
    68     RadioUiEngine( QObject* parent = 0 );
    74     RadioUiEngine( QObject* parent = 0 );
    69     ~RadioUiEngine();
    75     ~RadioUiEngine();
    70 
    76 
    71     bool isInitialized() const;
    77     bool isInitialized() const;
    72 
    78 
    73     bool init();
    79     bool init();
    74 
    80 
    75     bool isFirstTimeStart();
    81     bool isFirstTimeStart();
       
    82     void setFirstTimeStartPerformed( bool firstTimeStartPerformed );
       
    83 
       
    84     void setPowerOn();
       
    85     void setPowerOff( int delay = 0 );
       
    86     bool isPoweringOff() const;
    76 
    87 
    77     /**
    88     /**
    78      * Getters for things owned by the engine
    89      * Getters for things owned by the engine
    79      */
    90      */
    80     RadioSettingsIf& settings();
    91     RadioSettingsIf& settings();
    81     RadioStationModel& stationModel();
    92     RadioStationModel& stationModel();
    82     RadioHistoryModel& historyModel();
    93     RadioHistoryModel& historyModel();
    83     RadioStationFilterModel* createNewFilterModel( QObject* parent = 0 );
    94     RadioScannerEnginePtr createScannerEngine();
    84     RadioCarouselModel* carouselModel();
       
    85     RadioScannerEngine* scannerEngine();
    95     RadioScannerEngine* scannerEngine();
    86 
    96 
    87     bool isRadioOn() const;
    97     bool isRadioOn() const;
    88     bool isScanning() const;
    98     bool isScanning() const;
    89     bool isMuted() const;
    99     bool isMuted() const;
   109     uint skipStation( StationSkip::Mode mode, uint startFrequency = 0 );
   119     uint skipStation( StationSkip::Mode mode, uint startFrequency = 0 );
   110 
   120 
   111     enum MusicStore{ OviStore, OtherStore };
   121     enum MusicStore{ OviStore, OtherStore };
   112     void openMusicStore( const RadioHistoryItem& item, MusicStore store = OviStore );
   122     void openMusicStore( const RadioHistoryItem& item, MusicStore store = OviStore );
   113 
   123 
       
   124     void launchBrowser( const QString& url );
       
   125 
       
   126     void setManualSeekMode( bool manualSeek );
       
   127     bool isInManualSeekMode() const;
       
   128 
       
   129     /**
       
   130      * Tunes the radio engine to given frequency
       
   131      */
       
   132     void setFrequency( uint frequency, const int reason = TuneReason::Unspecified );
       
   133 
   114 signals:
   134 signals:
   115 
   135 
   116     void tunedToFrequency( uint frequency, int commandSender );
   136     void tunedToFrequency( uint frequency, int commandSender );
   117     void seekingStarted( int direction );
   137     void seekingStarted( int direction );
   118     void radioStatusChanged( bool radioIsOn );
   138     void radioStatusChanged( bool radioIsOn );
   123     void muteChanged( bool muted );
   143     void muteChanged( bool muted );
   124 
   144 
   125     void audioRouteChanged( bool loudspeaker );
   145     void audioRouteChanged( bool loudspeaker );
   126     void antennaStatusChanged( bool connected );
   146     void antennaStatusChanged( bool connected );
   127 
   147 
       
   148     void powerOffRequested();
       
   149 
   128 public slots:
   150 public slots:
   129 
       
   130     /**
       
   131      * Slots to tune to given frequency or preset
       
   132      */
       
   133     void tuneFrequency( uint frequency, const int reason = TuneReason::Unspecified );
       
   134     void tuneWithDelay( uint frequency, const int reason = TuneReason::Unspecified );
       
   135     void tunePreset( int presetIndex );
       
   136 
   151 
   137     /*!
   152     /*!
   138      * volume update command slot for the engine
   153      * volume update command slot for the engine
   139      */
   154      */
   140     void setVolume( int volume );
   155     void setVolume( int volume );
   149 
   164 
   150     /**
   165     /**
   151      * functions used only by the private class to get signals emitted
   166      * functions used only by the private class to get signals emitted
   152      */
   167      */
   153     void emitTunedToFrequency( uint frequency, int commandSender );
   168     void emitTunedToFrequency( uint frequency, int commandSender );
   154     void emitSeekingStarted( Seeking::Direction direction );
   169     void emitSeekingStarted( Seek::Direction direction );
   155     void emitRadioStatusChanged( bool radioIsOn );
   170     void emitRadioStatusChanged( bool radioIsOn );
   156     void emitRdsAvailabilityChanged( bool available );
   171     void emitRdsAvailabilityChanged( bool available );
   157     void emitVolumeChanged( int volume );
   172     void emitVolumeChanged( int volume );
   158     void emitMuteChanged( bool muted );
   173     void emitMuteChanged( bool muted );
   159     void emitAudioRouteChanged( bool loudspeaker );
   174     void emitAudioRouteChanged( bool loudspeaker );
   162 private: // data
   177 private: // data
   163 
   178 
   164     /**
   179     /**
   165      * Unmodifiable pointer to the private implementation
   180      * Unmodifiable pointer to the private implementation
   166      */
   181      */
   167     RadioUiEnginePrivate* const d_ptr;
   182     const QScopedPointer<RadioUiEnginePrivate> d_ptr;
   168 
   183 
   169 };
   184 };
   170 
   185 
   171 
   186 
   172 #endif // RADIOUIENGINE_H_
   187 #endif // RADIOUIENGINE_H_