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
  #301  
Old 02-21-2011, 02:47 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
I saw some info in the thread regarding using UIContext in Get/SetProperty() to make sure the data was actually written to the correct .properties file but it was old and I'd like to revisit the issue.

If I use SetProperty(UIContext.SAGETV_PROCESS_LOCAL_UI, "Name", "Value") from within my Java code will that write the property to the correct place or do I need to get the UIContext Name and then use SetProperty(new UIContext(UIContextName), "Name", "Value")?
I use the second method. If you are doing this in your server plugin configuration I am pretty sure you will always get the UICOntext of the server returned though for plugin implementations been a while since I have been in that part of my code though.
Reply With Quote
  #302  
Old 02-21-2011, 05:57 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by PLUCKYHD View Post
I use the second method. If you are doing this in your server plugin configuration I am pretty sure you will always get the UICOntext of the server returned though for plugin implementations been a while since I have been in that part of my code though.
I'm doing it in Java code that is called from any Sage UI.
__________________

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
  #303  
Old 02-21-2011, 06:03 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
I'm doing it in Java code that is called from any Sage UI.
Then yeah I have had better consistency using the new uicontext method.
Reply With Quote
  #304  
Old 02-21-2011, 07:36 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
I'm doing it in Java code that is called from any Sage UI
SAGETV_PROCESS_LOCAL_UI is specific context, and should only be used if you really mean to use that context. I think the client runs as that context.

If you need to set a property using the current ui context, then you can use SetProperty(UIContext.getCurrentContext(), Key, Value)

UIContext.getCurrentContext() will return the current ui context by checking a few things such as GetUIContextName(), thread names, etc, to return a valid ui context name.
Reply With Quote
  #305  
Old 02-21-2011, 07:38 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Thanks Sean, that's what I needed to know.
__________________

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
  #306  
Old 02-21-2011, 08:18 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
Thanks Sean, that's what I needed to know.
Just keep in mind, as Plucky noted as well, that sometimes, depending on when you are calling UIContent.GetCurrentContext(), you may not get the context you want (or think you are getting). This happens primarily if you call this during a plugin start/stop. This is because when aplugin is started, it doesn't have context, other than the local/server context.
Reply With Quote
  #307  
Old 02-22-2011, 04:57 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I'm not using it from the Plugin Implementation class, I'm using it in Java code that gets called from the STV. That should be OK, correct?
__________________

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
  #308  
Old 02-22-2011, 07:24 AM
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
I'm not using it from the Plugin Implementation class, I'm using it in Java code that gets called from the STV. That should be OK, correct?
That should be fine. But, if you find that you are a losing context... then you can always have your methods accept a context name. Calling GetUICotextName from the STV always returns the correct context. In phoenix, there are very few apis that accept a context... actually the only one that I can think of is the Play(MediaFile) api, since I want to be sure that it plays on the right context so normally i just rely on the underlying apis to return the correct one.
Reply With Quote
  #309  
Old 02-22-2011, 01:13 PM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Quote:
Originally Posted by stuckless View Post
Actually, apparently I do not compile the services every time. I only re-compile the services when the file's timestamp changes. So while you are developing it will recompile, but one you stop modifying the file, it will use the last compiled version of the service.
Great! I just wanted to say thanks for putting these APIs together. I'm using it for the new version of my Windows sidebar/desktop gadget and it's allowing me to do some cool things.
__________________
-Craig
Reply With Quote
  #310  
Old 02-22-2011, 01:30 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by cncb View Post
Great! I just wanted to say thanks for putting these APIs together. I'm using it for the new version of my Windows sidebar/desktop gadget and it's allowing me to do some cool things.
Cool... Just know that the latest sagex-api release will force http user authentication by default, so you'll want to store the username/password in your app, or have the user disable user/pass authentication on the server.
Reply With Quote
  #311  
Old 02-22-2011, 02:37 PM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Quote:
Originally Posted by stuckless View Post
Just know that the latest sagex-api release will force http user authentication by default, so you'll want to store the username/password in your app, or have the user disable user/pass authentication on the server.
Fortunately the current/first version already stores login info since it uses the web server interface but thanks for the heads up.
__________________
-Craig
Reply With Quote
  #312  
Old 02-24-2011, 07:39 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Sean,

I've got something strange going on and I don't know if it's me doing something wrong, me not understanding something, or a bug. I've been experimenting with UIContext.getCurrentContext() and the results seem to change during execution.

I've got the following code that I call multiple times during execution:

Code:
System.out.println("LOGGED IN USER " + Configuration.GetProperty(UIContext.getCurrentContext(), Plugin.PROPERTY_LAST_LOGGEDIN_USER, null));
System.out.println("UIContextName 1 " + Global.GetUIContextName());
System.out.println("UIContextName 2 " + Global.GetUIContextName(UIContext.getCurrentContext()));
At first it shows this, which is what I expect:

Code:
Thu 2/24 20:09:27.246 [Fork-BASE-55376@1b0d8fc] LOGGED IN USER Sue
Thu 2/24 20:09:27.246 [Fork-BASE-55376@1b0d8fc] UIContextName 1 0015170d8410
Thu 2/24 20:09:27.246 [Fork-BASE-55376@1b0d8fc] UIContextName 2 0015170d8410
After a few seconds it shows this:

Code:
Thu 2/24 20:09:42.588 [EventRouter-0015170d8410@1324aea] LOGGED IN USER Sue
Thu 2/24 20:09:42.588 [EventRouter-0015170d8410@1324aea] UIContextName 1 0015170d8410
Thu 2/24 20:09:42.588 [EventRouter-0015170d8410@1324aea] UIContextName 2 SAGETV_PROCESS_LOCAL_UI
And then a few seconds later it shows this:

