diff options
author | Sebastien Vincent <seb@jitsi.org> | 2012-01-04 14:04:42 +0000 |
---|---|---|
committer | Sebastien Vincent <seb@jitsi.org> | 2012-01-04 14:04:42 +0000 |
commit | a2c0b8a8172fdfe12f879b8778c988a25801d4d9 (patch) | |
tree | feb2e91566ccd98bc7df3bc235d3866f67491d6d /src/net/java/sip | |
parent | d8b4929942c29f837db4e7ac528379368c8afae7 (diff) | |
download | jitsi-a2c0b8a8172fdfe12f879b8778c988a25801d4d9.zip jitsi-a2c0b8a8172fdfe12f879b8778c988a25801d4d9.tar.gz jitsi-a2c0b8a8172fdfe12f879b8778c988a25801d4d9.tar.bz2 |
Fixes connection problem and avoids displaying two call windows with Google Voice.
Diffstat (limited to 'src/net/java/sip')
4 files changed, 83 insertions, 18 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallGTalkImpl.java index eb34d0a..6d9cdb4 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallGTalkImpl.java @@ -6,6 +6,8 @@ */ package net.java.sip.communicator.impl.protocol.jabber; +import java.util.*; + import org.jivesoftware.smack.packet.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.gtalk.*; @@ -26,6 +28,11 @@ public class CallGTalkImpl ProtocolProviderServiceJabberImpl> { /** + * If the first callPeer is a Google Voice (without resource) ones. + */ + private boolean firstCallPeerIsGV = false; + + /** * Initializes a new <tt>CallGTalkImpl</tt> instance belonging to * <tt>sourceProvider</tt> and associated with the jingle session with the * specified <tt>sessionID</tt>. If the new instance corresponds to an @@ -157,14 +164,44 @@ public class CallGTalkImpl // create the session-initiate IQ CallPeerGTalkImpl callPeer = new CallPeerGTalkImpl(calleeJID, this); + if(!firstCallPeerIsGV) + firstCallPeerIsGV = calleeJID.endsWith( + ProtocolProviderServiceJabberImpl.GOOGLE_VOICE_DOMAIN); + addCallPeer(callPeer); callPeer.setState(CallPeerState.INITIATING_CALL); // 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(getCallPeerCount() == 1) + if(getCallPeerCount() == 1 && !calleeJID.endsWith( + ProtocolProviderServiceJabberImpl.GOOGLE_VOICE_DOMAIN) || + getCallPeerCount() == 2 && firstCallPeerIsGV) + { + if(firstCallPeerIsGV) + { + // now all is setup, considered that there is no GV call + firstCallPeerIsGV = false; + Iterator<CallPeerGTalkImpl> it = + getCallPeersVector().iterator(); + String sub = calleeJID.substring(0, calleeJID.indexOf("/")); + + // remove Google Voice first call from CallPeer vector otherwise + // we will display a conference call window + while(it.hasNext()) + { + CallPeer p = it.next(); + + if(p.getAddress().equals(sub)) + { + it.remove(); + break; + } + } + } + parentOpSet.fireCallEvent(CallEvent.CALL_INITIATED, this); + } CallPeerMediaHandlerGTalkImpl mediaHandler = callPeer.getMediaHandler(); diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java index c630ba9..13e74a3 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java @@ -262,6 +262,14 @@ public class CallPeerGTalkImpl protocolProvider.getConnection().sendPacket(sessionInitIQ); + // for Google Voice JID without resource we do not harvest and send + // candidates + if(getAddress().endsWith( + ProtocolProviderServiceJabberImpl.GOOGLE_VOICE_DOMAIN)) + { + return; + } + getMediaHandler().harvestCandidates(offer.getPayloadTypes(), new CandidatesSender() { @@ -685,7 +693,8 @@ public class CallPeerGTalkImpl } } - if(fullJID.contains("@voice.google.com")) + if(fullJID.contains( + "@" + ProtocolProviderServiceJabberImpl.GOOGLE_VOICE_DOMAIN)) return true; return false; 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 1966a1f..093b12b 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java @@ -1022,7 +1022,7 @@ public class OperationSetBasicTelephonyJabberImpl private void processSessionIQ(SessionIQ sessionIQ) { //let's first see whether we have a peer that's concerned by this IQ - CallPeerGTalkImpl callPeer = + final CallPeerGTalkImpl callPeer = activeGTalkCallsRepository.findCallPeer(sessionIQ.getID()); IQ.Type type = sessionIQ.getType(); @@ -1051,22 +1051,36 @@ public class OperationSetBasicTelephonyJabberImpl if(redirect != null) { - CallGTalkImpl call = callPeer.getCall(); - - try + final CallGTalkImpl call = callPeer.getCall(); + final String redirAddr; + String redir = redirect.getRedir(); + + if(redir.startsWith("xmpp:")) + redirAddr = redir.substring(5); + else + redirAddr = null; + + if(redirAddr == null) + return; + + // launch the "new" call in another thread to not block + // smack processor + new Thread() { - String redir = redirect.getRedir(); - callPeer.setState(CallPeerState.DISCONNECTED); - - if(redir.startsWith("xmpp:")) - redir = redir.substring(5); - - call.initiateGTalkSession(redir, null); - } - catch(Exception e) - { - logger.info("Failed to initiate GTalk session (redirect)"); - } + public void run() + { + try + { + call.initiateGTalkSession(redirAddr, null); + callPeer.setState(CallPeerState.DISCONNECTED); + } + catch(Exception e) + { + logger.info( + "Failed to initiate GTalk session (redirect)"); + } + } + }.start(); return; } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index 17943c7..2f6abfd 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -192,6 +192,11 @@ public class ProtocolProviderServiceJabberImpl */ private static final String XMPP_DSCP_PROPERTY = "net.java.sip.communicator.impl.protocol.XMPP_DSCP"; + + /** + * Google voice domain name. + */ + public static final String GOOGLE_VOICE_DOMAIN = "voice.google.com"; /** * Used to connect to a XMPP server. |