public Engine[] loadFromVuzeFile( VuzeFile vf ) { List<Engine> result = new ArrayList<>(); VuzeFileComponent[] comps = vf.getComponents(); for (int j=0;j<comps.length;j++){ VuzeFileComponent comp = comps[j]; if ( comp.getType() == VuzeFileComponent.COMP_TYPE_METASEARCH_TEMPLATE ){ try{ result.add( importEngine( comp.getContent(), false )); }catch( Throwable e ){ Debug.printStackTrace(e); } } } return(result.toArray(new Engine[result.size()])); }
public static void main( String[] args ) { try{ VuzeFile vf = VuzeFileHandler.getSingleton().create(); Map contents = new HashMap(); contents.put( "type", new Long( 1 )); contents.put( "term", "donkey" ); vf.addComponent( VuzeFileComponent.COMP_TYPE_METASEARCH_OPERATION, contents); vf.write( new File( "C:\\temp\\search.vuze" )); }catch( Throwable e ){ e.printStackTrace(); } } }
VuzeFileComponent[] components = vf.getComponents(); for (VuzeFileComponent component : components) { if (component.getType() == VuzeFileComponent.COMP_TYPE_PLUGIN) { input_stream = new ByteArrayInputStream(vf.exportToBytes()); } else { input_stream = rd.download();
VuzeFileComponent[] comps = vf.getComponents(); target.addComponent( comp.getType(), comp.getContent()); target.write( output_file );
vf.write( f ); Map vuze_map = vf.exportToMap(); Map torrent_map = temp.serialiseToMap();
@Override public void runSupport() { FileDialog dialog = new FileDialog( Utils.findAnyShell(), SWT.SYSTEM_MODAL | SWT.SAVE ); dialog.setFilterPath( TorrentOpener.getFilterPathData() ); dialog.setText(MessageText.getString("device.export.select.template.file")); dialog.setFilterExtensions( VuzeFileHandler.getVuzeFileFilterExtensions()); dialog.setFilterNames( VuzeFileHandler.getVuzeFileFilterExtensions()); String path = TorrentOpener.setFilterPathData( dialog.open()); if ( path != null ){ if ( !VuzeFileHandler.isAcceptedVuzeFileName( path )){ path = VuzeFileHandler.getVuzeFileName( path ); } try{ VuzeFile vf = device.getVuzeFile(); vf.write( new File( path )); }catch( Throwable e ){ Debug.out( e ); } } } });
@Override public Subscription getSubscription() { try{ VuzeFile vf = exportToVuzeFile( true ); byte[] bytes = vf.exportToBytes(); String url_str = "vuze://?body=" + new String( bytes, Constants.BYTE_ENCODING ); boolean is_anon = isAnonymous(); SubscriptionManager sub_man = SubscriptionManagerFactory.getSingleton(); Subscription subs = sub_man.createSingletonRSS( vf.getName() + ": " + getName() + " (v" + getVersion() + ")", new URL( url_str ), Integer.MAX_VALUE, is_anon ); return( subs ); }catch( Throwable e ){ Debug.out( e ); } return( null ); }
protected VuzeFile exportVuzeFile( DeviceImpl device ) throws IOException { VuzeFile vf = VuzeFileHandler.getSingleton().create(); Map map = new HashMap(); Map device_map = new HashMap(); map.put( "device", device_map ); device.exportToBEncodedMap( device_map, true ); vf.addComponent( VuzeFileComponent.COMP_TYPE_DEVICE, map ); return( vf ); }
manager.subscribeToSubscription( arg ); input_stream = new ByteArrayInputStream( VuzeFileHandler.getSingleton().create().exportToBytes());
@Override public void runSupport() { FileDialog dialog = new FileDialog( Utils.findAnyShell(), SWT.SYSTEM_MODAL | SWT.SAVE ); dialog.setFilterPath( TorrentOpener.getFilterPathData() ); dialog.setText(MessageText.getString("subscript.export.select.template.file")); dialog.setFilterExtensions(VuzeFileHandler.getVuzeFileFilterExtensions()); dialog.setFilterNames(VuzeFileHandler.getVuzeFileFilterExtensions()); String path = TorrentOpener.setFilterPathData( dialog.open()); if ( path != null ){ if ( !VuzeFileHandler.isAcceptedVuzeFileName( path )){ path = VuzeFileHandler.getVuzeFileName( path ); } try{ VuzeFile vf = subs.getVuzeFile(); vf.write( new File( path )); }catch( Throwable e ){ Debug.out( e ); } } } });
vf.addComponent( VuzeFileComponent.COMP_TYPE_TAG, map );
return( new ByteArrayInputStream( VuzeFileHandler.getSingleton().create().exportToBytes() ));
private File extractFromVuzeFile( File file ) throws PluginException { VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile(file); VuzeFileComponent[] comps = vf.getComponents(); for (int j=0;j<comps.length;j++){ VuzeFileComponent comp = comps[j]; if ( comp.getType() == VuzeFileComponent.COMP_TYPE_PLUGIN ){ try{ Map content = comp.getContent(); String id = new String((byte[])content.get( "id" ), "UTF-8" ); String version = new String((byte[])content.get( "version" ), "UTF-8" ); String suffix = ((Long)content.get( "is_jar" )).longValue()==1?"jar":"zip"; byte[] plugin_file = (byte[])content.get( "file" ); File temp_dir = AETemporaryFileHandler.createTempDir(); File temp_file = new File( temp_dir, id + "_" + version + "." + suffix ); FileUtil.copyFile( new ByteArrayInputStream( plugin_file ), temp_file ); return( temp_file ); }catch( Throwable e ){ throw( new PluginException( "Not a valid Vuze file", e )); } } } return( file ); }
@Override public void exportToVuzeFile( File target ) throws IOException { VuzeFile vf = VuzeFileHandler.getSingleton().create(); vf.addComponent( VuzeFileComponent.COMP_TYPE_METASEARCH_TEMPLATE, exportToBencodedMap()); vf.write( target ); }
@Override public void runSupport() { FileDialog dialog = new FileDialog( Utils.findAnyShell(), SWT.SYSTEM_MODAL | SWT.SAVE ); dialog.setFilterPath( TorrentOpener.getFilterPathData() ); dialog.setText(MessageText.getString("tag.export.select.template.file")); dialog.setFilterExtensions(VuzeFileHandler.getVuzeFileFilterExtensions()); dialog.setFilterNames(VuzeFileHandler.getVuzeFileFilterExtensions()); String path = TorrentOpener.setFilterPathData( dialog.open()); if ( path != null ){ if ( !VuzeFileHandler.isAcceptedVuzeFileName( path )){ path = VuzeFileHandler.getVuzeFileName( path ); } try{ VuzeFile vf = TagManagerFactory.getTagManager().exportTags( tags ); vf.write( new File( path )); }catch( Throwable e ){ Debug.out( e ); } } } });
public VuzeFile exportToVuzeFile( boolean generic ) throws IOException { VuzeFile vf = VuzeFileHandler.getSingleton().create(); vf.addComponent( VuzeFileComponent.COMP_TYPE_METASEARCH_TEMPLATE, exportToBencodedMap( generic )); return( vf ); }
VuzeFileComponent[] comps = vf.getComponents();
map.put( "restart", new Long( 1 )); vf.addComponent( VuzeFileComponent.COMP_TYPE_CONFIG_SETTINGS, map ); vf.write( new File( "C:\\temp\\p_config.vuze" ) );
vf.addComponent( VuzeFileComponent.COMP_TYPE_TAG, map );
VuzeFileComponent[] comps = vf.getComponents();