1 package rero.client.notify; 2 3 import java.util.*; 4 import java.util.regex.*; 5 6 import rero.util.*; 7 8 import rero.ircfw.*; 9 import rero.ircfw.interfaces.*; 10 11 import rero.net.*; 12 import rero.client.*; 13 14 15 public class NotifyUser extends Feature implements ChatListener, FrameworkConstants 16 { 17 protected String nickname; 18 protected String address; 19 20 protected long time; 21 protected boolean signedon; 22 23 24 public void signOff() 25 { 26 signedon = false; 27 time = System.currentTimeMillis(); 28 29 getCapabilities().injectEvent(":" + nickname + "!" + address + " SIGNOFF :signed off"); 30 } 31 32 public void signOn() 33 { 34 getCapabilities().addTemporaryListener(this); 35 getCapabilities().sendln("USERHOST " + nickname); 36 } 37 38 39 public String getNickname() 40 { 41 return nickname; 42 } 43 44 45 public String getAddress() 46 { 47 return address; 48 } 49 50 51 public boolean isSignedOn() 52 { 53 return signedon; 54 } 55 56 57 public long getTimeOnline() 58 { 59 return (System.currentTimeMillis() - time) / 1000; 60 } 61 62 public NotifyUser(String nick) 63 { 64 nickname = nick; 65 signedon = false; 66 } 67 68 public void init() 69 { 70 } 72 73 public int fireChatEvent (HashMap eventDescription) 74 { 75 address = (String )eventDescription.get("$address"); 76 77 signedon = true; 78 time = System.currentTimeMillis(); 79 80 getCapabilities().injectEvent(":" + nickname + "!" + address + " SIGNON :signed on"); 81 82 return EVENT_HALT | REMOVE_LISTENER; 83 } 84 85 public boolean isChatEvent(String eventId, HashMap eventDescription) 86 { 87 if (eventId.equals("302")) 88 { 89 String parms = (String )eventDescription.get("$nick"); 90 return parms.equals(nickname); 91 } 92 93 return false; 94 } 95 96 public String toString() 97 { 98 return nickname; 99 } 100 } 101 | Popular Tags |