radioapp/radiouiengine/src/radiouiengine_p.cpp
changeset 16 f54ebcfc1b80
parent 14 63aabac4416d
child 19 afea38384506
equal deleted inserted replaced
14:63aabac4416d 16:f54ebcfc1b80
    28 // User includes
    28 // User includes
    29 #include "radiouiengine.h"
    29 #include "radiouiengine.h"
    30 #include "radiouiengine_p.h"
    30 #include "radiouiengine_p.h"
    31 #include "radioenginewrapper.h"
    31 #include "radioenginewrapper.h"
    32 #include "radiostationmodel.h"
    32 #include "radiostationmodel.h"
       
    33 #include "radiostationmodel_p.h"
    33 #include "radiopresetstorage.h"
    34 #include "radiopresetstorage.h"
    34 #include "radiosettings.h"
    35 #include "radiosettings.h"
    35 #include "radiostation.h"
    36 #include "radiostation.h"
       
    37 #include "radioscannerengine.h"
       
    38 #include "radiostationhandlerif.h"
    36 #ifndef BUILD_WIN32
    39 #ifndef BUILD_WIN32
    37 #   include "radiocontrolservice.h"
    40 #   include "radiocontrolservice.h"
    38 #   include "radiomonitorservice.h"
    41 #   include "radiomonitorservice.h"
    39 #else
    42 #else
    40 #   include "radiomonitorservice_win32.h"
    43 #   include "radiomonitorservice_win32.h"
    41 #endif
    44 #endif
    42 #include "radioserviceconst.h"
    45 #include "radioservicedef.h"
    43 #include "radiologger.h"
    46 #include "radiologger.h"
    44 
    47 
    45 /*!
    48 /*!
    46  *
    49  *
    47  */
    50  */
    48 RadioUiEnginePrivate::RadioUiEnginePrivate( RadioUiEngine* engine ) :
    51 RadioUiEnginePrivate::RadioUiEnginePrivate( RadioUiEngine* engine ) :
    49     q_ptr( engine ),
    52     q_ptr( engine ),
    50     mEngineWrapper( 0 ),
    53     mEngineWrapper( 0 ),
    51     mStationModel( 0 ),
    54     mStationModel( 0 ),
    52     mPlayLogModel( 0 ),
    55     mHistoryModel( 0 ),
    53     mControlService( 0 ),
    56     mControlService( 0 ),
    54     mMonitorService( 0 )
    57     mMonitorService( 0 )
    55 {
    58 {
    56 }
    59 }
    57 
    60 
    69 }
    72 }
    70 
    73 
    71 /*!
    74 /*!
    72  *
    75  *
    73  */
    76  */
       
    77 RadioUiEngine& RadioUiEnginePrivate::api()
       
    78 {
       
    79     Q_Q( RadioUiEngine );
       
    80     return *q;
       
    81 }
       
    82 
       
    83 /*!
       
    84  *
       
    85  */
    74 bool RadioUiEnginePrivate::startRadio()
    86 bool RadioUiEnginePrivate::startRadio()
    75 {
    87 {
    76 #ifndef BUILD_WIN32
    88 #ifndef BUILD_WIN32
    77     mControlService = new RadioControlService( *q_ptr );
    89     mControlService = new RadioControlService( *q_ptr );
    78 #endif
    90 #endif
    79     mMonitorService = new RadioMonitorService( *q_ptr );
    91     mMonitorService = new RadioMonitorService( *q_ptr );
    80     mStationModel = new RadioStationModel( *q_ptr );
    92     mStationModel = new RadioStationModel( *this );
    81     mEngineWrapper.reset( new RadioEngineWrapper( mStationModel->stationHandlerIf(), *this ) );
    93     mEngineWrapper.reset( new RadioEngineWrapper( mStationModel->stationHandlerIf() ) );
       
    94     mEngineWrapper->addObserver( this );
    82     mPresetStorage.reset( new RadioPresetStorage() );
    95     mPresetStorage.reset( new RadioPresetStorage() );
    83     mStationModel->initialize( mPresetStorage.data(), mEngineWrapper.data() );
    96     mStationModel->initialize( mPresetStorage.data(), mEngineWrapper.data() );
    84 
    97 
    85 #ifndef BUILD_WIN32
    98 #ifndef BUILD_WIN32
    86     // Write the startup timestamp to P&S key for the homescreen widget
    99     // Write the startup timestamp to P&S key for the homescreen widget
    95 }
   108 }
    96 
   109 
    97 /*!
   110 /*!
    98  *
   111  *
    99  */
   112  */
   100 void RadioUiEnginePrivate::tunedToFrequency( uint frequency, int commandSender )
   113 void RadioUiEnginePrivate::cancelSeeking()
   101 {
   114 {
   102     Q_Q( RadioUiEngine );
   115     mEngineWrapper->cancelSeeking();
   103     q->emitTunedToFrequency( frequency, commandSender );
   116     mMonitorService->notifyRadioStatus( mEngineWrapper->isMuted() ? RadioStatus::Muted : RadioStatus::Playing );
   104 }
   117 }
   105 
   118 
   106 /*!
   119 /*!
   107  *
   120  *
   108  */
   121  */
   109 void RadioUiEnginePrivate::seekingStarted( Seeking::Direction direction )
   122 RadioEngineWrapper& RadioUiEnginePrivate::wrapper()
   110 {
   123 {
   111     Q_Q( RadioUiEngine );
   124     return *mEngineWrapper;
   112     q->emitSeekingStarted( direction );
   125 }
       
   126 
       
   127 /*!
       
   128  *
       
   129  */
       
   130 void RadioUiEnginePrivate::tunedToFrequency( uint frequency, int reason )
       
   131 {
       
   132     Q_Q( RadioUiEngine );
       
   133     q->emitTunedToFrequency( frequency, reason );
       
   134     mMonitorService->notifyRadioStatus( RadioStatus::Playing );
   113 }
   135 }
   114 
   136 
   115 /*!
   137 /*!
   116  *
   138  *
   117  */
   139  */
   171  */
   193  */
   172 void RadioUiEnginePrivate::muteChanged( bool muted )
   194 void RadioUiEnginePrivate::muteChanged( bool muted )
   173 {
   195 {
   174     Q_Q( RadioUiEngine );
   196     Q_Q( RadioUiEngine );
   175     q->emitMuteChanged( muted );
   197     q->emitMuteChanged( muted );
       
   198     mMonitorService->notifyRadioStatus( muted ? RadioStatus::Muted : RadioStatus::Playing );
   176 }
   199 }
   177 
   200 
   178 /*!
   201 /*!
   179  *
   202  *
   180  */
   203  */
   185 }
   208 }
   186 
   209 
   187 /*!
   210 /*!
   188  *
   211  *
   189  */
   212  */
   190 void RadioUiEnginePrivate::scanAndSaveFinished()
   213 void RadioUiEnginePrivate::antennaStatusChanged( bool connected )
   191 {
   214 {
   192     Q_Q( RadioUiEngine );
   215     Q_Q( RadioUiEngine );
   193     q->emitScanAndSaveFinished();
   216     q->emitAntennaStatusChanged( connected );
   194 }
   217     mMonitorService->notifyAntennaStatus( connected );
   195 
       
   196 /*!
       
   197  *
       
   198  */
       
   199 void RadioUiEnginePrivate::headsetStatusChanged( bool connected )
       
   200 {
       
   201     Q_Q( RadioUiEngine );
       
   202     q->emitheadsetStatusChanged( connected );
       
   203 }
   218 }
   204 
   219 
   205 /*!
   220 /*!
   206  *
   221  *
   207  */
   222  */
   255     if ( direction == RadioUiEnginePrivate::Previous ) {
   270     if ( direction == RadioUiEnginePrivate::Previous ) {
   256         if ( previous == 0 ) {
   271         if ( previous == 0 ) {
   257             previous = favorites.last();
   272             previous = favorites.last();
   258         }
   273         }
   259         LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", currentFreq, previous );
   274         LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", currentFreq, previous );
   260         mEngineWrapper->tuneFrequency( previous, CommandSender::Unspecified );
   275         mEngineWrapper->tuneFrequency( previous, TuneReason::Unspecified );
   261     } else {
   276     } else {
   262         if ( next == 0 ) {
   277         if ( next == 0 ) {
   263             next = favorites.first();
   278             next = favorites.first();
   264         }
   279         }
   265         LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", currentFreq, next );
   280         LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", currentFreq, next );
   266         mEngineWrapper->tuneFrequency( next, CommandSender::Unspecified );
   281         mEngineWrapper->tuneFrequency( next, TuneReason::Unspecified );
   267     }    
   282     }    
   268 }
   283 }
   269 
   284