diff --git a/src/plugins/jingle/src/java/org/jivesoftware/sparkplugin/IncomingCall.java b/src/plugins/jingle/src/java/org/jivesoftware/sparkplugin/IncomingCall.java index 4a28dd31..25dc6b84 100644 --- a/src/plugins/jingle/src/java/org/jivesoftware/sparkplugin/IncomingCall.java +++ b/src/plugins/jingle/src/java/org/jivesoftware/sparkplugin/IncomingCall.java @@ -14,7 +14,6 @@ import org.jivesoftware.resource.SparkRes; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.jingle.IncomingJingleSession; -import org.jivesoftware.smackx.jingle.JingleNegotiator; import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSessionRequest; import org.jivesoftware.smackx.jingle.listeners.JingleSessionListener; @@ -23,11 +22,13 @@ import org.jivesoftware.smackx.jingle.nat.TransportCandidate; import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.ui.ChatRoom; import org.jivesoftware.spark.ui.ChatRoomClosingListener; -import org.jivesoftware.spark.util.TaskEngine; import org.jivesoftware.spark.util.SwingTimerTask; +import org.jivesoftware.spark.util.TaskEngine; import org.jivesoftware.spark.util.log.Log; import org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster; +import javax.swing.SwingUtilities; + import java.applet.Applet; import java.applet.AudioClip; import java.awt.GridBagConstraints; @@ -76,7 +77,8 @@ public class IncomingCall implements JingleSessionListener, ChatRoomClosingListe // Accept the request try { session = request.accept(); - } catch (XMPPException e) { + } + catch (XMPPException e) { Log.error(e); } @@ -117,33 +119,37 @@ public class IncomingCall implements JingleSessionListener, ChatRoomClosingListe * Removes the JingleRoom from the ChatRoom. */ private void showCallEndedState() { - if (ringing != null) { - ringing.stop(); - } + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (ringing != null) { + ringing.stop(); + } - final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm a"); - notificationUI.setTitle("Voice chat ended on " + formatter.format(new Date())); - notificationUI.setIcon(null); - notificationUI.showAlert(false); + final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm a"); + notificationUI.setTitle("Voice chat ended on " + formatter.format(new Date())); + notificationUI.setIcon(null); + notificationUI.showAlert(false); - if (chatRoom != null) { - JingleRoom room = callMap.get(chatRoom); - if (room != null) { - chatRoom.getChatPanel().remove(room); + if (chatRoom != null) { + JingleRoom room = callMap.get(chatRoom); + if (room != null) { + chatRoom.getChatPanel().remove(room); + } + + callMap.remove(chatRoom); + chatRoom.getChatPanel().invalidate(); + chatRoom.getChatPanel().validate(); + chatRoom.getChatPanel().repaint(); + } + + // Add state + JingleStateManager.getInstance().removeJingleSession(chatRoom); + + // Notify state change + SparkManager.getChatManager().notifySparkTabHandlers(chatRoom); } - - callMap.remove(chatRoom); - chatRoom.getChatPanel().invalidate(); - chatRoom.getChatPanel().validate(); - chatRoom.getChatPanel().repaint(); - } - - // Add state - JingleStateManager.getInstance().removeJingleSession(chatRoom); - - // Notify state change - SparkManager.getChatManager().notifySparkTabHandlers(chatRoom); + }); } /** @@ -209,7 +215,7 @@ public class IncomingCall implements JingleSessionListener, ChatRoomClosingListe }); incomingCall.getRejectButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) { rejectIncomingCall(); } });