Methods Summary |
---|
public synchronized void | addContactListListener(ContactListListener listener)Adds a listener to the manager so that it will be notified for contact
list changed.
if ((listener != null) && !mContactListListeners.contains(listener)) {
mContactListListeners.add(listener);
}
|
protected void | addContactToListAsync(java.lang.String address, ContactList list)
checkState();
doAddContactToListAsync(address, list);
|
public abstract void | approveSubscriptionRequest(java.lang.String contact)
|
public void | blockContactAsync(Contact contact)
blockContactAsync(contact.getAddress().getFullName());
|
public void | blockContactAsync(java.lang.String address)Blocks a certain Contact. The contact will be removed from any
ContactList after be blocked. If the contact has already been blocked,
the method does nothing.
checkState();
if(isBlocked(address)){
return;
}
if (mBlockPending.contains(address)) {
return;
}
doBlockContactAsync(address, true);
|
protected void | checkState()Check the state of the ContactListManager. Only the LIST_LOADED state
is permitted.
if (getConnection().getState() != ImConnection.LOGGED_IN) {
throw new ImException(ImErrorInfo.CANT_CONNECT_TO_SERVER,
"Can't connect to server");
}
if (getState() != LISTS_LOADED) {
throw new ImException(ImErrorInfo.ILLEGAL_CONTACT_LIST_MANAGER_STATE,
"Illegal contact list manager state");
}
|
public boolean | containsContact(Contact contact)Tell whether the manager contains the specified contact
for (ContactList list : mContactLists) {
if (list.containsContact(contact)) {
return true;
}
}
return false;
|
public void | createContactListAsync(java.lang.String name)Create a contact list with the specified name asynchronously.
createContactListAsync(name, null, false);
|
public void | createContactListAsync(java.lang.String name, boolean isDefault)Create a contact list with specified name and whether it is to be
created as the default list.
createContactListAsync(name, null, isDefault);
|
public void | createContactListAsync(java.lang.String name, java.util.Collection contacts)Create a contact list with specified name and contacts asynchronously.
createContactListAsync(name, contacts, false);
|
public synchronized void | createContactListAsync(java.lang.String name, java.util.Collection contacts, boolean isDefault)Create a contact list with specified name and contacts asynchronously,
and whether it is to be created as the default contact list.
checkState();
if (getContactList(name) != null) {
throw new ImException(ImErrorInfo.CONTACT_LIST_EXISTS,
"Contact list already exists");
}
if (mContactLists.isEmpty()) {
isDefault = true;
}
doCreateContactListAsync(name, contacts, isDefault);
|
public abstract Contact | createTemporaryContact(java.lang.String address)Creates a temporary contact. It's usually used when we want to create
a chat with someone not in the list.
|
public abstract void | declineSubscriptionRequest(java.lang.String contact)
|
public void | deleteContactListAsync(java.lang.String name)Delete a contact list of the specified name asynchronously
deleteContactListAsync(getContactList(name));
|
public synchronized void | deleteContactListAsync(ContactList list)Delete a specified contact list asynchronously
checkState();
if (null == list) {
throw new ImException(ImErrorInfo.CONTACT_LIST_NOT_FOUND,
"Contact list doesn't exist");
}
doDeleteContactListAsync(list);
|
protected abstract void | doAddContactToListAsync(java.lang.String address, ContactList list)
|
protected abstract void | doBlockContactAsync(java.lang.String address, boolean block)Block or unblock a contact.
|
protected abstract void | doCreateContactListAsync(java.lang.String name, java.util.Collection contacts, boolean isDefault)
|
protected abstract void | doDeleteContactListAsync(ContactList list)
|
protected abstract void | doRemoveContactFromListAsync(Contact contact, ContactList list)
|
public java.util.List | getBlockedList()Gets a unmodifiable list of blocked contacts.
checkState();
return Collections.unmodifiableList(mBlockedList);
|
protected abstract ImConnection | getConnection()
|
public Contact | getContact(java.lang.String address)
for (ContactList list : mContactLists) {
Contact c = list.getContact(address);
if( c != null) {
return c;
}
}
return null;
|
public Contact | getContact(Address address)Gets a contact by address.
return getContact(address.getFullName());
|
public ContactList | getContactList(java.lang.String name)Gets a contact list by name.
for (ContactList list : mContactLists) {
if (list.getName() != null && list.getName().equals(name)) {
return list;
}
}
return null;
|
public ContactList | getContactList(Address address)Get the contact list by the address
for (ContactList list : mContactLists) {
if (list.getAddress().equals(address)) {
return list;
}
}
return null;
|
public java.util.Collection | getContactLists()Gets a collection of the contact lists.
return Collections.unmodifiableCollection(mContactLists);
|
public ContactList | getDefaultContactList()Gets the default contact list.
checkState();
return mDefaultContactList;
|
public synchronized int | getState()Get the state of the ContactListManager
return mState;
|
public synchronized SubscriptionRequestListener | getSubscriptionRequestListener()
return mSubscriptionRequestListener;
|
public boolean | isBlocked(Contact contact)Checks if a contact is blocked.
return isBlocked(contact.getAddress().getFullName());
|
public synchronized boolean | isBlocked(java.lang.String address)Checks if a contact is blocked.
if(mState < BLOCKED_LIST_LOADED) {
throw new ImException(ImErrorInfo.ILLEGAL_CONTACT_LIST_MANAGER_STATE,
"Blocked list hasn't been loaded");
}
for(Contact c : mBlockedList) {
if(c.getAddress().getFullName().equals(address)){
return true;
}
}
return false;
|
public abstract void | loadContactListsAsync()Load the contact lists from the server. This method will normally called
after the user logged in to get the initial/saved contact lists from
server. After called once, this method should not be called again.
|
public abstract java.lang.String | normalizeAddress(java.lang.String address)
|
protected void | notifyBlockContact(Contact contact, boolean blocked)Notify that a contact has been blocked/unblocked.
synchronized (this) {
if (blocked) {
mBlockedList.add(contact);
String addr = contact.getAddress().getFullName();
mBlockPending.remove(addr);
} else {
mBlockedList.remove(contact);
}
}
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(blocked ? ContactListListener.CONTACT_BLOCKED
: ContactListListener.CONTACT_UNBLOCKED, null, contact);
}
|
protected void | notifyContactError(int type, ImErrorInfo error, java.lang.String listName, Contact contact)Notify that a contact list related error has been raised.
if (type == ContactListListener.ERROR_REMOVING_CONTACT) {
mDeletePending.remove(contact);
} else if (type == ContactListListener.ERROR_BLOCKING_CONTACT) {
mBlockPending.remove(contact.getAddress().getFullName());
}
for (ContactListListener listener : mContactListListeners) {
listener.onContactError(type, error, listName, contact);
}
|
protected void | notifyContactListCreated(ContactList list)Notify that a contact list has been created.
synchronized (this) {
if (list.isDefault()) {
for (ContactList l : mContactLists) {
l.setDefault(false);
}
mDefaultContactList = list;
}
mContactLists.add(list);
}
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(ContactListListener.LIST_CREATED,
list, null);
}
|
protected void | notifyContactListDeleted(ContactList list)Notify that a contact list has been deleted
synchronized(this) {
mContactLists.remove(list);
if (list.isDefault() && mContactLists.size() > 0) {
mContactLists.get(0).setDefault(true);
}
}
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(ContactListListener.LIST_DELETED,
list, null);
}
|
protected void | notifyContactListLoaded(ContactList list)Notify that a contact list has been loaded
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(ContactListListener.LIST_LOADED,
list, null);
}
|
protected void | notifyContactListNameUpdated(ContactList list, java.lang.String name)Notify that the name of the specified contact list has been updated.
list.mName = name;
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(ContactListListener.LIST_RENAMED,
list, null);
}
|
protected void | notifyContactListUpdated(ContactList list, int type, Contact contact)Notify that a contact has been added to or removed from a list.
synchronized (this) {
if (type == ContactListListener.LIST_CONTACT_ADDED) {
list.insertToCache(contact);
} else if (type == ContactListListener.LIST_CONTACT_REMOVED) {
list.removeFromCache(contact);
mDeletePending.remove(contact);
}
}
for (ContactListListener listener : mContactListListeners) {
listener.onContactChange(type, list, contact);
}
|
protected void | notifyContactListsLoaded()Notify that all contact lists has been loaded
setState(LISTS_LOADED);
for (ContactListListener listener : mContactListListeners) {
listener.onAllContactListsLoaded();
}
|
protected void | notifyContactsPresenceUpdated(Contact[] contacts)Notify that the presence of the contact has been updated
for (ContactListListener listener : mContactListListeners) {
listener.onContactsPresenceUpdate(contacts);
}
|
protected void | removeContactFromListAsync(Contact contact, ContactList list)
checkState();
if (mDeletePending.contains(contact)) {
return;
}
doRemoveContactFromListAsync(contact, list);
|
public synchronized void | removeContactListListener(ContactListListener listener)Removes a listener from this manager.
mContactListListeners.remove(listener);
|
protected abstract void | setListNameAsync(java.lang.String name, ContactList list)
|
protected synchronized void | setState(int state)Set the state of the ContactListManager
if (state < LISTS_NOT_LOADED || state > LISTS_LOADED) {
throw new IllegalArgumentException();
}
mState = state;
|
public synchronized void | setSubscriptionRequestListener(SubscriptionRequestListener listener)Sets the SubscriptionRequestListener to the manager so that it will be notified
when a subscription request from another user is received.
mSubscriptionRequestListener = listener;
|
public void | unblockContactAsync(Contact contact)
unblockContactAsync(contact.getAddress().getFullName());
|
public void | unblockContactAsync(java.lang.String address)Unblock a certain contact. It will removes the contact from the blocked
list and allows the contact to send message or invitation to the client
again. If the contact is not blocked on the client, this method does
nothing. Whether the unblocked contact will be added to the ContactList
it belongs before blocked or not depends on the underlying protocol
implementation.
checkState();
if(!isBlocked(address)) {
return;
}
doBlockContactAsync(address, false);
|