SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio

Notices

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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-17-2010, 07:18 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Plugin: STVI Configurator

Per this discussion, I have created an STVI (with some Java support code) that allows STVI plugins to use the V7 plugin configuration UI instead of rolling their own config UI. Detailed instructions are in the Javadocs for Tools Library V1.2, but the gist of it is that you implement a few lines of widget code in your STVI for each of the get/setConfig* methods, insert them into a standard place in the STVI Configurator code skeleton, and declare STVI Configurator as an STVI dependency in your manifest. Once this is done, a Configure button will appear on the options dialog for your plugin, and your widget-code methods will be called by the plugin manager in lieu of Java-based config methods.

To make things even easier, Tools Library V1.2 also includes an XmlConfig class that lets you define your config settings in an XML file, so that your config methods can be one-line calls into XmlConfig. You're not obliged to use XmlConfig with the STVI Configurator, but it does simplify things.
__________________
-- Greg

Last edited by GKusnick; 07-17-2010 at 07:24 PM.
Reply With Quote
  #2  
Old 07-18-2010, 08:10 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Very nice work Greg and much needed for per STVi developers who don't want to code their own stvi options.
Reply With Quote
  #3  
Old 07-18-2010, 08:39 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Greg, I just want to clarify... Will the PluginAPI calls, such as, GetPluginConfigSettings, work on these plugins as well? (I think it will, but I just want to make sure)
Reply With Quote
  #4  
Old 07-18-2010, 11:17 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by stuckless View Post
Greg, I just want to clarify... Will the PluginAPI calls, such as, GetPluginConfigSettings, work on these plugins as well? (I think it will, but I just want to make sure)
You mean if you call them yourself from Java or from another STVI? Unfortunately no, they won't. To get this to work I had to replace PluginAPI calls in the stock STV with calls to my STVI-aware wrapper methods. I would rather not have done this, so if you know of a way for me to intercept calls to the native PluginAPI methods, that would be a cleaner and more robust approach.
__________________
-- Greg
Reply With Quote
  #5  
Old 07-18-2010, 01:02 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Quote:
Originally Posted by GKusnick View Post
You mean if you call them yourself from Java or from another STVI? Unfortunately no, they won't. To get this to work I had to replace PluginAPI calls in the stock STV with calls to my STVI-aware wrapper methods. I would rather not have done this, so if you know of a way for me to intercept calls to the native PluginAPI methods, that would be a cleaner and more robust approach.
Ok.. thx. I don't know of a better way, and I'm sure the way you've done it, is one of few nice ways to do what you've done.

I was asking, because at some point, I wanted to make the plugin configuration available via the Phoenix configuration metadata (which would also make it available via the web ui) . I won't be doing this for some time, but when I do it, I'll simply create phoenix configuration nodes by iterating the plugin list and calling GetPluginConfigSettings for each plugin (as well as the other plugin apis to fully populate the metadata)
Reply With Quote
  #6  
Old 07-18-2010, 02:14 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
well, the plugin configurations are still just stored in the .properties files, so you shouldn't NEED to go through the plugin config system to use them from Phoenix/BMT Web.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #7  
Old 08-13-2010, 08:30 PM
chrishallowell chrishallowell is offline
Sage Advanced User
 
Join Date: Jan 2008
Posts: 169
STVi Configurator questions

I have a few questions as I work through the STVi Configurator process. I plan on storing the config values in an XML.

What folder do you store the config.xml (example.config.xml in the example)?

Where do you put the SettingMethod conditional in Studio? Does that go in the Application Started hook as well; right after the action that instantiates the XMLConfig via AddGlobalContext?

How do you test this? How do you test the Application Started hook? I tried F5 on the hook and a black screen showed up. Do you have to shut down SageTV and open it back up or is there a trick?

* merged *
Reply With Quote
  #8  
Old 08-13-2010, 09:09 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by chrishallowell View Post
I plan on storing the config values in an XML.
You can of course store config values anywhere you want, but the expected place for them is in the .properties file, and that's where my XmlConfig class will put them.

Or are you just saying you want to use XmlConfig to get the config definitions from an XML file?

Quote:
Originally Posted by chrishallowell View Post
What folder do you store the config.xml (example.config.xml in the example)?
Again, you can put it anywhere you want, so long as your plugin can find at startup time. One option is to have your plugin installer extract it to a custom folder, and set the ResourcePath in your manifest to the (relative) path of that folder. Then you can call GetPluginResourcePath() at startup time to locate it.

What I prefer to do is to package the config.xml as a resource in the JAR file, and use XmlConfig.FromResource() to load it at startup time. That way it's one less file cluttering up the user's disk.

