qtinternetradio/ui/src/irmonitorservice.cpp
changeset 15 065198191975
parent 12 608f67c22514
equal deleted inserted replaced
14:896e9dbc5f19 15:065198191975
    48     mStationLogoAvailable(false),
    48     mStationLogoAvailable(false),
    49     mIrState(IrAppState::Unknown),
    49     mIrState(IrAppState::Unknown),
    50     mIrApp(aIrApp),
    50     mIrApp(aIrApp),
    51     mPlayController(NULL)
    51     mPlayController(NULL)
    52 {   
    52 {   
       
    53     LOG_METHOD;
    53     publishAll();
    54     publishAll();
    54     mPlayController = mIrApp->getPlayController();
    55     mPlayController = mIrApp->getPlayController();
    55     setupConnection();
    56     setupConnection();
    56 }
    57 }
    57 
    58 
    58 // Destructor
    59 // Destructor
    59 IrMonitorService::~IrMonitorService()
    60 IrMonitorService::~IrMonitorService()
    60 {
    61 {
       
    62     LOG_METHOD;
    61 }
    63 }
    62 
    64 
    63 void IrMonitorService::setupConnection()
    65 void IrMonitorService::setupConnection()
    64 {
    66 {
       
    67     LOG_METHOD;
    65     // meta data update
    68     // meta data update
    66     connect(mPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), 
    69     connect(mPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), 
    67         this, SLOT(updateMetaData(IRQMetaData*)));
    70         this, SLOT(updateMetaData(IRQMetaData*)));
    68     // station logo update
    71     // station logo update
    69     connect(mPlayController, SIGNAL(stationLogoUpdated(bool)), 
    72     connect(mPlayController, SIGNAL(stationLogoUpdated(bool)), 
    89 }
    92 }
    90 
    93 
    91 // service interface, called via Qt Highway
    94 // service interface, called via Qt Highway
    92 void IrMonitorService::registerNotifications()
    95 void IrMonitorService::registerNotifications()
    93 {
    96 {
       
    97     LOG_METHOD;
    94     mRequestList.append(setCurrentRequestAsync());
    98     mRequestList.append(setCurrentRequestAsync());
    95     
    99     
    96     if (ANY_READY())
   100     if (ANY_READY())
    97     {
   101     {
    98         notifyAll();
   102         notifyAll();
   100 }
   104 }
   101 
   105 
   102 // service interface, called via Qt Highway
   106 // service interface, called via Qt Highway
   103 void IrMonitorService::refreshAllData()
   107 void IrMonitorService::refreshAllData()
   104 {
   108 {
       
   109     LOG_METHOD;
   105     IrServiceDataList notificationList;
   110     IrServiceDataList notificationList;
   106     
   111     
   107     IRQPreset * currentPreset = mPlayController->getNowPlayingPreset();    
   112     IRQPreset * currentPreset = mPlayController->getNowPlayingPreset();    
       
   113     
       
   114     LOG_FORMAT("mPlayController->state() = %d", mPlayController->state());
   108     
   115     
   109     switch (mPlayController->state())
   116     switch (mPlayController->state())
   110     {
   117     {
   111         case IRPlayController::EIdle:
   118         case IRPlayController::EIdle:
   112             notificationList.append(IrServiceData((int)IrServiceNotification::IrState, (int)IrAppState::RunningInit));
   119             notificationList.append(IrServiceData((int)IrServiceNotification::IrState, (int)IrAppState::RunningInit));
   158  *******************************************************************************************************
   165  *******************************************************************************************************
   159  */
   166  */
   160 
   167 
   161 void IrMonitorService::updateMetaData(IRQMetaData* aMetaData)
   168 void IrMonitorService::updateMetaData(IRQMetaData* aMetaData)
   162 {    
   169 {    
       
   170     LOG_METHOD;
   163     if (aMetaData)
   171     if (aMetaData)
   164     {
   172     {
   165         SET_FLAG(MetaData);
   173         SET_FLAG(MetaData);
   166         mMetaData = aMetaData->getArtistSongName();
   174         mMetaData = aMetaData->getArtistSongName();
   167         
   175         
   169     }
   177     }
   170 }
   178 }
   171  
   179  
   172 void IrMonitorService::handleStationLogoUpdated(bool aLogoAvailable)
   180 void IrMonitorService::handleStationLogoUpdated(bool aLogoAvailable)
   173 {
   181 {
       
   182     LOG_METHOD;
   174     mStationLogoAvailable = aLogoAvailable;
   183     mStationLogoAvailable = aLogoAvailable;
   175     SET_FLAG(StationLogo);
   184     SET_FLAG(StationLogo);
   176     
   185     
   177     notifyAll();
   186     notifyAll();
   178 }
   187 }
   179  
   188  
   180 void IrMonitorService::handleLoadingStarted(const QString &aStationName)
   189 void IrMonitorService::handleLoadingStarted(const QString &aStationName)
   181 {
   190 {
       
   191     LOG_METHOD;
   182     mMetaData.clear();
   192     mMetaData.clear();
   183     SET_FLAG(MetaData);
   193     SET_FLAG(MetaData);
   184     
   194     
   185     mStationName = aStationName;        
   195     mStationName = aStationName;        
   186     SET_FLAG(StationName);
   196     SET_FLAG(StationName);
   191     notifyAll();
   201     notifyAll();
   192 }
   202 }
   193 
   203 
   194 void IrMonitorService::handleLoadingCancelled(const QString &aStationName)
   204 void IrMonitorService::handleLoadingCancelled(const QString &aStationName)
   195 {
   205 {
       
   206     LOG_METHOD;
   196     mMetaData.clear();
   207     mMetaData.clear();
   197     SET_FLAG(MetaData);
   208     SET_FLAG(MetaData);
   198     
   209     
   199     mStationName = aStationName;
   210     mStationName = aStationName;
   200     SET_FLAG(StationName);
   211     SET_FLAG(StationName);
   212     notifyAll();
   223     notifyAll();
   213 }
   224 }
   214 
   225 
   215 void IrMonitorService::handlePlayStarted()
   226 void IrMonitorService::handlePlayStarted()
   216 {
   227 {
       
   228     LOG_METHOD;
   217     mMetaData.clear();
   229     mMetaData.clear();
   218     SET_FLAG(MetaData);
   230     SET_FLAG(MetaData);
   219     
   231     
   220     IRQPreset * currentPreset = mPlayController->getNowPlayingPreset();
   232     IRQPreset * currentPreset = mPlayController->getNowPlayingPreset();
   221     mStationName = currentPreset->name;
   233     mStationName = currentPreset->name;
   227     notifyAll();
   239     notifyAll();
   228 }
   240 }
   229 
   241 
   230 void IrMonitorService::handlePlayStopped()
   242 void IrMonitorService::handlePlayStopped()
   231 {
   243 {
       
   244     LOG_METHOD;
   232     mMetaData.clear();
   245     mMetaData.clear();
   233     SET_FLAG(MetaData);
   246     SET_FLAG(MetaData);
   234 
   247 
   235     mIrState = IrAppState::RunningStopped;
   248     mIrState = IrAppState::RunningStopped;
   236     SET_FLAG(IrState);
   249     SET_FLAG(IrState);
   243  * Others
   256  * Others
   244  *******************************************************************************************************
   257  *******************************************************************************************************
   245  */
   258  */
   246 void IrMonitorService::notifyAll()
   259 void IrMonitorService::notifyAll()
   247 {
   260 {
       
   261     LOG_METHOD;
   248     IrServiceDataList notificationList;
   262     IrServiceDataList notificationList;
   249     
   263     
   250     if(IS_READY(StationName))
   264     if(IS_READY(StationName))
   251     {
   265     {
   252         notificationList.append(IrServiceData((int)IrServiceNotification::StationName, mStationName)); 
   266         notificationList.append(IrServiceData((int)IrServiceNotification::StationName, mStationName)); 
   273     }
   287     }
   274 }
   288 }
   275 
   289 
   276 bool IrMonitorService::notifyList(const IrServiceDataList &aDataList)
   290 bool IrMonitorService::notifyList(const IrServiceDataList &aDataList)
   277 {
   291 {
       
   292     LOG_METHOD;
   278     bool retVal = true;
   293     bool retVal = true;
   279     
   294     
   280     if (mRequestList.count() > 0
   295     if (mRequestList.count() > 0
   281         && aDataList.count() > 0)
   296         && aDataList.count() > 0)
   282     {
   297     {