📄 torrentopener.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: TorrentOpener.java
package org.gudy.azureus2.ui.swt.mainwindow;
import com.aelitis.azureus.core.*;
import com.aelitis.azureus.core.vuzefile.VuzeFile;
import com.aelitis.azureus.core.vuzefile.VuzeFileHandler;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.tracker.host.TRHost;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.*;
import org.gudy.azureus2.ui.swt.sharing.ShareUtils;
// Referenced classes of package org.gudy.azureus2.ui.swt.mainwindow:
// SWTThread
public class TorrentOpener
{
public TorrentOpener()
{
}
public static void openTorrent(String torrentFile)
{
openTorrentWindow(null, new String[] {
torrentFile
}, false);
}
public static void openTorrents(String torrentFiles[])
{
openTorrentWindow(null, torrentFiles, false);
}
public static void openTorrentWindow()
{
openTorrentWindow(null, null, false);
}
protected static void openTorrentsForTracking(String path, String fileNames[])
{
Utils.execSWTThread(new AERunnable(fileNames, path) {
final String val$fileNames[];
final String val$path;
public void runSupport()
{
Display display = SWTThread.getInstance().getDisplay();
AzureusCore azureus_core = AzureusCoreFactory.getSingleton();
if (display == null || display.isDisposed() || azureus_core == null)
{
return;
} else
{
(new AEThread(azureus_core) {
final AzureusCore val$azureus_core;
final 1 this$0;
public void runSupport()
{
for (int i = 0; i < fileNames.length; i++)
try
{
org.gudy.azureus2.core3.torrent.TOTorrent t = TorrentUtils.readFromFile(new File(path, fileNames[i]), true);
azureus_core.getTrackerHost().hostTorrent(t, true, true);
}
catch (Throwable e)
{
Logger.log(new LogAlert(false, (new StringBuilder()).append("Torrent open fails for '").append(path).append(File.separator).append(fileNames[i]).append("'").toString(), e));
}
}
{
this$0 = 1.this;
azureus_core = azureuscore;
super(x0);
}
}).start();
return;
}
}
{
fileNames = as;
path = s;
super();
}
});
}
public static void openTorrentTrackingOnly()
{
Utils.execSWTThread(new AERunnable() {
public void runSupport()
{
org.eclipse.swt.widgets.Shell shell = Utils.findAnyShell();
if (shell == null)
return;
FileDialog fDialog = new FileDialog(shell, 4098);
fDialog.setFilterPath(TorrentOpener.getFilterPathTorrent());
fDialog.setFilterExtensions(new String[] {
"*.torrent", "*.tor", Constants.FILE_WILDCARD
});
fDialog.setFilterNames(new String[] {
"*.torrent", "*.tor", Constants.FILE_WILDCARD
});
fDialog.setText(MessageText.getString("MainWindow.dialog.choose.file"));
String path = TorrentOpener.setFilterPathTorrent(fDialog.open());
if (path == null)
{
return;
} else
{
TorrentOpener.openTorrentsForTracking(path, fDialog.getFileNames());
return;
}
}
});
}
public static void openTorrentSimple()
{
Utils.execSWTThread(new AERunnable() {
public void runSupport()
{
org.eclipse.swt.widgets.Shell shell = Utils.findAnyShell();
if (shell == null)
return;
FileDialog fDialog = new FileDialog(shell, 4098);
fDialog.setFilterPath(TorrentOpener.getFilterPathTorrent());
fDialog.setFilterExtensions(new String[] {
"*.torrent", "*.tor", Constants.FILE_WILDCARD
});
fDialog.setFilterNames(new String[] {
"*.torrent", "*.tor", Constants.FILE_WILDCARD
});
fDialog.setText(MessageText.getString("MainWindow.dialog.choose.file"));
String path = TorrentOpener.setFilterPathTorrent(fDialog.open());
if (path == null)
{
return;
} else
{
TorrentOpener.openTorrentWindow(path, fDialog.getFileNames(), false);
return;
}
}
});
}
public static void openDroppedTorrents(AzureusCore azureus_core, DropTargetEvent event, boolean bAllowShareAdd)
{
if (event.data == null)
return;
boolean bOverrideToStopped = event.detail == 1;
if ((event.data instanceof String[]) || (event.data instanceof String))
{
String sourceNames[] = (event.data instanceof String[]) ? (String[])(String[])event.data : (new String[] {
(String)event.data
});
if (sourceNames == null)
event.detail = 0;
if (event.detail == 0)
return;
for (int i = 0; i < sourceNames.length; i++)
{
File source = new File(sourceNames[i]);
String sURL = UrlUtils.parseTextForURL(sourceNames[i], true);
if (sURL != null && !source.exists())
openTorrentWindow(null, new String[] {
sURL
}, bOverrideToStopped);
else
if (source.isFile())
(new AEThread2("asyncOpen", true, source, bAllowShareAdd, azureus_core, bOverrideToStopped) {
final File val$source;
final boolean val$bAllowShareAdd;
final AzureusCore val$azureus_core;
final boolean val$bOverrideToStopped;
public void run()
{
String filename = source.getAbsolutePath();
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
if (vfh.loadAndHandleVuzeFile(filename, 0) != null)
return;
try
{
if (!TorrentUtils.isTorrentFile(filename) && bAllowShareAdd)
{
Logger.log(new LogEvent(LogIDs.GUI, "openDroppedTorrents: file not a torrent file, sharing"));
ShareUtils.shareFile(azureus_core, filename);
} else
{
TorrentOpener.openTorrentWindow(null, new String[] {
filename
}, bOverrideToStopped);
}
}
catch (Exception e)
{
Logger.log(new LogAlert(true, (new StringBuilder()).append("Torrent open fails for '").append(filename).append("'").toString(), e));
}
}
{
source = file;
bAllowShareAdd = flag;
azureus_core = azureuscore;
bOverrideToStopped = flag1;
super(x0, x1);
}
}).start();
else
if (source.isDirectory())
{
String dir_name = source.getAbsolutePath();
if (!bAllowShareAdd)
{
openTorrentWindow(dir_name, null, bOverrideToStopped);
} else
{
String drop_action = COConfigurationManager.getStringParameter("config.style.dropdiraction");
if (drop_action.equals("1"))
ShareUtils.shareDir(azureus_core, dir_name);
else
if (drop_action.equals("2"))
ShareUtils.shareDirContents(azureus_core, dir_name, false);
else
if (drop_action.equals("3"))
ShareUtils.shareDirContents(azureus_core, dir_name, true);
else
openTorrentWindow(dir_name, null, bOverrideToStopped);
}
}
}
} else
if (event.data instanceof org.gudy.azureus2.ui.swt.URLTransfer.URLType)
openTorrentWindow(null, new String[] {
((org.gudy.azureus2.ui.swt.URLTransfer.URLType)event.data).linkURL
}, bOverrideToStopped);
}
public static String getFilterPathData()
{
String before = COConfigurationManager.getStringParameter("previous.filter.dir.data");
if (before != null && before.length() > 0)
return before;
String def = COConfigurationManager.getDirectoryParameter("Default save path");
return def;
IOException e;
e;
return "";
}
public static String getFilterPathTorrent()
{
String before = COConfigurationManager.getStringParameter("previous.filter.dir.torrent");
if (before != null && before.length() > 0)
return before;
else
return COConfigurationManager.getStringParameter("General_sDefaultTorrent_Directory");
}
public static String setFilterPathData(String path)
{
if (path != null && path.length() > 0)
{
File test = new File(path);
if (!test.isDirectory())
test = test.getParentFile();
String now = "";
if (test != null)
now = test.getAbsolutePath();
String before = COConfigurationManager.getStringParameter("previous.filter.dir.data");
if (before == null || before.length() == 0 || !before.equals(now))
{
COConfigurationManager.setParameter("previous.filter.dir.data", now);
COConfigurationManager.save();
}
}
return path;
}
public static String setFilterPathTorrent(String path)
{
if (path != null && path.length() > 0)
{
File test = new File(path);
if (!test.isDirectory())
test = test.getParentFile();
String now = "";
if (test != null)
now = test.getAbsolutePath();
String before = COConfigurationManager.getStringParameter("previous.filter.dir.torrent");
if (before == null || before.length() == 0 || !before.equals(now))
{
COConfigurationManager.setParameter("previous.filter.dir.torrent", now);
COConfigurationManager.save();
}
return now;
} else
{
return path;
}
}
private static void openTorrentWindow(String path, String torrents[], boolean bOverrideStartModeToStopped)
{
(new AEThread2("openTorrentWindow", true, path, torrents, bOverrideStartModeToStopped) {
final String val$path;
final String val$torrents[];
final boolean val$bOverrideStartModeToStopped;
public void run()
{
TorrentOpener._openTorrentWindow(path, torrents, bOverrideStartModeToStopped);
}
{
path = s;
torrents = as;
bOverrideStartModeToStopped = flag;
super(x0, x1);
}
}).start();
}
private static void _openTorrentWindow(String path, String torrents[], boolean bOverrideStartModeToStopped)
{
if (torrents != null && torrents.length > 0)
{
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
List non_vuze_files = new ArrayList();
List vuze_files = new ArrayList();
for (int i = 0; i < torrents.length; i++)
{
String torrent = torrents[i];
try
{
VuzeFile vf = vfh.loadVuzeFile(torrent);
if (vf == null)
non_vuze_files.add(torrent);
else
vuze_files.add(vf);
continue;
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
non_vuze_files.add(torrent);
}
if (vuze_files.size() > 0)
{
VuzeFile vfs[] = new VuzeFile[vuze_files.size()];
vuze_files.toArray(vfs);
vfh.handleFiles(vfs, 0);
}
if (non_vuze_files.size() == 0 && vuze_files.size() > 0)
return;
String t[] = new String[non_vuze_files.size()];
non_vuze_files.toArray(t);
torrents = t;
}
String f_torrents[] = torrents;
Utils.execSWTThread(new AERunnable(path, f_torrents, bOverrideStartModeToStopped) {
final String val$path;
final String val$f_torrents[];
final boolean val$bOverrideStartModeToStopped;
public void runSupport()
{
org.eclipse.swt.widgets.Shell shell = Utils.findAnyShell();
AzureusCore core = AzureusCoreFactory.getSingleton();
org.gudy.azureus2.core3.global.GlobalManager gm = null;
try
{
gm = core.getGlobalManager();
}
catch (AzureusCoreException e) { }
if (gm == null)
{
core.addLifecycleListener(new AzureusCoreLifecycleAdapter() {
final 6 this$0;
public void componentCreated(AzureusCore core, AzureusCoreComponent component)
{
if (component instanceof UIFunctionsSWT)
TorrentOpener.openTorrentWindow(path, f_torrents, bOverrideStartModeToStopped);
}
{
this$0 = 6.this;
super();
}
});
return;
}
if (shell == null)
{
Debug.out("openTorrentWindow().. no shell");
return;
} else
{
OpenTorrentWindow.invoke(shell, gm, path, f_torrents, bOverrideStartModeToStopped, false, false);
return;
}
}
{
path = s;
f_torrents = as;
bOverrideStartModeToStopped = flag;
super();
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -