Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 import org.jivesoftware.smack.*; 2 import org.jivesoftware.smack.packet.*; 3 import org.jivesoftware.smack.util.StringUtils; 4 5 6 public final class PresenceChangeListener implements RosterListener{ 7 8 public void rosterModified(){ 9 WhisperIM.MainWindow.contactListPanel.tree.repaint(); 10 } 11 12 public void presenceChanged(String XMPPAddress){ 13 final String bareID=StringUtils.parseBareAddress(XMPPAddress); 15 final ContactListItem cli=(ContactListItem)WhisperIM.MainWindow.Contacts.get("jabber"+bareID); 16 if(cli==null){ return; 18 } 19 final Presence p=WhisperIM.MainWindow.roster.getPresence(XMPPAddress); 20 cli.setPresence(p); 21 RosterEntry re=WhisperIM.MainWindow.roster.getEntry(XMPPAddress); 22 if(re!=null){ 23 cli.setSubscription(re.getType()); 24 } 25 final ChatPanel cp=(ChatPanel)WhisperIM.MainWindow.Chats.get("jabber"+bareID); 27 final String status; 28 if(p!=null){ 29 status=p.getStatus(); 30 } 31 else{ 32 status=""; 33 } 34 javax.swing.SwingUtilities.invokeLater(new Runnable (){ 35 public void run(){ 36 WhisperIM.MainWindow.statusLbl.setText(GUI.getTime()+" "+cli.toString()+" "+ContactListCellRenderer.presenceToString(p)); 37 if(cp!=null){ 38 39 cp.announce((cp.Name+" : "+ContactListCellRenderer.presenceToString(p)+" ("+status+")"),GUI.getTime(p)); 40 } 41 } 42 }); 43 44 if(p!=null){ 45 if(p.getMode()==Presence.Mode.AVAILABLE || p.getMode()==Presence.Mode.CHAT){ 46 Alert.online(); 47 } 48 } 49 javax.swing.SwingUtilities.invokeLater(new Runnable (){ 50 public void run(){ 51 WhisperIM.MainWindow.contactListPanel.tree.repaint(); 52 } 53 }); 54 55 } 56 }
| Popular Tags
|