88 mControlReqOngoing(false), |
91 mControlReqOngoing(false), |
89 mMonitorRequest(NULL), |
92 mMonitorRequest(NULL), |
90 mRefreshRequest(NULL), |
93 mRefreshRequest(NULL), |
91 mControlRequest(NULL) |
94 mControlRequest(NULL) |
92 { |
95 { |
|
96 LOG_METHOD; |
93 mIrAppInspector = new IrAppInspector(this); |
97 mIrAppInspector = new IrAppInspector(this); |
94 |
98 |
95 QObject::connect(mIrAppInspector, SIGNAL(irRunningStatusChanged(IrAppInspector::IrRunningStatus)), |
99 QObject::connect(mIrAppInspector, SIGNAL(irRunningStatusChanged(IrAppInspector::IrRunningStatus)), |
96 this, SLOT(handleIrRunningStatusChanged(IrAppInspector::IrRunningStatus))); |
100 this, SLOT(handleIrRunningStatusChanged(IrAppInspector::IrRunningStatus))); |
97 } |
101 } |
98 |
102 |
99 // Destructor |
103 // Destructor |
100 IrServiceClient::~IrServiceClient() |
104 IrServiceClient::~IrServiceClient() |
101 { |
105 { |
|
106 LOG_METHOD; |
102 delete mMonitorRequest; |
107 delete mMonitorRequest; |
103 mMonitorRequest = NULL; |
108 mMonitorRequest = NULL; |
104 |
109 |
105 delete mRefreshRequest; |
110 delete mRefreshRequest; |
106 mRefreshRequest = NULL; |
111 mRefreshRequest = NULL; |
300 /****************************************************************** |
316 /****************************************************************** |
301 **************** Control Service Request ********************** |
317 **************** Control Service Request ********************** |
302 *******************************************************************/ |
318 *******************************************************************/ |
303 bool IrServiceClient::bringIrForeground() |
319 bool IrServiceClient::bringIrForeground() |
304 { |
320 { |
|
321 LOG_METHOD; |
305 QVariant commandArgument(QVariant::Int); |
322 QVariant commandArgument(QVariant::Int); |
306 commandArgument.setValue((int)IrServiceCmd::Foreground); |
323 commandArgument.setValue((int)IrServiceCmd::Foreground); |
307 return doSendControlRequest(commandArgument, true, ToForeground); |
324 return doSendControlRequest(commandArgument, true, ToForeground); |
308 } |
325 } |
309 |
326 |
314 return doSendControlRequest(commandArgument, true, ToForeground); |
331 return doSendControlRequest(commandArgument, true, ToForeground); |
315 } |
332 } |
316 |
333 |
317 bool IrServiceClient::launchIrNowPlaying() |
334 bool IrServiceClient::launchIrNowPlaying() |
318 { |
335 { |
|
336 LOG_METHOD; |
319 QVariant commandArgument(QVariant::Int); |
337 QVariant commandArgument(QVariant::Int); |
320 commandArgument.setValue((int)IrServiceCmd::LaunchNowPlayingView); |
338 commandArgument.setValue((int)IrServiceCmd::LaunchNowPlayingView); |
321 return doSendControlRequest(commandArgument, false, ToBackground); |
339 return doSendControlRequest(commandArgument, false, ToBackground); |
322 } |
340 } |
323 |
341 |
324 |
342 |
325 bool IrServiceClient::startPlaying() |
343 bool IrServiceClient::startPlaying() |
326 { |
344 { |
|
345 LOG_METHOD; |
327 QVariant commandArgument(QVariant::Int); |
346 QVariant commandArgument(QVariant::Int); |
328 commandArgument.setValue((int)IrServiceCmd::Play); |
347 commandArgument.setValue((int)IrServiceCmd::Play); |
329 return doSendControlRequest(commandArgument, true, DoNotChange); |
348 return doSendControlRequest(commandArgument, true, DoNotChange); |
330 } |
349 } |
331 |
350 |
332 |
351 |
333 bool IrServiceClient::stopPlaying() |
352 bool IrServiceClient::stopPlaying() |
334 { |
353 { |
|
354 LOG_METHOD; |
335 QVariant commandArgument(QVariant::Int); |
355 QVariant commandArgument(QVariant::Int); |
336 commandArgument.setValue((int)IrServiceCmd::Stop); |
356 commandArgument.setValue((int)IrServiceCmd::Stop); |
337 return doSendControlRequest(commandArgument, true, DoNotChange); |
357 return doSendControlRequest(commandArgument, true, DoNotChange); |
338 } |
358 } |
339 |
359 |
340 bool IrServiceClient::cancelLoading() |
360 bool IrServiceClient::cancelLoading() |
341 { |
361 { |
|
362 LOG_METHOD; |
342 QVariant commandArgument(QVariant::Int); |
363 QVariant commandArgument(QVariant::Int); |
343 commandArgument.setValue((int)IrServiceCmd::Cancel); |
364 commandArgument.setValue((int)IrServiceCmd::Cancel); |
344 return doSendControlRequest(commandArgument, true, DoNotChange); |
365 return doSendControlRequest(commandArgument, true, DoNotChange); |
345 } |
366 } |
346 |
367 |
347 bool IrServiceClient::doSendControlRequest(const QVariant &aArgument, bool aIsSync, IrAppVisibilty aVisibility) |
368 bool IrServiceClient::doSendControlRequest(const QVariant &aArgument, bool aIsSync, IrAppVisibilty aVisibility) |
348 { |
369 { |
|
370 LOG_METHOD; |
349 if(mControlReqOngoing) |
371 if(mControlReqOngoing) |
350 { |
372 { |
351 return false; |
373 return false; |
352 } |
374 } |
353 |
375 |
425 *******************************************************************/ |
453 *******************************************************************/ |
426 // slot connected to signals from IrAppInspector, |
454 // slot connected to signals from IrAppInspector, |
427 // used to monitor the startup / exit of IR |
455 // used to monitor the startup / exit of IR |
428 void IrServiceClient::handleIrRunningStatusChanged(IrAppInspector::IrRunningStatus aNewStatus) |
456 void IrServiceClient::handleIrRunningStatusChanged(IrAppInspector::IrRunningStatus aNewStatus) |
429 { |
457 { |
|
458 LOG_METHOD; |
|
459 LOG_FORMAT("aNewIrRunningStatusStatus = %d", aNewStatus); |
430 switch (aNewStatus) |
460 switch (aNewStatus) |
431 { |
461 { |
432 case IrAppInspector::StartingUp : |
462 case IrAppInspector::StartingUp : |
433 doSendRefreshRequest(); |
463 doSendRefreshRequest(); |
434 break; |
464 break; |
456 } |
486 } |
457 } |
487 } |
458 |
488 |
459 void IrServiceClient::clearMonitorServiceRequest() |
489 void IrServiceClient::clearMonitorServiceRequest() |
460 { |
490 { |
|
491 LOG_METHOD; |
461 delete mMonitorRequest; |
492 delete mMonitorRequest; |
462 mMonitorRequest = NULL; |
493 mMonitorRequest = NULL; |
463 |
494 |
464 delete mRefreshRequest; |
495 delete mRefreshRequest; |
465 mRefreshRequest = NULL; |
496 mRefreshRequest = NULL; |
466 } |
497 } |
467 |
498 |
468 // used to process service data sent from IR app. |
499 // used to process service data sent from IR app. |
469 void IrServiceClient::processNotificationData(const IrServiceData &aServiceData) |
500 void IrServiceClient::processNotificationData(const IrServiceData &aServiceData) |
470 { |
501 { |
|
502 LOG_METHOD; |
471 QVariant data = aServiceData.mData; |
503 QVariant data = aServiceData.mData; |
472 if (!data.isValid()) |
504 if (!data.isValid()) |
473 { |
505 { |
474 return; |
506 return; |
475 } |
507 } |
476 switch (aServiceData.mType) |
508 switch (aServiceData.mType) |
477 { |
509 { |
478 case IrServiceNotification::StationName: |
510 case IrServiceNotification::StationName: |
|
511 LOG("aServiceData = StationName"); |
479 if (data.canConvert(QVariant::String)) |
512 if (data.canConvert(QVariant::String)) |
480 { |
513 { |
481 notifyStationNameUpdated(data.toString()); |
514 notifyStationNameUpdated(data.toString()); |
482 } |
515 } |
483 break; |
516 break; |
484 |
517 |
485 case IrServiceNotification::MetaData: |
518 case IrServiceNotification::MetaData: |
|
519 LOG("aServiceData = MetaData"); |
486 if (data.canConvert(QVariant::String)) |
520 if (data.canConvert(QVariant::String)) |
487 { |
521 { |
488 notifyMetaDataUpdated(data.toString()); |
522 notifyMetaDataUpdated(data.toString()); |
489 } |
523 } |
490 break; |
524 break; |
491 |
525 |
492 case IrServiceNotification::StationLogo: |
526 case IrServiceNotification::StationLogo: |
|
527 LOG("aServiceData = StationLogo"); |
493 if (data.canConvert(QVariant::Bool)) |
528 if (data.canConvert(QVariant::Bool)) |
494 { |
529 { |
495 notifyStationLogoUpdated(data.toBool()); |
530 notifyStationLogoUpdated(data.toBool()); |
496 } |
531 } |
497 break; |
532 break; |
498 |
533 |
499 case IrServiceNotification::IrState: |
534 case IrServiceNotification::IrState: |
|
535 LOG("aServiceData = IrState"); |
500 if (data.canConvert(QVariant::Int)) |
536 if (data.canConvert(QVariant::Int)) |
501 { |
537 { |
502 notifyIrStateChanged((IrAppState::Type)data.toInt()); |
538 notifyIrStateChanged((IrAppState::Type)data.toInt()); |
503 } |
539 } |
504 break; |
540 break; |
535 aRequest->setInfo(reqInfo); |
573 aRequest->setInfo(reqInfo); |
536 } |
574 } |
537 |
575 |
538 void IrServiceClient::notifyStationNameUpdated(const QString &aStationName) |
576 void IrServiceClient::notifyStationNameUpdated(const QString &aStationName) |
539 { |
577 { |
|
578 LOG_METHOD; |
|
579 LOG_FORMAT("aStationName = %s", STRING2CHAR(aStationName)); |
540 mStationName = aStationName; |
580 mStationName = aStationName; |
541 emit stationNameUpdated(mStationName); |
581 emit stationNameUpdated(mStationName); |
542 } |
582 } |
543 |
583 |
544 void IrServiceClient::notifyStationLogoUpdated(bool aIsLogoAvailable) |
584 void IrServiceClient::notifyStationLogoUpdated(bool aIsLogoAvailable) |
545 { |
585 { |
|
586 LOG_METHOD; |
|
587 LOG_FORMAT("aIsLogoAvailable = %d", aIsLogoAvailable); |
546 mStationLogoAvailable = aIsLogoAvailable; |
588 mStationLogoAvailable = aIsLogoAvailable; |
547 emit stationLogoUpdated(mStationLogoAvailable); |
589 emit stationLogoUpdated(mStationLogoAvailable); |
548 } |
590 } |
549 |
591 |
550 void IrServiceClient::notifyMetaDataUpdated(const QString &aMetaData) |
592 void IrServiceClient::notifyMetaDataUpdated(const QString &aMetaData) |
551 { |
593 { |
|
594 LOG_METHOD; |
|
595 LOG_FORMAT("aMetaData = %s", STRING2CHAR(aMetaData)); |
552 mMetaData = aMetaData; |
596 mMetaData = aMetaData; |
553 emit metaDataUpdated(mMetaData); |
597 emit metaDataUpdated(mMetaData); |
554 } |
598 } |
555 |
599 |
556 void IrServiceClient::notifyIrStateChanged(IrAppState::Type aNewState) |
600 void IrServiceClient::notifyIrStateChanged(IrAppState::Type aNewState) |
557 { |
601 { |
|
602 LOG_METHOD; |
|
603 LOG_FORMAT("mIrHsWidgetState = %d", aNewState); |
558 mIrState = aNewState; |
604 mIrState = aNewState; |
559 emit irStateChanged(mIrState); |
605 emit irStateChanged(mIrState); |
560 } |
606 } |
561 |
607 |
562 bool IrServiceClient::isStationPlayed() |
608 bool IrServiceClient::isStationPlayed() |
563 { |
609 { |
|
610 LOG_METHOD; |
564 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
611 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
565 QString stationName = settings.value(KIrSettingStationName,KIrDefaultStationName).toString(); |
612 QString stationName = settings.value(KIrSettingStationName,KIrDefaultStationName).toString(); |
566 return stationName != KIrDefaultStationName; |
613 return stationName != KIrDefaultStationName; |
567 } |
614 } |
568 |
615 |
569 bool IrServiceClient::loadStationLogoFlag() |
616 bool IrServiceClient::loadStationLogoFlag() |
570 { |
617 { |
|
618 LOG_METHOD; |
571 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
619 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
572 return settings.value(KIrSettingStationLogoAvailable,false).toBool(); |
620 return settings.value(KIrSettingStationLogoAvailable,false).toBool(); |
573 } |
621 } |
574 |
622 |
575 bool IrServiceClient::loadStationName(QString &aStationName) |
623 bool IrServiceClient::loadStationName(QString &aStationName) |
576 { |
624 { |
|
625 LOG_METHOD; |
577 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
626 QSettings settings(KIrSettingOrganization, KIrSettingApplication); |
578 aStationName = settings.value(KIrSettingStationName,KIrDefaultStationName).toString(); |
627 aStationName = settings.value(KIrSettingStationName,KIrDefaultStationName).toString(); |
|
628 LOG_FORMAT("aStationName = %s", STRING2CHAR(aStationName)); |
579 if(aStationName != KIrDefaultStationName) |
629 if(aStationName != KIrDefaultStationName) |
580 { |
630 { |
581 return true; |
631 return true; |
582 } |
632 } |
583 else |
633 else |