use of com.biglybt.core.devices.Device in project BiglyBT by BiglySoftware.
the class TrancodeUIUtils method getTranscodeTargets.
public static TranscodeTarget[] getTranscodeTargets() {
List<TranscodeTarget> result = new ArrayList<>();
if (!COConfigurationManager.getStringParameter("ui").equals("az2")) {
try {
DeviceManager dm = DeviceManagerFactory.getSingleton();
Device[] devices = dm.getDevices();
for (final Device d : devices) {
if (d instanceof DeviceMediaRenderer) {
final DeviceMediaRenderer dmr = (DeviceMediaRenderer) d;
boolean hide_device = d.isHidden();
if (COConfigurationManager.getBooleanParameter("device.sidebar.ui.rend.hidegeneric", true)) {
if (dmr.isNonSimple()) {
hide_device = true;
}
}
if (hide_device) {
continue;
}
result.add(new TranscodeTarget() {
@Override
public String getName() {
return (d.getName());
}
@Override
public String getID() {
return (d.getID());
}
@Override
public TranscodeProfile[] getProfiles() {
List<TranscodeProfile> ps = new ArrayList<>();
com.biglybt.core.devices.TranscodeProfile[] profs = dmr.getTranscodeProfiles();
if (profs.length == 0) {
if (dmr.getTranscodeRequirement() == com.biglybt.core.devices.TranscodeTarget.TRANSCODE_NEVER) {
ps.add(new TranscodeProfile() {
@Override
public String getUID() {
return (dmr.getID() + "/" + dmr.getBlankProfile().getName());
}
@Override
public String getName() {
return (MessageText.getString("devices.profile.direct"));
}
});
}
} else {
for (final com.biglybt.core.devices.TranscodeProfile prof : profs) {
ps.add(new TranscodeProfile() {
@Override
public String getUID() {
return (prof.getUID());
}
@Override
public String getName() {
return (prof.getName());
}
});
}
}
return (ps.toArray(new TranscodeProfile[ps.size()]));
}
});
}
}
} catch (Throwable e) {
Debug.out(e);
}
}
Collections.sort(result, new Comparator<TranscodeTarget>() {
@Override
public int compare(TranscodeTarget o1, TranscodeTarget o2) {
return (o1.getName().compareTo(o2.getName()));
}
});
return (result.toArray(new TranscodeTarget[result.size()]));
}
use of com.biglybt.core.devices.Device in project BiglyBT by BiglySoftware.
the class DeviceDriveManager method driveDetected.
@Override
public void driveDetected(final DriveDetectedInfo info) {
// System.out.println("DD " + info.getLocation() + " via " + Debug.getCompressedStackTrace());
async_dispatcher.dispatch(new AERunnable() {
@Override
public void runSupport() {
Map<String, Object> infoMap = info.getInfoMap();
boolean isWritableUSB = MapUtils.getMapBoolean(infoMap, "isWritableUSB", false);
File root = info.getLocation();
String sProdID = MapUtils.getMapString(infoMap, "ProductID", MapUtils.getMapString(infoMap, "Product Name", "")).trim();
String sVendor = MapUtils.getMapString(infoMap, "VendorID", MapUtils.getMapString(infoMap, "Vendor Name", "")).trim();
// models anyway, so including that wouldn't have helped anyway
if ((sVendor.equalsIgnoreCase("htc") && sProdID.equalsIgnoreCase("android phone")) || (sVendor.toLowerCase().contains("motorola") && sProdID.length() > 0) || sVendor.equalsIgnoreCase("samsung")) {
if (isWritableUSB && sVendor.equalsIgnoreCase("samsung")) {
// Samsungs that start with Y are MP3 players
// Samsungs that don't have a dash aren't smart phones (none that we know of anyway..)
// Fake not writable so we remove the device instead of adding it
isWritableUSB = !sProdID.startsWith("Y") && sProdID.matches(".*[A-Z]-.*");
}
String name = sProdID.startsWith(sVendor) ? "" : sVendor;
if (sVendor.length() > 0) {
name += " ";
}
name += sProdID;
String id = "android.";
id += sProdID.replaceAll(" ", ".").toLowerCase();
if (sVendor.length() > 0) {
id += "." + sVendor.replaceAll(" ", ".").toLowerCase();
}
if (isWritableUSB) {
addDevice(name, id, root, new File(root, "videos"), true);
} else {
// Fixup old bug where we were adding Samsung hard drives as devices
Device existingDevice = getDeviceMediaRendererByClassification(id);
if (existingDevice != null) {
existingDevice.remove();
}
}
return;
} else if (isWritableUSB && sVendor.toLowerCase().equals("rim")) {
String name = sVendor;
if (name.length() > 0) {
name += " ";
}
name += sProdID;
String id = "";
id += sProdID.replaceAll(" ", ".").toLowerCase();
if (sVendor.length() > 0) {
id += "." + sVendor.replaceAll(" ", ".").toLowerCase();
}
DeviceMediaRendererManual device = addDevice(name, id, root, new File(root, "videos"), false);
if (device != null) {
device.setImageID("bb");
}
return;
}
if (!isWritableUSB) {
return;
}
if (root.exists()) {
File[] folders = root.listFiles();
if (folders != null) {
Set<String> names = new HashSet<>();
for (File file : folders) {
names.add(file.getName().toLowerCase());
}
if (names.contains("psp") && names.contains("video")) {
addDevice("PSP", "sony.PSP", root, new File(root, "VIDEO"), false);
return;
}
}
}
String pid = MapUtils.getMapString(infoMap, "PID", null);
String vid = MapUtils.getMapString(infoMap, "VID", null);
if (pid != null && vid != null) {
String name = sProdID.startsWith(sVendor) ? "" : sVendor;
if (name.length() > 0) {
name += " ";
}
name += sProdID;
String id = "";
id += sProdID.replaceAll(" ", ".").toLowerCase();
id += "." + pid.toLowerCase();
if (sVendor.length() > 0) {
id += "." + sVendor.replaceAll(" ", ".").toLowerCase();
}
id += "." + vid.toLowerCase();
// cheap hack to detect the PSP when it has no psp or video dir
if (id.equals("\"psp\".ms.02d2.sony.054c") || id.equals("\"psp\".ms.0381.sony.054c")) {
if (addDevice("PSP", "sony.PSP", root, new File(root, "VIDEO"), false) != null) {
return;
}
}
addDevice(name, id, root, new File(root, "video"), true);
}
}
});
}
use of com.biglybt.core.devices.Device in project BiglyBT by BiglySoftware.
the class TranscodeChooser method createDeviceList.
private void createDeviceList(SWTSkinObjectContainer soDeviceList) {
Composite parent = soDeviceList.getComposite();
parent.setBackgroundMode(SWT.INHERIT_FORCE);
FormLayout layout = new FormLayout();
layout.marginLeft = 10;
layout.marginHeight = 15;
parent.setLayout(layout);
DeviceManager device_manager = DeviceManagerFactory.getSingleton();
Device[] devices = device_manager.getDevices();
if (devices.length == 0) {
noDevices();
return;
}
Arrays.sort(devices, new Comparator<Device>() {
@Override
public int compare(Device o1, Device o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
fontDevice = FontUtils.getFontWithHeight(parent.getFont(), null, 16, SWT.BOLD);
fontDeviceDesc = FontUtils.getFontWithHeight(parent.getFont(), null, 16, SWT.NONE);
/**
* PaintListener paintListener = new PaintListener() {
* public void paintControl(PaintEvent e) {
* Rectangle ca = ((Composite) e.widget).getClientArea();
* e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
* e.gc.setBackground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_LIGHT_SHADOW));
* e.gc.setAntialias(SWT.ON);
* e.gc.fillRoundRectangle(ca.x, ca.y, ca.width - 1, ca.height - 1, 10, 10);
* e.gc.drawRoundRectangle(ca.x, ca.y, ca.width - 1, ca.height - 1, 10, 10);
* }
* };
*/
boolean hide_generic = COConfigurationManager.getBooleanParameter(DeviceManagerUI.CONFIG_VIEW_HIDE_REND_GENERIC, true);
boolean show_only_tagged = COConfigurationManager.getBooleanParameter(DeviceManagerUI.CONFIG_VIEW_SHOW_ONLY_TAGGED, false);
int numDevices = 0;
Button lastButton = null;
for (Device device : devices) {
if (device.getType() != Device.DT_MEDIA_RENDERER || device.isHidden() || !(device instanceof DeviceMediaRenderer)) {
continue;
}
DeviceMediaRenderer renderer = (DeviceMediaRenderer) device;
if (hide_generic && renderer.isNonSimple()) {
continue;
}
if (show_only_tagged && !renderer.isTagged()) {
continue;
}
TranscodeTarget transcodeTarget = (TranscodeTarget) device;
if (transcodeTarget.getTranscodeProfiles().length == 0) {
if (transcodeTarget.getTranscodeRequirement() != TranscodeTarget.TRANSCODE_NEVER) {
continue;
}
}
String imageID = "image.sidebar.device." + DeviceManagerUI.getDeviceImageIDs(device)[0] + ".big";
lastButton = createDeviceButton(parent, device, device.getName(), device.getShortDescription(), imageID, lastButton);
numDevices++;
}
if (numDevices == 0) {
noDevices();
return;
}
SWTSkinObjectText soTitle = (SWTSkinObjectText) skin.getSkinObject("title");
if (soTitle != null) {
soTitle.setTextID("devices.choose.device.title");
}
SWTSkinObjectText soSubTitle = (SWTSkinObjectText) skin.getSkinObject("subtitle");
if (soSubTitle != null) {
soSubTitle.setText("");
}
SWTSkinObjectContainer soButtonBottomArea = (SWTSkinObjectContainer) skin.getSkinObject("button-bottom");
if (soButtonBottomArea != null) {
soButtonBottomArea.setVisible(true);
SWTSkinObjectButton soOk = (SWTSkinObjectButton) skin.getSkinObject("ok");
if (soOk != null) {
shell.setDefaultButton(soOk.getButton());
soOk.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
transcodeProfiles = selectedTranscodeTarget.getTranscodeProfiles();
createProfileList(soList);
}
});
}
SWTSkinObjectButton soCancel = (SWTSkinObjectButton) skin.getSkinObject("cancel");
if (soCancel != null) {
soCancel.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
shell.close();
}
});
}
}
if (soBottomContainer != null) {
soBottomContainer.setVisible(false);
}
// shell.pack();
Point computeSize = shell.computeSize(400, SWT.DEFAULT, true);
shell.setSize(computeSize);
shell.layout(true);
Utils.centerWindowRelativeTo(shell, mainShell);
}
use of com.biglybt.core.devices.Device in project BiglyBT by BiglySoftware.
the class DeviceTivoManager method startUp.
protected void startUp() {
plugin_interface = PluginInitializer.getDefaultInterface();
if (COConfigurationManager.getStringParameter("ui").equals("az2")) {
is_enabled = false;
} else {
is_enabled = COConfigurationManager.getBooleanParameter("devices.tivo.enabled", true);
}
uid = COConfigurationManager.getStringParameter("devices.tivo.uid", null);
if (uid == null) {
byte[] bytes = new byte[8];
RandomUtils.nextBytes(bytes);
uid = Base32.encode(bytes);
COConfigurationManager.setParameter("devices.tivo.uid", uid);
}
boolean found_tivo = false;
for (Device device : device_manager.getDevices()) {
if (device instanceof DeviceTivo) {
found_tivo = true;
break;
}
}
if (found_tivo || device_manager.getAutoSearch()) {
search(found_tivo, false);
}
}
use of com.biglybt.core.devices.Device in project BiglyBT by BiglySoftware.
the class ColumnTJ_CopiedToDevice method refresh.
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
Device d = tf.getDevice();
String value = null;
if (d instanceof DeviceMediaRenderer) {
DeviceMediaRenderer dmr = (DeviceMediaRenderer) d;
if (!(dmr.canCopyToDevice() || dmr.canCopyToFolder())) {
value = na_text;
}
}
if (value == null) {
value = DisplayFormatters.getYesNo(tf.isCopiedToDevice());
}
if (cell.setSortValue(value) || !cell.isValid()) {
cell.setText(value);
}
}
Aggregations