com.blackledge.david.tivo.multitasker
Class URLProxyFactory

java.lang.Object
  extended by com.tivo.hme.sdk.Factory
      extended by com.blackledge.david.tivo.multitasker.URLProxyFactory
All Implemented Interfaces:
com.tivo.hme.interfaces.IFactory

Deprecated. not needed... thould delete this.

public class URLProxyFactory
extends com.tivo.hme.sdk.Factory

Need Factory to operate as a Thread so main app doesn't wait while tivo asks for content from factory.  Not sure I can do that without my own host impl… maybe make factory its own stand-alone…that would make sense, anyhow.   Just need inter-process comm for mapping urls.
Actually, should just be a proxy factory that asks app for true URL (or image object - future)… so maybe app has a factory that just serves url strings really quickly?

globalFactory = urlconverter - ideally not displayed on Tivo as an option.
myApp.Factory:
If url starts with "/urls/" take content after that and pass it to String app.getRealUrl(String mappedUrl)
myApp made orginal URL with

Extract most of MultitaskerAppFactory to globalFactory that runs independently.
Make it take current handling of /local(image) and if stuff after that starts with /mapp/ make request to url after /mapp/, expect result to be the unmapped URL, and continue.

Define in MultiTaskerAppFactory (maybe indirecting to Global Factory's static methods?):
String urlForTivo = getAsynchronousUrl(localFilePath or Web URL)
Generates globalFactory/local/mapp/myApp/asynch/mappedUrl
And locally store mapping of localFilePathOrWebURL mapped to mappedUrl
[optimized: if url would be within limits, don't do mapping, just put real path after "/local/"]
String urlForTivo = getAsynchronousImageUrl(localFilePath or Web URL, maxwidth, maxheight);
Generates globalFactory/localimage(w/h)/mapp/myApp/asynch/mappedUrl
And locally store mapping of localFilePathOrWebURL mapped to mappedUrl
public final String realUrlWithContentToServeTivo = getUnmappedUrl(tivoUrl) unmaps the "mappedUrl" portion to above mappings

Process:
App asks getFactory() for asynch url which maps to real url
App uses asynch url as stream source
        TiVo asks globalFactory to serve it.
                globalFactory sees /mapp/ and peals off Url back to App and makes request of that Url
                ---------
                        App Factory receives myApp/asynch/mappedUrl request, notices asynch, peals off mappedUrl and calls
                        AppFactory.getUnmappedUrl(mappedUrl)
And returns the string as content, hopefully. NOT SURE ABOUT THIS STEP - does SDK Factory API allow something like this between apps(factories)? - worst case, can set a header in the returned stream and just read that… hackish, though.
                -------
                globalFactory extracts real URL from response
                globalFactory does whatever it currently does after getting mapped Url unmapped to serve a stream to TiVo.

 

Version:
$Revision: 1.1 $

Field Summary
static String MAP_BACK_URL_PATH
          Deprecated.  
 
Fields inherited from class com.tivo.hme.sdk.Factory
active, assetURI, clazz, factoryData, isActive, listener, loader, title, uri
 
Fields inherited from interface com.tivo.hme.interfaces.IFactory
HME_APPLICATION_CLASSNAME, HME_DEBUG_KEY, HME_VERSION_TAG
 
Constructor Summary
URLProxyFactory()
          Deprecated. MultiTasker's Application factory.
 
Method Summary
protected  void addHeaders(com.tivo.hme.interfaces.IHttpRequest http, String uri)
          Deprecated.  
 com.tivo.hme.interfaces.IApplication createApplication(com.tivo.hme.interfaces.IContext context)
          Deprecated. Just to save a copy of the first-used context.
static String getLocalUri(String uri)
          Deprecated. only for map-back urls
 InputStream getStream(String uri2)
          Deprecated. If you override, just be sure to allow this (super) implementation to handle url's that are myapp/local.
 String getUnmappedUri(String shortUri)
          Deprecated. Undo the work of #getShortMappedUri(String).
protected  void init(com.tivo.hme.interfaces.IArgumentList args)
          Deprecated. Use arg "-localRoot" to specify the home dir from which local and localimage files are relative to.
 boolean isHandledUri(String uri)
          Deprecated.  
 
Methods inherited from class com.tivo.hme.sdk.Factory
addApplication, close, destroyFactory, fetchAsset, getActiveCount, getAppName, getAppTitle, getAssetURI, getFactoryData, getQuery, getSeekTime, getTitle, getURI, initFactory, isActive, log, removeApplication, removeQueryFromURI, setActive, setAppName, setAppTitle, setAssetURI, setListener, setTitle, setURI, shutdown, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAP_BACK_URL_PATH

public static final String MAP_BACK_URL_PATH
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

URLProxyFactory

public URLProxyFactory()
Deprecated. 
MultiTasker's Application factory. Handles "local" and "localimage" urls. Subclass this to create your own factory if needed and you still want to support those urls.

Method Detail

init

protected void init(com.tivo.hme.interfaces.IArgumentList args)
Deprecated. 
Use arg "-localRoot" to specify the home dir from which local and localimage files are relative to. Defaults to user.home - if that is empty or contains "galleon" uses "C:\Documents and Settings\Owner"

Overrides:
init in class com.tivo.hme.sdk.Factory
See Also:
Factory.init(com.tivo.hme.interfaces.IArgumentList)

isHandledUri

public boolean isHandledUri(String uri)
Deprecated. 

getStream

public InputStream getStream(String uri2)
                      throws IOException
Deprecated. 
If you override, just be sure to allow this (super) implementation to handle url's that are myapp/local. And call getUnmappedUri(String) on the uri to handle any short mapping that may have been done.

Overrides:
getStream in class com.tivo.hme.sdk.Factory
Throws:
IOException
See Also:
Factory.getStream(java.lang.String)

addHeaders

protected void addHeaders(com.tivo.hme.interfaces.IHttpRequest http,
                          String uri)
                   throws IOException
Deprecated. 
Overrides:
addHeaders in class com.tivo.hme.sdk.Factory
Throws:
IOException

getUnmappedUri

public String getUnmappedUri(String shortUri)
Deprecated. 
Undo the work of #getShortMappedUri(String).

Parameters:
shortUri - the result of the call to #getShortMappedUri(String)
Returns:
the uri originally passed to #getShortMappedUri(String) or shortUri if no mapping exists.

getLocalUri

public static String getLocalUri(String uri)
Deprecated. 
only for map-back urls

Parameters:
uri -
Returns:

createApplication

public com.tivo.hme.interfaces.IApplication createApplication(com.tivo.hme.interfaces.IContext context)
                                                       throws IOException
Deprecated. 
Just to save a copy of the first-used context.

Specified by:
createApplication in interface com.tivo.hme.interfaces.IFactory
Overrides:
createApplication in class com.tivo.hme.sdk.Factory
Throws:
IOException
See Also:
Factory.createApplication(com.tivo.hme.interfaces.IContext)