Creates chat dialog components, incoming call dialog and incoming file transfer components in swing dispatch thread.

If we failed to connect to xmpp server fire connection failed for provider and clean to avoid staying not connected and seeing duplicate connection in logs.
cusax-fix
Damian Minkov 15 years ago
parent 827588152a
commit a2d0e4e4a6

@ -69,8 +69,20 @@ public static class GuiCallListener implements CallListener
* ring phone sound to the user.
* @param event the <tt>CallEvent</tt>
*/
public void incomingCallReceived(CallEvent event)
public void incomingCallReceived(final CallEvent event)
{
if(!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
incomingCallReceived(event);
}
});
return;
}
Call sourceCall = event.getSourceCall();
final ReceivedCallDialog receivedCallDialog
= new ReceivedCallDialog(sourceCall, event.isVideoCall());

@ -1947,10 +1947,22 @@ else if (subject.equals(oldSubject))
* @param date the date on which the request has been received
*/
public void addIncomingFileTransferRequest(
OperationSetFileTransfer fileTransferOpSet,
IncomingFileTransferRequest request,
Date date)
final OperationSetFileTransfer fileTransferOpSet,
final IncomingFileTransferRequest request,
final Date date)
{
if(!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
addIncomingFileTransferRequest(
fileTransferOpSet, request, date);
}
});
}
this.addActiveFileTransfer(request.getID(), request);
ReceiveFileConversationComponent component

@ -233,69 +233,97 @@ public void messageReceived(MessageReceivedEvent evt)
Contact protocolContact = evt.getSourceContact();
Message message = evt.getSourceMessage();
int eventType = evt.getEventType();
MetaContact metaContact = GuiActivator.getContactListService()
.findMetaContactByContact(protocolContact);
if(metaContact != null)
{
// Obtain the corresponding chat panel.
final ChatPanel chatPanel
= chatWindowManager.getContactChat( metaContact,
protocolContact,
message.getMessageUID());
// Show an envelope on the sender contact in the contact list and
// in the systray.
if (!chatPanel.isChatFocused())
contactList.setActiveContact(metaContact, true);
// Distinguish the message type, depending on the type of event that
// we have received.
String messageType = null;
if(eventType == MessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED)
{
messageType = Chat.INCOMING_MESSAGE;
}
else if(eventType == MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED)
{
messageType = Chat.SYSTEM_MESSAGE;
}
else if(eventType == MessageReceivedEvent.SMS_MESSAGE_RECEIVED)
{
messageType = Chat.SMS_MESSAGE;
}
chatPanel.addMessage(
protocolContact.getAddress(),
protocolContact.getDisplayName(),
evt.getTimestamp(),
messageType,
message.getContent(),
message.getContentType());
messageReceived(protocolContact,
metaContact, message, eventType, evt.getTimestamp());
}
else
{
if (logger.isTraceEnabled())
logger.trace("MetaContact not found for protocol contact: "
+ protocolContact + ".");
}
}
// Opens the chat panel with the new message in the UI thread.
/**
* When a message is received determines whether to open a new chat window
* or chat window tab, or to indicate that a message is received from a
* contact which already has an open chat. When the chat is found checks if
* in mode "Auto popup enabled" and if this is the case shows the message in
* the appropriate chat panel.
*
* @param protocolContact the source contact of the event
* @param metaContact the metacontact containing <tt>protocolContact</tt>
* @param message the message to deliver
* @param eventType the event type
* @param timestamp the timestamp of the event
*/
private void messageReceived(final Contact protocolContact,
final MetaContact metaContact,
final Message message,
final int eventType,
final long timestamp)
{
if(!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
chatWindowManager.openChat(chatPanel, false);
messageReceived(protocolContact,
metaContact, message, eventType, timestamp);
}
});
return;
}
// Obtain the corresponding chat panel.
final ChatPanel chatPanel
= chatWindowManager.getContactChat( metaContact,
protocolContact,
message.getMessageUID());
// Show an envelope on the sender contact in the contact list and
// in the systray.
if (!chatPanel.isChatFocused())
contactList.setActiveContact(metaContact, true);
ChatTransport chatTransport
= chatPanel.getChatSession()
.findChatTransportForDescriptor(protocolContact);
// Distinguish the message type, depending on the type of event that
// we have received.
String messageType = null;
chatPanel.setSelectedChatTransport(chatTransport);
if(eventType == MessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED)
{
messageType = Chat.INCOMING_MESSAGE;
}
else
else if(eventType == MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED)
{
if (logger.isTraceEnabled())
logger.trace("MetaContact not found for protocol contact: "
+ protocolContact + ".");
messageType = Chat.SYSTEM_MESSAGE;
}
else if(eventType == MessageReceivedEvent.SMS_MESSAGE_RECEIVED)
{
messageType = Chat.SMS_MESSAGE;
}
chatPanel.addMessage(
protocolContact.getAddress(),
protocolContact.getDisplayName(),
timestamp,
messageType,
message.getContent(),
message.getContentType());
chatWindowManager.openChat(chatPanel, false);
ChatTransport chatTransport
= chatPanel.getChatSession()
.findChatTransportForDescriptor(protocolContact);
chatPanel.setSelectedChatTransport(chatTransport);
}
/**

@ -1130,7 +1130,25 @@ else if (tlsRequired)
throw new XMPPException("TLS is required by client");
}
connection.addConnectionListener(connectionListener);
if(!connection.isConnected())
{
// connection is not connected, lets set state to our connection
// as failed seems there is some lag/problem with network
// and this way we will inform for it and later reconnect if needed
// as IllegalStateException that is thrown within
// addConnectionListener is not handled properly
disconnectAndCleanConnection();
fireRegistrationStateChanged(getRegistrationState(),
RegistrationState.CONNECTION_FAILED,
RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND, null);
return ConnectState.ABORT_CONNECTING;
}
else
{
connection.addConnectionListener(connectionListener);
}
if(abortConnecting)
{

Loading…
Cancel
Save