summaryrefslogtreecommitdiff
path: root/src/camera/CameraTable.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-08-05 08:00:12 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-08-05 08:00:12 +0200
commit8ae550d463720d5d1c0e253af29843ff15de1a54 (patch)
treeb6be28a7d546e7a174910ee83d6af555ed8860fa /src/camera/CameraTable.vala
parent709e2d6f5652ec90c194a4ec2b530bebc6f952cb (diff)
parent9df0619e4e581eac73e5f3b76d271f1fff192f81 (diff)
Merge branch 'release/debian/0.28.4-1'debian/0.28.4-1
Diffstat (limited to 'src/camera/CameraTable.vala')
-rw-r--r--src/camera/CameraTable.vala105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/camera/CameraTable.vala b/src/camera/CameraTable.vala
index 1636816..3df4ad6 100644
--- a/src/camera/CameraTable.vala
+++ b/src/camera/CameraTable.vala
@@ -108,100 +108,6 @@ public class CameraTable {
do_op(abilities_list.load(null_context), "load camera abilities list");
}
- private string[] get_all_usb_cameras() {
- string[] cameras = new string[0];
-
- GLib.List<GUdev.Device> device_list = client.query_by_subsystem(null);
- foreach (GUdev.Device device in device_list) {
- string device_file = device.get_device_file();
- if(
- // only keep devices that have a non-null device file and that
- // have both the ID_GPHOTO2 and GPHOTO2_DRIVER properties set
- (device_file != null) &&
- (device.has_property("ID_GPHOTO2")) &&
- (device.has_property("GPHOTO2_DRIVER"))
- ) {
- int camera_bus, camera_device;
- // extract the bus and device IDs from the device file string
- // TODO: is it safe to parse the absolute path or should we be
- // smarter and use a regex to only pick up the end of the path?
- if (device_file.scanf("/dev/bus/usb/%d/%d", out camera_bus, out camera_device) < 2) {
- critical("get_all_usb_cameras: Failed to scanf device file %s", device_file);
-
- continue;
- }
- string camera = "usb:%.3d,%.3d".printf(camera_bus, camera_device);
- debug("USB camera detected at %s", camera);
- cameras += camera;
- }
- }
-
- return cameras;
- }
-
- // USB (or libusb) is a funny beast; if only one USB device is present (i.e. the camera),
- // then a single camera is detected at port usb:. However, if multiple USB devices are
- // present (including non-cameras), then the first attached camera will be listed twice,
- // first at usb:, then at usb:xxx,yyy. If the usb: device is removed, another usb:xxx,yyy
- // device will lose its full-path name and be referred to as usb: only.
- //
- // This function gleans the full port name of a particular port, even if it's the unadorned
- // "usb:", by using GUdev.
- private bool usb_esp(int current_camera_count, string[] usb_cameras, string port,
- out string full_port) {
- // sanity
- assert(current_camera_count > 0);
-
- debug("USB ESP: current_camera_count=%d port=%s", current_camera_count, port);
-
- full_port = null;
-
- // if GPhoto detects one camera, and USB reports one camera, all is swell
- if (current_camera_count == 1 && usb_cameras.length == 1) {
- full_port = usb_cameras[0];
-
- debug("USB ESP: port=%s full_port=%s", port, full_port);
-
- return true;
- }
-
- // with more than one camera, skip the mirrored "usb:" port
- if (port == "usb:") {
- debug("USB ESP: Skipping %s", port);
-
- return false;
- }
-
- // parse out the bus and device ID
- int bus, device;
- if (port.scanf("usb:%d,%d", out bus, out device) < 2) {
- critical("USB ESP: Failed to scanf %s", port);
-
- return false;
- }
-
- foreach (string usb_camera in usb_cameras) {
- int camera_bus, camera_device;
- if (usb_camera.scanf("usb:%d,%d", out camera_bus, out camera_device) < 2) {
- critical("USB ESP: Failed to scanf %s", usb_camera);
-
- continue;
- }
-
- if ((bus == camera_bus) && (device == camera_device)) {
- full_port = port;
-
- debug("USB ESP: port=%s full_port=%s", port, full_port);
-
- return true;
- }
- }
-
- debug("USB ESP: No matching bus/device found for port=%s", port);
-
- return false;
- }
-
public static string get_port_uri(string port) {
return "gphoto2://[%s]/".printf(port);
}
@@ -242,9 +148,6 @@ public class CameraTable {
Gee.HashMap<string, string> detected_map = new Gee.HashMap<string, string>();
- // walk the USB chain and find all PTP cameras; this is necessary for usb_esp
- string[] usb_cameras = get_all_usb_cameras();
-
// go through the detected camera list and glean their ports
for (int ctr = 0; ctr < camera_list.count(); ctr++) {
string name;
@@ -255,14 +158,6 @@ public class CameraTable {
debug("Detected %d/%d %s @ %s", ctr + 1, camera_list.count(), name, port);
- // do some USB ESP, skipping ports that cannot be deduced
- if (port.has_prefix("usb:")) {
- string full_port;
- if (!usb_esp(camera_list.count(), usb_cameras, port, out full_port))
- continue;
-
- port = full_port;
- }
detected_map.set(port, name);
}