SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

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 02-12-2011, 08:02 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Determining if SageClient is running on Server in service mode

How can I differentiate between a SageClient running remotely and a SageClient that is actually running on the server (when SageTV is running as a service)?

Maybe I'm doing something wrong, but I found some rather odd behavior with using GetProperty() in a Plugin implementation class. If you use GetProperty() in the Plugin code, and the code is invoked from a SageClient running on the server when SageTV is in service mode, GetProperty() returns the property from the sage.properties file and not the sageclient.properties file. Invoking the same code from a "real" SageClient (running on the network someplace) GetProperty() returns the value from the sageclient.properties file.

I realize this is probably because the implementation class can only have one instance on the server, but it's still a little odd IMHO and certainly confuses things a bit.

What I am doing is setting a property (using SetProperty()) in the STV code and then trying to retrieve it from the Plugin implementation class.
__________________

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.

Last edited by tmiranda; 02-12-2011 at 08:18 AM.
Reply With Quote
  #2  
Old 02-12-2011, 11:57 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
After re-reading the docs I think IsClient() && IsServerUI() is what I am looking for. More testing needed.....
__________________

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.
Reply With Quote
  #3  
Old 02-12-2011, 12:32 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Java plugins installed on the server run by default in the service process, not the UI process. If you intend for it to run in the UI process, tag it Desktop in the manifest. (However this may cause installation problems on Linux, where there is no Desktop client.)
__________________
-- Greg
Reply With Quote
  #4  
Old 02-12-2011, 01:00 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
I am currently using the following to determine if it is a client:

Global.GetUIContextName().equalsIgnoreCase("SAGETV_PROCESS_LOCAL_UI") || Global.IsClient() || Global.IsServerUI() || Global.IsDesktopUI()

For some strange reason, i have found that on a client, the IsClient() seems to work, but for a client running on a server, all the calls seem to return null, but the GetUIContextName() does return the "SAGETV_PROCESS_LOCAL_UI" value, which is usually only a client, since placeshifters and extenders return the MAC address...

Thanks,
Jeff

PS. Sorry I hadn't responded to your email.. been tied up with work problems...
Reply With Quote
  #5  
Old 02-12-2011, 03:03 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by GKusnick View Post
Java plugins installed on the server run by default in the service process, not the UI process.
I figured that part out. The issue I am having is that from a Plugin I need to retrieve a property that I want set on a per-UI basis. I can't simply call GetProperty() from the Plugin because it fails under one condition, when the SageClient is running on the server and SageTV is running in service mode.

Normally when GetProperty() is called in the Plugin from a placeshifter, or extender (or a SageClient not running on the server) it retrieves the property from the appropriate "client" property file. In the one case I mention above when SetProperty() is called from the STV it puts the property in the SageClient.properties file and the Plugin retrieves properties from the Sage.properties file.

I think the solution is to detect the special case in the STV and then make sure I put all of the properties for that special case in the server properties file.
__________________

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.
Reply With Quote
  #6  
Old 02-12-2011, 03:17 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by tmiranda View Post
I think the solution is to detect the special case in the STV and then make sure I put all of the properties for that special case in the server properties file.
This seems like a bad solution to me. Client properties belong in the client-specific properties file, where Get/SetProperty puts them. If your Java plugin is not accessing the correct file, then your solution is either to make sure it runs in the UI process (using the Desktop tag as I mentioned earlier), or if it must run in the service process for some other reason, then use the appropriate client UI context when making your Get/SetProperty calls.
__________________
-- Greg
Reply With Quote
  #7  
Old 02-12-2011, 04:01 PM
JREkiwi's Avatar
JREkiwi JREkiwi is offline
Sage Icon
 
Join Date: Jan 2005
Location: Auckland, New Zealand
Posts: 2,132
I've been using
Code:
sagex.api.Configuration.GetProperty(sagex.SageAPI.getUIContext(), "blah/blah", true)
which is working for me.

John

Last edited by JREkiwi; 02-12-2011 at 04:03 PM.
Reply With Quote
  #8  
Old 02-12-2011, 04:07 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by GKusnick View Post
This seems like a bad solution to me. Client properties belong in the client-specific properties file, where Get/SetProperty puts them. If your Java plugin is not accessing the correct file, then your solution is either to make sure it runs in the UI process (using the Desktop tag as I mentioned earlier), or if it must run in the service process for some other reason, then use the appropriate client UI context when making your Get/SetProperty calls.
Yup, it's an ugly solution. I (think) I can't make the "java Plugin" run in the UI process, because the java code is running as a "General" Plugin. The physical call to GetProperty() is in the Plugin.getConfigSettings() method. (I want to display different settings depending on a property that is set on a per-UI basis.)

Another solution is to create my own settings dialog and forget about using the Sage Plugin Config options. That's probably the cleanest thing to do.
__________________

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.
Reply With Quote
  #9  
Old 02-12-2011, 04:35 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by tmiranda View Post
I (think) I can't make the "java Plugin" run in the UI process, because the java code is running as a "General" Plugin.
A General plugin (i.e. one with a Java ImplementationClass) can run in the UI process. That's what the Desktop tag in the manifest is for. My Studio Tools plugin is an example of this.

Quote:
Originally Posted by tmiranda View Post
Another solution is to create my own settings dialog and forget about using the Sage Plugin Config options. That's probably the cleanest thing to do.
If the only purpose of your General plugin is to provide a config screen for your STVI (aka "UI mod") plugin, then you might want to take a look at my STVI Configurator, which allows you to write plugin config methods in Studio code rather than Java, and still use the built-in plugin config machinery instead of having to roll your own config dialog.
__________________
-- Greg
Reply With Quote
  #10  
Old 02-12-2011, 05:44 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by GKusnick View Post
A General plugin (i.e. one with a Java ImplementationClass) can run in the UI process. That's what the Desktop tag in the manifest is for. My Studio Tools plugin is an example of this.
I didn't realize that's what the tag did, thanks for the information.

Quote:
If the only purpose of your General plugin is to provide a config screen for your STVI (aka "UI mod") plugin, then you might want to take a look at my STVI Configurator, which allows you to write plugin config methods in Studio code rather than Java, and still use the built-in plugin config machinery instead of having to roll your own config dialog.
The implementation class does a lot more, but I still need to learn how to use your STVI Configurator.

I moved the config options to a new dialog and I think that is actually the best way to go. It provides more uniformity with the other dialogs and cuts down on complexity.

As always, thanks for your help and insight. I'm glad you take the time to help newbies.
__________________

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.
Reply With Quote
  #11  
Old 02-14-2011, 12:14 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by tmiranda View Post
How can I differentiate between a SageClient running remotely and a SageClient that is actually running on the server (when SageTV is running as a service)?
BTW: you can determine if the UI is a server UI being used with the service using the same method that the System Information menu does:

Code:
If !IsClient() && !IsRemoteUI()
|--InfoText = "Service Mode: " + If(GetProperty("client","")=="true", "Enabled", "Disabled")
That is for an installation of SageTV (server); if it is an installation of SageTVClient that is also running on the server, then I think IsClient() will be true anyway.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #12  
Old 02-14-2011, 02:01 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
Another solution is to create my own settings dialog and forget about using the Sage Plugin Config options. That's probably the cleanest thing to do.
This may be off base, but the PluginAPI doesn't care where you store your settings. ie, GetProperty/SetProperty is just one implementation that you might choose to do. So, you can choose to use any other means, ie, UserRecord, database, etc to store your actual configuration.

If you are extending the sagex AbstractPlugin and using the addProperty() methods to build up your configuration, then can you can assign your own persistence to each each property as well, by setting a custom IPropertyPersitence implementation. (you can also set a visiblility handler and a validation handler)

So, if you build your panel, then you'll probably still need to solve where you store configuration,etc.

If you haven't looked at the AbstractPlugin in sagex, it's worth checking it out. It allows you to easily build up your configuration, use alternate persistence models, and easily handle onchange events (or register yourself as a listener to other events) using annotations. Here's the AbstractPlugin, and here's a couple of implementations to see how it's used; Sagex Service Plugin; Phoenix Metadata Plugin.

Bottom line, I don't think you need a custom ui panel, you can probably do what you need using the existing plugin configuration panels.
Reply With Quote
  #13  
Old 02-14-2011, 02:05 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Thanks for the help.
__________________

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.
Reply With Quote
Reply


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

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
Client lockup only when server is running service pratt733 SageTV Software 4 04-21-2008 09:58 AM
Q: SageClient mode w/ Sage Service not saving into SageClient.properties laurenglenn SageTV Software 2 06-17-2007 09:22 PM
Sage service mode and media server sunray SageTV Software 0 07-02-2006 11:39 PM
Running as service mode, no go. (anymore) pciccone SageTV Software 0 12-29-2004 07:15 AM


All times are GMT -6. The time now is 04:22 PM.


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