com.webhiker.dreambox.api
Class DreamboxAPI

java.lang.Object
  extended by com.webhiker.dreambox.api.DreamboxAPI
All Implemented Interfaces:
java.lang.Runnable

public class DreamboxAPI
extends java.lang.Object
implements java.lang.Runnable

The Class DreamboxAPI. For events to be generated for registered listeners, a new Thread needs to be started e.g. new Thread(new DreamboxAPI("127.0.0.1","80","root","dreambox")).start();


Nested Class Summary
static class DreamboxAPI.Command
          The set of available Dreambox commands.
 
Constructor Summary
DreamboxAPI(java.lang.String host, int port, java.lang.String username, java.lang.String password)
          Instantiates a new dreambox api.
 
Method Summary
 void addDreamboxListener(DreamboxListener dl)
          Adds the dreambox listener.
 void checkConnection()
          Check connection parameter, and throw an exception if could not connect.
 void command(DreamboxAPI.Command command)
          This provides functionality for Dreambox control.
 void fireStatusChanged(DreamboxListener dl)
          Utility method to fire status changed events to all registered listeners.
 java.util.List<Bouquet> getBouquets()
          Gets the bouquets.
 EPG getEPG()
          Gets the Electronic Program Guide information for the currently showing channel.
 java.lang.String getHost()
          Gets the host.
 java.lang.String getPassword()
          Gets the password.
 int getPort()
          Gets the port.
 Status getStatus()
          Gets the status of the stream for the currently showing channel.
 StreamInfo getStreamInfo()
          Gets the stream info for the currently displayed service.
 java.lang.String getUsername()
          Gets the username.
 java.lang.String getVLCURL()
          Gets the VLC playable URL for the currently playing channel, but converted to specified host instead of internal IP address.
 int getVolume()
          Gets the current volume as reported by the Dreambox.
 boolean isConnected()
          Returns true if Dreambox is connected, else returns false
 boolean isRunning()
           
static void main(java.lang.String[] args)
          The main method.
 void run()
           
 void selectChannel(Channel channel)
          Change to the specified channel.
 void sendMessage(java.lang.String message)
          Send a message to the Dreambox display.
 void setHost(java.lang.String host)
          Sets the host.
 void setPassword(java.lang.String password)
          Sets the password.
 void setPort(int port)
          Sets the port.
 void setUsername(java.lang.String username)
          Sets the username.
 void setVolume(int volume)
          Sets the volume to the specified value.
 void stop()
          Stop polling the Dreambox for status changes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DreamboxAPI

public DreamboxAPI(java.lang.String host,
                   int port,
                   java.lang.String username,
                   java.lang.String password)
Instantiates a new dreambox api.

Parameters:
host - the host
port - the port
username - the username
password - the password
Method Detail

getHost

public java.lang.String getHost()
Gets the host.

Returns:
the host

setHost

public void setHost(java.lang.String host)
Sets the host.

Parameters:
host - the new host

getUsername

public java.lang.String getUsername()
Gets the username.

Returns:
the username

setUsername

public void setUsername(java.lang.String username)
Sets the username.

Parameters:
username - the new username

getPassword

public java.lang.String getPassword()
Gets the password.

Returns:
the password

setPassword

public void setPassword(java.lang.String password)
Sets the password.

Parameters:
password - the new password

getPort

public int getPort()
Gets the port.

Returns:
the port

setPort

public void setPort(int port)
Sets the port.

Parameters:
port - the new port

run

public void run()
Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stop polling the Dreambox for status changes.


selectChannel

public void selectChannel(Channel channel)
                   throws java.io.IOException
Change to the specified channel.

Parameters:
channel - the new channel
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

setVolume

public void setVolume(int volume)
               throws java.io.IOException
Sets the volume to the specified value.

Parameters:
volume - the new volume
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getVolume

public int getVolume()
              throws java.io.IOException
Gets the current volume as reported by the Dreambox.

Returns:
the volume
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

command

public void command(DreamboxAPI.Command command)
             throws java.io.IOException
This provides functionality for Dreambox control.

Parameters:
command - the command to execute
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

sendMessage

public void sendMessage(java.lang.String message)
                 throws java.io.IOException
Send a message to the Dreambox display.

Parameters:
message - the message
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getVLCURL

public java.lang.String getVLCURL()
                           throws java.io.IOException
Gets the VLC playable URL for the currently playing channel, but converted to specified host instead of internal IP address.

Returns:
the url
Throws:
java.io.IOException

getStatus

public Status getStatus()
                 throws java.io.IOException
Gets the status of the stream for the currently showing channel.

Returns:
the status
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getEPG

public EPG getEPG()
           throws java.io.IOException,
                  org.xml.sax.SAXException,
                  javax.xml.parsers.ParserConfigurationException
Gets the Electronic Program Guide information for the currently showing channel.

Returns:
the ePG
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
org.xml.sax.SAXException - the SAX exception
javax.xml.parsers.ParserConfigurationException - the parser configuration exception

getStreamInfo

public StreamInfo getStreamInfo()
                         throws java.io.IOException,
                                javax.xml.parsers.ParserConfigurationException,
                                org.xml.sax.SAXException
Gets the stream info for the currently displayed service.

Returns:
the stream info
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
javax.xml.parsers.ParserConfigurationException - the parser configuration exception
org.xml.sax.SAXException - the SAX exception

getBouquets

public java.util.List<Bouquet> getBouquets()
                                    throws java.io.IOException
Gets the bouquets.

Returns:
the bouquets
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

addDreamboxListener

public void addDreamboxListener(DreamboxListener dl)
Adds the dreambox listener.

Parameters:
dl - the dl

fireStatusChanged

public void fireStatusChanged(DreamboxListener dl)
                       throws java.io.IOException
Utility method to fire status changed events to all registered listeners.

Throws:
java.io.IOException

checkConnection

public void checkConnection()
                     throws java.io.IOException
Check connection parameter, and throw an exception if could not connect.

Throws:
java.io.IOException - Signals that an I/O exception has occurred.

isConnected

public boolean isConnected()
Returns true if Dreambox is connected, else returns false

Returns:
true, if is connected

main

public static final void main(java.lang.String[] args)
The main method.

Parameters:
args - the arguments

isRunning

public boolean isRunning()