Code:
Thu 2/24 20:11:17.213 [ReProcessHook@1a6ee94] LOGGED IN USER Sue
Thu 2/24 20:11:17.213 [ReProcessHook@1a6ee94] UIContextName 1 SAGETV_PROCESS_LOCAL_UI
Thu 2/24 20:11:17.213 [ReProcessHook@1a6ee94] UIContextName 2 SAGETV_PROCESS_LOCAL_UI
Why is the result changing over time? The code is getting called from a Java method that is called from the STV. It's running on a Windows PlaceShifter connected to a Linux server.

Thanks,

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.
Reply With Quote
  #313  
Old 02-24-2011, 08:07 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Tom, I can't really explain that. UIContext.getCurrentContext() uses a number of methods to discover the context, the first of which is GetUIContextName().

If you are calling GetUIContextName() from a non ui thread, then it will not return the current context.

If you are calling GetUIContextName() from the UI thread, the it should return current context.
Reply With Quote
  #314  
Old 02-24-2011, 08:52 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Just wanted to say if you are calling from a non ui thread you can pass the context to the thread when you start it and keep that variable in the thread.
Reply With Quote
  #315  
Old 02-25-2011, 05:32 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I'm calling the code from a UI thread which makes it all the more puzzling. What causes the UIContext to change (besides the obvious)?

I can't believe this is so difficult, all I am trying to do is read and write a property to the correct .property file from within Java using the sagex APIs. I'm not even using the sagex remote capabilities, this is all being done locally. I tried using Get/SetProperty() without the UIContext and I tried using the methods with the UIContext. I tried using UIContext.getCurrentContext() new UIContext(getUIContextName()). What am I doing wrong?

Plucky - I can't easily pass a UI Context to the methods, it would be a major pain in the butt and that seems an overkill for what should be a simple issue.
__________________

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
  #316  
Old 02-25-2011, 06:42 AM
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
I'm calling the code from a UI thread which makes it all the more puzzling. What causes the UIContext to change (besides the obvious)?

I can't believe this is so difficult, all I am trying to do is read and write a property to the correct .property file from within Java using the sagex APIs. I'm not even using the sagex remote capabilities, this is all being done locally. I tried using Get/SetProperty() without the UIContext and I tried using the methods with the UIContext. I tried using UIContext.getCurrentContext() new UIContext(getUIContextName()). What am I doing wrong?

Plucky - I can't easily pass a UI Context to the methods, it would be a major pain in the butt and that seems an overkill for what should be a simple issue.
I guess you'd have to strip away all the layers for the context stuff and use the SageTV.api("GetContextName") (not sure that's the right api name) and see if it returns the right value consistently... if it does, then it's something in the other layers... sagex is a pretty thin layer but the UIContext.getCurrentUIContent() does a lot.
Reply With Quote
  #317  
Old 02-25-2011, 12:00 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by stuckless View Post
I guess you'd have to strip away all the layers for the context stuff and use the SageTV.api("GetContextName") (not sure that's the right api name) and see if it returns the right value consistently... if it does, then it's something in the other layers... sagex is a pretty thin layer but the UIContext.getCurrentUIContent() does a lot.
OK, I'll give that a shot. I've never used the sage API directly, I've always used sagex and to a lesser extend Greg's wrappers. I poked around but could not find any instructions on how to call the API directly.

I did find the API specification here: http://download.sage.tv/api/index.html

But I'm still a novice at Java and can't really figure out how to invoke the methods in Java. Is it as simple as using SageTV.api.("methodNameHere", parm1, parm2)
__________________

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
  #318  
Old 02-25-2011, 12:25 PM
Fonceur's Avatar
Fonceur Fonceur is offline
Sage Icon
 
Join Date: Jan 2008
Location: DDO, QC
Posts: 1,915
Quote:
Originally Posted by tmiranda View Post
At first it shows this, which is what I expect:
Any chance you could simply save the initial value and reuse it, instead of constantly querying for it?
__________________
SageTCPServer (2.3.5): Open source TCP interface to the SageTV API
MLSageTV (3.1.8)/Sage Media Server (1.13): SageTV plugin for MainLobby/CQC
TaSageTV (2.58)/TaSTVRemote (1.14): Monitor/control SageTV with an Android device
TbSageTV (1.02)/STVRemote (1.11): Monitor/control SageTV with a PlayBook 2
TiSageTV (1.64)/TiSTVRemote (1.09): Monitor/control SageTV with an iPhone/iPod/iPad
Reply With Quote
  #319  
Old 02-25-2011, 12:35 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
you should be able to do sagex.api.Global.GetUIContextName() as well... unless stuckless is rerouting that to his own ui context logic....
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #320  
Old 02-25-2011, 01:00 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Fonceur View Post
Any chance you could simply save the initial value and reuse it, instead of constantly querying for it?
I thought about that but I don't know how I'd actually do it. All of the methods called from the STV must be public static (and can be invoked by different UIContexts simultaneously) which implies the only way to pass data to them is as a parameter and I can't easily add a parameter. (I'll explain why is you are interested.) If I am missing something obvious please let me know.
__________________

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
Hauppauge Remote Issue yacht_boy Hardware Support 4 05-01-2008 09:25 PM
MCE remote transmitting keypresses twice arnabbiswas Hardware Support 1 02-22-2007 10:55 AM
MCE Remote not work fully with Placeshifter devinteske SageTV Placeshifter 5 02-08-2007 11:45 PM
Harmony Remote IR Reciever Help brundag5 Hardware Support 2 01-13-2007 09:08 PM
How to get SageTV to release focus to NVDVD for remote IncredibleHat SageTV Software 4 07-06-2006 07:47 AM


All times are GMT -6. The time now is 06:13 PM.


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