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

📄 donationwindow.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:   DonationWindow.java

package org.gudy.azureus2.ui.swt.donations;

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.AzureusCoreFactory;
import java.util.Locale;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.stats.transfer.OverallStats;
import org.gudy.azureus2.core3.stats.transfer.StatsFactory;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;

public class DonationWindow
{

	public static boolean DEBUG = System.getProperty("donations.debug", "0").equals("1");
	private static int reAskEveryHours = 96;
	private static int initialAskHours = 48;
	private static boolean pageLoadedOk = false;
	private static Shell shell = null;
	private static Browser browser;

	public DonationWindow()
	{
	}

	public static void checkForDonationPopup()
	{
		if (shell != null)
		{
			if (DEBUG)
				Utils.openMessageBox(null, 32, "Donations Test", "Already Open");
			return;
		}
		boolean alreadyDonated = COConfigurationManager.getBooleanParameter("donations.donated", false);
		if (alreadyDonated)
		{
			if (DEBUG)
				Utils.openMessageBox(null, 32, "Donations Test", "Already Donated! I like you.");
			return;
		}
		long upTime = StatsFactory.getStats().getTotalUpTime();
		int hours = (int)(upTime / 3600L);
		int nextAsk = COConfigurationManager.getIntParameter("donations.nextAskHours", 0);
		if (nextAsk == 0)
		{
			COConfigurationManager.setParameter("donations.nextAskHours", hours + initialAskHours);
			COConfigurationManager.save();
			if (DEBUG)
				Utils.openMessageBox(null, 32, "Donations Test", (new StringBuilder()).append("Newbie. You're active for ").append(hours).append(".").toString());
			return;
		}
		if (hours < nextAsk)
		{
			if (DEBUG)
				Utils.openMessageBox(null, 32, "Donations Test", (new StringBuilder()).append("Wait ").append(nextAsk - hours).append(".").toString());
			return;
		}
		long minDate = COConfigurationManager.getLongParameter("donations.minDate", 0L);
		if (minDate > 0L && minDate > SystemTime.getCurrentTime())
		{
			if (DEBUG)
				Utils.openMessageBox(null, 32, "Donation Test", (new StringBuilder()).append("Wait ").append((SystemTime.getCurrentTime() - minDate) / 1000L / 3600L / 24L).append(" days").toString());
			return;
		} else
		{
			COConfigurationManager.setParameter("donations.nextAskHours", hours + reAskEveryHours);
			COConfigurationManager.save();
			Utils.execSWTThread(new AERunnable() {

				public void runSupport()
				{
					DonationWindow.open(false);
				}

			});
			return;
		}
	}

