diff options
author | hristoterezov <hristo@jitsi.org> | 2013-11-19 18:54:55 +0200 |
---|---|---|
committer | hristoterezov <hristo@jitsi.org> | 2013-11-19 18:54:55 +0200 |
commit | 3b5c887b80a52fc50579610cc54c7410fced2751 (patch) | |
tree | d0f44cbe7cb9629a14f4cd7f71cc7f01d1cf78bc | |
parent | 5898ddd57f5dbbc4bb67d704278addcddebcc5d8 (diff) | |
download | jitsi-3b5c887b80a52fc50579610cc54c7410fced2751.zip jitsi-3b5c887b80a52fc50579610cc54c7410fced2751.tar.gz jitsi-3b5c887b80a52fc50579610cc54c7410fced2751.tar.bz2 |
Fixes the order of chat room contacts to be ordered by presence status.
4 files changed, 69 insertions, 5 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java index cb2b2ed..ac201ec 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java @@ -296,9 +296,24 @@ public class TreeContactList return; ContactNode contactNode = ((UIContactImpl) uiContact).getContactNode(); - + if (contactNode != null) + { nodeChanged(contactNode); + + TreeNode parentNode = contactNode.getParent(); + if(parentNode == null) + return; + int currentIndex = parentNode.getIndex(contactNode); + if(currentIndex != sourceContact.getIndex()) + { + UIGroupImpl uiGroup = (UIGroupImpl)sourceUI.getUIGroup(); + GroupNode groupNode = uiGroup.getGroupNode(); + if (groupNode == null) + return; + groupNode.sort(treeModel); + } + } } /** diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java index 663026b..a7b2bcb 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java @@ -38,8 +38,8 @@ public class ChatRoomQuery /**
* List with the current results for the query.
*/
- private List<ChatRoomSourceContact> contactResults
- = new LinkedList<ChatRoomSourceContact>();
+ private Set<ChatRoomSourceContact> contactResults
+ = new TreeSet<ChatRoomSourceContact>();
/**
* MUC service.
@@ -144,15 +144,16 @@ public class ChatRoomQuery String eventType = evt.getEventType();
boolean existingContact = false;
- SourceContact foundContact = null;
+ ChatRoomSourceContact foundContact = null;
synchronized (contactResults)
{
- for(SourceContact contact : contactResults)
+ for(ChatRoomSourceContact contact : contactResults)
{
if(contact.getContactAddress().equals(sourceChatRoom.getName()))
{
existingContact = true;
foundContact = contact;
+ contactResults.remove(contact);
break;
}
}
@@ -166,6 +167,10 @@ public class ChatRoomQuery {
((ChatRoomSourceContact)foundContact).setPresenceStatus(
ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
+ synchronized (contactResults)
+ {
+ contactResults.add(foundContact);
+ }
fireContactChanged(foundContact);
}
else
@@ -186,6 +191,10 @@ public class ChatRoomQuery ((ChatRoomSourceContact)foundContact)
.setPresenceStatus(
ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
+ synchronized (contactResults)
+ {
+ contactResults.add(foundContact);
+ }
fireContactChanged(foundContact);
}
}
@@ -324,4 +333,20 @@ public class ChatRoomQuery }
}
}
+
+ public synchronized int indexOf(ChatRoomSourceContact contact)
+ {
+ Iterator<ChatRoomSourceContact> it = contactResults.iterator();
+ int i = 0;
+ while(it.hasNext())
+ {
+ if(contact.equals(it.next()))
+ {
+ return i;
+
+ }
+ i++;
+ }
+ return -1;
+ }
}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java index 976ebb9..e4f8f24 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java @@ -20,6 +20,10 @@ public class ChatRoomSourceContact extends SortedGenericSourceContact
{
/**
+ * The parent contact query.
+ */
+ private final ChatRoomQuery parentQuery;
+ /**
* The name of the chat room associated with the contact.
*/
private String chatRoomName;
@@ -50,6 +54,7 @@ public class ChatRoomSourceContact this.chatRoomName = chatRoomName;
this.chatRoomID = chatRoomID;
this.provider = pps;
+ this.parentQuery = query;
initContactProperties(getChatRoomStateByName());
@@ -68,6 +73,7 @@ public class ChatRoomSourceContact this.chatRoomName = chatRoom.getName();
this.chatRoomID = chatRoom.getIdentifier();
this.provider = chatRoom.getParentProvider();
+ this.parentQuery = query;
initContactProperties(
(chatRoom.isJoined()?
@@ -162,4 +168,16 @@ public class ChatRoomSourceContact return provider;
}
+ /**
+ * Returns the index of this source contact in its parent group.
+ *
+ * @return the index of this contact in its parent
+ */
+ @Override
+ public int getIndex()
+ {
+ return parentQuery.indexOf(this);
+ }
+
+
}
diff --git a/src/net/java/sip/communicator/service/muc/ChatRoomPresenceStatus.java b/src/net/java/sip/communicator/service/muc/ChatRoomPresenceStatus.java index 7609970..b4bae20 100644 --- a/src/net/java/sip/communicator/service/muc/ChatRoomPresenceStatus.java +++ b/src/net/java/sip/communicator/service/muc/ChatRoomPresenceStatus.java @@ -65,4 +65,10 @@ public class ChatRoomPresenceStatus extends PresenceStatus super(status, statusName);
}
+ @Override
+ public boolean isOnline()
+ {
+ return getStatus() == CHAT_ROOM_ONLINE_THRESHOLD;
+ }
+
}
|