Indy 9 | Content | Index | Reference

TIdIPWatch
Hierarchy, Properties, Methods, Events, See Also, Unit: IdIPWatch
Determines the online status and IP addresses for a computer.

    TIdIPWatch = class(TIdComponent)

Unit
IdIPWatch
Description
TIdIPWatch determines Online status, returns current IP address, and (optionally) keeps history of IP addresses issued to the computer using the class instance.

TIdIPWatch uses CurrentIP to determine online status, and will not establish a new connection using RAS or DUN.

TIdIPWatch.Active
TIdIPWatch
Indicates that IP history collection is active.

    property Active: Boolean;

Description
Active is a Boolean property used to indicate that the class instance is ready to detect new IP addresses. For TIdIPWatch, changing the value of Active also updates the state of the internal TIdIPWatchThread used by the object instance. The default value for Active is IP_WATCH_ACTIVE.

TIdIPWatch.CurrentIP
TIdIPWatch, See Also
Specifies the most recent IP used by the host.

    property CurrentIP: string;

Description
CurrentIP is a read-only String property used to identify the most recent IP address returned by the LocalIP function. CurrentIP is updated as a result of TIdIPWatchThread event notifications when WatchInterval milliseconds has elapsed, or by a call to ForceCheck.

TIdIPWatch.HistoryEnabled
TIdIPWatch
Indicates that the IP history is stored to the history file.

    property HistoryEnabled: Boolean;

Description
HistoryEnabled is a Boolean property used to indicate if the IPHistoryList should be saved in SaveHistory or restored in LoadHistory. The default value for HistoryEnabled is IP_WATCH_HIST_ENABLED, as assigned in the Create constructor.

TIdIPWatch.HistoryFilename
TIdIPWatch, See Also
Identifies the IP history storage file.

    property HistoryFilename: string;

Description
HistoryFilename is a String property used to identify the file name for saving and restoring IP addresses in IPHistoryList. The default value for HistoryFilename is defined in the constant IP_WATCH_HIST_FILENAME.

TIdIPWatch.IPHistoryList
TIdIPWatch, See Also
IPHistoryList is a list of IP addresses detected on the local computer.

    property IPHistoryList: TStringList;

Description
IPHistoryList is a read-only TStringList property used as a container for IP addresses detected by the TIdIPWatch class instance. IPHistoryList does not record an empty IP address ('') or the local IP address 127.0.0.1. IPHistoryList does not record an IP address when the most recent IP address in the history list matches the current IP address.

IPHistoryList is updated in the methods CheckStatus and Destroy.

The IPHistoryList can contain a maximum number of entries identified in the MaxHistoryEntries property. When the the number of entries exceeds MaxHistoryEntries, the oldest IP address in the history list will be deleted.

TIdIPWatch.IsOnline
TIdIPWatch
Identifies if the local host is online.

    property IsOnline: Boolean;

Description
IsOnline is a read-only Boolean property used to identify the current online status. IsOnline is updated in the CheckStatus method, and is set to True when the current IP address is not empty ('') or the default local host value 127.0.0.1.

The default value for IsOnline is False.

TIdIPWatch.MaxHistoryEntries
TIdIPWatch
The maximum number of IP addesses allowed in IPHistoryList.

    property MaxHistoryEntries: Integer;

Description
MaxHistoryEntries is an Integer property used to determine the maximum number of IP address to be maintain in IPHistoryList. When the number of entries in IPHistoryList exceeds MaxHistoryEntries, the oldest IP address will be deleted from IPHistoryList.

TIdIPWatch.OnStatusChanged
TIdIPWatch
OnStatusChanged event handler.

    property OnStatusChanged: TNotifyEvent;

Description
OnStatusChanged is a TNotifyEvent event handler triggered when the value of IsOnline is changed. The OnStatusChanged event handler is not called when the value of ComponentState is csDesigning. The OnStatusChanged event handler is generally used to update progress indicators or GUI components.

TIdIPWatch.PreviousIP
TIdIPWatch, See Also
Previous IP address detected on the local computer.

    property PreviousIP: string;

Description
PreviousIP is a String property, used internally by TIdIPWatch, to track the most recently detected IP address. PreviousIP is used in conjunction with CurrentIP to determine when a new IP address needs to be added to the IPHistoryList.

TIdIPWatch.WatchInterval
TIdIPWatch
Specifies the interval between checks for an IP address change.

    property WatchInterval: Cardinal;

Description
WatchInterval is a Cardinal property used to determine the time, in milliseconds, between firing of the timer used by TIdIPWatch. The default value for WatchInterval is IP_WATCH_INTERVAL.

When WatchInterval is changed, the Interval property for the internal TIdIPWatchThread instance is updated to contain the same value.

TIdIPWatch.Create
TIdIPWatch
Constructor for the object instance.

    constructor Create(AOwner: TComponent); override;

Description
Create is the constructor for the object instance, and performs the following operations:

- Initializes the IPHistoryList.

- Sets the IsOnline property to False.

- Sets the Enabled property to IP_WATCH_ACTIVE.

- Sets the WatchInterval to IP_WATCH_INTERVAL.

- Clears the previous IP address.

- Creates the TIdIPWatchThread used by the instance.

- Sets the HistoryEnabled property to IP_WATCH_HIST_ENABLED.

- Sets IP_WATCH_HIST_FILENAME as the default value for HistoryFilename.

- Sets IP_WATCH_HIST_MAX as the default value for MaxHistoryEntries.

TIdIPWatch.Destroy
TIdIPWatch, See Also
Frees the class instance.

    destructor Destroy; override;

Description
Destroy is the destructor for the class instance. Prior to calling the SaveHistory inherited Destroy method, TIdIPWatch performs the following operations:

- Ensures that CurrentIP is in the IPHistoryList.

- Disables the TIdIPWatch instance.

- Saves the history list in IPHistoryList to the file identified by HistoryFilename.

- Frees the IPHistoryList.

TIdIPWatch.ForceCheck
TIdIPWatch, See Also
Forces collection of the current IP address.

    function ForceCheck: Boolean;

Description
ForceCheck is a Boolean function that returns a value indicating if the local system is online. ForceCheck does not wait for the internal TIdIPWatchThread to generate an event notification by calling CheckStatus.

TIdIPWatch.LoadHistory
TIdIPWatch, See Also
Loads the history of local IP addresses from a file.

    procedure LoadHistory;

Description
LoadHistory is a procedure used to restore the IPHistoryList from the file identified in HistoryFilename. LoadHistory assigns the most recent IP address from IPHistoryList to the private variable used to maintain the PreviousIP address.
Notes
LoadHistory does not restore the history list in the IDE, or any time the component state is csDesigning.

TIdIPWatch.LocalIP
TIdIPWatch, See Also
Current IP address assigned to the local host.

    function LocalIP: string;

Description
LocalIP is a String function that returns the currently assigned IP address for the local system from the TCP/IP stack. LocalIP is used to determine the value of CurrentIP.

TIdIPWatch.SaveHistory
TIdIPWatch, See Also
Save IP addresses in IPHistoryList to a file.

    procedure SaveHistory;

Description
SaveHistory is a procedure used to write the contents of the IPHistoryList to the file identified by HistoryFilename when the HistoryEnabled property is True. SaveHistory has no effect when the ComponentState is csDesigning.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.