Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_abilities_list_detect ( CameraAbilitiesList list,
GPPortInfoList info_list,
CameraList l,
GPContext context 
)
Parameters:
lista CameraAbilitiesList
info_listthe GPPortInfoList of ports to use for detection
la CameraList that contains the autodetected cameras after the call
contexta GPContext

Tries to detect any camera connected to the computer using the supplied list of supported cameras and the supplied info_list of ports.

Returns:
a gphoto2 error code

Definition at line 417 of file gphoto2-abilities-list.c.

References gp_list_append(), gp_list_reset(), GP_OK, GP_PORT_DISK, gp_port_free(), gp_port_info_list_count(), gp_port_info_list_get_info(), gp_port_new(), GP_PORT_PTPIP, gp_port_set_error(), gp_port_set_info(), GP_PORT_USB, GP_PORT_USB_DISK_DIRECT, GP_PORT_USB_SCSI, CameraAbilities::model, _GPPortInfo::path, and _GPPortInfo::type.

Referenced by gp_camera_init().

{
      GPPortInfo info;
      GPPort *port;
      int i, info_count;

      CHECK_NULL (list && info_list && l);

      gp_list_reset (l);

      CHECK_RESULT (info_count = gp_port_info_list_count (info_list));

      CHECK_RESULT (gp_port_new (&port));
      for (i = 0; i < info_count; i++) {
            int res;

            CHECK_RESULT (gp_port_info_list_get_info (info_list, i, &info));
            CHECK_RESULT (gp_port_set_info (port, info));
            switch (info.type) {
            case GP_PORT_USB:
            case GP_PORT_USB_SCSI:
            case GP_PORT_USB_DISK_DIRECT: {
                  int ability;
                  res = gp_abilities_list_detect_usb (list, &ability, port);
                  if (res == GP_OK) {
                        gp_list_append(l,
                              list->abilities[ability].model,
                              info.path);
                  } else if (res < 0)
                        gp_port_set_error (port, NULL);

                  break;
            }
            case GP_PORT_DISK: {
                  char  *s, path[1024];
                  struct stat stbuf;
            
                  s = strchr (info.path, ':');
                  if (!s)
                        break;
                  s++;
                  snprintf (path, sizeof(path), "%s/DCIM", s);
                  if (-1 == stat(path, &stbuf)) {
                        snprintf (path, sizeof(path), "%s/dcim", s);
                        if (-1 == stat(path, &stbuf))
                              continue;
                  }
                  gp_list_append (l, "Mass Storage Camera", info.path);
                  break;
            }
            case GP_PORT_PTPIP: {
                  char  *s;

                  s = strchr (info.path, ':');
                  if (!s) break;
                  s++;
                  if (!strlen(s)) break;
                  gp_list_append (l, "PTP/IP Camera", info.path);
                  break;
            }
            default:
                  /*
                   * We currently cannot detect any cameras on this
                   * port
                   */
                  break;
            }
      }

      gp_port_free (port);

      return (GP_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index