	public static void open(boolean showNoLoad)
	{
		if (shell != null && !shell.isDisposed())
			return;
		Shell parentShell = Utils.findAnyShell();
		shell = ShellFactory.createShell(parentShell, 0x10820);
		shell.setLayout(new FillLayout());
		if (parentShell != null)
			parentShell.setCursor(shell.getDisplay().getSystemCursor(1));
		shell.addTraverseListener(new TraverseListener() {

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

		});
		shell.addShellListener(new ShellAdapter() {

			public void shellClosed(ShellEvent e)
			{
				e.doit = false;
			}

		});
		shell.addDisposeListener(new DisposeListener(parentShell) {

			final Shell val$parentShell;

			public void widgetDisposed(DisposeEvent e)
			{
				if (parentShell != null)
					parentShell.setCursor(e.display.getSystemCursor(0));
				DonationWindow.shell = null;
			}

			
			{
				parentShell = shell1;
				Object();
			}
		});
		try
		{
			browser = new Browser(shell, Utils.getInitialBrowserStyle(0));
		}
		catch (Throwable t)
		{
			shell.dispose();
			return;
		}
		browser.addTitleListener(new TitleListener() {

			public void changed(TitleEvent event)
			{
				DonationWindow.shell.setText(event.title);
			}

		});
		browser.addStatusTextListener(new StatusTextListener(parentShell) {

			String last;
			final Shell val$parentShell;

			public void changed(StatusTextEvent event)
			{
				String text = event.text.toLowerCase();
				if (last != null && last.equals(text))
					return;
				last = text;
				if (text.contains("page-loaded"))
				{
					DonationWindow.pageLoadedOk = true;
					COConfigurationManager.setParameter("donations.count", COConfigurationManager.getLongParameter("donations.count", 1L) + 1L);
					Utils.centreWindow(DonationWindow.shell);
					if (parentShell != null)
						parentShell.setCursor(DonationWindow.shell.getDisplay().getSystemCursor(0));
					DonationWindow.shell.open();
				} else
				if (text.contains("reset-ask-time"))
				{
					int time = DonationWindow.reAskEveryHours;
					String strings[] = text.split(" ");
					if (strings.length > 1)
						try
						{
							time = Integer.parseInt(strings[1]);
						}
						catch (Throwable t) { }
					DonationWindow.resetAskTime(time);
				} else
				if (text.contains("never-ask-again"))
					DonationWindow.neverAskAgain();
				else
				if (text.contains("close"))
					Utils.execSWTThreadLater(0, new AERunnable() {

						final 6 this$0;

						public void runSupport()
						{
							DonationWindow.shell.dispose();
						}

					
					{
						this$0 = 6.this;
						AERunnable();
					}
					});
				else
				if (text.startsWith("open-url"))
				{
					String url = event.text.substring(9);
					Utils.launch(url);
				} else
				if (text.startsWith("set-size"))
				{
					String strings[] = text.split(" ");
					if (strings.length > 2)
						try
						{
							int w = Integer.parseInt(strings[1]);
							int h = Integer.parseInt(strings[2]);
							Rectangle computeTrim = DonationWindow.shell.computeTrim(0, 0, w, h);
							DonationWindow.shell.setSize(computeTrim.width, computeTrim.height);
						}
						catch (Exception e) { }
				}
			}

			
			{
				parentShell = shell1;
				Object();
				last = null;
			}
		});
		browser.addLocationListener(new LocationListener() {

			public void changing(LocationEvent locationevent)
			{
			}

			public void changed(LocationEvent locationevent)
			{
			}

		});
		long upTime = StatsFactory.getStats().getTotalUpTime();
		int upHours = (int)(upTime / 3600L);
		String url = (new StringBuilder()).append("http://").append(System.getProperty("platform_address", "www.vuze.com")).append(":").append(System.getProperty("platform_port", "80")).append("/").append("donate.start?locale=").append(Locale.getDefault().toString()).append("&azv=").append("4.2.0.0").append("&count=").append(COConfigurationManager.getLongParameter("donations.count", 1L)).append("&uphours=").append(upHours).toString();
		SimpleTimer.addEvent("donation.pageload", SystemTime.getOffsetTime(5000L), new TimerEventPerformer(url, showNoLoad) {

			final String val$url;
			final boolean val$showNoLoad;

			public void perform(TimerEvent event)
			{
				if (!DonationWindow.pageLoadedOk)
					Utils.execSWTThread(new AERunnable() {

						final 8 this$0;

						public void runSupport()
						{
							Debug.out((new StringBuilder()).append("Page Didn't Load:").append(url).toString());
							DonationWindow.shell.dispose();
							if (showNoLoad)
								Utils.openMessageBox(DonationWindow.shell, 32, MessageText.getString("DonationWindow.noload.title"), MessageText.getString("DonationWindow.noload.text", new String[] {
									url
								}));
						}

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

			
			{
				url = s;
				showNoLoad = flag;
				Object();
			}
		});
		browser.setUrl(url);
	}

	protected static void neverAskAgain()
	{
		COConfigurationManager.setParameter("donations.donated", true);
		COConfigurationManager.save();
	}

	public static void resetAskTime()
	{
		resetAskTime(reAskEveryHours);
	}

	public static void resetAskTime(int askEveryHours)
	{
		long upTime = StatsFactory.getStats().getTotalUpTime();
		int hours = (int)(upTime / 3600L);
		int nextAsk = hours + askEveryHours;
		COConfigurationManager.setParameter("donations.nextAskHours", nextAsk);
		COConfigurationManager.setParameter("donations.lastVersion", "4.2.0.0");
		COConfigurationManager.save();
	}

	public static void updateMinDate()
	{
		COConfigurationManager.setParameter("donations.minDate", SystemTime.getOffsetTime(0x9a7ec800L));
		COConfigurationManager.save();
	}

	public static void setMinDate(long timestamp)
	{
		COConfigurationManager.setParameter("donations.minDate", timestamp);
		COConfigurationManager.save();
	}

	public static int getInitialAskHours()
	{
		return initialAskHours;
	}

	public static void setInitialAskHours(int i)
	{
		initialAskHours = i;
	}

	public static void main(String args[])
	{
		try
		{
			AzureusCoreFactory.create().start();
			open(true);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		do
		{
			Display d;
			for (d = Display.getDefault(); d.readAndDispatch(););
			d.sleep();
		} while (true);
	}






}

⌨️ 快捷键说明

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