aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/CallManager.java8
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java7
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java27
-rw-r--r--src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java42
-rw-r--r--src/net/java/sip/communicator/service/protocol/Call.java38
-rw-r--r--src/net/java/sip/communicator/service/protocol/event/CallChangeEvent.java34
-rw-r--r--src/net/java/sip/communicator/service/protocol/event/CallPeerChangeEvent.java44
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java12
8 files changed, 198 insertions, 14 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
index ebe3e8d..6144e00 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
@@ -94,7 +94,13 @@ public class CallManager
&& evt.getOldValue()
.equals(CallState.CALL_INITIALIZATION))
{
- addMissedCall(new MissedCall(peerName, callDate));
+ // if call was answered elsewhere, don't add it
+ // to missed calls
+ if(evt.getCause() == null
+ || (evt.getCause().getReasonCode() !=
+ CallPeerChangeEvent.NORMAL_CALL_CLEARING))
+ addMissedCall(new MissedCall(peerName, callDate));
+
evt.getSourceCall().removeCallChangeListener(this);
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
index 96a4659..84098b8 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
@@ -16,6 +16,7 @@ import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.event.*;
+import net.java.sip.communicator.impl.gui.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.main.chat.menus.*;
import net.java.sip.communicator.impl.gui.main.chat.toolBars.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
@@ -1124,7 +1125,11 @@ public class ChatWindow
// from the TooltipManager.
this.setToolTipText("");
- if (!chatSession.isDescriptorPersistent())
+ // if its multichat don't show addContactButton, cause
+ // it sa mutlichat room which
+ // cannot be saved with add contact dialog
+ if (!chatSession.isDescriptorPersistent()
+ && !(chatSession instanceof ConferenceChatSession))
this.add(addContactButton, 0);
else
this.remove(addContactButton);
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
index 74c13f8..6349da5 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
@@ -432,7 +432,18 @@ public class CallPeerSipImpl
}
else
{
- setState(CallPeerState.DISCONNECTED);
+ ReasonHeader reasonHeader =
+ (ReasonHeader)byeRequest.getHeader(ReasonHeader.NAME);
+
+ if(reasonHeader != null)
+ {
+ setState(
+ CallPeerState.DISCONNECTED,
+ reasonHeader.getText(),
+ reasonHeader.getCause());
+ }
+ else
+ setState(CallPeerState.DISCONNECTED);
}
}
@@ -498,8 +509,18 @@ public class CallPeerSipImpl
+ "an INVITE request.", ex);
}
- // change status
- setState(CallPeerState.DISCONNECTED);
+ ReasonHeader reasonHeader =
+ (ReasonHeader)cancel.getHeader(ReasonHeader.NAME);
+
+ if(reasonHeader != null)
+ {
+ setState(
+ CallPeerState.DISCONNECTED,
+ reasonHeader.getText(),
+ reasonHeader.getCause());
+ }
+ else
+ setState(CallPeerState.DISCONNECTED);
}
/**
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
index 115df8a..cd7d1fe 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
@@ -199,8 +199,30 @@ public abstract class AbstractCallPeer<T extends Call,
Object newValue,
String reason)
{
+ this.fireCallPeerChangeEvent(eventType, oldValue, newValue, reason, -1);
+ }
+
+ /**
+ * Constructs a <tt>CallPeerChangeEvent</tt> using this call peer as source,
+ * setting it to be of type <tt>eventType</tt> and the corresponding
+ * <tt>oldValue</tt> and <tt>newValue</tt>.
+ *
+ * @param eventType the type of the event to create and dispatch.
+ * @param oldValue the value of the source property before it changed.
+ * @param newValue the current value of the source property.
+ * @param reason a string that could be set to contain a human readable
+ * explanation for the transition (particularly handy when moving into a
+ * FAILED state).
+ * @param reasonCode the reason code for the reason of this event.
+ */
+ protected void fireCallPeerChangeEvent(String eventType,
+ Object oldValue,
+ Object newValue,
+ String reason,
+ int reasonCode)
+ {
CallPeerChangeEvent evt = new CallPeerChangeEvent(
- this, eventType, oldValue, newValue, reason);
+ this, eventType, oldValue, newValue, reason, reasonCode);
if (logger.isDebugEnabled())
logger.debug("Dispatching a CallPeerChangeEvent event to "
@@ -400,6 +422,21 @@ public abstract class AbstractCallPeer<T extends Call,
*/
public void setState(CallPeerState newState, String reason)
{
+ this.setState(newState, reason, -1);
+ }
+
+ /**
+ * Causes this CallPeer to enter the specified state. The method also sets
+ * the currentStateStartDate field and fires a CallPeerChangeEvent.
+ *
+ * @param newState the state this call peer should enter.
+ * @param reason a string that could be set to contain a human readable
+ * explanation for the transition (particularly handy when moving into a
+ * FAILED state).
+ * @param reasonCode the code for the reason of the state change.
+ */
+ public void setState(CallPeerState newState, String reason, int reasonCode)
+ {
CallPeerState oldState = getState();
if(oldState == newState)
@@ -417,7 +454,8 @@ public abstract class AbstractCallPeer<T extends Call,
CallPeerChangeEvent.CALL_PEER_STATE_CHANGE,
oldState,
newState,
- reason);
+ reason,
+ reasonCode);
}
/**
diff --git a/src/net/java/sip/communicator/service/protocol/Call.java b/src/net/java/sip/communicator/service/protocol/Call.java
index cac06f3..e4b39a9 100644
--- a/src/net/java/sip/communicator/service/protocol/Call.java
+++ b/src/net/java/sip/communicator/service/protocol/Call.java
@@ -227,8 +227,29 @@ public abstract class Call
Object oldValue,
Object newValue)
{
+ this.fireCallChangeEvent(type, oldValue, newValue, null);
+ }
+
+ /**
+ * Creates a <tt>CallChangeEvent</tt> with this class as
+ * <tt>sourceCall</tt>, and the specified <tt>eventID</tt> and old and new
+ * values and dispatches it on all currently registered listeners.
+ *
+ * @param type the type of the event to create (see CallChangeEvent member
+ * ints)
+ * @param oldValue the value of the call property that changed, before the
+ * event had occurred.
+ * @param newValue the value of the call property that changed, after the
+ * event has occurred.
+ * @param cause the event that is the initial cause of the current one.
+ */
+ protected void fireCallChangeEvent( String type,
+ Object oldValue,
+ Object newValue,
+ CallPeerChangeEvent cause)
+ {
CallChangeEvent ccEvent = new CallChangeEvent(
- this, type, oldValue, newValue);
+ this, type, oldValue, newValue, cause);
if (logger.isDebugEnabled())
logger.debug("Dispatching a CallChange event to "
@@ -271,6 +292,19 @@ public abstract class Call
*/
protected void setCallState(CallState newState)
{
+ this.setCallState(newState, null);
+ }
+
+ /**
+ * Sets the state of this call and fires a call change event notifying
+ * registered listeners for the change.
+ *
+ * @param newState a reference to the <tt>CallState</tt> instance that the
+ * call is to enter.
+ * @param cause the event that is the cause of the current change of state.
+ */
+ protected void setCallState(CallState newState, CallPeerChangeEvent cause)
+ {
CallState oldState = getCallState();
if (oldState != newState)
@@ -278,7 +312,7 @@ public abstract class Call
this.callState = newState;
fireCallChangeEvent(
- CallChangeEvent.CALL_STATE_CHANGE, oldState, newState);
+ CallChangeEvent.CALL_STATE_CHANGE, oldState, newState, cause);
}
}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallChangeEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallChangeEvent.java
index 37ce35b..d43e17c 100644
--- a/src/net/java/sip/communicator/service/protocol/event/CallChangeEvent.java
+++ b/src/net/java/sip/communicator/service/protocol/event/CallChangeEvent.java
@@ -35,6 +35,12 @@ public class CallChangeEvent
public static final String CALL_FOCUS_CHANGE = "CallFocusState";
/**
+ * The event which was the cause for current event, like last peer
+ * removed from call will hangup current call, if any, otherwise is null.
+ */
+ private final CallPeerChangeEvent cause;
+
+ /**
* Creates a CallChangeEvent with the specified source, type, oldValue and
* newValue.
* @param source the peer that produced the event.
@@ -47,7 +53,26 @@ public class CallChangeEvent
public CallChangeEvent(Call source, String type,
Object oldValue, Object newValue)
{
+ this(source, type, oldValue, newValue, null);
+ }
+
+ /**
+ * Creates a CallChangeEvent with the specified source, type, oldValue and
+ * newValue.
+ * @param source the peer that produced the event.
+ * @param type the type of the event (the name of the property that has
+ * changed).
+ * @param oldValue the value of the changed property before the event
+ * occurred
+ * @param newValue current value of the changed property.
+ * @param cause the event that causes this event, if any(null otherwise).
+ */
+ public CallChangeEvent(Call source, String type,
+ Object oldValue, Object newValue,
+ CallPeerChangeEvent cause)
+ {
super(source, type, oldValue, newValue);
+ this.cause = cause;
}
/**
@@ -82,5 +107,14 @@ public class CallChangeEvent
{
return (Call)getSource();
}
+
+ /**
+ * The event which was the cause for current event, like last peer
+ * removed from call will hangup current call, if any, otherwise is null.
+ */
+ public CallPeerChangeEvent getCause()
+ {
+ return cause;
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/event/CallPeerChangeEvent.java b/src/net/java/sip/communicator/service/protocol/event/CallPeerChangeEvent.java
index a847151..29f7c0d 100644
--- a/src/net/java/sip/communicator/service/protocol/event/CallPeerChangeEvent.java
+++ b/src/net/java/sip/communicator/service/protocol/event/CallPeerChangeEvent.java
@@ -75,6 +75,16 @@ public class CallPeerChangeEvent
private final String reason;
/**
+ * Reason code, if any, for the peer state change.
+ */
+ private final int reasonCode;
+
+ /**
+ * Code indicating normal call clear.
+ */
+ public static final int NORMAL_CALL_CLEARING = 200;
+
+ /**
* Creates a CallPeerChangeEvent with the specified source, type,
* oldValue and newValue.
* @param source the peer that produced the event.
@@ -106,8 +116,31 @@ public class CallPeerChangeEvent
Object newValue,
String reason)
{
+ this(source, type, oldValue, newValue, reason, -1);
+ }
+
+ /**
+ * Creates a CallPeerChangeEvent with the specified source, type,
+ * oldValue and newValue.
+ * @param source the peer that produced the event.
+ * @param type the type of the event (i.e. address change, state change etc.).
+ * @param oldValue the value of the changed property before the event occurred
+ * @param newValue current value of the changed property.
+ * @param reason a string containing a human readable explanation for the
+ * reason that triggered this event (may be null).
+ * @param reasonCode a code for the reason that triggered this
+ * event (may be -1 as not specified).
+ */
+ public CallPeerChangeEvent(CallPeer source,
+ String type,
+ Object oldValue,
+ Object newValue,
+ String reason,
+ int reasonCode)
+ {
super(source, type, oldValue, newValue);
this.reason = reason;
+ this.reasonCode = reasonCode;
}
/**
@@ -159,6 +192,15 @@ public class CallPeerChangeEvent
return reason;
}
-
+ /**
+ * Returns a reason code for the event (may be -1).
+ *
+ * @return a reason code for the event or -1 if no reason code
+ * was set.
+ */
+ public int getReasonCode()
+ {
+ return reasonCode;
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
index db7f24a..62d862d 100644
--- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
+++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
@@ -143,10 +143,14 @@ public abstract class MediaAwareCall<
* call. The method has no effect if there was no such peer in the
* call.
*
- * @param callPeer the <tt>CallPeer</tt> leaving the call;
+ * @param evt the event containing the <tt>CallPeer</tt> leaving the call;
+ * also we can obtain the reason for the <tt>CallPeerChangeEvent</tt> if
+ * any. Use the event as cause for the call state change event..
*/
- private void removeCallPeer(T callPeer)
+ private void removeCallPeer(CallPeerChangeEvent evt)
{
+ T callPeer = (T)evt.getSourceCallPeer();
+
if (!getCallPeersVector().contains(callPeer))
return;
@@ -175,7 +179,7 @@ public abstract class MediaAwareCall<
}
if (getCallPeersVector().isEmpty())
- setCallState(CallState.CALL_ENDED);
+ setCallState(CallState.CALL_ENDED, evt);
}
/**
@@ -237,7 +241,7 @@ public abstract class MediaAwareCall<
if (CallPeerState.DISCONNECTED.equals(newState)
|| CallPeerState.FAILED.equals(newState))
{
- removeCallPeer((T) evt.getSourceCallPeer());
+ removeCallPeer(evt);
}
else if (CallPeerState.CONNECTED.equals(newState)
|| CallPeerState.CONNECTING_WITH_EARLY_MEDIA.equals(newState))