Opened 3 years ago

Closed 21 months ago

Last modified 12 months ago

#12738 closed Bug Report - General (fixed)

Mythfrontend Service API SendAction not working

Reported by: paul@… Owned by: Bill Meek
Priority: minor Milestone: unknown
Component: MythTV - Services API - Frontend Version: 0.28.0
Severity: medium Keywords:
Cc: Ticket locked: no

Description

I have recently updated to 0.28 and have encountered a problem with the frontend service API. It seems that the SendAction? is being ignored. I’m using this as an example:

wget -O sendaction --post-data ‘Action=DOWN' http://192.168.x.x:6547/Frontend/SendAction

Mythfrontend responds with an xml file containing the boolean true, so assuming that this has been accepted fine. However, it never performs the action. SendKey? works fine, which is ok for up / down etc but I need SendAction? for jumping to recordings, live tv etc.

Attachments (3)

frontend.cpp.patch.0 (4.5 KB) - added by Bill Meek 2 years ago.
frontend.cpp.patch.1 (1.6 KB) - added by Roger Siddons 2 years ago.
QKeySequence demo
12783.frontend.cpp.patch.2 (601 bytes) - added by Bill Meek 23 months ago.
New approach, working in my tests.

Download all attachments as: .zip

Change History (27)

comment:1 Changed 3 years ago by Bill Meek

Status: newinfoneeded_new

Paul, I can get things like these working now:

Program Guide
Program Finder
Previously Recorded
Manage Recording Rules
Homepage
Channel Recording Priorities
Gallery Default
Video Browser
Video Gallery
Video Listings
Video Manager

are there others you use that aren't available with SendKey? I intentionally left out Live TV for now.

comment:2 Changed 3 years ago by paul@…

No, those cover all the ones I use, apart from Live TV, which, unfortunately, is probably the most used on my system. Any reaspn you left it out?

comment:3 Changed 3 years ago by Bill Meek

Status: infoneeded_newassigned

comment:4 Changed 3 years ago by Mitch Capper <mitch.capper@…>

Hi Bill, not to hijack this thread but it sounds like the fact SendAction? doesn't work is OK for anything that SendKey? can do (although technically I think even jumppoints can be assigned keys). I guess this also would depreciate GetActionList/GetContextList?.

To facilitate SendKey? I am thinking of adding a GetKeyBindings? / SetKeyBinding? actions to the backend myth service as I don't see another way of getting that information currently.

comment:5 Changed 3 years ago by Bill Meek

Was just reading your comments on IRC backlog. What I've got that works (with SendAction) is this:

-    QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, Action);
-    qApp->postEvent(GetMythMainWindow(), (QEvent*)ke);
+    GetMythMainWindow()->JumpTo(Action);

But it only does actions like "Program Guide", "Channel Recording Priorities" etc. (Things that the Network Control does.) That would make SendAction work again. Seems that if anything is sent in (QEvent*)ke above fails. Wondering if this is a Qt 5 issue.

comment:6 Changed 3 years ago by Mitch Capper <mitch.capper@…>

Sure although again I don't mind being forced onto SendKey? but if you don't know the keystrokes there isn't a way to /learn/ them with the services api so thus why I figured the new backend API calls. I am happy to see about diving into SendAction? if trying to maintain it further seems worthwhile.

comment:7 Changed 2 years ago by Eric Dobbertin <eric@…>

Is there any update on this issue? My company built and maintains the MythControlled? iOS app, and we've had complaints about none of the jumping working on 0.28.x, but I can't come up with any solution. The response is true but nothing happens. As Mitch pointed out, sending a key is useless if you actually want to trigger a certain action but you don't know which key is mapped to that action. The best I can do, I guess, is assume default key mappings or ask all our users to bind specific keys? What is the recommendation here? Thanks

comment:8 Changed 2 years ago by mitch.capper@…

I am even happy to write the code to fix this per above, but I want official direction before wasting my time on a solution not desired.

comment:9 Changed 2 years ago by Bill Meek

Eric/Mitch?,

If the jumpMap[] entries listed here:

https://code.mythtv.org/cgit/mythtv/tree/mythtv/programs/mythfrontend/networkcontrol.cpp#n84

worked, would that solve the iOS issue? Essentially, letting SendAction do actions and letting SendKey handle the rest. Specifically, Action=Live TV works.

