aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2011-01-18 15:54:53 +0000
committerDamian Minkov <damencho@jitsi.org>2011-01-18 15:54:53 +0000
commit4ebbc2c91a03c6a0f402d9031faab5e724b8d630 (patch)
tree311811d4df1788d27a95253996cb91895801ee4f
parente6f364e1fab6f245dd9e14ed2579624be803e6b2 (diff)
downloadjitsi-4ebbc2c91a03c6a0f402d9031faab5e724b8d630.zip
jitsi-4ebbc2c91a03c6a0f402d9031faab5e724b8d630.tar.gz
jitsi-4ebbc2c91a03c6a0f402d9031faab5e724b8d630.tar.bz2
Ask user for REFERS with unknown calls and decline them or ignore if not specified.
Update installers logging properties.
-rw-r--r--resources/install/logging.properties22
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java101
-rw-r--r--src/net/java/sip/communicator/service/protocol/OperationSetAdvancedTelephony.java8
-rw-r--r--src/net/java/sip/communicator/service/protocol/TransferAuthority.java26
4 files changed, 133 insertions, 24 deletions
diff --git a/resources/install/logging.properties b/resources/install/logging.properties
index 68577f5..d8aad91 100644
--- a/resources/install/logging.properties
+++ b/resources/install/logging.properties
@@ -24,10 +24,10 @@ handlers= net.java.sip.communicator.util.FileHandler, java.util.logging.ConsoleH
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
-# can be overriden by a facility specific level
+# can be overridden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
-.level= FINEST
+.level= INFO
############################################################
# Handler specific properties.
@@ -51,24 +51,6 @@ java.util.logging.ConsoleHandler.formatter = net.java.sip.communicator.util.ScLo
# Provides extra control for each logger.
############################################################
-# We don't want trace logs from joscar and joustsim
-net.kano.level = INFO
-
-# We don't want trace logs from java-jml
-net.sf.cindy.impl.level = INFO
-
-# But we want everything coming from the sip-comm
-net.java.sip.communicator.impl.level = INFO
-net.java.sip.communicator.impl.contactlist.level = FINEST
-net.java.sip.communicator.slick.level = FINEST
-net.java.sip.communicator.impl.level = FINEST
-net.java.sip.communicator.service.level = FINEST
-net.java.sip.communicator.util.level = FINEST
-net.java.sip.communicator.service.configuration.level = FINEST
-net.java.sip.communicator.impl.configuration.level = FINEST
-net.java.sip.communicator.impl.history.level = INFO
-net.java.sip.communicator.impl.gui.level = INFO
-
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
com.xyz.foo.level = SEVERE
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java
index a9b190e..b7bea3d 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java
@@ -63,6 +63,12 @@ public class OperationSetBasicTelephonySipImpl
new ActiveCallsRepositorySipImpl(this);
/**
+ * Transfer authority interacts with user to inform for incoming
+ * REFERS for unknown calls.
+ */
+ private TransferAuthority transferAuthority = null;
+
+ /**
* Creates a new instance and adds itself as an <tt>INVITE</tt> method
* handler in the creating protocolProvider.
*
@@ -1051,8 +1057,88 @@ public class OperationSetBasicTelephonySipImpl
return;
}
- //Send Accepted
final Dialog dialog = serverTransaction.getDialog();
+
+ CallPeerSipImpl callPeer = activeCallsRepository.findCallPeer(dialog);
+
+ if(callPeer == null)
+ {
+ // if we are missing transfer authority to inform user, just
+ // drop thi request cause possible attempt to compromise us.
+ if(transferAuthority == null)
+ {
+ // ignore request and terminate transaction
+ logger.warn("Ignoring REFER request without call for request:"
+ + referRequest);
+ try
+ {
+ serverTransaction.terminate();
+ }
+ catch (Throwable e)
+ {
+ logger.warn("Failed to properly terminate transaction for "
+ +"a rogue request. Well ... so be it "
+ + "Request:" + referRequest);
+ }
+
+ return;
+ }
+
+ FromHeader fromHeader =
+ (FromHeader)referRequest.getHeader(FromHeader.NAME);
+
+ OperationSetPresenceSipImpl opSetPersPresence =
+ (OperationSetPresenceSipImpl) protocolProvider
+ .getOperationSet(OperationSetPersistentPresence.class);
+
+ Contact from = opSetPersPresence.resolveContactID(
+ fromHeader.getAddress().getURI().toString());
+
+ if (from == null)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("received a message from an unknown contact: "
+ + fromHeader.getAddress().getURI().toString());
+ //create the volatile contact
+ from = opSetPersPresence.createVolatileContact(
+ fromHeader.getAddress().getURI().toString());
+ }
+
+ // found no call we must authorise this with user
+ // if user don't want it, decline it.
+ if(!transferAuthority.processTransfer(
+ from, referToAddress.getURI().toString()))
+ {
+ // send decline
+ Response declineResponse;
+ try
+ {
+ declineResponse = protocolProvider.getMessageFactory()
+ .createResponse(
+ Response.DECLINE,
+ referRequest);
+ }
+ catch (ParseException e)
+ {
+ logger.error("Error while creating 603 response", e);
+ return;
+ }
+
+ try
+ {
+ serverTransaction.sendResponse(declineResponse);
+ }
+ catch (Exception e)
+ {
+ logger.error("Error while sending the response 603", e);
+ return;
+ }
+
+ return;
+ }
+ }
+
+ //Send Accepted
Response accepted = null;
try
{
@@ -1137,9 +1223,6 @@ public class OperationSetBasicTelephonySipImpl
// Before creating the outgoing call to the refer address we change
// the call state of the refer peer to referred.
- CallPeerSipImpl callPeer = activeCallsRepository.findCallPeer(
- serverTransaction.getDialog());
-
if (callPeer != null)
callPeer.setState(CallPeerState.REFERRED);
@@ -1831,4 +1914,14 @@ public class OperationSetBasicTelephonySipImpl
return false;
}
+
+ /**
+ * Transfer authority used for interacting with user for unknown calls
+ * and the requests for transfer.
+ * @param authority transfer authority.
+ */
+ public void setTransferAuthority(TransferAuthority authority)
+ {
+ this.transferAuthority = authority;
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetAdvancedTelephony.java b/src/net/java/sip/communicator/service/protocol/OperationSetAdvancedTelephony.java
index 6ef5d6d..753256e 100644
--- a/src/net/java/sip/communicator/service/protocol/OperationSetAdvancedTelephony.java
+++ b/src/net/java/sip/communicator/service/protocol/OperationSetAdvancedTelephony.java
@@ -53,4 +53,12 @@ public interface OperationSetAdvancedTelephony<T extends ProtocolProviderService
*/
void transfer(CallPeer peer, String target)
throws OperationFailedException;
+
+ /**
+ * Transfer authority used for interacting with user for unknown
+ * call transfer requests.
+ * @param authority transfer authority asks user for accepting a particular
+ * transfer request.
+ */
+ public void setTransferAuthority(TransferAuthority authority);
}
diff --git a/src/net/java/sip/communicator/service/protocol/TransferAuthority.java b/src/net/java/sip/communicator/service/protocol/TransferAuthority.java
new file mode 100644
index 0000000..7d75029
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/TransferAuthority.java
@@ -0,0 +1,26 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.protocol;
+
+/**
+ * Interacts with user for received transfer request for unknown calls.
+ *
+ * @author Damian Minkov
+ */
+public interface TransferAuthority
+{
+ /**
+ * Checks with user for unknown transfer. Returns <tt>true</tt> if user
+ * accepts and we must process the transfer, <tt>false</tt> otherwise.
+ *
+ * @param fromContact the contact initiating the transfer.
+ * @param transferTo the address we will be transferred to.
+ * @return <tt>true</tt> if transfer is allowed to process, <tt>false</tt>
+ * otherwise.
+ */
+ public boolean processTransfer(Contact fromContact, String transferTo);
+}