diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:37 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:37 +0200 |
commit | bb80d3feebdc9acc52e3f4ad24084d8425f043a2 (patch) | |
tree | 2084a84c39f159c6aea254775dc0880d52579d45 /src/camera/CameraTable.vala | |
parent | b26ff0798252a1a8072dd2c7a67f6205de9fde11 (diff) | |
parent | 31804433d72460cbe0a39f9f8ea5e76058d84cda (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/camera/CameraTable.vala')
-rw-r--r-- | src/camera/CameraTable.vala | 83 |
1 files changed, 1 insertions, 82 deletions
diff --git a/src/camera/CameraTable.vala b/src/camera/CameraTable.vala index 5f888ac..172c00a 100644 --- a/src/camera/CameraTable.vala +++ b/src/camera/CameraTable.vala @@ -4,20 +4,6 @@ * (version 2.1 or later). See the COPYING file in this distribution. */ -public class DiscoveredCamera { - public GPhoto.Camera gcamera; - public string uri; - public string display_name; - public string? icon; - - public DiscoveredCamera(GPhoto.Camera gcamera, string uri, string display_name, string? icon) { - this.gcamera = gcamera; - this.uri = uri; - this.display_name = display_name; - this.icon = icon; - } -} - public class CameraTable { private const int UPDATE_DELAY_MSEC = 1000; @@ -119,32 +105,6 @@ public class CameraTable { return "gphoto2://[%s]/".printf(port); } - public static string? get_port_path(string port) { - // Accepted format is usb:001,005 - return port.has_prefix("usb:") ? - "/dev/bus/usb/%s".printf(port.substring(4).replace(",", "/")) : null; - } - -#if HAVE_UDEV - private string? get_name_for_uuid(string uuid) { - foreach (Volume volume in volume_monitor.get_volumes()) { - if (volume.get_identifier(VolumeIdentifier.UUID) == uuid) { - return volume.get_name(); - } - } - return null; - } - - private string? get_icon_for_uuid(string uuid) { - foreach (Volume volume in volume_monitor.get_volumes()) { - if (volume.get_identifier(VolumeIdentifier.UUID) == uuid) { - return volume.get_symbolic_icon().to_string(); - } - } - return null; - } -#endif - private void update_camera_table() throws GPhotoError { // need to do this because virtual ports come and go in the USB world (and probably others) GPhoto.PortInfoList port_info_list; @@ -217,8 +177,6 @@ public class CameraTable { // add cameras which were not present before foreach (string port in detected_map.keys) { string name = detected_map.get(port); - string display_name = null; - string? icon = null; string uri = get_port_uri(port); if (camera_map.has_key(uri)) { @@ -227,41 +185,7 @@ public class CameraTable { continue; } - -#if HAVE_UDEV - // Get display name for camera. - string path = get_port_path(port); - if (null != path) { - GUdev.Device device = client.query_by_device_file(path); - string serial = device.get_property("ID_SERIAL_SHORT"); - if (null != serial) { - // Try to get the name and icon. - display_name = get_name_for_uuid(serial); - icon = get_icon_for_uuid(serial); - } - if (null == display_name) { - display_name = device.get_sysfs_attr("product"); - } - if (null == display_name) { - display_name = device.get_property("ID_MODEL"); - } - } -#endif - - if (port.has_prefix("disk:")) { - try { - var mount = File.new_for_path (port.substring(5)).find_enclosing_mount(); - var volume = mount.get_volume(); - // Translators: First %s is the name of camera as gotten from GPhoto, second is the GVolume name, e.g. Mass storage camera (510MB volume) - display_name = _("%s (%s)").printf (name, volume.get_name ()); - icon = volume.get_symbolic_icon().to_string(); - } catch (Error e) { } - } - if (null == display_name) { - // Default to GPhoto detected name. - display_name = name; - } int index = port_info_list.lookup_path(port); if (index < 0) do_op((GPhoto.Result) index, "lookup port %s".printf(port)); @@ -283,14 +207,9 @@ public class CameraTable { do_op(abilities_list.get_abilities(index, out camera_abilities), "lookup camera abilities for %s".printf(name)); - GPhoto.Camera gcamera; - do_op(GPhoto.Camera.create(out gcamera), "create camera object for %s".printf(name)); - do_op(gcamera.set_abilities(camera_abilities), "set camera abilities for %s".printf(name)); - do_op(gcamera.set_port_info(port_info), "set port info for %s on %s".printf(name, port)); - debug("Adding to camera table: %s @ %s", name, port); - DiscoveredCamera camera = new DiscoveredCamera(gcamera, uri, display_name, icon); + var camera = new DiscoveredCamera(name, port, port_info, camera_abilities); camera_map.set(uri, camera); camera_added(camera); |