comment:10 Changed 2 years ago by Mitch Capper <mitch.capper@…>

Hi Bill, Obviously if we can get one or both of these fully working that would be great. I have had a PR request open for almost a year now: https://code.mythtv.org/trac/ticket/12753 to try and make sure clients can properly interact with key binds (and discover them) and actions.

I think a clear direction needs to be decided and then we can work to make it work, unfortunately the longer this issue stays open the broader the range of mythtv versions that are broken for proper remote control.

comment:11 Changed 2 years ago by Roger Siddons

Looks like SendAction was broken by 9f34b4f82252

The MythMainWindow::eventFilter interprets the KeyEvent as a ke->key() < 0 and blackholes it.

Reverting it (or preferably, only returning when keycode > 0) makes the OP's DOWN & "TV Recording Playback" actions start working for me.

Bill, can you confirm & fix ?

Last edited 2 years ago by Roger Siddons (previous) (diff)

comment:12 Changed 2 years ago by Bill Meek

Roger,

Thanks! This:

-            if (ke->key() <= 0)
+            if (ke->key() < 0)

works. So far, I'm getting ke->key() = 0 from everything from SendAction. SendKey continues to work and the eventFilter gets ke->key()s like 16777251/0x1000015/DOWN. Thought that would be considered negative. But no. (int)0 didn't help.

comment:13 Changed 2 years ago by Roger Siddons

Doh! I'd missed that SendAction is explicitly setting the key code to 0.

So the issue is SendAction was sending an "Unknown Key" but Stuart found real unknown keys, which could also be code 0 according to Qt, i.e. you might be breaking Stuart's patch.

The negative thing makes me uneasy. Qt defines key codes as bit patterns. We shouldn't be assuming how they are interpreted as some platforms may differ. However I don't think that's too relevant here.

I think keycodes of 0 should always be examined but unrecognised nativeScanCodes should be allowed through. It seems wrong but TranslateKeyPress depends on it.

According to the comment MythFEXML (whatever that is) may also be broken by this.

Changed 2 years ago by Bill Meek

Attachment: frontend.cpp.patch.0 added

comment:14 Changed 2 years ago by Bill Meek

OK, maybe the solution shouldn't be in eventFilter. The next attachment seems to work (it just calls SendKey for keys and keys with names (like DOWN.)

Otherwise, it uses the GetMythMainWindow()->JumpTo(Action) from way back in comment 5.

