package NET.worlds.console; import NET.worlds.network.Cache; import NET.worlds.network.CacheFile; import NET.worlds.network.URL; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.Label; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.text.MessageFormat; import java.util.Vector; class PersonalInfoDownload extends OkCancelDialog implements Runnable { private static final long serialVersionUID = -198244581766521022L; private String name; private CacheFile cf; private static Font font = new Font(Console.message("MenuFont"), 0, 12); public PersonalInfoDownload(String name, Console console) { super(Console.getFrame(), null, Console.message("Downloading2"), Console.message("Cancel"), null, false); this.name = name; String cfS = console.getScriptServer() + "profile" + Console.message(".pl") + "?" + name; this.cf = Cache.getFile(URL.make(cfS)); if (Console.wasHttpNoSuchFile(cfS)) { this.cf = Cache.getFile(URL.make(console.getScriptServer() + "profile.pl?" + name)); } this.setFont(new Font(Console.message("FriendsFont"), 0, 12)); Thread t = new Thread(this); t.setDaemon(true); t.start(); } @Override protected void build() { GridBagConstraints c = new GridBagConstraints(); c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = 0; Object[] arguments = new Object[]{new String(this.name)}; Label lDown = new Label(MessageFormat.format(Console.message("Downloading"), arguments)); lDown.setFont(font); this.add(this.gbag, lDown, c); Label lWait = new Label(Console.message("Please-wait")); lWait.setFont(font); this.add(this.gbag, lWait, c); super.build(); } @Override public void run() { this.readySetGo(); this.cf.waitUntilLoaded(); if (this.cf.isActive()) { this.done(true); if (this.cf.error()) { Object[] arguments = new Object[]{new String(this.name)}; new OkCancelDialog( Console.getFrame(), null, Console.message("Error"), null, Console.message("OK"), MessageFormat.format(Console.message("Error-down"), arguments), false ); System.out.println("Error downloading personal info for " + this.name); } else { Vector data = new Vector(); DataInputStream in = null; try { in = new DataInputStream(new FileInputStream(this.cf.getLocalName())); String line; while ((line = in.readLine()) != null) { data.addElement(line); } new PersonalInfoDialog(this.name, data); } catch (FileNotFoundException var14) { } catch (IOException var15) { } finally { try { if (in != null) { in.close(); } } catch (IOException var13) { } } } this.cf.close(); } } }