📄 sipmanager.java
字号:
}
to.setTag(Integer.toString(containingDialog.hashCode()));
}
}
catch (ParseException ex)
{
fireCommunicationsError(
new CommunicationsException(
"Failed to attach a TO tag to an outgoing response"));
}
}
finally
{
console.logExit();
}
}
//================================ PROPERTIES ================================
protected void initProperties()
{
try
{
console.logEntry();
// ------------------ stack properties --------------
stackAddress = Utils.getProperty("javax.sip.IP_ADDRESS");
if (stackAddress == null)
{
stackAddress = getLocalHostAddress();
//Add the host address to the properties that will pass the stack
sipProp.setProperty("javax.sip.IP_ADDRESS", stackAddress);
}
//ensure IPv6 address compliance
if (stackAddress.indexOf(':') != stackAddress.lastIndexOf(':')
&& stackAddress.charAt(0) != '['
)
{
stackAddress = '[' + stackAddress.trim() + ']';
}
if (console.isDebugEnabled())
{
console.debug("stack address=" + stackAddress);
}
stackName = Utils.getProperty("javax.sip.STACK_NAME");
if (stackName == null)
{
stackName = "SipCommunicator@" + Integer.toString(hashCode());
//Add the stack name to the properties that will pass the stack
sipProp.setProperty("javax.sip.STACK_NAME", stackName);
}
if (console.isDebugEnabled())
{
console.debug("stack name is:" + stackName);
}
String retransmissionFilter = Utils.getProperty("javax.sip.RETRANSMISSION_FILTER");
if (retransmissionFilter == null)
{
retransmissionFilter = "true";
//Add the retransmission filter param to the properties that will pass the stack
sipProp.setProperty("javax.sip.RETRANSMISSION_FILTER", retransmissionFilter);
}
if (console.isDebugEnabled())
{
console.debug("retransmission filter is:" + stackName);
}
//------------ application properties --------------
currentlyUsedURI = Utils.getProperty(
"net.java.sip.communicator.sip.PUBLIC_ADDRESS");
if (currentlyUsedURI == null)
{
currentlyUsedURI = Utils.getProperty("user.name") + "@" +
stackAddress;
}
if (!currentlyUsedURI.trim().toLowerCase().startsWith("sip:"))
{
currentlyUsedURI = "sip:" + currentlyUsedURI.trim();
}
if (console.isDebugEnabled())
{
console.debug("public address=" + currentlyUsedURI);
}
registrarAddress = Utils.getProperty(
"net.java.sip.communicator.sip.REGISTRAR_ADDRESS");
if (console.isDebugEnabled())
{
console.debug("registrar address=" + registrarAddress);
}
try
{
registrarPort = Integer.parseInt(Utils.getProperty(
"net.java.sip.communicator.sip.REGISTRAR_PORT"));
}
catch (NumberFormatException ex)
{
registrarPort = 5060;
}
if (console.isDebugEnabled())
{
console.debug("registrar port=" + registrarPort);
}
registrarTransport = Utils.getProperty(
"net.java.sip.communicator.sip.REGISTRAR_TRANSPORT");
if (registrarTransport == null)
{
registrarTransport = DEFAULT_TRANSPORT;
}
try
{
registrationsExpiration = Integer.parseInt(Utils.getProperty(
"net.java.sip.communicator.sip.REGISTRATIONS_EXPIRATION"));
}
catch (NumberFormatException ex)
{
registrationsExpiration = 3600;
}
if (console.isDebugEnabled())
{
console.debug("registrar transport=" + registrarTransport);
// Added by mranga
}
String serverLog = Utils.getProperty
("gov.nist.javax.sip.SERVER_LOG");
if (serverLog != null)
{
sipProp.setProperty
("gov.nist.javax.sip.TRACE_LEVEL", "16");
}
if (console.isDebugEnabled())
{
console.debug("server log=" + serverLog);
}
sipStackPath = Utils.getProperty(
"net.java.sip.communicator.sip.STACK_PATH");
if (sipStackPath == null)
{
sipStackPath = "gov.nist";
}
if (console.isDebugEnabled())
{
console.debug("stack path=" + sipStackPath);
}
String routerPath = Utils.getProperty("javax.sip.ROUTER_PATH");
if (routerPath == null)
{
sipProp.setProperty("javax.sip.ROUTER_PATH",
"net.sourceforge.gjtapi.raw.sipprovider.sip.SipCommRouter");
}
if (console.isDebugEnabled())
{
console.debug("router path=" + routerPath);
}
transport = sipProp.getProperty("net.java.sip.communicator.sip.TRANSPORT");
if (transport == null)
{
transport = DEFAULT_TRANSPORT;
}
if (console.isDebugEnabled())
{
console.debug("transport=" + transport);
}
String localPortStr = Utils.getProperty(
"net.java.sip.communicator.sip.PREFERRED_LOCAL_PORT");
try
{
localPort = Integer.parseInt(localPortStr);
}
catch (NumberFormatException exc)
{
localPort = 5060;
}
if (console.isDebugEnabled())
{
console.debug("preferred local port=" + localPort);
}
displayName = Utils.getProperty(
"net.java.sip.communicator.sip.DISPLAY_NAME");
if (console.isDebugEnabled())
{
console.debug("display name=" + displayName);
}
}
finally
{
console.logExit();
}
}
//============================ SECURITY ================================
/**
* Sets the SecurityAuthority instance that should be consulted later on for
* user credentials.
*
* @param authority the SecurityAuthority instance that should be consulted
* later on for user credentials.
*/
public void setSecurityAuthority(SecurityAuthority authority)
{
//keep a copty
this.securityAuthority = authority;
sipSecurityManager.setSecurityAuthority(authority);
}
/**
* Adds the specified credentials to the security manager's credentials cache
* so that they get tried next time they're needed.
*
* @param realm the realm these credentials should apply for.
* @param credentials a set of credentials (username and pass)
*/
public void cacheCredentials(String realm, UserCredentials credentials )
{
sipSecurityManager.cacheCredentials(realm, credentials);
}
//============================ EVENT DISPATHING ================================
/**
* Adds a CommunicationsListener to SipManager.
* @param listener The CommunicationsListener to be added.
*/
public void addCommunicationsListener(CommunicationsListener listener)
{
try
{
console.logEntry();
listeners.add(listener);
}
finally
{
console.logExit();
}
}
//------------ call received dispatch
public void fireCallReceived(Call call)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("received call" + call);
}
CallEvent evt = new CallEvent(call);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).callReceived(evt);
}
}
finally
{
console.logExit();
}
} //call received
//------------ call received dispatch
void fireMessageReceived(Request message)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("received instant message=" + message);
}
MessageEvent evt = new MessageEvent(message);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).messageReceived(
evt);
}
}
finally
{
console.logExit();
}
} //call received
//------------ registerred
public void fireRegistered(String address)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("registered with address = " + address);
}
RegistrationEvent evt = new RegistrationEvent(address);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).registered(evt);
}
}
finally
{
console.logExit();
}
} //call received
//------------ registering
public void fireRegistering(String address)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("registering with address=" + address);
}
RegistrationEvent evt = new RegistrationEvent(address);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).registering(evt);
}
}
finally
{
console.logExit();
}
} //call received
//------------ unregistered
public void fireUnregistered(String address)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("unregistered, address is " + address);
}
RegistrationEvent evt = new RegistrationEvent(address);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).unregistered(evt);
}
}
finally
{
console.logExit();
}
} //call received
public void fireUnregistering(String address)
{
try
{
console.logEntry();
if (console.isDebugEnabled())
{
console.debug("unregistering, address is " + address);
}
RegistrationEvent evt = new RegistrationEvent(address);
for (int i = listeners.size() - 1; i >= 0; i--)
{
( (CommunicationsListener) listeners.get(i)).unregistering(evt);
}
}
finally
{
console.logExit();
}
} //call received
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -