⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwordwindow.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   PasswordWindow.java

package org.gudy.azureus2.ui.swt;

import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.io.PrintStream;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;

// Referenced classes of package org.gudy.azureus2.ui.swt:
//			Utils

public class PasswordWindow
{

	private Shell shell;
	private static boolean bOk;
	private static long lastSuccess = 0L;
	private static final long REMEMBER_SUCCESS_MS = 3000L;
	protected static AESemaphore class_sem = new AESemaphore("PasswordWindow");
	private static PasswordWindow window = null;

	public static boolean showPasswordWindow(Display display)
	{
		if (lastSuccess + 3000L >= SystemTime.getCurrentTime())
			return true;
		boolean bSWTThread = display.getThread() == Thread.currentThread();
		display.syncExec(new AERunnable(display, bSWTThread) {

			final Display val$display;
			final boolean val$bSWTThread;

			public void runSupport()
			{
				if (PasswordWindow.window == null)
					PasswordWindow.window = new PasswordWindow(display);
				else
					PasswordWindow.window.shell.forceActive();
				if (bSWTThread)
					PasswordWindow.window.run();
			}

			
			{
				display = display1;
				bSWTThread = flag;
				super();
			}
		});
		if (!bSWTThread)
			class_sem.reserve();
		lastSuccess = bOk ? SystemTime.getCurrentTime() : 0L;
		return bOk;
	}

	protected PasswordWindow(Display display)
	{
		bOk = false;
		shell = new Shell(display, 0x10060);
		shell.setText(MessageText.getString("PasswordWindow.title"));
		Utils.setShellIcon(shell);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		layout.makeColumnsEqualWidth = true;
		shell.setLayout(layout);
		Label label = new Label(shell, 0);
		label.setText(MessageText.getString("PasswordWindow.passwordprotected"));
		GridData gridData = new GridData(768);
		gridData.horizontalSpan = 2;
		label.setLayoutData(gridData);
		final Text password = new Text(shell, 2048);
		password.setEchoChar('*');
		gridData = new GridData(768);
		gridData.horizontalSpan = 2;
		password.setLayoutData(gridData);
		Button ok = new Button(shell, 8);
		ok.setText(MessageText.getString("Button.ok"));
		gridData = new GridData(64);
		gridData.widthHint = 70;
		ok.setLayoutData(gridData);
		shell.setDefaultButton(ok);
		ok.addListener(13, new Listener() {

			final Text val$password;
			final PasswordWindow this$0;

			public void handleEvent(Event event)
			{
				try
				{
					SHA1Hasher hasher = new SHA1Hasher();
					byte passwordText[] = password.getText().getBytes();
					byte encoded[] = hasher.calculateHash(passwordText);
					byte correct[] = COConfigurationManager.getByteParameter("Password", "".getBytes());
					boolean same = true;
					for (int i = 0; i < correct.length; i++)
						if (correct[i] != encoded[i])
							same = false;

					if (same)
					{
						PasswordWindow.bOk = same;
						shell.dispose();
					} else
					{
						close();
					}
				}
				catch (Exception e)
				{
					Debug.printStackTrace(e);
				}
			}

			
			{
				this$0 = PasswordWindow.this;
				password = text;
				super();
			}
		});
		Button cancel = new Button(shell, 8);
		cancel.setText(MessageText.getString("Button.cancel"));
		gridData = new GridData(64);
		gridData.widthHint = 70;
		cancel.setLayoutData(gridData);
		cancel.addListener(13, new Listener() {

			final PasswordWindow this$0;

			public void handleEvent(Event event)
			{
				close();
			}

			
			{
				this$0 = PasswordWindow.this;
				super();
			}
		});
		shell.addDisposeListener(new DisposeListener() {

			final PasswordWindow this$0;

			public void widgetDisposed(DisposeEvent arg0)
			{
				PasswordWindow.window = null;
				PasswordWindow.class_sem.releaseAllWaiters();
			}

			
			{
				this$0 = PasswordWindow.this;
				super();
			}
		});
		shell.addTraverseListener(new TraverseListener() {

			final PasswordWindow this$0;

			public void keyTraversed(TraverseEvent e)
			{
				if (e.detail == 2)
				{
					close();
					e.doit = false;
				}
			}

			
			{
				this$0 = PasswordWindow.this;
				super();
			}
		});
		shell.addListener(21, new Listener() {

			final PasswordWindow this$0;

			public void handleEvent(Event arg0)
			{
				close();
			}

			
			{
				this$0 = PasswordWindow.this;
				super();
			}
		});
		shell.pack();
		Utils.centreWindow(shell);
		shell.open();
	}

	protected void run()
	{
		do
		{
			if (shell.isDisposed())
				break;
			if (!shell.getDisplay().readAndDispatch())
				shell.getDisplay().sleep();
		} while (true);
	}

	private void close()
	{
		shell.dispose();
		if (Constants.isOSX)
		{
			UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
			if (uiFunctions != null)
			{
				Shell mainShell = uiFunctions.getMainShell();
				if (mainShell != null)
				{
					mainShell.setMinimized(true);
					mainShell.setVisible(true);
				}
			}
		}
	}

	public static void main(String args[])
	{
		Display display = new Display();
		(new Thread(new Runnable(display) {

			final Display val$display;

			public void run()
			{
				System.out.println((new StringBuilder()).append("2: ").append(PasswordWindow.showPasswordWindow(display)).toString());
			}

			
			{
				display = display1;
				super();
			}
		})).start();
		(new Thread(new Runnable(display) {

			final Display val$display;

			public void run()
			{
				display.syncExec(new Runnable() {

					final 8 this$0;

					public void run()
					{
						System.out.println((new StringBuilder()).append("3: ").append(PasswordWindow.showPasswordWindow(display)).toString());
					}

					
					{
						this$0 = 8.this;
						super();
					}
				});
			}

			
			{
				display = display1;
				super();
			}
		})).start();
		display.asyncExec(new Runnable(display) {

			final Display val$display;

			public void run()
			{
				System.out.println((new StringBuilder()).append("4: ").append(PasswordWindow.showPasswordWindow(display)).toString());
			}

			
			{
				display = display1;
				super();
			}
		});
		System.out.println((new StringBuilder()).append("1: ").append(showPasswordWindow(display)).toString());
	}






}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -