com.lightdev.app.ddnscl
Class DynDnsClient


java.lang.Object

  extended bycom.lightdev.app.Application

      extended bycom.lightdev.app.DefaultApplication

          extended bycom.lightdev.app.ddnscl.DynDnsClient

All Implemented Interfaces:
DynDnsIPChecker.DynDnsIPCheckerListener, DynDnsIPUpdater.DynDnsIPUpdaterListener

public class DynDnsClient
extends DefaultApplication
implements DynDnsIPChecker.DynDnsIPCheckerListener, DynDnsIPUpdater.DynDnsIPUpdaterListener

An application to manually or automatically check the IP address of a machine and to update the obtained IP address at DynDns.org

Version:
1, July 11, 2004
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the GNU General Public License, for details see file gpl.txt in the distribution package of this software as well as any licensing notes inside this documentation

Nested Class Summary
 class DynDnsClient.CheckTimerTask
          a custom TimerTask that initiates an IP check in its run method
 class DynDnsClient.KillTimerTask
          a custom TimerTask that terminates an automatically running IP check.
 
Field Summary
static String ACTION_CHECK_IP
          keyword of the action that initiates IP checks
static String ACTION_TOGGLE_AUTO_MODE
          keyword of the action that switches automatic IP checks and updates on or off
static String ACTION_UPDATE_IP
          keyword of the action that initiates IP updates
static String APP_NAME
          name of this application
static String PREFS_DOMAIN
          constant that denotes in the preferences the domain to update an IP address for
static String PREFS_PASSWORD
          constant that denotes in the preferences the password at DynDns.org
static String PREFS_STORED_IP
          constant that denotes in the preferences the IP address stored most recently
static String PREFS_USER_NAME
          constant that denotes in the preferences the user name at DnyDns.org
 
Fields inherited from class com.lightdev.app.DefaultApplication
ACTION_ABOUT_APP, ACTION_EXIT_APP, ACTION_SHOW_HELP_CONTENTS
 
Fields inherited from class com.lightdev.app.Application
APP_HELP_NAME, JAVA_HELP_EXT, logger, RB_KEY_ABOUT_APP_DIALOG_TITLE, RB_KEY_APP_MENUBAR, RB_KEY_LOG_APP_CAN_NOT_EXIT, RB_KEY_LOG_APP_STARTED, RB_KEY_LOG_APP_TERMINATED, RESOURCE_NOT_FOUND, URL_SEPARATOR
 
Constructor Summary
DynDnsClient(boolean withUI, long duration)
          constructor
 
Method Summary
 void about()
          show information about this application (overridden from class Application)
 void acquireIP()
          get the IP address as determined by DynDns.org for this machine
 void initActions()
          intialize the actions of this application
 void IPDetectionError(DynDnsIPChecker checker, Exception e)
          a DynDnsIPChecker thread calls this method when an error occured during thread execution
 void IPUpdateError(DynDnsIPUpdater updater, Exception e)
          a DynDnsIPUpdater thread calls this method when an error occured during thread execution
static void main(String[] args)
          application main method The application checks for exact two parameters in args.
 void receivedIP(DynDnsIPChecker checker)
          a DynDnsIPChecker thread calls this method when it has received an IP address
 void receivedUpdateResponse(DynDnsIPUpdater updater)
          a DynDnsIPUpdater thread calls this method when it has received an update response
 boolean runsInAutoMode()
          determine if this application currently runs in auto mode, i.e. if it automatically checks and updates the IP address at DynDns.org
 void toggleAutoMode(boolean activate, long idle, long duration)
          switch automatic IP checks and updates on or off when duration is set to a non-zero value, the automatic IP checks will terminate after the number of minutes given in duration.
 void updateIP()
          store the current public IP address as acquired from DynDns.org as the IP address of the domain.
 
Methods inherited from class com.lightdev.app.DefaultApplication
center, centerFrame, findMainFrame, initMainFrame
 
Methods inherited from class com.lightdev.app.Application
canExit, exitApplication, getAppName, getBundle, getHelpBroker, getResMenu, log, logStackTrace, setLogging, setLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFS_STORED_IP


public static final String PREFS_STORED_IP
constant that denotes in the preferences the IP address stored most recently

See Also:
Constant Field Values

PREFS_DOMAIN


public static final String PREFS_DOMAIN
constant that denotes in the preferences the domain to update an IP address for

See Also:
Constant Field Values

PREFS_USER_NAME


public static final String PREFS_USER_NAME
constant that denotes in the preferences the user name at DnyDns.org

See Also:
Constant Field Values

PREFS_PASSWORD


public static final String PREFS_PASSWORD
constant that denotes in the preferences the password at DynDns.org

See Also:
Constant Field Values

APP_NAME


public static final String APP_NAME
name of this application

See Also:
Constant Field Values

ACTION_CHECK_IP


public static final String ACTION_CHECK_IP
keyword of the action that initiates IP checks

See Also:
Constant Field Values

ACTION_UPDATE_IP


public static final String ACTION_UPDATE_IP
keyword of the action that initiates IP updates

See Also:
Constant Field Values

ACTION_TOGGLE_AUTO_MODE


public static final String ACTION_TOGGLE_AUTO_MODE
keyword of the action that switches automatic IP checks and updates on or off

See Also:
Constant Field Values
Constructor Detail

DynDnsClient


public DynDnsClient(boolean withUI,

                    long duration)
constructor

Parameters:
withUI - boolean true, if a user interface is to be shown, false if not
duration - long the number of minutes to run in background mode, if withUI is false (0 = forever)
Method Detail

acquireIP


public void acquireIP()
get the IP address as determined by DynDns.org for this machine


updateIP


public void updateIP()
store the current public IP address as acquired from DynDns.org as the IP address of the domain.


runsInAutoMode


public boolean runsInAutoMode()
determine if this application currently runs in auto mode, i.e. if it automatically checks and updates the IP address at DynDns.org

Returns:
boolean true, if the application runs in auto mode

toggleAutoMode


public void toggleAutoMode(boolean activate,

                           long idle,

                           long duration)
switch automatic IP checks and updates on or off

when duration is set to a non-zero value, the automatic IP checks will terminate after the number of minutes given in duration. When the application is started to run in the background, this will terminate the application along with the timer task after the given amount of minutes.

Parameters:
activate - boolean true if automatic IP checks and updates is to be switched on, false otherwise
idle - long the time to wait between two subsquent checks/updates (unused, if 'activate' is false)
duration - long length of the timer thread in minutes

about


public void about()
show information about this application (overridden from class Application)


main


public static void main(String[] args)
application main method

The application checks for exact two parameters in args. When launched without command line parameters, the application displays a user interface and runs in interactive mode. The interactive mode allows to start and stop automatic IP checks and updates manually.

When '-noui' is given as the first command line parameter, the application is launched as a task in the background without user interface. In this mode the application is started with automatic IP checks/updates switched on checking the IP address and updating as necessary every 10 minutes. The applicatin will run forever unless a numeric value is given as an optional second parameter which denotes the duration the application shall run in this mode in minutes.

Examples


   1) java -jar DynDnsClient.jar

      start the application in interacive mode with user interface



   2) java -jar DynDnsClient.jar -noui

      start the application in background mode without user interface

      to run forever, checking/updating IPs every 10 minutes



   3) java -jar DynDnsClient.jar -noui 60

      start the application in background mode without user interface

      to run for 60 minutes, checking/updating IPs every 10 minutes

 

Parameters:
args - String[] the arguments passed to the application upon start

initActions


public void initActions()
intialize the actions of this application


receivedIP


public void receivedIP(DynDnsIPChecker checker)
a DynDnsIPChecker thread calls this method when it has received an IP address

Specified by:
receivedIP in interface DynDnsIPChecker.DynDnsIPCheckerListener
Parameters:
checker - DynDnsIPChecker the thread that fired this event

IPDetectionError


public void IPDetectionError(DynDnsIPChecker checker,

                             Exception e)
a DynDnsIPChecker thread calls this method when an error occured during thread execution

Specified by:
IPDetectionError in interface DynDnsIPChecker.DynDnsIPCheckerListener
Parameters:
checker - DynDnsIPChecker the thread that fired this event
e - Exception the exception that occurred

receivedUpdateResponse


public void receivedUpdateResponse(DynDnsIPUpdater updater)
a DynDnsIPUpdater thread calls this method when it has received an update response

Specified by:
receivedUpdateResponse in interface DynDnsIPUpdater.DynDnsIPUpdaterListener
Parameters:
updater - DynDnsIPUpdater the thread that fired this event

IPUpdateError


public void IPUpdateError(DynDnsIPUpdater updater,

                          Exception e)
a DynDnsIPUpdater thread calls this method when an error occured during thread execution

Specified by:
IPUpdateError in interface DynDnsIPUpdater.DynDnsIPUpdaterListener
Parameters:
updater - DynDnsIPUpdater the thread that fired this event
e - Exception the exception that occurred

Copyright (c) 2004 Ulrich Hilger