mymobilesite.controller
Class Controller

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by mymobilesite.controller.Controller
All Implemented Interfaces:
LibertyProtocolListener

public class Controller
extends javax.microedition.midlet.MIDlet
implements LibertyProtocolListener

The Controller class is the application's main class and controls the program execution. It calls the other classes and handles all user and program (exceptions) events.

Author:
Gunn Olaussen & Kirsti N. Torgersen

Field Summary
private  int chosenprovider
           
private  GUI gui
           
private  java.lang.String idpName
           
private  LibertyProtocol libProtocol
           
private  MessageException me
           
private  java.lang.String[] providerList
           
private  boolean retrivedProviders
           
private  Service[] serviceList
           
private  java.lang.String username
           
 
Constructor Summary
Controller()
          The Controller constructor.
 
Method Summary
 void contactWsp(int index)
          This method request the LibertyProtocol to start retrieving services from the chosen provider.
protected  void destroyApp(boolean unconditional)
           
 void encounteredException(int currentState, MessageException me)
          Calls the GUI to display an appropriate error message.
 java.lang.String getIdpName()
           
 java.lang.String[] getProviderList()
           
 Service[] getServices()
           
protected  void pauseApp()
          This application does not support pausing the application and calls destroyApp.
 void resultsReady(int state, java.lang.Object result)
          Receives the results from the LibertyProtocol and handles them according to the state.
 void retry()
          This method is called by the GUI to show that the user has requested the application to try again the previous action which failed.
protected  void startApp()
          Starts the application.
 void startLogin(java.lang.String un, java.lang.String pwd)
          This method is called by the GUI when the user has pressed the button to start login.
 void userAborted()
          This method is used by the GUI to alert the controller that the user pressed back while waiting.
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceList

private Service[] serviceList

providerList

private java.lang.String[] providerList

gui

private GUI gui

libProtocol

private LibertyProtocol libProtocol

username

private java.lang.String username

me

private MessageException me

chosenprovider

private int chosenprovider

retrivedProviders

private boolean retrivedProviders

idpName

private java.lang.String idpName
Constructor Detail

Controller

public Controller()
The Controller constructor.

Method Detail

getIdpName

public java.lang.String getIdpName()
Returns:
String The name of the identity provider as retrieved from the certificate.

getServices

public Service[] getServices()
Returns:
Service[] An array of retrieved services.

getProviderList

public java.lang.String[] getProviderList()
Returns:
String[] An array with the names of the service providers.

startLogin

public void startLogin(java.lang.String un,
                       java.lang.String pwd)
This method is called by the GUI when the user has pressed the button to start login. The controller then calls the gui to change the window and tells the LibertyProtocol to start login at the identity provider by passing on credentials.

Parameters:
un - String The username which was entered into the login screen.
pwd - String The password which was entered into the login screen.

contactWsp

public void contactWsp(int index)
This method request the LibertyProtocol to start retrieving services from the chosen provider. It also changes gui to a waiting window.

Parameters:
index - int The index in the list of providers which the user has chosen.

userAborted

public void userAborted()
This method is used by the GUI to alert the controller that the user pressed back while waiting.

Parameters:
waitingState - int The waiting window which the back command was called from.

retry

public void retry()
This method is called by the GUI to show that the user has requested the application to try again the previous action which failed.


startApp

protected void startApp()
                 throws javax.microedition.midlet.MIDletStateChangeException
Starts the application.

Specified by:
startApp in class javax.microedition.midlet.MIDlet
Throws:
javax.microedition.midlet.MIDletStateChangeException
See Also:
MIDlet.startApp()

pauseApp

protected void pauseApp()
This application does not support pausing the application and calls destroyApp.

Specified by:
pauseApp in class javax.microedition.midlet.MIDlet
See Also:
MIDlet.pauseApp()

destroyApp

protected void destroyApp(boolean unconditional)
                   throws javax.microedition.midlet.MIDletStateChangeException
Specified by:
destroyApp in class javax.microedition.midlet.MIDlet
Throws:
javax.microedition.midlet.MIDletStateChangeException
See Also:
MIDlet.destroyApp(boolean)

resultsReady

public void resultsReady(int state,
                         java.lang.Object result)
Receives the results from the LibertyProtocol and handles them according to the state.

Specified by:
resultsReady in interface LibertyProtocolListener
Parameters:
state - int The state which the LibertyProtocol is currently in.
result - Object The result from the LibertyProtocol to the listener.
See Also:
LibertyProtocolListener.resultsReady(int, java.lang.Object)

encounteredException

public void encounteredException(int currentState,
                                 MessageException me)
Calls the GUI to display an appropriate error message.

Specified by:
encounteredException in interface LibertyProtocolListener
Parameters:
currentState - int The state which the LibertyProtocol is currently in.
me - MessageException The MessageException that the LibertyProtocol encountered.
See Also:
LibertyProtocolListener.encounteredException(int, mymobilesite.communication.MessageException)