aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2010-12-21 16:40:13 +0000
committerSebastien Vincent <seb@jitsi.org>2010-12-21 16:40:13 +0000
commit568c50fd50660a4cd71e292a5623bccb5f99b74e (patch)
treea7ea61b7a1094ac30ead7f059ccfaed0d4afe143 /src/net
parent3e20c8c1ee64a16394b1e67881756b25e8838730 (diff)
downloadjitsi-568c50fd50660a4cd71e292a5623bccb5f99b74e.zip
jitsi-568c50fd50660a4cd71e292a5623bccb5f99b74e.tar.gz
jitsi-568c50fd50660a4cd71e292a5623bccb5f99b74e.tar.bz2
When we perform an XMPP/Jingle attended tranfer, the callee have to auto-answer when it receives a session-initiate with a transfer element (if ithe transfer information correspond to us).
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java10
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java97
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java60
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java40
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java27
5 files changed, 156 insertions, 78 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java
index 0d0512a..7c92118 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java
@@ -716,9 +716,13 @@ public class CallDialog
});
}
- public void conferenceMemberAdded(CallPeerConferenceEvent conferenceEvent) {}
+ public void conferenceMemberAdded(CallPeerConferenceEvent conferenceEvent)
+ {
+ }
- public void conferenceMemberRemoved(CallPeerConferenceEvent conferenceEvent) {}
+ public void conferenceMemberRemoved(CallPeerConferenceEvent conferenceEvent)
+ {
+ }
/**
* Checks if the contained call is a conference call.
@@ -1087,7 +1091,7 @@ public class CallDialog
/**
* Checks whether recording is currently enabled or not, state retrieved
* from call record button state.
- * @return
+ * @return <tt>true</tt> if the recording is started
*/
public boolean isRecordingStarted()
{
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java
index 964e580..a73210f 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallJabberImpl.java
@@ -90,6 +90,9 @@ public class CallJabberImpl
public CallPeerJabberImpl processSessionInitiate(JingleIQ jingleIQ)
{
String remoteParty = jingleIQ.getInitiator();
+ boolean autoAnswer = false;
+ CallPeerJabberImpl attendant = null;
+ OperationSetBasicTelephonyJabberImpl basicTelephony = null;
//according to the Jingle spec initiator may be null.
if (remoteParty == null)
@@ -97,16 +100,106 @@ public class CallJabberImpl
CallPeerJabberImpl callPeer = new CallPeerJabberImpl(remoteParty, this);
+ addCallPeer(callPeer);
+
+ /*
+ * We've already sent ack to the specified session-initiate so if it has
+ * been sent as part of an attended transfer, we have to hang up on the
+ * attendant.
+ */
+ try
+ {
+ TransferPacketExtension transfer
+ = (TransferPacketExtension)
+ jingleIQ.getExtension(
+ TransferPacketExtension.ELEMENT_NAME,
+ TransferPacketExtension.NAMESPACE);
+
+ if (transfer != null)
+ {
+ String sid = transfer.getSID();
+
+ if (sid != null)
+ {
+ ProtocolProviderServiceJabberImpl protocolProvider
+ = getProtocolProvider();
+ basicTelephony
+ = (OperationSetBasicTelephonyJabberImpl)
+ protocolProvider
+ .getOperationSet(
+ OperationSetBasicTelephony.class);
+ CallJabberImpl attendantCall
+ = basicTelephony
+ .getActiveCallsRepository()
+ .findJingleSID(sid);
+
+ if (attendantCall != null)
+ {
+ attendant
+ = attendantCall.getPeer(sid);
+
+ if ((attendant != null)
+ && basicTelephony
+ .getFullCalleeURI(attendant.getAddress())
+ .equals(transfer.getFrom())
+ && protocolProvider.getOurJID().equals(
+ transfer.getTo()))
+ {
+ //basicTelephony.hangupCallPeer(attendant);
+ autoAnswer = true;
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ logger.error(
+ "Failed to hang up on attendant"
+ + " as part of session transfer",
+ t);
+
+ if (t instanceof ThreadDeath)
+ throw (ThreadDeath) t;
+ }
+
//before notifying about this call, make sure that it looks alright
callPeer.processSessionInitiate(jingleIQ);
if( callPeer.getState() == CallPeerState.FAILED)
return null;
- addCallPeer(callPeer);
-
callPeer.setState( CallPeerState.INCOMING_CALL );
+ // in case of attended transfer, auto answer the call
+ if(autoAnswer)
+ {
+ /* answer directly */
+ try
+ {
+ callPeer.answer();
+ }
+ catch(Exception e)
+ {
+ logger.info("Exception occurred while answer transferred call",
+ e);
+ callPeer = null;
+ }
+
+ // hang up now
+ try
+ {
+ basicTelephony.hangupCallPeer(attendant);
+ }
+ catch(OperationFailedException e)
+ {
+ logger.error("Failed to hang up on attendant as part of " +
+ "session transfer", e);
+ }
+
+ return callPeer;
+ }
+
// if this was the first peer we added in this call then the call is
// new and we also need to notify everyone of its creation.
if(this.getCallPeerCount() == 1)
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java
index b67c341..3ab6c8c 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java
@@ -148,66 +148,6 @@ public class CallPeerJabberImpl
*/
protected synchronized void processSessionInitiate(JingleIQ sessionInitIQ)
{
- /*
- * We've already sent ack to the specified session-initiate so if it has
- * been sent as part of an attended transfer, we have to hang up on the
- * attendant.
- */
- try
- {
- TransferPacketExtension transfer
- = (TransferPacketExtension)
- sessionInitIQ.getExtension(
- TransferPacketExtension.ELEMENT_NAME,
- TransferPacketExtension.NAMESPACE);
-
- if (transfer != null)
- {
- String sid = transfer.getSID();
-
- if (sid != null)
- {
- ProtocolProviderServiceJabberImpl protocolProvider
- = getProtocolProvider();
- OperationSetBasicTelephonyJabberImpl basicTelephony
- = (OperationSetBasicTelephonyJabberImpl)
- protocolProvider
- .getOperationSet(
- OperationSetBasicTelephony.class);
- CallJabberImpl attendantCall
- = basicTelephony
- .getActiveCallsRepository()
- .findJingleSID(sid);
-
- if (attendantCall != null)
- {
- CallPeerJabberImpl attendant
- = attendantCall.getPeer(sid);
-
- if ((attendant != null)
- && basicTelephony
- .getFullCalleeURI(attendant.getAddress())
- .equals(transfer.getFrom())
- && protocolProvider.getOurJID().equals(
- transfer.getTo()))
- {
- basicTelephony.hangupCallPeer(attendant);
- }
- }
- }
- }
- }
- catch (Throwable t)
- {
- logger.error(
- "Failed to hang up on attendant"
- + " as part of session transfer",
- t);
-
- if (t instanceof ThreadDeath)
- throw (ThreadDeath) t;
- }
-
// Do initiate the session.
this.sessionInitIQ = sessionInitIQ;
this.isInitiator = true;
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
index ce2660c..18fbd2d 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java
@@ -629,7 +629,45 @@ public class OperationSetBasicTelephonyJabberImpl
if(action == JingleAction.SESSION_INITIATE)
{
- CallJabberImpl call = new CallJabberImpl(this);
+ CallJabberImpl call = null;
+
+ TransferPacketExtension transfer
+ = (TransferPacketExtension)
+ jingleIQ.getExtension(
+ TransferPacketExtension.ELEMENT_NAME,
+ TransferPacketExtension.NAMESPACE);
+
+ if (transfer != null)
+ {
+ String sid = transfer.getSID();
+
+ if (sid != null)
+ {
+ CallJabberImpl attendantCall
+ = getActiveCallsRepository().findJingleSID(sid);
+
+ if (attendantCall != null)
+ {
+ CallPeerJabberImpl attendant
+ = attendantCall.getPeer(sid);
+
+ if ((attendant != null)
+ && getFullCalleeURI(attendant.getAddress())
+ .equals(transfer.getFrom())
+ && protocolProvider.getOurJID().equals(
+ transfer.getTo()))
+ {
+ // OK transfer correspond to us
+ call = attendantCall;
+ }
+ }
+ }
+ }
+
+ if(call == null)
+ {
+ call = new CallJabberImpl(this);
+ }
call.processSessionInitiate(jingleIQ);
return;
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
index 74f3d8f..203680d 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java
@@ -85,7 +85,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Sends a file transfer request to the given <tt>toContact</tt>.
* @return the transfer object
- *
+ *
* @param toContact the contact that should receive the file
* @param file file to send
*/
@@ -150,9 +150,9 @@ public class OperationSetFileTransferJabberImpl
* Sends a file transfer request to the given <tt>toContact</tt> by
* specifying the local and remote file path and the <tt>fromContact</tt>,
* sending the file.
- *
+ *
* @return the transfer object
- *
+ *
* @param toContact the contact that should receive the file
* @param fromContact the contact sending the file
* @param remotePath the remote file path
@@ -172,7 +172,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Adds the given <tt>FileTransferListener</tt> that would listen for
* file transfer requests and created file transfers.
- *
+ *
* @param listener the <tt>FileTransferListener</tt> to add
*/
public void addFileTransferListener(
@@ -190,7 +190,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Removes the given <tt>FileTransferListener</tt> that listens for
* file transfer requests and created file transfers.
- *
+ *
* @param listener the <tt>FileTransferListener</tt> to remove
*/
public void removeFileTransferListener(
@@ -318,14 +318,14 @@ public class OperationSetFileTransferJabberImpl
}
}
- /**
+ /**
* Listener for Jabber incoming file transfer requests.
*/
private class FileTransferRequestListener implements PacketListener
{
/**
* Listens for file transfer packets.
- * @param packet
+ * @param packet packet to be processed
*/
public void processPacket(Packet packet)
{
@@ -395,7 +395,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Delivers the specified event to all registered file transfer listeners.
- *
+ *
* @param event the <tt>EventObject</tt> that we'd like delivered to all
* registered file transfer listeners.
*/
@@ -441,7 +441,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Delivers the file transfer to all registered listeners.
- *
+ *
* @param event the <tt>FileTransferEvent</tt> that we'd like delivered to
* all registered file transfer listeners.
*/
@@ -483,7 +483,7 @@ public class OperationSetFileTransferJabberImpl
this.fileTransfer = transfer;
this.initialFileSize = initialFileSize;
}
-
+
public FileTransferProgressThread(
org.jivesoftware.smackx.filetransfer.FileTransfer jabberTransfer,
AbstractFileTransfer transfer)
@@ -492,6 +492,9 @@ public class OperationSetFileTransferJabberImpl
this.fileTransfer = transfer;
}
+ /**
+ * Thread entry point.
+ */
public void run()
{
int status;
@@ -525,7 +528,7 @@ public class OperationSetFileTransferJabberImpl
// so it won't go through intermediate state - inProgress
// make sure this won't happen
if(status == FileTransferStatusChangeEvent.COMPLETED
- && fileTransfer.getStatus()
+ && fileTransfer.getStatus()
== FileTransferStatusChangeEvent.PREPARING)
{
fileTransfer.fireStatusChangeEvent(
@@ -579,7 +582,7 @@ public class OperationSetFileTransferJabberImpl
/**
* Parses the given Jabber status to a <tt>FileTransfer</tt> interface
* status.
- *
+ *
* @param jabberStatus the Jabber status to parse
* @return the parsed status
*/