Quote:
Originally Posted by chrishallowell View Post
Where do you put the SettingMethod conditional in Studio?
You don't. If you have STVI Configurator installed and enabled, the SettingMethod conditional should already exist in the STVI Configurator menu. You must add your methods to this existing conditional in order for STVI Configurator to find them.

(However there seems to be a new bug in 7.0.15 that prevents menus created by STVIs from showing up in Studio. I'll file a bug report on that.)

Quote:
Originally Posted by chrishallowell View Post
How do you test this? How do you test the Application Started hook? I tried F5 on the hook and a black screen showed up. Do you have to shut down SageTV and open it back up or is there a trick?
ApplicationStarted fires whenever an STV is loaded. So if you change the enable state of your STVI, the STV will be reloaded and ApplicationStarted will fire.

You can also test any arbitrary widget chain using the Execute Widget Chain command on the right-click context menu. But if the chain depends on variables that aren't globally defined, it may not do what you expect when invoked this way. (F5 is strictly for launching Menu widgets.)

As a final note, if you post questions like this to the existing STVI Configurator thread, I'll probably see them sooner because I'm subscribed to that thread. That goes for pretty much any plugin question: the plugin authors subscribe to their own support threads in order to get notifications about questions from users. Starting a new thread bypasses that notification system and may delay the response. (Plus it tends to clutter the forum unnecessarily and push useful threads off the front page.)
__________________
-- Greg
Reply With Quote
  #9  
Old 08-14-2010, 09:11 PM
chrishallowell chrishallowell is offline
Sage Advanced User
 
Join Date: Jan 2008
Posts: 169
More noob questions....

Yes, I will be using the gkusnick.sagetv.XmlConfig class to get my config definitions from an XML document.

I'm still confused what the job of the SettingMethod condition is? Is it to get any of the elements defined in the config definitions XML doc and to save values to the sageTV.properties file?

Say I have this XML config definitions file:
Code:
<config>
   <setting name="CallName" type="Text">
      <label>Call name:</label>
      <helptext>This will be the call name used.</helptext>
      <property>mypluginsCallName</property>
   </setting>
   <setting name="AgeOfUser" type="Integer">
      <label>Age:</label>
      <helptext>Enter your age.</helptext>
      <property>mypluginsAgeOfUser</property>
   </setting>
   <setting name="BkColor" type="Choice">
      <label>Background Color</label>
      <helptext>This will be the color of the table.</helptext>
      <option>red</option>
      <option>blue</option>
      <property>mypluginsBkColor</property>
      <default>red</default>
   </setting>
</config>
Where do I get the cls and the szResource for the FromResource method?
Say my jar has:
package HelloTable
class HelloTableClass1
class HelloTableClass2
Resource folder called: Resources
XML in the folder called: ConfigDefinitions.XML
Code:
In ApplicationStarted hook:
AddGlobalContext("ExampleConfig", new_gkusnick_sagetv_XmlConfig(XmlConfig.FromResource(cls, szResource)))
Is this what I need in the SettingMethod condition?
Code:
"example.getConfigSettings"
	gkusnick_sagetv_XmlConfig_getConfigSettings(ExampleConfig)
"example.getConfigType"
        gkusnick_sagetv_XmlConfig_getConfigType(ExampleConfig, SettingName)
"example.getConfigLabel"
        gkusnick_sagetv_XmlConfig_getConfigLabel(ExampleConfig, SettingName)
"example.getConfigHelpText"
        gkusnick_sagetv_XmlConfig_getConfigHelpText(ExampleConfig, SettingName)
"example.getConfigValue"
        gkusnick_sagetv_XmlConfig_getConfigValue(ExampleConfig, SettingName)
"example.setConfigValue"
        gkusnick_sagetv_XmlConfig_setConfigValue(ExampleConfig, SettingName, SettingStrValue)
"example.getConfigValueAsInt"
        gkusnick_sagetv_XmlConfig_getConfigValueAsInt(ExampleConfig, SettingName)
"example.????"
        gkusnick_sagetv_XmlConfig_setConfigValue(ExampleConfig, SettingName, SettingIntValue)
Since I already have a example.setConfigValue, I'm not sure what the ???? should be.

Last edited by chrishallowell; 08-14-2010 at 09:16 PM.
Reply With Quote
  #10  
Old 08-14-2010, 10:22 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
The SettingMethod conditional is how STVIConfig finds the right method to execute. When the UI wants to call method M of plugin P, the STVIConfig runtime sets the global variable SettingMethod to "P.M" and calls ExecuteWidgetChain on the conditional. The result is that the branch labeled "P.M" gets executed. But that's all internal to the STVIConfig implementation. Your responsibility is just to make sure that the appropriate branches exist for the methods you want to implement.

Also, as indicated in the STVIConfig docs, you're not obliged to use XmlConfig with STVIConfig. You can put any widget code you like in those method branches. Using XmlConfig is a convenient way to keep that code concise, but XmlConfig itself has no knowledge of that conditional widget structure, and STVIConfig has no special knowledge about XmlConfig, so it's not really accurate to say that the job of the conditional is to interact with XmlConfig. Its job is simply to invoke whatever code you choose to put in those branches, which can be calls to XmlConfig if that suits your needs.

The branch names you use should be specific to your plugin, e.g. "hellotable.getConfigSettings" rather than "example.getConfigSettings" (assuming "hellotable" is the unique plugin ID specified in your manifest). Your job is not to replace the contents of the existing "example" branches, but to add new, uniquely named branches below the "else" branch. Similarly, you ought not to call your XmlConfig instantiation ExampleConfig; you should call it HelloTableConfig or something else specific to your plugin. Don't step on the example code if you want your plugin to coexist peacefully with other plugins using the same machinery.

You don't need a branch for getConfigValueAsInt; that's not one of the standard methods defined by the SageTVPlugin interface (which is what you're trying to satisfy here). It's just a convenience method I thought might be useful to Java coders using XmlConfig and is not really relevant to STVI code.

I'm not following your question about setConfigValue; if you already have a branch for that, you don't need another one. Again, don't get confused by the overloads in XmlConfig.java; your guide on what to implement should be the methods defined by SageTVPlugin.

The class you pass in to XmlConfig.FromResource in some sense doesn't really matter; its only use is to determine which ClassLoader to use for loading the resource. If that doesn't mean anything to you, don't worry about it. The simplest rule of thumb is to pass in any class defined by the same JAR as the resource you're trying to load. In your case either of your HelloTable classes will work. To get a class object from STVI code, call java_lang_Object_getClass on an instance of the class.

The szResource you pass in is the string name of the resource file in the JAR. That's the filename that the resource loader will search for. As such it should be unique within the set of JARs on the search path (i.e. in the SageTV\JARs folder), to avoid collisions with other plugins and their resources. So "ConfigDefinitions.XML" is not a good choice from that perspective; something along the lines of "HelloTable.config.xml" would be better.

Your XML looks reasonable, but as a matter of convention I'd suggest putting your plugin's properties under some common key, e.g. Hallowell/HelloTable/CallName, Hallowell/HelloTable/AgeOfUser, etc. This makes it clear they belong together and lets you manipulate them as a group if you need to. Prefixing it with your name is a good idea so that if you write more than one plugin, their properties all group together in the .properties file.

The same goes for Java package names, by the way: call it Hallowell.HelloTable or something along those lines both to make it clear who it belongs to and to minimize the chance of collision with other package names. (The Java convention is to use some domain name that you own as the prefix, with the components reversed, e.g. org.apache.whatever.)
__________________
-- Greg
Reply With Quote
  #11  
Old 08-16-2010, 12:10 PM
chrishallowell chrishallowell is offline
Sage Advanced User
 
Join Date: Jan 2008
Posts: 169
Quote:
Originally Posted by GKusnick View Post
You don't need a branch for getConfigValueAsInt; that's not one of the standard methods defined by the SageTVPlugin interface (which is what you're trying to satisfy here).
Ok this clears things up a lot.

What does the getting/setting of the property values in the sage.properties file? STVi config, XmlConfig, SageTV internal, or something I need to do?

Do I have this right (not using the STVi config)?
1. User installs a plugin
2. SageTV internal process uses the manifest xml to ensure all dependencies are in place and then it installs the files.
3. User selects the config button of the plugin
4. SageTV internal process calls the get sage.api.PluginAPI methods to get the config options in the HelloTableConfigDefinitions.XML file and property values from the sage.properties file and then displays them in SageTV.
5. User changes a property value.
6. SageTV internal process calls a set sage.api.PluginAPI method to save the changed property to the sage.properties file.

But now since we are using the STVi config, SettingMethod conditional methods process the calls instead of the sage.api.PluginAPI. Am I right?

Assuming the above statements are true, how do I know what methods are called by the SageTV internal process?

(I know, it's like your trying to teach a baby to walk here... )

Last edited by chrishallowell; 08-16-2010 at 02:39 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
STVi Plugin: Phoenix Fanart for Malore Menus tmiranda SageTV v7 Customizations 29 11-28-2015 01:28 PM
MediaPlayer Plugin/STV Import: Winamp Media Player Plugin deria SageTV Customizations 447 12-11-2010 07:38 PM
STVi plugin request: Send TV show detailed info to an email recipient mkanet SageTV Customizations 1 01-22-2006 03:59 PM


All times are GMT -6. The time now is 02:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.