|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jpackages.jdun.DialUpManager
public class DialUpManager
This class provides Dial-up Networking functionality for windows operating systems.
In order for this class to function properly, jdun98.dll, jdun2k.dll, and jdunxp.dll have to be on your application's library path. If it is not, you will receive a JDUNLibraryLoadFailedException. The easiest way to have it on a correct path is to put the DLL in the same directory as your jar or class files.
If JDUN is run on a non-windows OS, a JDUNLibraryLoadFailedException will be thrown and none of the DialUpManager methods will work.
An application should only have one instance of this class. If additional instances are made, only the last instance created will receive the callback notifications about the dialing state.
Example:
try {
// specify your registration key if you have purchased a registered version
DialUpManager.setRegistrationKey("AAAA-BBBB-CCCC-DDDD-EEEE-FFFF");
// define a DialUpManager for synchronous dialing
DialUpManager dialUpManager = new DialUpManager();
// get the first entry
String entry = dialUpManager.getEntryNames()[0];
// dial this entry
int error = dialUpManager.dialEntrySynchronous(entry);
if (error != 0)
System.out.println("ERROR: " + dialUpManager.getErrorMessageForCode(error));
}
catch (LibraryLoadFailedException e) {
if (e instanceof JDUNLibraryLoadFailedException)
System.out.println("JDUN Library failed to load");
else if (e instanceof RASLibraryLoadFailedException)
System.out.println("RAS Library failed to load");
System.exit(0);
}
NOTE: Entry names are case sensitive.
NOTE: If your application terminates while a connection is being made but before it is completed, the given entry may become stuck in a connecting state. If this occurs, the entry will not function properly until the system is restarted. For this reason, it is important to not terminate your application prematurely when connecting.
Copyright (c) 2001-2007
| Constructor Summary | |
|---|---|
DialUpManager()
Use this constructor if you do not want real-time feedback of the dialing state. |
|
DialUpManager(DialingNotification dialingNotification)
Use this constructor if you want real-time feedback of the dialing state. |
|
| Method Summary | |
|---|---|
boolean |
createEntry(java.lang.String entryName)
Creates a new dial-up entry with default properties. |
boolean |
createEntry(java.lang.String entryName,
DialUpEntryProperties dialUpEntryProperties)
Creates a new dial-up entry with the specified properties. |
boolean |
deleteEntry(java.lang.String entryName)
Delete an entry. |
boolean |
dialEntryAsynchronous(java.lang.String entryName)
Dials an entry asynchronously. |
boolean |
dialEntryAsynchronous(java.lang.String entryName,
java.lang.String phoneNumber)
Dials an entry asynchronously. |
boolean |
dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password)
Dials an entry asynchronously. |
boolean |
dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials an entry asynchronously. |
boolean |
dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain,
java.lang.String phoneNumber)
Dials an entry asynchronously. |
int |
dialEntrySynchronous(java.lang.String entryName)
Dials an entry synchronously. |
int |
dialEntrySynchronous(java.lang.String entryName,
java.lang.String phoneNumber)
Dials an entry synchronously. |
int |
dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password)
Dials an entry synchronously. |
int |
dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials an entry synchronously. |
int |
dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain,
java.lang.String phoneNumber)
Dials an entry synchronously. |
java.lang.String |
dialNonEntryAsynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password)
Dials a non-entry (simple connection) asynchronously. |
java.lang.String |
dialNonEntryAsynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials a non-entry (simple connection) asynchronously. |
java.lang.String |
dialNonEntrySynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password)
Dials a non-entry (simple connection) synchronously. |
java.lang.String |
dialNonEntrySynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials a non-entry (simple connection) synchronously. |
void |
displayCreateEntryWindowAsynchronous()
Displays the create new entry window asynchronously. |
void |
displayCreateEntryWindowSynchronous()
Displays the create new entry window synchronously. |
void |
displayEditEntryWindowAsynchronous(java.lang.String entryName)
Displays the edit entry window asynchronously. |
void |
displayEditEntryWindowSynchronous(java.lang.String entryName)
Displays the edit entry window synchronously. |
java.lang.String |
getDefaultEntry()
Get the name of the default entry. |
DialUpDevice |
getDialUpDevice(java.lang.String type)
Retrieves the first dial-up device of a certain type it can find. |
DialUpDevice |
getDialUpDeviceModem()
Retrieves the first modem dial-up device it can find. |
DialUpDevice[] |
getDialUpDevices()
Retrieves all dial-up devices present on the computer. |
DialUpEntryProperties |
getDialUpEntryProperties(java.lang.String entryName)
Retrieves the dial-up properties of an entry. |
int |
getEntryDialingState(java.lang.String entryName)
Get the dialing state of a given entry. |
java.lang.String[] |
getEntryNames()
Get all entry names. |
java.lang.String |
getErrorMessageForCode(int errorCode)
Retrieve a String representation of an error code. |
java.lang.String |
getPassword(java.lang.String entryName)
Retrieve the password of a given entry. |
java.lang.String |
getPPPIPAddress(java.lang.String entryName)
Get the PPP IP address assigned to this computer from an entry connection. |
java.lang.String |
getPPPIPAddressForNonEntry(java.lang.String connectionID)
Get the PPP IP address assigned to this computer from a non-entry connection. |
java.lang.String |
getPPPIPAddressServer(java.lang.String entryName)
Get the PPP IP address of the server connected to via an entry. |
java.lang.String |
getPPPIPAddressServerForNonEntry(java.lang.String connectionID)
Get the PPP IP address of the server connected to via a non-entry connection. |
long |
getStatisticDuration(java.lang.String entryName)
Retrieve the duration of a connection for a given entry. |
long |
getStatisticReceived(java.lang.String entryName)
Retrieve the number of bytes received for a connection of a given entry. |
long |
getStatisticTransmitted(java.lang.String entryName)
Retrieve the number of bytes transmitted for a connection of a given entry. |
java.lang.String |
getUsername(java.lang.String entryName)
Retrieve the username of a given entry. |
boolean |
hangUpEntry(java.lang.String entryName)
Disconnect the connection for an entry. |
boolean |
hangUpNonEntry(java.lang.String connectionID)
Disconnect the connection for a non-entry. |
boolean |
hasEntry(java.lang.String entryName)
Determines if the entry exists. |
boolean |
isConnected()
Determines if there are any active dial-up networking entry connections. |
boolean |
isEntryConnected(java.lang.String entryName)
Determines if the entry is connected. |
boolean |
isInternetConnected()
Determines if Windows believes there is internet available. |
boolean |
isNonEntryConnected(java.lang.String connectionID)
Determines if the non-entry is connected. |
boolean |
renameEntry(java.lang.String oldEntryName,
java.lang.String newEntryName)
Rename an entry. |
boolean |
setDialUpEntryProperties(java.lang.String entryName,
DialUpEntryProperties dialUpEntryProperties)
Specifies the dial-up entry properties to use for the entry. |
static void |
setRegistrationKey(java.lang.String key)
When you purchase a registered version of JDUN, you must programmatically specify your registration key by passing it to this method. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DialUpManager()
throws LibraryLoadFailedException
Use this constructor if you do not want real-time feedback of the dialing state.
LibraryLoadFailedException - A required library failed to load.
public DialUpManager(DialingNotification dialingNotification)
throws LibraryLoadFailedException
Use this constructor if you want real-time feedback of the dialing state. DialingNotification is an interface that defines the callback method for dialing.
dialingNotification - A class implementing this interface.
LibraryLoadFailedException - A required library failed to load.| Method Detail |
|---|
public static final void setRegistrationKey(java.lang.String key)
When you purchase a registered version of JDUN, you must programmatically specify your registration key by passing it to this method.
This static method should be called before anything else is done with this API as
follows:
DialUpManager.setRegistrationKey("AAAA-BBBB-CCCC-DDDD-EEEE-FFFF");
key - JDUN Registration Keypublic java.lang.String getUsername(java.lang.String entryName)
Retrieve the username of a given entry.
entryName - The name of the entry.
public java.lang.String getPassword(java.lang.String entryName)
Retrieve the password of a given entry.
For Windows 2000 and later versions, the password returned is not the actual password. Instead, it is a handle to the saved password. When connecting with this handle as the password, the actual password is retrieved and used.
entryName - The name of the entry.
public boolean isInternetConnected()
Determines if Windows believes there is internet available.
public int getEntryDialingState(java.lang.String entryName)
Get the dialing state of a given entry.
entryName - The name of the entry.
public java.lang.String getPPPIPAddress(java.lang.String entryName)
Get the PPP IP address assigned to this computer from an entry connection.
entryName - The name of the entry.
public java.lang.String getPPPIPAddressForNonEntry(java.lang.String connectionID)
Get the PPP IP address assigned to this computer from a non-entry connection.
connectionID - The connection ID for this connection
public java.lang.String getPPPIPAddressServer(java.lang.String entryName)
Get the PPP IP address of the server connected to via an entry.
entryName - The name of the entry.
public java.lang.String getPPPIPAddressServerForNonEntry(java.lang.String connectionID)
Get the PPP IP address of the server connected to via a non-entry connection.
connectionID - The connection ID for this connection
public boolean renameEntry(java.lang.String oldEntryName,
java.lang.String newEntryName)
Rename an entry.
oldEntryName - The current entry name.newEntryName - The new entry name.
public boolean deleteEntry(java.lang.String entryName)
Delete an entry.
entryName - The name of the entry to be deleted.
public void displayCreateEntryWindowAsynchronous()
Displays the create new entry window asynchronously. Asynchronous refers to using a different thread of execution.
This method does not function in Windows Vista.
public void displayCreateEntryWindowSynchronous()
Displays the create new entry window synchronously. Synchronous refers to using the same thread of execution.
This method does not function in Windows Vista.
public void displayEditEntryWindowAsynchronous(java.lang.String entryName)
Displays the edit entry window asynchronously. Asynchronous refers to using a different thread of execution.
This method does not function in Windows Vista.
entryName - The name of the entry.public void displayEditEntryWindowSynchronous(java.lang.String entryName)
Displays the edit entry window synchronously. Synchronous refers to using the same thread of execution.
This method does not function in Windows Vista.
entryName - The name of the entry.public java.lang.String getErrorMessageForCode(int errorCode)
Retrieve a String representation of an error code.
errorCode - The error code to lookup.
public boolean isConnected()
Determines if there are any active dial-up networking entry connections.
public boolean isNonEntryConnected(java.lang.String connectionID)
Determines if the non-entry is connected.
connectionID - The connection ID returned when dialing a non-entry.
public boolean isEntryConnected(java.lang.String entryName)
Determines if the entry is connected.
entryName - The name of the entry.
public boolean hasEntry(java.lang.String entryName)
Determines if the entry exists.
entryName - The entry name.
public long getStatisticDuration(java.lang.String entryName)
Retrieve the duration of a connection for a given entry.
This method only works in Windows 2000 and XP.
entryName - The name of the entry.
public long getStatisticReceived(java.lang.String entryName)
Retrieve the number of bytes received for a connection of a given entry.
This method only works in Windows 2000 and XP.
entryName - The name of the entry.
public long getStatisticTransmitted(java.lang.String entryName)
Retrieve the number of bytes transmitted for a connection of a given entry.
This method only works in Windows 2000 and XP.
entryName - The name of the entry.
public java.lang.String getDefaultEntry()
Get the name of the default entry.
Default entry does not exist on operating systems before XP.
It is possible for the default entry name to not actually exist as an entry so it is recommended to use the hasEntry method to ensure it exists before using it.
public java.lang.String[] getEntryNames()
Get all entry names.
public DialUpDevice getDialUpDeviceModem()
Retrieves the first modem dial-up device it can find.
Each entry has a dial-up device that it uses to connect.
public DialUpDevice getDialUpDevice(java.lang.String type)
Retrieves the first dial-up device of a certain type it can find.
Types include but are not limited to "modem", "vpn", "pppoe", and "parallel".
type - The type of the device to locate.
public DialUpDevice[] getDialUpDevices()
Retrieves all dial-up devices present on the computer.
Each entry has a dial-up device that it uses to connect.
public DialUpEntryProperties getDialUpEntryProperties(java.lang.String entryName)
Retrieves the dial-up properties of an entry.
entryName - The name of the entry.
public boolean createEntry(java.lang.String entryName)
Creates a new dial-up entry with default properties.
entryName - The name of the entry.
public boolean createEntry(java.lang.String entryName,
DialUpEntryProperties dialUpEntryProperties)
Creates a new dial-up entry with the specified properties.
entryName - The name of the entry.dialUpEntryProperties - The properties to assign to the entry.
public boolean setDialUpEntryProperties(java.lang.String entryName,
DialUpEntryProperties dialUpEntryProperties)
Specifies the dial-up entry properties to use for the entry.
entryName - The name of the entry.dialUpEntryProperties - The properties to assign to the entry.
public int dialEntrySynchronous(java.lang.String entryName)
Dials an entry synchronously. Synchronous refers to using the same thread of execution.
entryName - The name of the entry to dial.
public int dialEntrySynchronous(java.lang.String entryName,
java.lang.String phoneNumber)
Dials an entry synchronously. Synchronous refers to using the same thread of execution.
entryName - The name of the entry to dial.phoneNumber - The phone number to dial.
public boolean dialEntryAsynchronous(java.lang.String entryName)
Dials an entry asynchronously. Asynchronous refers to using a different thread of execution.
If a connection is lost, be sure to call hangUpEntry for the entry.
entryName - The name of the entry to dial.
public boolean dialEntryAsynchronous(java.lang.String entryName,
java.lang.String phoneNumber)
Dials an entry asynchronously. Asynchronous refers to using a different thread of execution.
If a connection is lost, be sure to call hangUpEntry for the entry.
entryName - The name of the entry to dial.phoneNumber - The phone number to dial.
public int dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password)
Dials an entry synchronously. Synchronous refers to using the same thread of execution.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.
public boolean dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password)
Dials an entry asynchronously. Asynchronous refers to using a different thread of execution.
If a connection is lost, be sure to call hangUpEntry for the entry.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.
public int dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials an entry synchronously. Synchronous refers to using the same thread of execution.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur.
public int dialEntrySynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain,
java.lang.String phoneNumber)
Dials an entry synchronously. Synchronous refers to using the same thread of execution.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur. Use "" if no domain.phoneNumber - The phone number to dial.
public boolean dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials an entry asynchronously. Asynchronous refers to using a different thread of execution.
If a connection is lost, be sure to call hangUpEntry for the entry.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur.
public boolean dialEntryAsynchronous(java.lang.String entryName,
java.lang.String username,
java.lang.String password,
java.lang.String domain,
java.lang.String phoneNumber)
Dials an entry asynchronously. Asynchronous refers to using a different thread of execution.
If a connection is lost, be sure to call hangUpEntry for the entry.
entryName - The name of the entry to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur. Use "" if no domain.phoneNumber - The phone number to dial.
public java.lang.String dialNonEntrySynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password)
Dials a non-entry (simple connection) synchronously. Synchronous refers to using the same thread of execution.
phoneNumber - The phone number to dial.username - The username to use for authentication.password - The password to use for authentication.
public java.lang.String dialNonEntrySynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials a non-entry (simple connection) synchronously. Synchronous refers to using the same thread of execution.
phoneNumber - The phone number to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur.
public java.lang.String dialNonEntryAsynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password)
Dials a non-entry (simple connection) asynchronously. Asynchronous refers to using a different thread of execution.
phoneNumber - The phone number to dial.username - The username to use for authentication.password - The password to use for authentication.
public java.lang.String dialNonEntryAsynchronous(java.lang.String phoneNumber,
java.lang.String username,
java.lang.String password,
java.lang.String domain)
Dials a non-entry (simple connection) asynchronously. Asynchronous refers to using a different thread of execution.
phoneNumber - The phone number to dial.username - The username to use for authentication.password - The password to use for authentication.domain - The domain on which authentication is to occur.
public boolean hangUpNonEntry(java.lang.String connectionID)
Disconnect the connection for a non-entry.
In order to provide enough time to properly hang up, it is recommended to not exit your application within 3 seconds of executing this method.
connectionID - The connection ID returned when dialing a non-entry.
public boolean hangUpEntry(java.lang.String entryName)
Disconnect the connection for an entry.
In order to provide enough time to properly hang up, it is recommended to not exit your application within 3 seconds of executing this method.
entryName - The entry name to hang up.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||