|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Bad idea to modify Widgets from with STV?
I've been thinking about how to make my MultiUser plugin compatible with as many other plugins as possible. One possible way is to dynamically modify the STV widgets using SetWidgetName() during the ApplicationStarting hook (or even in the start() method in the Implementation class), but I'm wondering if this is a bad idea.
In the MultiUser plugin I've created an API that replaces many of the Sage core APIs. For example, instead of using GetFavorites() the STV invokes tmiranda_mus_API_getFavorites(). I did some experiments and it turns out to be very easy to scan all of the Widgets and replace all occurrences of the core API with my methods. So is it a bad idea to do this? I hope not because if I can get this to work properly I can make the plugin compatible with practically all plugins Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#2
|
||||
|
||||
That sort of thing used to be considered perfectly legitimate for an STVI to do in its STVImported hook. People don't implement STVIs that way very much anymore, with all the new tools that have emerged. But in principle it would still be possible. The problem would be making sure your import happened last so you could catch any new widgets introduced by other STVIs.
Obviously that's why you'd rather do it in ApplicationStarted. But I think you'll find that if you do it there, you're going to leave the STV in a dirty state so that it will be constantly prompting the user to save it (which you definitely don't want them doing). The other thing to consider is that a blanket replace of all uses of GetFavorites() might not be appropriate. There might be legitimate cases where a plugin wants access to all favorites, regardless of who they belong to or who's logged in. (A scheduling plugin might be an example of this.) On the other hand, there might be calls in Java code that ought to be changed, but you won't be able to find them with a widget-based search-and-replace. This could result in inconsistent behavior in plugins that use a mix of widget and Java code.
__________________
-- Greg |
#3
|
||||
|
||||
Greg,
Thanks for the insights. If I should not put the code in the ApplicationStarting hook, where should it go? And how do I avoid leaving the STV dirty state or how do I suppress the "STV has been modified" message? If editing Widgets was the "old way" of importing, there must be a way to do it correctly, right? To avoid "blanket replacements" I planned on using a .properties file with a simple grammar to specify what to replace and where NOT to do the replacement. Then as I find incompatibilities with plugins I can just update the .properties file rather than update the STVi and/or .jar. I'm not sure if this is possible, but it will make an interesting project. If other plugins call the core API from within their own java code there is nothing I can do about it. I know my system will not be foolproof, but it will work with many plugins (I hope).
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#4
|
||||
|
||||
Quote:
__________________
-- Greg |
#5
|
||||
|
||||
I'd rather hear a correct unsatisfactory answer than an incorrect satisfactory answer
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#6
|
||||
|
||||
I took a look at the manual and it says the hook is triggered when an STVi has been imported using the ImportSTVFile() method. I'm going to assume that that's how the Plugin Manager loads STVi's.
I'm thinking I can use that hook to scan the STV each time an STVi is loaded as long as I'm careful not to edit the same widget multiple times. So each time the code is called it will first check the existing STV (to make the changes to the widgets that were loaded before my plugin) and then check the new widgets for things that need to be changed. It's not real efficient but I think it's worth a shot.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#7
|
||||
|
||||
Quote:
The mechanism that clears the dirty flag is in the code that loads the STV, then imports any enabled STVI plugins, and then clears the dirty state of the STV. There is no other way currently to clear that dirty state. The biggest problem you'll run into doing what you outline here is what Greg mentioned where Java calls into the API would not get replaced by your logic (and there's really no way to replace those). So weird inconsistencies may result from your modifications.
__________________
Jeffrey Kardatzke Founder of SageTV |
#8
|
||||
|
||||
Jeff,
Thanks for the clarification. I have no intention of modifying the ImportSTVFile() API, I was just trying to understand how things are done to see if what I do want to do will have any adverse consequences. Two questions: 1. If I modify the STV during a STVImported() hook, will that cause the dirty flag to get set or not? 2. When the ImportedWidgets are passed to the STVImported() hook have they already been merged into the STV or will they be merged after the STVImported() hook is complete? I'm assuming it's the former but hoping it's the latter, because if it's the latter I can (hopefully) modify the Widgets BEFORE they get merged into the STV and that should solve my "dirty flag" problem. Tom
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#9
|
||||
|
||||
Quote:
Quote:
Quote:
I think the real sticking point is that you seem to be assuming that the STVImported hook in your STVI will fire when some other STVI is imported. I don't think that's the case. I think (but can't swear) that yours fires just once, when your STVI is imported, and then the hook and the code underneath it are deleted before the next STVI is imported. At least I don't see any evidence of STVImported hooks persisting in the STV beyond the initial import.
__________________
-- Greg |
#10
|
||||
|
||||
Quote:
__________________
Jeffrey Kardatzke Founder of SageTV |
#11
|
||||
|
||||
Quote:
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Are 64K Blocks Ever A Bad Idea? | Savage1701 | Hardware Support | 7 | 05-10-2010 11:33 AM |
HD PVR to record Blue ray movies...bad idea | tvconfuse | Hardware Support | 12 | 10-03-2008 08:17 AM |
Bad idea? | utekineir | Hardware Support | 5 | 01-13-2007 01:29 PM |
Removing garbage widgets from STV | dflachbart | SageTV Studio | 11 | 05-10-2006 09:10 AM |
STV feature idea | evilpenguin | SageTV Customizations | 15 | 12-08-2004 05:00 AM |