001/** 002 * 003 * Copyright 2003-2007 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smack; 019 020import org.jivesoftware.smack.packet.Presence; 021 022import java.util.Collection; 023 024/** 025 * A listener that is fired any time a roster is changed or the presence of 026 * a user in the roster is changed. 027 * 028 * @see Roster#addRosterListener(RosterListener) 029 * @author Matt Tucker 030 */ 031public interface RosterListener { 032 033 /** 034 * Called when roster entries are added. 035 * 036 * @param addresses the XMPP addresses of the contacts that have been added to the roster. 037 */ 038 public void entriesAdded(Collection<String> addresses); 039 040 /** 041 * Called when a roster entries are updated. 042 * 043 * @param addresses the XMPP addresses of the contacts whose entries have been updated. 044 */ 045 public void entriesUpdated(Collection<String> addresses); 046 047 /** 048 * Called when a roster entries are removed. 049 * 050 * @param addresses the XMPP addresses of the contacts that have been removed from the roster. 051 */ 052 public void entriesDeleted(Collection<String> addresses); 053 054 /** 055 * Called when the presence of a roster entry is changed. Care should be taken 056 * when using the presence data delivered as part of this event. Specifically, 057 * when a user account is online with multiple resources, the UI should account 058 * for that. For example, say a user is online with their desktop computer and 059 * mobile phone. If the user logs out of the IM client on their mobile phone, the 060 * user should not be shown in the roster (contact list) as offline since they're 061 * still available as another resource.<p> 062 * 063 * To get the current "best presence" for a user after the presence update, query the roster: 064 * <pre> 065 * String user = presence.getFrom(); 066 * Presence bestPresence = roster.getPresence(user); 067 * </pre> 068 * 069 * That will return the presence value for the user with the highest priority and 070 * availability. 071 * 072 * Note that this listener is triggered for presence (mode) changes only 073 * (e.g presence of types available and unavailable. Subscription-related 074 * presence packets will not cause this method to be called. 075 * 076 * @param presence the presence that changed. 077 * @see Roster#getPresence(String) 078 */ 079 public void presenceChanged(Presence presence); 080}