Display an error message when Jingle call failed if contact does not belong to our roster list, if it does not support Jingle.

cusax-fix
Sebastien Vincent 15 years ago
parent 50a2ab33bc
commit 863ce99804

@ -50,7 +50,7 @@ public ActiveCallsRepositoryJabberImpl(
* @param sid the jingle <tt>sid</tt> we're looking for.
*
* @return the {@link CallJabberImpl} containing the peer with the
* specified <tt>sid</tt> or tt>null</tt> if we couldn't find one matching
* specified <tt>sid</tt> or <tt>null</tt> if we couldn't find one matching
* it.
*/
public CallJabberImpl findJingleSID(String sid)
@ -91,6 +91,30 @@ public CallPeerJabberImpl findCallPeer(String sid)
return null;
}
/**
* Returns the {@link CallPeerJabberImpl} whose session-init's ID has
* the specified IQ <tt>id</tt>.
*
* @param id the IQ <tt>id</tt> we're looking for.
*
* @return the {@link CallPeerJabberImpl} with the specified <tt>id</tt>
* or <tt>null</tt> if we couldn't find one matching it.
*/
public CallPeerJabberImpl findCallPeerBySessInitPacketID(String id)
{
Iterator<CallJabberImpl> calls = getActiveCalls();
while (calls.hasNext())
{
CallJabberImpl call = calls.next();
CallPeerJabberImpl peer = call.getPeerBySessInitPacketID(id);
if ( peer != null )
return peer;
}
return null;
}
/**
* Creates and dispatches a <tt>CallEvent</tt> notifying registered
* listeners that an event with id <tt>eventID</tt> has occurred on

@ -223,4 +223,23 @@ public CallPeerJabberImpl getPeer(String sid)
}
return null;
}
/**
* Returns the peer whose corresponding session-init ID has the specified
* <tt>id</tt>.
*
* @param id the ID of the session-init IQ whose peer we are looking for.
*
* @return the {@link CallPeerJabberImpl} with the specified IQ
* <tt>id</tt> and <tt>null</tt> if no such peer exists in this call.
*/
public CallPeerJabberImpl getPeerBySessInitPacketID(String id)
{
for(CallPeerJabberImpl peer : getCallPeersVector())
{
if (peer.getSessInitID().equals(id))
return peer;
}
return null;
}
}

@ -456,6 +456,18 @@ public String getJingleSID()
return sessionInitIQ.getSID();
}
/**
* Returns the IQ ID of the Jingle session-initiate packet associated with
* this call.
*
* @return the IQ ID of the Jingle session-initiate packet associated with
* this call.
*/
public String getSessInitID()
{
return sessionInitIQ.getPacketID();
}
/**
* Puts this peer into a {@link CallPeerState#DISCONNECTED}, indicating a
* reason to the user, if there is one.

@ -451,7 +451,41 @@ public boolean accept(Packet packet)
{
//we only handle JingleIQ-s
if( ! (packet instanceof JingleIQ) )
{
CallPeerJabberImpl callPeer =
activeCallsRepository.findCallPeerBySessInitPacketID(
packet.getPacketID());
if(callPeer != null)
{
/* packet is a response to a Jingle call but is not a JingleIQ
* so it is for sure an error (peer does not support Jingle or
* does not belong to our roster)
*/
XMPPError error = packet.getError();
if (error != null)
{
logger.error("Received an error: code=" + error.getCode()
+ " message=" + error.getMessage());
String message = "Service unavailable";
Roster roster = getProtocolProvider().getConnection().
getRoster();
if(!roster.contains(packet.getFrom()))
{
message += ": try adding the contact to your contact " +
"list first.";
}
if (error.getMessage() != null)
message = error.getMessage();
callPeer.setState(CallPeerState.FAILED, message);
}
}
return false;
}
JingleIQ jingleIQ = (JingleIQ)packet;

Loading…
Cancel
Save