001 /* 002 Copyright (C) 2003 Adam Olsen 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU General Public License as published by 006 the Free Software Foundation; either version 1, or (at your option) 007 any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU General Public License for more details. 013 014 You should have received a copy of the GNU General Public License 015 along with this program; if not, write to the Free Software 016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 017 */ 018 019 package com.valhalla.jbother.jabber.smack; 020 021 import org.jivesoftware.smack.*; 022 import org.jivesoftware.smack.packet.*; 023 import com.valhalla.jbother.*; 024 import com.valhalla.jbother.jabber.*; 025 026 /** 027 * Listens for changes in the Roster 028 * @author Adam Olsen 029 * @version 1.0 030 */ 031 public class RosterListener implements org.jivesoftware.smack.RosterListener 032 { 033 /** 034 * Called when a roster entry's presence changes 035 */ 036 public void presenceChanged( String address ) 037 { 038 int loc = address.indexOf( "/" ); 039 040 if( loc != -1 ) 041 { 042 if( address.indexOf( "@" ) >= 0 ) address = address.substring( 0, loc ); 043 } 044 045 BuddyStatus buddy = BuddyList.getInstance().getBuddyStatus( address ); 046 BuddyList.getInstance().getBuddyListTree().addBuddy( buddy ); 047 } 048 049 /** 050 * Not used by this class 051 */ 052 public void rosterModified() { } 053 }