use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class TagUIUtils method checkTagSharing.
public static void checkTagSharing(boolean start_of_day) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
TagManager tm = TagManagerFactory.getTagManager();
if (start_of_day) {
if (COConfigurationManager.getBooleanParameter("tag.sharing.default.checked", false)) {
return;
}
COConfigurationManager.setParameter("tag.sharing.default.checked", true);
List<TagType> tag_types = tm.getTagTypes();
boolean prompt_required = false;
for (TagType tag_type : tag_types) {
List<Tag> tags = tag_type.getTags();
for (Tag tag : tags) {
if (tag.isPublic()) {
prompt_required = true;
}
}
}
if (!prompt_required) {
return;
}
}
String title = MessageText.getString("tag.sharing.enable.title");
String text = MessageText.getString("tag.sharing.enable.text");
UIFunctionsUserPrompter prompter = uiFunctions.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
prompter.setRemember("tag.share.default", true, MessageText.getString("MessageBoxWindow.nomoreprompting"));
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean share = prompter.waitUntilClosed() == 0;
tm.setTagPublicDefault(share);
}
}
use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class PluginUtils method installJavaScriptPlugin.
public static void installJavaScriptPlugin() {
synchronized (PluginUtils.class) {
if (js_plugin_installing) {
return;
}
js_plugin_installing = true;
}
boolean installing = false;
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
return;
}
if (!Constants.isJava8OrHigher) {
String title = MessageText.getString("azjscripter.install.fail.jver");
String text = MessageText.getString("azjscripter.install.fail.jver.text");
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.ok") }, 0);
prompter.setAutoCloseInMS(0);
prompter.open(null);
}
String title = MessageText.getString("azjscripter.install");
String text = MessageText.getString("azjscripter.install.text");
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
String remember_id = "azjscripter.install.remember.id";
if (remember_id != null) {
prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
}
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean install = prompter.waitUntilClosed() == 0;
if (install) {
uif.installPlugin("azjscripter", "azjscripter.install", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
try {
} finally {
synchronized (PluginUtils.class) {
js_plugin_installing = false;
}
}
}
});
installing = true;
} else {
}
return;
} finally {
if (!installing) {
synchronized (PluginUtils.class) {
js_plugin_installing = false;
}
}
}
}
use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class Utils method installTorBrowser.
private static boolean installTorBrowser(String remember_id, final boolean[] install_outcome, final Runnable callback) {
synchronized (pending_ext_urls) {
if (tb_installing) {
Debug.out("Tor Browser already installing");
return (false);
}
tb_installing = true;
}
boolean installing = false;
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
Debug.out("UIFunctions unavailable - can't install plugin");
return (false);
}
String title = MessageText.getString("aznettorbrowser.install");
String text = MessageText.getString("aznettorbrowser.install.text");
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
if (remember_id != null) {
prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
}
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean install = prompter.waitUntilClosed() == 0;
if (install) {
uif.installPlugin("aznettorbrowser", "aznettorbrowser.install", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
try {
if (callback != null) {
if (result instanceof Boolean) {
install_outcome[0] = (Boolean) result;
}
callback.run();
}
} finally {
synchronized (pending_ext_urls) {
tb_installing = false;
}
}
}
});
installing = true;
} else {
Debug.out("Tor Browser install declined (either user reply or auto-remembered)");
}
return (install);
} finally {
if (!installing) {
synchronized (pending_ext_urls) {
tb_installing = false;
}
}
}
}
use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class BaseMdiEntry method importStandAlone.
public static SWTSkinObjectContainer importStandAlone(SWTSkinObjectContainer soParent, Map<String, Object> map, Runnable callback) {
String mdi_type = (String) map.get("mdi");
String skin_ref = (String) map.get("skin_ref");
String skin_id = (String) map.get("skin_id");
SWTSkin skin = SWTSkinFactory.lookupSkin(skin_id);
String parent_id = (String) map.get("parent_id");
String id = (String) map.get("id");
Object data_source = map.get("data_source");
if (data_source != null) {
if (data_source instanceof Map) {
Map<String, Object> ds_map = (Map<String, Object>) data_source;
if (ds_map != null) {
ds_map = new HashMap<String, Object>(ds_map);
ds_map.put("callback", callback);
}
data_source = ds_map == null ? null : DataSourceResolver.importDataSource(ds_map);
} else if (data_source instanceof List) {
List l = (List) data_source;
String type = (String) l.get(0);
Long value = (Long) l.get(1);
if (type.equals("i")) {
data_source = value.intValue();
}
}
}
int control_type = ((Number) map.get("control_type")).intValue();
Map<String, Object> el_map = (Map<String, Object>) map.get("event_listener");
UISWTViewEventListener event_listener = null;
if (el_map != null) {
try {
String class_name = (String) el_map.get("name");
if (class_name != null) {
Class<? extends UISWTViewCoreEventListenerEx> cla = (Class<? extends UISWTViewCoreEventListenerEx>) Class.forName(class_name);
List p_types = (List) el_map.get("p_types");
List p_vals = (List) el_map.get("p_vals");
if (p_types != null && !p_types.isEmpty()) {
List<Class> types = new ArrayList<>();
List<Object> args = new ArrayList<>();
for (int i = 0; i < p_types.size(); i++) {
String type = (String) p_types.get(i);
Object val = p_vals.get(i);
if (type.equals("bool")) {
types.add(boolean.class);
args.add(((Long) val) != 0);
} else if (type.equals("long")) {
types.add(long.class);
args.add((Long) val);
} else if (type.equals("string")) {
types.add(String.class);
args.add((String) val);
} else {
Debug.out("Unsupported type: " + type);
}
}
event_listener = cla.getConstructor(types.toArray(new Class<?>[types.size()])).newInstance(args.toArray(new Object[args.size()]));
} else {
event_listener = cla.newInstance();
}
} else {
String plugin_id = (String) el_map.get("plugin_id");
PluginInterface pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(plugin_id);
if (pi != null) {
String ipc_method = (String) el_map.get("ipc_method");
List p_types = (List) el_map.get("p_types");
List p_vals = (List) el_map.get("p_vals");
List<Object> args = new ArrayList<>();
if (p_types != null && !p_types.isEmpty()) {
List<Class> types = new ArrayList<>();
for (int i = 0; i < p_types.size(); i++) {
String type = (String) p_types.get(i);
Object val = p_vals.get(i);
if (type.equals("bool")) {
types.add(boolean.class);
args.add(((Long) val) != 0);
} else if (type.equals("long")) {
types.add(long.class);
args.add((Long) val);
} else if (type.equals("string")) {
types.add(String.class);
args.add((String) val);
} else {
Debug.out("Unsupported type: " + type);
}
}
}
event_listener = (UISWTViewEventListener) pi.getIPC().invoke(ipc_method, args.toArray(new Object[args.size()]));
} else {
boolean try_install = false;
synchronized (installing_pids) {
if (!installing_pids.contains(plugin_id)) {
installing_pids.add(plugin_id);
try_install = true;
}
}
if (try_install) {
boolean went_async = false;
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
String plugin_name = (String) el_map.get("plugin_name");
String remember_id = "basemdi.import.view.install." + plugin_id;
String title = MessageText.getString("plugin.required");
String text = MessageText.getString("plugin.required.info", new String[] { plugin_name });
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
if (remember_id != null) {
prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
}
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean install = prompter.waitUntilClosed() == 0;
if (install) {
went_async = true;
uif.installPlugin(plugin_id, "plugin.generic.install", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
try {
if (callback != null) {
if (result instanceof Boolean) {
if ((Boolean) result) {
callback.run();
}
}
}
} finally {
synchronized (installing_pids) {
installing_pids.remove(plugin_id);
}
}
}
});
}
} finally {
if (!went_async) {
synchronized (installing_pids) {
installing_pids.remove(plugin_id);
}
}
}
}
}
}
} catch (Throwable e) {
Debug.out(e);
}
}
if (mdi_type.equals("sidebar")) {
return (SideBarEntrySWT.buildStandAlone(soParent, skin_ref, skin, parent_id, id, data_source, control_type, null, event_listener, true));
} else {
return (TabbedEntry.buildStandAlone(soParent, skin_ref, skin, parent_id, id, data_source, control_type, null, event_listener, true));
}
}
use of com.biglybt.ui.UIFunctionsUserPrompter in project BiglyBT by BiglySoftware.
the class AEPluginProxyHandler method installTor.
private static boolean installTor(String extra_text, String remember_id, final boolean[] install_outcome, final Runnable callback) {
String decline_key = remember_id;
if (decline_key == null) {
decline_key = extra_text;
}
if (decline_key == null) {
decline_key = "generic";
}
synchronized (tor_install_lock) {
Long decline = declines.get(decline_key);
if (decline != null && SystemTime.getMonotonousTime() - decline < 60 * 1000) {
return (false);
}
if (tor_installing) {
Debug.out("Tor Helper already installing");
return (false);
}
tor_installing = true;
}
boolean installing = false;
boolean declined = false;
try {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
Debug.out("UIFunctions unavailable - can't install plugin");
return (false);
}
String title = MessageText.getString("aznettor.install");
String text = "";
if (extra_text != null) {
text = extra_text + "\n\n";
}
text += MessageText.getString("aznettor.install.text");
UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
if (remember_id != null) {
prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
}
prompter.setAutoCloseInMS(0);
prompter.open(null);
boolean install = prompter.waitUntilClosed() == 0;
if (install) {
installing = true;
uif.installPlugin("aznettor", "aznettor.install", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
try {
if (callback != null) {
if (result instanceof Boolean) {
install_outcome[0] = (Boolean) result;
}
callback.run();
}
} finally {
synchronized (tor_install_lock) {
tor_installing = false;
}
}
}
});
} else {
declined = true;
Debug.out("Tor Helper install declined (either user reply or auto-remembered)");
}
return (install);
} finally {
synchronized (tor_install_lock) {
if (!installing) {
tor_installing = false;
}
if (declined) {
declines.put(decline_key, SystemTime.getMonotonousTime());
}
}
}
}
Aggregations