1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.opennap.net.msg.server;
21
22 import org.xnap.plugin.opennap.user.OpenNapUser;
23 import org.xnap.util.QuotedStringTokenizer;
24
25 public class WhoisResponseMessage extends ServerMessage {
26
27
28
29 public static final int TYPE = 604;
30
31
32
33 public String nick;
34 public String userLevel;
35 public int connectDuration;
36 public String channels;
37 public String status;
38 public int sharedCount;
39 public int downloadCount;
40 public int uploadCount;
41 public int linkSpeed;
42 public String clientInfo;
43 public int totalDownload;
44 public int totalUploads;
45 public String ip;
46 public int connectingPort;
47 public int dataPort;
48 public String email;
49 public boolean extendedInfo = false;
50
51
52
53 public WhoisResponseMessage(String data) throws InvalidMessageException
54 {
55 super(TYPE, data, 10);
56 }
57
58
59
60 protected void parse(QuotedStringTokenizer t)
61 {
62 nick = t.nextToken();
63 userLevel = t.nextToken();
64 connectDuration = (new Long(t.nextToken())).intValue();
65 channels = t.nextToken();
66 status = t.nextToken();
67 sharedCount = Integer.parseInt(t.nextToken());
68 downloadCount = Integer.parseInt(t.nextToken());
69 uploadCount = Integer.parseInt(t.nextToken());
70 linkSpeed = Integer.parseInt(t.nextToken());
71 clientInfo = t.nextToken();
72
73 if (t.countTokens() >= 6) {
74 extendedInfo = true;
75 totalDownload = Integer.parseInt(t.nextToken());
76 totalUploads = Integer.parseInt(t.nextToken());
77 ip = t.nextToken();
78 connectingPort = Integer.parseInt(t.nextToken());
79 dataPort = Integer.parseInt(t.nextToken());
80 email = t.nextToken();
81 }
82 }
83
84 public void received()
85 {
86 OpenNapUser u = server.getUser(nick);
87 u.setClientInfo(clientInfo);
88 u.setConnectDuration(connectDuration);
89 u.setDownloadCount(downloadCount);
90 u.setFileCount(sharedCount);
91 u.setHost(ip);
92 u.setLevel(userLevel);
93 u.setLinkSpeed(linkSpeed);
94 u.setStatus(status);
95 u.setUploadCount(uploadCount);
96
97 u.notifyWhoisReceived();
98
99 StringBuffer sb = new StringBuffer();
100 sb.append("=== whois " + nick + " ===");
101 sb.append(nick);
102 sb.append("server: ");
103 sb.append(server);
104 sb.append("\nuser: ");
105 sb.append(nick);
106 sb.append("\nuser level: ");
107 sb.append(userLevel);
108 sb.append("\nconnect duration: ");
109 sb.append(connectDuration);
110 sb.append("\nchannels: ");
111 sb.append(channels);
112 sb.append("\nstatus: ");
113 sb.append(status);
114 sb.append("\nshared: ");
115 sb.append(sharedCount);
116 sb.append("\ndownloads: ");
117 sb.append(downloadCount);
118 sb.append("\nuploads: ");
119 sb.append(uploadCount);
120 sb.append("\nlink speed: ");
121 sb.append(linkSpeed);
122 sb.append("\nclient: ");
123 sb.append(clientInfo);
124
125
126 }
127
128 }