use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class DeviceManagerImpl method exportVuzeFile.
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);
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class CustomizationManagerImpl method main.
public static void main(String[] args) {
try {
VuzeFile vf = VuzeFileHandler.getSingleton().create();
Map config = new HashMap();
List list = new ArrayList();
list.add("trout");
list.add(45);
config.put("test.a10", "Hello mum");
config.put("test.a11", new Long(100));
config.put("test.a13", list);
Map map = new HashMap();
map.put("name", "My Proxy Settings");
map.put("settings", config);
map.put("restart", new Long(1));
vf.addComponent(VuzeFileComponent.COMP_TYPE_CONFIG_SETTINGS, map);
vf.write(new File("C:\\temp\\p_config.vuze"));
} catch (Throwable e) {
e.printStackTrace();
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class CustomizationManagerImpl method initialize.
@Override
public void initialize() {
synchronized (this) {
if (initialised) {
return;
}
initialised = true;
}
VuzeFileHandler.getSingleton().addProcessor(new VuzeFileProcessor() {
@Override
public void process(VuzeFile[] files, int expected_types) {
for (int i = 0; i < files.length; i++) {
VuzeFile vf = files[i];
VuzeFileComponent[] comps = vf.getComponents();
for (int j = 0; j < comps.length; j++) {
VuzeFileComponent comp = comps[j];
if (comp.getType() == VuzeFileComponent.COMP_TYPE_CUSTOMIZATION) {
try {
Map map = comp.getContent();
((CustomizationManagerImpl) getSingleton()).importCustomization(map);
comp.setProcessed();
} catch (Throwable e) {
Debug.printStackTrace(e);
}
} else if (comp.getType() == VuzeFileComponent.COMP_TYPE_CONFIG_SETTINGS) {
try {
Map map = comp.getContent();
String name = new String((byte[]) map.get("name"));
UIManager ui_manager = StaticUtilities.getUIManager(120 * 1000);
String details = MessageText.getString("custom.settings.import", new String[] { name });
long res = ui_manager.showMessageBox("custom.settings.import.title", "!" + details + "!", UIManagerEvent.MT_YES | UIManagerEvent.MT_NO);
if (res == UIManagerEvent.MT_YES) {
Map<String, Object> config = (Map<String, Object>) map.get("settings");
int num_set = 0;
for (Map.Entry<String, Object> entry : config.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof Long) {
COConfigurationManager.setParameter(key, (Long) value);
} else if (value instanceof byte[]) {
COConfigurationManager.setParameter(key, (byte[]) value);
} else if (value instanceof List) {
COConfigurationManager.setParameter(key, (List) value);
} else if (value instanceof Map) {
COConfigurationManager.setParameter(key, (Map) value);
} else {
Debug.out("Unsupported entry: " + key + "=" + value);
}
num_set++;
}
Long l_restart = (Long) map.get("restart");
boolean restart = l_restart != null && l_restart != 0;
String restart_text = "";
if (restart) {
restart_text = "\r\n\r\n" + MessageText.getString("ConfigView.section.security.restart.title");
}
String res_details = MessageText.getString("custom.settings.import.res", new String[] { String.valueOf(num_set), restart_text });
ui_manager.showMessageBox("custom.settings.import.res.title", "!" + res_details + "!", UIManagerEvent.MT_OK);
}
comp.setProcessed();
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
}
}
}
});
File user_dir = FileUtil.getUserFile("custom");
File app_dir = FileUtil.getApplicationFile("custom");
loadCustomizations(app_dir);
if (!user_dir.equals(app_dir)) {
loadCustomizations(user_dir);
}
String active = COConfigurationManager.getStringParameter("customization.active.name", "");
if (customization_file_map.get(active) == null) {
// hmm, its been deleted or not set yet. look for new ones
Iterator it = customization_file_map.keySet().iterator();
while (it.hasNext()) {
String name = (String) it.next();
final String version_key = "customization.name." + name + ".version";
String existing_version = COConfigurationManager.getStringParameter(version_key, "0");
if (existing_version.equals("0")) {
active = name;
String version = ((String[]) customization_file_map.get(name))[0];
COConfigurationManager.setParameter("customization.active.name", active);
COConfigurationManager.setParameter(version_key, version);
break;
}
}
}
synchronized (this) {
current_customization_name = active;
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class EngineImpl method getSubscription.
@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);
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class EngineImpl method exportToVuzeFile.
public VuzeFile exportToVuzeFile(boolean generic) throws IOException {
VuzeFile vf = VuzeFileHandler.getSingleton().create();
vf.addComponent(VuzeFileComponent.COMP_TYPE_METASEARCH_TEMPLATE, exportToBencodedMap(generic));
return (vf);
}
Aggregations