Added multichat operation set definition and Gibberish protocol implementation. Related issues: Issue #241 , Issue #244, Issue #250

Fixed online threshold comparisons. a presence status with an index equal to the online threshold is considered online
cusax-fix
Emil Ivov 19 years ago
parent c86c101130
commit 997e245c18

@ -23,9 +23,9 @@
* some methods facilitating the access to the contact list. Some more contact
* list specific methods are added like: getMetaContactStatus,
* getMetaContactStatusIcon, changeContactStatus, etc.
*
*
* @author Yana Stamcheva
*
*
*/
public class ContactListModel
extends AbstractListModel
@ -42,7 +42,7 @@ public class ContactListModel
/**
* Creates a List Model, which gets its data from the given
* MetaContactListService.
*
*
* @param contactList The MetaContactListService which contains the contact
* list.
*/
@ -57,7 +57,7 @@ public ContactListModel(MetaContactListService contactList)
/**
* Informs interested listeners that the content has changed of the cells
* given by the range from startIndex to endIndex.
*
*
* @param startIndex The start index of the range .
* @param endIndex The end index of the range.
*/
@ -70,7 +70,7 @@ public void contentChanged(int startIndex, int endIndex)
/**
* Informs interested listeners that new cells are added from startIndex to
* endIndex.
*
*
* @param startIndex The start index of the range .
* @param endIndex The end index of the range.
*/
@ -82,7 +82,7 @@ public void contentAdded(final int startIndex, final int endIndex)
/**
* Informs interested listeners that a range of cells is removed.
*
*
* @param startIndex The start index of the range.
* @param endIndex The end index of the range.
*/
@ -94,7 +94,7 @@ public void contentRemoved(final int startIndex, final int endIndex)
/**
* Returns the size of this list model.
*
*
* @return The size of this list model.
*/
public int getSize()
@ -104,7 +104,7 @@ public int getSize()
/**
* Returns the object at the given index.
*
*
* @param index The index.
* @return The object at the given index.
*/
@ -118,7 +118,7 @@ public Object getElementAt(int index)
/**
* Goes through all subgroups and contacts and determines the final size of
* the contact list.
*
*
* @param group The group which to be measured.
* @return The size of the contactlist
*/
@ -145,7 +145,7 @@ private int getContactListSize(MetaContactGroup group)
if (isContactOnline(contact))
size++;
}
//count the group itself only if it contains any online contacts
if(!group.equals(rootGroup) && size > 0)
size++;
@ -156,7 +156,7 @@ private int getContactListSize(MetaContactGroup group)
while (subgroups.hasNext())
{
MetaContactGroup subGroup = (MetaContactGroup) subgroups.next();
size += getContactListSize(subGroup);
size += getContactListSize(subGroup);
}
}
else
@ -164,7 +164,7 @@ private int getContactListSize(MetaContactGroup group)
//count the closed group
size++;
}
return size;
}
@ -172,7 +172,7 @@ private int getContactListSize(MetaContactGroup group)
* Returns the general status of the given MetaContact. Detects the status
* using the priority status table. The priority is defined on the
* "availablity" factor and here the most "available" status is returned.
*
*
* @param metaContact The metaContact fot which the status is asked.
* @return PresenceStatus The most "available" status from all subcontact
* statuses.
@ -201,7 +201,7 @@ public PresenceStatus getMetaContactStatus(MetaContact metaContact)
/**
* Returns the status icon for this MetaContact.
*
*
* @param contact The metaContact for which the status icon is asked.
* @return the status icon for this MetaContact.
*/
@ -214,7 +214,7 @@ public ImageIcon getMetaContactStatusIcon(MetaContact contact)
/**
* If the given object is instance of MetaContact or MetaContactGroup
* returns the index of this meta contact or group, otherwiser returns -1.
*
*
* @param o the object, which index we search
* @return the index of the given object if it founds it, otherwise -1
*/
@ -236,7 +236,7 @@ else if (o instanceof MetaContactGroup)
/**
* Returns the index of the given MetaContact.
*
*
* @param contact The MetaContact to search for.
* @return The index of the given MetaContact.
*/
@ -265,34 +265,34 @@ private int indexOf(MetaContact contact)
/**
* Returns the index of the given MetaContactGroup.
*
*
* @param group The given MetaContactGroup to search for.
* @return The index of the given MetaContactGroup.
*/
private int indexOf(MetaContactGroup group)
{
int index = -1;
if (showOffline || containsOnlineContacts(group))
{
int currentIndex = 0;
MetaContactGroup parentGroup = this.contactList
.findParentMetaContactGroup(group);
if (parentGroup != null && !this.isGroupClosed(parentGroup))
{
currentIndex += this.indexOf(parentGroup);
currentIndex += countChildContacts(parentGroup);
currentIndex += parentGroup.indexOf(group) + 1;
for (int i = 0; i < parentGroup.indexOf(group); i++)
{
MetaContactGroup subGroup = parentGroup
.getMetaContactSubgroup(i);
currentIndex += countContactsAndSubgroups(subGroup);
}
index = currentIndex;
@ -304,7 +304,7 @@ private int indexOf(MetaContactGroup group)
/**
* Returns the number of all children of the given MetaContactGroup. Counts
* in depth all subgroups and child contacts.
*
*
* @param parentGroup The parent MetaContactGroup.
* @return The number of all children of the given MetaContactGroup
*/
@ -345,7 +345,7 @@ public int countContactsAndSubgroups(MetaContactGroup parentGroup)
/**
* Recursively searches the given group in depth for the element at the
* given index.
*
*
* @param group the group in which we search
* @param currentIndex the index, where we currently are
* @param searchedIndex the index to search for
@ -390,7 +390,7 @@ private Object getElementAt(MetaContactGroup group, int currentIndex,
{
MetaContactGroup subgroup = (MetaContactGroup) subgroups
.next();
if(showOffline || containsOnlineContacts(subgroup))
element = getElementAt(subgroup, currentIndex + 1,
searchedIndex);
@ -418,7 +418,7 @@ private Object getElementAt(MetaContactGroup group, int currentIndex,
/**
* Closes the given group by hiding all containing contacts.
*
*
* @param group The group to close.
*/
public void closeGroup(MetaContactGroup group)
@ -431,14 +431,14 @@ public void closeGroup(MetaContactGroup group)
this.indexOf(group.getMetaContact(
countContactsAndSubgroups(group) - 1)));
}
this.closedGroups.add(group);
}
}
/**
* Opens the given group by showing all containing contacts.
*
*
* @param group The group to open.
*/
public void openGroup(MetaContactGroup group)
@ -450,7 +450,7 @@ public void openGroup(MetaContactGroup group)
/**
* Checks whether the group is closed.
*
*
* @param group The group to check.
* @return True if the group is closed, false - otherwise.
*/
@ -464,7 +464,7 @@ public boolean isGroupClosed(MetaContactGroup group)
/**
* Returns true if offline contacts should be shown, false otherwise.
*
*
* @return boolean true if offline contacts should be shown, false
* otherwise.
*/
@ -476,7 +476,7 @@ public boolean isShowOffline()
/**
* Sets the showOffline variable to indicate whether or not offline contacts
* should be shown.
*
*
* @param showOffline true if offline contacts should be shown, false
* otherwise.
*/
@ -487,7 +487,7 @@ public void setShowOffline(boolean showOffline)
/**
* Returns TRUE if the given meta contact is online, FALSE otherwise.
*
*
* @param contact the meta contact
* @return TRUE if the given meta contact is online, FALSE otherwise
*/
@ -495,7 +495,7 @@ public boolean isContactOnline(MetaContact contact)
{
// Lays on the fact that the default contact is the most connected.
if (contact.getDefaultContact().getPresenceStatus()
.getStatus() > PresenceStatus.ONLINE_THRESHOLD)
.getStatus() >= PresenceStatus.ONLINE_THRESHOLD)
{
return true;
}
@ -507,7 +507,7 @@ public boolean isContactOnline(MetaContact contact)
/**
* Counts group child contacts depending on the showOffline option.
*
*
* @param group the parent group to count for
* @return child contacts count for the given group
*/
@ -519,11 +519,11 @@ public int countChildContacts(MetaContactGroup group)
{
int count = 0;
Iterator i = group.getChildContacts();
while (i.hasNext())
{
MetaContact metaContact = (MetaContact) i.next();
if (isContactOnline(metaContact))
{
count++;
@ -536,10 +536,10 @@ public int countChildContacts(MetaContactGroup group)
return count;
}
}
/**
* Checks if the given group contains online contacts.
*
*
* @param group the group to check for online contacts
* @return TRUE if the given group contains online contacts, FALSE otherwise
*/
@ -553,7 +553,7 @@ private boolean containsOnlineContacts(MetaContactGroup group)
if (isContactOnline(contact))
return true;
}
return false;
}
}

Loading…
Cancel
Save