return;
} else if (cmd.getCommand().equalsIgnoreCase("STATS")) {
Vector subCommands = cmd.getSubCommands();
stats.clear();
for (int i = 0; i < subCommands.size(); i++) {
Command proto = (Command)subCommands.get(i);
long files = -1;
long users = -1;
float size = -1;
try {
files = Long.parseLong((String) proto.getKey("files"));
} catch (NumberFormatException e) {
}
try {
users = Long.parseLong((String) proto.getKey("users"));
} catch (NumberFormatException e) {
}
try {
size = Float.parseFloat((String) proto.getKey("size"));
} catch (NumberFormatException e) {
}
if (!proto.getCommand().equalsIgnoreCase("gift")) {
stats.put(proto.getCommand(),
files + XNap.tr("Files", 1, 0) + ", " + users +
XNap.tr("Users", 1, 0) + ", " + size + " GB");
}
StatsEvent nsevt = new StatsEvent(proto.getCommand());
nsevt.setFiles(files);
nsevt.setUsers(users);
nsevt.setSize(size);
fireEvent(nsevt);
}
return;
} else if (cmd.getCommand().equalsIgnoreCase("ITEM")) {
// if share item
if (cmd.getCommandArgument() == null) {
if (cmd.hasKeys()) {
ShareItemEvent se = new ShareItemEvent();
se.setPath(cmd.getKey("path"));
try {
se.setSize(Long.parseLong(cmd.getKey("size")));
} catch (Exception e) {
}
se.setMime(cmd.getKey("mime"));
se.setHash(cmd.getKey("hash"));
Command meta = cmd.getSubCommandByName("META");
if (meta != null) {
Enumeration keys = meta.getKeys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
se.addMetaItem(key, meta.getKey(key));
}
}
fireEvent(se);
} else {
fireEvent(new SharesControlEvent(ControlEvent.FINISHED));
}
} else {
if (cmd.hasKeys()) {
// search item
long size = -1;
try {
size = Long.parseLong(cmd.getKey("size"));
} catch (Exception e) {
}
int score = 1;
try {
score = Integer.parseInt(cmd.getKey("availability"));
} catch (Exception e) {
}
Hashtable meta = new Hashtable();
Command metaCmd = cmd.getSubCommandByName("META");
if (metaCmd != null) {
Enumeration keys = metaCmd.getKeys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
meta.put(key, metaCmd.getKey(key));
}
}
IUser user = new User(cmd.getKey("user"));
SearchResult sr = new SearchResult(size, user,