Fixes chat transport selector updating the status after reconnect and choosing offline contacts.

cusax-fix
Damian Minkov 12 years ago
parent 21e8e31e6d
commit a8517a64b2

@ -355,6 +355,21 @@ public void setSelected(ChatTransport chatTransport)
new ImageIcon(createTransportStatusImage(chatTransport)));
}
/**
* Do we have a selected transport.
* @return do we have a selected transport.
*/
boolean hasSelectedTransport()
{
for(JCheckBoxMenuItem item : transportMenuItems.values())
{
if(item.isSelected())
return true;
}
return false;
}
/**
* Returns the protocol menu.
*

@ -1106,7 +1106,7 @@ public void run()
// Schedules the timer.
if(chatTransport.getResourceName() != null)
{
OutdatedResourceTimerTask task
OutdatedResourceTimerTask task
= new OutdatedResourceTimerTask();
outdatedResourceTimer = new java.util.Timer();
outdatedResourceTimer.schedule(task, timeout);
@ -1115,7 +1115,13 @@ public void run()
// Sets the new resource transport is really effective (i.e. we have
// received a message from this resource).
if(transportSelectorBox != null && isMessageOrFileTransferReceived)
// if we do not have any selected resource, or the currently selected
// if offline
if(transportSelectorBox != null
&& (isMessageOrFileTransferReceived
|| (!transportSelectorBox.hasSelectedTransport()
|| !chatPanel.getChatSession().getCurrentChatTransport()
.getStatus().isOnline())))
{
transportSelectorBox.setSelected(chatTransport);
}
@ -1493,7 +1499,9 @@ public void run()
// We found the bare ID, then set it as the current resource
// transport.
if(transport.getResourceName() == null)
// choose only online resources
if(transport.getResourceName() == null
&& transport.getStatus().isOnline())
{
isOutdatedResource = false;
setSelectedChatTransport(transport, true);

@ -761,6 +761,8 @@ private void removeChatTransports(Contact contact)
}
contact.removeResourceListener(this);
currentChatTransport = null;
}
/**

Loading…
Cancel
Save