I need some help here because I've duplicated the keyMap from SendKey into SendAction. Seems like there's a better way to do that (and the map is really from programs/mythfrontend/networkcontrol.cpp so it's really a third copy. Anyone know how to put it in a single place?

comment:15 Changed 2 years ago by Eric Dobbertin <eric@…>

Thanks for the quick response guys. I went through our iOS app's commands and this seems to be the full list of the actions that aren't working.

  • DAYLEFT
  • DAYRIGHT
  • TOGGLEFAV
  • HELP
  • RWND
  • FFWD
  • Reset+All+Keys
  • Channel+Recording+Priorities
  • TV+Recording+Deletion
  • Play+Disc
  • MythGallery
  • MythGame?
  • MythNetTree?
  • Live+TV
  • Main+Menu
  • Manage+Recording+Rules
  • Play+music
  • MythNews?
  • Previously+Recorded
  • Program+Finder
  • Program+Guide
  • Rip+CD
  • Status+Screen
  • Manage+Recordings+/+Fix+Conflicts
  • Video+Browser
  • Video+Gallery
  • Video+Listings
  • Video+Manager
  • TV+Recording+Playback
  • MythWeather?
  • Program+Recording+Priorities

It would be a bonus if Action=Live+TV&Value=[channel ID] worked to start on that channel, but I believe that one never worked properly.

RWND and FFWD seem strange because all the other variations of rewind and ffwd actions DO work. Currently our app allows you to bind the arrows on our remote screen separately from the normal up, down, left, right context-specific bindings that would apply when using a keyboard. And also it can do a different action if you hold it down vs a single tap. So it would be nice if the ff/rw actions all worked, but if necessary we could simplify things and just use up/down/left/right with SendKey?.

comment:16 Changed 2 years ago by Roger Siddons

Bill,

Strictly, the services run in a separate thread so your patch shouldn't be calling JumpTo (non-threadsafe UI code) directly. That's probably why it was 'abusing' QKeyEvent in the first place. You could use MythEvent(Action) instead and put the JumpTo in https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythui/mythmainwindow.cpp#L2634 with the others. But you'll be back to distinguishing a SendAction event from other events.

Also, a screen processing the Jump Action currently has the ability to clean itself up before completing the keypress. Short-circuiting that at the service level would prevent that. I doubt any do (or arguably should) but it may have ramifications...

Regarding your question, for SendKey & SendAction you could declare the keymap statically - see example in patch. It would need to go in a header for networkcontrol to use it as well.

However I'm wondering why keymap is necessary at all (networkcontrol is over 10 years old). QKeySequence will do the same thing - my patch demonstrates.

It differs only with the non-standard punctuation mneumonics. Is there a problem with sending puctuation characters to a service ? Seems we're forcing clients to convert "<" to "less" for purely historical reasons. It would be nice to delegate the character handling to Qt

Eric, There is no RWND action; only SEEKRWND, JUMPRWND, RWNDSTICKY

https://code.mythtv.org/doxygen/tv__actions_8h_source.html

Changed 2 years ago by Roger Siddons

Attachment: frontend.cpp.patch.1 added

QKeySequence demo

comment:17 Changed 2 years ago by Eric Dobbertin <eric@…>

OK, I will remove our RWND/FFWD usage. Both of those are still listed in the response when you hit /GetActionList?, but it's possible they never worked.

comment:18 Changed 2 years ago by Roger Siddons

I don't see it in my list. Looks like that list is actually generated from the keybindings table in your database.

Unfortunately old, deprecated settings/keybindings aren't always (ever?) removed so my guess would be you're using an database with old cruft and the RWND was removed.

If you remove those keybindings from the database then they should disappear from GetActionList?.

The frontend creates any missing keybindings on startup so, to get a reliable set of current actions, you could clear the whole table for a host before running the frontend.

comment:19 Changed 2 years ago by Eric Dobbertin <eric@…>

Oh that makes sense. The db for our test machine probably goes back to 0.25ish.

comment:20 in reply to:  18 Changed 2 years ago by Karl Egly

Replying to rsiddons:

Unfortunately old, deprecated settings/keybindings aren't always (ever?) removed so my guess would be you're using an database with old cruft and the RWND was removed.

I'm trying to collect old / disused settings for the next schema change, so we clean up behind us and avoid people fiddling with settings that are not used anymore, then wondering why they don't work, then ask for support. Wasting everybody's time in the process.

Maybe we should do the same for keybindings? Can someone provide a list of disused keybindings for cleanup with 29.0?

Changed 23 months ago by Bill Meek

Attachment: 12783.frontend.cpp.patch.2 added

New approach, working in my tests.

comment:21 Changed 21 months ago by Bill Meek <bmeek@…>

Resolution: fixed
Status: assignedclosed

In 7075a5fb0f4554beccca019849a9d2dd38b62fe8/mythtv:

Restore SendAction? operation, Fixes #12738

SendAction? appears to be affected by 9f34b4f, but that's needed to
allow operation of some keypresses.

Thanks to Roger Siddons for finding the root cause of the problem.

comment:22 Changed 21 months ago by Bill Meek <bmeek@…>

In 3ab8bebf7f46ef7e87e612d0eb1c9c4fc88b037d/mythtv:

Restore SendAction? operation, Fixes #12738

SendAction? appears to be affected by 9f34b4f, but that's needed to
allow operation of some keypresses.

Thanks to Roger Siddons for finding the root cause of the problem.

(cherry picked from commit 7075a5fb0f4554beccca019849a9d2dd38b62fe8)

comment:23 Changed 21 months ago by Bill Meek <bmeek@…>

In f1a485c62ad2c8da4f8d44056a2053ccf6e9eb84/mythtv:

Restore SendAction? operation, Fixes #12738

SendAction? appears to be affected by 9f34b4f, but that's needed to
allow operation of some keypresses.

Thanks to Roger Siddons for finding the root cause of the problem.

(cherry picked from commit 7075a5fb0f4554beccca019849a9d2dd38b62fe8)

comment:24 Changed 12 months ago by Bill Meek

Owner: changed from Bill Meek to Bill Meek
Note: See TracTickets for help on using tickets.