14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <hbaction.h> |
18 #include <hbaction.h> |
|
19 #include <hbapplication.h> |
19 #include <qcoreapplication.h> |
20 #include <qcoreapplication.h> |
20 #include <hbdevicemessagebox.h> |
21 #include <hbdevicemessagebox.h> |
21 #include <hbprogressdialog.h> |
22 #include <hbprogressdialog.h> |
22 #include <QLocalServer> |
23 #include <QLocalServer> |
23 #include <QLocalSocket> |
24 #include <QLocalSocket> |
24 #include <QFile> |
25 #include <QFile> |
25 #include <QTextStream> |
26 #include <QTextStream> |
26 #include <QDir> |
27 #include <QDir> |
27 #include <xqsharablefile.h> |
28 #include <hbmessagebox.h> |
|
29 |
28 #include <xqserviceutil.h> |
30 #include <xqserviceutil.h> |
|
31 #include <hbiconitem.h> |
|
32 #include <hbiconanimator.h> |
|
33 #include <hbiconanimationmanager.h> |
|
34 #ifdef HS_WIDGET_ENABLED |
|
35 #include <XQSettingsManager> |
|
36 #include <XQPublishAndSubscribeSettingsKey> |
|
37 #include <XQPublishAndSubscribeUtils> |
|
38 #include <QDateTime> |
|
39 #endif |
29 |
40 |
30 #ifdef LOCALIZATION |
41 #ifdef LOCALIZATION |
31 #include <QTranslator> |
42 #include <QTranslator> |
32 #include "irqutility.h" |
43 #include "irqutility.h" |
33 #endif |
44 #endif |
41 #include "irlastplayedstationinfo.h" |
52 #include "irlastplayedstationinfo.h" |
42 #include "irqfavoritesdb.h" |
53 #include "irqfavoritesdb.h" |
43 #include "irqsettings.h" |
54 #include "irqsettings.h" |
44 #include "irmediakeyobserver.h" |
55 #include "irmediakeyobserver.h" |
45 #include "ircategoryview.h" |
56 #include "ircategoryview.h" |
46 #include "irstationsview.h" |
|
47 #include "irqlogger.h" |
57 #include "irqlogger.h" |
48 #include "iruidefines.h" |
58 #include "iruidefines.h" |
49 #include "irqsystemeventhandler.h" |
59 #include "irqsystemeventhandler.h" |
50 #include "irplaylist.h" |
60 #include "irabstractlistviewbase.h" |
51 |
61 #include "irfileviewservice.h" |
52 #define INTERNETRADIO_SERVICE_NAME "internet_radio_10_1.com.nokia.symbian.IFileView" |
62 #ifdef HS_WIDGET_ENABLED |
|
63 #include "irmonitorservice.h" |
|
64 #include "ircontrolservice.h" |
|
65 #include "irservicedef.h" |
|
66 #include "irqisdsdatastructure.h" |
|
67 #include "irsearchchannelsview.h" |
|
68 #endif |
53 /* |
69 /* |
54 * Description : constructor, initialize all data members |
70 * Description : constructor, initialize all data members |
55 * Parameters : aViewManager : pointer to the view manager object |
71 * Parameters : aViewManager : pointer to the view manager object |
56 * Return : None |
72 * Return : None |
57 */ |
73 */ |
58 IRApplication::IRApplication(IRViewManager* aViewManager, IRQSystemEventHandler* aSystemEventHandler): |
74 IRApplication::IRApplication(IRViewManager* aViewManager, IRQSystemEventHandler* aSystemEventHandler): |
59 XQServiceProvider(INTERNETRADIO_SERVICE_NAME), |
|
60 #ifdef _DEBUG |
75 #ifdef _DEBUG |
61 iTestPreferredBitrate(false), |
76 iTestPreferredBitrate(false), |
62 #endif |
77 #endif |
63 iViewManager(aViewManager), |
78 iViewManager(aViewManager), |
64 iStartingViewId(EIRView_CategoryView), |
79 iStartingViewId(EIRView_CategoryView), |
72 iAdvertisementClient(NULL), |
87 iAdvertisementClient(NULL), |
73 iEnableGlobalAdv(true), |
88 iEnableGlobalAdv(true), |
74 iDisconnected(false), |
89 iDisconnected(false), |
75 iConnectingCanceled(false), |
90 iConnectingCanceled(false), |
76 iLocalServer(NULL), |
91 iLocalServer(NULL), |
77 iConnectingNote(NULL), |
92 iLoadingNote(NULL), |
78 #ifdef LOCALIZATION |
93 #ifdef LOCALIZATION |
79 iTranslator(NULL), |
94 iTranslator(NULL), |
80 #endif |
95 #endif |
81 iSystemEventHandler(aSystemEventHandler), |
96 iSystemEventHandler(aSystemEventHandler), |
82 iPlayList(NULL) |
97 iUseNetworkReason(EIR_UseNetwork_NoReason), |
|
98 iAppFullyStarted(false), |
|
99 #ifdef HS_WIDGET_ENABLED |
|
100 iControlService(NULL), |
|
101 iMonitorService(NULL), |
|
102 #endif |
|
103 iFileViewService(NULL), |
|
104 iMessageBox(NULL) |
83 |
105 |
84 { |
106 { |
85 LOG_METHOD; |
107 LOG_METHOD; |
86 if (XQServiceUtil::isService()) |
|
87 { |
|
88 //Publishes all public slots on this object |
|
89 publishAll(); |
|
90 } |
|
91 |
108 |
92 iViewManager->setApplication(this); |
109 iViewManager->setApplication(this); |
93 iInitEvent = static_cast<QEvent::Type>(QEvent::registerEventType()); |
110 iInitEvent = static_cast<QEvent::Type>(QEvent::registerEventType()); |
94 |
111 |
95 #ifdef _DEBUG |
112 #ifdef _DEBUG |
110 */ |
139 */ |
111 IRApplication::~IRApplication() |
140 IRApplication::~IRApplication() |
112 { |
141 { |
113 LOG_METHOD; |
142 LOG_METHOD; |
114 setExitingView(); |
143 setExitingView(); |
|
144 iViewManager->saveActivity(); |
|
145 |
115 destroyComponents(); |
146 destroyComponents(); |
116 |
147 |
117 if (iLocalServer) |
148 if (iLocalServer) |
118 { |
149 { |
119 iLocalServer->close(); |
150 iLocalServer->close(); |
120 } |
151 } |
121 |
152 |
122 delete iLastPlayedStationInfo; |
153 delete iLastPlayedStationInfo; |
123 iLastPlayedStationInfo = NULL; |
154 iLastPlayedStationInfo = NULL; |
124 |
155 |
125 delete iConnectingNote; |
156 delete iLoadingNote; |
126 iConnectingNote = NULL; |
157 iLoadingNote = NULL; |
|
158 |
|
159 delete iMessageBox; |
|
160 iMessageBox = NULL; |
127 |
161 |
128 delete iSystemEventHandler; |
162 delete iSystemEventHandler; |
129 |
|
130 delete iPlayList; |
|
131 |
163 |
132 #ifdef LOCALIZATION |
164 #ifdef LOCALIZATION |
133 if( iTranslator ) |
165 if( iTranslator ) |
134 { |
166 { |
135 qApp->removeTranslator(iTranslator); |
167 qApp->removeTranslator(iTranslator); |
136 delete iTranslator; |
168 delete iTranslator; |
137 iTranslator = NULL; |
169 iTranslator = NULL; |
138 } |
170 } |
139 #endif |
171 #endif |
|
172 |
|
173 delete iFileViewService; |
|
174 iFileViewService = NULL; |
|
175 |
|
176 #ifdef HS_WIDGET_ENABLED |
|
177 XQSettingsManager settingsManager; |
|
178 XQPublishAndSubscribeUtils psUtils(settingsManager); |
|
179 XQPublishAndSubscribeSettingsKey irStartupKey(KInternetRadioPSUid, KInternetRadioStartupKey); |
|
180 psUtils.deleteProperty(irStartupKey); |
|
181 #endif |
140 } |
182 } |
141 |
183 |
142 |
184 |
143 /* |
185 /* |
144 * Description : When ir application is launched, set the correct view according to whether the |
186 * Description : When ir application is launched, set the correct view according to whether the |
146 * Parameters : None |
188 * Parameters : None |
147 * Return : None |
189 * Return : None |
148 */ |
190 */ |
149 void IRApplication::setLaunchView() |
191 void IRApplication::setLaunchView() |
150 { |
192 { |
151 if (!XQServiceUtil::isService()) |
193 //get starting view id according to activate reason |
152 { |
194 TIRViewId viewId = EIRView_CategoryView; |
153 //normal launch, launch starting view |
195 HbApplication *hbApp = qobject_cast<HbApplication*>(qApp); |
154 TIRViewId viewId = EIRView_CategoryView; |
196 |
|
197 if (hbApp->activateReason() == Hb::ActivationReasonActivity) |
|
198 { |
|
199 QVariant data = hbApp->activateData(); |
|
200 QByteArray serializedModel = data.toByteArray(); |
|
201 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
202 int id = 0; |
|
203 stream>>id; |
|
204 viewId = TIRViewId(id); |
|
205 } |
|
206 else |
|
207 { |
155 iSettings->getStartingViewId(viewId); |
208 iSettings->getStartingViewId(viewId); |
156 launchStartingView(viewId); |
209 if (EIRView_PlayingView == viewId) |
157 } |
210 { |
|
211 //handle error case |
|
212 if (NULL == getLastPlayedStationInfo()->getLastPlayedStation()) |
|
213 { |
|
214 viewId = EIRView_CategoryView; |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 launchStartingView(viewId); |
158 } |
220 } |
159 |
221 |
160 /* |
222 /* |
161 * Description : verify if the network connection has been established |
223 * Description : verify if the network connection has been established |
162 * Parameters : None |
224 * Parameters : None |
169 |
231 |
170 bool ret = true; |
232 bool ret = true; |
171 |
233 |
172 if (!iNetworkController->getNetworkStatus()) |
234 if (!iNetworkController->getNetworkStatus()) |
173 { |
235 { |
|
236 LOG( "IRApplication::verifyNetworkConnectivity--1"); |
174 ret = false; |
237 ret = false; |
175 if (!iNetworkController->isConnectRequestIssued()) |
238 if (!iNetworkController->isConnectRequestIssued()) |
176 { |
239 { |
|
240 LOG( "IRApplication::verifyNetworkConnectivity--2"); |
177 iConnectingText = aConnectingText; |
241 iConnectingText = aConnectingText; |
178 iNetworkController->chooseAccessPoint(); |
242 iNetworkController->chooseAccessPoint(); |
179 } |
243 } |
180 } |
244 } |
181 |
245 |
182 return ret; |
246 return ret; |
183 } |
247 } |
184 |
248 |
185 void IRApplication::createConnectingDialog() |
249 void IRApplication::startLoadingAnimation(const QObject *aReceiver, const char *aFunc) |
186 { |
250 { |
187 LOG_METHOD_ENTER; |
251 LOG_METHOD_ENTER; |
188 if (NULL == iConnectingNote) |
252 |
189 { |
253 //for downloading logos in stations view, favorites view and history view, network connection |
190 iConnectingNote = new HbProgressDialog(HbProgressDialog::WaitDialog); |
254 //is initiated by low layer, we don't show any dialog |
191 iConnectingNote->setModal(true); |
255 if (!iNetworkController->getNetworkStatus()) |
192 iConnectingNote->setTimeout(HbPopup::NoTimeout); |
256 { |
193 QAction *action = iConnectingNote->actions().at(0); |
257 if (EIR_UseNetwork_NoReason == iUseNetworkReason) // network is not used by the Application |
|
258 { |
|
259 IRBaseView *currentView = static_cast<IRBaseView*>(iViewManager->currentView()); |
|
260 if (currentView && EIR_UseNetwork_NoReason == currentView->getUseNetworkReason()) |
|
261 { |
|
262 return; |
|
263 } |
|
264 } |
|
265 } |
|
266 |
|
267 if (NULL == iLoadingNote) |
|
268 { |
|
269 iLoadingNote = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
270 iLoadingNote->setModal(true); |
|
271 iLoadingNote->setTimeout(HbPopup::NoTimeout); |
|
272 QAction *action = iLoadingNote->actions().at(0); |
|
273 #ifdef SUBTITLE_STR_BY_LOCID |
194 action->setText(hbTrId("txt_common_button_cancel")); |
274 action->setText(hbTrId("txt_common_button_cancel")); |
195 connect(action, SIGNAL(triggered()), this, SLOT(cancelConnect())); |
275 #else |
196 } |
276 action->setText(hbTrId("Cancel")); |
197 |
277 #endif |
198 iConnectingNote->setText(iConnectingText); |
278 } |
199 iConnectingNote->show(); |
279 |
200 } |
280 iLoadingNote->disconnect(SIGNAL(cancelled())); |
201 |
281 connect(iLoadingNote, SIGNAL(cancelled()), aReceiver, aFunc); |
202 void IRApplication::closeConnectingDialog() |
282 |
|
283 if (iLoadingNote->isVisible()) |
|
284 { |
|
285 return; |
|
286 } |
|
287 |
|
288 //if iConnectingText == "", network connection is initiated by lower layer (eg. downloading logos) |
|
289 if ("" != iConnectingText) |
|
290 { |
|
291 iLoadingNote->setText(iConnectingText); |
|
292 iConnectingText = ""; |
|
293 } |
|
294 else |
|
295 { |
|
296 #ifdef SUBTITLE_STR_BY_LOCID |
|
297 iLoadingNote->setText(hbTrId("txt_common_info_loading")); |
|
298 #else |
|
299 iLoadingNote->setText(hbTrId("Loading")); |
|
300 #endif |
|
301 } |
|
302 |
|
303 iLoadingNote->show(); |
|
304 } |
|
305 |
|
306 void IRApplication::stopLoadingAnimation() |
203 { |
307 { |
204 LOG_METHOD_ENTER; |
308 LOG_METHOD_ENTER; |
205 if (iConnectingNote) |
309 |
206 { |
310 // this function is the endpoint of cancel loading actions for all views |
207 iConnectingNote->close(); |
311 // so we can do cleanup action here, including player stop action. |
208 delete iConnectingNote; |
312 // No need to stop the player in each views in the slot connected to the cancel signal of the loading note |
209 iConnectingNote = NULL; |
313 if (!getPlayController()->isPlaying()) |
210 } |
314 { |
|
315 getPlayController()->stop(EIRQUnknownTermination); |
|
316 } |
|
317 |
|
318 if (iLoadingNote) |
|
319 { |
|
320 iLoadingNote->close(); |
|
321 } |
211 } |
322 } |
212 |
323 |
213 /* |
324 /* |
214 * Description : return the pointer to the view manager object |
325 * Description : return the pointer to the view manager object |
215 * Parameters : None |
326 * Parameters : None |
321 void IRApplication::setTranslator(QTranslator* aTranslator) |
439 void IRApplication::setTranslator(QTranslator* aTranslator) |
322 { |
440 { |
323 iTranslator = aTranslator; |
441 iTranslator = aTranslator; |
324 } |
442 } |
325 #endif |
443 #endif |
326 |
|
327 void IRApplication::view(const QString &aFileName) |
|
328 { |
|
329 if (NULL == iPlayList) |
|
330 { |
|
331 iPlayList = new IRPlayList; |
|
332 } |
|
333 |
|
334 iPlayList->parseFile(aFileName); |
|
335 |
|
336 if (1 == iPlayList->getNumberOfEntries()) |
|
337 { |
|
338 launchStartingView(EIRView_PlayingView); |
|
339 } |
|
340 else if (iPlayList->getNumberOfEntries() > 1) |
|
341 { |
|
342 launchStartingView(EIRView_PlsView); |
|
343 } |
|
344 else |
|
345 { |
|
346 //normal launch, launch starting view |
|
347 TIRViewId viewId = EIRView_CategoryView; |
|
348 iSettings->getStartingViewId(viewId); |
|
349 launchStartingView(viewId); |
|
350 } |
|
351 } |
|
352 |
|
353 void IRApplication::view(const XQSharableFile &/*aSharableFile*/) |
|
354 { |
|
355 |
|
356 } |
|
357 |
444 |
358 /* |
445 /* |
359 * Description : create all the application level components, including network controller, |
446 * Description : create all the application level components, including network controller, |
360 * favorites db, isds client, play controller, etc |
447 * favorites db, isds client, play controller, etc |
361 * Parameters : None |
448 * Parameters : None |
362 * Return : None |
449 * Return : None |
363 */ |
450 */ |
364 void IRApplication::createComponents() |
451 void IRApplication::createComponents() |
365 { |
452 { |
366 getSettings(); |
453 getSettings(); |
|
454 #ifdef HS_WIDGET_ENABLED |
|
455 iControlService = new IrControlService(this); |
|
456 iMonitorService = new IrMonitorService(this); |
|
457 #endif |
367 } |
458 } |
368 |
459 |
369 /* |
460 /* |
370 * Descriiption : destroy all the application level components |
461 * Descriiption : destroy all the application level components |
371 * Parameters : None |
462 * Parameters : None |
492 LOG_SLOT_CALLER; |
597 LOG_SLOT_CALLER; |
493 bool hasCache = iIsdsClient->isdsIsCategoryCached(IRQIsdsClient::EGenre); |
598 bool hasCache = iIsdsClient->isdsIsCategoryCached(IRQIsdsClient::EGenre); |
494 |
599 |
495 if (!hasCache) |
600 if (!hasCache) |
496 { |
601 { |
497 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
602 iUseNetworkReason = EIR_UseNetwork_LoadCategory; |
498 Q_ASSERT(currView); |
|
499 currView->setUseNetworkReason(EIR_UseNetwork_LoadCategory); |
|
500 if (false == verifyNetworkConnectivity()) |
603 if (false == verifyNetworkConnectivity()) |
501 { |
604 { |
502 return; |
605 return; |
503 } |
606 } |
504 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
607 iUseNetworkReason = EIR_UseNetwork_NoReason; |
505 } |
608 } |
506 |
609 |
507 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
610 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
508 categoryView->loadCategory(IRQIsdsClient::EGenre); |
611 categoryView->loadCategory(IRQIsdsClient::EGenre); |
509 } |
612 } |
516 return; |
619 return; |
517 } |
620 } |
518 delete socket; |
621 delete socket; |
519 |
622 |
520 iViewManager->raise(); |
623 iViewManager->raise(); |
521 } |
624 } |
522 |
625 |
523 void IRApplication::initApp() |
626 void IRApplication::initApp() |
524 { |
627 { |
525 getNetworkController(); |
628 getNetworkController(); |
526 connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)), |
|
527 this, SLOT(networkEventNotified(IRQNetworkEvent))); |
|
528 |
629 |
529 IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView()); |
630 IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView()); |
530 if (view) |
631 if (view) |
531 { |
632 { |
532 view->lazyInit(); |
633 view->lazyInit(); |
533 view->launchAction(); |
634 view->launchAction(); |
534 } |
635 } |
535 getMediaKeyObserver(); |
636 getMediaKeyObserver(); |
536 startSystemEventMonitor(); |
637 startSystemEventMonitor(); |
537 startLocalServer(); |
638 startLocalServer(); |
|
639 //when IR is running, remove activity. Otherwise user can see two items in task switcher |
|
640 iViewManager->removeActivity(); |
|
641 |
|
642 #ifdef HS_WIDGET_ENABLED |
|
643 // Write the startup timestamp to P&S key for the homescreen widget |
|
644 XQSettingsManager settingsManager; |
|
645 XQPublishAndSubscribeUtils psUtils(settingsManager); |
|
646 XQPublishAndSubscribeSettingsKey irStartupKey(KInternetRadioPSUid, KInternetRadioStartupKey); |
|
647 if (psUtils.defineProperty(irStartupKey, XQSettingsManager::TypeInt)) |
|
648 { |
|
649 settingsManager.writeItemValue(irStartupKey, (int)QDateTime::currentDateTime().toTime_t()); |
|
650 } |
|
651 #endif |
538 } |
652 } |
539 |
653 |
540 bool IRApplication::event(QEvent* e) |
654 bool IRApplication::event(QEvent* e) |
541 { |
655 { |
542 if(e->type() == iInitEvent) |
656 if(e->type() == iInitEvent) |
548 return QObject::event(e); |
662 return QObject::event(e); |
549 } |
663 } |
550 |
664 |
551 TIRHandleResult IRApplication::handleConnectionEstablished() |
665 TIRHandleResult IRApplication::handleConnectionEstablished() |
552 { |
666 { |
553 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
667 TIRHandleResult retVal = EIR_DoDefault; |
554 Q_ASSERT(currView); |
668 switch (iUseNetworkReason) |
555 |
669 { |
556 if (EIR_UseNetwork_LoadCategory == currView->getUseNetworkReason()) |
670 case EIR_UseNetwork_LoadCategory: |
557 { |
671 { |
558 closeConnectingDialog(); |
672 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
559 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
673 categoryView->loadCategory(IRQIsdsClient::EGenre); |
560 categoryView->loadCategory(IRQIsdsClient::EGenre); |
674 retVal = EIR_NoDefault; |
561 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
675 break; |
562 return EIR_NoDefault; |
676 } |
563 } |
677 |
564 |
678 #ifdef HS_WIDGET_ENABLED |
565 return EIR_DoDefault; |
679 case EIR_UseNetwork_PlayStation: // play last station when player is in Idle state while there is no connection. |
|
680 getPlayController()->resume(); |
|
681 retVal = EIR_NoDefault; |
|
682 break; |
|
683 #endif |
|
684 default: |
|
685 break; |
|
686 } |
|
687 |
|
688 iUseNetworkReason = EIR_UseNetwork_NoReason; |
|
689 return retVal; |
566 } |
690 } |
567 |
691 |
568 void IRApplication::handleTermsConsAccepted() |
692 void IRApplication::handleTermsConsAccepted() |
569 { |
693 { |
570 iSettings->reSetFlagTermsAndConditions(); |
694 iSettings->reSetFlagTermsAndConditions(); |
578 QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); |
702 QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); |
579 } |
703 } |
580 |
704 |
581 void IRApplication::launchStartingView(TIRViewId aViewId) |
705 void IRApplication::launchStartingView(TIRViewId aViewId) |
582 { |
706 { |
583 bool isFirstTimeUsage = false; |
707 iStartingViewId = aViewId; |
|
708 /* bool isFirstTimeUsage = false; |
584 iSettings->isFlagTermsAndConditions(isFirstTimeUsage); |
709 iSettings->isFlagTermsAndConditions(isFirstTimeUsage); |
585 iStartingViewId = aViewId; |
710 |
586 if(isFirstTimeUsage) |
711 if(isFirstTimeUsage) |
587 { |
712 { |
588 iViewManager->activateView(EIRView_TermsConsView); |
713 iViewManager->activateView(EIRView_TermsConsView); |
589 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
714 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
590 } |
715 } |
591 else |
716 else*/ |
592 { |
717 { |
593 iViewManager->activateView(iStartingViewId); |
718 iViewManager->activateView(iStartingViewId); |
594 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
719 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
595 QEvent* initEvent = new QEvent(iInitEvent); |
720 QEvent* initEvent = new QEvent(iInitEvent); |
596 QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); |
721 QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); |
597 } |
722 } |
|
723 |
|
724 iAppFullyStarted = true; |
|
725 } |
|
726 |
|
727 bool IRApplication::isAppFullyStarted() const |
|
728 { |
|
729 return iAppFullyStarted; |
598 } |
730 } |
599 |
731 |
600 void IRApplication::setExitingView() |
732 void IRApplication::setExitingView() |
601 { |
733 { |
602 IRQSettings *settings = getSettings(); |
734 TIRViewId viewId = iViewManager->getExitingView(); |
603 TIRViewId viewId = iViewManager->currentViewId(); |
735 if(EIRView_InvalidId != viewId) |
604 |
736 { |
605 switch (viewId) |
737 getSettings()->setStartingViewId(viewId); |
606 { |
738 } |
607 case EIRView_MainView: |
739 } |
608 case EIRView_FavoritesView: |
740 |
609 case EIRView_PlayingView: |
741 |
610 settings->setStartingViewId(viewId); |
742 #ifdef HS_WIDGET_ENABLED |
611 break; |
743 bool IRApplication::startPlaying() |
612 |
744 { |
613 default: |
745 // if any loading is in progress, disallow to play |
614 settings->setStartingViewId(EIRView_CategoryView); |
746 if (iLoadingNote && iLoadingNote->isVisible()) |
615 break; |
747 { |
616 } |
748 LOG( "IRApplication::startPlaying() in the return false1"); |
617 } |
749 return false; |
|
750 } |
|
751 |
|
752 if (getPlayController()->isStopped()) |
|
753 { |
|
754 LOG_FORMAT( "IRApplication::startPlaying(), the station name is %s", |
|
755 STRING2CHAR(getPlayController()->getNowPlayingPreset()->name)); |
|
756 iUseNetworkReason = EIR_UseNetwork_PlayStation; |
|
757 getPlayController()->setConnectingStationName(getPlayController()->getNowPlayingPreset()->name); |
|
758 if (verifyNetworkConnectivity()) |
|
759 { |
|
760 iUseNetworkReason = EIR_UseNetwork_NoReason; |
|
761 getPlayController()->resume(); |
|
762 } |
|
763 return true; |
|
764 } |
|
765 else |
|
766 { |
|
767 LOG( "IRApplication::startPlaying() in the return false2"); |
|
768 return false; |
|
769 } |
|
770 } |
|
771 |
|
772 void IRApplication::cancelPlayerLoading() |
|
773 { |
|
774 if (IRPlayController::EConnecting == getPlayController()->state() |
|
775 || IRPlayController::EBuffering == getPlayController()->state()) |
|
776 { |
|
777 if (iLoadingNote && iLoadingNote->isVisible()) |
|
778 { |
|
779 iLoadingNote->cancel(); |
|
780 } |
|
781 } |
|
782 } |
|
783 |
|
784 #endif |
|
785 |
618 |
786 |
619 void IRApplication::startLocalServer() |
787 void IRApplication::startLocalServer() |
620 { |
788 { |
621 QString serverName = QCoreApplication::applicationName(); |
789 QString serverName = QCoreApplication::applicationName(); |
622 iLocalServer = new QLocalServer(this); |
790 iLocalServer = new QLocalServer(this); |
646 |
814 |
647 bool IRApplication::eventFilter(QObject *object, QEvent *event) |
815 bool IRApplication::eventFilter(QObject *object, QEvent *event) |
648 { |
816 { |
649 bool eventWasConsumed = false; |
817 bool eventWasConsumed = false; |
650 |
818 |
651 if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER |
819 if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER) |
652 && event->type() == QEvent::GraphicsSceneMousePress) |
820 { |
653 { |
821 if (NULL == iViewManager->currentView()) |
654 eventWasConsumed = true; |
822 { |
655 Q_ASSERT(iPlayController->isPlaying()); |
823 return false; |
656 iViewManager->activateView(EIRView_PlayingView); |
824 } |
|
825 |
|
826 if( (EIRView_PlayingView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) \ |
|
827 ||(EIRView_SearchView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) ) |
|
828 { |
|
829 return false; |
|
830 } |
|
831 |
|
832 if (event->type() == QEvent::GraphicsSceneMousePress) |
|
833 { |
|
834 eventWasConsumed = true; |
|
835 Q_ASSERT(iPlayController->isPlaying()); |
|
836 IrAbstractListViewBase* listview = static_cast<IrAbstractListViewBase*>(iViewManager->currentView()); |
|
837 listview->setPlayingBannerTextColor("qtc_multimedia_trans_pressed"); |
|
838 } |
|
839 else if(event->type() == QEvent::GraphicsSceneMouseRelease) |
|
840 { |
|
841 eventWasConsumed = true; |
|
842 Q_ASSERT(iPlayController->isPlaying()); |
|
843 IrAbstractListViewBase* listview = static_cast<IrAbstractListViewBase*>(iViewManager->currentView()); |
|
844 listview->setPlayingBannerTextColor("qtc_multimedia_trans_normal"); |
|
845 iViewManager->activateView(EIRView_PlayingView); |
|
846 } |
657 } |
847 } |
658 return eventWasConsumed; |
848 return eventWasConsumed; |
659 } |
849 } |
660 |
850 |
661 void IRApplication::startSystemEventMonitor() |
851 void IRApplication::startSystemEventMonitor() |
662 { |
852 { |
663 connect(iSystemEventHandler, SIGNAL(diskSpaceLowNotification(qint64)), |
853 connect(iSystemEventHandler, SIGNAL(diskSpaceLowNotification(qint64)), |
664 this, SLOT(handleDiskSpaceLow(qint64))); |
854 this, SLOT(handleDiskSpaceLow(qint64))); |
|
855 connect(iSystemEventHandler, SIGNAL(callActivated()), this, SLOT(handleCallActivated())); |
|
856 connect(iSystemEventHandler, SIGNAL(callDeactivated()), this, SLOT(handleCallDeactivated())); |
665 iSystemEventHandler->start(); |
857 iSystemEventHandler->start(); |
666 } |
858 } |
667 |
859 |
668 void IRApplication::handleDiskSpaceLow(qint64 aCriticalLevel) |
860 void IRApplication::handleDiskSpaceLow(qint64 aCriticalLevel) |
669 { |
861 { |
670 Q_UNUSED(aCriticalLevel); |
862 Q_UNUSED(aCriticalLevel); |
671 HbDeviceMessageBox messageBox(hbTrId("txt_irad_info_no_space_on_c_drive_internet_radio_closed"), |
863 #ifdef SUBTITLE_STR_BY_LOCID |
|
864 HbDeviceMessageBox messageBox(hbTrId("txt_irad_info_insufficient_disk_space"), |
672 HbMessageBox::MessageTypeWarning); |
865 HbMessageBox::MessageTypeWarning); |
|
866 #else |
|
867 HbDeviceMessageBox messageBox(hbTrId("Insufficient disk space"), |
|
868 HbMessageBox::MessageTypeWarning); |
|
869 #endif |
673 messageBox.setTimeout(HbPopup::NoTimeout); |
870 messageBox.setTimeout(HbPopup::NoTimeout); |
674 messageBox.exec(); |
871 messageBox.exec(); |
675 qApp->quit(); |
872 qApp->quit(); |
|
873 } |
|
874 |
|
875 void IRApplication::handleCallActivated() |
|
876 { |
|
877 LOG_METHOD; |
|
878 //for the buffering state needs more attention, we firstly |
|
879 //don't handle it, improve in future. |
|
880 if( iPlayController->isPlaying() /*|| iPlayController->isBuffering()*/) |
|
881 { |
|
882 iPlayController->stop(EIRQCallIsActivated); |
|
883 stopLoadingAnimation(); |
|
884 } |
|
885 |
|
886 //for we don't cancel the loading when call is activated, |
|
887 //so, here , we don't add the handling for it. |
|
888 } |
|
889 |
|
890 void IRApplication::handleCallDeactivated() |
|
891 { |
|
892 LOG_METHOD; |
|
893 if( iPlayController->getStopReason() == EIRQCallIsActivated ) |
|
894 { |
|
895 iPlayController->resume(); |
|
896 } |
|
897 } |
|
898 |
|
899 void IRApplication::handleHeadsetConnected() |
|
900 { |
|
901 LOG_METHOD; |
|
902 } |
|
903 |
|
904 void IRApplication::handleHeadsetDisconnected() |
|
905 { |
|
906 LOG_METHOD; |
676 } |
907 } |
677 |
908 |
678 #ifdef _DEBUG |
909 #ifdef _DEBUG |
679 void IRApplication::readConfiguration() |
910 void IRApplication::readConfiguration() |
680 { |
911 { |