|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbaction.h> |
|
19 #include <qcoreapplication.h> |
|
20 #include <hbdevicemessagebox.h> |
|
21 #include <QLocalServer> |
|
22 #include <QLocalSocket> |
|
23 #include <QFile> |
|
24 #include <QTextStream> |
|
25 #include <QDir> |
|
26 |
|
27 |
|
28 #ifdef LOCALIZATION |
|
29 #include <QTranslator> |
|
30 #include "irqutility.h" |
|
31 #endif |
|
32 |
|
33 #include "irabstractviewmanager.h" |
|
34 #include "irapplication.h" |
|
35 |
|
36 #include "irqnetworkcontroller.h" |
|
37 #include "irqisdsclient.h" |
|
38 #include "irplaycontroller.h" |
|
39 #include "irlastplayedstationinfo.h" |
|
40 #include "irqfavoritesdb.h" |
|
41 #include "irqsettings.h" |
|
42 #include "irmediakeyobserver.h" |
|
43 #include "ircategoryview.h" |
|
44 #include "irstationsview.h" |
|
45 #include "irqmusicshop.h" |
|
46 #include "irqnwkinfoobserver.h" |
|
47 #include "irqstatisticsreporter.h" |
|
48 #include "irsymbiandocument.h" |
|
49 #include "irqdiskspacewatcher.h" |
|
50 #include "irqlogger.h" |
|
51 /* |
|
52 * Description : constructor, initialize all data members |
|
53 * Parameters : aViewManager : pointer to the view manager object |
|
54 * Return : None |
|
55 */ |
|
56 IRApplication::IRApplication(IRAbstractViewManager* aViewManager): |
|
57 #ifdef _DEBUG |
|
58 iTestPreferredBitrate(false), |
|
59 #endif |
|
60 iViewManager(aViewManager), |
|
61 iNetworkController(NULL), |
|
62 iIsdsClient(NULL), |
|
63 iPlayController(NULL), |
|
64 iFavPresets(NULL), |
|
65 iSettings(NULL), |
|
66 iMediaKeyObserver(NULL), |
|
67 iLastPlayedStationInfo(NULL), |
|
68 iNwkInfoObserver(NULL), |
|
69 iStatisticsReporter(NULL), |
|
70 iMusicShop(NULL), |
|
71 iAdvertisementClient(NULL), |
|
72 iDiskSpaceWatcher(NULL), |
|
73 iEnableGlobalAdv(true), |
|
74 iDisconnected(false), |
|
75 iConnectingCanceled(false), |
|
76 iLocalServer(NULL), |
|
77 iConnectingNote(NULL) |
|
78 #ifdef LOCALIZATION |
|
79 ,iTranslator(NULL) |
|
80 #endif |
|
81 { |
|
82 LOG_METHOD; |
|
83 iViewManager->setApplication(this); |
|
84 |
|
85 #ifdef _DEBUG |
|
86 readConfiguration(); |
|
87 #endif |
|
88 |
|
89 createComponents(); |
|
90 // get advertisement setting |
|
91 iSettings->getGlobalAdvFlag(iEnableGlobalAdv); |
|
92 setupConnection(); |
|
93 setLaunchView(); |
|
94 #ifdef LOCALIZATION |
|
95 initLanguage(); |
|
96 #endif |
|
97 } |
|
98 |
|
99 /* |
|
100 * Description : destructor, destroy all data members |
|
101 * Parameters : None |
|
102 * Return : None |
|
103 */ |
|
104 IRApplication::~IRApplication() |
|
105 { |
|
106 LOG_METHOD; |
|
107 setExitingView(); |
|
108 destroyComponents(); |
|
109 |
|
110 if (iLocalServer) |
|
111 { |
|
112 iLocalServer->close(); |
|
113 } |
|
114 |
|
115 delete iLastPlayedStationInfo; |
|
116 iLastPlayedStationInfo = NULL; |
|
117 |
|
118 delete iConnectingNote; |
|
119 iConnectingNote = NULL; |
|
120 |
|
121 #ifdef LOCALIZATION |
|
122 if( iTranslator ) |
|
123 { |
|
124 qApp->removeTranslator(iTranslator); |
|
125 delete iTranslator; |
|
126 iTranslator = NULL; |
|
127 } |
|
128 #endif |
|
129 } |
|
130 |
|
131 #ifdef LOCALIZATION |
|
132 void IRApplication::initLanguage() |
|
133 { |
|
134 iTranslator = new QTranslator(); |
|
135 QString lang = QLocale::system().name(); |
|
136 LOG_FORMAT( "Current language is %s", STRING2CHAR(lang) ); |
|
137 QString path = "z:/resource/qt/translations/"; //this will be changed to a micro in future |
|
138 bool ret = iTranslator->load(path + "internet_radio_10_1_" + lang); |
|
139 qApp->installTranslator(iTranslator); |
|
140 } |
|
141 #endif |
|
142 /* |
|
143 * Description : When ir application is launched, set the correct view according to whether the |
|
144 * application is used for the first time |
|
145 * Parameters : None |
|
146 * Return : None |
|
147 */ |
|
148 void IRApplication::setLaunchView() |
|
149 { |
|
150 IRSymbianDocument *document = IRSymbianDocument::getInstance(); |
|
151 if (document && document->isPlsAvailable()) |
|
152 { |
|
153 iViewManager->activateView(EIRView_PlsView); |
|
154 } |
|
155 else |
|
156 { |
|
157 launchStartingView(); |
|
158 } |
|
159 |
|
160 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
|
161 |
|
162 iInitEvent = static_cast<QEvent::Type>(QEvent::registerEventType()); |
|
163 QEvent* initEvent = new QEvent(iInitEvent); |
|
164 QCoreApplication::postEvent(this, initEvent, Qt::HighEventPriority); |
|
165 } |
|
166 |
|
167 /* |
|
168 * Description : verify if the network connection has been established |
|
169 * Parameters : None |
|
170 * Return : true : network connection has been established |
|
171 * false : network connection has not been established |
|
172 */ |
|
173 bool IRApplication::verifyNetworkConnectivity(const QString &aConnectingText) |
|
174 { |
|
175 Q_ASSERT(iNetworkController); |
|
176 |
|
177 bool ret = true; |
|
178 |
|
179 if (!iNetworkController->getNetworkStatus()) |
|
180 { |
|
181 ret = false; |
|
182 if (!iNetworkController->isConnectRequestIssued()) |
|
183 { |
|
184 iConnectingText = aConnectingText; |
|
185 iNetworkController->chooseAccessPoint(); |
|
186 } |
|
187 } |
|
188 |
|
189 return ret; |
|
190 } |
|
191 |
|
192 void IRApplication::createConnectingDialog() |
|
193 { |
|
194 LOG_METHOD_ENTER; |
|
195 if (NULL == iConnectingNote) |
|
196 { |
|
197 iConnectingNote = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
198 iConnectingNote->setModal(true); |
|
199 iConnectingNote->setTimeout(HbPopup::NoTimeout); |
|
200 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"), iConnectingNote); |
|
201 iConnectingNote->setPrimaryAction(cancelAction); |
|
202 connect(cancelAction, SIGNAL(triggered()), this, SLOT(cancelConnect())); |
|
203 } |
|
204 |
|
205 iConnectingNote->setText(iConnectingText); |
|
206 iConnectingNote->show(); |
|
207 } |
|
208 |
|
209 void IRApplication::closeConnectingDialog() |
|
210 { |
|
211 LOG_METHOD_ENTER; |
|
212 if (iConnectingNote) |
|
213 { |
|
214 iConnectingNote->close(); |
|
215 delete iConnectingNote; |
|
216 iConnectingNote = NULL; |
|
217 } |
|
218 } |
|
219 |
|
220 /* |
|
221 * Description : return the pointer to the view manager object |
|
222 * Parameters : None |
|
223 * Return : the pointer to the view manager object |
|
224 */ |
|
225 IRAbstractViewManager* IRApplication::getViewManager() const |
|
226 { |
|
227 return iViewManager; |
|
228 } |
|
229 |
|
230 /* |
|
231 * Description : return the pointer to the network controller object |
|
232 * Parameters : None |
|
233 * Return : the pointer to the network controller object |
|
234 */ |
|
235 IRQNetworkController* IRApplication::getNetworkController() |
|
236 { |
|
237 if(NULL == iNetworkController) |
|
238 { |
|
239 iNetworkController = IRQNetworkController::openInstance(); |
|
240 } |
|
241 return iNetworkController; |
|
242 } |
|
243 |
|
244 /* |
|
245 * Description : return the pointer to the isds client object |
|
246 * Parameters : None |
|
247 * Return : the pointer to the isds client object |
|
248 */ |
|
249 IRQIsdsClient* IRApplication::getIsdsClient() |
|
250 { |
|
251 if(NULL == iIsdsClient) |
|
252 { |
|
253 iIsdsClient = IRQIsdsClient::openInstance(getFavoritesDB()); |
|
254 } |
|
255 return iIsdsClient; |
|
256 } |
|
257 |
|
258 /* |
|
259 * Description : return the pointer to the play controller object |
|
260 * Parameters : None |
|
261 * Return : the pointer to the play controller object |
|
262 */ |
|
263 IRPlayController* IRApplication::getPlayController() |
|
264 { |
|
265 if(NULL == iPlayController) |
|
266 { |
|
267 iPlayController = new IRPlayController(this); |
|
268 } |
|
269 return iPlayController; |
|
270 } |
|
271 |
|
272 IRLastPlayedStationInfo* IRApplication::getLastPlayedStationInfo() |
|
273 { |
|
274 if(NULL == iLastPlayedStationInfo) |
|
275 { |
|
276 iLastPlayedStationInfo = new IRLastPlayedStationInfo(); |
|
277 } |
|
278 return iLastPlayedStationInfo; |
|
279 } |
|
280 |
|
281 IRQFavoritesDB* IRApplication::getFavoritesDB() |
|
282 { |
|
283 if(NULL == iFavPresets) |
|
284 { |
|
285 iFavPresets = new IRQFavoritesDB(); |
|
286 } |
|
287 return iFavPresets; |
|
288 } |
|
289 |
|
290 IRQSettings * IRApplication::getSettings() |
|
291 { |
|
292 if(NULL == iSettings) |
|
293 { |
|
294 iSettings = IRQSettings::openInstance(); |
|
295 } |
|
296 return iSettings; |
|
297 } |
|
298 |
|
299 IRMediaKeyObserver* IRApplication::getMediaKeyObserver() |
|
300 { |
|
301 if(NULL == iMediaKeyObserver) |
|
302 { |
|
303 iMediaKeyObserver = new IRMediaKeyObserver(this); |
|
304 } |
|
305 return iMediaKeyObserver; |
|
306 } |
|
307 |
|
308 IRQNwkInfoObserver * IRApplication::getNwkInfoObserver() |
|
309 { |
|
310 if(NULL == iNwkInfoObserver) |
|
311 { |
|
312 iNwkInfoObserver = IRQNwkInfoObserver::openInstance(); |
|
313 } |
|
314 return iNwkInfoObserver; |
|
315 } |
|
316 |
|
317 IRQStatisticsReporter * IRApplication::getStatisticsReporter() |
|
318 { |
|
319 if(NULL == iStatisticsReporter) |
|
320 { |
|
321 iStatisticsReporter = IRQStatisticsReporter::openInstance(getIsdsClient()); |
|
322 } |
|
323 return iStatisticsReporter; |
|
324 } |
|
325 |
|
326 IRQMusicShop * IRApplication::getMusicShop() |
|
327 { |
|
328 if(NULL == iMusicShop) |
|
329 { |
|
330 iMusicShop = IRQMusicShop::openInstance(); |
|
331 } |
|
332 return iMusicShop; |
|
333 } |
|
334 |
|
335 IRQAdvClient* IRApplication::getAdvClient() |
|
336 { |
|
337 if(iEnableGlobalAdv && (NULL == iAdvertisementClient)) |
|
338 { |
|
339 //iAdvertisementClient = IRQAdvClient::openInstance(); |
|
340 } |
|
341 |
|
342 return iAdvertisementClient; |
|
343 } |
|
344 /* |
|
345 * Description : create all the application level components, including network controller, |
|
346 * favorites db, isds client, play controller, etc |
|
347 * Parameters : None |
|
348 * Return : None |
|
349 */ |
|
350 void IRApplication::createComponents() |
|
351 { |
|
352 getNetworkController(); |
|
353 getSettings(); |
|
354 } |
|
355 |
|
356 /* |
|
357 * Descriiption : destroy all the application level components |
|
358 * Parameters : None |
|
359 * Return : None |
|
360 */ |
|
361 void IRApplication::destroyComponents() |
|
362 { |
|
363 delete iPlayController; |
|
364 iPlayController = NULL; |
|
365 |
|
366 delete iDiskSpaceWatcher; |
|
367 iDiskSpaceWatcher = NULL; |
|
368 |
|
369 if(iIsdsClient) |
|
370 { |
|
371 iIsdsClient->closeInstance(); |
|
372 iIsdsClient = NULL; |
|
373 } |
|
374 |
|
375 delete iFavPresets; |
|
376 iFavPresets = NULL; |
|
377 |
|
378 if(iStatisticsReporter) |
|
379 { |
|
380 iStatisticsReporter->closeInstance(); |
|
381 iStatisticsReporter = NULL; |
|
382 } |
|
383 |
|
384 if(iNwkInfoObserver) |
|
385 { |
|
386 iNwkInfoObserver->closeInstance(); |
|
387 iNwkInfoObserver = NULL; |
|
388 } |
|
389 |
|
390 if(iMusicShop) |
|
391 { |
|
392 iMusicShop->closeInstance(); |
|
393 iMusicShop = NULL; |
|
394 } |
|
395 |
|
396 if(iNetworkController) |
|
397 { |
|
398 iNetworkController->closeInstance(); |
|
399 iNetworkController = NULL; |
|
400 } |
|
401 |
|
402 if(iSettings) |
|
403 { |
|
404 iSettings->closeInstance(); |
|
405 iSettings = NULL; |
|
406 } |
|
407 |
|
408 delete iMediaKeyObserver; |
|
409 iMediaKeyObserver = NULL; |
|
410 } |
|
411 |
|
412 void IRApplication::setupConnection() |
|
413 { |
|
414 //connect IRApplication to IRQNetworkController |
|
415 connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)), |
|
416 this, SLOT(networkEventNotified(IRQNetworkEvent))); |
|
417 |
|
418 connect(this, SIGNAL(quit()), qApp, SLOT(quit())); |
|
419 } |
|
420 |
|
421 void IRApplication::cancelConnect() |
|
422 { |
|
423 if (iConnectingCanceled) |
|
424 { |
|
425 return; |
|
426 } |
|
427 |
|
428 iConnectingCanceled = true; |
|
429 if (iNetworkController->getNetworkStatus()) |
|
430 { |
|
431 getIsdsClient()->isdsCancelRequest(); |
|
432 } |
|
433 else |
|
434 { |
|
435 iNetworkController->cancelConnecting(); |
|
436 } |
|
437 |
|
438 iNetworkController->notifyActiveNetworkObservers(EIRQConnectingCancelled); |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // IRApplication::startMonitoringNwkInfo |
|
443 // Start to monitor network info changes |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void IRApplication::startMonitoringNwkInfo() |
|
447 { |
|
448 getNwkInfoObserver(); |
|
449 getStatisticsReporter(); |
|
450 if(iNwkInfoObserver) |
|
451 { |
|
452 iNwkInfoObserver->startMonitorNwkInfo(); |
|
453 connectAndAssert(iNwkInfoObserver, SIGNAL(currentNwkChanged(const QString, const QString)), |
|
454 iStatisticsReporter, SLOT(updateCurrentNetwork(const QString, const QString))); |
|
455 connectAndAssert(iNwkInfoObserver, SIGNAL(homeNwkChanged(const QString, const QString)), |
|
456 iStatisticsReporter, SLOT(updateHomeOperator(const QString, const QString))); |
|
457 } |
|
458 |
|
459 } |
|
460 |
|
461 //connect to signal 'networkEventNotified' from IRQNetworkController |
|
462 void IRApplication::networkEventNotified(IRQNetworkEvent aEvent) |
|
463 { |
|
464 LOG_SLOT_CALLER; |
|
465 switch (aEvent) |
|
466 { |
|
467 case EIRQNetworkConnectionConnecting : |
|
468 createConnectingDialog(); |
|
469 iConnectingCanceled = false; |
|
470 break; |
|
471 |
|
472 case EIRQNetworkConnectionEstablished : |
|
473 iDisconnected = false; |
|
474 if (EIR_DoDefault == handleConnectionEstablished()) |
|
475 { |
|
476 iNetworkController->notifyActiveNetworkObservers(aEvent); |
|
477 } |
|
478 |
|
479 if (EIRQNoConnectionToNetwork == getPlayController()->getStopReason() && |
|
480 iNetworkController->isHandlingOverConnection()) |
|
481 { |
|
482 getPlayController()->resume(); |
|
483 } |
|
484 break; |
|
485 |
|
486 case EIRQAccessPointSelectionCancelled : |
|
487 closeConnectingDialog(); |
|
488 cancelConnect(); |
|
489 break; |
|
490 |
|
491 case EIRQNetworkConnectionDisconnected: |
|
492 { |
|
493 iDisconnected = true; |
|
494 iNetworkController->resetConnectionStatus(); |
|
495 getPlayController()->stop(EIRQNoConnectionToNetwork); |
|
496 iNetworkController->notifyActiveNetworkObservers(aEvent); |
|
497 } |
|
498 break; |
|
499 |
|
500 case EIRQDisplayNetworkMessageNoConnectivity: |
|
501 { |
|
502 closeConnectingDialog(); |
|
503 HbMessageBox note(hbTrId("txt_irad_info_no_network_connectiion"), HbMessageBox::MessageTypeWarning); |
|
504 note.exec(); |
|
505 |
|
506 //reset setting to 'Always ask' |
|
507 iSettings->setUserDefinedSelection(EIRAlwaysAsk); |
|
508 iSettings->setDisplayAccessPoint(); |
|
509 |
|
510 if (!iDisconnected) |
|
511 { |
|
512 /* the handling is up to each view */ |
|
513 iNetworkController->notifyActiveNetworkObservers(EIRQDisplayNetworkMessageNoConnectivity); |
|
514 } |
|
515 |
|
516 } |
|
517 break; |
|
518 |
|
519 default: |
|
520 break; |
|
521 } |
|
522 |
|
523 } |
|
524 |
|
525 void IRApplication::loadGenre() |
|
526 { |
|
527 LOG_SLOT_CALLER; |
|
528 bool hasCache = iIsdsClient->isdsIsCategoryCached(IRQIsdsClient::EGenre); |
|
529 |
|
530 if (!hasCache) |
|
531 { |
|
532 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
|
533 Q_ASSERT(currView); |
|
534 currView->setUseNetworkReason(EIR_UseNetwork_LoadCategory); |
|
535 if (false == verifyNetworkConnectivity()) |
|
536 { |
|
537 return; |
|
538 } |
|
539 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
540 } |
|
541 |
|
542 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
|
543 categoryView->loadCategory(IRQIsdsClient::EGenre); |
|
544 } |
|
545 |
|
546 void IRApplication::newLocalSocketConnection() |
|
547 { |
|
548 QLocalSocket *socket = iLocalServer->nextPendingConnection(); |
|
549 if (!socket) |
|
550 { |
|
551 return; |
|
552 } |
|
553 |
|
554 socket->waitForReadyRead(1000); |
|
555 QTextStream stream(socket); |
|
556 QString fileName; |
|
557 stream>>fileName; |
|
558 IRSymbianDocument *document = IRSymbianDocument::getInstance(); |
|
559 document->parseFile(fileName); |
|
560 |
|
561 if (document->isPlsAvailable()) |
|
562 { |
|
563 iViewManager->activateView(EIRView_PlsView); |
|
564 } |
|
565 else |
|
566 { |
|
567 IRBaseView *topView = static_cast<IRBaseView*>(iViewManager->currentView()); |
|
568 topView->updateView(); |
|
569 } |
|
570 |
|
571 iViewManager->raise(); |
|
572 delete socket; |
|
573 } |
|
574 |
|
575 void IRApplication::initApp() |
|
576 { |
|
577 if (!iIsdsClient->isdsIsConstructSucceed()) |
|
578 { |
|
579 HbMessageBox note("No available access points, exiting...", HbMessageBox::MessageTypeWarning); |
|
580 note.setPrimaryAction(NULL); |
|
581 note.setTimeout(5000); |
|
582 note.setModal(true); |
|
583 note.exec(); |
|
584 qApp->quit(); |
|
585 } |
|
586 else |
|
587 { |
|
588 static_cast<IRBaseView*>(iViewManager->currentView())->launchAction(); |
|
589 } |
|
590 |
|
591 getMediaKeyObserver(); |
|
592 startMonitoringNwkInfo(); |
|
593 startMonitoringDiskSpace(); |
|
594 startLocalServer(); |
|
595 } |
|
596 |
|
597 bool IRApplication::event(QEvent* e) |
|
598 { |
|
599 if(e->type() == iInitEvent) |
|
600 { |
|
601 initApp(); |
|
602 return true; |
|
603 } |
|
604 |
|
605 return QObject::event(e); |
|
606 } |
|
607 |
|
608 TIRHandleResult IRApplication::handleConnectionEstablished() |
|
609 { |
|
610 IRBaseView *currView = static_cast<IRBaseView*>(iViewManager->currentView()); |
|
611 Q_ASSERT(currView); |
|
612 |
|
613 if (EIR_UseNetwork_LoadCategory == currView->getUseNetworkReason()) |
|
614 { |
|
615 closeConnectingDialog(); |
|
616 IRCategoryView *categoryView = static_cast<IRCategoryView*>(getViewManager()->getView(EIRView_CategoryView, true)); |
|
617 categoryView->loadCategory(IRQIsdsClient::EGenre); |
|
618 currView->setUseNetworkReason(EIR_UseNetwork_NoReason); |
|
619 return EIR_NoDefault; |
|
620 } |
|
621 |
|
622 return EIR_DoDefault; |
|
623 } |
|
624 |
|
625 void IRApplication::launchStartingView() |
|
626 { |
|
627 TIRViewId viewId = EIRView_CategoryView; |
|
628 iSettings->getStartingViewId(viewId); |
|
629 TIRViewParameter viewParameter = EIRViewPara_Genre; |
|
630 iSettings->getStartingViewParameter(viewParameter); |
|
631 |
|
632 iViewManager->activateView(viewId); |
|
633 IRBaseView *currentView = iViewManager->getView(viewId); |
|
634 |
|
635 switch (viewId) |
|
636 { |
|
637 case EIRView_CategoryView: |
|
638 { |
|
639 IRCategoryView* categoryView = static_cast<IRCategoryView*> (currentView); |
|
640 categoryView->setViewParameter(viewParameter); |
|
641 |
|
642 switch (viewParameter) |
|
643 { |
|
644 case EIRViewPara_Genre: |
|
645 categoryView->setHeadingText(tr("Genre")); |
|
646 break; |
|
647 |
|
648 case EIRViewPara_Language: |
|
649 categoryView->setHeadingText(tr("Language")); |
|
650 break; |
|
651 |
|
652 case EIRViewPara_Country: |
|
653 categoryView->setHeadingText(tr("Country/Region")); |
|
654 break; |
|
655 |
|
656 default: |
|
657 break; |
|
658 } |
|
659 } |
|
660 break; |
|
661 |
|
662 case EIRView_PlayingView: |
|
663 iViewManager->pushViewById(EIRView_MainView); |
|
664 break; |
|
665 |
|
666 default: |
|
667 break; |
|
668 } |
|
669 } |
|
670 |
|
671 void IRApplication::setExitingView() |
|
672 { |
|
673 IRQSettings *settings = getSettings(); |
|
674 bool flag = false; |
|
675 settings->getStickyViewFlag(flag); |
|
676 if (!flag) |
|
677 { |
|
678 return; |
|
679 } |
|
680 |
|
681 TIRViewId viewId = iViewManager->currentViewId(); |
|
682 |
|
683 switch (viewId) |
|
684 { |
|
685 case EIRView_CategoryView: |
|
686 { |
|
687 IRCategoryView *topView = (IRCategoryView*)(iViewManager->currentView()); |
|
688 TIRViewParameter parameter = topView->getViewParameter(); |
|
689 settings->setStartingViewParameter(parameter); |
|
690 } |
|
691 break; |
|
692 |
|
693 case EIRView_StationsView: |
|
694 { |
|
695 IRStationsView *topView = (IRStationsView*)(iViewManager->currentView()); |
|
696 TIRViewParameter parameter = topView->getViewParameter(); |
|
697 if (parameter == EIRViewPara_PopularStations) |
|
698 { |
|
699 settings->setStartingViewParameter(EIRViewPara_PopularStations); |
|
700 } |
|
701 else if (parameter == EIRViewPara_CategoryStations) |
|
702 { |
|
703 IRBaseView *baseView = iViewManager->getView(EIRView_CategoryView, false); |
|
704 if (baseView) |
|
705 { |
|
706 IRCategoryView *categoryView = (IRCategoryView*)baseView; |
|
707 TIRViewParameter parameter = categoryView->getViewParameter(); |
|
708 settings->setStartingViewParameter(parameter); |
|
709 settings->setStartingViewId(EIRView_CategoryView); |
|
710 return; |
|
711 } |
|
712 } |
|
713 else if (parameter == EIRViewPara_SearchResults) |
|
714 { |
|
715 |
|
716 } |
|
717 } |
|
718 break; |
|
719 |
|
720 case EIRView_InvalidId: |
|
721 case EIRView_StationDetailsView: |
|
722 case EIRView_SettingsView: |
|
723 case EIRView_OpenWebAddressView: |
|
724 case EIRView_SearchView: |
|
725 case EIRView_SearchResultView: |
|
726 case EIRView_PlsView: |
|
727 case EIRView_HistoryView: |
|
728 case EIRView_SongHistoryView: |
|
729 case EIRView_ViewCount: |
|
730 { |
|
731 // these views are not starting view, so do not change settings. |
|
732 return; |
|
733 } |
|
734 |
|
735 default: |
|
736 break; |
|
737 } |
|
738 |
|
739 settings->setStartingViewId(viewId); |
|
740 } |
|
741 |
|
742 void IRApplication::startLocalServer() |
|
743 { |
|
744 QString serverName = QCoreApplication::applicationName(); |
|
745 iLocalServer = new QLocalServer(this); |
|
746 connect(iLocalServer, SIGNAL(newConnection()), |
|
747 this, SLOT(newLocalSocketConnection())); |
|
748 |
|
749 if (!iLocalServer->listen(serverName)) |
|
750 { |
|
751 QAbstractSocket::SocketError error = iLocalServer->serverError(); |
|
752 QString fullServerName; |
|
753 fullServerName = QDir::cleanPath(QDir::tempPath()); |
|
754 fullServerName += QLatin1Char('/') + serverName; |
|
755 bool fileExists = QFile::exists(fullServerName); |
|
756 |
|
757 if (error == QAbstractSocket::AddressInUseError && fileExists) |
|
758 { |
|
759 QFile::remove(fullServerName); |
|
760 iLocalServer->listen(serverName); |
|
761 } |
|
762 } |
|
763 } |
|
764 |
|
765 void IRApplication::startMonitoringDiskSpace() |
|
766 { |
|
767 if(NULL == iDiskSpaceWatcher) |
|
768 { |
|
769 iDiskSpaceWatcher = new IRQDiskSpaceWatcher(); |
|
770 } |
|
771 |
|
772 if(NULL != iDiskSpaceWatcher) |
|
773 { |
|
774 connect(iDiskSpaceWatcher, SIGNAL(diskSpaceLow(qint64)), |
|
775 this, SLOT(handleDiskSpaceLow(qint64))); |
|
776 iDiskSpaceWatcher->startMonitorDrive(); |
|
777 } |
|
778 } |
|
779 |
|
780 void IRApplication::handleDiskSpaceLow(qint64 aCriticalLevel) |
|
781 { |
|
782 Q_UNUSED(aCriticalLevel); |
|
783 HbDeviceMessageBox messageBox(hbTrId("txt_irad_info_no_space_on_c_drive_internet_radio_closed"), |
|
784 HbMessageBox::MessageTypeWarning); |
|
785 messageBox.setTimeout(HbPopup::NoTimeout); |
|
786 messageBox.exec(); |
|
787 qApp->quit(); |
|
788 } |
|
789 |
|
790 #ifdef _DEBUG |
|
791 void IRApplication::readConfiguration() |
|
792 { |
|
793 QFile file("C:\\data\\QTIRConfigure.txt"); |
|
794 if (file.open(QIODevice::ReadOnly)) |
|
795 { |
|
796 QTextStream stream( &file ); |
|
797 QString line; |
|
798 QStringList parameter; |
|
799 while (!stream.atEnd()) |
|
800 { |
|
801 line = stream.readLine(); |
|
802 parameter = line.split("="); |
|
803 if (parameter.count() == 2) |
|
804 { |
|
805 if (parameter.first() == "testPreferredBitrate" |
|
806 && parameter.last() == "true") |
|
807 { |
|
808 iTestPreferredBitrate = true; |
|
809 } |
|
810 } |
|
811 } |
|
812 } |
|
813 file.close(); |
|
814 } |
|
815 #endif |