From cac8d6acc75500264a8de0535bdb3fd67021d405 Mon Sep 17 00:00:00 2001
From: George Nassas <george@nassas.com>
Date: Wed, 14 Nov 2012 17:45:23 -0500
Subject: [PATCH 5/5] Give helpful errors for network control play program
---
mythtv/programs/mythfrontend/networkcontrol.cpp | 115 ++++++++++++-----------
1 file changed, 62 insertions(+), 53 deletions(-)
diff --git a/mythtv/programs/mythfrontend/networkcontrol.cpp b/mythtv/programs/mythfrontend/networkcontrol.cpp
index ddca896..1344326 100644
a
|
b
|
QString NetworkControl::processPlay(NetworkCommand *nc, int clientID) |
579 | 579 | return QString("Unable to change to main menu to start playback!"); |
580 | 580 | } |
581 | 581 | else if ((nc->getArgCount() >= 4) && |
582 | | (is_abbrev("program", nc->getArg(1))) && |
583 | | (nc->getArg(2).contains(QRegExp("^\\d+$"))) && |
584 | | (nc->getArg(3).contains(QRegExp( |
585 | | "^\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$")))) |
| 582 | (is_abbrev("program", nc->getArg(1)))) |
586 | 583 | { |
587 | | if (GetMythUI()->GetCurrentLocation().toLower() == "playback") |
| 584 | if (!(nc->getArg(2).contains(QRegExp("^\\d+$")))) |
588 | 585 | { |
589 | | QString message = QString("NETWORK_CONTROL STOP"); |
590 | | MythEvent me(message); |
591 | | gCoreContext->dispatch(me); |
592 | | |
593 | | QTime timer; |
594 | | timer.start(); |
595 | | while ((timer.elapsed() < FE_LONG_TO) && |
596 | | (GetMythUI()->GetCurrentLocation().toLower() == "playback")) |
597 | | usleep(10000); |
| 586 | result = QString("ERROR: Invalid ChanID %1") |
| 587 | .arg(nc->getArg(2)); |
598 | 588 | } |
599 | | |
600 | | if (GetMythUI()->GetCurrentLocation().toLower() != "playbackbox") |
| 589 | else if (!(nc->getArg(3).contains(QRegExp("^\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$")))) |
601 | 590 | { |
602 | | GetMythMainWindow()->JumpTo(jumpMap["playbackbox"]); |
| 591 | result = QString("ERROR: Invalid StartTime \"%1\", expecting UTC YYYY-MM-DDTHH:MM:SS") |
| 592 | .arg(nc->getArg(3)); |
| 593 | } |
| 594 | else { |
| 595 | if (GetMythUI()->GetCurrentLocation().toLower() == "playback") |
| 596 | { |
| 597 | QString message = QString("NETWORK_CONTROL STOP"); |
| 598 | MythEvent me(message); |
| 599 | gCoreContext->dispatch(me); |
603 | 600 | |
604 | | QTime timer; |
605 | | timer.start(); |
606 | | while ((timer.elapsed() < 10000) && |
607 | | (GetMythUI()->GetCurrentLocation().toLower() != "playbackbox")) |
608 | | usleep(10000); |
| 601 | QTime timer; |
| 602 | timer.start(); |
| 603 | while ((timer.elapsed() < FE_LONG_TO) && |
| 604 | (GetMythUI()->GetCurrentLocation().toLower() == "playback")) |
| 605 | usleep(10000); |
| 606 | } |
609 | 607 | |
610 | | timer.start(); |
611 | | while ((timer.elapsed() < 10000) && |
612 | | (!GetMythUI()->IsTopScreenInitialized())) |
613 | | usleep(10000); |
614 | | } |
| 608 | if (GetMythUI()->GetCurrentLocation().toLower() != "playbackbox") |
| 609 | { |
| 610 | GetMythMainWindow()->JumpTo(jumpMap["playbackbox"]); |
615 | 611 | |
616 | | if (GetMythUI()->GetCurrentLocation().toLower() == "playbackbox") |
617 | | { |
618 | | QString action = "PLAY"; |
619 | | if (nc->getArgCount() == 5 && nc->getArg(4) == "resume") |
620 | | action = "RESUME"; |
| 612 | QTime timer; |
| 613 | timer.start(); |
| 614 | while ((timer.elapsed() < 10000) && |
| 615 | (GetMythUI()->GetCurrentLocation().toLower() != "playbackbox")) |
| 616 | usleep(10000); |
621 | 617 | |
622 | | QString message = QString("NETWORK_CONTROL %1 PROGRAM %2 %3 %4") |
623 | | .arg(action).arg(nc->getArg(2)) |
624 | | .arg(nc->getArg(3).toUpper()).arg(clientID); |
| 618 | timer.start(); |
| 619 | while ((timer.elapsed() < 10000) && |
| 620 | (!GetMythUI()->IsTopScreenInitialized())) |
| 621 | usleep(10000); |
| 622 | } |
625 | 623 | |
626 | | result.clear(); |
627 | | gotAnswer = false; |
628 | | QTime timer; |
629 | | timer.start(); |
| 624 | if (GetMythUI()->GetCurrentLocation().toLower() == "playbackbox") |
| 625 | { |
| 626 | QString action = "PLAY"; |
| 627 | if (nc->getArgCount() == 5 && nc->getArg(4) == "resume") |
| 628 | action = "RESUME"; |
630 | 629 | |
631 | | MythEvent me(message); |
632 | | gCoreContext->dispatch(me); |
| 630 | QString message = QString("NETWORK_CONTROL %1 PROGRAM %2 %3 %4") |
| 631 | .arg(action).arg(nc->getArg(2)) |
| 632 | .arg(nc->getArg(3).toUpper()).arg(clientID); |
633 | 633 | |
634 | | while (timer.elapsed() < FE_LONG_TO && !gotAnswer) |
635 | | usleep(10000); |
| 634 | result.clear(); |
| 635 | gotAnswer = false; |
| 636 | QTime timer; |
| 637 | timer.start(); |
636 | 638 | |
637 | | if (gotAnswer) |
638 | | result += answer; |
639 | | else |
640 | | result = "ERROR: Timed out waiting for reply from player"; |
| 639 | MythEvent me(message); |
| 640 | gCoreContext->dispatch(me); |
641 | 641 | |
642 | | } |
643 | | else |
644 | | { |
645 | | result = QString("ERROR: Unable to change to PlaybackBox from " |
646 | | "%1, cannot play requested file.") |
647 | | .arg(GetMythUI()->GetCurrentLocation()); |
| 642 | while (timer.elapsed() < FE_LONG_TO && !gotAnswer) |
| 643 | usleep(10000); |
| 644 | |
| 645 | if (gotAnswer) |
| 646 | result += answer; |
| 647 | else |
| 648 | result = "ERROR: Timed out waiting for reply from player"; |
| 649 | |
| 650 | } |
| 651 | else |
| 652 | { |
| 653 | result = QString("ERROR: Unable to change to PlaybackBox from " |
| 654 | "%1, cannot play requested file.") |
| 655 | .arg(GetMythUI()->GetCurrentLocation()); |
| 656 | } |
648 | 657 | } |
649 | 658 | } |
650 | 659 | else if (is_abbrev("music", nc->getArg(1))) |