41 #include "irlastplayedstationinfo.h" |
41 #include "irlastplayedstationinfo.h" |
42 #include "irqfavoritesdb.h" |
42 #include "irqfavoritesdb.h" |
43 #include "irqsettings.h" |
43 #include "irqsettings.h" |
44 #include "irmediakeyobserver.h" |
44 #include "irmediakeyobserver.h" |
45 #include "ircategoryview.h" |
45 #include "ircategoryview.h" |
46 #include "irstationsview.h" |
|
47 #include "irqlogger.h" |
46 #include "irqlogger.h" |
48 #include "iruidefines.h" |
47 #include "iruidefines.h" |
49 #include "irqsystemeventhandler.h" |
48 #include "irqsystemeventhandler.h" |
50 #include "irplaylist.h" |
49 #include "irplaylist.h" |
|
50 #include "irabstractlistviewbase.h" |
51 |
51 |
52 #define INTERNETRADIO_SERVICE_NAME "internet_radio_10_1.com.nokia.symbian.IFileView" |
52 #define INTERNETRADIO_SERVICE_NAME "internet_radio_10_1.com.nokia.symbian.IFileView" |
53 /* |
53 /* |
54 * Description : constructor, initialize all data members |
54 * Description : constructor, initialize all data members |
55 * Parameters : aViewManager : pointer to the view manager object |
55 * Parameters : aViewManager : pointer to the view manager object |
72 iAdvertisementClient(NULL), |
72 iAdvertisementClient(NULL), |
73 iEnableGlobalAdv(true), |
73 iEnableGlobalAdv(true), |
74 iDisconnected(false), |
74 iDisconnected(false), |
75 iConnectingCanceled(false), |
75 iConnectingCanceled(false), |
76 iLocalServer(NULL), |
76 iLocalServer(NULL), |
77 iConnectingNote(NULL), |
77 iLoadingNote(NULL), |
78 #ifdef LOCALIZATION |
78 #ifdef LOCALIZATION |
79 iTranslator(NULL), |
79 iTranslator(NULL), |
80 #endif |
80 #endif |
81 iSystemEventHandler(aSystemEventHandler), |
81 iSystemEventHandler(aSystemEventHandler), |
82 iPlayList(NULL) |
82 iPlayList(NULL) |
151 if (!XQServiceUtil::isService()) |
151 if (!XQServiceUtil::isService()) |
152 { |
152 { |
153 //normal launch, launch starting view |
153 //normal launch, launch starting view |
154 TIRViewId viewId = EIRView_CategoryView; |
154 TIRViewId viewId = EIRView_CategoryView; |
155 iSettings->getStartingViewId(viewId); |
155 iSettings->getStartingViewId(viewId); |
|
156 if (EIRView_PlayingView == viewId) |
|
157 { |
|
158 //handle error case |
|
159 if (NULL == getLastPlayedStationInfo()->getLastPlayedStation()) |
|
160 { |
|
161 viewId = EIRView_CategoryView; |
|
162 } |
|
163 } |
|
164 |
156 launchStartingView(viewId); |
165 launchStartingView(viewId); |
157 } |
166 } |
158 } |
167 } |
159 |
168 |
160 /* |
169 /* |
180 } |
189 } |
181 |
190 |
182 return ret; |
191 return ret; |
183 } |
192 } |
184 |
193 |
185 void IRApplication::createConnectingDialog() |
194 void IRApplication::createLoadingDialog(const QObject *aReceiver, const char *aFunc) |
186 { |
195 { |
187 LOG_METHOD_ENTER; |
196 LOG_METHOD_ENTER; |
188 if (NULL == iConnectingNote) |
197 |
189 { |
198 //for downloading logos in stations view, favorites view and history view, network connection |
190 iConnectingNote = new HbProgressDialog(HbProgressDialog::WaitDialog); |
199 //is initiated by low layer, we don't show any dialog |
191 iConnectingNote->setModal(true); |
200 if (!iNetworkController->getNetworkStatus()) |
192 iConnectingNote->setTimeout(HbPopup::NoTimeout); |
201 { |
193 QAction *action = iConnectingNote->actions().at(0); |
202 IRBaseView *currentView = static_cast<IRBaseView*>(iViewManager->currentView()); |
|
203 if (currentView && EIR_UseNetwork_NoReason == currentView->getUseNetworkReason()) |
|
204 { |
|
205 return; |
|
206 } |
|
207 } |
|
208 |
|
209 if (NULL == iLoadingNote) |
|
210 { |
|
211 iLoadingNote = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
212 iLoadingNote->setModal(true); |
|
213 iLoadingNote->setTimeout(HbPopup::NoTimeout); |
|
214 QAction *action = iLoadingNote->actions().at(0); |
194 action->setText(hbTrId("txt_common_button_cancel")); |
215 action->setText(hbTrId("txt_common_button_cancel")); |
195 connect(action, SIGNAL(triggered()), this, SLOT(cancelConnect())); |
216 } |
196 } |
217 |
197 |
218 iLoadingNote->disconnect(SIGNAL(cancelled())); |
198 iConnectingNote->setText(iConnectingText); |
219 connect(iLoadingNote, SIGNAL(cancelled()), aReceiver, aFunc); |
199 iConnectingNote->show(); |
220 |
200 } |
221 if (iLoadingNote->isVisible()) |
201 |
222 { |
202 void IRApplication::closeConnectingDialog() |
223 return; |
|
224 } |
|
225 |
|
226 //if iConnectingText == "", network connection is initiated by lower layer (eg. downloading logos) |
|
227 if ("" != iConnectingText) |
|
228 { |
|
229 iLoadingNote->setText(iConnectingText); |
|
230 iConnectingText = ""; |
|
231 } |
|
232 else |
|
233 { |
|
234 iLoadingNote->setText(hbTrId("txt_common_info_loading")); |
|
235 } |
|
236 |
|
237 iLoadingNote->show(); |
|
238 } |
|
239 |
|
240 void IRApplication::closeLoadingDialog() |
203 { |
241 { |
204 LOG_METHOD_ENTER; |
242 LOG_METHOD_ENTER; |
205 if (iConnectingNote) |
243 if (iLoadingNote) |
206 { |
244 { |
207 iConnectingNote->close(); |
245 iLoadingNote->close(); |
208 delete iConnectingNote; |
|
209 iConnectingNote = NULL; |
|
210 } |
246 } |
211 } |
247 } |
212 |
248 |
213 /* |
249 /* |
214 * Description : return the pointer to the view manager object |
250 * Description : return the pointer to the view manager object |
435 { |
472 { |
436 LOG_SLOT_CALLER; |
473 LOG_SLOT_CALLER; |
437 switch (aEvent) |
474 switch (aEvent) |
438 { |
475 { |
439 case EIRQNetworkConnectionConnecting : |
476 case EIRQNetworkConnectionConnecting : |
440 createConnectingDialog(); |
477 createLoadingDialog(this, SLOT(cancelConnect())); |
441 iConnectingCanceled = false; |
478 iConnectingCanceled = false; |
442 break; |
479 break; |
443 |
480 |
444 case EIRQNetworkConnectionEstablished : |
481 case EIRQNetworkConnectionEstablished : |
445 iDisconnected = false; |
482 iDisconnected = false; |
469 } |
505 } |
470 break; |
506 break; |
471 |
507 |
472 case EIRQDisplayNetworkMessageNoConnectivity: |
508 case EIRQDisplayNetworkMessageNoConnectivity: |
473 { |
509 { |
474 closeConnectingDialog(); |
510 closeLoadingDialog(); |
475 HbMessageBox::warning(hbTrId("txt_irad_info_no_network_connectiion"), (QObject*)NULL, NULL); |
511 HbMessageBox::warning(hbTrId("txt_irad_info_no_network_connectiion"), (QObject*)NULL, NULL); |
476 if (!iDisconnected) |
512 if (!iDisconnected) |
477 { |
513 { |
478 /* the handling is up to each view */ |
514 /* the handling is up to each view */ |
479 iNetworkController->notifyActiveNetworkObservers(EIRQDisplayNetworkMessageNoConnectivity); |
515 iNetworkController->notifyActiveNetworkObservers(EIRQDisplayNetworkMessageNoConnectivity); |
553 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
589 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
554 Q_ASSERT(currView); |
590 Q_ASSERT(currView); |
555 |
591 |
556 if (EIR_UseNetwork_LoadCategory == currView->getUseNetworkReason()) |
592 if (EIR_UseNetwork_LoadCategory == currView->getUseNetworkReason()) |
557 { |
593 { |
558 closeConnectingDialog(); |
|
559 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
594 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
560 categoryView->loadCategory(IRQIsdsClient::EGenre); |
595 categoryView->loadCategory(IRQIsdsClient::EGenre); |
561 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
596 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
562 return EIR_NoDefault; |
597 return EIR_NoDefault; |
563 } |
598 } |
597 } |
632 } |
598 } |
633 } |
599 |
634 |
600 void IRApplication::setExitingView() |
635 void IRApplication::setExitingView() |
601 { |
636 { |
602 IRQSettings *settings = getSettings(); |
637 if (XQServiceUtil::isService()) |
603 TIRViewId viewId = iViewManager->currentViewId(); |
638 { |
604 |
639 return; |
605 switch (viewId) |
640 } |
606 { |
641 TIRViewId viewId = iViewManager->getExitingView(); |
607 case EIRView_MainView: |
642 if(EIRView_InvalidId != viewId) |
608 case EIRView_FavoritesView: |
643 { |
609 case EIRView_PlayingView: |
644 getSettings()->setStartingViewId(viewId); |
610 settings->setStartingViewId(viewId); |
|
611 break; |
|
612 |
|
613 default: |
|
614 settings->setStartingViewId(EIRView_CategoryView); |
|
615 break; |
|
616 } |
645 } |
617 } |
646 } |
618 |
647 |
619 void IRApplication::startLocalServer() |
648 void IRApplication::startLocalServer() |
620 { |
649 { |
646 |
675 |
647 bool IRApplication::eventFilter(QObject *object, QEvent *event) |
676 bool IRApplication::eventFilter(QObject *object, QEvent *event) |
648 { |
677 { |
649 bool eventWasConsumed = false; |
678 bool eventWasConsumed = false; |
650 |
679 |
651 if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER |
680 if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER) |
652 && event->type() == QEvent::GraphicsSceneMousePress) |
681 { |
653 { |
682 if( (EIRView_PlayingView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) \ |
654 eventWasConsumed = true; |
683 ||(EIRView_SearchView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) ) |
655 Q_ASSERT(iPlayController->isPlaying()); |
684 { |
656 iViewManager->activateView(EIRView_PlayingView); |
685 return false; |
|
686 } |
|
687 |
|
688 if (event->type() == QEvent::GraphicsSceneMousePress) |
|
689 { |
|
690 eventWasConsumed = true; |
|
691 Q_ASSERT(iPlayController->isPlaying()); |
|
692 IrAbstractListViewBase* listview = static_cast<IrAbstractListViewBase*>(iViewManager->currentView()); |
|
693 listview->setPlayingBannerTextColor("qtc_multimedia_trans_pressed"); |
|
694 } |
|
695 else if(event->type() == QEvent::GraphicsSceneMouseRelease) |
|
696 { |
|
697 eventWasConsumed = true; |
|
698 Q_ASSERT(iPlayController->isPlaying()); |
|
699 IrAbstractListViewBase* listview = static_cast<IrAbstractListViewBase*>(iViewManager->currentView()); |
|
700 listview->setPlayingBannerTextColor("qtc_multimedia_trans_normal"); |
|
701 iViewManager->activateView(EIRView_PlayingView); |
|
702 } |
657 } |
703 } |
658 return eventWasConsumed; |
704 return eventWasConsumed; |
659 } |
705 } |
660 |
706 |
661 void IRApplication::startSystemEventMonitor() |
707 void IRApplication::startSystemEventMonitor() |
662 { |
708 { |
663 connect(iSystemEventHandler, SIGNAL(diskSpaceLowNotification(qint64)), |
709 connect(iSystemEventHandler, SIGNAL(diskSpaceLowNotification(qint64)), |
664 this, SLOT(handleDiskSpaceLow(qint64))); |
710 this, SLOT(handleDiskSpaceLow(qint64))); |
|
711 connect(iSystemEventHandler, SIGNAL(callActivated()), this, SLOT(handleCallActivated())); |
|
712 connect(iSystemEventHandler, SIGNAL(callDeactivated()), this, SLOT(handleCallDeactivated())); |
665 iSystemEventHandler->start(); |
713 iSystemEventHandler->start(); |
666 } |
714 } |
667 |
715 |
668 void IRApplication::handleDiskSpaceLow(qint64 aCriticalLevel) |
716 void IRApplication::handleDiskSpaceLow(qint64 aCriticalLevel) |
669 { |
717 { |
671 HbDeviceMessageBox messageBox(hbTrId("txt_irad_info_no_space_on_c_drive_internet_radio_closed"), |
719 HbDeviceMessageBox messageBox(hbTrId("txt_irad_info_no_space_on_c_drive_internet_radio_closed"), |
672 HbMessageBox::MessageTypeWarning); |
720 HbMessageBox::MessageTypeWarning); |
673 messageBox.setTimeout(HbPopup::NoTimeout); |
721 messageBox.setTimeout(HbPopup::NoTimeout); |
674 messageBox.exec(); |
722 messageBox.exec(); |
675 qApp->quit(); |
723 qApp->quit(); |
|
724 } |
|
725 |
|
726 void IRApplication::handleCallActivated() |
|
727 { |
|
728 LOG_METHOD; |
|
729 //for the buffering state needs more attention, we firstly |
|
730 //don't handle it, improve in future. |
|
731 if( iPlayController->isPlaying() /*|| iPlayController->isBuffering()*/) |
|
732 { |
|
733 iPlayController->stop(EIRQCallIsActivated); |
|
734 closeLoadingDialog(); |
|
735 } |
|
736 |
|
737 //for we don't cancel the loading when call is activated, |
|
738 //so, here , we don't add the handling for it. |
|
739 } |
|
740 |
|
741 void IRApplication::handleCallDeactivated() |
|
742 { |
|
743 LOG_METHOD; |
|
744 if( iPlayController->getStopReason() == EIRQCallIsActivated ) |
|
745 { |
|
746 iPlayController->resume(); |
|
747 } |
|
748 } |
|
749 |
|
750 void IRApplication::handleHeadsetConnected() |
|
751 { |
|
752 LOG_METHOD; |
|
753 } |
|
754 |
|
755 void IRApplication::handleHeadsetDisconnected() |
|
756 { |
|
757 LOG_METHOD; |
676 } |
758 } |
677 |
759 |
678 #ifdef _DEBUG |
760 #ifdef _DEBUG |
679 void IRApplication::readConfiguration() |
761 void IRApplication::readConfiguration() |
680 { |
762 { |