org.stanwood.media.source.xbmc
Class XBMCAddonManager

java.lang.Object
  extended by org.stanwood.media.source.xbmc.XBMCAddonManager
All Implemented Interfaces:
IContentFetcher

public class XBMCAddonManager
extends java.lang.Object
implements IContentFetcher

The manager for XBMC addons


Constructor Summary
  XBMCAddonManager(ConfigReader config)
          Used to create a instance of the addon manager
protected XBMCAddonManager(ConfigReader config, IXBMCUpdater updater, boolean doInit)
           
 
Method Summary
 java.lang.String downloadFile(java.net.URL url, java.io.File newAddon)
          This will copy a file from the web to a destination file on the local system
 XBMCAddon getAddon(java.lang.String id)
          Used to get a addon
 java.lang.String getDefaultAddonID(Mode mode)
          Used to get the default source ID
 Stream getStreamToURL(java.net.URL url)
          This will get a input stream to the contents pointed at by the URL
 IXBMCUpdater getUpdater()
          Used to get the XBMC updater
protected  void init(IXBMCUpdater updater)
           
 boolean isFirstTime()
          Checks if this is the first time the application has been run.
 java.util.Set<java.lang.String> listAddons()
          Used to get a list of addon ID's
 void registerAddons()
          Used to register all the XBMC addons that are found in the addon directory
 void unregisterAddons()
          Used to unregister all XBMC addons with the manager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XBMCAddonManager

protected XBMCAddonManager(ConfigReader config,
                           IXBMCUpdater updater,
                           boolean doInit)
                    throws XBMCException
Throws:
XBMCException

XBMCAddonManager

public XBMCAddonManager(ConfigReader config)
                 throws XBMCException
Used to create a instance of the addon manager

Parameters:
config - The configuration
Throws:
XBMCException - Thrown if their is a problem creating the addon manager
Method Detail

init

protected void init(IXBMCUpdater updater)
             throws XBMCException
Throws:
XBMCException

getUpdater

public IXBMCUpdater getUpdater()
Used to get the XBMC updater

Returns:
the XBMC updater

unregisterAddons

public void unregisterAddons()
Used to unregister all XBMC addons with the manager


getAddon

public XBMCAddon getAddon(java.lang.String id)
                   throws XBMCException
Used to get a addon

Parameters:
id - The ID of the addon to get
Returns:
The addon
Throws:
XBMCException - Thrown if the addon could not be found

registerAddons

public void registerAddons()
                    throws XBMCException
Used to register all the XBMC addons that are found in the addon directory

Throws:
XBMCException - Thrown if their is a problem

getStreamToURL

public Stream getStreamToURL(java.net.URL url)
                      throws SourceException
This will get a input stream to the contents pointed at by the URL

Specified by:
getStreamToURL in interface IContentFetcher
Parameters:
url - The URL
Returns:
The input stream
Throws:
SourceException - thrown if their is a problem getting the stream

getDefaultAddonID

public java.lang.String getDefaultAddonID(Mode mode)
                                   throws XBMCException
Used to get the default source ID

Parameters:
mode - The mode that were looking for a source id in
Returns:
The default source ID for a given mode
Throws:
XBMCException - Thrown if their is a problem getting the default source ID

downloadFile

public java.lang.String downloadFile(java.net.URL url,
                                     java.io.File newAddon)
                              throws java.io.IOException
This will copy a file from the web to a destination file on the local system

Parameters:
url - The URL to read from the file from
newAddon - The file to be created on the location system
Returns:
A MD5 sum of the file
Throws:
java.io.IOException - Thrown if their is a problem reading or wring the file

listAddons

public java.util.Set<java.lang.String> listAddons()
Used to get a list of addon ID's

Returns:
The list of addon ID's

isFirstTime

public boolean isFirstTime()
                    throws XBMCException
Checks if this is the first time the application has been run.

Returns:
True if first time , otherwise false
Throws:
XBMCException - Thrown if their are any problems