protected String[] getAuthenticationDialog(final String realm, final String tracker) { final Display display = SWTThread.getInstance().getDisplay(); if (display.isDisposed()) { return (null); } final AESemaphore sem = new AESemaphore("SWTAuth"); final authDialog[] dialog = new authDialog[1]; TOTorrent torrent = TorrentUtils.getTLSTorrent(); final String torrent_name; if (torrent == null) { torrent_name = null; } else { torrent_name = TorrentUtils.getLocalisedName(torrent); } try { display.asyncExec( new AERunnable() { public void runSupport() { dialog[0] = new authDialog(sem, display, realm, tracker, torrent_name); } }); } catch (Throwable e) { Debug.printStackTrace(e); return (null); } sem.reserve(); String user = dialog[0].getUsername(); String pw = dialog[0].getPassword(); String persist = dialog[0].savePassword() ? "true" : "false"; if (user == null) { return (null); } return (new String[] {user, pw == null ? "" : pw, persist}); }
protected String[] getAuthenticationDialog(final String realm, final String location) { final Display display = SWTThread.getInstance().getDisplay(); if (display.isDisposed()) { return (null); } final AESemaphore sem = new AESemaphore("SWTAuth"); final authDialog[] dialog = new authDialog[1]; TOTorrent torrent = TorrentUtils.getTLSTorrent(); final boolean is_tracker; final String details; if (torrent == null) { is_tracker = false; details = TorrentUtils.getTLSDescription(); } else { details = TorrentUtils.getLocalisedName(torrent); is_tracker = true; } try { if (display.getThread() == Thread.currentThread()) { dialog[0] = new authDialog(sem, display, realm, is_tracker, location, details); while (!(display.isDisposed() || sem.isReleasedForever())) { if (!display.readAndDispatch()) { display.sleep(); } } if (display.isDisposed()) { return (null); } } else { display.asyncExec( new AERunnable() { public void runSupport() { dialog[0] = new authDialog(sem, display, realm, is_tracker, location, details); } }); } } catch (Throwable e) { Debug.printStackTrace(e); return (null); } sem.reserve(); String user = dialog[0].getUsername(); String pw = dialog[0].getPassword(); String persist = dialog[0].savePassword() ? "true" : "false"; if (user == null) { return (null); } return (new String[] {user, pw == null ? "" : pw, persist}); }