use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class TagManagerImpl method getVuzeFile.
public VuzeFile getVuzeFile(TagBase tag) {
if (tag.getTagType().getTagType() == TagType.TT_DOWNLOAD_MANUAL) {
TagWithState tws = (TagWithState) tag;
VuzeFile vf = VuzeFileHandler.getSingleton().create();
Map map = new HashMap();
Map tag_map = new HashMap();
tws.exportDetails(vf, tag_map, false);
Map conf = getConf(tag.getTagType(), tag, false);
map.put("tag", tag_map);
map.put("config", conf);
vf.addComponent(VuzeFileComponent.COMP_TYPE_TAG, map);
return (vf);
} else {
return (null);
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class TagManagerImpl method exportTags.
@Override
public VuzeFile exportTags(List<Tag> tags) {
VuzeFile vf = VuzeFileHandler.getSingleton().create();
for (Tag tag : tags) {
if (tag.getTagType().getTagType() == TagType.TT_DOWNLOAD_MANUAL) {
TagWithState tws = (TagWithState) tag;
Map map = new HashMap();
Map tag_map = new HashMap();
tws.exportDetails(vf, tag_map, false);
Map conf = getConf(tws.getTagType(), tws, false);
map.put("tag", tag_map);
map.put("config", conf);
vf.addComponent(VuzeFileComponent.COMP_TYPE_TAG, map);
}
}
return (vf);
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class NavigationHelper method main.
public static void main(String[] args) {
try {
VuzeFile vf = VuzeFileHandler.getSingleton().create();
Map content = new HashMap();
List commands = new ArrayList();
content.put("commands", commands);
// home tab
Map command1 = new HashMap();
commands.add(command1);
List l_args1 = new ArrayList();
// l_args1.add( SkinConstants.VIEWID_HOME_TAB );
command1.put("type", new Long(COMMAND_SWITCH_TO_TAB));
command1.put("args", l_args1);
// activity tab
Map command2 = new HashMap();
commands.add(command2);
List l_args2 = new ArrayList();
// l_args2.add( SkinConstants.VIEWID_ACTIVITY_TAB );
command2.put("type", new Long(COMMAND_SWITCH_TO_TAB));
command2.put("args", l_args2);
// check plugin available
Map command3 = new HashMap();
commands.add(command3);
List l_args3 = new ArrayList();
command3.put("type", new Long(COMMAND_CONDITION_CHECK));
command3.put("args", l_args3);
vf.addComponent(VuzeFileComponent.COMP_TYPE_V3_NAVIGATION, content);
vf.write(new File("C:\\temp\\v3ui.vuze"));
} catch (Throwable e) {
e.printStackTrace();
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class VuzeListener method handleMessage.
@Override
public void handleMessage(BrowserMessage message) {
String opid = message.getOperationId();
if (OP_LOAD_VUZE_FILE.equals(opid)) {
Map decodedMap = message.getDecodedMap();
String content = MapUtils.getMapString(decodedMap, "content", null);
if (content == null) {
throw new IllegalArgumentException("content missing");
} else {
byte[] bytes = Base32.decode(content);
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
VuzeFile vf = vfh.loadVuzeFile(bytes);
if (vf == null) {
throw new IllegalArgumentException("content invalid");
} else {
vfh.handleFiles(new VuzeFile[] { vf }, 0);
}
}
} else if (OP_RUN_SPEED_TEST.equals(opid)) {
SpeedTestSelector.runMLABTest(null);
} else if (OP_GET_MODE.equals(opid)) {
Map decodedMap = message.getDecodedMap();
String callback = MapUtils.getMapString(decodedMap, "callback", null);
if (callback != null) {
context.executeInBrowser(callback + "('" + "free" + "')");
} else {
message.debug("bad or no callback param");
}
} else {
throw new IllegalArgumentException("Unknown operation: " + opid);
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class TorrentOpener method openTorrentsFromStrings.
/**
* Adds torrents that are listed in torrents array. torrent array can
* can contain urls or file names. File names get pathPrefix appended.
* <P>
* will open url download dialog, or warning dialogs
*
* @since 5.0.0.1
*/
public static void openTorrentsFromStrings(TorrentOpenOptions optionsToClone, Shell parent, String pathPrefix, String[] torrents, String referrer, TorrentDownloaderCallBackInterface listener, boolean forceTorrentOptionsWindow) {
// if no torrents, but pathPrefix is directory, collect all torrents in it
if (torrents == null || torrents.length == 0) {
if (pathPrefix == null) {
return;
}
File path = new File(pathPrefix);
if (!path.isDirectory()) {
return;
}
List<String> newTorrents = new ArrayList<>();
File[] listFiles = path.listFiles();
for (File file : listFiles) {
try {
if (file.isFile() && TorrentUtils.isTorrentFile(file.getAbsolutePath())) {
newTorrents.add(file.getName());
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
if (newTorrents.size() == 0) {
return;
}
torrents = newTorrents.toArray(new String[0]);
}
// trim out any .vuze files
final VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
List<VuzeFile> vuze_files = new ArrayList<>();
for (String line : torrents) {
line = line.trim();
if (line.startsWith("\"") && line.endsWith("\"")) {
if (line.length() < 3) {
line = "";
} else {
line = line.substring(1, line.length() - 2);
}
}
TorrentOpenOptions torrentOptions = optionsToClone == null ? new TorrentOpenOptions() : new TorrentOpenOptions(optionsToClone);
File file = pathPrefix == null ? new File(line) : new File(pathPrefix, line);
if (file.exists()) {
try {
VuzeFile vf = vfh.loadVuzeFile(file);
if (vf != null) {
vuze_files.add(vf);
continue;
}
} catch (Throwable e) {
Debug.printStackTrace(e);
}
try {
File torrentDir = new File(COConfigurationManager.getDirectoryParameter("General_sDefaultTorrent_Directory"));
if (COConfigurationManager.getBooleanParameter("Save Torrent Files") && torrentDir.exists() && file.getParentFile().equals(torrentDir)) {
torrentOptions.setDeleteFileOnCancel(false);
}
} catch (Throwable e) {
}
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (TorrentOpener.mergeFileIntoTorrentInfo(file.getAbsolutePath(), null, torrentOptions)) {
uif.addTorrentWithOptions(forceTorrentOptionsWindow, torrentOptions);
}
continue;
}
final String url = UrlUtils.parseTextForURL(line, true);
if (url != null) {
// we used to load any URL, but that results in double loading..
if (VuzeFileHandler.isAcceptedVuzeFileName(url)) {
new AEThread2("VuzeLoader") {
@Override
public void run() {
try {
// XXX This takes a while..
VuzeFile vf = vfh.loadVuzeFile(url);
if (vf != null) {
vfh.handleFiles(new VuzeFile[] { vf }, VuzeFileComponent.COMP_TYPE_NONE);
}
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
}.start();
continue;
}
new FileDownloadWindow(parent, url, referrer, null, torrentOptions, listener);
}
}
if (vuze_files.size() > 0) {
VuzeFile[] vfs = new VuzeFile[vuze_files.size()];
vuze_files.toArray(vfs);
vfh.handleFiles(vfs, VuzeFileComponent.COMP_TYPE_NONE);
}
}
Aggregations