1 /* 2 * Copyright (C) 2007 Esmertec AG. 3 * Copyright (C) 2007 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.im.engine; 19 20 /** 21 * Interfaces that allows the implementing classes to listen to contact list 22 * relative events. Listeners are registered with ContactListManager. 23 */ 24 public interface ContactListListener { 25 public static final int LIST_CREATED = 1; 26 public static final int LIST_DELETED = 2; 27 public static final int LIST_LOADED = 3; 28 public static final int LIST_RENAMED = 4; 29 public static final int LIST_CONTACT_ADDED = 5; 30 public static final int LIST_CONTACT_REMOVED = 6; 31 public static final int CONTACT_BLOCKED = 7; 32 public static final int CONTACT_UNBLOCKED = 8; 33 34 public static final int ERROR_CREATING_LIST = -1; 35 public static final int ERROR_DELETING_LIST = -2; 36 public static final int ERROR_RENAMING_LIST = -3; 37 38 public static final int ERROR_LOADING_LIST = -4; 39 public static final int ERROR_LOADING_BLOCK_LIST = -5; 40 41 public static final int ERROR_RETRIEVING_PRESENCE = -6; 42 43 public static final int ERROR_ADDING_CONTACT = -7; 44 public static final int ERROR_REMOVING_CONTACT = -8; 45 public static final int ERROR_BLOCKING_CONTACT = -9; 46 public static final int ERROR_UNBLOCKING_CONTACT = -10; 47 48 /** 49 * Called when: 50 * <ul> 51 * <li> a contact list has been created, deleted, renamed or loaded, or 52 * <li> a contact has been added to or removed from a list, or 53 * <li> a contact has been blocked or unblocked 54 * </ul> 55 * 56 * @param type one of the following values: 57 * <ul> 58 * <li>{@link #LIST_CREATED} list: the newly created list; 59 * contact: null 60 * <li>{@link #LIST_DELETED} list: the delete list; contact: null 61 * <li>{@link #LIST_LOADED} list: the newly loaded list; 62 * contact: null 63 * <li>{@link #LIST_RENAMED} list: the list renamed; contact: null 64 * <li>{@link #LIST_CONTACT_ADDED} list: the list to which the 65 * contact is added, contact: the added contact 66 * <li>{@link #LIST_CONTACT_REMOVED} list: the list from which the 67 * contact is removed, contact: the removed contact 68 * <li>{@link #CONTACT_BLOCKED} list: null, contact: the blocked 69 * contact 70 * <li>{@link #CONTACT_UNBLOCKED} list: null, contact: the unblocked 71 * contact 72 * </ul> 73 * @param list 74 * @param contact 75 */ onContactChange(int type, ContactList list, Contact contact)76 public void onContactChange(int type, ContactList list, Contact contact); 77 78 /** 79 * Called when all the contact lists (including the block list) and 80 * contacts have been loaded from the server. 81 */ onAllContactListsLoaded()82 public void onAllContactListsLoaded(); 83 84 /** 85 * Called when received one or more contacts' updated presence 86 * information from the server. 87 * 88 * @param contacts one or more contacts that have updated presence 89 * information. 90 */ onContactsPresenceUpdate(Contact[] contacts)91 public void onContactsPresenceUpdate(Contact[] contacts); 92 93 /** 94 * 95 * @param errorType one of the following values: 96 * <ul> 97 * <li>{@link #ERROR_CREATING_LIST} listName: the name of the list 98 * to be created; contact: null 99 * <li>{@link #ERROR_DELETING_LIST} listName: the name of the list 100 * to be deleted; contact: null 101 * <li>{@link #ERROR_LOADING_LIST} listName: the name of the list 102 * to be loaded, or null if the error occurred while fetching 103 * the list of contact lists; contact: null 104 * <li>{@link #ERROR_RENAMING_LIST} listName: the original name of 105 * the list to be renamed; contact: null 106 * <li>{@link #ERROR_LOADING_BLOCK_LIST} list: null; contact: null 107 * <li>{@link #ERROR_RETRIEVING_PRESENCE} 108 * <ul> 109 * <li>when retrieving presence for a list: listName: the name 110 * of the list, or null, depending on the implementation; 111 * contact: null 112 * <li>when retrieving presence for a contact: listName: the 113 * name of the list that the contact belongs to, or null, 114 * depending on the implementation; 115 * contact: the contact 116 * </ul> 117 * <li>{@link #ERROR_ADDING_CONTACT} listName: the name of the list 118 * to which the contact was to be added; 119 * contact: the contact to add 120 * <li>{@link #ERROR_REMOVING_CONTACT} listName: the name of the 121 * list from which the contact was to be removed; 122 * contact: the contact to remove 123 * <li>{@link #ERROR_BLOCKING_CONTACT} list: null; 124 * contact: the contact to block 125 * <li>{@link #ERROR_UNBLOCKING_CONTACT} list: null; 126 * contact: the contact to be unblocked 127 * </ul> 128 * @param error 129 * @param listName 130 * @param contact 131 */ onContactError(int errorType, ImErrorInfo error, String listName, Contact contact)132 public void onContactError(int errorType, ImErrorInfo error, 133 String listName, Contact contact); 134 } 135